@amp-labs/react 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";var ya=e=>{throw TypeError(e)};var wo=(e,t,n)=>t.has(e)||ya("Cannot "+n);var O=(e,t,n)=>(wo(e,t,"read from private field"),n?n.call(e):t.get(e)),ae=(e,t,n)=>t.has(e)?ya("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Y=(e,t,n,r)=>(wo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),me=(e,t,n)=>(wo(e,t,"access private method"),n);var wi=(e,t,n,r)=>({set _(o){Y(e,t,o,n)},get _(){return O(e,t,r)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),w=require("react");require("react-dom");function ef(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const $=ef(w);var ri=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Yn=typeof window>"u"||"Deno"in globalThis;function Rt(){}function tf(e,t){return typeof e=="function"?e(t):e}function Lo(e){return typeof e=="number"&&e>=0&&e!==1/0}function Dc(e,t){return Math.max(e+(t||0)-Date.now(),0)}function lr(e,t){return typeof e=="function"?e(t):e}function Kt(e,t){return typeof e=="function"?e(t):e}function va(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==ys(s,t.options))return!1}else if(!Hr(t.queryKey,s))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||o&&o!==t.state.fetchStatus||i&&!i(t))}function wa(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(qr(t.options.mutationKey)!==qr(i))return!1}else if(!Hr(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function ys(e,t){return((t==null?void 0:t.queryKeyHashFn)||qr)(e)}function qr(e){return JSON.stringify(e,(t,n)=>$o(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function Hr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!Hr(e[n],t[n])):!1}function Vo(e,t){if(e===t)return e;const n=Ia(e)&&Ia(t);if(n||$o(e)&&$o(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{};let c=0;for(let u=0;u<s;u++){const d=n?u:i[u];(!n&&r.includes(d)||n)&&e[d]===void 0&&t[d]===void 0?(a[d]=void 0,c++):(a[d]=Vo(e[d],t[d]),a[d]===e[d]&&e[d]!==void 0&&c++)}return o===s&&c===o?e:a}return t}function Ko(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Ia(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function $o(e){if(!ba(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!ba(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function ba(e){return Object.prototype.toString.call(e)==="[object Object]"}function nf(e){return new Promise(t=>{setTimeout(t,e)})}function Uo(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Vo(e,t)}catch(r){console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`)}return Vo(e,t)}return t}function rf(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function of(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Mi=Symbol();function Fc(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Mi&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Mi?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Hn,In,dr,Cc,sf=(Cc=class extends ri{constructor(){super();ae(this,Hn);ae(this,In);ae(this,dr);Y(this,dr,t=>{if(!Yn&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){O(this,In)||this.setEventListener(O(this,dr))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,In))==null||t.call(this),Y(this,In,void 0))}setEventListener(t){var n;Y(this,dr,t),(n=O(this,In))==null||n.call(this),Y(this,In,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){O(this,Hn)!==t&&(Y(this,Hn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof O(this,Hn)=="boolean"?O(this,Hn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Hn=new WeakMap,In=new WeakMap,dr=new WeakMap,Cc),vs=new sf,fr,bn,pr,Oc,af=(Oc=class extends ri{constructor(){super();ae(this,fr,!0);ae(this,bn);ae(this,pr);Y(this,pr,t=>{if(!Yn&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){O(this,bn)||this.setEventListener(O(this,pr))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,bn))==null||t.call(this),Y(this,bn,void 0))}setEventListener(t){var n;Y(this,pr,t),(n=O(this,bn))==null||n.call(this),Y(this,bn,t(this.setOnline.bind(this)))}setOnline(t){O(this,fr)!==t&&(Y(this,fr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return O(this,fr)}},fr=new WeakMap,bn=new WeakMap,pr=new WeakMap,Oc),ji=new af;function qo(){let e,t;const n=new Promise((o,i)=>{e=o,t=i});n.status="pending",n.catch(()=>{});function r(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{r({status:"fulfilled",value:o}),e(o)},n.reject=o=>{r({status:"rejected",reason:o}),t(o)},n}function cf(e){return Math.min(1e3*2**e,3e4)}function Mc(e){return(e??"online")==="online"?ji.isOnline():!0}var jc=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Io(e){return e instanceof jc}function kc(e){let t=!1,n=0,r=!1,o;const i=qo(),s=y=>{var h;r||(m(new jc(y)),(h=e.abort)==null||h.call(e))},a=()=>{t=!0},c=()=>{t=!1},u=()=>vs.isFocused()&&(e.networkMode==="always"||ji.isOnline())&&e.canRun(),d=()=>Mc(e.networkMode)&&e.canRun(),f=y=>{var h;r||(r=!0,(h=e.onSuccess)==null||h.call(e,y),o==null||o(),i.resolve(y))},m=y=>{var h;r||(r=!0,(h=e.onError)==null||h.call(e,y),o==null||o(),i.reject(y))},p=()=>new Promise(y=>{var h;o=x=>{(r||u())&&y(x)},(h=e.onPause)==null||h.call(e)}).then(()=>{var y;o=void 0,r||(y=e.onContinue)==null||y.call(e)}),g=()=>{if(r)return;let y;const h=n===0?e.initialPromise:void 0;try{y=h??e.fn()}catch(x){y=Promise.reject(x)}Promise.resolve(y).then(f).catch(x=>{var S;if(r)return;const v=e.retry??(Yn?0:3),_=e.retryDelay??cf,C=typeof _=="function"?_(n,x):_,b=v===!0||typeof v=="number"&&n<v||typeof v=="function"&&v(n,x);if(t||!b){m(x);return}n++,(S=e.onFail)==null||S.call(e,n,x),nf(C).then(()=>u()?void 0:p()).then(()=>{t?m(x):g()})})};return{promise:i,cancel:s,continue:()=>(o==null||o(),i),cancelRetry:a,continueRetry:c,canStart:d,start:()=>(d()?g():p().then(g),i)}}function lf(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=a=>setTimeout(a,0);const i=a=>{t?e.push(a):o(()=>{n(a)})},s=()=>{const a=e;e=[],a.length&&o(()=>{r(()=>{a.forEach(c=>{n(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||s()}return c},batchCalls:a=>(...c)=>{i(()=>{a(...c)})},schedule:i,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{o=a}}}var et=lf(),Bn,Ec,Lc=(Ec=class{constructor(){ae(this,Bn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Lo(this.gcTime)&&Y(this,Bn,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Yn?1/0:5*60*1e3))}clearGcTimeout(){O(this,Bn)&&(clearTimeout(O(this,Bn)),Y(this,Bn,void 0))}},Bn=new WeakMap,Ec),hr,mr,Tt,ot,Zr,Wn,Lt,sn,Sc,uf=(Sc=class extends Lc{constructor(t){super();ae(this,Lt);ae(this,hr);ae(this,mr);ae(this,Tt);ae(this,ot);ae(this,Zr);ae(this,Wn);Y(this,Wn,!1),Y(this,Zr,t.defaultOptions),this.setOptions(t.options),this.observers=[],Y(this,Tt,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Y(this,hr,df(this.options)),this.state=t.state??O(this,hr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=O(this,ot))==null?void 0:t.promise}setOptions(t){this.options={...O(this,Zr),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&O(this,Tt).remove(this)}setData(t,n){const r=Uo(this.state.data,t,this.options);return me(this,Lt,sn).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){me(this,Lt,sn).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=O(this,ot))==null?void 0:r.promise;return(o=O(this,ot))==null||o.cancel(t),n?n.then(Rt).catch(Rt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(O(this,hr))}isActive(){return this.observers.some(t=>Kt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Mi||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(t=0){return this.state.isInvalidated||this.state.data===void 0||!Dc(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=O(this,ot))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=O(this,ot))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),O(this,Tt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(O(this,ot)&&(O(this,Wn)?O(this,ot).cancel({revert:!0}):O(this,ot).cancelRetry()),this.scheduleGc()),O(this,Tt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||me(this,Lt,sn).call(this,{type:"invalidate"})}fetch(t,n){var c,u,d;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(O(this,ot))return O(this,ot).continueRetry(),O(this,ot).promise}if(t&&this.setOptions(t),!this.options.queryFn){const f=this.observers.find(m=>m.options.queryFn);f&&this.setOptions(f.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(Y(this,Wn,!0),r.signal)})},i=()=>{const f=Fc(this.options,n),m={queryKey:this.queryKey,meta:this.meta};return o(m),Y(this,Wn,!1),this.options.persister?this.options.persister(f,m,this):f(m)},s={fetchOptions:n,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};o(s),(c=this.options.behavior)==null||c.onFetch(s,this),Y(this,mr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=s.fetchOptions)==null?void 0:u.meta))&&me(this,Lt,sn).call(this,{type:"fetch",meta:(d=s.fetchOptions)==null?void 0:d.meta});const a=f=>{var m,p,g,y;Io(f)&&f.silent||me(this,Lt,sn).call(this,{type:"error",error:f}),Io(f)||((p=(m=O(this,Tt).config).onError)==null||p.call(m,f,this),(y=(g=O(this,Tt).config).onSettled)==null||y.call(g,this.state.data,f,this)),this.scheduleGc()};return Y(this,ot,kc({initialPromise:n==null?void 0:n.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:f=>{var m,p,g,y;if(f===void 0){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(f)}catch(h){a(h);return}(p=(m=O(this,Tt).config).onSuccess)==null||p.call(m,f,this),(y=(g=O(this,Tt).config).onSettled)==null||y.call(g,f,this.state.error,this),this.scheduleGc()},onError:a,onFail:(f,m)=>{me(this,Lt,sn).call(this,{type:"failed",failureCount:f,error:m})},onPause:()=>{me(this,Lt,sn).call(this,{type:"pause"})},onContinue:()=>{me(this,Lt,sn).call(this,{type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0})),O(this,ot).start()}},hr=new WeakMap,mr=new WeakMap,Tt=new WeakMap,ot=new WeakMap,Zr=new WeakMap,Wn=new WeakMap,Lt=new WeakSet,sn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Vc(r.data,this.options),fetchMeta:t.meta??null};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=t.error;return Io(o)&&o.revert&&O(this,mr)?{...O(this,mr),fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),et.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),O(this,Tt).notify({query:this,type:"updated",action:t})})},Sc);function Vc(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Mc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function df(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Bt,Nc,ff=(Nc=class extends ri{constructor(t={}){super();ae(this,Bt);this.config=t,Y(this,Bt,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??ys(o,n);let s=this.get(i);return s||(s=new uf({cache:this,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){O(this,Bt).has(t.queryHash)||(O(this,Bt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=O(this,Bt).get(t.queryHash);n&&(t.destroy(),n===t&&O(this,Bt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){et.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return O(this,Bt).get(t)}getAll(){return[...O(this,Bt).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>va(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>va(t,r)):n}notify(t){et.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){et.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){et.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Bt=new WeakMap,Nc),Wt,ct,Jn,Jt,wn,Tc,pf=(Tc=class extends Lc{constructor(t){super();ae(this,Jt);ae(this,Wt);ae(this,ct);ae(this,Jn);this.mutationId=t.mutationId,Y(this,ct,t.mutationCache),Y(this,Wt,[]),this.state=t.state||hf(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){O(this,Wt).includes(t)||(O(this,Wt).push(t),this.clearGcTimeout(),O(this,ct).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Y(this,Wt,O(this,Wt).filter(n=>n!==t)),this.scheduleGc(),O(this,ct).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){O(this,Wt).length||(this.state.status==="pending"?this.scheduleGc():O(this,ct).remove(this))}continue(){var t;return((t=O(this,Jn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,s,a,c,u,d,f,m,p,g,y,h,x,v,_,C,b,S,R;Y(this,Jn,kc({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(N,M)=>{me(this,Jt,wn).call(this,{type:"failed",failureCount:N,error:M})},onPause:()=>{me(this,Jt,wn).call(this,{type:"pause"})},onContinue:()=>{me(this,Jt,wn).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>O(this,ct).canRun(this)}));const n=this.state.status==="pending",r=!O(this,Jn).canStart();try{if(!n){me(this,Jt,wn).call(this,{type:"pending",variables:t,isPaused:r}),await((i=(o=O(this,ct).config).onMutate)==null?void 0:i.call(o,t,this));const M=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));M!==this.state.context&&me(this,Jt,wn).call(this,{type:"pending",context:M,variables:t,isPaused:r})}const N=await O(this,Jn).start();return await((u=(c=O(this,ct).config).onSuccess)==null?void 0:u.call(c,N,t,this.state.context,this)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,N,t,this.state.context)),await((p=(m=O(this,ct).config).onSettled)==null?void 0:p.call(m,N,null,this.state.variables,this.state.context,this)),await((y=(g=this.options).onSettled)==null?void 0:y.call(g,N,null,t,this.state.context)),me(this,Jt,wn).call(this,{type:"success",data:N}),N}catch(N){try{throw await((x=(h=O(this,ct).config).onError)==null?void 0:x.call(h,N,t,this.state.context,this)),await((_=(v=this.options).onError)==null?void 0:_.call(v,N,t,this.state.context)),await((b=(C=O(this,ct).config).onSettled)==null?void 0:b.call(C,void 0,N,this.state.variables,this.state.context,this)),await((R=(S=this.options).onSettled)==null?void 0:R.call(S,void 0,N,t,this.state.context)),N}finally{me(this,Jt,wn).call(this,{type:"error",error:N})}}finally{O(this,ct).runNext(this)}}},Wt=new WeakMap,ct=new WeakMap,Jn=new WeakMap,Jt=new WeakSet,wn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),et.batch(()=>{O(this,Wt).forEach(r=>{r.onMutationUpdate(t)}),O(this,ct).notify({mutation:this,type:"updated",action:t})})},Tc);function hf(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var an,Vt,ei,Rc,mf=(Rc=class extends ri{constructor(t={}){super();ae(this,an);ae(this,Vt);ae(this,ei);this.config=t,Y(this,an,new Set),Y(this,Vt,new Map),Y(this,ei,0)}build(t,n,r){const o=new pf({mutationCache:this,mutationId:++wi(this,ei)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){O(this,an).add(t);const n=Ii(t);if(typeof n=="string"){const r=O(this,Vt).get(n);r?r.push(t):O(this,Vt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(O(this,an).delete(t)){const n=Ii(t);if(typeof n=="string"){const r=O(this,Vt).get(n);if(r)if(r.length>1){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}else r[0]===t&&O(this,Vt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Ii(t);if(typeof n=="string"){const r=O(this,Vt).get(n),o=r==null?void 0:r.find(i=>i.state.status==="pending");return!o||o===t}else return!0}runNext(t){var r;const n=Ii(t);if(typeof n=="string"){const o=(r=O(this,Vt).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){et.batch(()=>{O(this,an).forEach(t=>{this.notify({type:"removed",mutation:t})}),O(this,an).clear(),O(this,Vt).clear()})}getAll(){return Array.from(O(this,an))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>wa(n,r))}findAll(t={}){return this.getAll().filter(n=>wa(t,n))}notify(t){et.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return et.batch(()=>Promise.all(t.map(n=>n.continue().catch(Rt))))}},an=new WeakMap,Vt=new WeakMap,ei=new WeakMap,Rc);function Ii(e){var t;return(t=e.options.scope)==null?void 0:t.id}function _a(e){return{onFetch:(t,n)=>{var d,f,m,p,g;const r=t.options,o=(m=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:m.direction,i=((p=t.state.data)==null?void 0:p.pages)||[],s=((g=t.state.data)==null?void 0:g.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const u=async()=>{let y=!1;const h=_=>{Object.defineProperty(_,"signal",{enumerable:!0,get:()=>(t.signal.aborted?y=!0:t.signal.addEventListener("abort",()=>{y=!0}),t.signal)})},x=Fc(t.options,t.fetchOptions),v=async(_,C,b)=>{if(y)return Promise.reject();if(C==null&&_.pages.length)return Promise.resolve(_);const S={queryKey:t.queryKey,pageParam:C,direction:b?"backward":"forward",meta:t.options.meta};h(S);const R=await x(S),{maxPages:N}=t.options,M=b?of:rf;return{pages:M(_.pages,R,N),pageParams:M(_.pageParams,C,N)}};if(o&&i.length){const _=o==="backward",C=_?gf:xa,b={pages:i,pageParams:s},S=C(r,b);a=await v(b,S,_)}else{const _=e??i.length;do{const C=c===0?s[0]??r.initialPageParam:xa(r,a);if(c>0&&C==null)break;a=await v(a,C),c++}while(c<_)}return a};t.options.persister?t.fetchFn=()=>{var y,h;return(h=(y=t.options).persister)==null?void 0:h.call(y,u,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function xa(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function gf(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var Me,_n,xn,gr,yr,Cn,vr,wr,Ac,yf=(Ac=class{constructor(e={}){ae(this,Me);ae(this,_n);ae(this,xn);ae(this,gr);ae(this,yr);ae(this,Cn);ae(this,vr);ae(this,wr);Y(this,Me,e.queryCache||new ff),Y(this,_n,e.mutationCache||new mf),Y(this,xn,e.defaultOptions||{}),Y(this,gr,new Map),Y(this,yr,new Map),Y(this,Cn,0)}mount(){wi(this,Cn)._++,O(this,Cn)===1&&(Y(this,vr,vs.subscribe(async e=>{e&&(await this.resumePausedMutations(),O(this,Me).onFocus())})),Y(this,wr,ji.subscribe(async e=>{e&&(await this.resumePausedMutations(),O(this,Me).onOnline())})))}unmount(){var e,t;wi(this,Cn)._--,O(this,Cn)===0&&((e=O(this,vr))==null||e.call(this),Y(this,vr,void 0),(t=O(this,wr))==null||t.call(this),Y(this,wr,void 0))}isFetching(e){return O(this,Me).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return O(this,_n).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=O(this,Me).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=O(this,Me).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(lr(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return O(this,Me).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=O(this,Me).get(r.queryHash),i=o==null?void 0:o.state.data,s=tf(t,i);if(s!==void 0)return O(this,Me).build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return et.batch(()=>O(this,Me).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=O(this,Me).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=O(this,Me);et.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=O(this,Me),r={type:"active",...e};return et.batch(()=>(n.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries(r,t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=et.batch(()=>O(this,Me).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(Rt).catch(Rt)}invalidateQueries(e,t={}){return et.batch(()=>{if(O(this,Me).findAll(e).forEach(r=>{r.invalidate()}),(e==null?void 0:e.refetchType)==="none")return Promise.resolve();const n={...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"};return this.refetchQueries(n,t)})}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=et.batch(()=>O(this,Me).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(Rt)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Rt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=O(this,Me).build(this,t);return n.isStaleByTime(lr(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Rt).catch(Rt)}fetchInfiniteQuery(e){return e.behavior=_a(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Rt).catch(Rt)}ensureInfiniteQueryData(e){return e.behavior=_a(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ji.isOnline()?O(this,_n).resumePausedMutations():Promise.resolve()}getQueryCache(){return O(this,Me)}getMutationCache(){return O(this,_n)}getDefaultOptions(){return O(this,xn)}setDefaultOptions(e){Y(this,xn,e)}setQueryDefaults(e,t){O(this,gr).set(qr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...O(this,gr).values()],n={};return t.forEach(r=>{Hr(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){O(this,yr).set(qr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...O(this,yr).values()];let n={};return t.forEach(r=>{Hr(e,r.mutationKey)&&(n={...n,...r.defaultOptions})}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...O(this,xn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ys(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Mi&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...O(this,xn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){O(this,Me).clear(),O(this,_n).clear()}},Me=new WeakMap,_n=new WeakMap,xn=new WeakMap,gr=new WeakMap,yr=new WeakMap,Cn=new WeakMap,vr=new WeakMap,wr=new WeakMap,Ac),ht,ge,ti,lt,zn,Ir,On,zt,ni,br,_r,Gn,Xn,En,xr,Oe,Vr,Ho,Bo,Wo,Jo,zo,Go,Xo,Kc,Pc,vf=(Pc=class extends ri{constructor(t,n){super();ae(this,Oe);ae(this,ht);ae(this,ge);ae(this,ti);ae(this,lt);ae(this,zn);ae(this,Ir);ae(this,On);ae(this,zt);ae(this,ni);ae(this,br);ae(this,_r);ae(this,Gn);ae(this,Xn);ae(this,En);ae(this,xr,new Set);this.options=n,Y(this,ht,t),Y(this,zt,null),Y(this,On,qo()),this.options.experimental_prefetchInRender||O(this,On).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(O(this,ge).addObserver(this),Ca(O(this,ge),this.options)?me(this,Oe,Vr).call(this):this.updateResult(),me(this,Oe,Jo).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Qo(O(this,ge),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Qo(O(this,ge),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,me(this,Oe,zo).call(this),me(this,Oe,Go).call(this),O(this,ge).removeObserver(this)}setOptions(t,n){const r=this.options,o=O(this,ge);if(this.options=O(this,ht).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Kt(this.options.enabled,O(this,ge))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");me(this,Oe,Xo).call(this),O(this,ge).setOptions(this.options),r._defaulted&&!Ko(this.options,r)&&O(this,ht).getQueryCache().notify({type:"observerOptionsUpdated",query:O(this,ge),observer:this});const i=this.hasListeners();i&&Oa(O(this,ge),o,this.options,r)&&me(this,Oe,Vr).call(this),this.updateResult(n),i&&(O(this,ge)!==o||Kt(this.options.enabled,O(this,ge))!==Kt(r.enabled,O(this,ge))||lr(this.options.staleTime,O(this,ge))!==lr(r.staleTime,O(this,ge)))&&me(this,Oe,Ho).call(this);const s=me(this,Oe,Bo).call(this);i&&(O(this,ge)!==o||Kt(this.options.enabled,O(this,ge))!==Kt(r.enabled,O(this,ge))||s!==O(this,En))&&me(this,Oe,Wo).call(this,s)}getOptimisticResult(t){const n=O(this,ht).getQueryCache().build(O(this,ht),t),r=this.createResult(n,t);return If(this,r)&&(Y(this,lt,r),Y(this,Ir,this.options),Y(this,zn,O(this,ge).state)),r}getCurrentResult(){return O(this,lt)}trackResult(t,n){const r={};return Object.keys(t).forEach(o=>{Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(o),n==null||n(o),t[o])})}),r}trackProp(t){O(this,xr).add(t)}getCurrentQuery(){return O(this,ge)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=O(this,ht).defaultQueryOptions(t),r=O(this,ht).getQueryCache().build(O(this,ht),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return me(this,Oe,Vr).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),O(this,lt)))}createResult(t,n){var N;const r=O(this,ge),o=this.options,i=O(this,lt),s=O(this,zn),a=O(this,Ir),u=t!==r?t.state:O(this,ti),{state:d}=t;let f={...d},m=!1,p;if(n._optimisticResults){const M=this.hasListeners(),U=!M&&Ca(t,n),q=M&&Oa(t,r,n,o);(U||q)&&(f={...f,...Vc(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:g,errorUpdatedAt:y,status:h}=f;if(n.select&&f.data!==void 0)if(i&&f.data===(s==null?void 0:s.data)&&n.select===O(this,ni))p=O(this,br);else try{Y(this,ni,n.select),p=n.select(f.data),p=Uo(i==null?void 0:i.data,p,n),Y(this,br,p),Y(this,zt,null)}catch(M){Y(this,zt,M)}else p=f.data;if(n.placeholderData!==void 0&&p===void 0&&h==="pending"){let M;if(i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))M=i.data;else if(M=typeof n.placeholderData=="function"?n.placeholderData((N=O(this,_r))==null?void 0:N.state.data,O(this,_r)):n.placeholderData,n.select&&M!==void 0)try{M=n.select(M),Y(this,zt,null)}catch(U){Y(this,zt,U)}M!==void 0&&(h="success",p=Uo(i==null?void 0:i.data,M,n),m=!0)}O(this,zt)&&(g=O(this,zt),p=O(this,br),y=Date.now(),h="error");const x=f.fetchStatus==="fetching",v=h==="pending",_=h==="error",C=v&&x,b=p!==void 0,R={status:h,fetchStatus:f.fetchStatus,isPending:v,isSuccess:h==="success",isError:_,isInitialLoading:C,isLoading:C,data:p,dataUpdatedAt:f.dataUpdatedAt,error:g,errorUpdatedAt:y,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:x,isRefetching:x&&!v,isLoadingError:_&&!b,isPaused:f.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:_&&b,isStale:ws(t,n),refetch:this.refetch,promise:O(this,On)};if(this.options.experimental_prefetchInRender){const M=G=>{R.status==="error"?G.reject(R.error):R.data!==void 0&&G.resolve(R.data)},U=()=>{const G=Y(this,On,R.promise=qo());M(G)},q=O(this,On);switch(q.status){case"pending":t.queryHash===r.queryHash&&M(q);break;case"fulfilled":(R.status==="error"||R.data!==q.value)&&U();break;case"rejected":(R.status!=="error"||R.error!==q.reason)&&U();break}}return R}updateResult(t){const n=O(this,lt),r=this.createResult(O(this,ge),this.options);if(Y(this,zn,O(this,ge).state),Y(this,Ir,this.options),O(this,zn).data!==void 0&&Y(this,_r,O(this,ge)),Ko(r,n))return;Y(this,lt,r);const o={},i=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!O(this,xr).size)return!0;const c=new Set(a??O(this,xr));return this.options.throwOnError&&c.add("error"),Object.keys(O(this,lt)).some(u=>{const d=u;return O(this,lt)[d]!==n[d]&&c.has(d)})};(t==null?void 0:t.listeners)!==!1&&i()&&(o.listeners=!0),me(this,Oe,Kc).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&me(this,Oe,Jo).call(this)}},ht=new WeakMap,ge=new WeakMap,ti=new WeakMap,lt=new WeakMap,zn=new WeakMap,Ir=new WeakMap,On=new WeakMap,zt=new WeakMap,ni=new WeakMap,br=new WeakMap,_r=new WeakMap,Gn=new WeakMap,Xn=new WeakMap,En=new WeakMap,xr=new WeakMap,Oe=new WeakSet,Vr=function(t){me(this,Oe,Xo).call(this);let n=O(this,ge).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Rt)),n},Ho=function(){me(this,Oe,zo).call(this);const t=lr(this.options.staleTime,O(this,ge));if(Yn||O(this,lt).isStale||!Lo(t))return;const r=Dc(O(this,lt).dataUpdatedAt,t)+1;Y(this,Gn,setTimeout(()=>{O(this,lt).isStale||this.updateResult()},r))},Bo=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(O(this,ge)):this.options.refetchInterval)??!1},Wo=function(t){me(this,Oe,Go).call(this),Y(this,En,t),!(Yn||Kt(this.options.enabled,O(this,ge))===!1||!Lo(O(this,En))||O(this,En)===0)&&Y(this,Xn,setInterval(()=>{(this.options.refetchIntervalInBackground||vs.isFocused())&&me(this,Oe,Vr).call(this)},O(this,En)))},Jo=function(){me(this,Oe,Ho).call(this),me(this,Oe,Wo).call(this,me(this,Oe,Bo).call(this))},zo=function(){O(this,Gn)&&(clearTimeout(O(this,Gn)),Y(this,Gn,void 0))},Go=function(){O(this,Xn)&&(clearInterval(O(this,Xn)),Y(this,Xn,void 0))},Xo=function(){const t=O(this,ht).getQueryCache().build(O(this,ht),this.options);if(t===O(this,ge))return;const n=O(this,ge);Y(this,ge,t),Y(this,ti,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Kc=function(t){et.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(O(this,lt))}),O(this,ht).getQueryCache().notify({query:O(this,ge),type:"observerResultsUpdated"})})},Pc);function wf(e,t){return Kt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ca(e,t){return wf(e,t)||e.state.data!==void 0&&Qo(e,t,t.refetchOnMount)}function Qo(e,t,n){if(Kt(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&ws(e,t)}return!1}function Oa(e,t,n,r){return(e!==t||Kt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ws(e,n)}function ws(e,t){return Kt(t.enabled,e)!==!1&&e.isStaleByTime(lr(t.staleTime,e))}function If(e,t){return!Ko(e.getCurrentResult(),t)}var $c=$.createContext(void 0),bf=e=>{const t=$.useContext($c);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},_f=({client:e,children:t})=>($.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),l.jsx($c.Provider,{value:e,children:t})),Uc=$.createContext(!1),xf=()=>$.useContext(Uc);Uc.Provider;function Cf(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Of=$.createContext(Cf()),Ef=()=>$.useContext(Of);function Sf(e,t){return typeof e=="function"?e(...t):!!e}function Ea(){}var Nf=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Tf=e=>{$.useEffect(()=>{e.clearReset()},[e])},Rf=({result:e,errorResetBoundary:t,throwOnError:n,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&Sf(n,[e.error,r]),Af=e=>{const t=e.staleTime;e.suspense&&(e.staleTime=typeof t=="function"?(...n)=>Math.max(t(...n),1e3):Math.max(t??1e3,1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},Pf=(e,t)=>e.isLoading&&e.isFetching&&!t,Df=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Sa=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ff(e,t,n){var f,m,p,g,y;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=bf(),o=xf(),i=Ef(),s=r.defaultQueryOptions(e);(m=(f=r.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||m.call(f,s),s._optimisticResults=o?"isRestoring":"optimistic",Af(s),Nf(s,i),Tf(i);const a=!r.getQueryCache().get(s.queryHash),[c]=$.useState(()=>new t(r,s)),u=c.getOptimisticResult(s),d=!o&&e.subscribed!==!1;if($.useSyncExternalStore($.useCallback(h=>{const x=d?c.subscribe(et.batchCalls(h)):Ea;return c.updateResult(),x},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),$.useEffect(()=>{c.setOptions(s,{listeners:!1})},[s,c]),Df(s,u))throw Sa(s,c,i);if(Rf({result:u,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash)}))throw u.error;if((g=(p=r.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||g.call(p,s,u),s.experimental_prefetchInRender&&!Yn&&Pf(u,o)){const h=a?Sa(s,c,i):(y=r.getQueryCache().get(s.queryHash))==null?void 0:y.promise;h==null||h.catch(Ea).finally(()=>{c.updateResult()})}return s.notifyOnChangeProps?u:c.trackResult(u)}function Mf(e,t){return Ff(e,vf)}const qc=w.createContext(null),jf=qc.Provider,tt=()=>{const e=w.useContext(qc);if(e===null)throw new Error("useApiKey must be used within an ApiKeyProvider");return e};var we=(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.VALUE_MAPPING="valueMappingError",e))(we||{});const Hc=w.createContext(void 0);function Ht(){const e=w.useContext(Hc);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const kf=(()=>{const e={};return Object.values(we).forEach(t=>{e[t]={}}),e})();function Lf({children:e}){const[t,n]=w.useState(kf),r=w.useCallback((d,f,m=!0)=>{n(p=>{const g={...p};return g[d]=g[d]||{},g[d][f]=m,g})},[n]),o=w.useCallback((d,f)=>{var m;return!!((m=t[d])!=null&&m[f])},[t]),i=w.useCallback((d,f)=>{var m;return(m=t[d])==null?void 0:m[f]},[t]),s=w.useCallback((d,f)=>{n(m=>{var g;const p={...m};return(g=p[d])==null||delete g[f],p})},[n]),a=w.useCallback(d=>{n(f=>{const m={...f};return m[d]={},m})},[n]),c=w.useCallback((d,f)=>{n(m=>{const p={...m};return p[d]=p[d]||{},f.forEach(g=>{p[d][g]=!0}),p})},[n]),u=w.useMemo(()=>({errorState:t,setErrorState:n,setError:r,isError:o,removeError:s,resetBoundary:a,setErrors:c,getError:i}),[t,n,r,o,s,a,c,i]);return l.jsx(Hc.Provider,{value:u,children:e})}const Vf="https://api.withampersand.com/v1".replace(/\/+$/,"");class Is{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Vf}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Wc}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 Kf=new Is,Yi=class Yi{constructor(t=Kf){this.configuration=t,this.fetchApi=async(n,r)=>{let o={url:n,init:r};for(const s of this.middleware)s.pre&&(o=await s.pre({fetch:this.fetchApi,...o})||o);let i;try{i=await(this.configuration.fetchApi||fetch)(o.url,o.init)}catch(s){for(const a of this.middleware)a.onError&&(i=await a.onError({fetch:this.fetchApi,url:o.url,init:o.init,error:s,response:i?i.clone():void 0})||i);if(i===void 0)throw s instanceof Error?new qf(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(i=await s.post({fetch:this.fetchApi,url:o.url,init:o.init,response:i.clone()})||i);return i},this.middleware=t.middleware}withMiddleware(...t){const n=this.clone();return n.middleware=n.middleware.concat(...t),n}withPreMiddleware(...t){const n=t.map(r=>({pre:r}));return this.withMiddleware(...n)}withPostMiddleware(...t){const n=t.map(r=>({post:r}));return this.withMiddleware(...n)}isJsonMime(t){return t?Yi.jsonRegex.test(t):!1}async request(t,n){const{url:r,init:o}=await this.createFetchParams(t,n),i=await this.fetchApi(r,o);if(i&&i.status>=200&&i.status<300)return i;throw new Bc(i,"Response returned an error code")}async createFetchParams(t,n){let r=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(r+="?"+this.configuration.queryParamsStringify(t.query));const o=Object.assign({},this.configuration.headers,t.headers);Object.keys(o).forEach(u=>o[u]===void 0?delete o[u]:{});const i=typeof n=="function"?n:async()=>n,s={method:t.method,headers:o,body:t.body,credentials:this.configuration.credentials},a={...s,...await i({init:s,context:t})},c={...a,body:Uf(a.body)||a.body instanceof URLSearchParams||$f(a.body)?a.body:JSON.stringify(a.body)};return{url:r,init:c}}clone(){const t=this.constructor,n=new t(this.configuration);return n.middleware=this.middleware.slice(),n}};Yi.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let Gt=Yi;function $f(e){return typeof Blob<"u"&&e instanceof Blob}function Uf(e){return typeof FormData<"u"&&e instanceof FormData}class Bc extends Error{constructor(t,n){super(n),this.response=t,this.name="ResponseError"}}class qf extends Error{constructor(t,n){super(n),this.cause=t,this.name="FetchError"}}class se extends Error{constructor(t,n){super(n),this.field=t,this.name="RequiredError"}}function P(e,t){const n=e[t];return n!=null}function Wc(e,t=""){return Object.keys(e).map(n=>Jc(n,e[n],t)).filter(n=>n.length>0).join("&")}function Jc(e,t,n=""){const r=n+(n.length?`[${e}]`:e);if(t instanceof Array){const o=t.map(i=>encodeURIComponent(String(i))).join(`&${encodeURIComponent(r)}=`);return`${encodeURIComponent(r)}=${o}`}if(t instanceof Set){const o=Array.from(t);return Jc(e,o,n)}return t instanceof Date?`${encodeURIComponent(r)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Wc(t,r):`${encodeURIComponent(r)}=${encodeURIComponent(String(t))}`}function Zi(e,t){return Object.keys(e).reduce((n,r)=>({...n,[r]:t(e[r])}),{})}class Ke{constructor(t,n=r=>r){this.raw=t,this.transformer=n}async value(){return this.transformer(await this.raw.json())}}class Zn{constructor(t){this.raw=t}async value(){}}class Hf{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function Bf(e){return Wf(e)}function Wf(e,t){return e==null?e:{fieldUsed:P(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:P(e,"keyFormat")?e.keyFormat:void 0}}function Jf(e){return zf(e)}function zf(e,t){return e==null?e:{name:e.name,valuePrefix:P(e,"valuePrefix")?e.valuePrefix:void 0}}function Gf(e){return Xf(e)}function Xf(e,t){return e==null?e:{name:e.name}}function Qf(e){return Yf(e)}function Yf(e,t){return e==null?e:{attachmentType:e.attachmentType,query:P(e,"query")?Gf(e.query):void 0,header:P(e,"header")?Jf(e.header):void 0,docsURL:P(e,"docsURL")?e.docsURL:void 0}}function Zf(e){return ep(e)}function ep(e,t){return e}function tp(e){return np(e)}function np(e,t){return e==null?e:{days:P(e,"days")?e.days:void 0,fullHistory:P(e,"fullHistory")?e.fullHistory:void 0}}function rp(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function zc(e){return ip(e)}function ip(e,t){return e==null?e:{defaultPeriod:tp(e.defaultPeriod)}}function op(e){if(e!==void 0)return e===null?null:{defaultPeriod:rp(e.defaultPeriod)}}function sp(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function ap(e){if(e!==void 0)return e===null?null:{defaultPeriod:sp(e.defaultPeriod)}}function cp(e){return lp(e)}function lp(e,t){return e==null?e:{enabled:P(e,"enabled")?e.enabled:void 0}}function Gc(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function up(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,schedule:e.schedule,destination:e.destination,selectedFields:e.selectedFields,selectedValueMappings:e.selectedValueMappings,selectedFieldMappings:e.selectedFieldMappings,selectedFieldsAuto:e.selectedFieldsAuto,backfill:ap(e.backfill)}}function dp(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Zi(e.objects,up)}}function fp(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,selectedValueDefaults:e.selectedValueDefaults}}function pp(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Zi(e.objects,fp)}}function hp(e){return mp(e)}function mp(e,t){return e==null?e:{apiKeyAsBasic:P(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:P(e,"apiKeyAsBasicOpts")?Bf(e.apiKeyAsBasicOpts):void 0,docsURL:P(e,"docsURL")?e.docsURL:void 0}}function gp(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function bi(e){return yp(e)}function yp(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:P(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:P(e,"updateTime")?new Date(e.updateTime):void 0}}function vp(e){return wp(e)}function wp(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function Ip(e){return bp(e)}function bp(e,t){return e==null?e:{provider:e.provider,read:P(e,"read")?e.read:void 0,write:P(e,"write")?e.write:void 0,proxy:P(e,"proxy")?cp(e.proxy):void 0}}function _p(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:e.read,write:e.write,proxy:Gc(e.proxy)}}function xp(e){return Cp(e)}function Cp(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:Ip(e.content)}}function Op(e){return Ep(e)}function Ep(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:P(e,"updateTime")?new Date(e.updateTime):void 0}}function Xc(e){return Sp(e)}function Sp(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:P(e,"updateTime")?new Date(e.updateTime):void 0}}function Np(e){return Tp(e)}function Tp(e,t){return e==null?e:{token:e.token}}function Rp(e){return Ap(e)}function Ap(e,t){return e==null?e:{token:e.token}}function Pp(e){return Dp(e)}function Dp(e,t){return e==null?e:{accessToken:P(e,"accessToken")?Np(e.accessToken):void 0,refreshToken:P(e,"refreshToken")?Rp(e.refreshToken):void 0,scopes:P(e,"scopes")?e.scopes:void 0}}function Ri(e){return Fp(e)}function Fp(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:P(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:P(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:P(e,"updateTime")?new Date(e.updateTime):void 0}}function Ai(e){return Mp(e)}function Mp(e,t){return e==null?e:{id:e.id,projectId:e.projectId,provider:e.provider,providerApp:P(e,"providerApp")?Ri(e.providerApp):void 0,group:Xc(e.group),consumer:Op(e.consumer),providerWorkspaceRef:P(e,"providerWorkspaceRef")?e.providerWorkspaceRef:void 0,providerConsumerRef:P(e,"providerConsumerRef")?e.providerConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:P(e,"updateTime")?new Date(e.updateTime):void 0,authScheme:e.authScheme,status:e.status,oauth2AuthorizationCode:P(e,"oauth2AuthorizationCode")?Pp(e.oauth2AuthorizationCode):void 0}}function jp(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:_p(e.content)}}function kp(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:jp(e.config)}}function Lp(e){return Vp(e)}function Vp(e,t){return e==null?e:{enabled:P(e,"enabled")?e.enabled:void 0}}function Kp(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function $p(e){return Up(e)}function Up(e,t){return e==null?e:{mode:P(e,"mode")?e.mode:void 0,pageSize:P(e,"pageSize")?e.pageSize:void 0}}function qp(e){if(e!==void 0)return e===null?null:{mode:e.mode,pageSize:e.pageSize}}function Hp(e){let t=!0;return t=t&&"fieldName"in e,t}function Bp(e,t){return e==null?e:{fieldName:e.fieldName,mapToName:P(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:P(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function Wp(e){if(e!==void 0)return e===null?null:{fieldName:e.fieldName,mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName}}function Jp(e){let t=!0;return t=t&&"mapToName"in e,t}function Qc(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:P(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:P(e,"default")?e.default:void 0,prompt:P(e,"prompt")?e.prompt:void 0}}function zp(e){if(e!==void 0)return e===null?null:{mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName,default:e._default,prompt:e.prompt}}function Na(e){return Gp(e)}function Gp(e,t){return e==null?e:{...Bp(e),...Qc(e)}}function Ta(e){if(e!==void 0)return e===null?null:Hp(e)?Wp(e):Jp(e)?zp(e):{}}function Yc(e){return Xp(e)}function Xp(e,t){return e}function Qp(e){return Yp(e)}function Yp(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,mapToName:P(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:P(e,"mapToDisplayName")?e.mapToDisplayName:void 0,requiredFields:P(e,"requiredFields")?e.requiredFields.map(Na):void 0,optionalFields:P(e,"optionalFields")?e.optionalFields.map(Na):void 0,optionalFieldsAuto:P(e,"optionalFieldsAuto")?Yc(e.optionalFieldsAuto):void 0,backfill:P(e,"backfill")?zc(e.backfill):void 0,delivery:P(e,"delivery")?$p(e.delivery):void 0}}function Zp(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName,requiredFields:e.requiredFields===void 0?void 0:e.requiredFields.map(Ta),optionalFields:e.optionalFields===void 0?void 0:e.optionalFields.map(Ta),optionalFieldsAuto:e.optionalFieldsAuto,backfill:op(e.backfill),delivery:qp(e.delivery)}}function eh(e){return th(e)}function th(e,t){return e==null?e:{objects:P(e,"objects")?e.objects.map(Qp):void 0}}function nh(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Zp)}}function Zc(e){return rh(e)}function rh(e,t){return e==null?e:{allowAnyFields:P(e,"allowAnyFields")?e.allowAnyFields:void 0}}function ih(e){if(e!==void 0)return e===null?null:{allowAnyFields:e.allowAnyFields}}function oh(e){return sh(e)}function sh(e,t){return e==null?e:{objectName:e.objectName,inheritMapping:P(e,"inheritMapping")?e.inheritMapping:void 0,valueDefaults:P(e,"valueDefaults")?Zc(e.valueDefaults):void 0}}function ah(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,inheritMapping:e.inheritMapping,valueDefaults:ih(e.valueDefaults)}}function ch(e){return lh(e)}function lh(e,t){return e==null?e:{objects:P(e,"objects")?e.objects.map(oh):void 0}}function uh(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(ah)}}function dh(e){return fh(e)}function fh(e,t){return e==null?e:{name:e.name,displayName:P(e,"displayName")?e.displayName:void 0,provider:e.provider,read:P(e,"read")?eh(e.read):void 0,write:P(e,"write")?ch(e.write):void 0,proxy:P(e,"proxy")?Lp(e.proxy):void 0}}function ph(e){if(e!==void 0)return e===null?null:{name:e.name,displayName:e.displayName,provider:e.provider,read:nh(e.read),write:uh(e.write),proxy:Kp(e.proxy)}}function hh(e){if(e!==void 0)return e===null?null:{specVersion:e.specVersion,content:ph(e.content)}}function mh(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:hh(e.latestRevision)}}function gh(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function yh(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 vh(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function wh(e){return Ih(e)}function Ih(e,t){return e==null?e:{value:e.value,displayValue:e.displayValue}}function bh(e){return _h(e)}function _h(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,valueType:P(e,"valueType")?e.valueType:void 0,providerType:P(e,"providerType")?e.providerType:void 0,readOnly:P(e,"readOnly")?e.readOnly:void 0,values:P(e,"values")?e.values.map(wh):void 0}}function xh(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function Ch(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function Oh(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 Eh(e){if(e!==void 0)return e===null?null:{token:e.token,expiresAt:e.expiresAt===void 0?void 0:e.expiresAt.toISOString(),issuedAt:e.issuedAt===void 0?void 0:e.issuedAt.toISOString()}}function Sh(e){if(e!==void 0)return e===null?null:{token:e.token,expiresAt:e.expiresAt===void 0?void 0:e.expiresAt.toISOString(),issuedAt:e.issuedAt===void 0?void 0:e.issuedAt.toISOString()}}function Nh(e){if(e!==void 0)return e===null?null:{accessToken:Eh(e.accessToken),refreshToken:Sh(e.refreshToken),scopes:e.scopes}}function Th(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:xh(e.basicAuth),oauth2ClientCredentials:Ch(e.oauth2ClientCredentials),oauth2Password:Oh(e.oauth2Password),oauth2AuthorizationCode:Nh(e.oauth2AuthorizationCode)}}function Rh(e){return Ah(e)}function Ah(e,t){return e==null?e:{enabled:P(e,"enabled")?e.enabled:void 0}}function Ph(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,mapToName:P(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:P(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function bo(e){return Dh(e)}function Dh(e,t){return e==null?e:{...Ph(e),...Qc(e)}}function Fh(e){return Mh(e)}function Mh(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,mapToName:P(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:P(e,"mapToDisplayName")?e.mapToDisplayName:void 0,destination:e.destination,schedule:e.schedule,requiredFields:P(e,"requiredFields")?e.requiredFields.map(bo):void 0,optionalFields:P(e,"optionalFields")?e.optionalFields.map(bo):void 0,optionalFieldsAuto:P(e,"optionalFieldsAuto")?Yc(e.optionalFieldsAuto):void 0,allFields:P(e,"allFields")?e.allFields.map(bo):void 0,allFieldsMetadata:P(e,"allFieldsMetadata")?Zi(e.allFieldsMetadata,bh):void 0,backfill:P(e,"backfill")?zc(e.backfill):void 0}}function jh(e){return kh(e)}function kh(e,t){return e==null?e:{objects:P(e,"objects")?e.objects.map(Fh):void 0}}function Lh(e){return Vh(e)}function Vh(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,valueDefaults:P(e,"valueDefaults")?Zc(e.valueDefaults):void 0}}function Kh(e){return $h(e)}function $h(e,t){return e==null?e:{objects:P(e,"objects")?e.objects.map(Lh):void 0}}function Uh(e){return qh(e)}function qh(e,t){return e==null?e:{name:e.name,displayName:P(e,"displayName")?e.displayName:void 0,provider:e.provider,read:P(e,"read")?jh(e.read):void 0,write:P(e,"write")?Kh(e.write):void 0,proxy:P(e,"proxy")?Rh(e.proxy):void 0}}function Hh(e){return Bh(e)}function Bh(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Uh(e.content)}}function _i(e){return Wh(e)}function Wh(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:P(e,"group")?Xc(e.group):void 0,healthStatus:e.healthStatus,connection:Ai(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:P(e,"updateTime")?new Date(e.updateTime):void 0,config:xp(e.config)}}function Jh(e){return zh(e)}function zh(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:dh(e.content)}}function Ra(e){return Gh(e)}function Gh(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:P(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Jh(e.latestRevision)}}function Xh(e){return Qh(e)}function Qh(e,t){return e==null?e:{iconURL:P(e,"iconURL")?e.iconURL:void 0,logoURL:P(e,"logoURL")?e.logoURL:void 0}}function Yh(e){return Zh(e)}function Zh(e,t){return e==null?e:{iconURL:P(e,"iconURL")?e.iconURL:void 0,logoURL:P(e,"logoURL")?e.logoURL:void 0}}function em(e){return tm(e)}function tm(e,t){return e==null?e:{regular:P(e,"regular")?Yh(e.regular):void 0,darkMode:P(e,"darkMode")?Xh(e.darkMode):void 0}}function nm(e){return rm(e)}function rm(e,t){return e==null?e:{workspaceRefField:P(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:P(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:P(e,"scopesField")?e.scopesField:void 0}}function im(e){return om(e)}function om(e,t){return e==null?e:{grantType:e.grantType,authURL:P(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:P(e,"audience")?e.audience:void 0,tokenMetadataFields:nm(e.tokenMetadataFields),docsURL:P(e,"docsURL")?e.docsURL:void 0,authURLParams:P(e,"authURLParams")?e.authURLParams:void 0}}function sm(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,enableCSRFProtection:e.enableCSRFProtection}}function am(e){return cm(e)}function cm(e,t){return e==null?e:{bulkWrite:vp(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write}}function Aa(e){return lm(e)}function lm(e,t){return e==null?e:{name:e.name,authType:Zf(e.authType),baseURL:e.baseURL,oauth2Opts:P(e,"oauth2Opts")?im(e.oauth2Opts):void 0,apiKeyOpts:P(e,"apiKeyOpts")?Qf(e.apiKeyOpts):void 0,basicOpts:P(e,"basicOpts")?hp(e.basicOpts):void 0,support:am(e.support),providerOpts:e.providerOpts,displayName:P(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:P(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:P(e,"media")?em(e.media):void 0,labels:P(e,"labels")?e.labels:void 0}}function um(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:dp(e.read),write:pp(e.write),proxy:Gc(e.proxy)}}function dm(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:um(e.content)}}function fm(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:dm(e.config)}}function pm(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:fm(e.installation)}}function hm(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function mm(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:hm(e.project)}}function gm(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 ym(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:gm(e.providerApp)}}class vm extends Gt{async deleteConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new se("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling deleteConnection.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"DELETE",headers:o,query:r},n);return new Zn(i)}async deleteConnection(t,n){await this.deleteConnectionRaw(t,n)}async generateConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling generateConnection.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections:generate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:r,body:Th(t.generateConnectionParams)},n);return new Ke(i,s=>Ai(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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new se("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getConnection.");const r={};t.includeCreds!==void 0&&(r.includeCreds=t.includeCreds),t.includeRefreshToken!==void 0&&(r.includeRefreshToken=t.includeRefreshToken),t.refresh!==void 0&&(r.refresh=t.refresh);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"GET",headers:o,query:r},n);return new Ke(i,s=>Ai(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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listConnections.");const r={};t.provider!==void 0&&(r.provider=t.provider),t.groupRef!==void 0&&(r.groupRef=t.groupRef),t.consumerRef!==void 0&&(r.consumerRef=t.consumerRef);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Ke(i,s=>s.map(Ai))}async listConnections(t,n){return await(await this.listConnectionsRaw(t,n)).value()}}class wm extends Gt{async createInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new se("installation","Required parameter requestParameters.installation was null or undefined when calling createInstallation.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:o,query:r,body:kp(t.installation)},n);return new Ke(i,s=>_i(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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new se("installationId","Required parameter requestParameters.installationId was null or undefined when calling deleteInstallation.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=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:o,query:r},n);return new Zn(i)}async deleteInstallation(t,n){await this.deleteInstallationRaw(t,n)}async getInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new se("installationId","Required parameter requestParameters.installationId was null or undefined when calling getInstallation.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=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:o,query:r},n);return new Ke(i,s=>_i(s))}async getInstallation(t,n){return await(await this.getInstallationRaw(t,n)).value()}async listInstallationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listInstallations.");const r={};t.groupRef!==void 0&&(r.groupRef=t.groupRef);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"GET",headers:o,query:r},n);return new Ke(i,s=>s.map(_i))}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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new se("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new se("installationUpdate","Required parameter requestParameters.installationUpdate was null or undefined when calling updateInstallation.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=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:o,query:r,body:pm(t.installationUpdate)},n);return new Ke(i,s=>_i(s))}async updateInstallation(t,n){return await(await this.updateInstallationRaw(t,n)).value()}}class Im extends Gt{async batchUpsertIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations:batch".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PUT",headers:o,query:r,body:gp(t.batchUpsertIntegrationsRequest)},n);return new Ke(i,s=>s.map(Ra))}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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new se("integration","Required parameter requestParameters.integration was null or undefined when calling createIntegration.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:r,body:mh(t.integration)},n);return new Zn(i)}async createIntegration(t,n){await this.createIntegrationRaw(t,n)}async deleteIntegrationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteIntegration.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"DELETE",headers:o,query:r},n);return new Zn(i)}async deleteIntegration(t,n){await this.deleteIntegrationRaw(t,n)}async listIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listIntegrations.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Ke(i,s=>s.map(Ra))}async listIntegrations(t,n){return await(await this.listIntegrationsRaw(t,n)).value()}}class bm extends Gt{async oauthConnectRaw(t,n){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new se("connectOAuthParams","Required parameter requestParameters.connectOAuthParams was null or undefined when calling oauthConnect.");const r={},o={};o["Content-Type"]="application/json";const i=await this.request({path:"/oauth-connect",method:"POST",headers:o,query:r,body:sm(t.connectOAuthParams)},n);return this.isJsonMime(i.headers.get("content-type"))?new Ke(i):new Hf(i)}async oauthConnect(t,n){return await(await this.oauthConnectRaw(t,n)).value()}}class _m extends Gt{async createProjectRaw(t,n){if(t.project===null||t.project===void 0)throw new se("project","Required parameter requestParameters.project was null or undefined when calling createProject.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects",method:"POST",headers:o,query:r,body:gh(t.project)},n);return new Ke(i,s=>bi(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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProject.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"DELETE",headers:o,query:r},n);return new Zn(i)}async deleteProject(t,n){await this.deleteProjectRaw(t,n)}async getProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getProject.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Ke(i,s=>bi(s))}async getProject(t,n){return await(await this.getProjectRaw(t,n)).value()}async listProjectsRaw(t){const n={},r={};this.configuration&&this.configuration.apiKey&&(r["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects",method:"GET",headers:r,query:n},t);return new Ke(o,i=>i.map(bi))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new se("projectUpdate","Required parameter requestParameters.projectUpdate was null or undefined when calling updateProject.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PATCH",headers:o,query:r,body:mm(t.projectUpdate)},n);return new Ke(i,s=>bi(s))}async updateProject(t,n){return await(await this.updateProjectRaw(t,n)).value()}}class xm extends Gt{async getProviderRaw(t,n){if(t.provider===null||t.provider===void 0)throw new se("provider","Required parameter requestParameters.provider was null or undefined when calling getProvider.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/providers/{provider}".replace("{provider}",encodeURIComponent(String(t.provider))),method:"GET",headers:o,query:r},n);return new Ke(i,s=>Aa(s))}async getProvider(t,n){return await(await this.getProviderRaw(t,n)).value()}async listProvidersRaw(t){const n={},r={};this.configuration&&this.configuration.apiKey&&(r["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/providers",method:"GET",headers:r,query:n},t);return new Ke(o,i=>Zi(i,Aa))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class Cm extends Gt{async createProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new se("providerApp","Required parameter requestParameters.providerApp was null or undefined when calling createProviderApp.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:r,body:yh(t.providerApp)},n);return new Ke(i,s=>Ri(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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new se("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling deleteProviderApp.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"DELETE",headers:o,query:r},n);return new Zn(i)}async deleteProviderApp(t,n){await this.deleteProviderAppRaw(t,n)}async listProviderAppsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listProviderApps.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Ke(i,s=>s.map(Ri))}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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new se("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new se("providerAppUpdate","Required parameter requestParameters.providerAppUpdate was null or undefined when calling updateProviderApp.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"PATCH",headers:o,query:r,body:ym(t.providerAppUpdate)},n);return new Ke(i,s=>Ri(s))}async updateProviderApp(t,n){return await(await this.updateProviderAppRaw(t,n)).value()}}class Om extends Gt{async createRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/revisions".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:o,query:r,body:vh(t.revision)},n);return new Zn(i)}async createRevision(t,n){await this.createRevisionRaw(t,n)}async getHydratedRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new se("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new se("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getHydratedRevision.");const r={};t.connectionId!==void 0&&(r.connectionId=t.connectionId);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=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:o,query:r},n);return new Ke(i,s=>Hh(s))}async getHydratedRevision(t,n){return await(await this.getHydratedRevisionRaw(t,n)).value()}}class el{constructor(t){this.connectionApi=new vm(t),this.installationApi=new wm(t),this.integrationApi=new Im(t),this.oAuthApi=new bm(t),this.projectApi=new _m(t),this.providerApi=new xm(t),this.providerAppApi=new Cm(t),this.revisionApi=new Om(t)}}const tl="2.4.1",Em="v1",xi="https://api.withampersand.com";function nl(){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 xi;case"mock":return"http://127.0.0.1:4010";case"":return xi;default:return e??xi}}catch{return xi}}const Sm=(e,t)=>`${e}/${t}`;function Nm(){return Sm(nl(),Em)}const Tm=nl(),rl=Nm(),Rm=new Is({basePath:rl,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":tl}});let Am=new el(Rm);const je=()=>Am;function il(){const e=tt();return w.useCallback(async()=>{e||console.error("Unable to create API service without API key.");const n=new Is({basePath:rl,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":tl,"X-Api-Key":e}});return new el(n)},[e])}const st=async(e,t)=>{var n;if(e instanceof Bc){const{status:r,statusText:o}=e.response;console.error(r===500?"Internal Server Error (500):":r===400?"Bad Request (400):":`Error (${r}):`,o);const i=await e.response.json(),s=((n=i==null?void 0:i.causes)==null?void 0:n.join(`
1
+ "use strict";var ya=e=>{throw TypeError(e)};var wo=(e,t,n)=>t.has(e)||ya("Cannot "+n);var O=(e,t,n)=>(wo(e,t,"read from private field"),n?n.call(e):t.get(e)),ae=(e,t,n)=>t.has(e)?ya("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Y=(e,t,n,r)=>(wo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),me=(e,t,n)=>(wo(e,t,"access private method"),n);var wi=(e,t,n,r)=>({set _(o){Y(e,t,o,n)},get _(){return O(e,t,r)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),w=require("react");require("react-dom");function ef(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const $=ef(w);var ri=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Yn=typeof window>"u"||"Deno"in globalThis;function Rt(){}function tf(e,t){return typeof e=="function"?e(t):e}function Lo(e){return typeof e=="number"&&e>=0&&e!==1/0}function Dc(e,t){return Math.max(e+(t||0)-Date.now(),0)}function lr(e,t){return typeof e=="function"?e(t):e}function Kt(e,t){return typeof e=="function"?e(t):e}function va(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==ys(s,t.options))return!1}else if(!Hr(t.queryKey,s))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||o&&o!==t.state.fetchStatus||i&&!i(t))}function wa(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(qr(t.options.mutationKey)!==qr(i))return!1}else if(!Hr(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function ys(e,t){return((t==null?void 0:t.queryKeyHashFn)||qr)(e)}function qr(e){return JSON.stringify(e,(t,n)=>$o(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function Hr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!Hr(e[n],t[n])):!1}function Vo(e,t){if(e===t)return e;const n=Ia(e)&&Ia(t);if(n||$o(e)&&$o(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{};let c=0;for(let u=0;u<s;u++){const d=n?u:i[u];(!n&&r.includes(d)||n)&&e[d]===void 0&&t[d]===void 0?(a[d]=void 0,c++):(a[d]=Vo(e[d],t[d]),a[d]===e[d]&&e[d]!==void 0&&c++)}return o===s&&c===o?e:a}return t}function Ko(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Ia(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function $o(e){if(!ba(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!ba(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function ba(e){return Object.prototype.toString.call(e)==="[object Object]"}function nf(e){return new Promise(t=>{setTimeout(t,e)})}function Uo(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Vo(e,t)}catch(r){console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`)}return Vo(e,t)}return t}function rf(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function of(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Mi=Symbol();function Fc(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Mi&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Mi?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Hn,In,dr,Cc,sf=(Cc=class extends ri{constructor(){super();ae(this,Hn);ae(this,In);ae(this,dr);Y(this,dr,t=>{if(!Yn&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){O(this,In)||this.setEventListener(O(this,dr))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,In))==null||t.call(this),Y(this,In,void 0))}setEventListener(t){var n;Y(this,dr,t),(n=O(this,In))==null||n.call(this),Y(this,In,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){O(this,Hn)!==t&&(Y(this,Hn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof O(this,Hn)=="boolean"?O(this,Hn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Hn=new WeakMap,In=new WeakMap,dr=new WeakMap,Cc),vs=new sf,fr,bn,pr,Oc,af=(Oc=class extends ri{constructor(){super();ae(this,fr,!0);ae(this,bn);ae(this,pr);Y(this,pr,t=>{if(!Yn&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){O(this,bn)||this.setEventListener(O(this,pr))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,bn))==null||t.call(this),Y(this,bn,void 0))}setEventListener(t){var n;Y(this,pr,t),(n=O(this,bn))==null||n.call(this),Y(this,bn,t(this.setOnline.bind(this)))}setOnline(t){O(this,fr)!==t&&(Y(this,fr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return O(this,fr)}},fr=new WeakMap,bn=new WeakMap,pr=new WeakMap,Oc),ji=new af;function qo(){let e,t;const n=new Promise((o,i)=>{e=o,t=i});n.status="pending",n.catch(()=>{});function r(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{r({status:"fulfilled",value:o}),e(o)},n.reject=o=>{r({status:"rejected",reason:o}),t(o)},n}function cf(e){return Math.min(1e3*2**e,3e4)}function Mc(e){return(e??"online")==="online"?ji.isOnline():!0}var jc=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Io(e){return e instanceof jc}function kc(e){let t=!1,n=0,r=!1,o;const i=qo(),s=y=>{var h;r||(m(new jc(y)),(h=e.abort)==null||h.call(e))},a=()=>{t=!0},c=()=>{t=!1},u=()=>vs.isFocused()&&(e.networkMode==="always"||ji.isOnline())&&e.canRun(),d=()=>Mc(e.networkMode)&&e.canRun(),f=y=>{var h;r||(r=!0,(h=e.onSuccess)==null||h.call(e,y),o==null||o(),i.resolve(y))},m=y=>{var h;r||(r=!0,(h=e.onError)==null||h.call(e,y),o==null||o(),i.reject(y))},p=()=>new Promise(y=>{var h;o=x=>{(r||u())&&y(x)},(h=e.onPause)==null||h.call(e)}).then(()=>{var y;o=void 0,r||(y=e.onContinue)==null||y.call(e)}),g=()=>{if(r)return;let y;const h=n===0?e.initialPromise:void 0;try{y=h??e.fn()}catch(x){y=Promise.reject(x)}Promise.resolve(y).then(f).catch(x=>{var S;if(r)return;const v=e.retry??(Yn?0:3),_=e.retryDelay??cf,C=typeof _=="function"?_(n,x):_,b=v===!0||typeof v=="number"&&n<v||typeof v=="function"&&v(n,x);if(t||!b){m(x);return}n++,(S=e.onFail)==null||S.call(e,n,x),nf(C).then(()=>u()?void 0:p()).then(()=>{t?m(x):g()})})};return{promise:i,cancel:s,continue:()=>(o==null||o(),i),cancelRetry:a,continueRetry:c,canStart:d,start:()=>(d()?g():p().then(g),i)}}function lf(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=a=>setTimeout(a,0);const i=a=>{t?e.push(a):o(()=>{n(a)})},s=()=>{const a=e;e=[],a.length&&o(()=>{r(()=>{a.forEach(c=>{n(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||s()}return c},batchCalls:a=>(...c)=>{i(()=>{a(...c)})},schedule:i,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{o=a}}}var et=lf(),Bn,Ec,Lc=(Ec=class{constructor(){ae(this,Bn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Lo(this.gcTime)&&Y(this,Bn,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Yn?1/0:5*60*1e3))}clearGcTimeout(){O(this,Bn)&&(clearTimeout(O(this,Bn)),Y(this,Bn,void 0))}},Bn=new WeakMap,Ec),hr,mr,Tt,ot,Zr,Wn,Lt,sn,Sc,uf=(Sc=class extends Lc{constructor(t){super();ae(this,Lt);ae(this,hr);ae(this,mr);ae(this,Tt);ae(this,ot);ae(this,Zr);ae(this,Wn);Y(this,Wn,!1),Y(this,Zr,t.defaultOptions),this.setOptions(t.options),this.observers=[],Y(this,Tt,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Y(this,hr,df(this.options)),this.state=t.state??O(this,hr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=O(this,ot))==null?void 0:t.promise}setOptions(t){this.options={...O(this,Zr),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&O(this,Tt).remove(this)}setData(t,n){const r=Uo(this.state.data,t,this.options);return me(this,Lt,sn).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){me(this,Lt,sn).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=O(this,ot))==null?void 0:r.promise;return(o=O(this,ot))==null||o.cancel(t),n?n.then(Rt).catch(Rt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(O(this,hr))}isActive(){return this.observers.some(t=>Kt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Mi||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(t=0){return this.state.isInvalidated||this.state.data===void 0||!Dc(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=O(this,ot))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=O(this,ot))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),O(this,Tt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(O(this,ot)&&(O(this,Wn)?O(this,ot).cancel({revert:!0}):O(this,ot).cancelRetry()),this.scheduleGc()),O(this,Tt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||me(this,Lt,sn).call(this,{type:"invalidate"})}fetch(t,n){var c,u,d;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(O(this,ot))return O(this,ot).continueRetry(),O(this,ot).promise}if(t&&this.setOptions(t),!this.options.queryFn){const f=this.observers.find(m=>m.options.queryFn);f&&this.setOptions(f.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(Y(this,Wn,!0),r.signal)})},i=()=>{const f=Fc(this.options,n),m={queryKey:this.queryKey,meta:this.meta};return o(m),Y(this,Wn,!1),this.options.persister?this.options.persister(f,m,this):f(m)},s={fetchOptions:n,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};o(s),(c=this.options.behavior)==null||c.onFetch(s,this),Y(this,mr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=s.fetchOptions)==null?void 0:u.meta))&&me(this,Lt,sn).call(this,{type:"fetch",meta:(d=s.fetchOptions)==null?void 0:d.meta});const a=f=>{var m,p,g,y;Io(f)&&f.silent||me(this,Lt,sn).call(this,{type:"error",error:f}),Io(f)||((p=(m=O(this,Tt).config).onError)==null||p.call(m,f,this),(y=(g=O(this,Tt).config).onSettled)==null||y.call(g,this.state.data,f,this)),this.scheduleGc()};return Y(this,ot,kc({initialPromise:n==null?void 0:n.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:f=>{var m,p,g,y;if(f===void 0){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(f)}catch(h){a(h);return}(p=(m=O(this,Tt).config).onSuccess)==null||p.call(m,f,this),(y=(g=O(this,Tt).config).onSettled)==null||y.call(g,f,this.state.error,this),this.scheduleGc()},onError:a,onFail:(f,m)=>{me(this,Lt,sn).call(this,{type:"failed",failureCount:f,error:m})},onPause:()=>{me(this,Lt,sn).call(this,{type:"pause"})},onContinue:()=>{me(this,Lt,sn).call(this,{type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0})),O(this,ot).start()}},hr=new WeakMap,mr=new WeakMap,Tt=new WeakMap,ot=new WeakMap,Zr=new WeakMap,Wn=new WeakMap,Lt=new WeakSet,sn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Vc(r.data,this.options),fetchMeta:t.meta??null};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=t.error;return Io(o)&&o.revert&&O(this,mr)?{...O(this,mr),fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),et.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),O(this,Tt).notify({query:this,type:"updated",action:t})})},Sc);function Vc(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Mc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function df(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Bt,Nc,ff=(Nc=class extends ri{constructor(t={}){super();ae(this,Bt);this.config=t,Y(this,Bt,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??ys(o,n);let s=this.get(i);return s||(s=new uf({cache:this,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){O(this,Bt).has(t.queryHash)||(O(this,Bt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=O(this,Bt).get(t.queryHash);n&&(t.destroy(),n===t&&O(this,Bt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){et.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return O(this,Bt).get(t)}getAll(){return[...O(this,Bt).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>va(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>va(t,r)):n}notify(t){et.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){et.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){et.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Bt=new WeakMap,Nc),Wt,ct,Jn,Jt,wn,Tc,pf=(Tc=class extends Lc{constructor(t){super();ae(this,Jt);ae(this,Wt);ae(this,ct);ae(this,Jn);this.mutationId=t.mutationId,Y(this,ct,t.mutationCache),Y(this,Wt,[]),this.state=t.state||hf(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){O(this,Wt).includes(t)||(O(this,Wt).push(t),this.clearGcTimeout(),O(this,ct).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Y(this,Wt,O(this,Wt).filter(n=>n!==t)),this.scheduleGc(),O(this,ct).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){O(this,Wt).length||(this.state.status==="pending"?this.scheduleGc():O(this,ct).remove(this))}continue(){var t;return((t=O(this,Jn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,s,a,c,u,d,f,m,p,g,y,h,x,v,_,C,b,S,R;Y(this,Jn,kc({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(N,M)=>{me(this,Jt,wn).call(this,{type:"failed",failureCount:N,error:M})},onPause:()=>{me(this,Jt,wn).call(this,{type:"pause"})},onContinue:()=>{me(this,Jt,wn).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>O(this,ct).canRun(this)}));const n=this.state.status==="pending",r=!O(this,Jn).canStart();try{if(!n){me(this,Jt,wn).call(this,{type:"pending",variables:t,isPaused:r}),await((i=(o=O(this,ct).config).onMutate)==null?void 0:i.call(o,t,this));const M=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));M!==this.state.context&&me(this,Jt,wn).call(this,{type:"pending",context:M,variables:t,isPaused:r})}const N=await O(this,Jn).start();return await((u=(c=O(this,ct).config).onSuccess)==null?void 0:u.call(c,N,t,this.state.context,this)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,N,t,this.state.context)),await((p=(m=O(this,ct).config).onSettled)==null?void 0:p.call(m,N,null,this.state.variables,this.state.context,this)),await((y=(g=this.options).onSettled)==null?void 0:y.call(g,N,null,t,this.state.context)),me(this,Jt,wn).call(this,{type:"success",data:N}),N}catch(N){try{throw await((x=(h=O(this,ct).config).onError)==null?void 0:x.call(h,N,t,this.state.context,this)),await((_=(v=this.options).onError)==null?void 0:_.call(v,N,t,this.state.context)),await((b=(C=O(this,ct).config).onSettled)==null?void 0:b.call(C,void 0,N,this.state.variables,this.state.context,this)),await((R=(S=this.options).onSettled)==null?void 0:R.call(S,void 0,N,t,this.state.context)),N}finally{me(this,Jt,wn).call(this,{type:"error",error:N})}}finally{O(this,ct).runNext(this)}}},Wt=new WeakMap,ct=new WeakMap,Jn=new WeakMap,Jt=new WeakSet,wn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),et.batch(()=>{O(this,Wt).forEach(r=>{r.onMutationUpdate(t)}),O(this,ct).notify({mutation:this,type:"updated",action:t})})},Tc);function hf(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var an,Vt,ei,Rc,mf=(Rc=class extends ri{constructor(t={}){super();ae(this,an);ae(this,Vt);ae(this,ei);this.config=t,Y(this,an,new Set),Y(this,Vt,new Map),Y(this,ei,0)}build(t,n,r){const o=new pf({mutationCache:this,mutationId:++wi(this,ei)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){O(this,an).add(t);const n=Ii(t);if(typeof n=="string"){const r=O(this,Vt).get(n);r?r.push(t):O(this,Vt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(O(this,an).delete(t)){const n=Ii(t);if(typeof n=="string"){const r=O(this,Vt).get(n);if(r)if(r.length>1){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}else r[0]===t&&O(this,Vt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Ii(t);if(typeof n=="string"){const r=O(this,Vt).get(n),o=r==null?void 0:r.find(i=>i.state.status==="pending");return!o||o===t}else return!0}runNext(t){var r;const n=Ii(t);if(typeof n=="string"){const o=(r=O(this,Vt).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){et.batch(()=>{O(this,an).forEach(t=>{this.notify({type:"removed",mutation:t})}),O(this,an).clear(),O(this,Vt).clear()})}getAll(){return Array.from(O(this,an))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>wa(n,r))}findAll(t={}){return this.getAll().filter(n=>wa(t,n))}notify(t){et.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return et.batch(()=>Promise.all(t.map(n=>n.continue().catch(Rt))))}},an=new WeakMap,Vt=new WeakMap,ei=new WeakMap,Rc);function Ii(e){var t;return(t=e.options.scope)==null?void 0:t.id}function _a(e){return{onFetch:(t,n)=>{var d,f,m,p,g;const r=t.options,o=(m=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:m.direction,i=((p=t.state.data)==null?void 0:p.pages)||[],s=((g=t.state.data)==null?void 0:g.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const u=async()=>{let y=!1;const h=_=>{Object.defineProperty(_,"signal",{enumerable:!0,get:()=>(t.signal.aborted?y=!0:t.signal.addEventListener("abort",()=>{y=!0}),t.signal)})},x=Fc(t.options,t.fetchOptions),v=async(_,C,b)=>{if(y)return Promise.reject();if(C==null&&_.pages.length)return Promise.resolve(_);const S={queryKey:t.queryKey,pageParam:C,direction:b?"backward":"forward",meta:t.options.meta};h(S);const R=await x(S),{maxPages:N}=t.options,M=b?of:rf;return{pages:M(_.pages,R,N),pageParams:M(_.pageParams,C,N)}};if(o&&i.length){const _=o==="backward",C=_?gf:xa,b={pages:i,pageParams:s},S=C(r,b);a=await v(b,S,_)}else{const _=e??i.length;do{const C=c===0?s[0]??r.initialPageParam:xa(r,a);if(c>0&&C==null)break;a=await v(a,C),c++}while(c<_)}return a};t.options.persister?t.fetchFn=()=>{var y,h;return(h=(y=t.options).persister)==null?void 0:h.call(y,u,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function xa(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function gf(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var Me,_n,xn,gr,yr,Cn,vr,wr,Ac,yf=(Ac=class{constructor(e={}){ae(this,Me);ae(this,_n);ae(this,xn);ae(this,gr);ae(this,yr);ae(this,Cn);ae(this,vr);ae(this,wr);Y(this,Me,e.queryCache||new ff),Y(this,_n,e.mutationCache||new mf),Y(this,xn,e.defaultOptions||{}),Y(this,gr,new Map),Y(this,yr,new Map),Y(this,Cn,0)}mount(){wi(this,Cn)._++,O(this,Cn)===1&&(Y(this,vr,vs.subscribe(async e=>{e&&(await this.resumePausedMutations(),O(this,Me).onFocus())})),Y(this,wr,ji.subscribe(async e=>{e&&(await this.resumePausedMutations(),O(this,Me).onOnline())})))}unmount(){var e,t;wi(this,Cn)._--,O(this,Cn)===0&&((e=O(this,vr))==null||e.call(this),Y(this,vr,void 0),(t=O(this,wr))==null||t.call(this),Y(this,wr,void 0))}isFetching(e){return O(this,Me).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return O(this,_n).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=O(this,Me).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=O(this,Me).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(lr(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return O(this,Me).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=O(this,Me).get(r.queryHash),i=o==null?void 0:o.state.data,s=tf(t,i);if(s!==void 0)return O(this,Me).build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return et.batch(()=>O(this,Me).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=O(this,Me).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=O(this,Me);et.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=O(this,Me),r={type:"active",...e};return et.batch(()=>(n.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries(r,t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=et.batch(()=>O(this,Me).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(Rt).catch(Rt)}invalidateQueries(e,t={}){return et.batch(()=>{if(O(this,Me).findAll(e).forEach(r=>{r.invalidate()}),(e==null?void 0:e.refetchType)==="none")return Promise.resolve();const n={...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"};return this.refetchQueries(n,t)})}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=et.batch(()=>O(this,Me).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(Rt)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Rt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=O(this,Me).build(this,t);return n.isStaleByTime(lr(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Rt).catch(Rt)}fetchInfiniteQuery(e){return e.behavior=_a(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Rt).catch(Rt)}ensureInfiniteQueryData(e){return e.behavior=_a(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ji.isOnline()?O(this,_n).resumePausedMutations():Promise.resolve()}getQueryCache(){return O(this,Me)}getMutationCache(){return O(this,_n)}getDefaultOptions(){return O(this,xn)}setDefaultOptions(e){Y(this,xn,e)}setQueryDefaults(e,t){O(this,gr).set(qr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...O(this,gr).values()],n={};return t.forEach(r=>{Hr(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){O(this,yr).set(qr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...O(this,yr).values()];let n={};return t.forEach(r=>{Hr(e,r.mutationKey)&&(n={...n,...r.defaultOptions})}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...O(this,xn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ys(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Mi&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...O(this,xn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){O(this,Me).clear(),O(this,_n).clear()}},Me=new WeakMap,_n=new WeakMap,xn=new WeakMap,gr=new WeakMap,yr=new WeakMap,Cn=new WeakMap,vr=new WeakMap,wr=new WeakMap,Ac),ht,ge,ti,lt,zn,Ir,On,zt,ni,br,_r,Gn,Xn,En,xr,Oe,Vr,Ho,Bo,Wo,Jo,zo,Go,Xo,Kc,Pc,vf=(Pc=class extends ri{constructor(t,n){super();ae(this,Oe);ae(this,ht);ae(this,ge);ae(this,ti);ae(this,lt);ae(this,zn);ae(this,Ir);ae(this,On);ae(this,zt);ae(this,ni);ae(this,br);ae(this,_r);ae(this,Gn);ae(this,Xn);ae(this,En);ae(this,xr,new Set);this.options=n,Y(this,ht,t),Y(this,zt,null),Y(this,On,qo()),this.options.experimental_prefetchInRender||O(this,On).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(O(this,ge).addObserver(this),Ca(O(this,ge),this.options)?me(this,Oe,Vr).call(this):this.updateResult(),me(this,Oe,Jo).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Qo(O(this,ge),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Qo(O(this,ge),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,me(this,Oe,zo).call(this),me(this,Oe,Go).call(this),O(this,ge).removeObserver(this)}setOptions(t,n){const r=this.options,o=O(this,ge);if(this.options=O(this,ht).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Kt(this.options.enabled,O(this,ge))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");me(this,Oe,Xo).call(this),O(this,ge).setOptions(this.options),r._defaulted&&!Ko(this.options,r)&&O(this,ht).getQueryCache().notify({type:"observerOptionsUpdated",query:O(this,ge),observer:this});const i=this.hasListeners();i&&Oa(O(this,ge),o,this.options,r)&&me(this,Oe,Vr).call(this),this.updateResult(n),i&&(O(this,ge)!==o||Kt(this.options.enabled,O(this,ge))!==Kt(r.enabled,O(this,ge))||lr(this.options.staleTime,O(this,ge))!==lr(r.staleTime,O(this,ge)))&&me(this,Oe,Ho).call(this);const s=me(this,Oe,Bo).call(this);i&&(O(this,ge)!==o||Kt(this.options.enabled,O(this,ge))!==Kt(r.enabled,O(this,ge))||s!==O(this,En))&&me(this,Oe,Wo).call(this,s)}getOptimisticResult(t){const n=O(this,ht).getQueryCache().build(O(this,ht),t),r=this.createResult(n,t);return If(this,r)&&(Y(this,lt,r),Y(this,Ir,this.options),Y(this,zn,O(this,ge).state)),r}getCurrentResult(){return O(this,lt)}trackResult(t,n){const r={};return Object.keys(t).forEach(o=>{Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(o),n==null||n(o),t[o])})}),r}trackProp(t){O(this,xr).add(t)}getCurrentQuery(){return O(this,ge)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=O(this,ht).defaultQueryOptions(t),r=O(this,ht).getQueryCache().build(O(this,ht),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return me(this,Oe,Vr).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),O(this,lt)))}createResult(t,n){var N;const r=O(this,ge),o=this.options,i=O(this,lt),s=O(this,zn),a=O(this,Ir),u=t!==r?t.state:O(this,ti),{state:d}=t;let f={...d},m=!1,p;if(n._optimisticResults){const M=this.hasListeners(),U=!M&&Ca(t,n),q=M&&Oa(t,r,n,o);(U||q)&&(f={...f,...Vc(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:g,errorUpdatedAt:y,status:h}=f;if(n.select&&f.data!==void 0)if(i&&f.data===(s==null?void 0:s.data)&&n.select===O(this,ni))p=O(this,br);else try{Y(this,ni,n.select),p=n.select(f.data),p=Uo(i==null?void 0:i.data,p,n),Y(this,br,p),Y(this,zt,null)}catch(M){Y(this,zt,M)}else p=f.data;if(n.placeholderData!==void 0&&p===void 0&&h==="pending"){let M;if(i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))M=i.data;else if(M=typeof n.placeholderData=="function"?n.placeholderData((N=O(this,_r))==null?void 0:N.state.data,O(this,_r)):n.placeholderData,n.select&&M!==void 0)try{M=n.select(M),Y(this,zt,null)}catch(U){Y(this,zt,U)}M!==void 0&&(h="success",p=Uo(i==null?void 0:i.data,M,n),m=!0)}O(this,zt)&&(g=O(this,zt),p=O(this,br),y=Date.now(),h="error");const x=f.fetchStatus==="fetching",v=h==="pending",_=h==="error",C=v&&x,b=p!==void 0,R={status:h,fetchStatus:f.fetchStatus,isPending:v,isSuccess:h==="success",isError:_,isInitialLoading:C,isLoading:C,data:p,dataUpdatedAt:f.dataUpdatedAt,error:g,errorUpdatedAt:y,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:x,isRefetching:x&&!v,isLoadingError:_&&!b,isPaused:f.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:_&&b,isStale:ws(t,n),refetch:this.refetch,promise:O(this,On)};if(this.options.experimental_prefetchInRender){const M=G=>{R.status==="error"?G.reject(R.error):R.data!==void 0&&G.resolve(R.data)},U=()=>{const G=Y(this,On,R.promise=qo());M(G)},q=O(this,On);switch(q.status){case"pending":t.queryHash===r.queryHash&&M(q);break;case"fulfilled":(R.status==="error"||R.data!==q.value)&&U();break;case"rejected":(R.status!=="error"||R.error!==q.reason)&&U();break}}return R}updateResult(t){const n=O(this,lt),r=this.createResult(O(this,ge),this.options);if(Y(this,zn,O(this,ge).state),Y(this,Ir,this.options),O(this,zn).data!==void 0&&Y(this,_r,O(this,ge)),Ko(r,n))return;Y(this,lt,r);const o={},i=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!O(this,xr).size)return!0;const c=new Set(a??O(this,xr));return this.options.throwOnError&&c.add("error"),Object.keys(O(this,lt)).some(u=>{const d=u;return O(this,lt)[d]!==n[d]&&c.has(d)})};(t==null?void 0:t.listeners)!==!1&&i()&&(o.listeners=!0),me(this,Oe,Kc).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&me(this,Oe,Jo).call(this)}},ht=new WeakMap,ge=new WeakMap,ti=new WeakMap,lt=new WeakMap,zn=new WeakMap,Ir=new WeakMap,On=new WeakMap,zt=new WeakMap,ni=new WeakMap,br=new WeakMap,_r=new WeakMap,Gn=new WeakMap,Xn=new WeakMap,En=new WeakMap,xr=new WeakMap,Oe=new WeakSet,Vr=function(t){me(this,Oe,Xo).call(this);let n=O(this,ge).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Rt)),n},Ho=function(){me(this,Oe,zo).call(this);const t=lr(this.options.staleTime,O(this,ge));if(Yn||O(this,lt).isStale||!Lo(t))return;const r=Dc(O(this,lt).dataUpdatedAt,t)+1;Y(this,Gn,setTimeout(()=>{O(this,lt).isStale||this.updateResult()},r))},Bo=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(O(this,ge)):this.options.refetchInterval)??!1},Wo=function(t){me(this,Oe,Go).call(this),Y(this,En,t),!(Yn||Kt(this.options.enabled,O(this,ge))===!1||!Lo(O(this,En))||O(this,En)===0)&&Y(this,Xn,setInterval(()=>{(this.options.refetchIntervalInBackground||vs.isFocused())&&me(this,Oe,Vr).call(this)},O(this,En)))},Jo=function(){me(this,Oe,Ho).call(this),me(this,Oe,Wo).call(this,me(this,Oe,Bo).call(this))},zo=function(){O(this,Gn)&&(clearTimeout(O(this,Gn)),Y(this,Gn,void 0))},Go=function(){O(this,Xn)&&(clearInterval(O(this,Xn)),Y(this,Xn,void 0))},Xo=function(){const t=O(this,ht).getQueryCache().build(O(this,ht),this.options);if(t===O(this,ge))return;const n=O(this,ge);Y(this,ge,t),Y(this,ti,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Kc=function(t){et.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(O(this,lt))}),O(this,ht).getQueryCache().notify({query:O(this,ge),type:"observerResultsUpdated"})})},Pc);function wf(e,t){return Kt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ca(e,t){return wf(e,t)||e.state.data!==void 0&&Qo(e,t,t.refetchOnMount)}function Qo(e,t,n){if(Kt(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&ws(e,t)}return!1}function Oa(e,t,n,r){return(e!==t||Kt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ws(e,n)}function ws(e,t){return Kt(t.enabled,e)!==!1&&e.isStaleByTime(lr(t.staleTime,e))}function If(e,t){return!Ko(e.getCurrentResult(),t)}var $c=$.createContext(void 0),bf=e=>{const t=$.useContext($c);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},_f=({client:e,children:t})=>($.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),l.jsx($c.Provider,{value:e,children:t})),Uc=$.createContext(!1),xf=()=>$.useContext(Uc);Uc.Provider;function Cf(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Of=$.createContext(Cf()),Ef=()=>$.useContext(Of);function Sf(e,t){return typeof e=="function"?e(...t):!!e}function Ea(){}var Nf=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Tf=e=>{$.useEffect(()=>{e.clearReset()},[e])},Rf=({result:e,errorResetBoundary:t,throwOnError:n,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&Sf(n,[e.error,r]),Af=e=>{const t=e.staleTime;e.suspense&&(e.staleTime=typeof t=="function"?(...n)=>Math.max(t(...n),1e3):Math.max(t??1e3,1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},Pf=(e,t)=>e.isLoading&&e.isFetching&&!t,Df=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Sa=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ff(e,t,n){var f,m,p,g,y;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=bf(),o=xf(),i=Ef(),s=r.defaultQueryOptions(e);(m=(f=r.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||m.call(f,s),s._optimisticResults=o?"isRestoring":"optimistic",Af(s),Nf(s,i),Tf(i);const a=!r.getQueryCache().get(s.queryHash),[c]=$.useState(()=>new t(r,s)),u=c.getOptimisticResult(s),d=!o&&e.subscribed!==!1;if($.useSyncExternalStore($.useCallback(h=>{const x=d?c.subscribe(et.batchCalls(h)):Ea;return c.updateResult(),x},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),$.useEffect(()=>{c.setOptions(s,{listeners:!1})},[s,c]),Df(s,u))throw Sa(s,c,i);if(Rf({result:u,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash)}))throw u.error;if((g=(p=r.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||g.call(p,s,u),s.experimental_prefetchInRender&&!Yn&&Pf(u,o)){const h=a?Sa(s,c,i):(y=r.getQueryCache().get(s.queryHash))==null?void 0:y.promise;h==null||h.catch(Ea).finally(()=>{c.updateResult()})}return s.notifyOnChangeProps?u:c.trackResult(u)}function Mf(e,t){return Ff(e,vf)}const qc=w.createContext(null),jf=qc.Provider,tt=()=>{const e=w.useContext(qc);if(e===null)throw new Error("useApiKey must be used within an ApiKeyProvider");return e};var we=(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.VALUE_MAPPING="valueMappingError",e))(we||{});const Hc=w.createContext(void 0);function Ht(){const e=w.useContext(Hc);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const kf=(()=>{const e={};return Object.values(we).forEach(t=>{e[t]={}}),e})();function Lf({children:e}){const[t,n]=w.useState(kf),r=w.useCallback((d,f,m=!0)=>{n(p=>{const g={...p};return g[d]=g[d]||{},g[d][f]=m,g})},[n]),o=w.useCallback((d,f)=>{var m;return!!((m=t[d])!=null&&m[f])},[t]),i=w.useCallback((d,f)=>{var m;return(m=t[d])==null?void 0:m[f]},[t]),s=w.useCallback((d,f)=>{n(m=>{var g;const p={...m};return(g=p[d])==null||delete g[f],p})},[n]),a=w.useCallback(d=>{n(f=>{const m={...f};return m[d]={},m})},[n]),c=w.useCallback((d,f)=>{n(m=>{const p={...m};return p[d]=p[d]||{},f.forEach(g=>{p[d][g]=!0}),p})},[n]),u=w.useMemo(()=>({errorState:t,setErrorState:n,setError:r,isError:o,removeError:s,resetBoundary:a,setErrors:c,getError:i}),[t,n,r,o,s,a,c,i]);return l.jsx(Hc.Provider,{value:u,children:e})}const Vf="https://api.withampersand.com/v1".replace(/\/+$/,"");class Is{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Vf}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Wc}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 Kf=new Is,Yi=class Yi{constructor(t=Kf){this.configuration=t,this.fetchApi=async(n,r)=>{let o={url:n,init:r};for(const s of this.middleware)s.pre&&(o=await s.pre({fetch:this.fetchApi,...o})||o);let i;try{i=await(this.configuration.fetchApi||fetch)(o.url,o.init)}catch(s){for(const a of this.middleware)a.onError&&(i=await a.onError({fetch:this.fetchApi,url:o.url,init:o.init,error:s,response:i?i.clone():void 0})||i);if(i===void 0)throw s instanceof Error?new qf(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(i=await s.post({fetch:this.fetchApi,url:o.url,init:o.init,response:i.clone()})||i);return i},this.middleware=t.middleware}withMiddleware(...t){const n=this.clone();return n.middleware=n.middleware.concat(...t),n}withPreMiddleware(...t){const n=t.map(r=>({pre:r}));return this.withMiddleware(...n)}withPostMiddleware(...t){const n=t.map(r=>({post:r}));return this.withMiddleware(...n)}isJsonMime(t){return t?Yi.jsonRegex.test(t):!1}async request(t,n){const{url:r,init:o}=await this.createFetchParams(t,n),i=await this.fetchApi(r,o);if(i&&i.status>=200&&i.status<300)return i;throw new Bc(i,"Response returned an error code")}async createFetchParams(t,n){let r=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(r+="?"+this.configuration.queryParamsStringify(t.query));const o=Object.assign({},this.configuration.headers,t.headers);Object.keys(o).forEach(u=>o[u]===void 0?delete o[u]:{});const i=typeof n=="function"?n:async()=>n,s={method:t.method,headers:o,body:t.body,credentials:this.configuration.credentials},a={...s,...await i({init:s,context:t})},c={...a,body:Uf(a.body)||a.body instanceof URLSearchParams||$f(a.body)?a.body:JSON.stringify(a.body)};return{url:r,init:c}}clone(){const t=this.constructor,n=new t(this.configuration);return n.middleware=this.middleware.slice(),n}};Yi.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let Gt=Yi;function $f(e){return typeof Blob<"u"&&e instanceof Blob}function Uf(e){return typeof FormData<"u"&&e instanceof FormData}class Bc extends Error{constructor(t,n){super(n),this.response=t,this.name="ResponseError"}}class qf extends Error{constructor(t,n){super(n),this.cause=t,this.name="FetchError"}}class se extends Error{constructor(t,n){super(n),this.field=t,this.name="RequiredError"}}function P(e,t){const n=e[t];return n!=null}function Wc(e,t=""){return Object.keys(e).map(n=>Jc(n,e[n],t)).filter(n=>n.length>0).join("&")}function Jc(e,t,n=""){const r=n+(n.length?`[${e}]`:e);if(t instanceof Array){const o=t.map(i=>encodeURIComponent(String(i))).join(`&${encodeURIComponent(r)}=`);return`${encodeURIComponent(r)}=${o}`}if(t instanceof Set){const o=Array.from(t);return Jc(e,o,n)}return t instanceof Date?`${encodeURIComponent(r)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Wc(t,r):`${encodeURIComponent(r)}=${encodeURIComponent(String(t))}`}function Zi(e,t){return Object.keys(e).reduce((n,r)=>({...n,[r]:t(e[r])}),{})}class Ke{constructor(t,n=r=>r){this.raw=t,this.transformer=n}async value(){return this.transformer(await this.raw.json())}}class Zn{constructor(t){this.raw=t}async value(){}}class Hf{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function Bf(e){return Wf(e)}function Wf(e,t){return e==null?e:{fieldUsed:P(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:P(e,"keyFormat")?e.keyFormat:void 0}}function Jf(e){return zf(e)}function zf(e,t){return e==null?e:{name:e.name,valuePrefix:P(e,"valuePrefix")?e.valuePrefix:void 0}}function Gf(e){return Xf(e)}function Xf(e,t){return e==null?e:{name:e.name}}function Qf(e){return Yf(e)}function Yf(e,t){return e==null?e:{attachmentType:e.attachmentType,query:P(e,"query")?Gf(e.query):void 0,header:P(e,"header")?Jf(e.header):void 0,docsURL:P(e,"docsURL")?e.docsURL:void 0}}function Zf(e){return ep(e)}function ep(e,t){return e}function tp(e){return np(e)}function np(e,t){return e==null?e:{days:P(e,"days")?e.days:void 0,fullHistory:P(e,"fullHistory")?e.fullHistory:void 0}}function rp(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function zc(e){return ip(e)}function ip(e,t){return e==null?e:{defaultPeriod:tp(e.defaultPeriod)}}function op(e){if(e!==void 0)return e===null?null:{defaultPeriod:rp(e.defaultPeriod)}}function sp(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function ap(e){if(e!==void 0)return e===null?null:{defaultPeriod:sp(e.defaultPeriod)}}function cp(e){return lp(e)}function lp(e,t){return e==null?e:{enabled:P(e,"enabled")?e.enabled:void 0}}function Gc(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function up(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,schedule:e.schedule,destination:e.destination,selectedFields:e.selectedFields,selectedValueMappings:e.selectedValueMappings,selectedFieldMappings:e.selectedFieldMappings,selectedFieldsAuto:e.selectedFieldsAuto,backfill:ap(e.backfill)}}function dp(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Zi(e.objects,up)}}function fp(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,selectedValueDefaults:e.selectedValueDefaults}}function pp(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Zi(e.objects,fp)}}function hp(e){return mp(e)}function mp(e,t){return e==null?e:{apiKeyAsBasic:P(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:P(e,"apiKeyAsBasicOpts")?Bf(e.apiKeyAsBasicOpts):void 0,docsURL:P(e,"docsURL")?e.docsURL:void 0}}function gp(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function bi(e){return yp(e)}function yp(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:P(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:P(e,"updateTime")?new Date(e.updateTime):void 0}}function vp(e){return wp(e)}function wp(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function Ip(e){return bp(e)}function bp(e,t){return e==null?e:{provider:e.provider,read:P(e,"read")?e.read:void 0,write:P(e,"write")?e.write:void 0,proxy:P(e,"proxy")?cp(e.proxy):void 0}}function _p(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:e.read,write:e.write,proxy:Gc(e.proxy)}}function xp(e){return Cp(e)}function Cp(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:Ip(e.content)}}function Op(e){return Ep(e)}function Ep(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:P(e,"updateTime")?new Date(e.updateTime):void 0}}function Xc(e){return Sp(e)}function Sp(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:P(e,"updateTime")?new Date(e.updateTime):void 0}}function Np(e){return Tp(e)}function Tp(e,t){return e==null?e:{token:e.token}}function Rp(e){return Ap(e)}function Ap(e,t){return e==null?e:{token:e.token}}function Pp(e){return Dp(e)}function Dp(e,t){return e==null?e:{accessToken:P(e,"accessToken")?Np(e.accessToken):void 0,refreshToken:P(e,"refreshToken")?Rp(e.refreshToken):void 0,scopes:P(e,"scopes")?e.scopes:void 0}}function Ri(e){return Fp(e)}function Fp(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:P(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:P(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:P(e,"updateTime")?new Date(e.updateTime):void 0}}function Ai(e){return Mp(e)}function Mp(e,t){return e==null?e:{id:e.id,projectId:e.projectId,provider:e.provider,providerApp:P(e,"providerApp")?Ri(e.providerApp):void 0,group:Xc(e.group),consumer:Op(e.consumer),providerWorkspaceRef:P(e,"providerWorkspaceRef")?e.providerWorkspaceRef:void 0,providerConsumerRef:P(e,"providerConsumerRef")?e.providerConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:P(e,"updateTime")?new Date(e.updateTime):void 0,authScheme:e.authScheme,status:e.status,oauth2AuthorizationCode:P(e,"oauth2AuthorizationCode")?Pp(e.oauth2AuthorizationCode):void 0}}function jp(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:_p(e.content)}}function kp(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:jp(e.config)}}function Lp(e){return Vp(e)}function Vp(e,t){return e==null?e:{enabled:P(e,"enabled")?e.enabled:void 0}}function Kp(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function $p(e){return Up(e)}function Up(e,t){return e==null?e:{mode:P(e,"mode")?e.mode:void 0,pageSize:P(e,"pageSize")?e.pageSize:void 0}}function qp(e){if(e!==void 0)return e===null?null:{mode:e.mode,pageSize:e.pageSize}}function Hp(e){let t=!0;return t=t&&"fieldName"in e,t}function Bp(e,t){return e==null?e:{fieldName:e.fieldName,mapToName:P(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:P(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function Wp(e){if(e!==void 0)return e===null?null:{fieldName:e.fieldName,mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName}}function Jp(e){let t=!0;return t=t&&"mapToName"in e,t}function Qc(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:P(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:P(e,"default")?e.default:void 0,prompt:P(e,"prompt")?e.prompt:void 0}}function zp(e){if(e!==void 0)return e===null?null:{mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName,default:e._default,prompt:e.prompt}}function Na(e){return Gp(e)}function Gp(e,t){return e==null?e:{...Bp(e),...Qc(e)}}function Ta(e){if(e!==void 0)return e===null?null:Hp(e)?Wp(e):Jp(e)?zp(e):{}}function Yc(e){return Xp(e)}function Xp(e,t){return e}function Qp(e){return Yp(e)}function Yp(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,mapToName:P(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:P(e,"mapToDisplayName")?e.mapToDisplayName:void 0,requiredFields:P(e,"requiredFields")?e.requiredFields.map(Na):void 0,optionalFields:P(e,"optionalFields")?e.optionalFields.map(Na):void 0,optionalFieldsAuto:P(e,"optionalFieldsAuto")?Yc(e.optionalFieldsAuto):void 0,backfill:P(e,"backfill")?zc(e.backfill):void 0,delivery:P(e,"delivery")?$p(e.delivery):void 0}}function Zp(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName,requiredFields:e.requiredFields===void 0?void 0:e.requiredFields.map(Ta),optionalFields:e.optionalFields===void 0?void 0:e.optionalFields.map(Ta),optionalFieldsAuto:e.optionalFieldsAuto,backfill:op(e.backfill),delivery:qp(e.delivery)}}function eh(e){return th(e)}function th(e,t){return e==null?e:{objects:P(e,"objects")?e.objects.map(Qp):void 0}}function nh(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Zp)}}function Zc(e){return rh(e)}function rh(e,t){return e==null?e:{allowAnyFields:P(e,"allowAnyFields")?e.allowAnyFields:void 0}}function ih(e){if(e!==void 0)return e===null?null:{allowAnyFields:e.allowAnyFields}}function oh(e){return sh(e)}function sh(e,t){return e==null?e:{objectName:e.objectName,inheritMapping:P(e,"inheritMapping")?e.inheritMapping:void 0,valueDefaults:P(e,"valueDefaults")?Zc(e.valueDefaults):void 0}}function ah(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,inheritMapping:e.inheritMapping,valueDefaults:ih(e.valueDefaults)}}function ch(e){return lh(e)}function lh(e,t){return e==null?e:{objects:P(e,"objects")?e.objects.map(oh):void 0}}function uh(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(ah)}}function dh(e){return fh(e)}function fh(e,t){return e==null?e:{name:e.name,displayName:P(e,"displayName")?e.displayName:void 0,provider:e.provider,read:P(e,"read")?eh(e.read):void 0,write:P(e,"write")?ch(e.write):void 0,proxy:P(e,"proxy")?Lp(e.proxy):void 0}}function ph(e){if(e!==void 0)return e===null?null:{name:e.name,displayName:e.displayName,provider:e.provider,read:nh(e.read),write:uh(e.write),proxy:Kp(e.proxy)}}function hh(e){if(e!==void 0)return e===null?null:{specVersion:e.specVersion,content:ph(e.content)}}function mh(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:hh(e.latestRevision)}}function gh(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function yh(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 vh(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function wh(e){return Ih(e)}function Ih(e,t){return e==null?e:{value:e.value,displayValue:e.displayValue}}function bh(e){return _h(e)}function _h(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,valueType:P(e,"valueType")?e.valueType:void 0,providerType:P(e,"providerType")?e.providerType:void 0,readOnly:P(e,"readOnly")?e.readOnly:void 0,values:P(e,"values")?e.values.map(wh):void 0}}function xh(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function Ch(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function Oh(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 Eh(e){if(e!==void 0)return e===null?null:{token:e.token,expiresAt:e.expiresAt===void 0?void 0:e.expiresAt.toISOString(),issuedAt:e.issuedAt===void 0?void 0:e.issuedAt.toISOString()}}function Sh(e){if(e!==void 0)return e===null?null:{token:e.token,expiresAt:e.expiresAt===void 0?void 0:e.expiresAt.toISOString(),issuedAt:e.issuedAt===void 0?void 0:e.issuedAt.toISOString()}}function Nh(e){if(e!==void 0)return e===null?null:{accessToken:Eh(e.accessToken),refreshToken:Sh(e.refreshToken),scopes:e.scopes}}function Th(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:xh(e.basicAuth),oauth2ClientCredentials:Ch(e.oauth2ClientCredentials),oauth2Password:Oh(e.oauth2Password),oauth2AuthorizationCode:Nh(e.oauth2AuthorizationCode)}}function Rh(e){return Ah(e)}function Ah(e,t){return e==null?e:{enabled:P(e,"enabled")?e.enabled:void 0}}function Ph(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,mapToName:P(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:P(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function bo(e){return Dh(e)}function Dh(e,t){return e==null?e:{...Ph(e),...Qc(e)}}function Fh(e){return Mh(e)}function Mh(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,mapToName:P(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:P(e,"mapToDisplayName")?e.mapToDisplayName:void 0,destination:e.destination,schedule:e.schedule,requiredFields:P(e,"requiredFields")?e.requiredFields.map(bo):void 0,optionalFields:P(e,"optionalFields")?e.optionalFields.map(bo):void 0,optionalFieldsAuto:P(e,"optionalFieldsAuto")?Yc(e.optionalFieldsAuto):void 0,allFields:P(e,"allFields")?e.allFields.map(bo):void 0,allFieldsMetadata:P(e,"allFieldsMetadata")?Zi(e.allFieldsMetadata,bh):void 0,backfill:P(e,"backfill")?zc(e.backfill):void 0}}function jh(e){return kh(e)}function kh(e,t){return e==null?e:{objects:P(e,"objects")?e.objects.map(Fh):void 0}}function Lh(e){return Vh(e)}function Vh(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,valueDefaults:P(e,"valueDefaults")?Zc(e.valueDefaults):void 0}}function Kh(e){return $h(e)}function $h(e,t){return e==null?e:{objects:P(e,"objects")?e.objects.map(Lh):void 0}}function Uh(e){return qh(e)}function qh(e,t){return e==null?e:{name:e.name,displayName:P(e,"displayName")?e.displayName:void 0,provider:e.provider,read:P(e,"read")?jh(e.read):void 0,write:P(e,"write")?Kh(e.write):void 0,proxy:P(e,"proxy")?Rh(e.proxy):void 0}}function Hh(e){return Bh(e)}function Bh(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Uh(e.content)}}function _i(e){return Wh(e)}function Wh(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:P(e,"group")?Xc(e.group):void 0,healthStatus:e.healthStatus,connection:Ai(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:P(e,"updateTime")?new Date(e.updateTime):void 0,config:xp(e.config)}}function Jh(e){return zh(e)}function zh(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:dh(e.content)}}function Ra(e){return Gh(e)}function Gh(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:P(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Jh(e.latestRevision)}}function Xh(e){return Qh(e)}function Qh(e,t){return e==null?e:{iconURL:P(e,"iconURL")?e.iconURL:void 0,logoURL:P(e,"logoURL")?e.logoURL:void 0}}function Yh(e){return Zh(e)}function Zh(e,t){return e==null?e:{iconURL:P(e,"iconURL")?e.iconURL:void 0,logoURL:P(e,"logoURL")?e.logoURL:void 0}}function em(e){return tm(e)}function tm(e,t){return e==null?e:{regular:P(e,"regular")?Yh(e.regular):void 0,darkMode:P(e,"darkMode")?Xh(e.darkMode):void 0}}function nm(e){return rm(e)}function rm(e,t){return e==null?e:{workspaceRefField:P(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:P(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:P(e,"scopesField")?e.scopesField:void 0}}function im(e){return om(e)}function om(e,t){return e==null?e:{grantType:e.grantType,authURL:P(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:P(e,"audience")?e.audience:void 0,tokenMetadataFields:nm(e.tokenMetadataFields),docsURL:P(e,"docsURL")?e.docsURL:void 0,authURLParams:P(e,"authURLParams")?e.authURLParams:void 0}}function sm(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,enableCSRFProtection:e.enableCSRFProtection}}function am(e){return cm(e)}function cm(e,t){return e==null?e:{bulkWrite:vp(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write}}function Aa(e){return lm(e)}function lm(e,t){return e==null?e:{name:e.name,authType:Zf(e.authType),baseURL:e.baseURL,oauth2Opts:P(e,"oauth2Opts")?im(e.oauth2Opts):void 0,apiKeyOpts:P(e,"apiKeyOpts")?Qf(e.apiKeyOpts):void 0,basicOpts:P(e,"basicOpts")?hp(e.basicOpts):void 0,support:am(e.support),providerOpts:e.providerOpts,displayName:P(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:P(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:P(e,"media")?em(e.media):void 0,labels:P(e,"labels")?e.labels:void 0}}function um(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:dp(e.read),write:pp(e.write),proxy:Gc(e.proxy)}}function dm(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:um(e.content)}}function fm(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:dm(e.config)}}function pm(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:fm(e.installation)}}function hm(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function mm(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:hm(e.project)}}function gm(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 ym(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:gm(e.providerApp)}}class vm extends Gt{async deleteConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new se("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling deleteConnection.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"DELETE",headers:o,query:r},n);return new Zn(i)}async deleteConnection(t,n){await this.deleteConnectionRaw(t,n)}async generateConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling generateConnection.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections:generate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:r,body:Th(t.generateConnectionParams)},n);return new Ke(i,s=>Ai(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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new se("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getConnection.");const r={};t.includeCreds!==void 0&&(r.includeCreds=t.includeCreds),t.includeRefreshToken!==void 0&&(r.includeRefreshToken=t.includeRefreshToken),t.refresh!==void 0&&(r.refresh=t.refresh);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"GET",headers:o,query:r},n);return new Ke(i,s=>Ai(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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listConnections.");const r={};t.provider!==void 0&&(r.provider=t.provider),t.groupRef!==void 0&&(r.groupRef=t.groupRef),t.consumerRef!==void 0&&(r.consumerRef=t.consumerRef);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Ke(i,s=>s.map(Ai))}async listConnections(t,n){return await(await this.listConnectionsRaw(t,n)).value()}}class wm extends Gt{async createInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new se("installation","Required parameter requestParameters.installation was null or undefined when calling createInstallation.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:o,query:r,body:kp(t.installation)},n);return new Ke(i,s=>_i(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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new se("installationId","Required parameter requestParameters.installationId was null or undefined when calling deleteInstallation.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=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:o,query:r},n);return new Zn(i)}async deleteInstallation(t,n){await this.deleteInstallationRaw(t,n)}async getInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new se("installationId","Required parameter requestParameters.installationId was null or undefined when calling getInstallation.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=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:o,query:r},n);return new Ke(i,s=>_i(s))}async getInstallation(t,n){return await(await this.getInstallationRaw(t,n)).value()}async listInstallationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listInstallations.");const r={};t.groupRef!==void 0&&(r.groupRef=t.groupRef);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"GET",headers:o,query:r},n);return new Ke(i,s=>s.map(_i))}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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new se("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new se("installationUpdate","Required parameter requestParameters.installationUpdate was null or undefined when calling updateInstallation.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=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:o,query:r,body:pm(t.installationUpdate)},n);return new Ke(i,s=>_i(s))}async updateInstallation(t,n){return await(await this.updateInstallationRaw(t,n)).value()}}class Im extends Gt{async batchUpsertIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations:batch".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PUT",headers:o,query:r,body:gp(t.batchUpsertIntegrationsRequest)},n);return new Ke(i,s=>s.map(Ra))}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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new se("integration","Required parameter requestParameters.integration was null or undefined when calling createIntegration.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:r,body:mh(t.integration)},n);return new Zn(i)}async createIntegration(t,n){await this.createIntegrationRaw(t,n)}async deleteIntegrationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteIntegration.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"DELETE",headers:o,query:r},n);return new Zn(i)}async deleteIntegration(t,n){await this.deleteIntegrationRaw(t,n)}async listIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listIntegrations.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Ke(i,s=>s.map(Ra))}async listIntegrations(t,n){return await(await this.listIntegrationsRaw(t,n)).value()}}class bm extends Gt{async oauthConnectRaw(t,n){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new se("connectOAuthParams","Required parameter requestParameters.connectOAuthParams was null or undefined when calling oauthConnect.");const r={},o={};o["Content-Type"]="application/json";const i=await this.request({path:"/oauth-connect",method:"POST",headers:o,query:r,body:sm(t.connectOAuthParams)},n);return this.isJsonMime(i.headers.get("content-type"))?new Ke(i):new Hf(i)}async oauthConnect(t,n){return await(await this.oauthConnectRaw(t,n)).value()}}class _m extends Gt{async createProjectRaw(t,n){if(t.project===null||t.project===void 0)throw new se("project","Required parameter requestParameters.project was null or undefined when calling createProject.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects",method:"POST",headers:o,query:r,body:gh(t.project)},n);return new Ke(i,s=>bi(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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProject.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"DELETE",headers:o,query:r},n);return new Zn(i)}async deleteProject(t,n){await this.deleteProjectRaw(t,n)}async getProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getProject.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Ke(i,s=>bi(s))}async getProject(t,n){return await(await this.getProjectRaw(t,n)).value()}async listProjectsRaw(t){const n={},r={};this.configuration&&this.configuration.apiKey&&(r["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects",method:"GET",headers:r,query:n},t);return new Ke(o,i=>i.map(bi))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new se("projectUpdate","Required parameter requestParameters.projectUpdate was null or undefined when calling updateProject.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PATCH",headers:o,query:r,body:mm(t.projectUpdate)},n);return new Ke(i,s=>bi(s))}async updateProject(t,n){return await(await this.updateProjectRaw(t,n)).value()}}class xm extends Gt{async getProviderRaw(t,n){if(t.provider===null||t.provider===void 0)throw new se("provider","Required parameter requestParameters.provider was null or undefined when calling getProvider.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/providers/{provider}".replace("{provider}",encodeURIComponent(String(t.provider))),method:"GET",headers:o,query:r},n);return new Ke(i,s=>Aa(s))}async getProvider(t,n){return await(await this.getProviderRaw(t,n)).value()}async listProvidersRaw(t){const n={},r={};this.configuration&&this.configuration.apiKey&&(r["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/providers",method:"GET",headers:r,query:n},t);return new Ke(o,i=>Zi(i,Aa))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class Cm extends Gt{async createProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new se("providerApp","Required parameter requestParameters.providerApp was null or undefined when calling createProviderApp.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:r,body:yh(t.providerApp)},n);return new Ke(i,s=>Ri(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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new se("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling deleteProviderApp.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"DELETE",headers:o,query:r},n);return new Zn(i)}async deleteProviderApp(t,n){await this.deleteProviderAppRaw(t,n)}async listProviderAppsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listProviderApps.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Ke(i,s=>s.map(Ri))}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 se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new se("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new se("providerAppUpdate","Required parameter requestParameters.providerAppUpdate was null or undefined when calling updateProviderApp.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"PATCH",headers:o,query:r,body:ym(t.providerAppUpdate)},n);return new Ke(i,s=>Ri(s))}async updateProviderApp(t,n){return await(await this.updateProviderAppRaw(t,n)).value()}}class Om extends Gt{async createRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/revisions".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:o,query:r,body:vh(t.revision)},n);return new Zn(i)}async createRevision(t,n){await this.createRevisionRaw(t,n)}async getHydratedRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new se("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new se("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new se("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new se("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getHydratedRevision.");const r={};t.connectionId!==void 0&&(r.connectionId=t.connectionId);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=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:o,query:r},n);return new Ke(i,s=>Hh(s))}async getHydratedRevision(t,n){return await(await this.getHydratedRevisionRaw(t,n)).value()}}class el{constructor(t){this.connectionApi=new vm(t),this.installationApi=new wm(t),this.integrationApi=new Im(t),this.oAuthApi=new bm(t),this.projectApi=new _m(t),this.providerApi=new xm(t),this.providerAppApi=new Cm(t),this.revisionApi=new Om(t)}}const tl="2.4.2",Em="v1",xi="https://api.withampersand.com";function nl(){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 xi;case"mock":return"http://127.0.0.1:4010";case"":return xi;default:return e??xi}}catch{return xi}}const Sm=(e,t)=>`${e}/${t}`;function Nm(){return Sm(nl(),Em)}const Tm=nl(),rl=Nm(),Rm=new Is({basePath:rl,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":tl}});let Am=new el(Rm);const je=()=>Am;function il(){const e=tt();return w.useCallback(async()=>{e||console.error("Unable to create API service without API key.");const n=new Is({basePath:rl,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":tl,"X-Api-Key":e}});return new el(n)},[e])}const st=async(e,t)=>{var n;if(e instanceof Bc){const{status:r,statusText:o}=e.response;console.error(r===500?"Internal Server Error (500):":r===400?"Bad Request (400):":`Error (${r}):`,o);const i=await e.response.json(),s=((n=i==null?void 0:i.causes)==null?void 0:n.join(`
2
2
  `))||"[ERROR] Creating installation failed.";console.error("[Error Message]",s),t&&t(s)}else console.error("Unexpected error:",e.message)},ol=w.createContext({integrations:null,isLoading:!0}),bs=()=>{const e=w.useContext(ol);if(!e)throw new Error("useIntegrationList must be used within a IntegrationListProvider");return e};function Pm({projectIdOrName:e,children:t}){const n=tt(),{setError:r}=Ht(),[o,i]=w.useState(null),[s,a]=w.useState(!0);w.useEffect(()=>{je().integrationApi.listIntegrations({projectIdOrName:e},{headers:{"X-Api-Key":n??""}}).then(u=>{a(!1),i(u||[])}).catch(u=>{console.error("Error retrieving integration information."),st(u),a(!1),r(we.INTEGRATION_LIST,e)})},[e,n,r]);const c=w.useMemo(()=>({integrations:o,isLoading:s}),[o,s]);return l.jsx(ol.Provider,{value:c,children:t})}const Dm=e=>{const t=il();return Mf({queryKey:["project",e],queryFn:async()=>(await t()).projectApi.getProject({projectIdOrName:e})})},sl=w.createContext({project:null,appName:"",projectId:"",projectIdOrName:"",isLoading:!0}),Le=()=>{const e=w.useContext(sl);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function Fm({projectIdOrName:e,children:t}){const{setError:n}=Ht(),{data:r,isLoading:o,isError:i}=Dm(e);w.useEffect(()=>{i&&n(we.PROJECT,e)},[i,e,n]);const s=w.useMemo(()=>({projectId:(r==null?void 0:r.id)||"",projectIdOrName:e,project:r||null,appName:(r==null?void 0:r.appName)||"",isLoading:o}),[e,r,o]);return l.jsx(sl.Provider,{value:s,children:t})}const Mm=new yf;function jm(e){const{options:{apiKey:t,projectId:n,project:r},children:o}=e,i=r||n;if(n&&r)throw new Error("Use AmpersandProvider either with projectId or project but not both.");if(!i)throw new Error("Cannot use AmpersandProvider without a projectId or name.");if(!t)throw new Error("Cannot use AmpersandProvider without an apiKey.");return l.jsx(_f,{client:Mm,children:l.jsx(Lf,{children:l.jsx(jf,{value:t,children:l.jsx(Fm,{projectIdOrName:i,children:l.jsx(Pm,{projectIdOrName:i,children:o})})})})})}const al=w.createContext(null);function km(){const e=w.useContext(al);if(!e)throw new Error(`Cannot call useAmpersandProvider unless your
3
3
  component is wrapped with AmpersandProvider`);return e}function Lm(){return l.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.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"}),l.jsx("path",{d:"M24 18V26",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M24 34H24.02",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]})}const Vm="_box_1p7c5_1",Pa={box:Vm};function Pn({children:e,className:t,style:n}){return l.jsx("div",{className:t?`${Pa.box} ${t}`:Pa.box,style:n,children:e})}const Km="_container_1wvzr_1",Da={container:Km};function Pr({children:e,className:t,style:n}){return l.jsx("div",{className:t?`${Da.container} ${t}`:Da.container,style:n,children:e})}const $m="_errorBoxContainer_4sdb2_1",Um="_errorBox_4sdb2_1",qm="_errorText_4sdb2_20",_o={errorBoxContainer:$m,errorBox:Um,errorText:qm};function cl({message:e}){return l.jsxs(Pr,{className:_o.errorBoxContainer,children:[l.jsx(Lm,{}),l.jsx(Pn,{className:_o.errorBox,children:l.jsx("p",{className:_o.errorText,children:e})})]})}const Hm="_loader_6ubm6_1",Bm="_rotate_6ubm6_1",Wm="_ball1_6ubm6_1",Jm="_ball2_6ubm6_1",zm={loader:Hm,rotate:Bm,ball1:Wm,ball2:Jm};function Gm(){return l.jsx("span",{className:zm.loader})}function Br(){return l.jsx("div",{style:{display:"flex",width:"100%",height:"100%",justifyContent:"center",marginTop:"20%",marginBottom:"20%"},children:l.jsx(Gm,{})})}function ll({children:e}){return l.jsx(Pr,{style:{maxWidth:"55rem"},children:l.jsx(Pn,{children:e})})}function eo(){return l.jsx(ll,{children:l.jsx(Br,{})})}function un({message:e}){return l.jsx(ll,{children:l.jsx(cl,{message:e})})}const ul=()=>{const[e,t]=w.useState(!1),n=w.useCallback(()=>{t(!0)},[t]);return{isIntegrationDeleted:e,setIntegrationDeleted:n}};function _s(e,t){try{return process.env[e]}catch{return t}}function Wr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Dn(e,t){return(t==null?void 0:t.displayName)??Wr(e)}const Xm=e=>e.split(`
4
4
  `).filter(n=>n.trim()!==""),Qm=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(n=>n.name===e)??null,dl=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 ut(){const e=w.useContext(dl);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function Ym({children:e,integration:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,onInstallSuccess:s,onUpdateSuccess:a,onUninstallSuccess:c,fieldMapping:u}){const d=tt(),{projectId:f}=Le(),{integrations:m}=bs(),{setError:p,isError:g}=Ht(),{isIntegrationDeleted:y,setIntegrationDeleted:h}=ul(),[x,v]=w.useState([]),[_,C]=w.useState(!0),b=(x==null?void 0:x[0])||null,S=w.useMemo(()=>Qm(t,m||[]),[t,m]);w.useEffect(()=>{S===null&&(m!=null&&m.length)&&console.error(`Integration "${t}" not found in integration list`)},[t,S,m]);const R=w.useCallback(q=>{v([q])},[v]),N=w.useCallback(()=>{S!=null&&S.id&&je().installationApi.listInstallations({projectIdOrName:f,integrationId:S.id,groupRef:o},{headers:{"X-Api-Key":d??""}}).then(q=>{C(!1),v(q||[])}).catch(q=>{p(we.INSTALLATION_LIST,S.id),C(!1),console.error("Error retrieving installation information: ",q)})},[S,f,d,p,o]),M=(S==null?void 0:S.id)||"";w.useEffect(()=>{N()},[N]);const U=w.useMemo(()=>({integrationId:(S==null?void 0:S.id)||"",provider:(S==null?void 0:S.provider)||"",integrationObj:S,consumerRef:n,consumerName:r,groupRef:o,groupName:i,installation:b,setInstallation:R,resetInstallations:N,onInstallSuccess:s,onUpdateSuccess:a,onUninstallSuccess:c,isIntegrationDeleted:y,setIntegrationDeleted:h,fieldMapping:u}),[S,n,r,o,i,b,R,N,s,a,c,y,h,u]);if(_)return l.jsx(eo,{});if(S===null)return l.jsx(un,{message:`Integration "${t}" not found`});if(g(we.INSTALLATION_LIST,M)){const q=`Error retrieving installation information for integration "${(S==null?void 0:S.name)||"unknown"}"`;return l.jsx(un,{message:q})}return l.jsx(dl.Provider,{value:U,children:e})}const fl=w.createContext({connections:null,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{},isIntegrationDeleted:!1,setIntegrationDeleted:()=>{}}),or=()=>{const e=w.useContext(fl);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function pl({provider:e,groupRef:t,children:n}){const r=il(),{projectId:o,isLoading:i}=Le(),[s,a]=w.useState(null),[c,u]=w.useState(null),[d,f]=w.useState(!0),{setError:m,isError:p}=Ht(),{provider:g}=ut(),{isIntegrationDeleted:y,setIntegrationDeleted:h}=ul(),x=e||g;if(!x)throw new Error("ConnectionsProvider must be given a provider prop or be used within InstallIntegrationProvider");w.useEffect(()=>{async function _(){const C=await r();if(!o)throw new Error("Project ID not found. Component must be used within AmpersandProvider");C.connectionApi.listConnections({projectIdOrName:o,groupRef:t,provider:x}).then(b=>{f(!1),a(b)}).catch(b=>{console.error(`Error retrieving existing connections for group ID ${t}.`),st(b),f(!1),m(we.CONNECTION_LIST,o)})}o&&_()},[o,t,x,m,r,y]),w.useEffect(()=>{c&&(c.provider!==x?(console.warn("Provider has changed, resetting selected connection"),u(null)):s!=null&&s.length&&(s.some(C=>C.id===c.id)||(console.warn("Selected connection not found in connections list, resetting selected connection"),u(null))))},[s,c,x]),w.useEffect(()=>{if(!c&&s&&s.length>0){const[_]=s;u(_)}},[s,c]);const v=w.useMemo(()=>({connections:s,selectedConnection:c,setConnections:a,setSelectedConnection:u,isIntegrationDeleted:y,setIntegrationDeleted:h}),[s,c,a,u,y,h]);if(d||i)return l.jsx(eo,{});if(p(we.PROJECT,o))return l.jsx(un,{message:`Error loading project ${o}`});if(p(we.CONNECTION_LIST,o))return l.jsx(un,{message:"Error retrieving existing connections"});if(!o)throw new Error("Project ID not found. ConnectionsProvider must be used within AmpersandProvider");return l.jsx(fl.Provider,{value:v,children:n})}function hl(){const[e,t]=w.useState(1);return{seed:e,reset:()=>{t(Math.random())}}}const Zm="_resetContainer_lkwv9_4",ml={resetContainer:Zm};var Ci=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ki={exports:{}};ki.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",o=1,i=2,s=9007199254740991,a="[object Arguments]",c="[object Array]",u="[object AsyncFunction]",d="[object Boolean]",f="[object Date]",m="[object Error]",p="[object Function]",g="[object GeneratorFunction]",y="[object Map]",h="[object Number]",x="[object Null]",v="[object Object]",_="[object Promise]",C="[object Proxy]",b="[object RegExp]",S="[object Set]",R="[object String]",N="[object Symbol]",M="[object Undefined]",U="[object WeakMap]",q="[object ArrayBuffer]",G="[object DataView]",ne="[object Float32Array]",W="[object Float64Array]",ce="[object Int8Array]",re="[object Int16Array]",Q="[object Int32Array]",fe="[object Uint8Array]",ye="[object Uint8ClampedArray]",T="[object Uint16Array]",j="[object Uint32Array]",K=/[\\^$.*+?()[\]{}|]/g,L=/^\[object .+?Constructor\]$/,k=/^(?:0|[1-9]\d*)$/,D={};D[ne]=D[W]=D[ce]=D[re]=D[Q]=D[fe]=D[ye]=D[T]=D[j]=!0,D[a]=D[c]=D[q]=D[d]=D[G]=D[f]=D[m]=D[p]=D[y]=D[h]=D[v]=D[b]=D[S]=D[R]=D[U]=!1;var Z=typeof Ci=="object"&&Ci&&Ci.Object===Object&&Ci,ee=typeof self=="object"&&self&&self.Object===Object&&self,H=Z||ee||Function("return this")(),te=t&&!t.nodeType&&t,z=te&&!0&&e&&!e.nodeType&&e,ue=z&&z.exports===te,F=ue&&Z.process,ve=function(){try{return F&&F.binding&&F.binding("util")}catch{}}(),B=ve&&ve.isTypedArray;function Ee(I,E){for(var A=-1,X=I==null?0:I.length,Te=0,de=[];++A<X;){var Fe=I[A];E(Fe,A,I)&&(de[Te++]=Fe)}return de}function Ve(I,E){for(var A=-1,X=E.length,Te=I.length;++A<X;)I[Te+A]=E[A];return I}function Ge(I,E){for(var A=-1,X=I==null?0:I.length;++A<X;)if(E(I[A],A,I))return!0;return!1}function $e(I,E){for(var A=-1,X=Array(I);++A<I;)X[A]=E(A);return X}function Ie(I){return function(E){return I(E)}}function At(I,E){return I.has(E)}function Xe(I,E){return I==null?void 0:I[E]}function gt(I){var E=-1,A=Array(I.size);return I.forEach(function(X,Te){A[++E]=[Te,X]}),A}function Pt(I,E){return function(A){return I(E(A))}}function Dt(I){var E=-1,A=Array(I.size);return I.forEach(function(X){A[++E]=X}),A}var Qe=Array.prototype,We=Function.prototype,Ue=Object.prototype,Ae=H["__core-js_shared__"],Ft=We.toString,nt=Ue.hasOwnProperty,Yt=function(){var I=/[^.]+$/.exec(Ae&&Ae.keys&&Ae.keys.IE_PROTO||"");return I?"Symbol(src)_1."+I:""}(),fn=Ue.toString,yt=RegExp("^"+Ft.call(nt).replace(K,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Pe=ue?H.Buffer:void 0,Zt=H.Symbol,pn=H.Uint8Array,en=Ue.propertyIsEnumerable,Mn=Qe.splice,dt=Zt?Zt.toStringTag:void 0,tn=Object.getOwnPropertySymbols,hn=Pe?Pe.isBuffer:void 0,jn=Pt(Object.keys,Object),mn=sr(H,"DataView"),Re=sr(H,"Map"),rt=sr(H,"Promise"),ie=sr(H,"Set"),he=sr(H,"WeakMap"),qe=sr(Object,"create"),nn=Vn(mn),J=Vn(Re),oe=Vn(rt),le=Vn(ie),ke=Vn(he),He=Zt?Zt.prototype:void 0,ft=He?He.valueOf:void 0;function Je(I){var E=-1,A=I==null?0:I.length;for(this.clear();++E<A;){var X=I[E];this.set(X[0],X[1])}}function Ye(){this.__data__=qe?qe(null):{},this.size=0}function pt(I){var E=this.has(I)&&delete this.__data__[I];return this.size-=E?1:0,E}function Ne(I){var E=this.__data__;if(qe){var A=E[I];return A===r?void 0:A}return nt.call(E,I)?E[I]:void 0}function kn(I){var E=this.__data__;return qe?E[I]!==void 0:nt.call(E,I)}function go(I,E){var A=this.__data__;return this.size+=this.has(I)?0:1,A[I]=qe&&E===void 0?r:E,this}Je.prototype.clear=Ye,Je.prototype.delete=pt,Je.prototype.get=Ne,Je.prototype.has=kn,Je.prototype.set=go;function Ot(I){var E=-1,A=I==null?0:I.length;for(this.clear();++E<A;){var X=I[E];this.set(X[0],X[1])}}function ui(){this.__data__=[],this.size=0}function di(I){var E=this.__data__,A=hi(E,I);if(A<0)return!1;var X=E.length-1;return A==X?E.pop():Mn.call(E,A,1),--this.size,!0}function fi(I){var E=this.__data__,A=hi(E,I);return A<0?void 0:E[A][1]}function Se(I){return hi(this.__data__,I)>-1}function Mt(I,E){var A=this.__data__,X=hi(A,I);return X<0?(++this.size,A.push([I,E])):A[X][1]=E,this}Ot.prototype.clear=ui,Ot.prototype.delete=di,Ot.prototype.get=fi,Ot.prototype.has=Se,Ot.prototype.set=Mt;function jt(I){var E=-1,A=I==null?0:I.length;for(this.clear();++E<A;){var X=I[E];this.set(X[0],X[1])}}function Ln(){this.size=0,this.__data__={hash:new Je,map:new(Re||Ot),string:new Je}}function yo(I){var E=mi(this,I).delete(I);return this.size-=E?1:0,E}function Mr(I){return mi(this,I).get(I)}function Cd(I){return mi(this,I).has(I)}function Od(I,E){var A=mi(this,I),X=A.size;return A.set(I,E),this.size+=A.size==X?0:1,this}jt.prototype.clear=Ln,jt.prototype.delete=yo,jt.prototype.get=Mr,jt.prototype.has=Cd,jt.prototype.set=Od;function pi(I){var E=-1,A=I==null?0:I.length;for(this.__data__=new jt;++E<A;)this.add(I[E])}function Ed(I){return this.__data__.set(I,r),this}function Sd(I){return this.__data__.has(I)}pi.prototype.add=pi.prototype.push=Ed,pi.prototype.has=Sd;function gn(I){var E=this.__data__=new Ot(I);this.size=E.size}function Nd(){this.__data__=new Ot,this.size=0}function Td(I){var E=this.__data__,A=E.delete(I);return this.size=E.size,A}function Rd(I){return this.__data__.get(I)}function Ad(I){return this.__data__.has(I)}function Pd(I,E){var A=this.__data__;if(A instanceof Ot){var X=A.__data__;if(!Re||X.length<n-1)return X.push([I,E]),this.size=++A.size,this;A=this.__data__=new jt(X)}return A.set(I,E),this.size=A.size,this}gn.prototype.clear=Nd,gn.prototype.delete=Td,gn.prototype.get=Rd,gn.prototype.has=Ad,gn.prototype.set=Pd;function Dd(I,E){var A=gi(I),X=!A&&zd(I),Te=!A&&!X&&vo(I),de=!A&&!X&&!Te&&ma(I),Fe=A||X||Te||de,ze=Fe?$e(I.length,String):[],Ze=ze.length;for(var De in I)nt.call(I,De)&&!(Fe&&(De=="length"||Te&&(De=="offset"||De=="parent")||de&&(De=="buffer"||De=="byteLength"||De=="byteOffset")||qd(De,Ze)))&&ze.push(De);return ze}function hi(I,E){for(var A=I.length;A--;)if(da(I[A][0],E))return A;return-1}function Fd(I,E,A){var X=E(I);return gi(I)?X:Ve(X,A(I))}function jr(I){return I==null?I===void 0?M:x:dt&&dt in Object(I)?$d(I):Jd(I)}function aa(I){return kr(I)&&jr(I)==a}function ca(I,E,A,X,Te){return I===E?!0:I==null||E==null||!kr(I)&&!kr(E)?I!==I&&E!==E:Md(I,E,A,X,ca,Te)}function Md(I,E,A,X,Te,de){var Fe=gi(I),ze=gi(E),Ze=Fe?c:yn(I),De=ze?c:yn(E);Ze=Ze==a?v:Ze,De=De==a?v:De;var vt=Ze==v,kt=De==v,it=Ze==De;if(it&&vo(I)){if(!vo(E))return!1;Fe=!0,vt=!1}if(it&&!vt)return de||(de=new gn),Fe||ma(I)?la(I,E,A,X,Te,de):Vd(I,E,Ze,A,X,Te,de);if(!(A&o)){var Et=vt&&nt.call(I,"__wrapped__"),St=kt&&nt.call(E,"__wrapped__");if(Et||St){var vn=Et?I.value():I,rn=St?E.value():E;return de||(de=new gn),Te(vn,rn,A,X,de)}}return it?(de||(de=new gn),Kd(I,E,A,X,Te,de)):!1}function jd(I){if(!ha(I)||Bd(I))return!1;var E=fa(I)?yt:L;return E.test(Vn(I))}function kd(I){return kr(I)&&pa(I.length)&&!!D[jr(I)]}function Ld(I){if(!Wd(I))return jn(I);var E=[];for(var A in Object(I))nt.call(I,A)&&A!="constructor"&&E.push(A);return E}function la(I,E,A,X,Te,de){var Fe=A&o,ze=I.length,Ze=E.length;if(ze!=Ze&&!(Fe&&Ze>ze))return!1;var De=de.get(I);if(De&&de.get(E))return De==E;var vt=-1,kt=!0,it=A&i?new pi:void 0;for(de.set(I,E),de.set(E,I);++vt<ze;){var Et=I[vt],St=E[vt];if(X)var vn=Fe?X(St,Et,vt,E,I,de):X(Et,St,vt,I,E,de);if(vn!==void 0){if(vn)continue;kt=!1;break}if(it){if(!Ge(E,function(rn,Kn){if(!At(it,Kn)&&(Et===rn||Te(Et,rn,A,X,de)))return it.push(Kn)})){kt=!1;break}}else if(!(Et===St||Te(Et,St,A,X,de))){kt=!1;break}}return de.delete(I),de.delete(E),kt}function Vd(I,E,A,X,Te,de,Fe){switch(A){case G:if(I.byteLength!=E.byteLength||I.byteOffset!=E.byteOffset)return!1;I=I.buffer,E=E.buffer;case q:return!(I.byteLength!=E.byteLength||!de(new pn(I),new pn(E)));case d:case f:case h:return da(+I,+E);case m:return I.name==E.name&&I.message==E.message;case b:case R:return I==E+"";case y:var ze=gt;case S:var Ze=X&o;if(ze||(ze=Dt),I.size!=E.size&&!Ze)return!1;var De=Fe.get(I);if(De)return De==E;X|=i,Fe.set(I,E);var vt=la(ze(I),ze(E),X,Te,de,Fe);return Fe.delete(I),vt;case N:if(ft)return ft.call(I)==ft.call(E)}return!1}function Kd(I,E,A,X,Te,de){var Fe=A&o,ze=ua(I),Ze=ze.length,De=ua(E),vt=De.length;if(Ze!=vt&&!Fe)return!1;for(var kt=Ze;kt--;){var it=ze[kt];if(!(Fe?it in E:nt.call(E,it)))return!1}var Et=de.get(I);if(Et&&de.get(E))return Et==E;var St=!0;de.set(I,E),de.set(E,I);for(var vn=Fe;++kt<Ze;){it=ze[kt];var rn=I[it],Kn=E[it];if(X)var ga=Fe?X(Kn,rn,it,E,I,de):X(rn,Kn,it,I,E,de);if(!(ga===void 0?rn===Kn||Te(rn,Kn,A,X,de):ga)){St=!1;break}vn||(vn=it=="constructor")}if(St&&!vn){var yi=I.constructor,vi=E.constructor;yi!=vi&&"constructor"in I&&"constructor"in E&&!(typeof yi=="function"&&yi instanceof yi&&typeof vi=="function"&&vi instanceof vi)&&(St=!1)}return de.delete(I),de.delete(E),St}function ua(I){return Fd(I,Qd,Ud)}function mi(I,E){var A=I.__data__;return Hd(E)?A[typeof E=="string"?"string":"hash"]:A.map}function sr(I,E){var A=Xe(I,E);return jd(A)?A:void 0}function $d(I){var E=nt.call(I,dt),A=I[dt];try{I[dt]=void 0;var X=!0}catch{}var Te=fn.call(I);return X&&(E?I[dt]=A:delete I[dt]),Te}var Ud=tn?function(I){return I==null?[]:(I=Object(I),Ee(tn(I),function(E){return en.call(I,E)}))}:Yd,yn=jr;(mn&&yn(new mn(new ArrayBuffer(1)))!=G||Re&&yn(new Re)!=y||rt&&yn(rt.resolve())!=_||ie&&yn(new ie)!=S||he&&yn(new he)!=U)&&(yn=function(I){var E=jr(I),A=E==v?I.constructor:void 0,X=A?Vn(A):"";if(X)switch(X){case nn:return G;case J:return y;case oe:return _;case le:return S;case ke:return U}return E});function qd(I,E){return E=E??s,!!E&&(typeof I=="number"||k.test(I))&&I>-1&&I%1==0&&I<E}function Hd(I){var E=typeof I;return E=="string"||E=="number"||E=="symbol"||E=="boolean"?I!=="__proto__":I===null}function Bd(I){return!!Yt&&Yt in I}function Wd(I){var E=I&&I.constructor,A=typeof E=="function"&&E.prototype||Ue;return I===A}function Jd(I){return fn.call(I)}function Vn(I){if(I!=null){try{return Ft.call(I)}catch{}try{return I+""}catch{}}return""}function da(I,E){return I===E||I!==I&&E!==E}var zd=aa(function(){return arguments}())?aa:function(I){return kr(I)&&nt.call(I,"callee")&&!en.call(I,"callee")},gi=Array.isArray;function Gd(I){return I!=null&&pa(I.length)&&!fa(I)}var vo=hn||Zd;function Xd(I,E){return ca(I,E)}function fa(I){if(!ha(I))return!1;var E=jr(I);return E==p||E==g||E==u||E==C}function pa(I){return typeof I=="number"&&I>-1&&I%1==0&&I<=s}function ha(I){var E=typeof I;return I!=null&&(E=="object"||E=="function")}function kr(I){return I!=null&&typeof I=="object"}var ma=B?Ie(B):kd;function Qd(I){return Gd(I)?Dd(I):Ld(I)}function Yd(){return[]}function Zd(){return!1}e.exports=Xd})(ki,ki.exports);var eg=ki.exports;const gl=xs(eg),er="other",Li="uninstall-installation";function Tn(e){return!e.fieldName}function Cs(e,t){var n;return((n=e==null?void 0:e.objects)==null?void 0:n.find(r=>r.objectName===t))||null}function tg(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(n=>!Tn(n)&&!!n.fieldName))||null}function ng(e){var n;return((n=e==null?void 0:e.requiredFields)==null?void 0:n.filter(r=>Tn(r)&&!!r.mapToName))||[]}function rg(e){var n;return((n=e==null?void 0:e.optionalFields)==null?void 0:n.filter(r=>Tn(r)&&!!r.mapToName))||[]}function ig(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(n=>!Tn(n)&&!!n.fieldName))||null}const yl=(e,t)=>{var n,r,o;return(o=(r=(n=e==null?void 0:e.content)==null?void 0:n.read)==null?void 0:r.objects)==null?void 0:o[t]};function og(e){return Tn(e)?e.mapToName:e.fieldName}const vl=(e,t)=>{var r,o,i;const n=[];return(i=(o=(r=t.content)==null?void 0:r.read)==null?void 0:o.objects)==null||i.forEach(s=>{n.push({name:s==null?void 0:s.objectName,displayName:(s==null?void 0:s.mapToDisplayName)||(s==null?void 0:s.displayName)||(s==null?void 0:s.objectName)&&Wr(s==null?void 0:s.objectName),completed:e?!!yl(e,s.objectName):!1})}),n},wl=e=>{var n;return{name:er,completed:e?!!((n=e==null?void 0:e.content)!=null&&n.write):!1}};function sg(e,t){var i;const n=vl(e,t),o=!!((i=t==null?void 0:t.content)!=null&&i.write)?wl(e):void 0;return o&&n.push(o),n}function Il(e,t,n){const r=(e==null?void 0:e.filter(i=>!(t!=null&&t[i==null?void 0:i.mapToName])))||[],o=r.map(i=>i.mapToName);return n(we.MAPPING,o),r!=null&&r.length&&console.error("required fields not met",r.map(i=>i.mapToDisplayName)),{errorList:o}}function bl(e,t){return gl(e,t)}function _l(e,t){return gl(e,t)}const ag=(e,t,n)=>{var h,x,v,_,C,b,S,R,N;if(!e)return null;const r=Cs(e,t),o=r&&tg(r),i=r&&ig(r),s=r&&ng(r),a=r&&rg(r),c=(r==null?void 0:r.allFields)||[],u=(r==null?void 0:r.allFieldsMetadata)||{},d=n==null?void 0:n.content,f=((v=(x=(h=d==null?void 0:d.read)==null?void 0:h.objects)==null?void 0:x[t])==null?void 0:v.selectedFields)||{},m=((b=(C=(_=d==null?void 0:d.read)==null?void 0:_.objects)==null?void 0:C[t])==null?void 0:b.selectedValueMappings)||{},p=((N=(R=(S=d==null?void 0:d.read)==null?void 0:S.objects)==null?void 0:R[t])==null?void 0:N.selectedFieldMappings)||{},g={...f},y={...p};return{allFields:c,allFieldsMetadata:u,requiredFields:o,optionalFields:i,requiredMapFields:s,optionalMapFields:a,selectedOptionalFields:f,selectedFieldMappings:p,selectedValueMappings:m,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,isValueMappingsModified:!1,savedConfig:{optionalFields:g,requiredMapFields:y,selectedValueMappings:m}}},cg=(e,t)=>{var r,o;if(!e)return null;const n=(o=(r=t==null?void 0:t.content)==null?void 0:r.write)==null?void 0:o.objects;return{writeObjects:(e==null?void 0:e.objects)||[],selectedWriteObjects:n||{},isWriteModified:!1,savedConfig:{selectedWriteObjects:n||{}}}};function xl(e,t,n){var i,s;const r=(i=e==null?void 0:e.content)==null?void 0:i.read,o=(s=e==null?void 0:e.content)==null?void 0:s.write;return{read:ag(r,t,n),write:cg(o,n)}}const Cl=(e,t,n,r)=>{const o=xl(e,n,t);r(n,o)},lg=(e,t,n)=>{const r=sg(t,e),o={};r.forEach(({name:i,completed:s})=>{s&&(o[i]=xl(e,i,t))}),n(o)},Ol=e=>{const{requiredFields:t,selectedOptionalFields:n}=(e==null?void 0:e.read)||{},r=new Set;return t==null||t.forEach(i=>r.add(og(i))),{...Array.from(r).reduce((i,s)=>({...i,[s]:!0}),{}),...n||{}}},El=e=>{const{selectedFieldMappings:t}=(e==null?void 0:e.read)||{},n={};return t&&Object.keys(t).forEach(r=>{t[r]!==void 0?n[r]=t[r]||"":console.warn(`Error undefined when generating selectedRequiredMapFieldsSubmit for key: ${r}`)}),n},Sl=e=>{const{selectedValueMappings:t}=(e==null?void 0:e.read)||{};return t};function Nl(e,t){return t[e]||void 0}async function Os({createConfig:e,projectId:t,integrationId:n,groupRef:r,connectionId:o,apiKey:i,setError:s,setInstallation:a,onInstallSuccess:c}){const u={projectIdOrName:t,integrationId:n,installation:{groupRef:r,connectionId:o,config:e}};try{const d=await je().installationApi.createInstallation(u,{headers:{"X-Api-Key":i,"Content-Type":"application/json"}});a(d),c==null||c(d.id,d.config)}catch(d){st(d,s)}}function to(e){var t;return(t=e.content.proxy)==null?void 0:t.enabled}const ug=(e,t)=>{const n=e.content.read,r=n==null?void 0:n.objects;return r==null?void 0:r.find(o=>o.objectName===t)},dg=(e,t,n,r)=>{const o=Ol(e),i=El(e),s=Sl(e),a=ug(n,t);if(!a)return console.error(`Error when getting object from hydratedRevision for objectName: ${t}`),null;const c={revisionId:n.id,createdBy:`consumer:${r}`,content:{provider:n.content.provider,read:{objects:{[t]:{objectName:t,schedule:a.schedule,destination:a.destination,selectedFields:o,selectedFieldMappings:i,selectedValueMappings:s||{},backfill:a.backfill}}}}};return to(n)&&(c.content.proxy={enabled:!0}),c},fg=(e,t,n,r,o,i,s,a,c,u,d,f)=>{const m=dg(c,i,a,r);return m?Os({createConfig:m,projectId:e,integrationId:t,groupRef:n,connectionId:o,apiKey:s,setError:u,setInstallation:d,onInstallSuccess:f}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},Tl=e=>{var t;return{...(t=e.write)==null?void 0:t.selectedWriteObjects}},pg=e=>{const t=e.content.write;return t==null?void 0:t.objects},hg=(e,t,n)=>{if(!pg(t))return console.error("Error when getting write objects from hydratedRevision"),null;const o=Tl(e),i={revisionId:t.id,createdBy:`consumer:${n}`,content:{provider:t.content.provider,read:{objects:{}},write:{objects:o}}};return to(t)&&(i.content.proxy={enabled:!0}),i},mg=(e,t,n,r,o,i,s,a,c,u,d)=>{const f=hg(a,s,r);return f?Os({createConfig:f,projectId:e,integrationId:t,groupRef:n,connectionId:o,apiKey:i,setError:c,setInstallation:u,onInstallSuccess:d}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},gg={backgroundColor:"var(--amp-colors-status-critical-muted)",borderColor:"var(--amp-colors-status-critical-muted)",color:"var(--amp-colors-status-critical-dark)",padding:".5rem 1rem"};function Rl({children:e,style:t}){return l.jsx(Pn,{style:{...gg,...t},children:e})}var Al={exports:{}};/*!
@@ -46,4 +46,4 @@ Valid keys: `+JSON.stringify(Object.keys(T),null," "));var F=ue(ee,z,k,D,Z+"."+
46
46
  * @copyright ReactTooltip Team
47
47
  * @license MIT
48
48
  */const Rv="react-tooltip-core-styles",Av="react-tooltip-base-styles",uc={core:!1,base:!1};function dc({css:e,id:t=Av,type:n="base",ref:r}){var o,i;if(!e||typeof document>"u"||uc[n]||n==="core"&&typeof process<"u"&&(!((o=process==null?void 0:process.env)===null||o===void 0)&&o.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((i=process==null?void 0:process.env)===null||i===void 0)&&i.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=Rv),r||(r={});const{insertAt:s}=r;if(document.getElementById(t))return;const a=document.head||document.getElementsByTagName("head")[0],c=document.createElement("style");c.id=t,c.type="text/css",s==="top"&&a.firstChild?a.insertBefore(c,a.firstChild):a.appendChild(c),c.styleSheet?c.styleSheet.cssText=e:c.appendChild(document.createTextNode(e)),uc[n]=!0}const fc=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:r="top",offset:o=10,strategy:i="absolute",middlewares:s=[Ev(Number(o)),Nv({fallbackAxisSideDirection:"start"}),Sv({padding:5})],border:a})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};if(t===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};const c=s;return n?(c.push(Tv({element:n,padding:5})),lc(e,t,{placement:r,strategy:i,middleware:c}).then(({x:u,y:d,placement:f,middlewareData:m})=>{var p,g;const y={left:`${u}px`,top:`${d}px`,border:a},{x:h,y:x}=(p=m.arrow)!==null&&p!==void 0?p:{x:0,y:0},v=(g={top:"bottom",right:"left",bottom:"top",left:"right"}[f.split("-")[0]])!==null&&g!==void 0?g:"bottom",_=a&&{borderBottom:a,borderRight:a};let C=0;if(a){const b=`${a}`.match(/(\d+)px/);C=b!=null&&b[1]?Number(b[1]):1}return{tooltipStyles:y,tooltipArrowStyles:{left:h!=null?`${h}px`:"",top:x!=null?`${x}px`:"",right:"",bottom:"",..._,[v]:`-${4+C}px`},place:f}})):lc(e,t,{placement:"bottom",strategy:i,middleware:c}).then(({x:u,y:d,placement:f})=>({tooltipStyles:{left:`${u}px`,top:`${d}px`},tooltipArrowStyles:{},place:f}))},pc=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),hc=(e,t,n)=>{let r=null;const o=function(...i){const s=()=>{r=null};!r&&(e.apply(this,i),r=setTimeout(s,t))};return o.cancel=()=>{r&&(clearTimeout(r),r=null)},o},mc=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",hs=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((o,i)=>hs(o,t[i]));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!mc(e)||!mc(t))return e===t;const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(o=>hs(e[o],t[o]))},Pv=e=>{if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const t=getComputedStyle(e);return["overflow","overflow-x","overflow-y"].some(n=>{const r=t.getPropertyValue(n);return r==="auto"||r==="scroll"})},gc=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(Pv(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},Dv=typeof window<"u"?w.useLayoutEffect:w.useEffect,Nt=e=>{e.current&&(clearTimeout(e.current),e.current=null)},Fv="DEFAULT_TOOLTIP_ID",Mv={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},jv=w.createContext({getTooltipData:()=>Mv});function ju(e=Fv){return w.useContext(jv).getTooltipData(e)}var ar={tooltip:"core-styles-module_tooltip__3vRRp",fixed:"core-styles-module_fixed__pcSol",arrow:"core-styles-module_arrow__cvMwQ",noArrow:"core-styles-module_noArrow__xock6",clickable:"core-styles-module_clickable__ZuTTB",show:"core-styles-module_show__Nt9eE",closing:"core-styles-module_closing__sGnxF"},Fo={tooltip:"styles-module_tooltip__mnnfp",arrow:"styles-module_arrow__K0L3T",dark:"styles-module_dark__xNqje",light:"styles-module_light__Z6W-X",success:"styles-module_success__A2AKt",warning:"styles-module_warning__SCK0X",error:"styles-module_error__JvumD",info:"styles-module_info__BWdHW"};const kv=({forwardRef:e,id:t,className:n,classNameArrow:r,variant:o="dark",anchorId:i,anchorSelect:s,place:a="top",offset:c=10,events:u=["hover"],openOnClick:d=!1,positionStrategy:f="absolute",middlewares:m,wrapper:p,delayShow:g=0,delayHide:y=0,float:h=!1,hidden:x=!1,noArrow:v=!1,clickable:_=!1,closeOnEsc:C=!1,closeOnScroll:b=!1,closeOnResize:S=!1,openEvents:R,closeEvents:N,globalCloseEvents:M,imperativeModeOnly:U,style:q,position:G,afterShow:ne,afterHide:W,disableTooltip:ce,content:re,contentWrapperRef:Q,isOpen:fe,defaultIsOpen:ye=!1,setIsOpen:T,activeAnchor:j,setActiveAnchor:K,border:L,opacity:k,arrowColor:D,role:Z="tooltip"})=>{var ee;const H=w.useRef(null),te=w.useRef(null),z=w.useRef(null),ue=w.useRef(null),F=w.useRef(null),[ve,B]=w.useState({tooltipStyles:{},tooltipArrowStyles:{},place:a}),[Ee,Ve]=w.useState(!1),[Ge,$e]=w.useState(!1),[Ie,At]=w.useState(null),Xe=w.useRef(!1),gt=w.useRef(null),{anchorRefs:Pt,setActiveAnchor:Dt}=ju(t),Qe=w.useRef(!1),[We,Ue]=w.useState([]),Ae=w.useRef(!1),Ft=d||u.includes("click"),nt=Ft||(R==null?void 0:R.click)||(R==null?void 0:R.dblclick)||(R==null?void 0:R.mousedown),Yt=R?{...R}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!R&&Ft&&Object.assign(Yt,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const fn=N?{...N}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!N&&Ft&&Object.assign(fn,{mouseleave:!1,blur:!1,mouseout:!1});const yt=M?{...M}:{escape:C||!1,scroll:b||!1,resize:S||!1,clickOutsideAnchor:nt||!1};U&&(Object.assign(Yt,{mouseenter:!1,focus:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(fn,{mouseleave:!1,blur:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(yt,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),Dv(()=>(Ae.current=!0,()=>{Ae.current=!1}),[]);const Pe=J=>{Ae.current&&(J&&$e(!0),setTimeout(()=>{Ae.current&&(T==null||T(J),fe===void 0&&Ve(J))},10))};w.useEffect(()=>{if(fe===void 0)return()=>null;fe&&$e(!0);const J=setTimeout(()=>{Ve(fe)},10);return()=>{clearTimeout(J)}},[fe]),w.useEffect(()=>{if(Ee!==Xe.current)if(Nt(F),Xe.current=Ee,Ee)ne==null||ne();else{const J=(oe=>{const le=oe.match(/^([\d.]+)(ms|s)$/);if(!le)return 0;const[,ke,He]=le;return Number(ke)*(He==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));F.current=setTimeout(()=>{$e(!1),At(null),W==null||W()},J+25)}},[Ee]);const Zt=J=>{B(oe=>hs(oe,J)?oe:J)},pn=(J=g)=>{Nt(z),Ge?Pe(!0):z.current=setTimeout(()=>{Pe(!0)},J)},en=(J=y)=>{Nt(ue),ue.current=setTimeout(()=>{Qe.current||Pe(!1)},J)},Mn=J=>{var oe;if(!J)return;const le=(oe=J.currentTarget)!==null&&oe!==void 0?oe:J.target;if(!(le!=null&&le.isConnected))return K(null),void Dt({current:null});g?pn():Pe(!0),K(le),Dt({current:le}),Nt(ue)},dt=()=>{_?en(y||100):y?en():Pe(!1),Nt(z)},tn=({x:J,y:oe})=>{var le;const ke={getBoundingClientRect:()=>({x:J,y:oe,width:0,height:0,top:oe,left:J,right:J,bottom:oe})};fc({place:(le=Ie==null?void 0:Ie.place)!==null&&le!==void 0?le:a,offset:c,elementReference:ke,tooltipReference:H.current,tooltipArrowReference:te.current,strategy:f,middlewares:m,border:L}).then(He=>{Zt(He)})},hn=J=>{if(!J)return;const oe=J,le={x:oe.clientX,y:oe.clientY};tn(le),gt.current=le},jn=J=>{var oe;if(!Ee)return;const le=J.target;le.isConnected&&(!((oe=H.current)===null||oe===void 0)&&oe.contains(le)||[document.querySelector(`[id='${i}']`),...We].some(ke=>ke==null?void 0:ke.contains(le))||(Pe(!1),Nt(z)))},mn=hc(Mn,50),Re=hc(dt,50),rt=J=>{Re.cancel(),mn(J)},ie=()=>{mn.cancel(),Re()},he=w.useCallback(()=>{var J,oe;const le=(J=Ie==null?void 0:Ie.position)!==null&&J!==void 0?J:G;le?tn(le):h?gt.current&&tn(gt.current):j!=null&&j.isConnected&&fc({place:(oe=Ie==null?void 0:Ie.place)!==null&&oe!==void 0?oe:a,offset:c,elementReference:j,tooltipReference:H.current,tooltipArrowReference:te.current,strategy:f,middlewares:m,border:L}).then(ke=>{Ae.current&&Zt(ke)})},[Ee,j,re,q,a,Ie==null?void 0:Ie.place,c,f,G,Ie==null?void 0:Ie.position,h]);w.useEffect(()=>{var J,oe;const le=new Set(Pt);We.forEach(Se=>{ce!=null&&ce(Se)||le.add({current:Se})});const ke=document.querySelector(`[id='${i}']`);ke&&!(ce!=null&&ce(ke))&&le.add({current:ke});const He=()=>{Pe(!1)},ft=gc(j),Je=gc(H.current);yt.scroll&&(window.addEventListener("scroll",He),ft==null||ft.addEventListener("scroll",He),Je==null||Je.addEventListener("scroll",He));let Ye=null;yt.resize?window.addEventListener("resize",He):j&&H.current&&(Ye=Ov(j,H.current,he,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const pt=Se=>{Se.key==="Escape"&&Pe(!1)};yt.escape&&window.addEventListener("keydown",pt),yt.clickOutsideAnchor&&window.addEventListener("click",jn);const Ne=[],kn=Se=>{Ee&&(Se==null?void 0:Se.target)===j||Mn(Se)},go=Se=>{Ee&&(Se==null?void 0:Se.target)===j&&dt()},Ot=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],ui=["click","dblclick","mousedown","mouseup"];Object.entries(Yt).forEach(([Se,Mt])=>{Mt&&(Ot.includes(Se)?Ne.push({event:Se,listener:rt}):ui.includes(Se)&&Ne.push({event:Se,listener:kn}))}),Object.entries(fn).forEach(([Se,Mt])=>{Mt&&(Ot.includes(Se)?Ne.push({event:Se,listener:ie}):ui.includes(Se)&&Ne.push({event:Se,listener:go}))}),h&&Ne.push({event:"pointermove",listener:hn});const di=()=>{Qe.current=!0},fi=()=>{Qe.current=!1,dt()};return _&&!nt&&((J=H.current)===null||J===void 0||J.addEventListener("mouseenter",di),(oe=H.current)===null||oe===void 0||oe.addEventListener("mouseleave",fi)),Ne.forEach(({event:Se,listener:Mt})=>{le.forEach(jt=>{var Ln;(Ln=jt.current)===null||Ln===void 0||Ln.addEventListener(Se,Mt)})}),()=>{var Se,Mt;yt.scroll&&(window.removeEventListener("scroll",He),ft==null||ft.removeEventListener("scroll",He),Je==null||Je.removeEventListener("scroll",He)),yt.resize?window.removeEventListener("resize",He):Ye==null||Ye(),yt.clickOutsideAnchor&&window.removeEventListener("click",jn),yt.escape&&window.removeEventListener("keydown",pt),_&&!nt&&((Se=H.current)===null||Se===void 0||Se.removeEventListener("mouseenter",di),(Mt=H.current)===null||Mt===void 0||Mt.removeEventListener("mouseleave",fi)),Ne.forEach(({event:jt,listener:Ln})=>{le.forEach(yo=>{var Mr;(Mr=yo.current)===null||Mr===void 0||Mr.removeEventListener(jt,Ln)})})}},[j,he,Ge,Pt,We,R,N,M,Ft,g,y]),w.useEffect(()=>{var J,oe;let le=(oe=(J=Ie==null?void 0:Ie.anchorSelect)!==null&&J!==void 0?J:s)!==null&&oe!==void 0?oe:"";!le&&t&&(le=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const ke=new MutationObserver(He=>{const ft=[],Je=[];He.forEach(Ye=>{if(Ye.type==="attributes"&&Ye.attributeName==="data-tooltip-id"&&(Ye.target.getAttribute("data-tooltip-id")===t?ft.push(Ye.target):Ye.oldValue===t&&Je.push(Ye.target)),Ye.type==="childList"){if(j){const pt=[...Ye.removedNodes].filter(Ne=>Ne.nodeType===1);if(le)try{Je.push(...pt.filter(Ne=>Ne.matches(le))),Je.push(...pt.flatMap(Ne=>[...Ne.querySelectorAll(le)]))}catch{}pt.some(Ne=>{var kn;return!!(!((kn=Ne==null?void 0:Ne.contains)===null||kn===void 0)&&kn.call(Ne,j))&&($e(!1),Pe(!1),K(null),Nt(z),Nt(ue),!0)})}if(le)try{const pt=[...Ye.addedNodes].filter(Ne=>Ne.nodeType===1);ft.push(...pt.filter(Ne=>Ne.matches(le))),ft.push(...pt.flatMap(Ne=>[...Ne.querySelectorAll(le)]))}catch{}}}),(ft.length||Je.length)&&Ue(Ye=>[...Ye.filter(pt=>!Je.includes(pt)),...ft])});return ke.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{ke.disconnect()}},[t,s,Ie==null?void 0:Ie.anchorSelect,j]),w.useEffect(()=>{he()},[he]),w.useEffect(()=>{if(!(Q!=null&&Q.current))return()=>null;const J=new ResizeObserver(()=>{setTimeout(()=>he())});return J.observe(Q.current),()=>{J.disconnect()}},[re,Q==null?void 0:Q.current]),w.useEffect(()=>{var J;const oe=document.querySelector(`[id='${i}']`),le=[...We,oe];j&&le.includes(j)||K((J=We[0])!==null&&J!==void 0?J:oe)},[i,We,j]),w.useEffect(()=>(ye&&Pe(!0),()=>{Nt(z),Nt(ue)}),[]),w.useEffect(()=>{var J;let oe=(J=Ie==null?void 0:Ie.anchorSelect)!==null&&J!==void 0?J:s;if(!oe&&t&&(oe=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),oe)try{const le=Array.from(document.querySelectorAll(oe));Ue(le)}catch{Ue([])}},[t,s,Ie==null?void 0:Ie.anchorSelect]),w.useEffect(()=>{z.current&&(Nt(z),pn(g))},[g]);const qe=(ee=Ie==null?void 0:Ie.content)!==null&&ee!==void 0?ee:re,nn=Ee&&Object.keys(ve.tooltipStyles).length>0;return w.useImperativeHandle(e,()=>({open:J=>{if(J!=null&&J.anchorSelect)try{document.querySelector(J.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${J.anchorSelect}" is not a valid CSS selector`)}At(J??null),J!=null&&J.delay?pn(J.delay):Pe(!0)},close:J=>{J!=null&&J.delay?en(J.delay):Pe(!1)},activeAnchor:j,place:ve.place,isOpen:!!(Ge&&!x&&qe&&nn)})),Ge&&!x&&qe?w.createElement(p,{id:t,role:Z,className:It("react-tooltip",ar.tooltip,Fo.tooltip,Fo[o],n,`react-tooltip__place-${ve.place}`,ar[nn?"show":"closing"],nn?"react-tooltip__show":"react-tooltip__closing",f==="fixed"&&ar.fixed,_&&ar.clickable),onTransitionEnd:J=>{Nt(F),Ee||J.propertyName!=="opacity"||($e(!1),At(null),W==null||W())},style:{...q,...ve.tooltipStyles,opacity:k!==void 0&&nn?k:void 0},ref:H},qe,w.createElement(p,{className:It("react-tooltip-arrow",ar.arrow,Fo.arrow,r,v&&ar.noArrow),style:{...ve.tooltipArrowStyles,background:D?`linear-gradient(to right bottom, transparent 50%, ${D} 50%)`:void 0},ref:te})):null},Lv=({content:e})=>w.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),Vv=w.forwardRef(({id:e,anchorId:t,anchorSelect:n,content:r,html:o,render:i,className:s,classNameArrow:a,variant:c="dark",place:u="top",offset:d=10,wrapper:f="div",children:m=null,events:p=["hover"],openOnClick:g=!1,positionStrategy:y="absolute",middlewares:h,delayShow:x=0,delayHide:v=0,float:_=!1,hidden:C=!1,noArrow:b=!1,clickable:S=!1,closeOnEsc:R=!1,closeOnScroll:N=!1,closeOnResize:M=!1,openEvents:U,closeEvents:q,globalCloseEvents:G,imperativeModeOnly:ne=!1,style:W,position:ce,isOpen:re,defaultIsOpen:Q=!1,disableStyleInjection:fe=!1,border:ye,opacity:T,arrowColor:j,setIsOpen:K,afterShow:L,afterHide:k,disableTooltip:D,role:Z="tooltip"},ee)=>{const[H,te]=w.useState(r),[z,ue]=w.useState(o),[F,ve]=w.useState(u),[B,Ee]=w.useState(c),[Ve,Ge]=w.useState(d),[$e,Ie]=w.useState(x),[At,Xe]=w.useState(v),[gt,Pt]=w.useState(_),[Dt,Qe]=w.useState(C),[We,Ue]=w.useState(f),[Ae,Ft]=w.useState(p),[nt,Yt]=w.useState(y),[fn,yt]=w.useState(null),[Pe,Zt]=w.useState(null),pn=w.useRef(fe),{anchorRefs:en,activeAnchor:Mn}=ju(e),dt=Re=>Re==null?void 0:Re.getAttributeNames().reduce((rt,ie)=>{var he;return ie.startsWith("data-tooltip-")&&(rt[ie.replace(/^data-tooltip-/,"")]=(he=Re==null?void 0:Re.getAttribute(ie))!==null&&he!==void 0?he:null),rt},{}),tn=Re=>{const rt={place:ie=>{var he;ve((he=ie)!==null&&he!==void 0?he:u)},content:ie=>{te(ie??r)},html:ie=>{ue(ie??o)},variant:ie=>{var he;Ee((he=ie)!==null&&he!==void 0?he:c)},offset:ie=>{Ge(ie===null?d:Number(ie))},wrapper:ie=>{var he;Ue((he=ie)!==null&&he!==void 0?he:f)},events:ie=>{const he=ie==null?void 0:ie.split(" ");Ft(he??p)},"position-strategy":ie=>{var he;Yt((he=ie)!==null&&he!==void 0?he:y)},"delay-show":ie=>{Ie(ie===null?x:Number(ie))},"delay-hide":ie=>{Xe(ie===null?v:Number(ie))},float:ie=>{Pt(ie===null?_:ie==="true")},hidden:ie=>{Qe(ie===null?C:ie==="true")},"class-name":ie=>{yt(ie)}};Object.values(rt).forEach(ie=>ie(null)),Object.entries(Re).forEach(([ie,he])=>{var qe;(qe=rt[ie])===null||qe===void 0||qe.call(rt,he)})};w.useEffect(()=>{te(r)},[r]),w.useEffect(()=>{ue(o)},[o]),w.useEffect(()=>{ve(u)},[u]),w.useEffect(()=>{Ee(c)},[c]),w.useEffect(()=>{Ge(d)},[d]),w.useEffect(()=>{Ie(x)},[x]),w.useEffect(()=>{Xe(v)},[v]),w.useEffect(()=>{Pt(_)},[_]),w.useEffect(()=>{Qe(C)},[C]),w.useEffect(()=>{Yt(y)},[y]),w.useEffect(()=>{pn.current!==fe&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")},[fe]),w.useEffect(()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:fe==="core",disableBase:fe}}))},[]),w.useEffect(()=>{var Re;const rt=new Set(en);let ie=n;if(!ie&&e&&(ie=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),ie)try{document.querySelectorAll(ie).forEach(oe=>{rt.add({current:oe})})}catch{console.warn(`[react-tooltip] "${ie}" is not a valid CSS selector`)}const he=document.querySelector(`[id='${t}']`);if(he&&rt.add({current:he}),!rt.size)return()=>null;const qe=(Re=Pe??he)!==null&&Re!==void 0?Re:Mn.current,nn=new MutationObserver(oe=>{oe.forEach(le=>{var ke;if(!qe||le.type!=="attributes"||!(!((ke=le.attributeName)===null||ke===void 0)&&ke.startsWith("data-tooltip-")))return;const He=dt(qe);tn(He)})}),J={attributes:!0,childList:!1,subtree:!1};if(qe){const oe=dt(qe);tn(oe),nn.observe(qe,J)}return()=>{nn.disconnect()}},[en,Mn,Pe,t,n]),w.useEffect(()=>{W!=null&&W.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),ye&&!pc("border",`${ye}`)&&console.warn(`[react-tooltip] "${ye}" is not a valid \`border\`.`),W!=null&&W.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),T&&!pc("opacity",`${T}`)&&console.warn(`[react-tooltip] "${T}" is not a valid \`opacity\`.`)},[]);let hn=m;const jn=w.useRef(null);if(i){const Re=i({content:(Pe==null?void 0:Pe.getAttribute("data-tooltip-content"))||H||null,activeAnchor:Pe});hn=Re?w.createElement("div",{ref:jn,className:"react-tooltip-content-wrapper"},Re):null}else H&&(hn=H);z&&(hn=w.createElement(Lv,{content:z}));const mn={forwardRef:ee,id:e,anchorId:t,anchorSelect:n,className:It(s,fn),classNameArrow:a,content:hn,contentWrapperRef:jn,place:F,variant:B,offset:Ve,wrapper:We,events:Ae,openOnClick:g,positionStrategy:nt,middlewares:h,delayShow:$e,delayHide:At,float:gt,hidden:Dt,noArrow:b,clickable:S,closeOnEsc:R,closeOnScroll:N,closeOnResize:M,openEvents:U,closeEvents:q,globalCloseEvents:G,imperativeModeOnly:ne,style:W,position:ce,isOpen:re,defaultIsOpen:Q,border:ye,opacity:T,arrowColor:j,setIsOpen:K,afterShow:L,afterHide:k,disableTooltip:D,activeAnchor:Pe,setActiveAnchor:Re=>Zt(Re),role:Z};return w.createElement(kv,{...mn})});typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",e=>{e.detail.disableCore||dc({css:":root{--rt-color-white:#fff;--rt-color-dark:#222;--rt-color-success:#8dc572;--rt-color-error:#be6464;--rt-color-warning:#f0ad4e;--rt-color-info:#337ab7;--rt-opacity:0.9;--rt-transition-show-delay:0.15s;--rt-transition-closing-delay:0.15s}.core-styles-module_tooltip__3vRRp{position:absolute;top:0;left:0;pointer-events:none;opacity:0;will-change:opacity}.core-styles-module_fixed__pcSol{position:fixed}.core-styles-module_arrow__cvMwQ{position:absolute;background:inherit}.core-styles-module_noArrow__xock6{display:none}.core-styles-module_clickable__ZuTTB{pointer-events:auto}.core-styles-module_show__Nt9eE{opacity:var(--rt-opacity);transition:opacity var(--rt-transition-show-delay)ease-out}.core-styles-module_closing__sGnxF{opacity:0;transition:opacity var(--rt-transition-closing-delay)ease-in}",type:"core"}),e.detail.disableBase||dc({css:`
49
- .styles-module_tooltip__mnnfp{padding:8px 16px;border-radius:3px;font-size:90%;width:max-content}.styles-module_arrow__K0L3T{width:8px;height:8px}[class*='react-tooltip__place-top']>.styles-module_arrow__K0L3T{transform:rotate(45deg)}[class*='react-tooltip__place-right']>.styles-module_arrow__K0L3T{transform:rotate(135deg)}[class*='react-tooltip__place-bottom']>.styles-module_arrow__K0L3T{transform:rotate(225deg)}[class*='react-tooltip__place-left']>.styles-module_arrow__K0L3T{transform:rotate(315deg)}.styles-module_dark__xNqje{background:var(--rt-color-dark);color:var(--rt-color-white)}.styles-module_light__Z6W-X{background-color:var(--rt-color-white);color:var(--rt-color-dark)}.styles-module_success__A2AKt{background-color:var(--rt-color-success);color:var(--rt-color-white)}.styles-module_warning__SCK0X{background-color:var(--rt-color-warning);color:var(--rt-color-white)}.styles-module_error__JvumD{background-color:var(--rt-color-error);color:var(--rt-color-white)}.styles-module_info__BWdHW{background-color:var(--rt-color-info);color:var(--rt-color-white)}`,type:"base"})});function Kv(){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:[l.jsxs("g",{clipPath:"url(#clip0_2896_16290)",children:[l.jsx("path",{d:"M8.00032 11.167L8.00032 7.83366M8.00032 1.83366C4.33366 1.83366 1.33366 4.83366 1.33366 8.50033C1.33366 12.167 4.33366 15.167 8.00033 15.167C11.667 15.167 14.667 12.167 14.667 8.50033C14.667 4.83366 11.667 1.83366 8.00032 1.83366Z",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M8.00293 5.83301L7.99768 5.83301",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})]}),l.jsx("defs",{children:l.jsx("clipPath",{id:"clip0_2896_16290",children:l.jsx("rect",{width:"16",height:"16",fill:"white",transform:"translate(16 16.5) rotate(180)"})})})]})}function $v({id:e,tooltipText:t}){return l.jsxs(l.Fragment,{children:[l.jsx("span",{"data-tooltip-id":e,style:{maxWidth:"20rem"},children:Kv()}),l.jsx(Vv,{id:e,place:"top",content:t,style:{maxWidth:"30rem"}})]})}function uo({field:e,onSelectChange:t,allFields:n}){var p;const{configureState:r,selectedObjectName:o,setConfigureState:i}=Ct(),[s,a]=w.useState(!0),c=(p=r==null?void 0:r.read)==null?void 0:p.selectedFieldMappings,u=c==null?void 0:c[e.mapToName];w.useEffect(()=>{e._default&&!u&&o&&r&&Gr(o,i,[{field:e.mapToName,value:e._default}]),a(!1)},[e,i,o,u,r]);const d=w.useMemo(()=>n.map(g=>({id:g.fieldName,label:g.displayName,value:g.fieldName})),[n]),f=l.jsx(Js,{disabled:s,items:d,selectedValue:u||null,onSelectedItemChange:g=>{t({target:{name:e.mapToName,value:g==null?void 0:g.value}})},placeholder:"Please select one",style:{width:"100%"}}),m=w.useCallback(()=>{o&&Gr(o,i,[{field:e.mapToName,value:null}])},[e.mapToName,o,i]);return l.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[l.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem",marginBottom:".25rem"},children:[l.jsx("span",{style:{fontWeight:500},children:e.mapToDisplayName}),l.jsx("span",{children:(e==null?void 0:e.prompt)&&l.jsx($v,{id:`tooltip-id-${e==null?void 0:e.prompt}`,tooltipText:e==null?void 0:e.prompt})})]}),l.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[f,l.jsx(at,{type:"button",variant:"ghost",onClick:m,children:"clear"})]})]},e.mapToName)}const Uv="_formControl_9qd8d_1",qv="_formLabel_9qd8d_5",Hv="_formLabelRequired_9qd8d_11",Bv="_formInput_9qd8d_16",Wv="_formInputInvalid_9qd8d_20",Jv="_formError_9qd8d_24",zv="_disabled_9qd8d_30",$n={formControl:Uv,formLabel:qv,formLabelRequired:Hv,formInput:Bv,formInputInvalid:Wv,formError:Jv,disabled:zv};function fo({id:e,label:t,isRequired:n=!1,isDisabled:r=!1,isInvalid:o=!1,errorMessage:i,children:s}){return l.jsxs("div",{className:It($n.formControl,{[$n.disabled]:r}),children:[t&&l.jsx("label",{htmlFor:e,className:It($n.formLabel,{[$n.formLabelRequired]:n}),children:t}),l.jsx("div",{id:e,className:It($n.formInput,{[$n.formInputInvalid]:o}),children:s}),o&&i&&l.jsx("div",{className:$n.formError,role:"alert",children:i})]})}const Gv="_divider_1kmoj_1",yc={divider:Gv};function po({className:e,style:t}){return l.jsx("hr",{className:e?`${yc.divider} ${e}`:yc.divider,style:t})}function Fr({string:e}){return l.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"1rem",paddingBottom:".5rem"},children:[l.jsx("h3",{style:{color:"var(--amp-colors-text-muted)",fontSize:"1rem",fontWeight:"400"},children:e}),l.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:l.jsx(po,{style:{width:"100%",marginLeft:"1rem"}})})]})}function Xv({dynamicFieldMappings:e,onSelectChange:t,allFields:n}){return e.length?l.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:e.map(r=>l.jsx(fo,{id:r.mapToName,children:l.jsx(uo,{allFields:n,field:r,onSelectChange:t})},r.mapToName))}):null}function Qv(){var m;const{selectedObjectName:e,configureState:t,setConfigureState:n}=Ct(),{isError:r,removeError:o}=Ht(),i=((m=t==null?void 0:t.read)==null?void 0:m.allFields)||[],{fieldMapping:s}=ut(),a=p=>{const{value:g,name:y}=p.target;g&&(e&&Gr(e,n,[{field:y,value:g}]),r(we.MAPPING,y)&&o(we.MAPPING,y))},c=w.useMemo(()=>!e||!s?[]:Object.values(s[e]||{}).flat().filter(p=>!p.fieldName),[s,e]),u=w.useMemo(()=>{var y;return(((y=t==null?void 0:t.read)==null?void 0:y.optionalMapFields)||[]).filter(h=>!c.some(x=>x.mapToName===h.mapToName))},[t,c]),d=c.length>0;return u.length>0||d?l.jsxs(l.Fragment,{children:[l.jsx(Fr,{string:"Map the following optional fields"}),l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:[u==null?void 0:u.map(p=>l.jsx(fo,{id:p.mapToName,children:l.jsx(uo,{allFields:i,field:p,onSelectChange:a})},p.mapToName)),d&&l.jsx(Xv,{dynamicFieldMappings:c,onSelectChange:a,allFields:i})]})]}):null}function Yv(){const{selectedObjectName:e,configureState:t,setConfigureState:n}=Ct(),{isError:r,removeError:o}=Ht(),i=a=>{const{value:c,name:u}=a.target;c&&(e&&Gr(e,n,[{field:u,value:c}]),r(we.MAPPING,u)&&o(we.MAPPING,u))},s=w.useMemo(()=>{var a;return((a=t==null?void 0:t.read)==null?void 0:a.requiredMapFields)||[]},[t]);return s!=null&&s.length?l.jsxs(l.Fragment,{children:[l.jsx(Fr,{string:"Map the following fields"}),l.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:s.map(a=>{var c;return l.jsx(fo,{id:a.mapToName,isInvalid:r(we.MAPPING,a.mapToName),errorMessage:"* required",children:l.jsx(uo,{allFields:((c=t==null?void 0:t.read)==null?void 0:c.allFields)||[],field:a,onSelectChange:i})},a.mapToName)})})]}):null}const Zv={backgroundColor:"var(--amp-colors-bg-highlight)",borderColor:"var(--amp-colors-bg-highlight)",padding:".5rem 1rem"};function ew({children:e,style:t}){return l.jsx(Pn,{style:{...Zv,...t},children:e})}function tw(){var d,f,m;const{project:e}=Le(),{hydratedRevision:t}=dn(),{selectedObjectName:n}=Ct(),{provider:r}=ut(),o=e==null?void 0:e.appName,i=Dn(r),s=(m=(f=(d=t==null?void 0:t.content)==null?void 0:d.read)==null?void 0:f.objects)==null?void 0:m.find(p=>p.objectName===n),a=(s==null?void 0:s.displayName)||n&&Wr(n),c=s==null?void 0:s.mapToName,u=(s==null?void 0:s.mapToDisplayName)||c&&Wr(c);return u&&o&&i?l.jsx(ew,{style:{marginTop:"1rem"},children:l.jsxs("p",{style:{margin:"1rem 0"},children:[l.jsx("b",{children:u})," in ",o," is mapped to ",l.jsx("b",{children:a})," in ",i,"."]})}):null}function vc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ku(...e){return t=>{let n=!1;const r=e.map(o=>{const i=vc(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():vc(e[o],null)}}}}function Qr(...e){return $.useCallback(ku(...e),e)}function ho(e,t=[]){let n=[];function r(i,s){const a=$.createContext(s),c=n.length;n=[...n,s];const u=f=>{var x;const{scope:m,children:p,...g}=f,y=((x=m==null?void 0:m[e])==null?void 0:x[c])||a,h=$.useMemo(()=>g,Object.values(g));return l.jsx(y.Provider,{value:h,children:p})};u.displayName=i+"Provider";function d(f,m){var y;const p=((y=m==null?void 0:m[e])==null?void 0:y[c])||a,g=$.useContext(p);if(g)return g;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[u,d]}const o=()=>{const i=n.map(s=>$.createContext(s));return function(a){const c=(a==null?void 0:a[e])||i;return $.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,nw(o,...t)]}function nw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:c,scopeName:u})=>{const f=c(i)[`__scope${u}`];return{...a,...f}},{});return $.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function $t(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Zs(e){const t=$.useRef(e);return $.useEffect(()=>{t.current=e}),$.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function ea({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=rw({defaultProp:t,onChange:n}),i=e!==void 0,s=i?e:r,a=Zs(n),c=$.useCallback(u=>{if(i){const f=typeof u=="function"?u(e):u;f!==e&&a(f)}else o(u)},[i,e,o,a]);return[s,c]}function rw({defaultProp:e,onChange:t}){const n=$.useState(e),[r]=n,o=$.useRef(r),i=Zs(t);return $.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}function iw(e){const t=$.useRef({value:e,previous:e});return $.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Gi=globalThis!=null&&globalThis.document?$.useLayoutEffect:()=>{};function ow(e){const[t,n]=$.useState(void 0);return Gi(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const c=i.borderBoxSize,u=Array.isArray(c)?c[0]:c;s=u.inlineSize,a=u.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}function sw(e,t){return $.useReducer((n,r)=>t[n][r]??n,e)}var ta=e=>{const{present:t,children:n}=e,r=aw(t),o=typeof n=="function"?n({present:r.isPresent}):$.Children.only(n),i=Qr(r.ref,cw(o));return typeof n=="function"||r.isPresent?$.cloneElement(o,{ref:i}):null};ta.displayName="Presence";function aw(e){const[t,n]=$.useState(),r=$.useRef({}),o=$.useRef(e),i=$.useRef("none"),s=e?"mounted":"unmounted",[a,c]=sw(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return $.useEffect(()=>{const u=Ti(r.current);i.current=a==="mounted"?u:"none"},[a]),Gi(()=>{const u=r.current,d=o.current;if(d!==e){const m=i.current,p=Ti(u);e?c("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(d&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),Gi(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const y=Ti(r.current).includes(p.animationName);if(p.target===t&&y&&(c("ANIMATION_END"),!o.current)){const h=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=h)})}},m=p=>{p.target===t&&(i.current=Ti(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:$.useCallback(u=>{u&&(r.current=getComputedStyle(u)),n(u)},[])}}function Ti(e){return(e==null?void 0:e.animationName)||"none"}function cw(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xi=$.forwardRef((e,t)=>{const{children:n,...r}=e,o=$.Children.toArray(n),i=o.find(uw);if(i){const s=i.props.children,a=o.map(c=>c===i?$.Children.count(s)>1?$.Children.only(null):$.isValidElement(s)?s.props.children:null:c);return l.jsx(ms,{...r,ref:t,children:$.isValidElement(s)?$.cloneElement(s,void 0,a):null})}return l.jsx(ms,{...r,ref:t,children:n})});Xi.displayName="Slot";var ms=$.forwardRef((e,t)=>{const{children:n,...r}=e;if($.isValidElement(n)){const o=fw(n);return $.cloneElement(n,{...dw(r,n.props),ref:t?ku(t,o):o})}return $.Children.count(n)>1?$.Children.only(null):null});ms.displayName="SlotClone";var lw=({children:e})=>l.jsx(l.Fragment,{children:e});function uw(e){return $.isValidElement(e)&&e.type===lw}function dw(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function fw(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var pw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Fn=pw.reduce((e,t)=>{const n=$.forwardRef((r,o)=>{const{asChild:i,...s}=r,a=i?Xi:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(a,{...s,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),na="Checkbox",[hw,$b]=ho(na),[mw,gw]=hw(na),Lu=$.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:c="on",onCheckedChange:u,form:d,...f}=e,[m,p]=$.useState(null),g=Qr(t,C=>p(C)),y=$.useRef(!1),h=m?d||!!m.closest("form"):!0,[x=!1,v]=ea({prop:o,defaultProp:i,onChange:u}),_=$.useRef(x);return $.useEffect(()=>{const C=m==null?void 0:m.form;if(C){const b=()=>v(_.current);return C.addEventListener("reset",b),()=>C.removeEventListener("reset",b)}},[m,v]),l.jsxs(mw,{scope:n,state:x,disabled:a,children:[l.jsx(Fn.button,{type:"button",role:"checkbox","aria-checked":Nn(x)?"mixed":x,"aria-required":s,"data-state":$u(x),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:g,onKeyDown:$t(e.onKeyDown,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:$t(e.onClick,C=>{v(b=>Nn(b)?!0:!b),h&&(y.current=C.isPropagationStopped(),y.current||C.stopPropagation())})}),h&&l.jsx(yw,{control:m,bubbles:!y.current,name:r,value:c,checked:x,required:s,disabled:a,form:d,style:{transform:"translateX(-100%)"},defaultChecked:Nn(i)?!1:i})]})});Lu.displayName=na;var Vu="CheckboxIndicator",Ku=$.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=gw(Vu,n);return l.jsx(ta,{present:r||Nn(i.state)||i.state===!0,children:l.jsx(Fn.span,{"data-state":$u(i.state),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});Ku.displayName=Vu;var yw=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...i}=e,s=$.useRef(null),a=iw(n),c=ow(t);$.useEffect(()=>{const d=s.current,f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(a!==n&&p){const g=new Event("click",{bubbles:r});d.indeterminate=Nn(n),p.call(d,Nn(n)?!1:n),d.dispatchEvent(g)}},[a,n,r]);const u=$.useRef(Nn(n)?!1:n);return l.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??u.current,...i,tabIndex:-1,ref:s,style:{...e.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function Nn(e){return e==="indeterminate"}function $u(e){return Nn(e)?"indeterminate":e?"checked":"unchecked"}var Uu=Lu,qu=Ku;function Hu(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i<r.length;i++)o=r[i],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}var vw=["color"],Bu=w.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=Hu(e,vw);return w.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),w.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:r,fillRule:"evenodd",clipRule:"evenodd"}))}),ww=["color"],Iw=w.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=Hu(e,ww);return w.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),w.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:r,fillRule:"evenodd",clipRule:"evenodd"}))});const bw="_checkboxGroupContainer_1ya1t_1",_w="_stack_1ya1t_6",xw="_selectAllContainer_1ya1t_11",Cw="_fieldContainer_1ya1t_18",Ow="_checkbox_1ya1t_1",Ar={checkboxGroupContainer:bw,stack:_w,selectAllContainer:xw,fieldContainer:Cw,checkbox:Ow};function Wu({id:e,isChecked:t,label:n,onCheckedChange:r}){return l.jsxs("div",{className:Ar.fieldContainer,children:[l.jsx(Uu,{className:Ar.checkbox,id:e,onCheckedChange:r,checked:t,children:l.jsx(qu,{children:l.jsx(Bu,{})})}),l.jsx("label",{htmlFor:e,style:{overflowWrap:"anywhere"},children:n})]})}function Ju({id:e,isChecked:t,label:n,onCheckedChange:r,isIndeterminate:o}){return l.jsxs("div",{className:Ar.selectAllContainer,children:[l.jsx(Uu,{className:Ar.checkbox,id:e,onCheckedChange:r,children:l.jsxs(qu,{children:[o&&l.jsx(Iw,{}),t===!0&&l.jsx(Bu,{})]})}),l.jsx("label",{htmlFor:e,children:n})]})}function zu({children:e}){return l.jsx("div",{className:Ar.checkboxGroupContainer,children:e})}function Gu({children:e}){return l.jsx("div",{className:Ar.stack,children:e})}function Ew(e,t,n){var o,i;const r=((o=e==null?void 0:e.read)==null?void 0:o.selectedOptionalFields)||{};if(r[t]=n,n||delete r[t],(i=e.read)!=null&&i.savedConfig.optionalFields){const s=e.read.savedConfig.optionalFields,c=!_l(s,r);e.read.isOptionalFieldsModified=c}else console.warn("read.savedConfig.optionalFields is undefined")}function wc(e,t,n,r){t(e,o=>Ew(o,n,r))}function Sw(){var f,m;const{appName:e,configureState:t,setConfigureState:n,selectedObjectName:r}=Ct(),o=(f=t==null?void 0:t.read)==null?void 0:f.selectedOptionalFields,i=(p,g)=>{p!=="indeterminate"&&r&&t&&wc(r,n,g,p)},s=(m=t==null?void 0:t.read)==null?void 0:m.optionalFields,a=p=>{r&&s&&s.forEach(g=>{Tn(g)||wc(r,n,g.fieldName,p)})},c=!!(s&&s.length>0),u=Object.keys(o||{}).length===(s==null?void 0:s.length),d=!u&&Object.keys(o||{}).length>0;return c&&l.jsxs(l.Fragment,{children:[l.jsx(Fr,{string:`${e} reads the following optional fields`}),l.jsxs(zu,{children:[((s==null?void 0:s.length)||0)>=2&&l.jsx(Ju,{id:"select-all-fields",isChecked:u,label:"Select all",onCheckedChange:a,isIndeterminate:d}),l.jsx(Gu,{children:s.map(p=>Tn(p)?null:l.jsx(Wu,{id:p.fieldName,isChecked:!!(o!=null&&o[p==null?void 0:p.fieldName]),label:p.displayName,onCheckedChange:g=>i(g,p.fieldName)},p.fieldName))})]})]})}function Nw(){return l.jsx(Sw,{})}const Tw={color:"var(--amp-colors-text-regular)",backgroundColor:"var(--amp-colors-bg-highlight)",borderRadius:"4px",display:"inline-block",fontSize:"0.75rem",fontWeight:500,lineHeight:"1.25",padding:"0.25rem 0.5rem"};function Rw({children:e,style:t,...n}){return l.jsx("span",{style:{...Tw,...t},...n,children:e})}function Aw(){var r,o,i;const{configureState:e,selectedObjectName:t}=Ct(),{appName:n}=Le();return l.jsxs(l.Fragment,{children:[l.jsx(Fr,{string:`${n} reads the following ${t} fields`}),l.jsx("div",{style:{display:"flex",gap:".5rem",marginBottom:".5rem",flexWrap:"wrap"},children:(o=(r=e==null?void 0:e.read)==null?void 0:r.requiredFields)!=null&&o.length?(i=e.read)==null?void 0:i.requiredFields.map(s=>Tn(s)?null:l.jsx(Rw,{children:s.displayName},s.fieldName)):"There are no required fields."})]})}function Pw(e,t,n,r,o){e.read&&(e.read.selectedValueMappings||(e.read.selectedValueMappings={}),e.read.selectedValueMappings[o]||(e.read.selectedValueMappings[o]={}),e.read.selectedValueMappings[o][n]=r)}function Dw(e,t,n,r,o){t(e,i=>Pw(i,e,n,r,o))}function Fw(e,t,n){t(e,r=>{r.read&&(r.read.isValueMappingsModified=n)})}function Mw({string:e,fieldName:t}){return l.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"1rem",paddingBottom:".5rem"},children:[l.jsxs("h3",{style:{color:"var(--amp-colors-text-muted)",fontSize:"1rem",fontWeight:"400"},children:[e,l.jsx("b",{children:t})]}),l.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:l.jsx(po,{style:{width:"100%",marginLeft:"1rem"}})})]})}function jw({mappedValue:e,onSelectChange:t,fieldName:n,allValueOptions:r,hasError:o}){var v;const{configureState:i,selectedObjectName:s,setConfigureState:a}=Ct(),[c,u]=w.useState(!0),{getError:d,setError:f,resetBoundary:m}=Ht(),p=w.useMemo(()=>{var _,C;return((C=(_=i==null?void 0:i.read)==null?void 0:_.selectedValueMappings)==null?void 0:C[n])||{}},[(v=i==null?void 0:i.read)==null?void 0:v.selectedValueMappings,n]),g=w.useMemo(()=>p==null?void 0:p[e.mappedValue],[p,e.mappedValue]);w.useEffect(()=>{u(!1)},[e,a,s,g,i]);const y=w.useMemo(()=>r.map(_=>({id:_.value,label:_.displayValue,value:_.value})),[r]),h=w.useCallback(_=>{if(_){if(Object.values(p).some(C=>C===_.value&&C!==g)){const C=[...Object.entries(p).filter(([b,S])=>S===_.value&&S!==g).map(([b])=>b),e.mappedValue];f(we.VALUE_MAPPING,n,C);return}d(we.VALUE_MAPPING,n)&&m(we.VALUE_MAPPING),t({target:{name:e.mappedValue,value:_.value,fieldName:n}})}},[t,p,g,n,e.mappedValue,m,f,d]),x=w.useMemo(()=>l.jsx(Js,{disabled:c,items:y,selectedValue:g||null,onSelectedItemChange:h,placeholder:"Please select one",style:{border:o?"2px solid red":void 0,borderRadius:"8px"}},g),[g,c,y,h,o]);return l.jsxs("div",{style:{display:"flex",flexDirection:"column",marginBottom:".25rem"},children:[l.jsx("div",{style:{display:"flex",flexDirection:"row",gap:".25rem",marginBottom:".25rem"},children:l.jsx("span",{style:{fontWeight:500},children:e.mappedDisplayValue})}),x]},e.mappedValue)}function kw(){var p,g,y;const{fieldMapping:e}=ut(),{selectedObjectName:t,configureState:n,setConfigureState:r}=Ct(),{isError:o,removeError:i,getError:s}=Ht(),a=(p=n==null?void 0:n.read)==null?void 0:p.selectedFieldMappings,c=(g=n==null?void 0:n.read)==null?void 0:g.selectedValueMappings,u=(y=n==null?void 0:n.read)==null?void 0:y.isValueMappingsModified,d=w.useRef(!1),f=w.useMemo(()=>{const h=t&&e?Object.values(e[t]||{}).flat().filter(x=>x.mappedValues).map(x=>({...x})):[];if(a)for(let x=0;x<h.length;x+=1)a!=null&&a[h[x].mapToName]&&(h[x].fieldName=a[h[x].mapToName]);return h},[t,e,a]),m=w.useCallback(h=>{const{value:x,name:v,fieldName:_}=h.target;x&&(t&&Dw(t,r,v,x,_),o(we.VALUE_MAPPING,v)&&i(we.VALUE_MAPPING,v))},[t,r,o,i]);return w.useEffect(()=>{if(t&&c){const h=(e==null?void 0:e[t].filter(v=>v.fieldName&&v.mappedValues.length>0))||[];h.every(v=>{const _=c[v.fieldName]||{};return Object.keys(_).length===Object.keys(v.mappedValues).length})&&h.length>0?!u&&!d.current&&(Fw(t,r,!0),d.current=!0):d.current=!1}},[c,f,t,r,e,u]),f!=null&&f.length?l.jsx(l.Fragment,{children:f.map(h=>{var x,v,_,C,b,S,R,N,M,U,q,G,ne,W,ce,re;return h.fieldName?["singleSelect","multiSelect"].includes((_=(v=(x=n==null?void 0:n.read)==null?void 0:x.allFieldsMetadata)==null?void 0:v[h.fieldName])==null?void 0:_.valueType)?(S=(b=(C=n==null?void 0:n.read)==null?void 0:C.allFieldsMetadata)==null?void 0:b[h.fieldName])!=null&&S.values?(M=(N=(R=n==null?void 0:n.read)==null?void 0:R.allFieldsMetadata)==null?void 0:N[h.fieldName])!=null&&M.values&&Object.keys((h==null?void 0:h.mappedValues)||[]).length===Object.keys(((G=(q=(U=n==null?void 0:n.read)==null?void 0:U.allFieldsMetadata)==null?void 0:q[h.fieldName])==null?void 0:G.values)||[]).length?l.jsxs(l.Fragment,{children:[l.jsx(Mw,{string:"Map the values for ",fieldName:h.mapToName||h.fieldName}),l.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:l.jsx(fo,{id:h.mapToName||h.fieldName,children:(re=h==null?void 0:h.mappedValues)==null?void 0:re.map(Q=>{var T,j,K;const fe=s(we.VALUE_MAPPING,h.fieldName),ye=Array.isArray(fe)&&fe.includes(Q.mappedValue);return l.jsxs(l.Fragment,{children:[l.jsx(jw,{allValueOptions:((K=(j=(T=n==null?void 0:n.read)==null?void 0:T.allFieldsMetadata)==null?void 0:j[h.fieldName])==null?void 0:K.values)||[],mappedValue:Q,onSelectChange:m,fieldName:(h==null?void 0:h.fieldName)||"",hasError:ye},`${Q.mappedValue}-${h.fieldName}`),ye&&l.jsx("span",{style:{color:"red",fontSize:"14px",marginTop:"4px"},children:`Each ${h.mapToName||h.fieldName} must be mapped to a unique value`},Q.mappedValue)]})})},h.mapToName||h.fieldName)})]}):(console.error("field values and the values to be mapped are not of the same length",h,(ce=(W=(ne=n==null?void 0:n.read)==null?void 0:ne.allFieldsMetadata)==null?void 0:W[h.fieldName])==null?void 0:ce.values),null):(console.error("field has no values array",h),null):(console.error("fieldName is not a singleSelect or multiSelect",h),null):(console.error("fieldName is undefined",h),null)})}):null}function Lw(){return Vg(),l.jsxs(l.Fragment,{children:[l.jsx(tw,{}),l.jsx(Aw,{}),l.jsx(Yv,{}),l.jsx(Qv,{}),l.jsx(kw,{}),l.jsx(Nw,{})]})}const Vw="_input_10rzg_1",Kw="_inputError_10rzg_27",$w="_error_10rzg_43",Mo={input:Vw,inputError:Kw,error:$w};function Qi({id:e,type:t,className:n,isError:r=!1,...o}){const i=r?It(Mo.inputError,Mo.input):Mo.input;return l.jsx("input",{id:e,type:t,className:It(i,n),...o})}function Uw({objectName:e,onAddDefaultValue:t}){const{readAction:n,loading:r}=dn(),[o,i]=w.useState(null),[s,a]=w.useState(""),c=n&&Cs(n,e),u=w.useMemo(()=>(c==null?void 0:c.allFields)||[],[c]),d=r||!u||u.length===0,f=w.useMemo(()=>u.map(h=>({id:h.fieldName,label:h.displayName,value:h.fieldName})),[u]),m=h=>{const{value:x,name:v}=h.target;x&&i({label:v,value:x})},p=h=>{const{value:x}=h.target;a(x)},g=()=>{s&&(o!=null&&o.value)&&(t(o==null?void 0:o.value,o.label,s),i(null),a(""))},y=l.jsx(Js,{style:{width:"100%"},disabled:d,items:f,selectedValue:(o==null?void 0:o.value)||null,onSelectedItemChange:h=>{m({target:{name:h==null?void 0:h.label,value:h==null?void 0:h.value}})},placeholder:"Please select field."});return l.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[y,l.jsx(Qi,{id:"new-default-value",type:"text",value:s,onChange:p,style:{width:"10rem"},placeholder:"default value"}),l.jsx(at,{type:"button",onClick:g,variant:"ghost",children:"+"})]})}function qw(e,t,n,r){var o,i,s,a;if(((o=e==null?void 0:e.write)==null?void 0:o.selectedWriteObjects)===null&&(e.write.selectedWriteObjects={}),e!=null&&e.write){const c=e.write.selectedWriteObjects;if(r&&(c[t]||(c[t]={}),c[t].selectedValueDefaults||(c[t].selectedValueDefaults={}),c[t].selectedValueDefaults[n]=r),r||(i=c[t])!=null&&i.selectedValueDefaults&&delete c[t].selectedValueDefaults[n],(a=(s=e==null?void 0:e.write)==null?void 0:s.savedConfig)!=null&&a.selectedWriteObjects){const u=e.write.savedConfig.selectedWriteObjects,f=!bl(u,c);e.write.isWriteModified=f}}}function Ic(e,t,n,r,o){o(e,i=>{qw(i,t,n,r)})}const Hw=(e,t,n)=>{var i;const r=n&&Cs(n,t),o=r==null?void 0:r.allFieldsMetadata;return((i=o==null?void 0:o[e])==null?void 0:i.displayName)||e};function Bw({objectName:e}){var f;const{readAction:t}=dn(),{selectedObjectName:n,configureState:r,setConfigureState:o}=Ct(),i=(f=r==null?void 0:r.write)==null?void 0:f.selectedWriteObjects,s=i==null?void 0:i[e],a=w.useMemo(()=>(s==null?void 0:s.selectedValueDefaults)||{},[s]),c=w.useCallback((m,p,g)=>{Ic(n||"",e,m,g,o)},[e,n,o]),u=m=>{Ic(n||"",e,m,null,o)},d=Object.keys(a).map(m=>({field:m,defaultValue:a[m],fieldDisplayName:t?Hw(m,e,t):m}));return l.jsxs(l.Fragment,{children:[l.jsx("div",{style:{paddingBottom:"1rem",display:"flex",flexDirection:"column",gap:".5rem"},children:d.map(({field:m,fieldDisplayName:p,defaultValue:g})=>l.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[l.jsx(Qi,{id:m,type:"text",disabled:!0,value:p,style:{width:"100%"}}),l.jsx(Qi,{id:`${m}-${g}`,type:"text",disabled:!0,value:g,style:{width:"10rem"}}),l.jsx(at,{type:"button",variant:"ghost",onClick:()=>u(m),children:"x"})]},`${m}-${g}`))}),l.jsx(Uw,{objectName:e,onAddDefaultValue:c}),l.jsx("div",{style:{textAlign:"right",padding:".25rem 0",color:"var(--amp-colors-text-muted)"},children:"click + to confirm"})]})}const Ww=(e,t)=>!!t.find(n=>{var r;return n.objectName===e&&((r=n==null?void 0:n.valueDefaults)==null?void 0:r.allowAnyFields)});function Jw(){var o;const{configureState:e}=Ct(),{writeObjects:t}=dn(),n=(o=e==null?void 0:e.write)==null?void 0:o.selectedWriteObjects;return!!t&&l.jsx(l.Fragment,{children:t.map(i=>n!=null&&n[i.objectName]&&Ww(i.objectName,t)?l.jsxs(l.Fragment,{children:[l.jsx(Fr,{string:`Defaults for ${i.displayName} `}),l.jsx(Bw,{objectName:i.objectName})]}):null)})}function zw(e,t,n){var r,o,i;if(((r=e==null?void 0:e.write)==null?void 0:r.selectedWriteObjects)===null&&(e.write.selectedWriteObjects={}),e!=null&&e.write){const s=e.write.selectedWriteObjects;if(n&&(s[t]={objectName:t}),n||delete s[t],(i=(o=e==null?void 0:e.write)==null?void 0:o.savedConfig)!=null&&i.selectedWriteObjects){const a=e.write.savedConfig.selectedWriteObjects,u=!bl(a,s);e.write.isWriteModified=u}}}function bc(e,t,n,r){t(e,o=>{zw(o,n,r)})}function Gw(){var f,m,p,g;const{appName:e,selectedObjectName:t,configureState:n,setConfigureState:r}=Ct(),o=(f=n==null?void 0:n.write)==null?void 0:f.selectedWriteObjects,i=(m=n==null?void 0:n.write)==null?void 0:m.writeObjects,s=(y,h)=>{y!=="indeterminate"&&t&&n&&bc(t,r,h,y)},a=y=>{var h,x;t&&n&&((x=(h=n==null?void 0:n.write)==null?void 0:h.writeObjects)==null||x.forEach(v=>{bc(t,r,v.objectName,y)}))},c=!!i,u=Object.keys(o||{}).length===((g=(p=n==null?void 0:n.write)==null?void 0:p.writeObjects)==null?void 0:g.length),d=!u&&Object.keys(o||{}).length>0;return c&&l.jsxs(l.Fragment,{children:[l.jsx(Fr,{string:`Allow ${e} to write to these objects`}),l.jsxs(zu,{children:[((i==null?void 0:i.length)||0)>=2&&l.jsx(Ju,{id:"select-all-fields",onCheckedChange:a,isIndeterminate:d,isChecked:u,label:"Select all"}),l.jsx(Gu,{children:i.map(y=>l.jsx(Wu,{id:y.objectName,onCheckedChange:h=>s(h,y.objectName),isChecked:!!(o!=null&&o[y.objectName]),label:y.displayName},y.objectName))})]})]})}function Xw(){return l.jsxs(l.Fragment,{children:[l.jsx(Gw,{}),l.jsx(Jw,{})]})}function Xu({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={}}){const r=tt(),{projectId:o}=Le(),{integrationId:i,installation:s,resetInstallations:a,setIntegrationDeleted:c,onUninstallSuccess:u}=ut(),[d,f]=w.useState(!1),m=!o||!i||!(s!=null&&s.id)||d,p=async()=>{if(!m){f(!0),console.warn("uninstalling installation",{projectId:o,integrationId:i,installationId:s.id});try{await je().installationApi.deleteInstallation({projectIdOrName:o,integrationId:i,installationId:s.id},{headers:{"X-Api-Key":r,"Content-Type":"application/json"}}),console.warn("successfully uninstalled installation:",s.id),u==null||u(s==null?void 0:s.id),a(),c()}catch(h){console.error("Error uninstalling installation."),st(h)}finally{f(!1)}}},g=d?"Uninstalling...":e,y=l.jsx(at,{type:"button",onClick:p,disabled:m,variant:t,style:n,children:g});return s!=null&&s.id?y:null}function Qw(){const{appName:e}=Le(),{installation:t}=ut();return l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[t!=null&&t.id?l.jsxs("p",{children:["Once you uninstall this integration, all your configuration will be lost, and"," ",l.jsx("b",{children:e})," may stop working."]}):l.jsx("p",{children:"You've successfully uninstalled the integration."}),l.jsx(Xu,{buttonText:"Yes, uninstall",buttonVariant:"danger"})]})}function Qu({onSave:e,onReset:t,isLoading:n,isCreateMode:r=!1,errorMsg:o}){var S,R,N,M;const{installation:i}=ut(),{hydratedRevision:s,loading:a}=dn(),{configureState:c,selectedObjectName:u}=Ct(),d=i==null?void 0:i.config,f=d&&u&&!!yl(d,u)||!1,m=((S=c==null?void 0:c.read)==null?void 0:S.isOptionalFieldsModified)||((R=c==null?void 0:c.read)==null?void 0:R.isRequiredMapFieldsModified)||((N=c==null?void 0:c.read)==null?void 0:N.isValueMappingsModified),p=(M=c==null?void 0:c.write)==null?void 0:M.isWriteModified,x=a||n||!c||!u||!(m||p||r||u!==er&&!f),v=u===er,_=u===Li,C=l.jsx(at,{type:"submit",disabled:x,children:r?"Install":"Save"}),b=l.jsx(at,{type:"button",onClick:t,disabled:x,variant:"ghost",children:"Reset"});return n?l.jsx(Br,{}):l.jsxs("form",{style:{width:"34rem"},onSubmit:e,children:[l.jsxs("div",{style:{display:"flex",flexDirection:"row-reverse",gap:".8rem",marginBottom:"20px"},children:[C,b]}),l.jsxs(Pn,{style:{padding:"1rem 2rem",minHeight:"300px",backgroundColor:"var(--amp-colors-bg-primary)",borderColor:"var(--amp-colors-border)"},children:[o&&l.jsx(Rl,{children:typeof o=="string"?o:"Installation Failed."}),a&&l.jsx(Br,{}),s&&!_&&!v&&l.jsx(Lw,{}),s&&!_&&v&&l.jsx(Xw,{}),!a&&_&&l.jsx(Qw,{})]})]})}const Yu=()=>{const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,onInstallSuccess:o,onUpdateSuccess:i}=ut(),{hydratedRevision:s,loading:a}=dn(),{selectedObjectName:c}=Fl(),{selectedConnection:u}=or(),d=tt(),{projectId:f}=Le(),{resetBoundary:m,setErrors:p,setError:g,getError:y}=Ht(),{resetConfigureState:h,objectConfigurationsState:x,resetPendingConfigurationState:v}=Ns(),_=Nl(c||"",x),{onNextIncompleteTab:C}=xg(),b=w.useCallback(()=>{m(we.INSTALLATION_MUTATION)},[m]),S=w.useCallback(N=>N?M=>{g(we.INSTALLATION_MUTATION,N,M)}:M=>{console.error("objectName is required to set installation error: ",M)},[g]),R=w.useCallback(N=>N?y(we.INSTALLATION_MUTATION,N):"",[y]);return{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:s,loading:a,selectedObjectName:c,selectedConnection:u,apiKey:d,projectId:f,resetBoundary:m,setErrors:p,setMutateInstallationError:S,getMutateInstallationError:R,resetMutateInstallationErrorState:b,resetConfigureState:h,objectConfigurationsState:x,resetPendingConfigurationState:v,configureState:_,onInstallSuccess:o,onUpdateSuccess:i,onNextIncompleteTab:C}},Yw=void 0;function Zw(){const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:o,loading:i,selectedObjectName:s,selectedConnection:a,apiKey:c,projectId:u,resetBoundary:d,setErrors:f,setMutateInstallationError:m,getMutateInstallationError:p,resetMutateInstallationErrorState:g,resetConfigureState:y,objectConfigurationsState:h,resetPendingConfigurationState:x,configureState:v,onInstallSuccess:_,onNextIncompleteTab:C}=Yu(),[b,S]=w.useState(!1),R=s===er,N=p(s),M=w.useCallback(()=>{d(we.MAPPING),o!=null&&o.content&&!i&&s&&Cl(o,Yw,s,y)},[d,o,i,s,y]);w.useEffect(()=>{!v&&(o!=null&&o.content)&&!i&&M()},[v,h,o,i,M]);const U=()=>{g();const{requiredMapFields:ne,selectedFieldMappings:W}=(v==null?void 0:v.read)||{},{errorList:ce}=Il(ne,W,f);ce.length>0||(s&&(a!=null&&a.id)&&c&&u&&e&&t&&n&&o?(S(!0),fg(u,e,t,n,a.id,s,c,o,v,m(s),r,_).finally(()=>{S(!1),x(s),C()})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},q=()=>{g(),s&&(a!=null&&a.id)&&c&&u&&e&&t&&n&&o?(S(!0),mg(u,e,t,n,a.id,c,o,v,m(s),r,_).finally(()=>{S(!1),x(s),C()})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},G=ne=>{ne.preventDefault(),R?q():U()};return l.jsx(Qu,{errorMsg:N,isCreateMode:!0,isLoading:b,onSave:G,onReset:M})}function eI({updateConfig:e,projectId:t,integrationId:n,installationId:r,apiKey:o,selectedObjectName:i,setInstallation:s,onUpdateSuccess:a,setError:c}){const u={projectIdOrName:t,installationId:r,integrationId:n,installationUpdate:{updateMask:[`config.content.read.objects.${i}`],installation:{config:e}}};return je().installationApi.updateInstallation(u,{headers:{"X-Api-Key":o,"Content-Type":"application/json"}}).then(d=>{s(d),a==null||a(d.id,d.config)}).catch(d=>{st(d,c)})}const tI=(e,t,n,r,o,i)=>{const s=Ol(e),a=El(e),c=Sl(e),u={content:{read:{objects:{[t]:{objectName:t,schedule:r,destination:(n==null?void 0:n.destination)||"",selectedFields:s,selectedFieldMappings:a,selectedValueMappings:c||{},backfill:i}}}}};return to(o)&&(u.content||(u.content={}),u.content.proxy={enabled:!0}),u},nI=(e,t,n,r,o,i,s,a,c,u,d)=>{const f=tI(i,r||"",a,a.schedule,c,a.backfill);return f?eI({updateConfig:f,projectId:e,integrationId:t,installationId:n,apiKey:o,selectedObjectName:r,setError:u,setInstallation:s,onUpdateSuccess:d}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},rI=(e,t)=>{const r={content:{write:{objects:Tl(e)}}};return to(t)&&(r.content||(r.content={}),r.content.proxy={enabled:!0}),r},iI=(e,t,n,r,o,i,s,a,c)=>{const u=rI(o,i);if(!u)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const d={projectIdOrName:e,installationId:n,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:u}}};return je().installationApi.updateInstallation(d,{headers:{"X-Api-Key":r,"Content-Type":"application/json"}}).then(f=>{a(f),c==null||c(f.id,f.config)}).catch(f=>{st(f,s)})};function oI({installation:e,integrationObj:t}){const{setInstallation:n,hydratedRevision:r,loading:o,selectedObjectName:i,apiKey:s,projectId:a,resetBoundary:c,setErrors:u,setMutateInstallationError:d,getMutateInstallationError:f,resetConfigureState:m,resetPendingConfigurationState:p,configureState:g,onUpdateSuccess:y,onNextIncompleteTab:h}=Yu(),[x,v]=w.useState(!1),_=i===er,C=f(i),{config:b}=e,S=w.useCallback(()=>{c(we.MAPPING),r!=null&&r.content&&!o&&i&&Cl(r,b,i,m)},[c,r,o,i,b,m]);w.useEffect(()=>{g||S()},[g,S]);const R=w.useMemo(()=>{var G,ne,W;return(W=(ne=(G=r==null?void 0:r.content)==null?void 0:G.read)==null?void 0:ne.objects)==null?void 0:W.find(ce=>(ce==null?void 0:ce.objectName)===i)},[r,i]),N=()=>{const{requiredMapFields:q,selectedFieldMappings:G}=(g==null?void 0:g.read)||{},{errorList:ne}=Il(q,G,u);ne.length>0||(r&&e&&i&&s&&a&&R?(v(!0),nI(a,t.id,e.id,i,s,g,n,R,r,d(i),y).finally(()=>{v(!1),p(i),h()})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},M=()=>{e&&i&&s&&a&&r?(v(!0),iI(a,t.id,e.id,s,g,r,d(i),n,y).finally(()=>{v(!1),p(i),h()})):console.error("UpdateInstallation - onSaveUpdate missing required props")},U=q=>{q.preventDefault(),_?M():N()};return l.jsx(Qu,{errorMsg:C,onSave:U,onReset:S,isLoading:x})}function sI(){const{integrationObj:e,installation:t}=ut();return e?t&&e?l.jsx(oI,{installation:t,integrationObj:e}):l.jsx(Zw,{}):l.jsx(cl,{message:"We can't load the integration"})}const aI=(e,t)=>({revisionId:e.id,createdBy:`consumer:${t}`,content:{provider:e.content.provider,proxy:{enabled:!0}}});function cI({projectId:e,integrationId:t,groupRef:n,consumerRef:r,connectionId:o,apiKey:i,hydratedRevision:s,setError:a,setInstallation:c,onInstallSuccess:u}){const d=aI(s,r);return d?Os({createConfig:d,projectId:e,integrationId:t,groupRef:n,connectionId:o,apiKey:i,setError:a,setInstallation:c,onInstallSuccess:u}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))}function lI(){return l.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"#BBF7D0"}),l.jsx("path",{d:"M34.6666 18.6667L20 32.0001L13.3333 25.9395",stroke:"#16A34A",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}function ra({text:e,children:t}){return l.jsx(Pr,{children:l.jsxs(Pn,{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"3rem",gap:"3rem"},children:[l.jsx(lI,{}),l.jsx("p",{children:e}),t]})})}function uI({provider:e}){const t=`You have successfully installed your ${Dn(e)} integration.`;return l.jsx(ra,{text:t,children:l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:l.jsx(Xu,{buttonText:"Uninstall",buttonVariant:"outline",buttonStyle:{fontSize:"13px"}})})})}const dI=e=>{const{read:t,write:n,proxy:r}=(e==null?void 0:e.content)??{};return!t&&!n&&(r==null?void 0:r.enabled)||!1};function fI({children:e}){var _;const{projectId:t}=Le(),n=tt(),{hydratedRevision:r,loading:o}=dn(),{integrationObj:i,installation:s,groupRef:a,consumerRef:c,setInstallation:u,onInstallSuccess:d,isIntegrationDeleted:f}=ut(),{selectedConnection:m}=or(),[p,g]=w.useState(!1),y=o||p,h=(_=r==null?void 0:r.content)==null?void 0:_.provider,x=dI(r),v=C=>{console.error("Error when creating proxy installation:",C)};return w.useEffect(()=>{!y&&r&&x&&!s&&m&&n&&(i!=null&&i.id)&&!f&&(g(!0),cI({apiKey:n,projectId:t,integrationId:i==null?void 0:i.id,groupRef:a,consumerRef:c,connectionId:m==null?void 0:m.id,hydratedRevision:r,setError:v,setInstallation:u,onInstallSuccess:d}).then(()=>{g(!1)}).catch(C=>{g(!1),console.error("Error when creating proxy installation:",C)}))},[r,x,s,m,n,t,i==null?void 0:i.id,a,c,u,y,d,f]),i?y?l.jsx(eo,{}):x&&h&&s?l.jsx(uI,{provider:h}):l.jsx("div",{children:e}):l.jsx(un,{message:"We can't load the integration"})}function Zu(){return l.jsxs("footer",{style:{backgroundColor:"light-dark(#EFEFEF, #646266)",padding:"1em",fontSize:"0.8em",color:"gray",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"0 0 4px 4px",gap:"0.4em"},children:[l.jsx("p",{style:{color:"light-dark(gray, #EFEFEF)"},children:"Secured by"}),l.jsx("a",{href:"https://www.withampersand.com/",target:"_blank","aria-label":"Go to Ampersand",rel:"noreferrer noopener",children:l.jsxs("picture",{children:[l.jsx("source",{srcSet:"https://res.cloudinary.com/dycvts6vp/image/upload/v1723671980/ampersand-logo-black.svg",media:"(prefers-color-scheme: light)"}),l.jsx("source",{srcSet:"https://res.cloudinary.com/dycvts6vp/image/upload/v1735853540/ampersand_logo_white.svg",media:"(prefers-color-scheme: dark)"}),l.jsx("img",{style:{height:".8em"},src:"https://res.cloudinary.com/dycvts6vp/image/upload/v1723671980/ampersand-logo-black.svg",alt:"Ampersand"})]})})]})}function ai({children:e}){return l.jsx(Pr,{children:l.jsxs(Pn,{children:[l.jsx("div",{style:{padding:"3rem 2rem"},children:e}),l.jsx(Zu,{})]})})}function ci({children:e}){return l.jsx("h1",{style:{fontWeight:600,lineHeight:1.2,fontSize:"1.2em"},children:e})}function li({error:e}){return e?l.jsx(Rl,{style:{marginTop:"2em"},children:e}):null}function ia({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r,children:o,title:i}){if(!i&&!r)throw new Error("Either title or providerName is required");return l.jsxs(ai,{children:[l.jsx(ci,{children:i||`Set up ${r} integration`}),l.jsx(li,{error:t}),o,l.jsx(at,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}const pI="_link_oo2kv_1",hI={link:pI};function ed({href:e,className:t,style:n,label:r,children:o,newTab:i=!1}){return l.jsx("a",{className:It(hI.link,t),style:n,href:e,"aria-label":r||void 0,target:i?"_blank":"_self",rel:i?"noopener noreferrer":void 0,children:o})}function td({url:e,providerDisplayName:t,credentialName:n}){return l.jsxs("p",{style:{color:"var(--amp-colors-text-muted)"},children:[l.jsx(ed,{href:e,newTab:!0,children:l.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," about where to find your ",t," ",n,"."]})}const mI="_textarea_18zl4_1",gI="_textareaError_18zl4_14",yI="_error_18zl4_29",jo={textarea:mI,textareaError:gI,error:yI};function vI({className:e,isError:t=!1,...n}){const r=t?It(jo.textareaError,jo.textarea):jo.textarea;return l.jsx("textarea",{className:It(e,r),...n})}const ln={Input:Qi,Textarea:vI};function wI({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){var y;const[i,s]=w.useState(!1),a=()=>s(h=>!h),[c,u]=w.useState(""),d=h=>u(h.currentTarget.value),f=c.length>0,m=o||!f,p=Dn(e,t),g=(y=t.apiKeyOpts)==null?void 0:y.docsURL;return l.jsx(ia,{providerName:p,handleSubmit:()=>{n({apiKey:c})},error:r,isButtonDisabled:m,children:l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[g&&l.jsx(td,{url:g,providerDisplayName:p,credentialName:"API key"}),l.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[l.jsx(ln.Input,{id:"password",name:"password",type:i?"text":"password",placeholder:"API Key",onChange:h=>d(h)}),l.jsx(at,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:a,children:i?"Hide":"Show"})]})]})})}function II({...e}){return l.jsx(wI,{...e})}function bI({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a,setSelectedConnection:c}){const u=Le(),[d,f]=w.useState(!1),[m,p]=w.useState(null),g=tt();w.useEffect(()=>{if(e&&je&&d&&m!=null){const h={groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,apiKey:m};je().connectionApi.generateConnection({projectIdOrName:u.projectId,generateConnectionParams:h},{headers:{"X-Api-Key":g??"","Content-Type":"application/json"}}).then(x=>{c(x)}).catch(x=>{console.error("Error loading provider info."),st(x)})}},[g,e,d,r,n,i,o,u,c,m]);const y=h=>{p(h.apiKey),f(!0)};return a===null?l.jsx(II,{provider:e,providerInfo:t,handleSubmit:y,error:null}):s}function _I({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){var x;const[i,s]=w.useState(!1),a=()=>s(v=>!v),[c,u]=w.useState({username:"",password:""}),{username:d,password:f}=c,m=Dn(e,t),p=(x=t.basicOpts)==null?void 0:x.docsURL,g=d.length>0,y=o||!g,h=v=>{const{name:_,value:C}=v.currentTarget;u(b=>({...b,[_]:C}))};return l.jsx(ia,{providerName:m,handleSubmit:()=>{n({user:d,pass:f})},error:r,isButtonDisabled:y,children:l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[p&&l.jsx(td,{url:p,providerDisplayName:m,credentialName:"credentials"}),l.jsx(ln.Input,{id:"username",name:"username",type:"text",placeholder:"Username",onChange:v=>h(v)}),l.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[l.jsx(ln.Input,{id:"password",name:"password",type:i?"text":"password",placeholder:"Password",onChange:v=>h(v)}),l.jsx(at,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:a,children:i?"Hide":"Show"})]})]})})}function xI({...e}){return l.jsx(_I,{...e})}function CI({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a,setSelectedConnection:c}){const u=Le(),[d,f]=w.useState(!1),[m,p]=w.useState(null),g=tt();w.useEffect(()=>{if(e&&je&&d&&m!=null){const h={groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,basicAuth:{username:m.user,password:m.pass}};je().connectionApi.generateConnection({projectIdOrName:u.projectId,generateConnectionParams:h},{headers:{"X-Api-Key":g??"","Content-Type":"application/json"}}).then(x=>{c(x)}).catch(x=>{console.error("Error loading provider info."),st(x)})}},[g,e,d,r,n,i,o,u,m,c]);const y=h=>{const{user:x,pass:v}=h;p({user:x,pass:v}),f(!0)};return a===null?l.jsx(xI,{provider:e,providerInfo:t,handleSubmit:y,error:null}):s}function OI({...e}){return l.jsx(ia,{...e})}function EI({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,selectedConnection:s,setSelectedConnection:a,providerName:c}){const u=Le(),d=tt(),[f,m]=w.useState(!1);w.useEffect(()=>{if(e&&je&&f){const g={groupName:o,groupRef:r,consumerName:n,consumerRef:t,provider:e};je().connectionApi.generateConnection({projectIdOrName:u.projectId,generateConnectionParams:g},{headers:{"X-Api-Key":d??"","Content-Type":"application/json"}}).then(y=>{a(y)}).catch(y=>{console.error("Error loading provider info."),st(y)})}},[d,e,f,n,t,o,r,a,u]);const p=()=>{m(!0)};return s===null?l.jsx(OI,{handleSubmit:p,error:null,providerName:c}):i}const SI=_s("VITE_AMP_ENABLE_CSRF",!1),NI=_s("NEXT_AMP_ENABLE_CSRF",!1),TI=_s("REACT_APP_AMP_ENABLE_CSRF",!1),RI=!!SI||!!NI||!!TI,nd=async(e,t,n,r,o,i,s,a)=>{var u,d;const c=await je().providerApi.getProvider({provider:o},{headers:{"X-Api-Key":r??""}});if(!c)throw new Error(`Provider ${o} not found`);if(c.authType==="oauth2"&&(((u=c.oauth2Opts)==null?void 0:u.grantType)==="authorizationCode"||((d=c.oauth2Opts)==null?void 0:d.grantType)==="authorizationCodePKCE")){const m=(await je().providerAppApi.listProviderApps({projectIdOrName:e},{headers:{"X-Api-Key":r??""}})).find(h=>h.provider===o),p=Dn(o,c);if(!m)throw new Error(`You must first set up a ${p} Provider App using the Ampersand Console.`);const g={connectOAuthParams:{providerWorkspaceRef:i,projectId:e,groupRef:n,groupName:a,consumerRef:t,consumerName:s,providerAppId:m.id,provider:o,enableCSRFProtection:RI}};return await je().oAuthApi.oauthConnect(g,{credentials:"include",headers:{"X-Api-Key":r??"","Content-Type":"application/json"}})}throw new Error(`Provider ${o} does not support an OAuth2 web flow.`)},_c=600,xc=600,AI="AUTHORIZATION_SUCCEEDED",PI="AUTHORIZATION_FAILED";function DI(e,t,n){return w.useCallback(async r=>{const o=await je().connectionApi.getConnection({projectIdOrName:e,connectionId:r},{headers:{"X-Api-Key":t??""}});n(o)},[e,t,n])}function FI(e,t,n,r){return w.useCallback(()=>{if(!r)return;const o=window.screenX+(window.outerWidth-_c)/2,i=window.screenY+(window.outerHeight-xc)/2.5,s=`width=${_c},height=${xc},left=${o},top=${i}`,a=window.open(r,e,s);t(a),window.addEventListener("message",n,!1)},[r,e,t,n])}function MI(e,t){return w.useCallback(n=>{var r,o;if(n.origin===Tm){if(n.data.eventType===AI){const i=(r=n.data.data)==null?void 0:r.connection;i?e(i):console.error("Connection ID not found in event data: ",{event:n})}n.data.eventType===PI&&(console.error("OAuth failed: ",{event:n}),t==null||t(((o=n==null?void 0:n.data)==null?void 0:o.message)??"OAuth failed. Please try again."))}},[t,e])}function rd({children:e,oauthUrl:t,windowTitle:n="Connect to Provider",onError:r,error:o}){const i=tt(),{projectId:s}=Le(),[a,c]=w.useState(null),[u,d]=w.useState(null),{setSelectedConnection:f}=or(),m=MI(c,r),p=FI(n,d,m,t),g=DI(s,i,f);return w.useEffect(()=>{t&&!u&&p()},[t,u,p,m,n]),w.useEffect(()=>{a&&g(a).then(()=>{u==null||u.close()}).catch(y=>{console.error("Error refreshing connection: ",y),r==null||r(y.message??"Unexpected error: not able to refresh connection")})},[a,i,f,g,u,r]),w.useEffect(()=>{if(!u)return;const y=setInterval(()=>{u.closed&&(clearInterval(y),window.removeEventListener("message",m),d(null),!a&&!o?(console.error("OAuth failed. Please try again."),r==null||r("OAuth failed. Please try again.")):a&&(r==null||r(null)))},500);return()=>{clearInterval(y),window.removeEventListener("message",m)}},[u,a,o,m,r]),l.jsx("div",{children:e})}function jI({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return l.jsxs(ai,{children:[l.jsx(ci,{children:`Set up ${r} integration`}),l.jsx(li,{error:t}),l.jsx(at,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function kI({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,providerName:i}){const{projectId:s}=Le(),a=tt(),[c,u]=w.useState(null),[d,f]=w.useState(null),m=async()=>{f(null);try{const g=await nd(s,t,r,a,e,void 0,n,o);u(g)}catch(g){console.error("Could not fetch OAuth popup URL."),st(g),f(g.message??"Unexpected error")}},p=w.useCallback(g=>{f(g),u(null)},[]);return l.jsx(rd,{windowTitle:`Connect to ${i}`,oauthUrl:c,onError:p,children:l.jsx(jI,{handleSubmit:m,error:d,providerName:i})})}const LI="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function VI({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r}){return l.jsxs(ai,{children:[l.jsx(ci,{children:"Enter your Salesforce subdomain"}),l.jsx(ed,{href:LI,newTab:!0,children:"What is my Salesforce subdomain?"}),l.jsx(li,{error:n}),l.jsxs("div",{style:{display:"flex",marginTop:"1em",alignItems:"center"},children:[l.jsx(ln.Input,{id:"salesforce-subdomain",type:"text",placeholder:"my-domain",onChange:o=>t(o.currentTarget.value)}),l.jsx("p",{style:{lineHeight:"2.2em",marginLeft:"0.4em"},children:".my.salesforce.com"})]}),l.jsx(at,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}function KI({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r,providerName:o}){return l.jsxs(ai,{children:[l.jsxs(ci,{children:["Enter your ",o," workspace"]}),l.jsx(li,{error:n}),l.jsx("br",{}),l.jsx(ln.Input,{id:"workspace",type:"text",placeholder:"MyWorkspace",onChange:i=>t(i.currentTarget.value)}),l.jsx("br",{}),l.jsx(at,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}const $I="salesforce";function UI({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,providerName:i}){const{projectId:s}=Le(),a=tt(),[c,u]=w.useState(""),[d,f]=w.useState(null),[m,p]=w.useState(null),g=async()=>{if(p(null),!c){p("Workspace is required");return}try{const x=await nd(s,t,r,a,e,c,n,o);f(x)}catch(x){console.error(x),p((x==null?void 0:x.message)??"Unexpected error")}},y=w.useCallback(x=>{p(x),f(null)},[]),h=e===$I?l.jsx(VI,{handleSubmit:g,setWorkspace:u,error:m,isButtonDisabled:c.length===0}):l.jsx(KI,{handleSubmit:g,setWorkspace:u,error:m,isButtonDisabled:c.length===0,providerName:i});return l.jsx(rd,{windowTitle:`Connect to ${i}`,oauthUrl:d,onError:y,children:h})}function qI({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r,explicitScopesRequired:o,explicitWorkspaceRequired:i}){const[s,a]=w.useState(!1),[c,u]=w.useState({clientSecret:"",clientId:"",workspace:"",scopes:""}),d=()=>a(b=>!b),f=b=>{const{name:S,value:R}=b.currentTarget;u(N=>({...N,[S]:R}))},{clientSecret:m,clientId:p,workspace:g,scopes:y}=c,h=m.length>0,x=p.length>0,v=i?g.length>0:!0,_=n||!h||!x||!v,C=()=>{const b={clientId:p,clientSecret:m};i&&(b.workspace=g),o&&y.length>0&&(b.scopes=Xm(y)),e(b)};return l.jsxs(ai,{children:[l.jsx(ci,{children:`Set up ${r} integration`}),l.jsx(li,{error:t}),l.jsx("br",{}),l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.2rem"},children:[i&&l.jsx(ln.Input,{id:"workspace",name:"workspace",type:"text",placeholder:"MyWorkspace",onChange:b=>f(b)}),l.jsx(ln.Input,{id:"clientId",name:"clientId",type:"text",placeholder:"Client ID",onChange:b=>f(b)}),l.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[l.jsx(ln.Input,{id:"clientSecret",name:"clientSecret",type:s?"text":"password",placeholder:"Client Secret",onChange:b=>f(b)}),l.jsx(at,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:d,children:s?"Hide":"Show"})]}),o&&l.jsx(ln.Textarea,{name:"scopes",placeholder:"Scopes separated by new line",onChange:b=>f(b)})]}),l.jsx("br",{}),l.jsx(at,{style:{marginTop:"1em",width:"100%"},disabled:_,type:"submit",onClick:C,children:"Next"})]})}function HI({provider:e,providerName:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,explicitScopesRequired:s,explicitWorkspaceRequired:a,selectedConnection:c,setSelectedConnection:u}){const{projectId:d}=Le(),f=tt(),[m,p]=w.useState(null),g=async y=>{p(null);const h={groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,providerWorkspaceRef:y.workspace,oauth2ClientCredentials:{clientId:y.clientId,clientSecret:y.clientSecret,scopes:y.scopes}};je().connectionApi.generateConnection({projectIdOrName:d,generateConnectionParams:h},{headers:{"X-Api-Key":f??"","Content-Type":"application/json"}}).then(x=>{u(x)}).catch(x=>{console.error("Error loading provider info."),st(x),p("Error loading provider info")})};return c===null?l.jsx(qI,{providerName:t,handleSubmit:g,error:m,explicitScopesRequired:s,explicitWorkspaceRequired:a}):l.jsx(Br,{})}function BI({...e}){return l.jsx(HI,{...e})}const WI="authorizationCode",JI="authorizationCodePKCE",zI="clientCredentials";function GI({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,selectedConnection:s,setSelectedConnection:a}){if(t.oauth2Opts===void 0)return l.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:c,explicitScopesRequired:u,explicitWorkspaceRequired:d}=t.oauth2Opts,f=Dn(e,t),m={provider:e,consumerRef:n,consumerName:r,groupRef:o,groupName:i,providerName:f};return c===WI||c===JI?d?l.jsx(UI,{...m}):l.jsx(kI,{...m}):c===zI?l.jsx(BI,{...m,explicitWorkspaceRequired:d,explicitScopesRequired:u,selectedConnection:s,setSelectedConnection:a}):c==="password"?l.jsx("em",{children:"Password flow not supported yet"}):l.jsxs("em",{children:["Unsupported grant type: ",c]})}function XI(e){const{selectedConnection:t}=or();w.useEffect(()=>{e&&t&&e(t)},[e,t])}function QI({onSuccess:e}){XI(e)}const YI=async(e,t)=>{const n=await je().providerApi.getProvider({provider:t},{headers:{"X-Api-Key":e??""}});if(!n)throw new Error(`Provider ${t} not found`);return n};function id({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,onSuccess:s,onDisconnectSuccess:a,resetComponent:c}){const u=tt(),[d,f]=w.useState(null),{provider:m,isIntegrationDeleted:p}=ut(),{selectedConnection:g,setSelectedConnection:y}=or();QI({onSuccess:s});const h=e||m,x=(d==null?void 0:d.displayName)??Wr(h);if(w.useEffect(()=>{YI(u,h).then(_=>{f(_)}).catch(_=>{console.error("Error loading provider info."),st(_)})},[u,h]),!e&&!m)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");if(p)return l.jsx(ra,{text:"Integration successfully uninstalled.",children:l.jsx(at,{type:"button",onClick:c,style:{width:"100%"},children:"Reinstall Integration"})});if(g)return i;if(d==null)return l.jsx("strong",{children:"Provider not found"});const v={provider:h,consumerRef:t,consumerName:n,groupRef:r,groupName:o,selectedConnection:g,setSelectedConnection:y,providerName:x,providerInfo:d,onDisconnectSuccess:a};return d.authType==="none"?l.jsx(EI,{...v,children:i}):d.authType==="basic"?l.jsx(CI,{...v,children:i}):d.authType==="apiKey"?l.jsx(bI,{...v,children:i}):l.jsx(GI,{...v})}function ZI(e){const t=e+"CollectionProvider",[n,r]=ho(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=p=>{const{scope:g,children:y}=p,h=w.useRef(null),x=w.useRef(new Map).current;return l.jsx(o,{scope:g,itemMap:x,collectionRef:h,children:y})};s.displayName=t;const a=e+"CollectionSlot",c=w.forwardRef((p,g)=>{const{scope:y,children:h}=p,x=i(a,y),v=Qr(g,x.collectionRef);return l.jsx(Xi,{ref:v,children:h})});c.displayName=a;const u=e+"CollectionItemSlot",d="data-radix-collection-item",f=w.forwardRef((p,g)=>{const{scope:y,children:h,...x}=p,v=w.useRef(null),_=Qr(g,v),C=i(u,y);return w.useEffect(()=>(C.itemMap.set(v,{ref:v,...x}),()=>void C.itemMap.delete(v))),l.jsx(Xi,{[d]:"",ref:_,children:h})});f.displayName=u;function m(p){const g=i(e+"CollectionConsumer",p);return w.useCallback(()=>{const h=g.collectionRef.current;if(!h)return[];const x=Array.from(h.querySelectorAll(`[${d}]`));return Array.from(g.itemMap.values()).sort((C,b)=>x.indexOf(C.ref.current)-x.indexOf(b.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:s,Slot:c,ItemSlot:f},m,r]}var eb=$.useId||(()=>{}),tb=0;function od(e){const[t,n]=$.useState(eb());return Gi(()=>{e||n(r=>r??String(tb++))},[e]),e||(t?`radix-${t}`:"")}var nb=$.createContext(void 0);function sd(e){const t=$.useContext(nb);return e||t||"ltr"}var ko="rovingFocusGroup.onEntryFocus",rb={bubbles:!1,cancelable:!0},mo="RovingFocusGroup",[gs,ad,ib]=ZI(mo),[ob,cd]=ho(mo,[ib]),[sb,ab]=ob(mo),ld=$.forwardRef((e,t)=>l.jsx(gs.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(gs.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(cb,{...e,ref:t})})}));ld.displayName=mo;var cb=$.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,m=$.useRef(null),p=Qr(t,m),g=sd(i),[y=null,h]=ea({prop:s,defaultProp:a,onChange:c}),[x,v]=$.useState(!1),_=Zs(u),C=ad(n),b=$.useRef(!1),[S,R]=$.useState(0);return $.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(ko,_),()=>N.removeEventListener(ko,_)},[_]),l.jsx(sb,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:y,onItemFocus:$.useCallback(N=>h(N),[h]),onItemShiftTab:$.useCallback(()=>v(!0),[]),onFocusableItemAdd:$.useCallback(()=>R(N=>N+1),[]),onFocusableItemRemove:$.useCallback(()=>R(N=>N-1),[]),children:l.jsx(Fn.div,{tabIndex:x||S===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:$t(e.onMouseDown,()=>{b.current=!0}),onFocus:$t(e.onFocus,N=>{const M=!b.current;if(N.target===N.currentTarget&&M&&!x){const U=new CustomEvent(ko,rb);if(N.currentTarget.dispatchEvent(U),!U.defaultPrevented){const q=C().filter(re=>re.focusable),G=q.find(re=>re.active),ne=q.find(re=>re.id===y),ce=[G,ne,...q].filter(Boolean).map(re=>re.ref.current);fd(ce,d)}}b.current=!1}),onBlur:$t(e.onBlur,()=>v(!1))})})}),ud="RovingFocusGroupItem",dd=$.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,...s}=e,a=od(),c=i||a,u=ab(ud,n),d=u.currentTabStopId===c,f=ad(n),{onFocusableItemAdd:m,onFocusableItemRemove:p}=u;return $.useEffect(()=>{if(r)return m(),()=>p()},[r,m,p]),l.jsx(gs.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:l.jsx(Fn.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:$t(e.onMouseDown,g=>{r?u.onItemFocus(c):g.preventDefault()}),onFocus:$t(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:$t(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){u.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const y=db(g,u.orientation,u.dir);if(y!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let x=f().filter(v=>v.focusable).map(v=>v.ref.current);if(y==="last")x.reverse();else if(y==="prev"||y==="next"){y==="prev"&&x.reverse();const v=x.indexOf(g.currentTarget);x=u.loop?fb(x,v+1):x.slice(v+1)}setTimeout(()=>fd(x))}})})})});dd.displayName=ud;var lb={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ub(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function db(e,t,n){const r=ub(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return lb[r]}function fd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function fb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var pb=ld,hb=dd,oa="Tabs",[mb,Ub]=ho(oa,[cd]),pd=cd(),[gb,sa]=mb(oa),hd=$.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:c="automatic",...u}=e,d=sd(a),[f,m]=ea({prop:r,onChange:o,defaultProp:i});return l.jsx(gb,{scope:n,baseId:od(),value:f,onValueChange:m,orientation:s,dir:d,activationMode:c,children:l.jsx(Fn.div,{dir:d,"data-orientation":s,...u,ref:t})})});hd.displayName=oa;var md="TabsList",gd=$.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=sa(md,n),s=pd(n);return l.jsx(pb,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:r,children:l.jsx(Fn.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});gd.displayName=md;var yd="TabsTrigger",vd=$.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=sa(yd,n),a=pd(n),c=Id(s.baseId,r),u=bd(s.baseId,r),d=r===s.value;return l.jsx(hb,{asChild:!0,...a,focusable:!o,active:d,children:l.jsx(Fn.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":u,"data-state":d?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...i,ref:t,onMouseDown:$t(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(r):f.preventDefault()}),onKeyDown:$t(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(r)}),onFocus:$t(e.onFocus,()=>{const f=s.activationMode!=="manual";!d&&!o&&f&&s.onValueChange(r)})})})});vd.displayName=yd;var wd="TabsContent",yb=$.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=sa(wd,n),c=Id(a.baseId,r),u=bd(a.baseId,r),d=r===a.value,f=$.useRef(d);return $.useEffect(()=>{const m=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(m)},[]),l.jsx(ta,{present:o||d,children:({present:m})=>l.jsx(Fn.div,{"data-state":d?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:u,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:m&&i})})});yb.displayName=wd;function Id(e,t){return`${e}-trigger-${t}`}function bd(e,t){return`${e}-content-${t}`}var vb=hd,wb=gd,_d=vd;const Ib=l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[l.jsx("circle",{cx:"9",cy:"9",r:"9",fill:"#BBF7D0"}),l.jsx("path",{d:"M13 7L7.5 12L5 9.72727",stroke:"#16A34A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function bb(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?Ib:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:l.jsx("circle",{cx:"9",cy:"9",r:"5",fill:"#BFDBFE"})})}function _b(){return l.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M2.25 4.5H3.75H15.75",stroke:"#E73D3D",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),l.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:"#E73D3D",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M7.5 8.25V12.75",stroke:"#E73D3D",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M10.5 8.25V12.75",stroke:"#E73D3D",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const xb="_tabsRoot_ktpr0_1",Cb="_tabsList_ktpr0_6",Ob="_tabTrigger_ktpr0_12",Eb="_danger_ktpr0_29",Yr={tabsRoot:xb,tabsList:Cb,tabTrigger:Ob,danger:Eb};function xd({objectName:e,completed:t,pending:n,displayName:r}){return l.jsx(_d,{value:e,className:Yr.tabTrigger,children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[bb(t,n),l.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[l.jsx("span",{children:r||e}),n&&l.jsx("span",{style:{fontSize:".8rem",fontStyle:"italic"},children:"pending"})]})]})})}function Sb({completed:e,pending:t,displayName:n}){return l.jsxs(l.Fragment,{children:[l.jsx(po,{style:{margin:"1rem 0"}}),l.jsx(xd,{objectName:er,completed:e,pending:t,displayName:n},"other-write")]})}function Nb(){return l.jsxs(l.Fragment,{children:[l.jsx(po,{style:{margin:"3rem 0 1rem 0"}}),l.jsx(_d,{value:Li,className:It(Yr.tabTrigger,Yr.danger),children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[_b(),l.jsx("span",{children:"Uninstall"})]})})]})}function Tb({value:e,readNavObjects:t,onValueChange:n,objectConfigurationsState:r,writeNavObject:o,showUninstallButton:i}){var s,a;return l.jsx(vb,{value:e,className:Yr.tabsRoot,onValueChange:n,children:l.jsxs(wb,{className:Yr.tabsList,children:[t.map(c=>{var u,d,f,m,p,g;return l.jsx(xd,{objectName:c.name,displayName:c.displayName,completed:c.completed,pending:((d=(u=r==null?void 0:r[c.name])==null?void 0:u.read)==null?void 0:d.isOptionalFieldsModified)||((m=(f=r==null?void 0:r[c.name])==null?void 0:f.read)==null?void 0:m.isRequiredMapFieldsModified)||((g=(p=r==null?void 0:r[c.name])==null?void 0:p.read)==null?void 0:g.isValueMappingsModified)||!1},c.name)}),o&&l.jsx(Sb,{completed:o.completed,pending:((a=(s=r==null?void 0:r.other)==null?void 0:s.write)==null?void 0:a.isWriteModified)||!1,displayName:"Write"}),i&&l.jsx(Nb,{})]})})}function Rb(e,t){return t===Li?{name:Li,completed:!1}:e.find(n=>n.name===t)}function Ab({children:e}){var x;const{project:t}=Le(),{installation:n,provider:r}=ut(),{hydratedRevision:o}=dn(),{objectConfigurationsState:i}=Ns(),[s,a]=w.useState(""),c=(t==null?void 0:t.appName)||"",u=n==null?void 0:n.config,d=o&&vl(u,o),f=d!==null,m=!!((x=o==null?void 0:o.content)!=null&&x.write),p=m?wl(u):void 0,g=w.useMemo(()=>{const v=[...d||[]];return p&&m&&v.push(p),v},[d,p,m]),y=Rb(g,s),h=w.useCallback(()=>{const v=g.find(_=>y!==_&&!_.completed);v&&a(v.name)},[g,y]);return w.useEffect(()=>{!s&&g.length>0&&a(g[0].name)},[g,s,h]),l.jsx(Ml.Provider,{value:h,children:l.jsx(Dl.Provider,{value:y==null?void 0:y.name,children:l.jsxs(Pr,{style:{maxWidth:"55rem"},children:[l.jsxs(Pn,{style:{display:"flex",gap:"1rem",padding:"3rem",backgroundColor:"var(--amp-colors-bg-primary)"},children:[l.jsxs("div",{style:{width:"20rem"},children:[l.jsxs("h1",{style:{fontSize:"small",fontWeight:"400"},children:[Dn(r)," integration"]}),l.jsx("h3",{style:{marginBottom:"20px",fontSize:"large",fontWeight:"500"},children:c}),f&&l.jsx(Tb,{value:s,readNavObjects:d,onValueChange:v=>a(v),objectConfigurationsState:i,writeNavObject:p,showUninstallButton:!!n})]}),e]}),l.jsx(Zu,{})]})})})}function Pb({...e}){return l.jsx(Ab,{...e})}function Db({integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c}){var x;const{projectId:u,projectIdOrName:d,isLoading:f}=Le(),{isLoading:m}=bs(),{isError:p,errorState:g}=Ht(),{seed:y,reset:h}=hl();return f||m?l.jsx(eo,{}):p(we.PROJECT,d)?l.jsx(un,{message:`Error loading project ${d}`}):p(we.INTEGRATION_LIST,d)?l.jsx(un,{message:"Error retrieving integrations for the project, double check the API key"}):(x=g[we.INTEGRATION_LIST])!=null&&x.apiError?l.jsx(un,{message:"Something went wrong, couldn't find integration information"}):l.jsx("div",{className:ml.resetContainer,children:l.jsx(Ym,{integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c,children:l.jsx(pl,{groupRef:r,children:l.jsx(id,{consumerRef:t,consumerName:n,groupRef:r,groupName:o,resetComponent:h,children:l.jsx(_g,{projectId:u,children:l.jsx(fI,{children:l.jsx(jg,{children:l.jsx(Pb,{children:l.jsx(sI,{})})})})})})})},y)})}function Fb(){return l.jsxs(Pr,{style:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[l.jsx(Br,{}),l.jsx("p",{children:"Redirecting"})]})}function Mb({redirectURL:e,children:t}){return w.useEffect(()=>{e&&window.location.replace(e)},[e]),e?l.jsx(Fb,{}):t}function jb({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={},onDisconnectSuccess:r,resetComponent:o}){const i=tt(),{projectId:s}=Le(),{selectedConnection:a,setConnections:c}=or(),[u,d]=w.useState(!1),f=!s||!a||!a.id||u,m=async()=>{if(!f){d(!0),console.warn("deleting connection",{projectId:s,connectionId:a==null?void 0:a.id});try{await je().connectionApi.deleteConnection({projectIdOrName:s,connectionId:a==null?void 0:a.id},{headers:{"X-Api-Key":i,"Content-Type":"application/json"}}),console.warn("successfully deleted connection:",a==null?void 0:a.id),r==null||r(a),je().connectionApi.listConnections({projectIdOrName:s},{headers:{"X-Api-Key":i??""}}).then(y=>{c(y),o()}).catch(y=>{st(y)})}catch(y){console.error("Error deleting connection."),st(y)}finally{d(!1)}}},p=u?"Disconnecting...":e;return l.jsx(at,{type:"button",onClick:m,disabled:f,variant:t,style:n,children:p})}function kb({provider:e,onDisconnectSuccess:t,resetComponent:n}){const{appName:r}=Le(),o=`You have successfully connected your ${Dn(e)} account to ${r}.`;return l.jsx(ra,{text:o,children:l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:l.jsx(jb,{resetComponent:n,onDisconnectSuccess:t,buttonText:"Remove Connection",buttonVariant:"outline",buttonStyle:{fontSize:"13px"}})})})}function Lb({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,redirectUrl:i,onSuccess:s,onDisconnectSuccess:a,onConnectSuccess:c}){const{seed:u,reset:d}=hl(),f=w.useCallback(m=>{s?s(m.id):c&&c(m)},[s,c]);return l.jsx("div",{className:ml.resetContainer,children:l.jsx(pl,{provider:e,groupRef:r,children:l.jsx(id,{resetComponent:d,provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onSuccess:f,onDisconnectSuccess:a,children:l.jsx(Mb,{redirectURL:i,children:l.jsx(kb,{resetComponent:d,provider:e,onDisconnectSuccess:a})})})})},u)}const Vb=(e,t)=>{const n=tt(),{projectId:r,isLoading:o}=Le(),{integrations:i}=bs(),[s,a]=w.useState(!1),[c,u]=w.useState(null);if(!n||!o&&!r)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 f=w.useMemo(()=>i==null?void 0:i.reduce((m,p)=>(p==null?void 0:p.name)===e?p:m,{}),[i,e]);return w.useEffect(()=>{!f||o||je().installationApi.listInstallations({projectIdOrName:r,integrationId:f.id,groupRef:t},{headers:{"x-api-key":n}}).then(m=>{a(!0),u(m.length>0)}).catch(m=>{console.error("Error listing installations."),st(m),a(!0)})},[t,n,r,f,o]),{isLoaded:s,isIntegrationInstalled:c}};exports.AmpersandContext=al;exports.AmpersandProvider=jm;exports.ConnectProvider=Lb;exports.FieldMapping=uo;exports.InstallIntegration=Db;exports.useAmpersandProvider=km;exports.useIsIntegrationInstalled=Vb;
49
+ .styles-module_tooltip__mnnfp{padding:8px 16px;border-radius:3px;font-size:90%;width:max-content}.styles-module_arrow__K0L3T{width:8px;height:8px}[class*='react-tooltip__place-top']>.styles-module_arrow__K0L3T{transform:rotate(45deg)}[class*='react-tooltip__place-right']>.styles-module_arrow__K0L3T{transform:rotate(135deg)}[class*='react-tooltip__place-bottom']>.styles-module_arrow__K0L3T{transform:rotate(225deg)}[class*='react-tooltip__place-left']>.styles-module_arrow__K0L3T{transform:rotate(315deg)}.styles-module_dark__xNqje{background:var(--rt-color-dark);color:var(--rt-color-white)}.styles-module_light__Z6W-X{background-color:var(--rt-color-white);color:var(--rt-color-dark)}.styles-module_success__A2AKt{background-color:var(--rt-color-success);color:var(--rt-color-white)}.styles-module_warning__SCK0X{background-color:var(--rt-color-warning);color:var(--rt-color-white)}.styles-module_error__JvumD{background-color:var(--rt-color-error);color:var(--rt-color-white)}.styles-module_info__BWdHW{background-color:var(--rt-color-info);color:var(--rt-color-white)}`,type:"base"})});function Kv(){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:[l.jsxs("g",{clipPath:"url(#clip0_2896_16290)",children:[l.jsx("path",{d:"M8.00032 11.167L8.00032 7.83366M8.00032 1.83366C4.33366 1.83366 1.33366 4.83366 1.33366 8.50033C1.33366 12.167 4.33366 15.167 8.00033 15.167C11.667 15.167 14.667 12.167 14.667 8.50033C14.667 4.83366 11.667 1.83366 8.00032 1.83366Z",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M8.00293 5.83301L7.99768 5.83301",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})]}),l.jsx("defs",{children:l.jsx("clipPath",{id:"clip0_2896_16290",children:l.jsx("rect",{width:"16",height:"16",fill:"white",transform:"translate(16 16.5) rotate(180)"})})})]})}function $v({id:e,tooltipText:t}){return l.jsxs(l.Fragment,{children:[l.jsx("span",{"data-tooltip-id":e,style:{maxWidth:"20rem"},children:Kv()}),l.jsx(Vv,{id:e,place:"top",content:t,style:{maxWidth:"30rem"}})]})}function uo({field:e,onSelectChange:t,allFields:n}){var p;const{configureState:r,selectedObjectName:o,setConfigureState:i}=Ct(),[s,a]=w.useState(!0),c=(p=r==null?void 0:r.read)==null?void 0:p.selectedFieldMappings,u=c==null?void 0:c[e.mapToName];w.useEffect(()=>{e._default&&!u&&o&&r&&Gr(o,i,[{field:e.mapToName,value:e._default}]),a(!1)},[e,i,o,u,r]);const d=w.useMemo(()=>n.map(g=>({id:g.fieldName,label:g.displayName,value:g.fieldName})),[n]),f=l.jsx(Js,{disabled:s,items:d,selectedValue:u||null,onSelectedItemChange:g=>{t({target:{name:e.mapToName,value:g==null?void 0:g.value}})},placeholder:"Please select one",style:{width:"100%"}}),m=w.useCallback(()=>{o&&Gr(o,i,[{field:e.mapToName,value:null}])},[e.mapToName,o,i]);return l.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[l.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem",marginBottom:".25rem"},children:[l.jsx("span",{style:{fontWeight:500},children:e.mapToDisplayName}),l.jsx("span",{children:(e==null?void 0:e.prompt)&&l.jsx($v,{id:`tooltip-id-${e==null?void 0:e.prompt}`,tooltipText:e==null?void 0:e.prompt})})]}),l.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[f,l.jsx(at,{type:"button",variant:"ghost",onClick:m,children:"clear"})]})]},e.mapToName)}const Uv="_formControl_9qd8d_1",qv="_formLabel_9qd8d_5",Hv="_formLabelRequired_9qd8d_11",Bv="_formInput_9qd8d_16",Wv="_formInputInvalid_9qd8d_20",Jv="_formError_9qd8d_24",zv="_disabled_9qd8d_30",$n={formControl:Uv,formLabel:qv,formLabelRequired:Hv,formInput:Bv,formInputInvalid:Wv,formError:Jv,disabled:zv};function fo({id:e,label:t,isRequired:n=!1,isDisabled:r=!1,isInvalid:o=!1,errorMessage:i,children:s}){return l.jsxs("div",{className:It($n.formControl,{[$n.disabled]:r}),children:[t&&l.jsx("label",{htmlFor:e,className:It($n.formLabel,{[$n.formLabelRequired]:n}),children:t}),l.jsx("div",{id:e,className:It($n.formInput,{[$n.formInputInvalid]:o}),children:s}),o&&i&&l.jsx("div",{className:$n.formError,role:"alert",children:i})]})}const Gv="_divider_1kmoj_1",yc={divider:Gv};function po({className:e,style:t}){return l.jsx("hr",{className:e?`${yc.divider} ${e}`:yc.divider,style:t})}function Fr({string:e}){return l.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"1rem",paddingBottom:".5rem"},children:[l.jsx("h3",{style:{color:"var(--amp-colors-text-muted)",fontSize:"1rem",fontWeight:"400"},children:e}),l.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:l.jsx(po,{style:{width:"100%",marginLeft:"1rem"}})})]})}function Xv({dynamicFieldMappings:e,onSelectChange:t,allFields:n}){return e.length?l.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:e.map(r=>l.jsx(fo,{id:r.mapToName,children:l.jsx(uo,{allFields:n,field:r,onSelectChange:t})},r.mapToName))}):null}function Qv(){var m;const{selectedObjectName:e,configureState:t,setConfigureState:n}=Ct(),{isError:r,removeError:o}=Ht(),i=((m=t==null?void 0:t.read)==null?void 0:m.allFields)||[],{fieldMapping:s}=ut(),a=p=>{const{value:g,name:y}=p.target;g&&(e&&Gr(e,n,[{field:y,value:g}]),r(we.MAPPING,y)&&o(we.MAPPING,y))},c=w.useMemo(()=>!e||!s?[]:Object.values(s[e]||{}).flat().filter(p=>!p.fieldName),[s,e]),u=w.useMemo(()=>{var y;return(((y=t==null?void 0:t.read)==null?void 0:y.optionalMapFields)||[]).filter(h=>!c.some(x=>x.mapToName===h.mapToName))},[t,c]),d=c.length>0;return u.length>0||d?l.jsxs(l.Fragment,{children:[l.jsx(Fr,{string:"Map the following optional fields"}),l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:[u==null?void 0:u.map(p=>l.jsx(fo,{id:p.mapToName,children:l.jsx(uo,{allFields:i,field:p,onSelectChange:a})},p.mapToName)),d&&l.jsx(Xv,{dynamicFieldMappings:c,onSelectChange:a,allFields:i})]})]}):null}function Yv(){const{selectedObjectName:e,configureState:t,setConfigureState:n}=Ct(),{isError:r,removeError:o}=Ht(),i=a=>{const{value:c,name:u}=a.target;c&&(e&&Gr(e,n,[{field:u,value:c}]),r(we.MAPPING,u)&&o(we.MAPPING,u))},s=w.useMemo(()=>{var a;return((a=t==null?void 0:t.read)==null?void 0:a.requiredMapFields)||[]},[t]);return s!=null&&s.length?l.jsxs(l.Fragment,{children:[l.jsx(Fr,{string:"Map the following fields"}),l.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:s.map(a=>{var c;return l.jsx(fo,{id:a.mapToName,isInvalid:r(we.MAPPING,a.mapToName),errorMessage:"* required",children:l.jsx(uo,{allFields:((c=t==null?void 0:t.read)==null?void 0:c.allFields)||[],field:a,onSelectChange:i})},a.mapToName)})})]}):null}const Zv={backgroundColor:"var(--amp-colors-bg-highlight)",borderColor:"var(--amp-colors-bg-highlight)",padding:".5rem 1rem"};function ew({children:e,style:t}){return l.jsx(Pn,{style:{...Zv,...t},children:e})}function tw(){var d,f,m;const{project:e}=Le(),{hydratedRevision:t}=dn(),{selectedObjectName:n}=Ct(),{provider:r}=ut(),o=e==null?void 0:e.appName,i=Dn(r),s=(m=(f=(d=t==null?void 0:t.content)==null?void 0:d.read)==null?void 0:f.objects)==null?void 0:m.find(p=>p.objectName===n),a=(s==null?void 0:s.displayName)||n&&Wr(n),c=s==null?void 0:s.mapToName,u=(s==null?void 0:s.mapToDisplayName)||c&&Wr(c);return u&&o&&i?l.jsx(ew,{style:{marginTop:"1rem"},children:l.jsxs("p",{style:{margin:"1rem 0"},children:[l.jsx("b",{children:u})," in ",o," is mapped to ",l.jsx("b",{children:a})," in ",i,"."]})}):null}function vc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ku(...e){return t=>{let n=!1;const r=e.map(o=>{const i=vc(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():vc(e[o],null)}}}}function Qr(...e){return $.useCallback(ku(...e),e)}function ho(e,t=[]){let n=[];function r(i,s){const a=$.createContext(s),c=n.length;n=[...n,s];const u=f=>{var x;const{scope:m,children:p,...g}=f,y=((x=m==null?void 0:m[e])==null?void 0:x[c])||a,h=$.useMemo(()=>g,Object.values(g));return l.jsx(y.Provider,{value:h,children:p})};u.displayName=i+"Provider";function d(f,m){var y;const p=((y=m==null?void 0:m[e])==null?void 0:y[c])||a,g=$.useContext(p);if(g)return g;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[u,d]}const o=()=>{const i=n.map(s=>$.createContext(s));return function(a){const c=(a==null?void 0:a[e])||i;return $.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,nw(o,...t)]}function nw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:c,scopeName:u})=>{const f=c(i)[`__scope${u}`];return{...a,...f}},{});return $.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function $t(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Zs(e){const t=$.useRef(e);return $.useEffect(()=>{t.current=e}),$.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function ea({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=rw({defaultProp:t,onChange:n}),i=e!==void 0,s=i?e:r,a=Zs(n),c=$.useCallback(u=>{if(i){const f=typeof u=="function"?u(e):u;f!==e&&a(f)}else o(u)},[i,e,o,a]);return[s,c]}function rw({defaultProp:e,onChange:t}){const n=$.useState(e),[r]=n,o=$.useRef(r),i=Zs(t);return $.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}function iw(e){const t=$.useRef({value:e,previous:e});return $.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Gi=globalThis!=null&&globalThis.document?$.useLayoutEffect:()=>{};function ow(e){const[t,n]=$.useState(void 0);return Gi(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const c=i.borderBoxSize,u=Array.isArray(c)?c[0]:c;s=u.inlineSize,a=u.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}function sw(e,t){return $.useReducer((n,r)=>t[n][r]??n,e)}var ta=e=>{const{present:t,children:n}=e,r=aw(t),o=typeof n=="function"?n({present:r.isPresent}):$.Children.only(n),i=Qr(r.ref,cw(o));return typeof n=="function"||r.isPresent?$.cloneElement(o,{ref:i}):null};ta.displayName="Presence";function aw(e){const[t,n]=$.useState(),r=$.useRef({}),o=$.useRef(e),i=$.useRef("none"),s=e?"mounted":"unmounted",[a,c]=sw(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return $.useEffect(()=>{const u=Ti(r.current);i.current=a==="mounted"?u:"none"},[a]),Gi(()=>{const u=r.current,d=o.current;if(d!==e){const m=i.current,p=Ti(u);e?c("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(d&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),Gi(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const y=Ti(r.current).includes(p.animationName);if(p.target===t&&y&&(c("ANIMATION_END"),!o.current)){const h=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=h)})}},m=p=>{p.target===t&&(i.current=Ti(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:$.useCallback(u=>{u&&(r.current=getComputedStyle(u)),n(u)},[])}}function Ti(e){return(e==null?void 0:e.animationName)||"none"}function cw(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xi=$.forwardRef((e,t)=>{const{children:n,...r}=e,o=$.Children.toArray(n),i=o.find(uw);if(i){const s=i.props.children,a=o.map(c=>c===i?$.Children.count(s)>1?$.Children.only(null):$.isValidElement(s)?s.props.children:null:c);return l.jsx(ms,{...r,ref:t,children:$.isValidElement(s)?$.cloneElement(s,void 0,a):null})}return l.jsx(ms,{...r,ref:t,children:n})});Xi.displayName="Slot";var ms=$.forwardRef((e,t)=>{const{children:n,...r}=e;if($.isValidElement(n)){const o=fw(n);return $.cloneElement(n,{...dw(r,n.props),ref:t?ku(t,o):o})}return $.Children.count(n)>1?$.Children.only(null):null});ms.displayName="SlotClone";var lw=({children:e})=>l.jsx(l.Fragment,{children:e});function uw(e){return $.isValidElement(e)&&e.type===lw}function dw(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function fw(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var pw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Fn=pw.reduce((e,t)=>{const n=$.forwardRef((r,o)=>{const{asChild:i,...s}=r,a=i?Xi:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(a,{...s,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),na="Checkbox",[hw,$b]=ho(na),[mw,gw]=hw(na),Lu=$.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:c="on",onCheckedChange:u,form:d,...f}=e,[m,p]=$.useState(null),g=Qr(t,C=>p(C)),y=$.useRef(!1),h=m?d||!!m.closest("form"):!0,[x=!1,v]=ea({prop:o,defaultProp:i,onChange:u}),_=$.useRef(x);return $.useEffect(()=>{const C=m==null?void 0:m.form;if(C){const b=()=>v(_.current);return C.addEventListener("reset",b),()=>C.removeEventListener("reset",b)}},[m,v]),l.jsxs(mw,{scope:n,state:x,disabled:a,children:[l.jsx(Fn.button,{type:"button",role:"checkbox","aria-checked":Nn(x)?"mixed":x,"aria-required":s,"data-state":$u(x),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:g,onKeyDown:$t(e.onKeyDown,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:$t(e.onClick,C=>{v(b=>Nn(b)?!0:!b),h&&(y.current=C.isPropagationStopped(),y.current||C.stopPropagation())})}),h&&l.jsx(yw,{control:m,bubbles:!y.current,name:r,value:c,checked:x,required:s,disabled:a,form:d,style:{transform:"translateX(-100%)"},defaultChecked:Nn(i)?!1:i})]})});Lu.displayName=na;var Vu="CheckboxIndicator",Ku=$.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=gw(Vu,n);return l.jsx(ta,{present:r||Nn(i.state)||i.state===!0,children:l.jsx(Fn.span,{"data-state":$u(i.state),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});Ku.displayName=Vu;var yw=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...i}=e,s=$.useRef(null),a=iw(n),c=ow(t);$.useEffect(()=>{const d=s.current,f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(a!==n&&p){const g=new Event("click",{bubbles:r});d.indeterminate=Nn(n),p.call(d,Nn(n)?!1:n),d.dispatchEvent(g)}},[a,n,r]);const u=$.useRef(Nn(n)?!1:n);return l.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??u.current,...i,tabIndex:-1,ref:s,style:{...e.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function Nn(e){return e==="indeterminate"}function $u(e){return Nn(e)?"indeterminate":e?"checked":"unchecked"}var Uu=Lu,qu=Ku;function Hu(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i<r.length;i++)o=r[i],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}var vw=["color"],Bu=w.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=Hu(e,vw);return w.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),w.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:r,fillRule:"evenodd",clipRule:"evenodd"}))}),ww=["color"],Iw=w.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=Hu(e,ww);return w.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),w.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:r,fillRule:"evenodd",clipRule:"evenodd"}))});const bw="_checkboxGroupContainer_1ya1t_1",_w="_stack_1ya1t_6",xw="_selectAllContainer_1ya1t_11",Cw="_fieldContainer_1ya1t_18",Ow="_checkbox_1ya1t_1",Ar={checkboxGroupContainer:bw,stack:_w,selectAllContainer:xw,fieldContainer:Cw,checkbox:Ow};function Wu({id:e,isChecked:t,label:n,onCheckedChange:r}){return l.jsxs("div",{className:Ar.fieldContainer,children:[l.jsx(Uu,{className:Ar.checkbox,id:e,onCheckedChange:r,checked:t,children:l.jsx(qu,{children:l.jsx(Bu,{})})}),l.jsx("label",{htmlFor:e,style:{overflowWrap:"anywhere"},children:n})]})}function Ju({id:e,isChecked:t,label:n,onCheckedChange:r,isIndeterminate:o}){return l.jsxs("div",{className:Ar.selectAllContainer,children:[l.jsx(Uu,{className:Ar.checkbox,id:e,onCheckedChange:r,children:l.jsxs(qu,{children:[o&&l.jsx(Iw,{}),t===!0&&l.jsx(Bu,{})]})}),l.jsx("label",{htmlFor:e,children:n})]})}function zu({children:e}){return l.jsx("div",{className:Ar.checkboxGroupContainer,children:e})}function Gu({children:e}){return l.jsx("div",{className:Ar.stack,children:e})}function Ew(e,t,n){var o,i;const r=((o=e==null?void 0:e.read)==null?void 0:o.selectedOptionalFields)||{};if(r[t]=n,n||delete r[t],(i=e.read)!=null&&i.savedConfig.optionalFields){const s=e.read.savedConfig.optionalFields,c=!_l(s,r);e.read.isOptionalFieldsModified=c}else console.warn("read.savedConfig.optionalFields is undefined")}function wc(e,t,n,r){t(e,o=>Ew(o,n,r))}function Sw(){var f,m;const{appName:e,configureState:t,setConfigureState:n,selectedObjectName:r}=Ct(),o=(f=t==null?void 0:t.read)==null?void 0:f.selectedOptionalFields,i=(p,g)=>{p!=="indeterminate"&&r&&t&&wc(r,n,g,p)},s=(m=t==null?void 0:t.read)==null?void 0:m.optionalFields,a=p=>{r&&s&&s.forEach(g=>{Tn(g)||wc(r,n,g.fieldName,p)})},c=!!(s&&s.length>0),u=Object.keys(o||{}).length===(s==null?void 0:s.length),d=!u&&Object.keys(o||{}).length>0;return c&&l.jsxs(l.Fragment,{children:[l.jsx(Fr,{string:`${e} reads the following optional fields`}),l.jsxs(zu,{children:[((s==null?void 0:s.length)||0)>=2&&l.jsx(Ju,{id:"select-all-fields",isChecked:u,label:"Select all",onCheckedChange:a,isIndeterminate:d}),l.jsx(Gu,{children:s.map(p=>Tn(p)?null:l.jsx(Wu,{id:p.fieldName,isChecked:!!(o!=null&&o[p==null?void 0:p.fieldName]),label:p.displayName,onCheckedChange:g=>i(g,p.fieldName)},p.fieldName))})]})]})}function Nw(){return l.jsx(Sw,{})}const Tw={color:"var(--amp-colors-text-regular)",backgroundColor:"var(--amp-colors-bg-highlight)",borderRadius:"4px",display:"inline-block",fontSize:"0.75rem",fontWeight:500,lineHeight:"1.25",padding:"0.25rem 0.5rem"};function Rw({children:e,style:t,...n}){return l.jsx("span",{style:{...Tw,...t},...n,children:e})}function Aw(){var r,o,i;const{configureState:e,selectedObjectName:t}=Ct(),{appName:n}=Le();return l.jsxs(l.Fragment,{children:[l.jsx(Fr,{string:`${n} reads the following ${t} fields`}),l.jsx("div",{style:{display:"flex",gap:".5rem",marginBottom:".5rem",flexWrap:"wrap"},children:(o=(r=e==null?void 0:e.read)==null?void 0:r.requiredFields)!=null&&o.length?(i=e.read)==null?void 0:i.requiredFields.map(s=>Tn(s)?null:l.jsx(Rw,{children:s.displayName},s.fieldName)):"There are no required fields."})]})}function Pw(e,t,n,r,o){e.read&&(e.read.selectedValueMappings||(e.read.selectedValueMappings={}),e.read.selectedValueMappings[o]||(e.read.selectedValueMappings[o]={}),e.read.selectedValueMappings[o][n]=r)}function Dw(e,t,n,r,o){t(e,i=>Pw(i,e,n,r,o))}function Fw(e,t,n){t(e,r=>{r.read&&(r.read.isValueMappingsModified=n)})}function Mw({string:e,fieldName:t}){return l.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"1rem",paddingBottom:".5rem"},children:[l.jsxs("h3",{style:{color:"var(--amp-colors-text-muted)",fontSize:"1rem",fontWeight:"400"},children:[e,l.jsx("b",{children:t})]}),l.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:l.jsx(po,{style:{width:"100%",marginLeft:"1rem"}})})]})}function jw({mappedValue:e,onSelectChange:t,fieldName:n,allValueOptions:r,hasError:o}){var v;const{configureState:i,selectedObjectName:s,setConfigureState:a}=Ct(),[c,u]=w.useState(!0),{getError:d,setError:f,resetBoundary:m}=Ht(),p=w.useMemo(()=>{var _,C;return((C=(_=i==null?void 0:i.read)==null?void 0:_.selectedValueMappings)==null?void 0:C[n])||{}},[(v=i==null?void 0:i.read)==null?void 0:v.selectedValueMappings,n]),g=w.useMemo(()=>p==null?void 0:p[e.mappedValue],[p,e.mappedValue]);w.useEffect(()=>{u(!1)},[e,a,s,g,i]);const y=w.useMemo(()=>r.map(_=>({id:_.value,label:_.displayValue,value:_.value})),[r]),h=w.useCallback(_=>{if(_){if(Object.values(p).some(C=>C===_.value&&C!==g)){const C=[...Object.entries(p).filter(([b,S])=>S===_.value&&S!==g).map(([b])=>b),e.mappedValue];f(we.VALUE_MAPPING,n,C);return}d(we.VALUE_MAPPING,n)&&m(we.VALUE_MAPPING),t({target:{name:e.mappedValue,value:_.value,fieldName:n}})}},[t,p,g,n,e.mappedValue,m,f,d]),x=w.useMemo(()=>l.jsx(Js,{disabled:c,items:y,selectedValue:g||null,onSelectedItemChange:h,placeholder:"Please select one",style:{border:o?"2px solid red":void 0,borderRadius:"8px"}},g),[g,c,y,h,o]);return l.jsxs("div",{style:{display:"flex",flexDirection:"column",marginBottom:".25rem"},children:[l.jsx("div",{style:{display:"flex",flexDirection:"row",gap:".25rem",marginBottom:".25rem"},children:l.jsx("span",{style:{fontWeight:500},children:e.mappedDisplayValue})}),x]},e.mappedValue)}function kw(){var p,g,y;const{fieldMapping:e}=ut(),{selectedObjectName:t,configureState:n,setConfigureState:r}=Ct(),{isError:o,removeError:i,getError:s}=Ht(),a=(p=n==null?void 0:n.read)==null?void 0:p.selectedFieldMappings,c=(g=n==null?void 0:n.read)==null?void 0:g.selectedValueMappings,u=(y=n==null?void 0:n.read)==null?void 0:y.isValueMappingsModified,d=w.useRef(!1),f=w.useMemo(()=>{const h=t&&e?Object.values(e[t]||{}).flat().filter(x=>x.mappedValues).map(x=>({...x})):[];if(a)for(let x=0;x<h.length;x+=1)a!=null&&a[h[x].mapToName]&&(h[x].fieldName=a[h[x].mapToName]);return h},[t,e,a]),m=w.useCallback(h=>{const{value:x,name:v,fieldName:_}=h.target;x&&(t&&Dw(t,r,v,x,_),o(we.VALUE_MAPPING,v)&&i(we.VALUE_MAPPING,v))},[t,r,o,i]);return w.useEffect(()=>{var h;if(t&&c){const x=((h=e==null?void 0:e[t])==null?void 0:h.filter(_=>_.fieldName&&_.mappedValues.length>0))||[];x.every(_=>{const C=c[_.fieldName]||{};return Object.keys(C).length===Object.keys(_.mappedValues).length})&&x.length>0?!u&&!d.current&&(Fw(t,r,!0),d.current=!0):d.current=!1}},[c,f,t,r,e,u]),f!=null&&f.length?l.jsx(l.Fragment,{children:f.map(h=>{var x,v,_,C,b,S,R,N,M,U,q,G,ne,W,ce,re;return h.fieldName?["singleSelect","multiSelect"].includes((_=(v=(x=n==null?void 0:n.read)==null?void 0:x.allFieldsMetadata)==null?void 0:v[h.fieldName])==null?void 0:_.valueType)?(S=(b=(C=n==null?void 0:n.read)==null?void 0:C.allFieldsMetadata)==null?void 0:b[h.fieldName])!=null&&S.values?(M=(N=(R=n==null?void 0:n.read)==null?void 0:R.allFieldsMetadata)==null?void 0:N[h.fieldName])!=null&&M.values&&Object.keys((h==null?void 0:h.mappedValues)||[]).length===Object.keys(((G=(q=(U=n==null?void 0:n.read)==null?void 0:U.allFieldsMetadata)==null?void 0:q[h.fieldName])==null?void 0:G.values)||[]).length?l.jsxs(l.Fragment,{children:[l.jsx(Mw,{string:"Map the values for ",fieldName:h.mapToName||h.fieldName}),l.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:l.jsx(fo,{id:h.mapToName||h.fieldName,children:(re=h==null?void 0:h.mappedValues)==null?void 0:re.map(Q=>{var T,j,K;const fe=s(we.VALUE_MAPPING,h.fieldName),ye=Array.isArray(fe)&&fe.includes(Q.mappedValue);return l.jsxs(l.Fragment,{children:[l.jsx(jw,{allValueOptions:((K=(j=(T=n==null?void 0:n.read)==null?void 0:T.allFieldsMetadata)==null?void 0:j[h.fieldName])==null?void 0:K.values)||[],mappedValue:Q,onSelectChange:m,fieldName:(h==null?void 0:h.fieldName)||"",hasError:ye},`${Q.mappedValue}-${h.fieldName}`),ye&&l.jsx("span",{style:{color:"red",fontSize:"14px",marginTop:"4px"},children:`Each ${h.mapToName||h.fieldName} must be mapped to a unique value`},Q.mappedValue)]})})},h.mapToName||h.fieldName)})]}):(console.error("field values and the values to be mapped are not of the same length",h,(ce=(W=(ne=n==null?void 0:n.read)==null?void 0:ne.allFieldsMetadata)==null?void 0:W[h.fieldName])==null?void 0:ce.values),null):(console.error("field has no values array",h),null):(console.error("fieldName is not a singleSelect or multiSelect",h),null):(console.error("fieldName is undefined",h),null)})}):null}function Lw(){return Vg(),l.jsxs(l.Fragment,{children:[l.jsx(tw,{}),l.jsx(Aw,{}),l.jsx(Yv,{}),l.jsx(Qv,{}),l.jsx(kw,{}),l.jsx(Nw,{})]})}const Vw="_input_10rzg_1",Kw="_inputError_10rzg_27",$w="_error_10rzg_43",Mo={input:Vw,inputError:Kw,error:$w};function Qi({id:e,type:t,className:n,isError:r=!1,...o}){const i=r?It(Mo.inputError,Mo.input):Mo.input;return l.jsx("input",{id:e,type:t,className:It(i,n),...o})}function Uw({objectName:e,onAddDefaultValue:t}){const{readAction:n,loading:r}=dn(),[o,i]=w.useState(null),[s,a]=w.useState(""),c=n&&Cs(n,e),u=w.useMemo(()=>(c==null?void 0:c.allFields)||[],[c]),d=r||!u||u.length===0,f=w.useMemo(()=>u.map(h=>({id:h.fieldName,label:h.displayName,value:h.fieldName})),[u]),m=h=>{const{value:x,name:v}=h.target;x&&i({label:v,value:x})},p=h=>{const{value:x}=h.target;a(x)},g=()=>{s&&(o!=null&&o.value)&&(t(o==null?void 0:o.value,o.label,s),i(null),a(""))},y=l.jsx(Js,{style:{width:"100%"},disabled:d,items:f,selectedValue:(o==null?void 0:o.value)||null,onSelectedItemChange:h=>{m({target:{name:h==null?void 0:h.label,value:h==null?void 0:h.value}})},placeholder:"Please select field."});return l.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[y,l.jsx(Qi,{id:"new-default-value",type:"text",value:s,onChange:p,style:{width:"10rem"},placeholder:"default value"}),l.jsx(at,{type:"button",onClick:g,variant:"ghost",children:"+"})]})}function qw(e,t,n,r){var o,i,s,a;if(((o=e==null?void 0:e.write)==null?void 0:o.selectedWriteObjects)===null&&(e.write.selectedWriteObjects={}),e!=null&&e.write){const c=e.write.selectedWriteObjects;if(r&&(c[t]||(c[t]={}),c[t].selectedValueDefaults||(c[t].selectedValueDefaults={}),c[t].selectedValueDefaults[n]=r),r||(i=c[t])!=null&&i.selectedValueDefaults&&delete c[t].selectedValueDefaults[n],(a=(s=e==null?void 0:e.write)==null?void 0:s.savedConfig)!=null&&a.selectedWriteObjects){const u=e.write.savedConfig.selectedWriteObjects,f=!bl(u,c);e.write.isWriteModified=f}}}function Ic(e,t,n,r,o){o(e,i=>{qw(i,t,n,r)})}const Hw=(e,t,n)=>{var i;const r=n&&Cs(n,t),o=r==null?void 0:r.allFieldsMetadata;return((i=o==null?void 0:o[e])==null?void 0:i.displayName)||e};function Bw({objectName:e}){var f;const{readAction:t}=dn(),{selectedObjectName:n,configureState:r,setConfigureState:o}=Ct(),i=(f=r==null?void 0:r.write)==null?void 0:f.selectedWriteObjects,s=i==null?void 0:i[e],a=w.useMemo(()=>(s==null?void 0:s.selectedValueDefaults)||{},[s]),c=w.useCallback((m,p,g)=>{Ic(n||"",e,m,g,o)},[e,n,o]),u=m=>{Ic(n||"",e,m,null,o)},d=Object.keys(a).map(m=>({field:m,defaultValue:a[m],fieldDisplayName:t?Hw(m,e,t):m}));return l.jsxs(l.Fragment,{children:[l.jsx("div",{style:{paddingBottom:"1rem",display:"flex",flexDirection:"column",gap:".5rem"},children:d.map(({field:m,fieldDisplayName:p,defaultValue:g})=>l.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[l.jsx(Qi,{id:m,type:"text",disabled:!0,value:p,style:{width:"100%"}}),l.jsx(Qi,{id:`${m}-${g}`,type:"text",disabled:!0,value:g,style:{width:"10rem"}}),l.jsx(at,{type:"button",variant:"ghost",onClick:()=>u(m),children:"x"})]},`${m}-${g}`))}),l.jsx(Uw,{objectName:e,onAddDefaultValue:c}),l.jsx("div",{style:{textAlign:"right",padding:".25rem 0",color:"var(--amp-colors-text-muted)"},children:"click + to confirm"})]})}const Ww=(e,t)=>!!t.find(n=>{var r;return n.objectName===e&&((r=n==null?void 0:n.valueDefaults)==null?void 0:r.allowAnyFields)});function Jw(){var o;const{configureState:e}=Ct(),{writeObjects:t}=dn(),n=(o=e==null?void 0:e.write)==null?void 0:o.selectedWriteObjects;return!!t&&l.jsx(l.Fragment,{children:t.map(i=>n!=null&&n[i.objectName]&&Ww(i.objectName,t)?l.jsxs(l.Fragment,{children:[l.jsx(Fr,{string:`Defaults for ${i.displayName} `}),l.jsx(Bw,{objectName:i.objectName})]}):null)})}function zw(e,t,n){var r,o,i;if(((r=e==null?void 0:e.write)==null?void 0:r.selectedWriteObjects)===null&&(e.write.selectedWriteObjects={}),e!=null&&e.write){const s=e.write.selectedWriteObjects;if(n&&(s[t]={objectName:t}),n||delete s[t],(i=(o=e==null?void 0:e.write)==null?void 0:o.savedConfig)!=null&&i.selectedWriteObjects){const a=e.write.savedConfig.selectedWriteObjects,u=!bl(a,s);e.write.isWriteModified=u}}}function bc(e,t,n,r){t(e,o=>{zw(o,n,r)})}function Gw(){var f,m,p,g;const{appName:e,selectedObjectName:t,configureState:n,setConfigureState:r}=Ct(),o=(f=n==null?void 0:n.write)==null?void 0:f.selectedWriteObjects,i=(m=n==null?void 0:n.write)==null?void 0:m.writeObjects,s=(y,h)=>{y!=="indeterminate"&&t&&n&&bc(t,r,h,y)},a=y=>{var h,x;t&&n&&((x=(h=n==null?void 0:n.write)==null?void 0:h.writeObjects)==null||x.forEach(v=>{bc(t,r,v.objectName,y)}))},c=!!i,u=Object.keys(o||{}).length===((g=(p=n==null?void 0:n.write)==null?void 0:p.writeObjects)==null?void 0:g.length),d=!u&&Object.keys(o||{}).length>0;return c&&l.jsxs(l.Fragment,{children:[l.jsx(Fr,{string:`Allow ${e} to write to these objects`}),l.jsxs(zu,{children:[((i==null?void 0:i.length)||0)>=2&&l.jsx(Ju,{id:"select-all-fields",onCheckedChange:a,isIndeterminate:d,isChecked:u,label:"Select all"}),l.jsx(Gu,{children:i.map(y=>l.jsx(Wu,{id:y.objectName,onCheckedChange:h=>s(h,y.objectName),isChecked:!!(o!=null&&o[y.objectName]),label:y.displayName},y.objectName))})]})]})}function Xw(){return l.jsxs(l.Fragment,{children:[l.jsx(Gw,{}),l.jsx(Jw,{})]})}function Xu({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={}}){const r=tt(),{projectId:o}=Le(),{integrationId:i,installation:s,resetInstallations:a,setIntegrationDeleted:c,onUninstallSuccess:u}=ut(),[d,f]=w.useState(!1),m=!o||!i||!(s!=null&&s.id)||d,p=async()=>{if(!m){f(!0),console.warn("uninstalling installation",{projectId:o,integrationId:i,installationId:s.id});try{await je().installationApi.deleteInstallation({projectIdOrName:o,integrationId:i,installationId:s.id},{headers:{"X-Api-Key":r,"Content-Type":"application/json"}}),console.warn("successfully uninstalled installation:",s.id),u==null||u(s==null?void 0:s.id),a(),c()}catch(h){console.error("Error uninstalling installation."),st(h)}finally{f(!1)}}},g=d?"Uninstalling...":e,y=l.jsx(at,{type:"button",onClick:p,disabled:m,variant:t,style:n,children:g});return s!=null&&s.id?y:null}function Qw(){const{appName:e}=Le(),{installation:t}=ut();return l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[t!=null&&t.id?l.jsxs("p",{children:["Once you uninstall this integration, all your configuration will be lost, and"," ",l.jsx("b",{children:e})," may stop working."]}):l.jsx("p",{children:"You've successfully uninstalled the integration."}),l.jsx(Xu,{buttonText:"Yes, uninstall",buttonVariant:"danger"})]})}function Qu({onSave:e,onReset:t,isLoading:n,isCreateMode:r=!1,errorMsg:o}){var S,R,N,M;const{installation:i}=ut(),{hydratedRevision:s,loading:a}=dn(),{configureState:c,selectedObjectName:u}=Ct(),d=i==null?void 0:i.config,f=d&&u&&!!yl(d,u)||!1,m=((S=c==null?void 0:c.read)==null?void 0:S.isOptionalFieldsModified)||((R=c==null?void 0:c.read)==null?void 0:R.isRequiredMapFieldsModified)||((N=c==null?void 0:c.read)==null?void 0:N.isValueMappingsModified),p=(M=c==null?void 0:c.write)==null?void 0:M.isWriteModified,x=a||n||!c||!u||!(m||p||r||u!==er&&!f),v=u===er,_=u===Li,C=l.jsx(at,{type:"submit",disabled:x,children:r?"Install":"Save"}),b=l.jsx(at,{type:"button",onClick:t,disabled:x,variant:"ghost",children:"Reset"});return n?l.jsx(Br,{}):l.jsxs("form",{style:{width:"34rem"},onSubmit:e,children:[l.jsxs("div",{style:{display:"flex",flexDirection:"row-reverse",gap:".8rem",marginBottom:"20px"},children:[C,b]}),l.jsxs(Pn,{style:{padding:"1rem 2rem",minHeight:"300px",backgroundColor:"var(--amp-colors-bg-primary)",borderColor:"var(--amp-colors-border)"},children:[o&&l.jsx(Rl,{children:typeof o=="string"?o:"Installation Failed."}),a&&l.jsx(Br,{}),s&&!_&&!v&&l.jsx(Lw,{}),s&&!_&&v&&l.jsx(Xw,{}),!a&&_&&l.jsx(Qw,{})]})]})}const Yu=()=>{const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,onInstallSuccess:o,onUpdateSuccess:i}=ut(),{hydratedRevision:s,loading:a}=dn(),{selectedObjectName:c}=Fl(),{selectedConnection:u}=or(),d=tt(),{projectId:f}=Le(),{resetBoundary:m,setErrors:p,setError:g,getError:y}=Ht(),{resetConfigureState:h,objectConfigurationsState:x,resetPendingConfigurationState:v}=Ns(),_=Nl(c||"",x),{onNextIncompleteTab:C}=xg(),b=w.useCallback(()=>{m(we.INSTALLATION_MUTATION)},[m]),S=w.useCallback(N=>N?M=>{g(we.INSTALLATION_MUTATION,N,M)}:M=>{console.error("objectName is required to set installation error: ",M)},[g]),R=w.useCallback(N=>N?y(we.INSTALLATION_MUTATION,N):"",[y]);return{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:s,loading:a,selectedObjectName:c,selectedConnection:u,apiKey:d,projectId:f,resetBoundary:m,setErrors:p,setMutateInstallationError:S,getMutateInstallationError:R,resetMutateInstallationErrorState:b,resetConfigureState:h,objectConfigurationsState:x,resetPendingConfigurationState:v,configureState:_,onInstallSuccess:o,onUpdateSuccess:i,onNextIncompleteTab:C}},Yw=void 0;function Zw(){const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:o,loading:i,selectedObjectName:s,selectedConnection:a,apiKey:c,projectId:u,resetBoundary:d,setErrors:f,setMutateInstallationError:m,getMutateInstallationError:p,resetMutateInstallationErrorState:g,resetConfigureState:y,objectConfigurationsState:h,resetPendingConfigurationState:x,configureState:v,onInstallSuccess:_,onNextIncompleteTab:C}=Yu(),[b,S]=w.useState(!1),R=s===er,N=p(s),M=w.useCallback(()=>{d(we.MAPPING),o!=null&&o.content&&!i&&s&&Cl(o,Yw,s,y)},[d,o,i,s,y]);w.useEffect(()=>{!v&&(o!=null&&o.content)&&!i&&M()},[v,h,o,i,M]);const U=()=>{g();const{requiredMapFields:ne,selectedFieldMappings:W}=(v==null?void 0:v.read)||{},{errorList:ce}=Il(ne,W,f);ce.length>0||(s&&(a!=null&&a.id)&&c&&u&&e&&t&&n&&o?(S(!0),fg(u,e,t,n,a.id,s,c,o,v,m(s),r,_).finally(()=>{S(!1),x(s),C()})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},q=()=>{g(),s&&(a!=null&&a.id)&&c&&u&&e&&t&&n&&o?(S(!0),mg(u,e,t,n,a.id,c,o,v,m(s),r,_).finally(()=>{S(!1),x(s),C()})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},G=ne=>{ne.preventDefault(),R?q():U()};return l.jsx(Qu,{errorMsg:N,isCreateMode:!0,isLoading:b,onSave:G,onReset:M})}function eI({updateConfig:e,projectId:t,integrationId:n,installationId:r,apiKey:o,selectedObjectName:i,setInstallation:s,onUpdateSuccess:a,setError:c}){const u={projectIdOrName:t,installationId:r,integrationId:n,installationUpdate:{updateMask:[`config.content.read.objects.${i}`],installation:{config:e}}};return je().installationApi.updateInstallation(u,{headers:{"X-Api-Key":o,"Content-Type":"application/json"}}).then(d=>{s(d),a==null||a(d.id,d.config)}).catch(d=>{st(d,c)})}const tI=(e,t,n,r,o,i)=>{const s=Ol(e),a=El(e),c=Sl(e),u={content:{read:{objects:{[t]:{objectName:t,schedule:r,destination:(n==null?void 0:n.destination)||"",selectedFields:s,selectedFieldMappings:a,selectedValueMappings:c||{},backfill:i}}}}};return to(o)&&(u.content||(u.content={}),u.content.proxy={enabled:!0}),u},nI=(e,t,n,r,o,i,s,a,c,u,d)=>{const f=tI(i,r||"",a,a.schedule,c,a.backfill);return f?eI({updateConfig:f,projectId:e,integrationId:t,installationId:n,apiKey:o,selectedObjectName:r,setError:u,setInstallation:s,onUpdateSuccess:d}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},rI=(e,t)=>{const r={content:{write:{objects:Tl(e)}}};return to(t)&&(r.content||(r.content={}),r.content.proxy={enabled:!0}),r},iI=(e,t,n,r,o,i,s,a,c)=>{const u=rI(o,i);if(!u)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const d={projectIdOrName:e,installationId:n,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:u}}};return je().installationApi.updateInstallation(d,{headers:{"X-Api-Key":r,"Content-Type":"application/json"}}).then(f=>{a(f),c==null||c(f.id,f.config)}).catch(f=>{st(f,s)})};function oI({installation:e,integrationObj:t}){const{setInstallation:n,hydratedRevision:r,loading:o,selectedObjectName:i,apiKey:s,projectId:a,resetBoundary:c,setErrors:u,setMutateInstallationError:d,getMutateInstallationError:f,resetConfigureState:m,resetPendingConfigurationState:p,configureState:g,onUpdateSuccess:y,onNextIncompleteTab:h}=Yu(),[x,v]=w.useState(!1),_=i===er,C=f(i),{config:b}=e,S=w.useCallback(()=>{c(we.MAPPING),r!=null&&r.content&&!o&&i&&Cl(r,b,i,m)},[c,r,o,i,b,m]);w.useEffect(()=>{g||S()},[g,S]);const R=w.useMemo(()=>{var G,ne,W;return(W=(ne=(G=r==null?void 0:r.content)==null?void 0:G.read)==null?void 0:ne.objects)==null?void 0:W.find(ce=>(ce==null?void 0:ce.objectName)===i)},[r,i]),N=()=>{const{requiredMapFields:q,selectedFieldMappings:G}=(g==null?void 0:g.read)||{},{errorList:ne}=Il(q,G,u);ne.length>0||(r&&e&&i&&s&&a&&R?(v(!0),nI(a,t.id,e.id,i,s,g,n,R,r,d(i),y).finally(()=>{v(!1),p(i),h()})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},M=()=>{e&&i&&s&&a&&r?(v(!0),iI(a,t.id,e.id,s,g,r,d(i),n,y).finally(()=>{v(!1),p(i),h()})):console.error("UpdateInstallation - onSaveUpdate missing required props")},U=q=>{q.preventDefault(),_?M():N()};return l.jsx(Qu,{errorMsg:C,onSave:U,onReset:S,isLoading:x})}function sI(){const{integrationObj:e,installation:t}=ut();return e?t&&e?l.jsx(oI,{installation:t,integrationObj:e}):l.jsx(Zw,{}):l.jsx(cl,{message:"We can't load the integration"})}const aI=(e,t)=>({revisionId:e.id,createdBy:`consumer:${t}`,content:{provider:e.content.provider,proxy:{enabled:!0}}});function cI({projectId:e,integrationId:t,groupRef:n,consumerRef:r,connectionId:o,apiKey:i,hydratedRevision:s,setError:a,setInstallation:c,onInstallSuccess:u}){const d=aI(s,r);return d?Os({createConfig:d,projectId:e,integrationId:t,groupRef:n,connectionId:o,apiKey:i,setError:a,setInstallation:c,onInstallSuccess:u}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))}function lI(){return l.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"#BBF7D0"}),l.jsx("path",{d:"M34.6666 18.6667L20 32.0001L13.3333 25.9395",stroke:"#16A34A",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}function ra({text:e,children:t}){return l.jsx(Pr,{children:l.jsxs(Pn,{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"3rem",gap:"3rem"},children:[l.jsx(lI,{}),l.jsx("p",{children:e}),t]})})}function uI({provider:e}){const t=`You have successfully installed your ${Dn(e)} integration.`;return l.jsx(ra,{text:t,children:l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:l.jsx(Xu,{buttonText:"Uninstall",buttonVariant:"outline",buttonStyle:{fontSize:"13px"}})})})}const dI=e=>{const{read:t,write:n,proxy:r}=(e==null?void 0:e.content)??{};return!t&&!n&&(r==null?void 0:r.enabled)||!1};function fI({children:e}){var _;const{projectId:t}=Le(),n=tt(),{hydratedRevision:r,loading:o}=dn(),{integrationObj:i,installation:s,groupRef:a,consumerRef:c,setInstallation:u,onInstallSuccess:d,isIntegrationDeleted:f}=ut(),{selectedConnection:m}=or(),[p,g]=w.useState(!1),y=o||p,h=(_=r==null?void 0:r.content)==null?void 0:_.provider,x=dI(r),v=C=>{console.error("Error when creating proxy installation:",C)};return w.useEffect(()=>{!y&&r&&x&&!s&&m&&n&&(i!=null&&i.id)&&!f&&(g(!0),cI({apiKey:n,projectId:t,integrationId:i==null?void 0:i.id,groupRef:a,consumerRef:c,connectionId:m==null?void 0:m.id,hydratedRevision:r,setError:v,setInstallation:u,onInstallSuccess:d}).then(()=>{g(!1)}).catch(C=>{g(!1),console.error("Error when creating proxy installation:",C)}))},[r,x,s,m,n,t,i==null?void 0:i.id,a,c,u,y,d,f]),i?y?l.jsx(eo,{}):x&&h&&s?l.jsx(uI,{provider:h}):l.jsx("div",{children:e}):l.jsx(un,{message:"We can't load the integration"})}function Zu(){return l.jsxs("footer",{style:{backgroundColor:"light-dark(#EFEFEF, #646266)",padding:"1em",fontSize:"0.8em",color:"gray",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"0 0 4px 4px",gap:"0.4em"},children:[l.jsx("p",{style:{color:"light-dark(gray, #EFEFEF)"},children:"Secured by"}),l.jsx("a",{href:"https://www.withampersand.com/",target:"_blank","aria-label":"Go to Ampersand",rel:"noreferrer noopener",children:l.jsxs("picture",{children:[l.jsx("source",{srcSet:"https://res.cloudinary.com/dycvts6vp/image/upload/v1723671980/ampersand-logo-black.svg",media:"(prefers-color-scheme: light)"}),l.jsx("source",{srcSet:"https://res.cloudinary.com/dycvts6vp/image/upload/v1735853540/ampersand_logo_white.svg",media:"(prefers-color-scheme: dark)"}),l.jsx("img",{style:{height:".8em"},src:"https://res.cloudinary.com/dycvts6vp/image/upload/v1723671980/ampersand-logo-black.svg",alt:"Ampersand"})]})})]})}function ai({children:e}){return l.jsx(Pr,{children:l.jsxs(Pn,{children:[l.jsx("div",{style:{padding:"3rem 2rem"},children:e}),l.jsx(Zu,{})]})})}function ci({children:e}){return l.jsx("h1",{style:{fontWeight:600,lineHeight:1.2,fontSize:"1.2em"},children:e})}function li({error:e}){return e?l.jsx(Rl,{style:{marginTop:"2em"},children:e}):null}function ia({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r,children:o,title:i}){if(!i&&!r)throw new Error("Either title or providerName is required");return l.jsxs(ai,{children:[l.jsx(ci,{children:i||`Set up ${r} integration`}),l.jsx(li,{error:t}),o,l.jsx(at,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}const pI="_link_oo2kv_1",hI={link:pI};function ed({href:e,className:t,style:n,label:r,children:o,newTab:i=!1}){return l.jsx("a",{className:It(hI.link,t),style:n,href:e,"aria-label":r||void 0,target:i?"_blank":"_self",rel:i?"noopener noreferrer":void 0,children:o})}function td({url:e,providerDisplayName:t,credentialName:n}){return l.jsxs("p",{style:{color:"var(--amp-colors-text-muted)"},children:[l.jsx(ed,{href:e,newTab:!0,children:l.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," about where to find your ",t," ",n,"."]})}const mI="_textarea_18zl4_1",gI="_textareaError_18zl4_14",yI="_error_18zl4_29",jo={textarea:mI,textareaError:gI,error:yI};function vI({className:e,isError:t=!1,...n}){const r=t?It(jo.textareaError,jo.textarea):jo.textarea;return l.jsx("textarea",{className:It(e,r),...n})}const ln={Input:Qi,Textarea:vI};function wI({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){var y;const[i,s]=w.useState(!1),a=()=>s(h=>!h),[c,u]=w.useState(""),d=h=>u(h.currentTarget.value),f=c.length>0,m=o||!f,p=Dn(e,t),g=(y=t.apiKeyOpts)==null?void 0:y.docsURL;return l.jsx(ia,{providerName:p,handleSubmit:()=>{n({apiKey:c})},error:r,isButtonDisabled:m,children:l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[g&&l.jsx(td,{url:g,providerDisplayName:p,credentialName:"API key"}),l.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[l.jsx(ln.Input,{id:"password",name:"password",type:i?"text":"password",placeholder:"API Key",onChange:h=>d(h)}),l.jsx(at,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:a,children:i?"Hide":"Show"})]})]})})}function II({...e}){return l.jsx(wI,{...e})}function bI({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a,setSelectedConnection:c}){const u=Le(),[d,f]=w.useState(!1),[m,p]=w.useState(null),g=tt();w.useEffect(()=>{if(e&&je&&d&&m!=null){const h={groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,apiKey:m};je().connectionApi.generateConnection({projectIdOrName:u.projectId,generateConnectionParams:h},{headers:{"X-Api-Key":g??"","Content-Type":"application/json"}}).then(x=>{c(x)}).catch(x=>{console.error("Error loading provider info."),st(x)})}},[g,e,d,r,n,i,o,u,c,m]);const y=h=>{p(h.apiKey),f(!0)};return a===null?l.jsx(II,{provider:e,providerInfo:t,handleSubmit:y,error:null}):s}function _I({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){var x;const[i,s]=w.useState(!1),a=()=>s(v=>!v),[c,u]=w.useState({username:"",password:""}),{username:d,password:f}=c,m=Dn(e,t),p=(x=t.basicOpts)==null?void 0:x.docsURL,g=d.length>0,y=o||!g,h=v=>{const{name:_,value:C}=v.currentTarget;u(b=>({...b,[_]:C}))};return l.jsx(ia,{providerName:m,handleSubmit:()=>{n({user:d,pass:f})},error:r,isButtonDisabled:y,children:l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[p&&l.jsx(td,{url:p,providerDisplayName:m,credentialName:"credentials"}),l.jsx(ln.Input,{id:"username",name:"username",type:"text",placeholder:"Username",onChange:v=>h(v)}),l.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[l.jsx(ln.Input,{id:"password",name:"password",type:i?"text":"password",placeholder:"Password",onChange:v=>h(v)}),l.jsx(at,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:a,children:i?"Hide":"Show"})]})]})})}function xI({...e}){return l.jsx(_I,{...e})}function CI({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a,setSelectedConnection:c}){const u=Le(),[d,f]=w.useState(!1),[m,p]=w.useState(null),g=tt();w.useEffect(()=>{if(e&&je&&d&&m!=null){const h={groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,basicAuth:{username:m.user,password:m.pass}};je().connectionApi.generateConnection({projectIdOrName:u.projectId,generateConnectionParams:h},{headers:{"X-Api-Key":g??"","Content-Type":"application/json"}}).then(x=>{c(x)}).catch(x=>{console.error("Error loading provider info."),st(x)})}},[g,e,d,r,n,i,o,u,m,c]);const y=h=>{const{user:x,pass:v}=h;p({user:x,pass:v}),f(!0)};return a===null?l.jsx(xI,{provider:e,providerInfo:t,handleSubmit:y,error:null}):s}function OI({...e}){return l.jsx(ia,{...e})}function EI({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,selectedConnection:s,setSelectedConnection:a,providerName:c}){const u=Le(),d=tt(),[f,m]=w.useState(!1);w.useEffect(()=>{if(e&&je&&f){const g={groupName:o,groupRef:r,consumerName:n,consumerRef:t,provider:e};je().connectionApi.generateConnection({projectIdOrName:u.projectId,generateConnectionParams:g},{headers:{"X-Api-Key":d??"","Content-Type":"application/json"}}).then(y=>{a(y)}).catch(y=>{console.error("Error loading provider info."),st(y)})}},[d,e,f,n,t,o,r,a,u]);const p=()=>{m(!0)};return s===null?l.jsx(OI,{handleSubmit:p,error:null,providerName:c}):i}const SI=_s("VITE_AMP_ENABLE_CSRF",!1),NI=_s("NEXT_AMP_ENABLE_CSRF",!1),TI=_s("REACT_APP_AMP_ENABLE_CSRF",!1),RI=!!SI||!!NI||!!TI,nd=async(e,t,n,r,o,i,s,a)=>{var u,d;const c=await je().providerApi.getProvider({provider:o},{headers:{"X-Api-Key":r??""}});if(!c)throw new Error(`Provider ${o} not found`);if(c.authType==="oauth2"&&(((u=c.oauth2Opts)==null?void 0:u.grantType)==="authorizationCode"||((d=c.oauth2Opts)==null?void 0:d.grantType)==="authorizationCodePKCE")){const m=(await je().providerAppApi.listProviderApps({projectIdOrName:e},{headers:{"X-Api-Key":r??""}})).find(h=>h.provider===o),p=Dn(o,c);if(!m)throw new Error(`You must first set up a ${p} Provider App using the Ampersand Console.`);const g={connectOAuthParams:{providerWorkspaceRef:i,projectId:e,groupRef:n,groupName:a,consumerRef:t,consumerName:s,providerAppId:m.id,provider:o,enableCSRFProtection:RI}};return await je().oAuthApi.oauthConnect(g,{credentials:"include",headers:{"X-Api-Key":r??"","Content-Type":"application/json"}})}throw new Error(`Provider ${o} does not support an OAuth2 web flow.`)},_c=600,xc=600,AI="AUTHORIZATION_SUCCEEDED",PI="AUTHORIZATION_FAILED";function DI(e,t,n){return w.useCallback(async r=>{const o=await je().connectionApi.getConnection({projectIdOrName:e,connectionId:r},{headers:{"X-Api-Key":t??""}});n(o)},[e,t,n])}function FI(e,t,n,r){return w.useCallback(()=>{if(!r)return;const o=window.screenX+(window.outerWidth-_c)/2,i=window.screenY+(window.outerHeight-xc)/2.5,s=`width=${_c},height=${xc},left=${o},top=${i}`,a=window.open(r,e,s);t(a),window.addEventListener("message",n,!1)},[r,e,t,n])}function MI(e,t){return w.useCallback(n=>{var r,o;if(n.origin===Tm){if(n.data.eventType===AI){const i=(r=n.data.data)==null?void 0:r.connection;i?e(i):console.error("Connection ID not found in event data: ",{event:n})}n.data.eventType===PI&&(console.error("OAuth failed: ",{event:n}),t==null||t(((o=n==null?void 0:n.data)==null?void 0:o.message)??"OAuth failed. Please try again."))}},[t,e])}function rd({children:e,oauthUrl:t,windowTitle:n="Connect to Provider",onError:r,error:o}){const i=tt(),{projectId:s}=Le(),[a,c]=w.useState(null),[u,d]=w.useState(null),{setSelectedConnection:f}=or(),m=MI(c,r),p=FI(n,d,m,t),g=DI(s,i,f);return w.useEffect(()=>{t&&!u&&p()},[t,u,p,m,n]),w.useEffect(()=>{a&&g(a).then(()=>{u==null||u.close()}).catch(y=>{console.error("Error refreshing connection: ",y),r==null||r(y.message??"Unexpected error: not able to refresh connection")})},[a,i,f,g,u,r]),w.useEffect(()=>{if(!u)return;const y=setInterval(()=>{u.closed&&(clearInterval(y),window.removeEventListener("message",m),d(null),!a&&!o?(console.error("OAuth failed. Please try again."),r==null||r("OAuth failed. Please try again.")):a&&(r==null||r(null)))},500);return()=>{clearInterval(y),window.removeEventListener("message",m)}},[u,a,o,m,r]),l.jsx("div",{children:e})}function jI({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return l.jsxs(ai,{children:[l.jsx(ci,{children:`Set up ${r} integration`}),l.jsx(li,{error:t}),l.jsx(at,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function kI({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,providerName:i}){const{projectId:s}=Le(),a=tt(),[c,u]=w.useState(null),[d,f]=w.useState(null),m=async()=>{f(null);try{const g=await nd(s,t,r,a,e,void 0,n,o);u(g)}catch(g){console.error("Could not fetch OAuth popup URL."),st(g),f(g.message??"Unexpected error")}},p=w.useCallback(g=>{f(g),u(null)},[]);return l.jsx(rd,{windowTitle:`Connect to ${i}`,oauthUrl:c,onError:p,children:l.jsx(jI,{handleSubmit:m,error:d,providerName:i})})}const LI="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function VI({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r}){return l.jsxs(ai,{children:[l.jsx(ci,{children:"Enter your Salesforce subdomain"}),l.jsx(ed,{href:LI,newTab:!0,children:"What is my Salesforce subdomain?"}),l.jsx(li,{error:n}),l.jsxs("div",{style:{display:"flex",marginTop:"1em",alignItems:"center"},children:[l.jsx(ln.Input,{id:"salesforce-subdomain",type:"text",placeholder:"my-domain",onChange:o=>t(o.currentTarget.value)}),l.jsx("p",{style:{lineHeight:"2.2em",marginLeft:"0.4em"},children:".my.salesforce.com"})]}),l.jsx(at,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}function KI({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r,providerName:o}){return l.jsxs(ai,{children:[l.jsxs(ci,{children:["Enter your ",o," workspace"]}),l.jsx(li,{error:n}),l.jsx("br",{}),l.jsx(ln.Input,{id:"workspace",type:"text",placeholder:"MyWorkspace",onChange:i=>t(i.currentTarget.value)}),l.jsx("br",{}),l.jsx(at,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}const $I="salesforce";function UI({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,providerName:i}){const{projectId:s}=Le(),a=tt(),[c,u]=w.useState(""),[d,f]=w.useState(null),[m,p]=w.useState(null),g=async()=>{if(p(null),!c){p("Workspace is required");return}try{const x=await nd(s,t,r,a,e,c,n,o);f(x)}catch(x){console.error(x),p((x==null?void 0:x.message)??"Unexpected error")}},y=w.useCallback(x=>{p(x),f(null)},[]),h=e===$I?l.jsx(VI,{handleSubmit:g,setWorkspace:u,error:m,isButtonDisabled:c.length===0}):l.jsx(KI,{handleSubmit:g,setWorkspace:u,error:m,isButtonDisabled:c.length===0,providerName:i});return l.jsx(rd,{windowTitle:`Connect to ${i}`,oauthUrl:d,onError:y,children:h})}function qI({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r,explicitScopesRequired:o,explicitWorkspaceRequired:i}){const[s,a]=w.useState(!1),[c,u]=w.useState({clientSecret:"",clientId:"",workspace:"",scopes:""}),d=()=>a(b=>!b),f=b=>{const{name:S,value:R}=b.currentTarget;u(N=>({...N,[S]:R}))},{clientSecret:m,clientId:p,workspace:g,scopes:y}=c,h=m.length>0,x=p.length>0,v=i?g.length>0:!0,_=n||!h||!x||!v,C=()=>{const b={clientId:p,clientSecret:m};i&&(b.workspace=g),o&&y.length>0&&(b.scopes=Xm(y)),e(b)};return l.jsxs(ai,{children:[l.jsx(ci,{children:`Set up ${r} integration`}),l.jsx(li,{error:t}),l.jsx("br",{}),l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.2rem"},children:[i&&l.jsx(ln.Input,{id:"workspace",name:"workspace",type:"text",placeholder:"MyWorkspace",onChange:b=>f(b)}),l.jsx(ln.Input,{id:"clientId",name:"clientId",type:"text",placeholder:"Client ID",onChange:b=>f(b)}),l.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[l.jsx(ln.Input,{id:"clientSecret",name:"clientSecret",type:s?"text":"password",placeholder:"Client Secret",onChange:b=>f(b)}),l.jsx(at,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:d,children:s?"Hide":"Show"})]}),o&&l.jsx(ln.Textarea,{name:"scopes",placeholder:"Scopes separated by new line",onChange:b=>f(b)})]}),l.jsx("br",{}),l.jsx(at,{style:{marginTop:"1em",width:"100%"},disabled:_,type:"submit",onClick:C,children:"Next"})]})}function HI({provider:e,providerName:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,explicitScopesRequired:s,explicitWorkspaceRequired:a,selectedConnection:c,setSelectedConnection:u}){const{projectId:d}=Le(),f=tt(),[m,p]=w.useState(null),g=async y=>{p(null);const h={groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,providerWorkspaceRef:y.workspace,oauth2ClientCredentials:{clientId:y.clientId,clientSecret:y.clientSecret,scopes:y.scopes}};je().connectionApi.generateConnection({projectIdOrName:d,generateConnectionParams:h},{headers:{"X-Api-Key":f??"","Content-Type":"application/json"}}).then(x=>{u(x)}).catch(x=>{console.error("Error loading provider info."),st(x),p("Error loading provider info")})};return c===null?l.jsx(qI,{providerName:t,handleSubmit:g,error:m,explicitScopesRequired:s,explicitWorkspaceRequired:a}):l.jsx(Br,{})}function BI({...e}){return l.jsx(HI,{...e})}const WI="authorizationCode",JI="authorizationCodePKCE",zI="clientCredentials";function GI({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,selectedConnection:s,setSelectedConnection:a}){if(t.oauth2Opts===void 0)return l.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:c,explicitScopesRequired:u,explicitWorkspaceRequired:d}=t.oauth2Opts,f=Dn(e,t),m={provider:e,consumerRef:n,consumerName:r,groupRef:o,groupName:i,providerName:f};return c===WI||c===JI?d?l.jsx(UI,{...m}):l.jsx(kI,{...m}):c===zI?l.jsx(BI,{...m,explicitWorkspaceRequired:d,explicitScopesRequired:u,selectedConnection:s,setSelectedConnection:a}):c==="password"?l.jsx("em",{children:"Password flow not supported yet"}):l.jsxs("em",{children:["Unsupported grant type: ",c]})}function XI(e){const{selectedConnection:t}=or();w.useEffect(()=>{e&&t&&e(t)},[e,t])}function QI({onSuccess:e}){XI(e)}const YI=async(e,t)=>{const n=await je().providerApi.getProvider({provider:t},{headers:{"X-Api-Key":e??""}});if(!n)throw new Error(`Provider ${t} not found`);return n};function id({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,onSuccess:s,onDisconnectSuccess:a,resetComponent:c}){const u=tt(),[d,f]=w.useState(null),{provider:m,isIntegrationDeleted:p}=ut(),{selectedConnection:g,setSelectedConnection:y}=or();QI({onSuccess:s});const h=e||m,x=(d==null?void 0:d.displayName)??Wr(h);if(w.useEffect(()=>{YI(u,h).then(_=>{f(_)}).catch(_=>{console.error("Error loading provider info."),st(_)})},[u,h]),!e&&!m)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");if(p)return l.jsx(ra,{text:"Integration successfully uninstalled.",children:l.jsx(at,{type:"button",onClick:c,style:{width:"100%"},children:"Reinstall Integration"})});if(g)return i;if(d==null)return l.jsx("strong",{children:"Provider not found"});const v={provider:h,consumerRef:t,consumerName:n,groupRef:r,groupName:o,selectedConnection:g,setSelectedConnection:y,providerName:x,providerInfo:d,onDisconnectSuccess:a};return d.authType==="none"?l.jsx(EI,{...v,children:i}):d.authType==="basic"?l.jsx(CI,{...v,children:i}):d.authType==="apiKey"?l.jsx(bI,{...v,children:i}):l.jsx(GI,{...v})}function ZI(e){const t=e+"CollectionProvider",[n,r]=ho(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=p=>{const{scope:g,children:y}=p,h=w.useRef(null),x=w.useRef(new Map).current;return l.jsx(o,{scope:g,itemMap:x,collectionRef:h,children:y})};s.displayName=t;const a=e+"CollectionSlot",c=w.forwardRef((p,g)=>{const{scope:y,children:h}=p,x=i(a,y),v=Qr(g,x.collectionRef);return l.jsx(Xi,{ref:v,children:h})});c.displayName=a;const u=e+"CollectionItemSlot",d="data-radix-collection-item",f=w.forwardRef((p,g)=>{const{scope:y,children:h,...x}=p,v=w.useRef(null),_=Qr(g,v),C=i(u,y);return w.useEffect(()=>(C.itemMap.set(v,{ref:v,...x}),()=>void C.itemMap.delete(v))),l.jsx(Xi,{[d]:"",ref:_,children:h})});f.displayName=u;function m(p){const g=i(e+"CollectionConsumer",p);return w.useCallback(()=>{const h=g.collectionRef.current;if(!h)return[];const x=Array.from(h.querySelectorAll(`[${d}]`));return Array.from(g.itemMap.values()).sort((C,b)=>x.indexOf(C.ref.current)-x.indexOf(b.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:s,Slot:c,ItemSlot:f},m,r]}var eb=$.useId||(()=>{}),tb=0;function od(e){const[t,n]=$.useState(eb());return Gi(()=>{e||n(r=>r??String(tb++))},[e]),e||(t?`radix-${t}`:"")}var nb=$.createContext(void 0);function sd(e){const t=$.useContext(nb);return e||t||"ltr"}var ko="rovingFocusGroup.onEntryFocus",rb={bubbles:!1,cancelable:!0},mo="RovingFocusGroup",[gs,ad,ib]=ZI(mo),[ob,cd]=ho(mo,[ib]),[sb,ab]=ob(mo),ld=$.forwardRef((e,t)=>l.jsx(gs.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(gs.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(cb,{...e,ref:t})})}));ld.displayName=mo;var cb=$.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,m=$.useRef(null),p=Qr(t,m),g=sd(i),[y=null,h]=ea({prop:s,defaultProp:a,onChange:c}),[x,v]=$.useState(!1),_=Zs(u),C=ad(n),b=$.useRef(!1),[S,R]=$.useState(0);return $.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(ko,_),()=>N.removeEventListener(ko,_)},[_]),l.jsx(sb,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:y,onItemFocus:$.useCallback(N=>h(N),[h]),onItemShiftTab:$.useCallback(()=>v(!0),[]),onFocusableItemAdd:$.useCallback(()=>R(N=>N+1),[]),onFocusableItemRemove:$.useCallback(()=>R(N=>N-1),[]),children:l.jsx(Fn.div,{tabIndex:x||S===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:$t(e.onMouseDown,()=>{b.current=!0}),onFocus:$t(e.onFocus,N=>{const M=!b.current;if(N.target===N.currentTarget&&M&&!x){const U=new CustomEvent(ko,rb);if(N.currentTarget.dispatchEvent(U),!U.defaultPrevented){const q=C().filter(re=>re.focusable),G=q.find(re=>re.active),ne=q.find(re=>re.id===y),ce=[G,ne,...q].filter(Boolean).map(re=>re.ref.current);fd(ce,d)}}b.current=!1}),onBlur:$t(e.onBlur,()=>v(!1))})})}),ud="RovingFocusGroupItem",dd=$.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,...s}=e,a=od(),c=i||a,u=ab(ud,n),d=u.currentTabStopId===c,f=ad(n),{onFocusableItemAdd:m,onFocusableItemRemove:p}=u;return $.useEffect(()=>{if(r)return m(),()=>p()},[r,m,p]),l.jsx(gs.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:l.jsx(Fn.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:$t(e.onMouseDown,g=>{r?u.onItemFocus(c):g.preventDefault()}),onFocus:$t(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:$t(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){u.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const y=db(g,u.orientation,u.dir);if(y!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let x=f().filter(v=>v.focusable).map(v=>v.ref.current);if(y==="last")x.reverse();else if(y==="prev"||y==="next"){y==="prev"&&x.reverse();const v=x.indexOf(g.currentTarget);x=u.loop?fb(x,v+1):x.slice(v+1)}setTimeout(()=>fd(x))}})})})});dd.displayName=ud;var lb={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ub(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function db(e,t,n){const r=ub(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return lb[r]}function fd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function fb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var pb=ld,hb=dd,oa="Tabs",[mb,Ub]=ho(oa,[cd]),pd=cd(),[gb,sa]=mb(oa),hd=$.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:c="automatic",...u}=e,d=sd(a),[f,m]=ea({prop:r,onChange:o,defaultProp:i});return l.jsx(gb,{scope:n,baseId:od(),value:f,onValueChange:m,orientation:s,dir:d,activationMode:c,children:l.jsx(Fn.div,{dir:d,"data-orientation":s,...u,ref:t})})});hd.displayName=oa;var md="TabsList",gd=$.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=sa(md,n),s=pd(n);return l.jsx(pb,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:r,children:l.jsx(Fn.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});gd.displayName=md;var yd="TabsTrigger",vd=$.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=sa(yd,n),a=pd(n),c=Id(s.baseId,r),u=bd(s.baseId,r),d=r===s.value;return l.jsx(hb,{asChild:!0,...a,focusable:!o,active:d,children:l.jsx(Fn.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":u,"data-state":d?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...i,ref:t,onMouseDown:$t(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(r):f.preventDefault()}),onKeyDown:$t(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(r)}),onFocus:$t(e.onFocus,()=>{const f=s.activationMode!=="manual";!d&&!o&&f&&s.onValueChange(r)})})})});vd.displayName=yd;var wd="TabsContent",yb=$.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=sa(wd,n),c=Id(a.baseId,r),u=bd(a.baseId,r),d=r===a.value,f=$.useRef(d);return $.useEffect(()=>{const m=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(m)},[]),l.jsx(ta,{present:o||d,children:({present:m})=>l.jsx(Fn.div,{"data-state":d?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:u,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:m&&i})})});yb.displayName=wd;function Id(e,t){return`${e}-trigger-${t}`}function bd(e,t){return`${e}-content-${t}`}var vb=hd,wb=gd,_d=vd;const Ib=l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[l.jsx("circle",{cx:"9",cy:"9",r:"9",fill:"#BBF7D0"}),l.jsx("path",{d:"M13 7L7.5 12L5 9.72727",stroke:"#16A34A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function bb(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?Ib:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:l.jsx("circle",{cx:"9",cy:"9",r:"5",fill:"#BFDBFE"})})}function _b(){return l.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M2.25 4.5H3.75H15.75",stroke:"#E73D3D",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),l.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:"#E73D3D",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M7.5 8.25V12.75",stroke:"#E73D3D",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M10.5 8.25V12.75",stroke:"#E73D3D",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const xb="_tabsRoot_ktpr0_1",Cb="_tabsList_ktpr0_6",Ob="_tabTrigger_ktpr0_12",Eb="_danger_ktpr0_29",Yr={tabsRoot:xb,tabsList:Cb,tabTrigger:Ob,danger:Eb};function xd({objectName:e,completed:t,pending:n,displayName:r}){return l.jsx(_d,{value:e,className:Yr.tabTrigger,children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[bb(t,n),l.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[l.jsx("span",{children:r||e}),n&&l.jsx("span",{style:{fontSize:".8rem",fontStyle:"italic"},children:"pending"})]})]})})}function Sb({completed:e,pending:t,displayName:n}){return l.jsxs(l.Fragment,{children:[l.jsx(po,{style:{margin:"1rem 0"}}),l.jsx(xd,{objectName:er,completed:e,pending:t,displayName:n},"other-write")]})}function Nb(){return l.jsxs(l.Fragment,{children:[l.jsx(po,{style:{margin:"3rem 0 1rem 0"}}),l.jsx(_d,{value:Li,className:It(Yr.tabTrigger,Yr.danger),children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[_b(),l.jsx("span",{children:"Uninstall"})]})})]})}function Tb({value:e,readNavObjects:t,onValueChange:n,objectConfigurationsState:r,writeNavObject:o,showUninstallButton:i}){var s,a;return l.jsx(vb,{value:e,className:Yr.tabsRoot,onValueChange:n,children:l.jsxs(wb,{className:Yr.tabsList,children:[t.map(c=>{var u,d,f,m,p,g;return l.jsx(xd,{objectName:c.name,displayName:c.displayName,completed:c.completed,pending:((d=(u=r==null?void 0:r[c.name])==null?void 0:u.read)==null?void 0:d.isOptionalFieldsModified)||((m=(f=r==null?void 0:r[c.name])==null?void 0:f.read)==null?void 0:m.isRequiredMapFieldsModified)||((g=(p=r==null?void 0:r[c.name])==null?void 0:p.read)==null?void 0:g.isValueMappingsModified)||!1},c.name)}),o&&l.jsx(Sb,{completed:o.completed,pending:((a=(s=r==null?void 0:r.other)==null?void 0:s.write)==null?void 0:a.isWriteModified)||!1,displayName:"Write"}),i&&l.jsx(Nb,{})]})})}function Rb(e,t){return t===Li?{name:Li,completed:!1}:e.find(n=>n.name===t)}function Ab({children:e}){var x;const{project:t}=Le(),{installation:n,provider:r}=ut(),{hydratedRevision:o}=dn(),{objectConfigurationsState:i}=Ns(),[s,a]=w.useState(""),c=(t==null?void 0:t.appName)||"",u=n==null?void 0:n.config,d=o&&vl(u,o),f=d!==null,m=!!((x=o==null?void 0:o.content)!=null&&x.write),p=m?wl(u):void 0,g=w.useMemo(()=>{const v=[...d||[]];return p&&m&&v.push(p),v},[d,p,m]),y=Rb(g,s),h=w.useCallback(()=>{const v=g.find(_=>y!==_&&!_.completed);v&&a(v.name)},[g,y]);return w.useEffect(()=>{!s&&g.length>0&&a(g[0].name)},[g,s,h]),l.jsx(Ml.Provider,{value:h,children:l.jsx(Dl.Provider,{value:y==null?void 0:y.name,children:l.jsxs(Pr,{style:{maxWidth:"55rem"},children:[l.jsxs(Pn,{style:{display:"flex",gap:"1rem",padding:"3rem",backgroundColor:"var(--amp-colors-bg-primary)"},children:[l.jsxs("div",{style:{width:"20rem"},children:[l.jsxs("h1",{style:{fontSize:"small",fontWeight:"400"},children:[Dn(r)," integration"]}),l.jsx("h3",{style:{marginBottom:"20px",fontSize:"large",fontWeight:"500"},children:c}),f&&l.jsx(Tb,{value:s,readNavObjects:d,onValueChange:v=>a(v),objectConfigurationsState:i,writeNavObject:p,showUninstallButton:!!n})]}),e]}),l.jsx(Zu,{})]})})})}function Pb({...e}){return l.jsx(Ab,{...e})}function Db({integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c}){var x;const{projectId:u,projectIdOrName:d,isLoading:f}=Le(),{isLoading:m}=bs(),{isError:p,errorState:g}=Ht(),{seed:y,reset:h}=hl();return f||m?l.jsx(eo,{}):p(we.PROJECT,d)?l.jsx(un,{message:`Error loading project ${d}`}):p(we.INTEGRATION_LIST,d)?l.jsx(un,{message:"Error retrieving integrations for the project, double check the API key"}):(x=g[we.INTEGRATION_LIST])!=null&&x.apiError?l.jsx(un,{message:"Something went wrong, couldn't find integration information"}):l.jsx("div",{className:ml.resetContainer,children:l.jsx(Ym,{integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c,children:l.jsx(pl,{groupRef:r,children:l.jsx(id,{consumerRef:t,consumerName:n,groupRef:r,groupName:o,resetComponent:h,children:l.jsx(_g,{projectId:u,children:l.jsx(fI,{children:l.jsx(jg,{children:l.jsx(Pb,{children:l.jsx(sI,{})})})})})})})},y)})}function Fb(){return l.jsxs(Pr,{style:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[l.jsx(Br,{}),l.jsx("p",{children:"Redirecting"})]})}function Mb({redirectURL:e,children:t}){return w.useEffect(()=>{e&&window.location.replace(e)},[e]),e?l.jsx(Fb,{}):t}function jb({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={},onDisconnectSuccess:r,resetComponent:o}){const i=tt(),{projectId:s}=Le(),{selectedConnection:a,setConnections:c}=or(),[u,d]=w.useState(!1),f=!s||!a||!a.id||u,m=async()=>{if(!f){d(!0),console.warn("deleting connection",{projectId:s,connectionId:a==null?void 0:a.id});try{await je().connectionApi.deleteConnection({projectIdOrName:s,connectionId:a==null?void 0:a.id},{headers:{"X-Api-Key":i,"Content-Type":"application/json"}}),console.warn("successfully deleted connection:",a==null?void 0:a.id),r==null||r(a),je().connectionApi.listConnections({projectIdOrName:s},{headers:{"X-Api-Key":i??""}}).then(y=>{c(y),o()}).catch(y=>{st(y)})}catch(y){console.error("Error deleting connection."),st(y)}finally{d(!1)}}},p=u?"Disconnecting...":e;return l.jsx(at,{type:"button",onClick:m,disabled:f,variant:t,style:n,children:p})}function kb({provider:e,onDisconnectSuccess:t,resetComponent:n}){const{appName:r}=Le(),o=`You have successfully connected your ${Dn(e)} account to ${r}.`;return l.jsx(ra,{text:o,children:l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:l.jsx(jb,{resetComponent:n,onDisconnectSuccess:t,buttonText:"Remove Connection",buttonVariant:"outline",buttonStyle:{fontSize:"13px"}})})})}function Lb({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,redirectUrl:i,onSuccess:s,onDisconnectSuccess:a,onConnectSuccess:c}){const{seed:u,reset:d}=hl(),f=w.useCallback(m=>{s?s(m.id):c&&c(m)},[s,c]);return l.jsx("div",{className:ml.resetContainer,children:l.jsx(pl,{provider:e,groupRef:r,children:l.jsx(id,{resetComponent:d,provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onSuccess:f,onDisconnectSuccess:a,children:l.jsx(Mb,{redirectURL:i,children:l.jsx(kb,{resetComponent:d,provider:e,onDisconnectSuccess:a})})})})},u)}const Vb=(e,t)=>{const n=tt(),{projectId:r,isLoading:o}=Le(),{integrations:i}=bs(),[s,a]=w.useState(!1),[c,u]=w.useState(null);if(!n||!o&&!r)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 f=w.useMemo(()=>i==null?void 0:i.reduce((m,p)=>(p==null?void 0:p.name)===e?p:m,{}),[i,e]);return w.useEffect(()=>{!f||o||je().installationApi.listInstallations({projectIdOrName:r,integrationId:f.id,groupRef:t},{headers:{"x-api-key":n}}).then(m=>{a(!0),u(m.length>0)}).catch(m=>{console.error("Error listing installations."),st(m),a(!0)})},[t,n,r,f,o]),{isLoaded:s,isIntegrationInstalled:c}};exports.AmpersandContext=al;exports.AmpersandProvider=jm;exports.ConnectProvider=Lb;exports.FieldMapping=uo;exports.InstallIntegration=Db;exports.useAmpersandProvider=km;exports.useIsIntegrationInstalled=Vb;
@@ -3643,7 +3643,7 @@ class pl {
3643
3643
  this.connectionApi = new Pm(t), this.installationApi = new Dm(t), this.integrationApi = new Fm(t), this.oAuthApi = new Mm(t), this.projectApi = new km(t), this.providerApi = new Lm(t), this.providerAppApi = new Vm(t), this.revisionApi = new Km(t);
3644
3644
  }
3645
3645
  }
3646
- const fl = "2.4.1", $m = "v1", Pi = "https://api.withampersand.com";
3646
+ const fl = "2.4.2", $m = "v1", Pi = "https://api.withampersand.com";
3647
3647
  function hl() {
3648
3648
  try {
3649
3649
  const e = process.env.REACT_APP_AMP_SERVER;
@@ -10515,14 +10515,15 @@ function Xw() {
10515
10515
  [t, r, o, i]
10516
10516
  );
10517
10517
  return ee(() => {
10518
+ var f;
10518
10519
  if (t && c) {
10519
- const f = (e == null ? void 0 : e[t].filter(
10520
- (v) => v.fieldName && v.mappedValues.length > 0
10520
+ const _ = ((f = e == null ? void 0 : e[t]) == null ? void 0 : f.filter(
10521
+ (b) => b.fieldName && b.mappedValues.length > 0
10521
10522
  )) || [];
10522
- f.every((v) => {
10523
- const b = c[v.fieldName] || {};
10524
- return Object.keys(b).length === Object.keys(v.mappedValues).length;
10525
- }) && f.length > 0 ? !l && !u.current && (Jw(t, r, !0), u.current = !0) : u.current = !1;
10523
+ _.every((b) => {
10524
+ const O = c[b.fieldName] || {};
10525
+ return Object.keys(O).length === Object.keys(b.mappedValues).length;
10526
+ }) && _.length > 0 ? !l && !u.current && (Jw(t, r, !0), u.current = !0) : u.current = !1;
10526
10527
  }
10527
10528
  }, [
10528
10529
  c,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amp-labs/react",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "description": "Ampersand React library.",
5
5
  "author": {
6
6
  "name": "Ampersand Labs",