@amp-labs/react 2.7.7 → 2.7.8

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 Ka=e=>{throw TypeError(e)};var ko=(e,t,n)=>t.has(e)||Ka("Cannot "+n);var O=(e,t,n)=>(ko(e,t,"read from private field"),n?n.call(e):t.get(e)),se=(e,t,n)=>t.has(e)?Ka("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),G=(e,t,n,r)=>(ko(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),he=(e,t,n)=>(ko(e,t,"access private method"),n);var ji=(e,t,n,r)=>({set _(o){G(e,t,o,n)},get _(){return O(e,t,r)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),y=require("react");require("react-dom");function $f(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 M=$f(y);var Br=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(){}},cr=typeof window>"u"||"Deno"in globalThis;function At(){}function qf(e,t){return typeof e=="function"?e(t):e}function ns(e){return typeof e=="number"&&e>=0&&e!==1/0}function il(e,t){return Math.max(e+(t||0)-Date.now(),0)}function xr(e,t){return typeof e=="function"?e(t):e}function Ht(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!==js(s,t.options))return!1}else if(!ai(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 Ua(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(lr(t.options.mutationKey)!==lr(i))return!1}else if(!ai(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function js(e,t){return((t==null?void 0:t.queryKeyHashFn)||lr)(e)}function lr(e){return JSON.stringify(e,(t,n)=>is(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function ai(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>ai(e[n],t[n])):!1}function rs(e,t){if(e===t)return e;const n=$a(e)&&$a(t);if(n||is(e)&&is(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 f=0;f<s;f++){const u=n?f:i[f];(!n&&r.includes(u)||n)&&e[u]===void 0&&t[u]===void 0?(a[u]=void 0,c++):(a[u]=rs(e[u],t[u]),a[u]===e[u]&&e[u]!==void 0&&c++)}return o===s&&c===o?e:a}return t}function Zi(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 $a(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function is(e){if(!qa(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!qa(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function qa(e){return Object.prototype.toString.call(e)==="[object Object]"}function Hf(e){return new Promise(t=>{setTimeout(t,e)})}function os(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 rs(e,t)}catch(r){throw 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}`),r}return rs(e,t)}return t}function Bf(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Jf(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var eo=Symbol();function ol(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===eo&&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===eo?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Zn,Tn,_r,zc,Wf=(zc=class extends Br{constructor(){super();se(this,Zn);se(this,Tn);se(this,_r);G(this,_r,t=>{if(!cr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){O(this,Tn)||this.setEventListener(O(this,_r))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,Tn))==null||t.call(this),G(this,Tn,void 0))}setEventListener(t){var n;G(this,_r,t),(n=O(this,Tn))==null||n.call(this),G(this,Tn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){O(this,Zn)!==t&&(G(this,Zn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof O(this,Zn)=="boolean"?O(this,Zn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Zn=new WeakMap,Tn=new WeakMap,_r=new WeakMap,zc),Ls=new Wf,Or,Rn,Er,Gc,zf=(Gc=class extends Br{constructor(){super();se(this,Or,!0);se(this,Rn);se(this,Er);G(this,Er,t=>{if(!cr&&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,Rn)||this.setEventListener(O(this,Er))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,Rn))==null||t.call(this),G(this,Rn,void 0))}setEventListener(t){var n;G(this,Er,t),(n=O(this,Rn))==null||n.call(this),G(this,Rn,t(this.setOnline.bind(this)))}setOnline(t){O(this,Or)!==t&&(G(this,Or,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return O(this,Or)}},Or=new WeakMap,Rn=new WeakMap,Er=new WeakMap,Gc),to=new zf;function ss(){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 Gf(e){return Math.min(1e3*2**e,3e4)}function sl(e){return(e??"online")==="online"?to.isOnline():!0}var al=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function jo(e){return e instanceof al}function cl(e){let t=!1,n=0,r=!1,o;const i=ss(),s=v=>{var p;r||(g(new al(v)),(p=e.abort)==null||p.call(e))},a=()=>{t=!0},c=()=>{t=!1},f=()=>Ls.isFocused()&&(e.networkMode==="always"||to.isOnline())&&e.canRun(),u=()=>sl(e.networkMode)&&e.canRun(),d=v=>{var p;r||(r=!0,(p=e.onSuccess)==null||p.call(e,v),o==null||o(),i.resolve(v))},g=v=>{var p;r||(r=!0,(p=e.onError)==null||p.call(e,v),o==null||o(),i.reject(v))},h=()=>new Promise(v=>{var p;o=x=>{(r||f())&&v(x)},(p=e.onPause)==null||p.call(e)}).then(()=>{var v;o=void 0,r||(v=e.onContinue)==null||v.call(e)}),w=()=>{if(r)return;let v;const p=n===0?e.initialPromise:void 0;try{v=p??e.fn()}catch(x){v=Promise.reject(x)}Promise.resolve(v).then(d).catch(x=>{var S;if(r)return;const m=e.retry??(cr?0:3),I=e.retryDelay??Gf,_=typeof I=="function"?I(n,x):I,C=m===!0||typeof m=="number"&&n<m||typeof m=="function"&&m(n,x);if(t||!C){g(x);return}n++,(S=e.onFail)==null||S.call(e,n,x),Hf(_).then(()=>f()?void 0:h()).then(()=>{t?g(x):w()})})};return{promise:i,cancel:s,continue:()=>(o==null||o(),i),cancelRetry:a,continueRetry:c,canStart:u,start:()=>(u()?w():h().then(w),i)}}var Qf=e=>setTimeout(e,0);function Xf(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=Qf;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 Je=Xf(),er,Qc,ll=(Qc=class{constructor(){se(this,er)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ns(this.gcTime)&&G(this,er,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(cr?1/0:5*60*1e3))}clearGcTimeout(){O(this,er)&&(clearTimeout(O(this,er)),G(this,er,void 0))}},er=new WeakMap,Qc),Sr,Nr,Rt,tr,st,mi,nr,$t,fn,Xc,Yf=(Xc=class extends ll{constructor(t){super();se(this,$t);se(this,Sr);se(this,Nr);se(this,Rt);se(this,tr);se(this,st);se(this,mi);se(this,nr);G(this,nr,!1),G(this,mi,t.defaultOptions),this.setOptions(t.options),this.observers=[],G(this,tr,t.client),G(this,Rt,O(this,tr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,G(this,Sr,Zf(this.options)),this.state=t.state??O(this,Sr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=O(this,st))==null?void 0:t.promise}setOptions(t){this.options={...O(this,mi),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&O(this,Rt).remove(this)}setData(t,n){const r=os(this.state.data,t,this.options);return he(this,$t,fn).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){he(this,$t,fn).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=O(this,st))==null?void 0:r.promise;return(o=O(this,st))==null||o.cancel(t),n?n.then(At).catch(At):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(O(this,Sr))}isActive(){return this.observers.some(t=>Ht(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===eo||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||!il(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=O(this,st))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=O(this,st))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),O(this,Rt).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,st)&&(O(this,nr)?O(this,st).cancel({revert:!0}):O(this,st).cancelRetry()),this.scheduleGc()),O(this,Rt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||he(this,$t,fn).call(this,{type:"invalidate"})}fetch(t,n){var c,f,u;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(O(this,st))return O(this,st).continueRetry(),O(this,st).promise}if(t&&this.setOptions(t),!this.options.queryFn){const d=this.observers.find(g=>g.options.queryFn);d&&this.setOptions(d.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=d=>{Object.defineProperty(d,"signal",{enumerable:!0,get:()=>(G(this,nr,!0),r.signal)})},i=()=>{const d=ol(this.options,n),g={client:O(this,tr),queryKey:this.queryKey,meta:this.meta};return o(g),G(this,nr,!1),this.options.persister?this.options.persister(d,g,this):d(g)},s={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:O(this,tr),state:this.state,fetchFn:i};o(s),(c=this.options.behavior)==null||c.onFetch(s,this),G(this,Nr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=s.fetchOptions)==null?void 0:f.meta))&&he(this,$t,fn).call(this,{type:"fetch",meta:(u=s.fetchOptions)==null?void 0:u.meta});const a=d=>{var g,h,w,v;jo(d)&&d.silent||he(this,$t,fn).call(this,{type:"error",error:d}),jo(d)||((h=(g=O(this,Rt).config).onError)==null||h.call(g,d,this),(v=(w=O(this,Rt).config).onSettled)==null||v.call(w,this.state.data,d,this)),this.scheduleGc()};return G(this,st,cl({initialPromise:n==null?void 0:n.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:d=>{var g,h,w,v;if(d===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(d)}catch(p){a(p);return}(h=(g=O(this,Rt).config).onSuccess)==null||h.call(g,d,this),(v=(w=O(this,Rt).config).onSettled)==null||v.call(w,d,this.state.error,this),this.scheduleGc()},onError:a,onFail:(d,g)=>{he(this,$t,fn).call(this,{type:"failed",failureCount:d,error:g})},onPause:()=>{he(this,$t,fn).call(this,{type:"pause"})},onContinue:()=>{he(this,$t,fn).call(this,{type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0})),O(this,st).start()}},Sr=new WeakMap,Nr=new WeakMap,Rt=new WeakMap,tr=new WeakMap,st=new WeakMap,mi=new WeakMap,nr=new WeakMap,$t=new WeakSet,fn=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,...ul(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 jo(o)&&o.revert&&O(this,Nr)?{...O(this,Nr),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),Je.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),O(this,Rt).notify({query:this,type:"updated",action:t})})},Xc);function ul(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:sl(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Zf(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 Zt,Yc,ep=(Yc=class extends Br{constructor(t={}){super();se(this,Zt);this.config=t,G(this,Zt,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??js(o,n);let s=this.get(i);return s||(s=new Yf({client:t,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){O(this,Zt).has(t.queryHash)||(O(this,Zt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=O(this,Zt).get(t.queryHash);n&&(t.destroy(),n===t&&O(this,Zt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Je.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return O(this,Zt).get(t)}getAll(){return[...O(this,Zt).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){Je.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Je.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Je.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Zt=new WeakMap,Yc),en,ct,rr,tn,Nn,Zc,tp=(Zc=class extends ll{constructor(t){super();se(this,tn);se(this,en);se(this,ct);se(this,rr);this.mutationId=t.mutationId,G(this,ct,t.mutationCache),G(this,en,[]),this.state=t.state||dl(),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,en).includes(t)||(O(this,en).push(t),this.clearGcTimeout(),O(this,ct).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){G(this,en,O(this,en).filter(n=>n!==t)),this.scheduleGc(),O(this,ct).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){O(this,en).length||(this.state.status==="pending"?this.scheduleGc():O(this,ct).remove(this))}continue(){var t;return((t=O(this,rr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,s,a,c,f,u,d,g,h,w,v,p,x,m,I,_,C,S,R,N;const n=()=>{he(this,tn,Nn).call(this,{type:"continue"})};G(this,rr,cl({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(A,K)=>{he(this,tn,Nn).call(this,{type:"failed",failureCount:A,error:K})},onPause:()=>{he(this,tn,Nn).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>O(this,ct).canRun(this)}));const r=this.state.status==="pending",o=!O(this,rr).canStart();try{if(r)n();else{he(this,tn,Nn).call(this,{type:"pending",variables:t,isPaused:o}),await((s=(i=O(this,ct).config).onMutate)==null?void 0:s.call(i,t,this));const K=await((c=(a=this.options).onMutate)==null?void 0:c.call(a,t));K!==this.state.context&&he(this,tn,Nn).call(this,{type:"pending",context:K,variables:t,isPaused:o})}const A=await O(this,rr).start();return await((u=(f=O(this,ct).config).onSuccess)==null?void 0:u.call(f,A,t,this.state.context,this)),await((g=(d=this.options).onSuccess)==null?void 0:g.call(d,A,t,this.state.context)),await((w=(h=O(this,ct).config).onSettled)==null?void 0:w.call(h,A,null,this.state.variables,this.state.context,this)),await((p=(v=this.options).onSettled)==null?void 0:p.call(v,A,null,t,this.state.context)),he(this,tn,Nn).call(this,{type:"success",data:A}),A}catch(A){try{throw await((m=(x=O(this,ct).config).onError)==null?void 0:m.call(x,A,t,this.state.context,this)),await((_=(I=this.options).onError)==null?void 0:_.call(I,A,t,this.state.context)),await((S=(C=O(this,ct).config).onSettled)==null?void 0:S.call(C,void 0,A,this.state.variables,this.state.context,this)),await((N=(R=this.options).onSettled)==null?void 0:N.call(R,void 0,A,t,this.state.context)),A}finally{he(this,tn,Nn).call(this,{type:"error",error:A})}}finally{O(this,ct).runNext(this)}}},en=new WeakMap,ct=new WeakMap,rr=new WeakMap,tn=new WeakSet,Nn=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),Je.batch(()=>{O(this,en).forEach(r=>{r.onMutationUpdate(t)}),O(this,ct).notify({mutation:this,type:"updated",action:t})})},Zc);function dl(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var pn,qt,gi,el,np=(el=class extends Br{constructor(t={}){super();se(this,pn);se(this,qt);se(this,gi);this.config=t,G(this,pn,new Set),G(this,qt,new Map),G(this,gi,0)}build(t,n,r){const o=new tp({mutationCache:this,mutationId:++ji(this,gi)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){O(this,pn).add(t);const n=Li(t);if(typeof n=="string"){const r=O(this,qt).get(n);r?r.push(t):O(this,qt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(O(this,pn).delete(t)){const n=Li(t);if(typeof n=="string"){const r=O(this,qt).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,qt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Li(t);if(typeof n=="string"){const r=O(this,qt).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=Li(t);if(typeof n=="string"){const o=(r=O(this,qt).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(){Je.batch(()=>{O(this,pn).forEach(t=>{this.notify({type:"removed",mutation:t})}),O(this,pn).clear(),O(this,qt).clear()})}getAll(){return Array.from(O(this,pn))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Ua(n,r))}findAll(t={}){return this.getAll().filter(n=>Ua(t,n))}notify(t){Je.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Je.batch(()=>Promise.all(t.map(n=>n.continue().catch(At))))}},pn=new WeakMap,qt=new WeakMap,gi=new WeakMap,el);function Li(e){var t;return(t=e.options.scope)==null?void 0:t.id}function Ha(e){return{onFetch:(t,n)=>{var u,d,g,h,w;const r=t.options,o=(g=(d=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:d.fetchMore)==null?void 0:g.direction,i=((h=t.state.data)==null?void 0:h.pages)||[],s=((w=t.state.data)==null?void 0:w.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const f=async()=>{let v=!1;const p=I=>{Object.defineProperty(I,"signal",{enumerable:!0,get:()=>(t.signal.aborted?v=!0:t.signal.addEventListener("abort",()=>{v=!0}),t.signal)})},x=ol(t.options,t.fetchOptions),m=async(I,_,C)=>{if(v)return Promise.reject();if(_==null&&I.pages.length)return Promise.resolve(I);const S={client:t.client,queryKey:t.queryKey,pageParam:_,direction:C?"backward":"forward",meta:t.options.meta};p(S);const R=await x(S),{maxPages:N}=t.options,A=C?Jf:Bf;return{pages:A(I.pages,R,N),pageParams:A(I.pageParams,_,N)}};if(o&&i.length){const I=o==="backward",_=I?rp:Ba,C={pages:i,pageParams:s},S=_(r,C);a=await m(C,S,I)}else{const I=e??i.length;do{const _=c===0?s[0]??r.initialPageParam:Ba(r,a);if(c>0&&_==null)break;a=await m(a,_),c++}while(c<I)}return a};t.options.persister?t.fetchFn=()=>{var v,p;return(p=(v=t.options).persister)==null?void 0:p.call(v,f,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=f}}}function Ba(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 rp(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 ke,An,Pn,Tr,Rr,Fn,Ar,Pr,tl,ip=(tl=class{constructor(e={}){se(this,ke);se(this,An);se(this,Pn);se(this,Tr);se(this,Rr);se(this,Fn);se(this,Ar);se(this,Pr);G(this,ke,e.queryCache||new ep),G(this,An,e.mutationCache||new np),G(this,Pn,e.defaultOptions||{}),G(this,Tr,new Map),G(this,Rr,new Map),G(this,Fn,0)}mount(){ji(this,Fn)._++,O(this,Fn)===1&&(G(this,Ar,Ls.subscribe(async e=>{e&&(await this.resumePausedMutations(),O(this,ke).onFocus())})),G(this,Pr,to.subscribe(async e=>{e&&(await this.resumePausedMutations(),O(this,ke).onOnline())})))}unmount(){var e,t;ji(this,Fn)._--,O(this,Fn)===0&&((e=O(this,Ar))==null||e.call(this),G(this,Ar,void 0),(t=O(this,Pr))==null||t.call(this),G(this,Pr,void 0))}isFetching(e){return O(this,ke).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return O(this,An).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=O(this,ke).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=O(this,ke).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(xr(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return O(this,ke).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,ke).get(r.queryHash),i=o==null?void 0:o.state.data,s=qf(t,i);if(s!==void 0)return O(this,ke).build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return Je.batch(()=>O(this,ke).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,ke).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=O(this,ke);Je.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=O(this,ke);return Je.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Je.batch(()=>O(this,ke).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(At).catch(At)}invalidateQueries(e,t={}){return Je.batch(()=>(O(this,ke).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Je.batch(()=>O(this,ke).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(At)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(At)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=O(this,ke).build(this,t);return n.isStaleByTime(xr(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(At).catch(At)}fetchInfiniteQuery(e){return e.behavior=Ha(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(At).catch(At)}ensureInfiniteQueryData(e){return e.behavior=Ha(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return to.isOnline()?O(this,An).resumePausedMutations():Promise.resolve()}getQueryCache(){return O(this,ke)}getMutationCache(){return O(this,An)}getDefaultOptions(){return O(this,Pn)}setDefaultOptions(e){G(this,Pn,e)}setQueryDefaults(e,t){O(this,Tr).set(lr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...O(this,Tr).values()],n={};return t.forEach(r=>{ai(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){O(this,Rr).set(lr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...O(this,Rr).values()],n={};return t.forEach(r=>{ai(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...O(this,Pn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=js(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===eo&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...O(this,Pn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){O(this,ke).clear(),O(this,An).clear()}},ke=new WeakMap,An=new WeakMap,Pn=new WeakMap,Tr=new WeakMap,Rr=new WeakMap,Fn=new WeakMap,Ar=new WeakMap,Pr=new WeakMap,tl),mt,ve,yi,lt,ir,Fr,Dn,Mn,vi,Dr,Mr,or,sr,kn,kr,Ee,ni,as,cs,ls,us,ds,fs,ps,fl,nl,op=(nl=class extends Br{constructor(t,n){super();se(this,Ee);se(this,mt);se(this,ve);se(this,yi);se(this,lt);se(this,ir);se(this,Fr);se(this,Dn);se(this,Mn);se(this,vi);se(this,Dr);se(this,Mr);se(this,or);se(this,sr);se(this,kn);se(this,kr,new Set);this.options=n,G(this,mt,t),G(this,Mn,null),G(this,Dn,ss()),this.options.experimental_prefetchInRender||O(this,Dn).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,ve).addObserver(this),Ja(O(this,ve),this.options)?he(this,Ee,ni).call(this):this.updateResult(),he(this,Ee,us).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return hs(O(this,ve),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return hs(O(this,ve),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,he(this,Ee,ds).call(this),he(this,Ee,fs).call(this),O(this,ve).removeObserver(this)}setOptions(t){const n=this.options,r=O(this,ve);if(this.options=O(this,mt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ht(this.options.enabled,O(this,ve))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");he(this,Ee,ps).call(this),O(this,ve).setOptions(this.options),n._defaulted&&!Zi(this.options,n)&&O(this,mt).getQueryCache().notify({type:"observerOptionsUpdated",query:O(this,ve),observer:this});const o=this.hasListeners();o&&Wa(O(this,ve),r,this.options,n)&&he(this,Ee,ni).call(this),this.updateResult(),o&&(O(this,ve)!==r||Ht(this.options.enabled,O(this,ve))!==Ht(n.enabled,O(this,ve))||xr(this.options.staleTime,O(this,ve))!==xr(n.staleTime,O(this,ve)))&&he(this,Ee,as).call(this);const i=he(this,Ee,cs).call(this);o&&(O(this,ve)!==r||Ht(this.options.enabled,O(this,ve))!==Ht(n.enabled,O(this,ve))||i!==O(this,kn))&&he(this,Ee,ls).call(this,i)}getOptimisticResult(t){const n=O(this,mt).getQueryCache().build(O(this,mt),t),r=this.createResult(n,t);return ap(this,r)&&(G(this,lt,r),G(this,Fr,this.options),G(this,ir,O(this,ve).state)),r}getCurrentResult(){return O(this,lt)}trackResult(t,n){return new Proxy(t,{get:(r,o)=>(this.trackProp(o),n==null||n(o),Reflect.get(r,o))})}trackProp(t){O(this,kr).add(t)}getCurrentQuery(){return O(this,ve)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=O(this,mt).defaultQueryOptions(t),r=O(this,mt).getQueryCache().build(O(this,mt),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return he(this,Ee,ni).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),O(this,lt)))}createResult(t,n){var A;const r=O(this,ve),o=this.options,i=O(this,lt),s=O(this,ir),a=O(this,Fr),f=t!==r?t.state:O(this,yi),{state:u}=t;let d={...u},g=!1,h;if(n._optimisticResults){const K=this.hasListeners(),z=!K&&Ja(t,n),H=K&&Wa(t,r,n,o);(z||H)&&(d={...d,...ul(u.data,t.options)}),n._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:w,errorUpdatedAt:v,status:p}=d;h=d.data;let x=!1;if(n.placeholderData!==void 0&&h===void 0&&p==="pending"){let K;i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(K=i.data,x=!0):K=typeof n.placeholderData=="function"?n.placeholderData((A=O(this,Mr))==null?void 0:A.state.data,O(this,Mr)):n.placeholderData,K!==void 0&&(p="success",h=os(i==null?void 0:i.data,K,n),g=!0)}if(n.select&&h!==void 0&&!x)if(i&&h===(s==null?void 0:s.data)&&n.select===O(this,vi))h=O(this,Dr);else try{G(this,vi,n.select),h=n.select(h),h=os(i==null?void 0:i.data,h,n),G(this,Dr,h),G(this,Mn,null)}catch(K){G(this,Mn,K)}O(this,Mn)&&(w=O(this,Mn),h=O(this,Dr),v=Date.now(),p="error");const m=d.fetchStatus==="fetching",I=p==="pending",_=p==="error",C=I&&m,S=h!==void 0,N={status:p,fetchStatus:d.fetchStatus,isPending:I,isSuccess:p==="success",isError:_,isInitialLoading:C,isLoading:C,data:h,dataUpdatedAt:d.dataUpdatedAt,error:w,errorUpdatedAt:v,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>f.dataUpdateCount||d.errorUpdateCount>f.errorUpdateCount,isFetching:m,isRefetching:m&&!I,isLoadingError:_&&!S,isPaused:d.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:_&&S,isStale:Ks(t,n),refetch:this.refetch,promise:O(this,Dn)};if(this.options.experimental_prefetchInRender){const K=ee=>{N.status==="error"?ee.reject(N.error):N.data!==void 0&&ee.resolve(N.data)},z=()=>{const ee=G(this,Dn,N.promise=ss());K(ee)},H=O(this,Dn);switch(H.status){case"pending":t.queryHash===r.queryHash&&K(H);break;case"fulfilled":(N.status==="error"||N.data!==H.value)&&z();break;case"rejected":(N.status!=="error"||N.error!==H.reason)&&z();break}}return N}updateResult(){const t=O(this,lt),n=this.createResult(O(this,ve),this.options);if(G(this,ir,O(this,ve).state),G(this,Fr,this.options),O(this,ir).data!==void 0&&G(this,Mr,O(this,ve)),Zi(n,t))return;G(this,lt,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options,i=typeof o=="function"?o():o;if(i==="all"||!i&&!O(this,kr).size)return!0;const s=new Set(i??O(this,kr));return this.options.throwOnError&&s.add("error"),Object.keys(O(this,lt)).some(a=>{const c=a;return O(this,lt)[c]!==t[c]&&s.has(c)})};he(this,Ee,fl).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&he(this,Ee,us).call(this)}},mt=new WeakMap,ve=new WeakMap,yi=new WeakMap,lt=new WeakMap,ir=new WeakMap,Fr=new WeakMap,Dn=new WeakMap,Mn=new WeakMap,vi=new WeakMap,Dr=new WeakMap,Mr=new WeakMap,or=new WeakMap,sr=new WeakMap,kn=new WeakMap,kr=new WeakMap,Ee=new WeakSet,ni=function(t){he(this,Ee,ps).call(this);let n=O(this,ve).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(At)),n},as=function(){he(this,Ee,ds).call(this);const t=xr(this.options.staleTime,O(this,ve));if(cr||O(this,lt).isStale||!ns(t))return;const r=il(O(this,lt).dataUpdatedAt,t)+1;G(this,or,setTimeout(()=>{O(this,lt).isStale||this.updateResult()},r))},cs=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(O(this,ve)):this.options.refetchInterval)??!1},ls=function(t){he(this,Ee,fs).call(this),G(this,kn,t),!(cr||Ht(this.options.enabled,O(this,ve))===!1||!ns(O(this,kn))||O(this,kn)===0)&&G(this,sr,setInterval(()=>{(this.options.refetchIntervalInBackground||Ls.isFocused())&&he(this,Ee,ni).call(this)},O(this,kn)))},us=function(){he(this,Ee,as).call(this),he(this,Ee,ls).call(this,he(this,Ee,cs).call(this))},ds=function(){O(this,or)&&(clearTimeout(O(this,or)),G(this,or,void 0))},fs=function(){O(this,sr)&&(clearInterval(O(this,sr)),G(this,sr,void 0))},ps=function(){const t=O(this,mt).getQueryCache().build(O(this,mt),this.options);if(t===O(this,ve))return;const n=O(this,ve);G(this,ve,t),G(this,yi,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},fl=function(t){Je.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(O(this,lt))}),O(this,mt).getQueryCache().notify({query:O(this,ve),type:"observerResultsUpdated"})})},nl);function sp(e,t){return Ht(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ja(e,t){return sp(e,t)||e.state.data!==void 0&&hs(e,t,t.refetchOnMount)}function hs(e,t,n){if(Ht(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Ks(e,t)}return!1}function Wa(e,t,n,r){return(e!==t||Ht(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Ks(e,n)}function Ks(e,t){return Ht(t.enabled,e)!==!1&&e.isStaleByTime(xr(t.staleTime,e))}function ap(e,t){return!Zi(e.getCurrentResult(),t)}var jn,Ln,gt,hn,gn,zi,ms,rl,cp=(rl=class extends Br{constructor(n,r){super();se(this,gn);se(this,jn);se(this,Ln);se(this,gt);se(this,hn);G(this,jn,n),this.setOptions(r),this.bindMethods(),he(this,gn,zi).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var o;const r=this.options;this.options=O(this,jn).defaultMutationOptions(n),Zi(this.options,r)||O(this,jn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:O(this,gt),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&lr(r.mutationKey)!==lr(this.options.mutationKey)?this.reset():((o=O(this,gt))==null?void 0:o.state.status)==="pending"&&O(this,gt).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=O(this,gt))==null||n.removeObserver(this)}onMutationUpdate(n){he(this,gn,zi).call(this),he(this,gn,ms).call(this,n)}getCurrentResult(){return O(this,Ln)}reset(){var n;(n=O(this,gt))==null||n.removeObserver(this),G(this,gt,void 0),he(this,gn,zi).call(this),he(this,gn,ms).call(this)}mutate(n,r){var o;return G(this,hn,r),(o=O(this,gt))==null||o.removeObserver(this),G(this,gt,O(this,jn).getMutationCache().build(O(this,jn),this.options)),O(this,gt).addObserver(this),O(this,gt).execute(n)}},jn=new WeakMap,Ln=new WeakMap,gt=new WeakMap,hn=new WeakMap,gn=new WeakSet,zi=function(){var r;const n=((r=O(this,gt))==null?void 0:r.state)??dl();G(this,Ln,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},ms=function(n){Je.batch(()=>{var r,o,i,s,a,c,f,u;if(O(this,hn)&&this.hasListeners()){const d=O(this,Ln).variables,g=O(this,Ln).context;(n==null?void 0:n.type)==="success"?((o=(r=O(this,hn)).onSuccess)==null||o.call(r,n.data,d,g),(s=(i=O(this,hn)).onSettled)==null||s.call(i,n.data,null,d,g)):(n==null?void 0:n.type)==="error"&&((c=(a=O(this,hn)).onError)==null||c.call(a,n.error,d,g),(u=(f=O(this,hn)).onSettled)==null||u.call(f,void 0,n.error,d,g))}this.listeners.forEach(d=>{d(O(this,Ln))})})},rl),pl=M.createContext(void 0),vt=e=>{const t=M.useContext(pl);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},lp=({client:e,children:t})=>(M.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),l.jsx(pl.Provider,{value:e,children:t})),hl=M.createContext(!1),up=()=>M.useContext(hl);hl.Provider;function dp(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var fp=M.createContext(dp()),pp=()=>M.useContext(fp);function ml(e,t){return typeof e=="function"?e(...t):!!e}function gs(){}var hp=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},mp=e=>{M.useEffect(()=>{e.clearReset()},[e])},gp=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||ml(n,[e.error,r])),yp=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)))},vp=(e,t)=>e.isLoading&&e.isFetching&&!t,wp=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,za=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ip(e,t,n){var d,g,h,w,v;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=vt(),o=up(),i=pp(),s=r.defaultQueryOptions(e);(g=(d=r.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||g.call(d,s),process.env.NODE_ENV!=="production"&&(s.queryFn||console.error(`[${s.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),s._optimisticResults=o?"isRestoring":"optimistic",yp(s),hp(s,i),mp(i);const a=!r.getQueryCache().get(s.queryHash),[c]=M.useState(()=>new t(r,s)),f=c.getOptimisticResult(s),u=!o&&e.subscribed!==!1;if(M.useSyncExternalStore(M.useCallback(p=>{const x=u?c.subscribe(Je.batchCalls(p)):gs;return c.updateResult(),x},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),M.useEffect(()=>{c.setOptions(s)},[s,c]),wp(s,f))throw za(s,c,i);if(gp({result:f,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw f.error;if((w=(h=r.getDefaultOptions().queries)==null?void 0:h._experimental_afterQuery)==null||w.call(h,s,f),s.experimental_prefetchInRender&&!cr&&vp(f,o)){const p=a?za(s,c,i):(v=r.getQueryCache().get(s.queryHash))==null?void 0:v.promise;p==null||p.catch(gs).finally(()=>{c.updateResult()})}return s.notifyOnChangeProps?f:c.trackResult(f)}function yn(e,t){return Ip(e,op)}function Jr(e,t){const n=vt(),[r]=M.useState(()=>new cp(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);const o=M.useSyncExternalStore(M.useCallback(s=>r.subscribe(Je.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=M.useCallback((s,a)=>{r.mutate(s,a).catch(gs)},[r]);if(o.error&&ml(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:i,mutateAsync:o.mutate}}const gl=y.createContext(null),bp=gl.Provider,yl=()=>{const e=y.useContext(gl);if(e===null)throw new Error("useApiKey must be used within an ApiKeyProvider");return e};var ue=(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))(ue||{});const vl=y.createContext(void 0);function Ft(){const e=y.useContext(vl);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const xp=(()=>{const e={};return Object.values(ue).forEach(t=>{e[t]={}}),e})();function Cp({children:e}){const[t,n]=y.useState(xp),r=y.useCallback((u,d,g=!0)=>{n(h=>{const w={...h};return w[u]=w[u]||{},w[u][d]=g,w})},[n]),o=y.useCallback((u,d)=>{var g;return!!((g=t[u])!=null&&g[d])},[t]),i=y.useCallback((u,d)=>{var g;return(g=t[u])==null?void 0:g[d]},[t]),s=y.useCallback((u,d)=>{n(g=>{var w;const h={...g};return(w=h[u])==null||delete w[d],h})},[n]),a=y.useCallback(u=>{n(d=>{const g={...d};return g[u]={},g})},[n]),c=y.useCallback((u,d)=>{n(g=>{const h={...g};return h[u]=h[u]||{},d.forEach(w=>{h[u][w]=!0}),h})},[n]),f=y.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(vl.Provider,{value:f,children:e})}const _p="https://api.withampersand.com/v1".replace(/\/+$/,"");class Vs{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:_p}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Il}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 Op=new Vs,yo=class yo{constructor(t=Op){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 Np(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?yo.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 wl(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(f=>o[f]===void 0?delete o[f]:{});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:Sp(a.body)||a.body instanceof URLSearchParams||Ep(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}};yo.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let nn=yo;function Ep(e){return typeof Blob<"u"&&e instanceof Blob}function Sp(e){return typeof FormData<"u"&&e instanceof FormData}class wl extends Error{constructor(t,n){super(n),this.response=t,this.name="ResponseError"}}class Np extends Error{constructor(t,n){super(n),this.cause=t,this.name="FetchError"}}class ie extends Error{constructor(t,n){super(n),this.field=t,this.name="RequiredError"}}function T(e,t){const n=e[t];return n!=null}function Il(e,t=""){return Object.keys(e).map(n=>bl(n,e[n],t)).filter(n=>n.length>0).join("&")}function bl(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 bl(e,o,n)}return t instanceof Date?`${encodeURIComponent(r)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Il(t,r):`${encodeURIComponent(r)}=${encodeURIComponent(String(t))}`}function We(e,t){return Object.keys(e).reduce((n,r)=>({...n,[r]:t(e[r])}),{})}class je{constructor(t,n=r=>r){this.raw=t,this.transformer=n}async value(){return this.transformer(await this.raw.json())}}class ur{constructor(t){this.raw=t}async value(){}}class Ga{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function Tp(e){return Rp(e)}function Rp(e,t){return e==null?e:{fieldUsed:T(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:T(e,"keyFormat")?e.keyFormat:void 0}}function Ap(e){return Pp(e)}function Pp(e,t){return e==null?e:{name:e.name,valuePrefix:T(e,"valuePrefix")?e.valuePrefix:void 0}}function Fp(e){return Dp(e)}function Dp(e,t){return e==null?e:{name:e.name}}function Mp(e){return kp(e)}function kp(e,t){return e==null?e:{attachmentType:e.attachmentType,query:T(e,"query")?Fp(e.query):void 0,header:T(e,"header")?Ap(e.header):void 0,docsURL:T(e,"docsURL")?e.docsURL:void 0}}function jp(e){return Lp(e)}function Lp(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0,includeFullRecords:T(e,"includeFullRecords")?e.includeFullRecords:void 0}}function Kp(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,includeFullRecords:e.includeFullRecords}}function Vp(e){return Up(e)}function Up(e,t){return e==null?e:{url:e.url,method:T(e,"method")?e.method:void 0,successStatusCodes:T(e,"successStatusCodes")?e.successStatusCodes:void 0}}const Qa={Oauth2:"oauth2",ApiKey:"apiKey",Basic:"basic",Jwt:"jwt",None:"none"};function $p(e){return qp(e)}function qp(e,t){return e}function Hp(e){return Bp(e)}function Bp(e,t){return e==null?e:{days:T(e,"days")?e.days:void 0,fullHistory:T(e,"fullHistory")?e.fullHistory:void 0}}function Jp(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function xl(e){return Wp(e)}function Wp(e,t){return e==null?e:{defaultPeriod:Hp(e.defaultPeriod)}}function zp(e){if(e!==void 0)return e===null?null:{defaultPeriod:Jp(e.defaultPeriod)}}function Gp(e){return Qp(e)}function Qp(e,t){return e==null?e:{days:T(e,"days")?e.days:void 0,fullHistory:T(e,"fullHistory")?e.fullHistory:void 0}}function Xp(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function Yp(e){return Zp(e)}function Zp(e,t){return e==null?e:{defaultPeriod:Gp(e.defaultPeriod)}}function Cl(e){if(e!==void 0)return e===null?null:{defaultPeriod:Xp(e.defaultPeriod)}}function eh(e){return th(e)}function th(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function _l(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function nh(e){return rh(e)}function rh(e,t){return e}function ih(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:Cl(e.backfill)}}function oh(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:We(e.objects,ih)}}function sh(e){return ah(e)}function ah(e,t){return e==null?e:{stringValue:T(e,"stringValue")?e.stringValue:void 0,integerValue:T(e,"integerValue")?e.integerValue:void 0,booleanValue:T(e,"booleanValue")?e.booleanValue:void 0}}function ch(e){if(e!==void 0)return e===null?null:{stringValue:e.stringValue,integerValue:e.integerValue,booleanValue:e.booleanValue}}function lh(e){return uh(e)}function uh(e,t){return e==null?e:{_default:T(e,"default")?sh(e.default):void 0,writeOnCreate:T(e,"writeOnCreate")?e.writeOnCreate:void 0,writeOnUpdate:T(e,"writeOnUpdate")?e.writeOnUpdate:void 0}}function Ol(e){if(e!==void 0)return e===null?null:{default:ch(e._default),writeOnCreate:e.writeOnCreate,writeOnUpdate:e.writeOnUpdate}}function dh(e){let t=!0;return t=t&&"value"in e,t}function fh(e,t){return e==null?e:{value:e.value,applyOnUpdate:T(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function ph(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function hh(e){let t=!0;return t=t&&"value"in e,t}function mh(e,t){return e==null?e:{value:e.value,applyOnUpdate:T(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function gh(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function yh(e){let t=!0;return t=t&&"value"in e,t}function vh(e,t){return e==null?e:{value:e.value,applyOnUpdate:T(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function wh(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function Ih(e){return bh(e)}function bh(e,t){return e==null?e:{...fh(e),...mh(e),...vh(e)}}function El(e){if(e!==void 0)return e===null?null:dh(e)?ph(e):hh(e)?gh(e):yh(e)?wh(e):{}}function xh(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,selectedValueDefaults:e.selectedValueDefaults===void 0?void 0:We(e.selectedValueDefaults,El),selectedFieldSettings:e.selectedFieldSettings===void 0?void 0:We(e.selectedFieldSettings,Ol)}}function Ch(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:We(e.objects,xh)}}function _h(e){return Oh(e)}function Oh(e,t){return e==null?e:{apiKeyAsBasic:T(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:T(e,"apiKeyAsBasicOpts")?Tp(e.apiKeyAsBasicOpts):void 0,docsURL:T(e,"docsURL")?e.docsURL:void 0}}function Eh(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function Sh(e){return Nh(e)}function Nh(e,t){return e==null?e:{value:e.value}}function Th(e){return Rh(e)}function Rh(e,t){return e==null?e:{brandingRemoval:T(e,"brandingRemoval")?Sh(e.brandingRemoval):void 0}}function Ki(e){return Ah(e)}function Ah(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:T(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0,entitlements:T(e,"entitlements")?Th(e.entitlements):void 0}}function Ph(e){return Fh(e)}function Fh(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function Dh(e){return Mh(e)}function Mh(e,t){return e==null?e:{objectName:e.objectName,schedule:e.schedule,destination:e.destination,selectedFields:e.selectedFields,selectedValueMappings:T(e,"selectedValueMappings")?e.selectedValueMappings:void 0,selectedFieldMappings:e.selectedFieldMappings,selectedFieldsAuto:T(e,"selectedFieldsAuto")?nh(e.selectedFieldsAuto):void 0,backfill:T(e,"backfill")?Yp(e.backfill):void 0}}function kh(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:Cl(e.backfill)}}function jh(e){return Lh(e)}function Lh(e,t){return e==null?e:{objects:We(e.objects,Dh)}}function Kh(e){if(e!==void 0)return e===null?null:{objects:We(e.objects,kh)}}function Vh(e){return Uh(e)}function Uh(e,t){return e==null?e:{objectName:e.objectName,selectedValueDefaults:T(e,"selectedValueDefaults")?We(e.selectedValueDefaults,Ih):void 0,selectedFieldSettings:T(e,"selectedFieldSettings")?We(e.selectedFieldSettings,lh):void 0}}function $h(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,selectedValueDefaults:e.selectedValueDefaults===void 0?void 0:We(e.selectedValueDefaults,El),selectedFieldSettings:e.selectedFieldSettings===void 0?void 0:We(e.selectedFieldSettings,Ol)}}function qh(e){return Hh(e)}function Hh(e,t){return e==null?e:{objects:T(e,"objects")?We(e.objects,Vh):void 0}}function Bh(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:We(e.objects,$h)}}function Jh(e){return Wh(e)}function Wh(e,t){return e==null?e:{provider:e.provider,read:T(e,"read")?jh(e.read):void 0,write:T(e,"write")?qh(e.write):void 0,proxy:T(e,"proxy")?eh(e.proxy):void 0}}function zh(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:Kh(e.read),write:Bh(e.write),proxy:_l(e.proxy)}}function Gh(e){return Qh(e)}function Qh(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:Jh(e.content)}}function Xh(e){return Yh(e)}function Yh(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0}}function Sl(e){return Zh(e)}function Zh(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0}}function em(e){return tm(e)}function tm(e,t){return e==null?e:{token:e.token,issuedAt:T(e,"issuedAt")?new Date(e.issuedAt):void 0,expiresAt:T(e,"expiresAt")?new Date(e.expiresAt):void 0}}function nm(e){return rm(e)}function rm(e,t){return e==null?e:{token:e.token,issuedAt:T(e,"issuedAt")?new Date(e.issuedAt):void 0,expiresAt:T(e,"expiresAt")?new Date(e.expiresAt):void 0}}function im(e){return om(e)}function om(e,t){return e==null?e:{accessToken:T(e,"accessToken")?em(e.accessToken):void 0,refreshToken:T(e,"refreshToken")?nm(e.refreshToken):void 0,scopes:T(e,"scopes")?e.scopes:void 0}}function Gi(e){return sm(e)}function sm(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:T(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:T(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0}}function am(e){return cm(e)}function cm(e,t){return e==null?e:{value:e.value,source:e.source,displayName:T(e,"displayName")?e.displayName:void 0}}function Us(e){if(e!==void 0)return e===null?null:{value:e.value,source:e.source,displayName:e.displayName}}function ri(e){return lm(e)}function lm(e,t){return e==null?e:{id:e.id,projectId:e.projectId,provider:e.provider,providerApp:T(e,"providerApp")?Gi(e.providerApp):void 0,group:Sl(e.group),consumer:Xh(e.consumer),providerWorkspaceRef:T(e,"providerWorkspaceRef")?e.providerWorkspaceRef:void 0,providerConsumerRef:T(e,"providerConsumerRef")?e.providerConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0,authScheme:e.authScheme,status:e.status,oauth2AuthorizationCode:T(e,"oauth2AuthorizationCode")?im(e.oauth2AuthorizationCode):void 0,apiKey:T(e,"apiKey")?e.apiKey:void 0,providerMetadata:T(e,"providerMetadata")?We(e.providerMetadata,am):void 0}}function Nl(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function Tl(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function Rl(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 um(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 dm(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 Al(e){if(e!==void 0)return e===null?null:{accessToken:um(e.accessToken),refreshToken:dm(e.refreshToken),scopes:e.scopes}}function fm(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:We(e.providerMetadata,Us),groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,basicAuth:Nl(e.basicAuth),oauth2ClientCredentials:Tl(e.oauth2ClientCredentials),oauth2PasswordCredentials:Rl(e.oauth2PasswordCredentials),oauth2AuthorizationCode:Al(e.oauth2AuthorizationCode)}}function pm(e){return hm(e)}function hm(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function mm(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function gm(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:zh(e.content)}}function ym(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:gm(e.config)}}function vm(e){return wm(e)}function wm(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function Im(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function bm(e){return xm(e)}function xm(e,t){return e==null?e:{mode:T(e,"mode")?e.mode:void 0,pageSize:T(e,"pageSize")?e.pageSize:void 0}}function Cm(e){if(e!==void 0)return e===null?null:{mode:e.mode,pageSize:e.pageSize}}function _m(e){let t=!0;return t=t&&"fieldName"in e,t}function Om(e,t){return e==null?e:{fieldName:e.fieldName,mapToName:T(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function Em(e){if(e!==void 0)return e===null?null:{fieldName:e.fieldName,mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName}}function Sm(e){let t=!0;return t=t&&"mapToName"in e,t}function Pl(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:T(e,"default")?e.default:void 0,prompt:T(e,"prompt")?e.prompt:void 0}}function Nm(e){if(e!==void 0)return e===null?null:{mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName,default:e._default,prompt:e.prompt}}function Xa(e){return Tm(e)}function Tm(e,t){return e==null?e:{...Om(e),...Pl(e)}}function Ya(e){if(e!==void 0)return e===null?null:_m(e)?Em(e):Sm(e)?Nm(e):{}}function Fl(e){return Rm(e)}function Rm(e,t){return e}function Am(e){return Pm(e)}function Pm(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,mapToName:T(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0,requiredFields:T(e,"requiredFields")?e.requiredFields.map(Xa):void 0,optionalFields:T(e,"optionalFields")?e.optionalFields.map(Xa):void 0,optionalFieldsAuto:T(e,"optionalFieldsAuto")?Fl(e.optionalFieldsAuto):void 0,backfill:T(e,"backfill")?xl(e.backfill):void 0,delivery:T(e,"delivery")?bm(e.delivery):void 0}}function Fm(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(Ya),optionalFields:e.optionalFields===void 0?void 0:e.optionalFields.map(Ya),optionalFieldsAuto:e.optionalFieldsAuto,backfill:zp(e.backfill),delivery:Cm(e.delivery)}}function Dm(e){return Mm(e)}function Mm(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(Am):void 0}}function km(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Fm)}}function jm(e){return Lm(e)}function Lm(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function Km(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Vm(e){return Um(e)}function Um(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0,watchFieldsAuto:T(e,"watchFieldsAuto")?e.watchFieldsAuto:void 0,requiredWatchFields:T(e,"requiredWatchFields")?e.requiredWatchFields:void 0}}function $m(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,watchFieldsAuto:e.watchFieldsAuto,requiredWatchFields:e.requiredWatchFields}}function qm(e){return Hm(e)}function Hm(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,inheritFieldsAndMapping:T(e,"inheritFieldsAndMapping")?e.inheritFieldsAndMapping:void 0,createEvent:T(e,"createEvent")?pm(e.createEvent):void 0,updateEvent:T(e,"updateEvent")?Vm(e.updateEvent):void 0,deleteEvent:T(e,"deleteEvent")?jm(e.deleteEvent):void 0,associationChangeEvent:T(e,"associationChangeEvent")?jp(e.associationChangeEvent):void 0,otherEvents:T(e,"otherEvents")?e.otherEvents:void 0}}function Bm(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,destination:e.destination,inheritFieldsAndMapping:e.inheritFieldsAndMapping,createEvent:mm(e.createEvent),updateEvent:$m(e.updateEvent),deleteEvent:Km(e.deleteEvent),associationChangeEvent:Kp(e.associationChangeEvent),otherEvents:e.otherEvents}}function Jm(e){return Wm(e)}function Wm(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(qm):void 0}}function zm(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Bm)}}function Dl(e){return Gm(e)}function Gm(e,t){return e==null?e:{allowAnyFields:T(e,"allowAnyFields")?e.allowAnyFields:void 0}}function Qm(e){if(e!==void 0)return e===null?null:{allowAnyFields:e.allowAnyFields}}function Xm(e){return Ym(e)}function Ym(e,t){return e==null?e:{objectName:e.objectName,inheritMapping:T(e,"inheritMapping")?e.inheritMapping:void 0,valueDefaults:T(e,"valueDefaults")?Dl(e.valueDefaults):void 0}}function Zm(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,inheritMapping:e.inheritMapping,valueDefaults:Qm(e.valueDefaults)}}function eg(e){return tg(e)}function tg(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(Xm):void 0}}function ng(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Zm)}}function rg(e){return ig(e)}function ig(e,t){return e==null?e:{name:e.name,displayName:T(e,"displayName")?e.displayName:void 0,provider:e.provider,read:T(e,"read")?Dm(e.read):void 0,write:T(e,"write")?eg(e.write):void 0,proxy:T(e,"proxy")?vm(e.proxy):void 0,subscribe:T(e,"subscribe")?Jm(e.subscribe):void 0}}function og(e){if(e!==void 0)return e===null?null:{name:e.name,displayName:e.displayName,provider:e.provider,read:km(e.read),write:ng(e.write),proxy:Im(e.proxy),subscribe:zm(e.subscribe)}}function sg(e){if(e!==void 0)return e===null?null:{specVersion:e.specVersion,content:og(e.content)}}function ag(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:sg(e.latestRevision)}}function cg(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function lg(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 ug(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function dg(e){return fg(e)}function fg(e,t){return e==null?e:{value:e.value,displayValue:e.displayValue}}function pg(e){return hg(e)}function hg(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,valueType:T(e,"valueType")?e.valueType:void 0,providerType:T(e,"providerType")?e.providerType:void 0,readOnly:T(e,"readOnly")?e.readOnly:void 0,values:T(e,"values")?e.values.map(dg):void 0}}function mg(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:We(e.providerMetadata,Us),groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,basicAuth:Nl(e.basicAuth),oauth2ClientCredentials:Tl(e.oauth2ClientCredentials),oauth2PasswordCredentials:Rl(e.oauth2PasswordCredentials),oauth2AuthorizationCode:Al(e.oauth2AuthorizationCode)}}function gg(e){return yg(e)}function yg(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function vg(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,mapToName:T(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function Lo(e){return wg(e)}function wg(e,t){return e==null?e:{...vg(e),...Pl(e)}}function Ig(e){return bg(e)}function bg(e,t){return e==null?e:{error:T(e,"error")?e.error:void 0,objectName:e.objectName,displayName:e.displayName,mapToName:T(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0,destination:e.destination,schedule:e.schedule,requiredFields:T(e,"requiredFields")?e.requiredFields.map(Lo):void 0,optionalFields:T(e,"optionalFields")?e.optionalFields.map(Lo):void 0,optionalFieldsAuto:T(e,"optionalFieldsAuto")?Fl(e.optionalFieldsAuto):void 0,allFields:T(e,"allFields")?e.allFields.map(Lo):void 0,allFieldsMetadata:T(e,"allFieldsMetadata")?We(e.allFieldsMetadata,pg):void 0,backfill:T(e,"backfill")?xl(e.backfill):void 0}}function xg(e){return Cg(e)}function Cg(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(Ig):void 0}}function _g(e){return Og(e)}function Og(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,valueDefaults:T(e,"valueDefaults")?Dl(e.valueDefaults):void 0}}function Eg(e){return Sg(e)}function Sg(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(_g):void 0}}function Ng(e){return Tg(e)}function Tg(e,t){return e==null?e:{name:e.name,displayName:T(e,"displayName")?e.displayName:void 0,provider:e.provider,read:T(e,"read")?xg(e.read):void 0,write:T(e,"write")?Eg(e.write):void 0,proxy:T(e,"proxy")?gg(e.proxy):void 0}}function Rg(e){return Ag(e)}function Ag(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Ng(e.content)}}function Vi(e){return Pg(e)}function Pg(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:T(e,"group")?Sl(e.group):void 0,healthStatus:e.healthStatus,connection:ri(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0,config:Gh(e.config)}}function Fg(e){return Dg(e)}function Dg(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:rg(e.content)}}function Za(e){return Mg(e)}function Mg(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Fg(e.latestRevision)}}function kg(e){return jg(e)}function jg(e,t){return e==null?e:{iconURL:T(e,"iconURL")?e.iconURL:void 0,logoURL:T(e,"logoURL")?e.logoURL:void 0}}function Lg(e){return Kg(e)}function Kg(e,t){return e==null?e:{iconURL:T(e,"iconURL")?e.iconURL:void 0,logoURL:T(e,"logoURL")?e.logoURL:void 0}}function Vg(e){return Ug(e)}function Ug(e,t){return e==null?e:{regular:T(e,"regular")?Lg(e.regular):void 0,darkMode:T(e,"darkMode")?kg(e.darkMode):void 0}}function $g(e){return qg(e)}function qg(e,t){return e==null?e:{name:e.name,displayName:T(e,"displayName")?e.displayName:void 0,docsURL:T(e,"docsURL")?e.docsURL:void 0}}function Hg(e){return Bg(e)}function Bg(e,t){return e==null?e:{name:e.name}}function Jg(e){return Wg(e)}function Wg(e,t){return e==null?e:{create:T(e,"create")?e.create:void 0,update:T(e,"update")?e.update:void 0,_delete:T(e,"delete")?e.delete:void 0,passThrough:T(e,"passThrough")?e.passThrough:void 0}}function Ml(e){return zg(e)}function zg(e,t){return e==null?e:{bulkWrite:Ph(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write,subscribeSupport:T(e,"subscribeSupport")?Jg(e.subscribeSupport):void 0}}function Gg(e){return Qg(e)}function Qg(e,t){return e==null?e:{displayName:e.displayName,baseURL:e.baseURL,support:Ml(e.support)}}function Xg(e){return Yg(e)}function Yg(e,t){return e==null?e:{name:e.name,displayName:e.displayName,path:e.path,capture:T(e,"capture")?e.capture:void 0}}function Zg(e){return ey(e)}function ey(e,t){return e==null?e:{workspaceRefField:T(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:T(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:T(e,"scopesField")?e.scopesField:void 0,otherFields:T(e,"otherFields")?e.otherFields.map(Xg):void 0}}const Ko={AuthorizationCode:"authorizationCode",AuthorizationCodePkce:"authorizationCodePKCE",ClientCredentials:"clientCredentials",Password:"password"};function ty(e){return ny(e)}function ny(e,t){return e==null?e:{grantType:e.grantType,authURL:T(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:T(e,"audience")?e.audience:void 0,tokenMetadataFields:Zg(e.tokenMetadataFields),docsURL:T(e,"docsURL")?e.docsURL:void 0,authURLParams:T(e,"authURLParams")?e.authURLParams:void 0}}function ry(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:We(e.providerMetadata,Us),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 iy(e){return oy(e)}function oy(e,t){return e==null?e:{input:T(e,"input")?e.input.map($g):void 0,postAuthentication:T(e,"postAuthentication")?e.postAuthentication.map(Hg):void 0}}function sy(e){return ay(e)}function ay(e,t){return e==null?e:{subscriptionScope:e.subscriptionScope,targetURLScope:e.targetURLScope,registrationTiming:e.registrationTiming}}function ec(e){return cy(e)}function cy(e,t){return e==null?e:{name:e.name,authType:$p(e.authType),baseURL:e.baseURL,oauth2Opts:T(e,"oauth2Opts")?ty(e.oauth2Opts):void 0,apiKeyOpts:T(e,"apiKeyOpts")?Mp(e.apiKeyOpts):void 0,basicOpts:T(e,"basicOpts")?_h(e.basicOpts):void 0,support:Ml(e.support),providerOpts:e.providerOpts,authHealthCheck:T(e,"authHealthCheck")?Vp(e.authHealthCheck):void 0,displayName:T(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:T(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:T(e,"media")?Vg(e.media):void 0,labels:T(e,"labels")?e.labels:void 0,subscribeOpts:T(e,"subscribeOpts")?sy(e.subscribeOpts):void 0,modules:T(e,"modules")?We(e.modules,Gg):void 0,metadata:T(e,"metadata")?iy(e.metadata):void 0}}function ly(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,connection:fm(e.connection)}}function uy(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:oh(e.read),write:Ch(e.write),proxy:_l(e.proxy)}}function dy(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:uy(e.content)}}function fy(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:dy(e.config)}}function py(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:fy(e.installation)}}function hy(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function my(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:hy(e.project)}}function gy(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 yy(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:gy(e.providerApp)}}class vy extends nn{async deleteConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("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 ur(i)}async deleteConnection(t,n){await this.deleteConnectionRaw(t,n)}async generateConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("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:mg(t.generateConnectionParams)},n);return new je(i,s=>ri(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 ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("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 je(i,s=>ri(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 ie("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 je(i,s=>s.map(ri))}async listConnections(t,n){return await(await this.listConnectionsRaw(t,n)).value()}async updateConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling updateConnection.");if(t.updateConnectionRequest===null||t.updateConnectionRequest===void 0)throw new ie("updateConnectionRequest","Required parameter requestParameters.updateConnectionRequest was null or undefined when calling updateConnection.");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/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"PATCH",headers:o,query:r,body:ly(t.updateConnectionRequest)},n);return new je(i,s=>ri(s))}async updateConnection(t,n){return await(await this.updateConnectionRaw(t,n)).value()}}class wy extends nn{async createInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new ie("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:ym(t.installation)},n);return new je(i,s=>Vi(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 ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new ie("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 ur(i)}async deleteInstallation(t,n){await this.deleteInstallationRaw(t,n)}async getInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new ie("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 je(i,s=>Vi(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 ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("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 je(i,s=>s.map(Vi))}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 ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new ie("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new ie("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:py(t.installationUpdate)},n);return new je(i,s=>Vi(s))}async updateInstallation(t,n){return await(await this.updateInstallationRaw(t,n)).value()}}class Iy extends nn{async batchUpsertIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");if(t.batchUpsertIntegrationsRequest===null||t.batchUpsertIntegrationsRequest===void 0)throw new ie("batchUpsertIntegrationsRequest","Required parameter requestParameters.batchUpsertIntegrationsRequest 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:Eh(t.batchUpsertIntegrationsRequest)},n);return new je(i,s=>s.map(Za))}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 ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new ie("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:ag(t.integration)},n);return new ur(i)}async createIntegration(t,n){await this.createIntegrationRaw(t,n)}async deleteIntegrationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("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 ur(i)}async deleteIntegration(t,n){await this.deleteIntegrationRaw(t,n)}async listIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("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 je(i,s=>s.map(Za))}async listIntegrations(t,n){return await(await this.listIntegrationsRaw(t,n)).value()}}class by extends nn{async oauthConnectRaw(t,n){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new ie("connectOAuthParams","Required parameter requestParameters.connectOAuthParams was null or undefined when calling oauthConnect.");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:"/oauth-connect",method:"POST",headers:o,query:r,body:ry(t.connectOAuthParams)},n);return this.isJsonMime(i.headers.get("content-type"))?new je(i):new Ga(i)}async oauthConnect(t,n){return await(await this.oauthConnectRaw(t,n)).value()}async oauthUpdateRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling oauthUpdate.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling oauthUpdate.");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}:oauth-update".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"PATCH",headers:o,query:r},n);return this.isJsonMime(i.headers.get("content-type"))?new je(i):new Ga(i)}async oauthUpdate(t,n){return await(await this.oauthUpdateRaw(t,n)).value()}}class xy extends nn{async createProjectRaw(t,n){if(t.project===null||t.project===void 0)throw new ie("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:cg(t.project)},n);return new je(i,s=>Ki(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 ie("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 ur(i)}async deleteProject(t,n){await this.deleteProjectRaw(t,n)}async getProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getProject.");const r={};t.includeEntitlements!==void 0&&(r.includeEntitlements=t.includeEntitlements);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}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new je(i,s=>Ki(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 je(o,i=>i.map(Ki))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new ie("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:my(t.projectUpdate)},n);return new je(i,s=>Ki(s))}async updateProject(t,n){return await(await this.updateProjectRaw(t,n)).value()}}class Cy extends nn{async getProviderRaw(t,n){if(t.provider===null||t.provider===void 0)throw new ie("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 je(i,s=>ec(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 je(o,i=>We(i,ec))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class _y extends nn{async createProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new ie("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:lg(t.providerApp)},n);return new je(i,s=>Gi(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 ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new ie("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 ur(i)}async deleteProviderApp(t,n){await this.deleteProviderAppRaw(t,n)}async listProviderAppsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("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 je(i,s=>s.map(Gi))}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 ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new ie("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new ie("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:yy(t.providerAppUpdate)},n);return new je(i,s=>Gi(s))}async updateProviderApp(t,n){return await(await this.updateProviderAppRaw(t,n)).value()}}class Oy extends nn{async createRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");if(t.revision===null||t.revision===void 0)throw new ie("revision","Required parameter requestParameters.revision 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:ug(t.revision)},n);return new ur(i)}async createRevision(t,n){await this.createRevisionRaw(t,n)}async getHydratedRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new ie("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("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 je(i,s=>Rg(s))}async getHydratedRevision(t,n){return await(await this.getHydratedRevisionRaw(t,n)).value()}}class kl{constructor(t){this.connectionApi=new vy(t),this.installationApi=new wy(t),this.integrationApi=new Iy(t),this.oAuthApi=new by(t),this.projectApi=new xy(t),this.providerApi=new Cy(t),this.providerAppApi=new _y(t),this.revisionApi=new Oy(t)}}const jl="2.7.7",Ey="v1",Ui="https://api.withampersand.com";function Ll(){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 Ui;case"mock":return"http://127.0.0.1:4010";case"":return Ui;default:return e??Ui}}catch{return Ui}}const Sy=(e,t)=>`${e}/${t}`;function Ny(){return Sy(Ll(),Ey)}const Ty=Ll(),Kl=Ny(),Ry=new Vs({basePath:Kl,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":jl}});let Ay=new kl(Ry);const $s=()=>Ay;function ut(){const e=yl();return y.useCallback(async()=>{e||console.error("Unable to create API service without API key.");const n=new Vs({basePath:Kl,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":jl,"X-Api-Key":e}});return new kl(n)},[e])}const Py=e=>{const t=ut();return yn({queryKey:["project",e],queryFn:async()=>(await t()).projectApi.getProject({projectIdOrName:e})})},Vl=y.createContext({project:null,appName:"",projectId:"",projectIdOrName:"",isLoading:!0}),Te=()=>{const e=y.useContext(Vl);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function Fy({projectIdOrName:e,children:t}){const{setError:n}=Ft(),{data:r,isLoading:o,isError:i}=Py(e);y.useEffect(()=>{i&&n(ue.PROJECT,e)},[i,e,n]);const s=y.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(Vl.Provider,{value:s,children:t})}function Ul(){const e=ut(),{projectIdOrName:t}=Te();return yn({queryKey:["amp","integrations",t],queryFn:async()=>{if(!t)throw new Error("Project ID or name is required");return(await e()).integrationApi.listIntegrations({projectIdOrName:t})},enabled:!!t})}const Le=async(e,t)=>{var n;if(e instanceof wl){const{status:r,statusText:o}=e.response;console.error(r===500?"Internal Server Error (500):":r===400?"Bad Request (400):":`Error (${r}):`,o);try{const s=await e.response.clone().json(),a=((n=s==null?void 0:s.causes)==null?void 0:n.join(`
1
+ "use strict";var Ka=e=>{throw TypeError(e)};var ko=(e,t,n)=>t.has(e)||Ka("Cannot "+n);var O=(e,t,n)=>(ko(e,t,"read from private field"),n?n.call(e):t.get(e)),se=(e,t,n)=>t.has(e)?Ka("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),G=(e,t,n,r)=>(ko(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),he=(e,t,n)=>(ko(e,t,"access private method"),n);var ji=(e,t,n,r)=>({set _(o){G(e,t,o,n)},get _(){return O(e,t,r)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),y=require("react");require("react-dom");function $f(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 M=$f(y);var Br=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(){}},cr=typeof window>"u"||"Deno"in globalThis;function At(){}function qf(e,t){return typeof e=="function"?e(t):e}function ns(e){return typeof e=="number"&&e>=0&&e!==1/0}function il(e,t){return Math.max(e+(t||0)-Date.now(),0)}function xr(e,t){return typeof e=="function"?e(t):e}function Ht(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!==js(s,t.options))return!1}else if(!ai(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 Ua(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(lr(t.options.mutationKey)!==lr(i))return!1}else if(!ai(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function js(e,t){return((t==null?void 0:t.queryKeyHashFn)||lr)(e)}function lr(e){return JSON.stringify(e,(t,n)=>is(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function ai(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>ai(e[n],t[n])):!1}function rs(e,t){if(e===t)return e;const n=$a(e)&&$a(t);if(n||is(e)&&is(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 f=0;f<s;f++){const u=n?f:i[f];(!n&&r.includes(u)||n)&&e[u]===void 0&&t[u]===void 0?(a[u]=void 0,c++):(a[u]=rs(e[u],t[u]),a[u]===e[u]&&e[u]!==void 0&&c++)}return o===s&&c===o?e:a}return t}function Zi(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 $a(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function is(e){if(!qa(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!qa(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function qa(e){return Object.prototype.toString.call(e)==="[object Object]"}function Hf(e){return new Promise(t=>{setTimeout(t,e)})}function os(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 rs(e,t)}catch(r){throw 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}`),r}return rs(e,t)}return t}function Bf(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Jf(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var eo=Symbol();function ol(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===eo&&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===eo?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Zn,Tn,_r,zc,Wf=(zc=class extends Br{constructor(){super();se(this,Zn);se(this,Tn);se(this,_r);G(this,_r,t=>{if(!cr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){O(this,Tn)||this.setEventListener(O(this,_r))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,Tn))==null||t.call(this),G(this,Tn,void 0))}setEventListener(t){var n;G(this,_r,t),(n=O(this,Tn))==null||n.call(this),G(this,Tn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){O(this,Zn)!==t&&(G(this,Zn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof O(this,Zn)=="boolean"?O(this,Zn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Zn=new WeakMap,Tn=new WeakMap,_r=new WeakMap,zc),Ls=new Wf,Or,Rn,Er,Gc,zf=(Gc=class extends Br{constructor(){super();se(this,Or,!0);se(this,Rn);se(this,Er);G(this,Er,t=>{if(!cr&&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,Rn)||this.setEventListener(O(this,Er))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,Rn))==null||t.call(this),G(this,Rn,void 0))}setEventListener(t){var n;G(this,Er,t),(n=O(this,Rn))==null||n.call(this),G(this,Rn,t(this.setOnline.bind(this)))}setOnline(t){O(this,Or)!==t&&(G(this,Or,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return O(this,Or)}},Or=new WeakMap,Rn=new WeakMap,Er=new WeakMap,Gc),to=new zf;function ss(){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 Gf(e){return Math.min(1e3*2**e,3e4)}function sl(e){return(e??"online")==="online"?to.isOnline():!0}var al=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function jo(e){return e instanceof al}function cl(e){let t=!1,n=0,r=!1,o;const i=ss(),s=v=>{var p;r||(g(new al(v)),(p=e.abort)==null||p.call(e))},a=()=>{t=!0},c=()=>{t=!1},f=()=>Ls.isFocused()&&(e.networkMode==="always"||to.isOnline())&&e.canRun(),u=()=>sl(e.networkMode)&&e.canRun(),d=v=>{var p;r||(r=!0,(p=e.onSuccess)==null||p.call(e,v),o==null||o(),i.resolve(v))},g=v=>{var p;r||(r=!0,(p=e.onError)==null||p.call(e,v),o==null||o(),i.reject(v))},h=()=>new Promise(v=>{var p;o=x=>{(r||f())&&v(x)},(p=e.onPause)==null||p.call(e)}).then(()=>{var v;o=void 0,r||(v=e.onContinue)==null||v.call(e)}),w=()=>{if(r)return;let v;const p=n===0?e.initialPromise:void 0;try{v=p??e.fn()}catch(x){v=Promise.reject(x)}Promise.resolve(v).then(d).catch(x=>{var S;if(r)return;const m=e.retry??(cr?0:3),I=e.retryDelay??Gf,_=typeof I=="function"?I(n,x):I,C=m===!0||typeof m=="number"&&n<m||typeof m=="function"&&m(n,x);if(t||!C){g(x);return}n++,(S=e.onFail)==null||S.call(e,n,x),Hf(_).then(()=>f()?void 0:h()).then(()=>{t?g(x):w()})})};return{promise:i,cancel:s,continue:()=>(o==null||o(),i),cancelRetry:a,continueRetry:c,canStart:u,start:()=>(u()?w():h().then(w),i)}}var Qf=e=>setTimeout(e,0);function Xf(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=Qf;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 Je=Xf(),er,Qc,ll=(Qc=class{constructor(){se(this,er)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ns(this.gcTime)&&G(this,er,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(cr?1/0:5*60*1e3))}clearGcTimeout(){O(this,er)&&(clearTimeout(O(this,er)),G(this,er,void 0))}},er=new WeakMap,Qc),Sr,Nr,Rt,tr,st,mi,nr,$t,fn,Xc,Yf=(Xc=class extends ll{constructor(t){super();se(this,$t);se(this,Sr);se(this,Nr);se(this,Rt);se(this,tr);se(this,st);se(this,mi);se(this,nr);G(this,nr,!1),G(this,mi,t.defaultOptions),this.setOptions(t.options),this.observers=[],G(this,tr,t.client),G(this,Rt,O(this,tr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,G(this,Sr,Zf(this.options)),this.state=t.state??O(this,Sr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=O(this,st))==null?void 0:t.promise}setOptions(t){this.options={...O(this,mi),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&O(this,Rt).remove(this)}setData(t,n){const r=os(this.state.data,t,this.options);return he(this,$t,fn).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){he(this,$t,fn).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=O(this,st))==null?void 0:r.promise;return(o=O(this,st))==null||o.cancel(t),n?n.then(At).catch(At):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(O(this,Sr))}isActive(){return this.observers.some(t=>Ht(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===eo||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||!il(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=O(this,st))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=O(this,st))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),O(this,Rt).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,st)&&(O(this,nr)?O(this,st).cancel({revert:!0}):O(this,st).cancelRetry()),this.scheduleGc()),O(this,Rt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||he(this,$t,fn).call(this,{type:"invalidate"})}fetch(t,n){var c,f,u;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(O(this,st))return O(this,st).continueRetry(),O(this,st).promise}if(t&&this.setOptions(t),!this.options.queryFn){const d=this.observers.find(g=>g.options.queryFn);d&&this.setOptions(d.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=d=>{Object.defineProperty(d,"signal",{enumerable:!0,get:()=>(G(this,nr,!0),r.signal)})},i=()=>{const d=ol(this.options,n),g={client:O(this,tr),queryKey:this.queryKey,meta:this.meta};return o(g),G(this,nr,!1),this.options.persister?this.options.persister(d,g,this):d(g)},s={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:O(this,tr),state:this.state,fetchFn:i};o(s),(c=this.options.behavior)==null||c.onFetch(s,this),G(this,Nr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=s.fetchOptions)==null?void 0:f.meta))&&he(this,$t,fn).call(this,{type:"fetch",meta:(u=s.fetchOptions)==null?void 0:u.meta});const a=d=>{var g,h,w,v;jo(d)&&d.silent||he(this,$t,fn).call(this,{type:"error",error:d}),jo(d)||((h=(g=O(this,Rt).config).onError)==null||h.call(g,d,this),(v=(w=O(this,Rt).config).onSettled)==null||v.call(w,this.state.data,d,this)),this.scheduleGc()};return G(this,st,cl({initialPromise:n==null?void 0:n.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:d=>{var g,h,w,v;if(d===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(d)}catch(p){a(p);return}(h=(g=O(this,Rt).config).onSuccess)==null||h.call(g,d,this),(v=(w=O(this,Rt).config).onSettled)==null||v.call(w,d,this.state.error,this),this.scheduleGc()},onError:a,onFail:(d,g)=>{he(this,$t,fn).call(this,{type:"failed",failureCount:d,error:g})},onPause:()=>{he(this,$t,fn).call(this,{type:"pause"})},onContinue:()=>{he(this,$t,fn).call(this,{type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0})),O(this,st).start()}},Sr=new WeakMap,Nr=new WeakMap,Rt=new WeakMap,tr=new WeakMap,st=new WeakMap,mi=new WeakMap,nr=new WeakMap,$t=new WeakSet,fn=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,...ul(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 jo(o)&&o.revert&&O(this,Nr)?{...O(this,Nr),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),Je.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),O(this,Rt).notify({query:this,type:"updated",action:t})})},Xc);function ul(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:sl(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Zf(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 Zt,Yc,ep=(Yc=class extends Br{constructor(t={}){super();se(this,Zt);this.config=t,G(this,Zt,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??js(o,n);let s=this.get(i);return s||(s=new Yf({client:t,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){O(this,Zt).has(t.queryHash)||(O(this,Zt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=O(this,Zt).get(t.queryHash);n&&(t.destroy(),n===t&&O(this,Zt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Je.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return O(this,Zt).get(t)}getAll(){return[...O(this,Zt).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){Je.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Je.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Je.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Zt=new WeakMap,Yc),en,ct,rr,tn,Nn,Zc,tp=(Zc=class extends ll{constructor(t){super();se(this,tn);se(this,en);se(this,ct);se(this,rr);this.mutationId=t.mutationId,G(this,ct,t.mutationCache),G(this,en,[]),this.state=t.state||dl(),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,en).includes(t)||(O(this,en).push(t),this.clearGcTimeout(),O(this,ct).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){G(this,en,O(this,en).filter(n=>n!==t)),this.scheduleGc(),O(this,ct).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){O(this,en).length||(this.state.status==="pending"?this.scheduleGc():O(this,ct).remove(this))}continue(){var t;return((t=O(this,rr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,s,a,c,f,u,d,g,h,w,v,p,x,m,I,_,C,S,R,N;const n=()=>{he(this,tn,Nn).call(this,{type:"continue"})};G(this,rr,cl({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(A,K)=>{he(this,tn,Nn).call(this,{type:"failed",failureCount:A,error:K})},onPause:()=>{he(this,tn,Nn).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>O(this,ct).canRun(this)}));const r=this.state.status==="pending",o=!O(this,rr).canStart();try{if(r)n();else{he(this,tn,Nn).call(this,{type:"pending",variables:t,isPaused:o}),await((s=(i=O(this,ct).config).onMutate)==null?void 0:s.call(i,t,this));const K=await((c=(a=this.options).onMutate)==null?void 0:c.call(a,t));K!==this.state.context&&he(this,tn,Nn).call(this,{type:"pending",context:K,variables:t,isPaused:o})}const A=await O(this,rr).start();return await((u=(f=O(this,ct).config).onSuccess)==null?void 0:u.call(f,A,t,this.state.context,this)),await((g=(d=this.options).onSuccess)==null?void 0:g.call(d,A,t,this.state.context)),await((w=(h=O(this,ct).config).onSettled)==null?void 0:w.call(h,A,null,this.state.variables,this.state.context,this)),await((p=(v=this.options).onSettled)==null?void 0:p.call(v,A,null,t,this.state.context)),he(this,tn,Nn).call(this,{type:"success",data:A}),A}catch(A){try{throw await((m=(x=O(this,ct).config).onError)==null?void 0:m.call(x,A,t,this.state.context,this)),await((_=(I=this.options).onError)==null?void 0:_.call(I,A,t,this.state.context)),await((S=(C=O(this,ct).config).onSettled)==null?void 0:S.call(C,void 0,A,this.state.variables,this.state.context,this)),await((N=(R=this.options).onSettled)==null?void 0:N.call(R,void 0,A,t,this.state.context)),A}finally{he(this,tn,Nn).call(this,{type:"error",error:A})}}finally{O(this,ct).runNext(this)}}},en=new WeakMap,ct=new WeakMap,rr=new WeakMap,tn=new WeakSet,Nn=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),Je.batch(()=>{O(this,en).forEach(r=>{r.onMutationUpdate(t)}),O(this,ct).notify({mutation:this,type:"updated",action:t})})},Zc);function dl(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var pn,qt,gi,el,np=(el=class extends Br{constructor(t={}){super();se(this,pn);se(this,qt);se(this,gi);this.config=t,G(this,pn,new Set),G(this,qt,new Map),G(this,gi,0)}build(t,n,r){const o=new tp({mutationCache:this,mutationId:++ji(this,gi)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){O(this,pn).add(t);const n=Li(t);if(typeof n=="string"){const r=O(this,qt).get(n);r?r.push(t):O(this,qt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(O(this,pn).delete(t)){const n=Li(t);if(typeof n=="string"){const r=O(this,qt).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,qt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Li(t);if(typeof n=="string"){const r=O(this,qt).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=Li(t);if(typeof n=="string"){const o=(r=O(this,qt).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(){Je.batch(()=>{O(this,pn).forEach(t=>{this.notify({type:"removed",mutation:t})}),O(this,pn).clear(),O(this,qt).clear()})}getAll(){return Array.from(O(this,pn))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Ua(n,r))}findAll(t={}){return this.getAll().filter(n=>Ua(t,n))}notify(t){Je.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Je.batch(()=>Promise.all(t.map(n=>n.continue().catch(At))))}},pn=new WeakMap,qt=new WeakMap,gi=new WeakMap,el);function Li(e){var t;return(t=e.options.scope)==null?void 0:t.id}function Ha(e){return{onFetch:(t,n)=>{var u,d,g,h,w;const r=t.options,o=(g=(d=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:d.fetchMore)==null?void 0:g.direction,i=((h=t.state.data)==null?void 0:h.pages)||[],s=((w=t.state.data)==null?void 0:w.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const f=async()=>{let v=!1;const p=I=>{Object.defineProperty(I,"signal",{enumerable:!0,get:()=>(t.signal.aborted?v=!0:t.signal.addEventListener("abort",()=>{v=!0}),t.signal)})},x=ol(t.options,t.fetchOptions),m=async(I,_,C)=>{if(v)return Promise.reject();if(_==null&&I.pages.length)return Promise.resolve(I);const S={client:t.client,queryKey:t.queryKey,pageParam:_,direction:C?"backward":"forward",meta:t.options.meta};p(S);const R=await x(S),{maxPages:N}=t.options,A=C?Jf:Bf;return{pages:A(I.pages,R,N),pageParams:A(I.pageParams,_,N)}};if(o&&i.length){const I=o==="backward",_=I?rp:Ba,C={pages:i,pageParams:s},S=_(r,C);a=await m(C,S,I)}else{const I=e??i.length;do{const _=c===0?s[0]??r.initialPageParam:Ba(r,a);if(c>0&&_==null)break;a=await m(a,_),c++}while(c<I)}return a};t.options.persister?t.fetchFn=()=>{var v,p;return(p=(v=t.options).persister)==null?void 0:p.call(v,f,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=f}}}function Ba(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 rp(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 ke,An,Pn,Tr,Rr,Fn,Ar,Pr,tl,ip=(tl=class{constructor(e={}){se(this,ke);se(this,An);se(this,Pn);se(this,Tr);se(this,Rr);se(this,Fn);se(this,Ar);se(this,Pr);G(this,ke,e.queryCache||new ep),G(this,An,e.mutationCache||new np),G(this,Pn,e.defaultOptions||{}),G(this,Tr,new Map),G(this,Rr,new Map),G(this,Fn,0)}mount(){ji(this,Fn)._++,O(this,Fn)===1&&(G(this,Ar,Ls.subscribe(async e=>{e&&(await this.resumePausedMutations(),O(this,ke).onFocus())})),G(this,Pr,to.subscribe(async e=>{e&&(await this.resumePausedMutations(),O(this,ke).onOnline())})))}unmount(){var e,t;ji(this,Fn)._--,O(this,Fn)===0&&((e=O(this,Ar))==null||e.call(this),G(this,Ar,void 0),(t=O(this,Pr))==null||t.call(this),G(this,Pr,void 0))}isFetching(e){return O(this,ke).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return O(this,An).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=O(this,ke).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=O(this,ke).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(xr(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return O(this,ke).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,ke).get(r.queryHash),i=o==null?void 0:o.state.data,s=qf(t,i);if(s!==void 0)return O(this,ke).build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return Je.batch(()=>O(this,ke).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,ke).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=O(this,ke);Je.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=O(this,ke);return Je.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Je.batch(()=>O(this,ke).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(At).catch(At)}invalidateQueries(e,t={}){return Je.batch(()=>(O(this,ke).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Je.batch(()=>O(this,ke).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(At)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(At)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=O(this,ke).build(this,t);return n.isStaleByTime(xr(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(At).catch(At)}fetchInfiniteQuery(e){return e.behavior=Ha(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(At).catch(At)}ensureInfiniteQueryData(e){return e.behavior=Ha(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return to.isOnline()?O(this,An).resumePausedMutations():Promise.resolve()}getQueryCache(){return O(this,ke)}getMutationCache(){return O(this,An)}getDefaultOptions(){return O(this,Pn)}setDefaultOptions(e){G(this,Pn,e)}setQueryDefaults(e,t){O(this,Tr).set(lr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...O(this,Tr).values()],n={};return t.forEach(r=>{ai(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){O(this,Rr).set(lr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...O(this,Rr).values()],n={};return t.forEach(r=>{ai(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...O(this,Pn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=js(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===eo&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...O(this,Pn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){O(this,ke).clear(),O(this,An).clear()}},ke=new WeakMap,An=new WeakMap,Pn=new WeakMap,Tr=new WeakMap,Rr=new WeakMap,Fn=new WeakMap,Ar=new WeakMap,Pr=new WeakMap,tl),mt,ve,yi,lt,ir,Fr,Dn,Mn,vi,Dr,Mr,or,sr,kn,kr,Ee,ni,as,cs,ls,us,ds,fs,ps,fl,nl,op=(nl=class extends Br{constructor(t,n){super();se(this,Ee);se(this,mt);se(this,ve);se(this,yi);se(this,lt);se(this,ir);se(this,Fr);se(this,Dn);se(this,Mn);se(this,vi);se(this,Dr);se(this,Mr);se(this,or);se(this,sr);se(this,kn);se(this,kr,new Set);this.options=n,G(this,mt,t),G(this,Mn,null),G(this,Dn,ss()),this.options.experimental_prefetchInRender||O(this,Dn).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,ve).addObserver(this),Ja(O(this,ve),this.options)?he(this,Ee,ni).call(this):this.updateResult(),he(this,Ee,us).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return hs(O(this,ve),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return hs(O(this,ve),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,he(this,Ee,ds).call(this),he(this,Ee,fs).call(this),O(this,ve).removeObserver(this)}setOptions(t){const n=this.options,r=O(this,ve);if(this.options=O(this,mt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ht(this.options.enabled,O(this,ve))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");he(this,Ee,ps).call(this),O(this,ve).setOptions(this.options),n._defaulted&&!Zi(this.options,n)&&O(this,mt).getQueryCache().notify({type:"observerOptionsUpdated",query:O(this,ve),observer:this});const o=this.hasListeners();o&&Wa(O(this,ve),r,this.options,n)&&he(this,Ee,ni).call(this),this.updateResult(),o&&(O(this,ve)!==r||Ht(this.options.enabled,O(this,ve))!==Ht(n.enabled,O(this,ve))||xr(this.options.staleTime,O(this,ve))!==xr(n.staleTime,O(this,ve)))&&he(this,Ee,as).call(this);const i=he(this,Ee,cs).call(this);o&&(O(this,ve)!==r||Ht(this.options.enabled,O(this,ve))!==Ht(n.enabled,O(this,ve))||i!==O(this,kn))&&he(this,Ee,ls).call(this,i)}getOptimisticResult(t){const n=O(this,mt).getQueryCache().build(O(this,mt),t),r=this.createResult(n,t);return ap(this,r)&&(G(this,lt,r),G(this,Fr,this.options),G(this,ir,O(this,ve).state)),r}getCurrentResult(){return O(this,lt)}trackResult(t,n){return new Proxy(t,{get:(r,o)=>(this.trackProp(o),n==null||n(o),Reflect.get(r,o))})}trackProp(t){O(this,kr).add(t)}getCurrentQuery(){return O(this,ve)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=O(this,mt).defaultQueryOptions(t),r=O(this,mt).getQueryCache().build(O(this,mt),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return he(this,Ee,ni).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),O(this,lt)))}createResult(t,n){var A;const r=O(this,ve),o=this.options,i=O(this,lt),s=O(this,ir),a=O(this,Fr),f=t!==r?t.state:O(this,yi),{state:u}=t;let d={...u},g=!1,h;if(n._optimisticResults){const K=this.hasListeners(),z=!K&&Ja(t,n),H=K&&Wa(t,r,n,o);(z||H)&&(d={...d,...ul(u.data,t.options)}),n._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:w,errorUpdatedAt:v,status:p}=d;h=d.data;let x=!1;if(n.placeholderData!==void 0&&h===void 0&&p==="pending"){let K;i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(K=i.data,x=!0):K=typeof n.placeholderData=="function"?n.placeholderData((A=O(this,Mr))==null?void 0:A.state.data,O(this,Mr)):n.placeholderData,K!==void 0&&(p="success",h=os(i==null?void 0:i.data,K,n),g=!0)}if(n.select&&h!==void 0&&!x)if(i&&h===(s==null?void 0:s.data)&&n.select===O(this,vi))h=O(this,Dr);else try{G(this,vi,n.select),h=n.select(h),h=os(i==null?void 0:i.data,h,n),G(this,Dr,h),G(this,Mn,null)}catch(K){G(this,Mn,K)}O(this,Mn)&&(w=O(this,Mn),h=O(this,Dr),v=Date.now(),p="error");const m=d.fetchStatus==="fetching",I=p==="pending",_=p==="error",C=I&&m,S=h!==void 0,N={status:p,fetchStatus:d.fetchStatus,isPending:I,isSuccess:p==="success",isError:_,isInitialLoading:C,isLoading:C,data:h,dataUpdatedAt:d.dataUpdatedAt,error:w,errorUpdatedAt:v,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>f.dataUpdateCount||d.errorUpdateCount>f.errorUpdateCount,isFetching:m,isRefetching:m&&!I,isLoadingError:_&&!S,isPaused:d.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:_&&S,isStale:Ks(t,n),refetch:this.refetch,promise:O(this,Dn)};if(this.options.experimental_prefetchInRender){const K=ee=>{N.status==="error"?ee.reject(N.error):N.data!==void 0&&ee.resolve(N.data)},z=()=>{const ee=G(this,Dn,N.promise=ss());K(ee)},H=O(this,Dn);switch(H.status){case"pending":t.queryHash===r.queryHash&&K(H);break;case"fulfilled":(N.status==="error"||N.data!==H.value)&&z();break;case"rejected":(N.status!=="error"||N.error!==H.reason)&&z();break}}return N}updateResult(){const t=O(this,lt),n=this.createResult(O(this,ve),this.options);if(G(this,ir,O(this,ve).state),G(this,Fr,this.options),O(this,ir).data!==void 0&&G(this,Mr,O(this,ve)),Zi(n,t))return;G(this,lt,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options,i=typeof o=="function"?o():o;if(i==="all"||!i&&!O(this,kr).size)return!0;const s=new Set(i??O(this,kr));return this.options.throwOnError&&s.add("error"),Object.keys(O(this,lt)).some(a=>{const c=a;return O(this,lt)[c]!==t[c]&&s.has(c)})};he(this,Ee,fl).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&he(this,Ee,us).call(this)}},mt=new WeakMap,ve=new WeakMap,yi=new WeakMap,lt=new WeakMap,ir=new WeakMap,Fr=new WeakMap,Dn=new WeakMap,Mn=new WeakMap,vi=new WeakMap,Dr=new WeakMap,Mr=new WeakMap,or=new WeakMap,sr=new WeakMap,kn=new WeakMap,kr=new WeakMap,Ee=new WeakSet,ni=function(t){he(this,Ee,ps).call(this);let n=O(this,ve).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(At)),n},as=function(){he(this,Ee,ds).call(this);const t=xr(this.options.staleTime,O(this,ve));if(cr||O(this,lt).isStale||!ns(t))return;const r=il(O(this,lt).dataUpdatedAt,t)+1;G(this,or,setTimeout(()=>{O(this,lt).isStale||this.updateResult()},r))},cs=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(O(this,ve)):this.options.refetchInterval)??!1},ls=function(t){he(this,Ee,fs).call(this),G(this,kn,t),!(cr||Ht(this.options.enabled,O(this,ve))===!1||!ns(O(this,kn))||O(this,kn)===0)&&G(this,sr,setInterval(()=>{(this.options.refetchIntervalInBackground||Ls.isFocused())&&he(this,Ee,ni).call(this)},O(this,kn)))},us=function(){he(this,Ee,as).call(this),he(this,Ee,ls).call(this,he(this,Ee,cs).call(this))},ds=function(){O(this,or)&&(clearTimeout(O(this,or)),G(this,or,void 0))},fs=function(){O(this,sr)&&(clearInterval(O(this,sr)),G(this,sr,void 0))},ps=function(){const t=O(this,mt).getQueryCache().build(O(this,mt),this.options);if(t===O(this,ve))return;const n=O(this,ve);G(this,ve,t),G(this,yi,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},fl=function(t){Je.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(O(this,lt))}),O(this,mt).getQueryCache().notify({query:O(this,ve),type:"observerResultsUpdated"})})},nl);function sp(e,t){return Ht(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ja(e,t){return sp(e,t)||e.state.data!==void 0&&hs(e,t,t.refetchOnMount)}function hs(e,t,n){if(Ht(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Ks(e,t)}return!1}function Wa(e,t,n,r){return(e!==t||Ht(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Ks(e,n)}function Ks(e,t){return Ht(t.enabled,e)!==!1&&e.isStaleByTime(xr(t.staleTime,e))}function ap(e,t){return!Zi(e.getCurrentResult(),t)}var jn,Ln,gt,hn,gn,zi,ms,rl,cp=(rl=class extends Br{constructor(n,r){super();se(this,gn);se(this,jn);se(this,Ln);se(this,gt);se(this,hn);G(this,jn,n),this.setOptions(r),this.bindMethods(),he(this,gn,zi).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var o;const r=this.options;this.options=O(this,jn).defaultMutationOptions(n),Zi(this.options,r)||O(this,jn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:O(this,gt),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&lr(r.mutationKey)!==lr(this.options.mutationKey)?this.reset():((o=O(this,gt))==null?void 0:o.state.status)==="pending"&&O(this,gt).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=O(this,gt))==null||n.removeObserver(this)}onMutationUpdate(n){he(this,gn,zi).call(this),he(this,gn,ms).call(this,n)}getCurrentResult(){return O(this,Ln)}reset(){var n;(n=O(this,gt))==null||n.removeObserver(this),G(this,gt,void 0),he(this,gn,zi).call(this),he(this,gn,ms).call(this)}mutate(n,r){var o;return G(this,hn,r),(o=O(this,gt))==null||o.removeObserver(this),G(this,gt,O(this,jn).getMutationCache().build(O(this,jn),this.options)),O(this,gt).addObserver(this),O(this,gt).execute(n)}},jn=new WeakMap,Ln=new WeakMap,gt=new WeakMap,hn=new WeakMap,gn=new WeakSet,zi=function(){var r;const n=((r=O(this,gt))==null?void 0:r.state)??dl();G(this,Ln,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},ms=function(n){Je.batch(()=>{var r,o,i,s,a,c,f,u;if(O(this,hn)&&this.hasListeners()){const d=O(this,Ln).variables,g=O(this,Ln).context;(n==null?void 0:n.type)==="success"?((o=(r=O(this,hn)).onSuccess)==null||o.call(r,n.data,d,g),(s=(i=O(this,hn)).onSettled)==null||s.call(i,n.data,null,d,g)):(n==null?void 0:n.type)==="error"&&((c=(a=O(this,hn)).onError)==null||c.call(a,n.error,d,g),(u=(f=O(this,hn)).onSettled)==null||u.call(f,void 0,n.error,d,g))}this.listeners.forEach(d=>{d(O(this,Ln))})})},rl),pl=M.createContext(void 0),vt=e=>{const t=M.useContext(pl);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},lp=({client:e,children:t})=>(M.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),l.jsx(pl.Provider,{value:e,children:t})),hl=M.createContext(!1),up=()=>M.useContext(hl);hl.Provider;function dp(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var fp=M.createContext(dp()),pp=()=>M.useContext(fp);function ml(e,t){return typeof e=="function"?e(...t):!!e}function gs(){}var hp=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},mp=e=>{M.useEffect(()=>{e.clearReset()},[e])},gp=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||ml(n,[e.error,r])),yp=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)))},vp=(e,t)=>e.isLoading&&e.isFetching&&!t,wp=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,za=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ip(e,t,n){var d,g,h,w,v;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=vt(),o=up(),i=pp(),s=r.defaultQueryOptions(e);(g=(d=r.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||g.call(d,s),process.env.NODE_ENV!=="production"&&(s.queryFn||console.error(`[${s.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),s._optimisticResults=o?"isRestoring":"optimistic",yp(s),hp(s,i),mp(i);const a=!r.getQueryCache().get(s.queryHash),[c]=M.useState(()=>new t(r,s)),f=c.getOptimisticResult(s),u=!o&&e.subscribed!==!1;if(M.useSyncExternalStore(M.useCallback(p=>{const x=u?c.subscribe(Je.batchCalls(p)):gs;return c.updateResult(),x},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),M.useEffect(()=>{c.setOptions(s)},[s,c]),wp(s,f))throw za(s,c,i);if(gp({result:f,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw f.error;if((w=(h=r.getDefaultOptions().queries)==null?void 0:h._experimental_afterQuery)==null||w.call(h,s,f),s.experimental_prefetchInRender&&!cr&&vp(f,o)){const p=a?za(s,c,i):(v=r.getQueryCache().get(s.queryHash))==null?void 0:v.promise;p==null||p.catch(gs).finally(()=>{c.updateResult()})}return s.notifyOnChangeProps?f:c.trackResult(f)}function yn(e,t){return Ip(e,op)}function Jr(e,t){const n=vt(),[r]=M.useState(()=>new cp(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);const o=M.useSyncExternalStore(M.useCallback(s=>r.subscribe(Je.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=M.useCallback((s,a)=>{r.mutate(s,a).catch(gs)},[r]);if(o.error&&ml(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:i,mutateAsync:o.mutate}}const gl=y.createContext(null),bp=gl.Provider,yl=()=>{const e=y.useContext(gl);if(e===null)throw new Error("useApiKey must be used within an ApiKeyProvider");return e};var ue=(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))(ue||{});const vl=y.createContext(void 0);function Ft(){const e=y.useContext(vl);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const xp=(()=>{const e={};return Object.values(ue).forEach(t=>{e[t]={}}),e})();function Cp({children:e}){const[t,n]=y.useState(xp),r=y.useCallback((u,d,g=!0)=>{n(h=>{const w={...h};return w[u]=w[u]||{},w[u][d]=g,w})},[n]),o=y.useCallback((u,d)=>{var g;return!!((g=t[u])!=null&&g[d])},[t]),i=y.useCallback((u,d)=>{var g;return(g=t[u])==null?void 0:g[d]},[t]),s=y.useCallback((u,d)=>{n(g=>{var w;const h={...g};return(w=h[u])==null||delete w[d],h})},[n]),a=y.useCallback(u=>{n(d=>{const g={...d};return g[u]={},g})},[n]),c=y.useCallback((u,d)=>{n(g=>{const h={...g};return h[u]=h[u]||{},d.forEach(w=>{h[u][w]=!0}),h})},[n]),f=y.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(vl.Provider,{value:f,children:e})}const _p="https://api.withampersand.com/v1".replace(/\/+$/,"");class Vs{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:_p}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||Il}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 Op=new Vs,yo=class yo{constructor(t=Op){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 Np(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?yo.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 wl(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(f=>o[f]===void 0?delete o[f]:{});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:Sp(a.body)||a.body instanceof URLSearchParams||Ep(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}};yo.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let nn=yo;function Ep(e){return typeof Blob<"u"&&e instanceof Blob}function Sp(e){return typeof FormData<"u"&&e instanceof FormData}class wl extends Error{constructor(t,n){super(n),this.response=t,this.name="ResponseError"}}class Np extends Error{constructor(t,n){super(n),this.cause=t,this.name="FetchError"}}class ie extends Error{constructor(t,n){super(n),this.field=t,this.name="RequiredError"}}function T(e,t){const n=e[t];return n!=null}function Il(e,t=""){return Object.keys(e).map(n=>bl(n,e[n],t)).filter(n=>n.length>0).join("&")}function bl(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 bl(e,o,n)}return t instanceof Date?`${encodeURIComponent(r)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?Il(t,r):`${encodeURIComponent(r)}=${encodeURIComponent(String(t))}`}function We(e,t){return Object.keys(e).reduce((n,r)=>({...n,[r]:t(e[r])}),{})}class je{constructor(t,n=r=>r){this.raw=t,this.transformer=n}async value(){return this.transformer(await this.raw.json())}}class ur{constructor(t){this.raw=t}async value(){}}class Ga{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function Tp(e){return Rp(e)}function Rp(e,t){return e==null?e:{fieldUsed:T(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:T(e,"keyFormat")?e.keyFormat:void 0}}function Ap(e){return Pp(e)}function Pp(e,t){return e==null?e:{name:e.name,valuePrefix:T(e,"valuePrefix")?e.valuePrefix:void 0}}function Fp(e){return Dp(e)}function Dp(e,t){return e==null?e:{name:e.name}}function Mp(e){return kp(e)}function kp(e,t){return e==null?e:{attachmentType:e.attachmentType,query:T(e,"query")?Fp(e.query):void 0,header:T(e,"header")?Ap(e.header):void 0,docsURL:T(e,"docsURL")?e.docsURL:void 0}}function jp(e){return Lp(e)}function Lp(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0,includeFullRecords:T(e,"includeFullRecords")?e.includeFullRecords:void 0}}function Kp(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,includeFullRecords:e.includeFullRecords}}function Vp(e){return Up(e)}function Up(e,t){return e==null?e:{url:e.url,method:T(e,"method")?e.method:void 0,successStatusCodes:T(e,"successStatusCodes")?e.successStatusCodes:void 0}}const Qa={Oauth2:"oauth2",ApiKey:"apiKey",Basic:"basic",Jwt:"jwt",None:"none"};function $p(e){return qp(e)}function qp(e,t){return e}function Hp(e){return Bp(e)}function Bp(e,t){return e==null?e:{days:T(e,"days")?e.days:void 0,fullHistory:T(e,"fullHistory")?e.fullHistory:void 0}}function Jp(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function xl(e){return Wp(e)}function Wp(e,t){return e==null?e:{defaultPeriod:Hp(e.defaultPeriod)}}function zp(e){if(e!==void 0)return e===null?null:{defaultPeriod:Jp(e.defaultPeriod)}}function Gp(e){return Qp(e)}function Qp(e,t){return e==null?e:{days:T(e,"days")?e.days:void 0,fullHistory:T(e,"fullHistory")?e.fullHistory:void 0}}function Xp(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function Yp(e){return Zp(e)}function Zp(e,t){return e==null?e:{defaultPeriod:Gp(e.defaultPeriod)}}function Cl(e){if(e!==void 0)return e===null?null:{defaultPeriod:Xp(e.defaultPeriod)}}function eh(e){return th(e)}function th(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function _l(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function nh(e){return rh(e)}function rh(e,t){return e}function ih(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:Cl(e.backfill)}}function oh(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:We(e.objects,ih)}}function sh(e){return ah(e)}function ah(e,t){return e==null?e:{stringValue:T(e,"stringValue")?e.stringValue:void 0,integerValue:T(e,"integerValue")?e.integerValue:void 0,booleanValue:T(e,"booleanValue")?e.booleanValue:void 0}}function ch(e){if(e!==void 0)return e===null?null:{stringValue:e.stringValue,integerValue:e.integerValue,booleanValue:e.booleanValue}}function lh(e){return uh(e)}function uh(e,t){return e==null?e:{_default:T(e,"default")?sh(e.default):void 0,writeOnCreate:T(e,"writeOnCreate")?e.writeOnCreate:void 0,writeOnUpdate:T(e,"writeOnUpdate")?e.writeOnUpdate:void 0}}function Ol(e){if(e!==void 0)return e===null?null:{default:ch(e._default),writeOnCreate:e.writeOnCreate,writeOnUpdate:e.writeOnUpdate}}function dh(e){let t=!0;return t=t&&"value"in e,t}function fh(e,t){return e==null?e:{value:e.value,applyOnUpdate:T(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function ph(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function hh(e){let t=!0;return t=t&&"value"in e,t}function mh(e,t){return e==null?e:{value:e.value,applyOnUpdate:T(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function gh(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function yh(e){let t=!0;return t=t&&"value"in e,t}function vh(e,t){return e==null?e:{value:e.value,applyOnUpdate:T(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function wh(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function Ih(e){return bh(e)}function bh(e,t){return e==null?e:{...fh(e),...mh(e),...vh(e)}}function El(e){if(e!==void 0)return e===null?null:dh(e)?ph(e):hh(e)?gh(e):yh(e)?wh(e):{}}function xh(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,selectedValueDefaults:e.selectedValueDefaults===void 0?void 0:We(e.selectedValueDefaults,El),selectedFieldSettings:e.selectedFieldSettings===void 0?void 0:We(e.selectedFieldSettings,Ol)}}function Ch(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:We(e.objects,xh)}}function _h(e){return Oh(e)}function Oh(e,t){return e==null?e:{apiKeyAsBasic:T(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:T(e,"apiKeyAsBasicOpts")?Tp(e.apiKeyAsBasicOpts):void 0,docsURL:T(e,"docsURL")?e.docsURL:void 0}}function Eh(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function Sh(e){return Nh(e)}function Nh(e,t){return e==null?e:{value:e.value}}function Th(e){return Rh(e)}function Rh(e,t){return e==null?e:{brandingRemoval:T(e,"brandingRemoval")?Sh(e.brandingRemoval):void 0}}function Ki(e){return Ah(e)}function Ah(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:T(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0,entitlements:T(e,"entitlements")?Th(e.entitlements):void 0}}function Ph(e){return Fh(e)}function Fh(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function Dh(e){return Mh(e)}function Mh(e,t){return e==null?e:{objectName:e.objectName,schedule:e.schedule,destination:e.destination,selectedFields:e.selectedFields,selectedValueMappings:T(e,"selectedValueMappings")?e.selectedValueMappings:void 0,selectedFieldMappings:e.selectedFieldMappings,selectedFieldsAuto:T(e,"selectedFieldsAuto")?nh(e.selectedFieldsAuto):void 0,backfill:T(e,"backfill")?Yp(e.backfill):void 0}}function kh(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:Cl(e.backfill)}}function jh(e){return Lh(e)}function Lh(e,t){return e==null?e:{objects:We(e.objects,Dh)}}function Kh(e){if(e!==void 0)return e===null?null:{objects:We(e.objects,kh)}}function Vh(e){return Uh(e)}function Uh(e,t){return e==null?e:{objectName:e.objectName,selectedValueDefaults:T(e,"selectedValueDefaults")?We(e.selectedValueDefaults,Ih):void 0,selectedFieldSettings:T(e,"selectedFieldSettings")?We(e.selectedFieldSettings,lh):void 0}}function $h(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,selectedValueDefaults:e.selectedValueDefaults===void 0?void 0:We(e.selectedValueDefaults,El),selectedFieldSettings:e.selectedFieldSettings===void 0?void 0:We(e.selectedFieldSettings,Ol)}}function qh(e){return Hh(e)}function Hh(e,t){return e==null?e:{objects:T(e,"objects")?We(e.objects,Vh):void 0}}function Bh(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:We(e.objects,$h)}}function Jh(e){return Wh(e)}function Wh(e,t){return e==null?e:{provider:e.provider,read:T(e,"read")?jh(e.read):void 0,write:T(e,"write")?qh(e.write):void 0,proxy:T(e,"proxy")?eh(e.proxy):void 0}}function zh(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:Kh(e.read),write:Bh(e.write),proxy:_l(e.proxy)}}function Gh(e){return Qh(e)}function Qh(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:Jh(e.content)}}function Xh(e){return Yh(e)}function Yh(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0}}function Sl(e){return Zh(e)}function Zh(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0}}function em(e){return tm(e)}function tm(e,t){return e==null?e:{token:e.token,issuedAt:T(e,"issuedAt")?new Date(e.issuedAt):void 0,expiresAt:T(e,"expiresAt")?new Date(e.expiresAt):void 0}}function nm(e){return rm(e)}function rm(e,t){return e==null?e:{token:e.token,issuedAt:T(e,"issuedAt")?new Date(e.issuedAt):void 0,expiresAt:T(e,"expiresAt")?new Date(e.expiresAt):void 0}}function im(e){return om(e)}function om(e,t){return e==null?e:{accessToken:T(e,"accessToken")?em(e.accessToken):void 0,refreshToken:T(e,"refreshToken")?nm(e.refreshToken):void 0,scopes:T(e,"scopes")?e.scopes:void 0}}function Gi(e){return sm(e)}function sm(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:T(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:T(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0}}function am(e){return cm(e)}function cm(e,t){return e==null?e:{value:e.value,source:e.source,displayName:T(e,"displayName")?e.displayName:void 0}}function Us(e){if(e!==void 0)return e===null?null:{value:e.value,source:e.source,displayName:e.displayName}}function ri(e){return lm(e)}function lm(e,t){return e==null?e:{id:e.id,projectId:e.projectId,provider:e.provider,providerApp:T(e,"providerApp")?Gi(e.providerApp):void 0,group:Sl(e.group),consumer:Xh(e.consumer),providerWorkspaceRef:T(e,"providerWorkspaceRef")?e.providerWorkspaceRef:void 0,providerConsumerRef:T(e,"providerConsumerRef")?e.providerConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0,authScheme:e.authScheme,status:e.status,oauth2AuthorizationCode:T(e,"oauth2AuthorizationCode")?im(e.oauth2AuthorizationCode):void 0,apiKey:T(e,"apiKey")?e.apiKey:void 0,providerMetadata:T(e,"providerMetadata")?We(e.providerMetadata,am):void 0}}function Nl(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function Tl(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function Rl(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 um(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 dm(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 Al(e){if(e!==void 0)return e===null?null:{accessToken:um(e.accessToken),refreshToken:dm(e.refreshToken),scopes:e.scopes}}function fm(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:We(e.providerMetadata,Us),groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,basicAuth:Nl(e.basicAuth),oauth2ClientCredentials:Tl(e.oauth2ClientCredentials),oauth2PasswordCredentials:Rl(e.oauth2PasswordCredentials),oauth2AuthorizationCode:Al(e.oauth2AuthorizationCode)}}function pm(e){return hm(e)}function hm(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function mm(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function gm(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:zh(e.content)}}function ym(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:gm(e.config)}}function vm(e){return wm(e)}function wm(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function Im(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function bm(e){return xm(e)}function xm(e,t){return e==null?e:{mode:T(e,"mode")?e.mode:void 0,pageSize:T(e,"pageSize")?e.pageSize:void 0}}function Cm(e){if(e!==void 0)return e===null?null:{mode:e.mode,pageSize:e.pageSize}}function _m(e){let t=!0;return t=t&&"fieldName"in e,t}function Om(e,t){return e==null?e:{fieldName:e.fieldName,mapToName:T(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function Em(e){if(e!==void 0)return e===null?null:{fieldName:e.fieldName,mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName}}function Sm(e){let t=!0;return t=t&&"mapToName"in e,t}function Pl(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:T(e,"default")?e.default:void 0,prompt:T(e,"prompt")?e.prompt:void 0}}function Nm(e){if(e!==void 0)return e===null?null:{mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName,default:e._default,prompt:e.prompt}}function Xa(e){return Tm(e)}function Tm(e,t){return e==null?e:{...Om(e),...Pl(e)}}function Ya(e){if(e!==void 0)return e===null?null:_m(e)?Em(e):Sm(e)?Nm(e):{}}function Fl(e){return Rm(e)}function Rm(e,t){return e}function Am(e){return Pm(e)}function Pm(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,mapToName:T(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0,requiredFields:T(e,"requiredFields")?e.requiredFields.map(Xa):void 0,optionalFields:T(e,"optionalFields")?e.optionalFields.map(Xa):void 0,optionalFieldsAuto:T(e,"optionalFieldsAuto")?Fl(e.optionalFieldsAuto):void 0,backfill:T(e,"backfill")?xl(e.backfill):void 0,delivery:T(e,"delivery")?bm(e.delivery):void 0}}function Fm(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(Ya),optionalFields:e.optionalFields===void 0?void 0:e.optionalFields.map(Ya),optionalFieldsAuto:e.optionalFieldsAuto,backfill:zp(e.backfill),delivery:Cm(e.delivery)}}function Dm(e){return Mm(e)}function Mm(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(Am):void 0}}function km(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Fm)}}function jm(e){return Lm(e)}function Lm(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function Km(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Vm(e){return Um(e)}function Um(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0,watchFieldsAuto:T(e,"watchFieldsAuto")?e.watchFieldsAuto:void 0,requiredWatchFields:T(e,"requiredWatchFields")?e.requiredWatchFields:void 0}}function $m(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,watchFieldsAuto:e.watchFieldsAuto,requiredWatchFields:e.requiredWatchFields}}function qm(e){return Hm(e)}function Hm(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,inheritFieldsAndMapping:T(e,"inheritFieldsAndMapping")?e.inheritFieldsAndMapping:void 0,createEvent:T(e,"createEvent")?pm(e.createEvent):void 0,updateEvent:T(e,"updateEvent")?Vm(e.updateEvent):void 0,deleteEvent:T(e,"deleteEvent")?jm(e.deleteEvent):void 0,associationChangeEvent:T(e,"associationChangeEvent")?jp(e.associationChangeEvent):void 0,otherEvents:T(e,"otherEvents")?e.otherEvents:void 0}}function Bm(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,destination:e.destination,inheritFieldsAndMapping:e.inheritFieldsAndMapping,createEvent:mm(e.createEvent),updateEvent:$m(e.updateEvent),deleteEvent:Km(e.deleteEvent),associationChangeEvent:Kp(e.associationChangeEvent),otherEvents:e.otherEvents}}function Jm(e){return Wm(e)}function Wm(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(qm):void 0}}function zm(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Bm)}}function Dl(e){return Gm(e)}function Gm(e,t){return e==null?e:{allowAnyFields:T(e,"allowAnyFields")?e.allowAnyFields:void 0}}function Qm(e){if(e!==void 0)return e===null?null:{allowAnyFields:e.allowAnyFields}}function Xm(e){return Ym(e)}function Ym(e,t){return e==null?e:{objectName:e.objectName,inheritMapping:T(e,"inheritMapping")?e.inheritMapping:void 0,valueDefaults:T(e,"valueDefaults")?Dl(e.valueDefaults):void 0}}function Zm(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,inheritMapping:e.inheritMapping,valueDefaults:Qm(e.valueDefaults)}}function eg(e){return tg(e)}function tg(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(Xm):void 0}}function ng(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Zm)}}function rg(e){return ig(e)}function ig(e,t){return e==null?e:{name:e.name,displayName:T(e,"displayName")?e.displayName:void 0,provider:e.provider,read:T(e,"read")?Dm(e.read):void 0,write:T(e,"write")?eg(e.write):void 0,proxy:T(e,"proxy")?vm(e.proxy):void 0,subscribe:T(e,"subscribe")?Jm(e.subscribe):void 0}}function og(e){if(e!==void 0)return e===null?null:{name:e.name,displayName:e.displayName,provider:e.provider,read:km(e.read),write:ng(e.write),proxy:Im(e.proxy),subscribe:zm(e.subscribe)}}function sg(e){if(e!==void 0)return e===null?null:{specVersion:e.specVersion,content:og(e.content)}}function ag(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:sg(e.latestRevision)}}function cg(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function lg(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 ug(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function dg(e){return fg(e)}function fg(e,t){return e==null?e:{value:e.value,displayValue:e.displayValue}}function pg(e){return hg(e)}function hg(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,valueType:T(e,"valueType")?e.valueType:void 0,providerType:T(e,"providerType")?e.providerType:void 0,readOnly:T(e,"readOnly")?e.readOnly:void 0,values:T(e,"values")?e.values.map(dg):void 0}}function mg(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:We(e.providerMetadata,Us),groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,basicAuth:Nl(e.basicAuth),oauth2ClientCredentials:Tl(e.oauth2ClientCredentials),oauth2PasswordCredentials:Rl(e.oauth2PasswordCredentials),oauth2AuthorizationCode:Al(e.oauth2AuthorizationCode)}}function gg(e){return yg(e)}function yg(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function vg(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,mapToName:T(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function Lo(e){return wg(e)}function wg(e,t){return e==null?e:{...vg(e),...Pl(e)}}function Ig(e){return bg(e)}function bg(e,t){return e==null?e:{error:T(e,"error")?e.error:void 0,objectName:e.objectName,displayName:e.displayName,mapToName:T(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0,destination:e.destination,schedule:e.schedule,requiredFields:T(e,"requiredFields")?e.requiredFields.map(Lo):void 0,optionalFields:T(e,"optionalFields")?e.optionalFields.map(Lo):void 0,optionalFieldsAuto:T(e,"optionalFieldsAuto")?Fl(e.optionalFieldsAuto):void 0,allFields:T(e,"allFields")?e.allFields.map(Lo):void 0,allFieldsMetadata:T(e,"allFieldsMetadata")?We(e.allFieldsMetadata,pg):void 0,backfill:T(e,"backfill")?xl(e.backfill):void 0}}function xg(e){return Cg(e)}function Cg(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(Ig):void 0}}function _g(e){return Og(e)}function Og(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,valueDefaults:T(e,"valueDefaults")?Dl(e.valueDefaults):void 0}}function Eg(e){return Sg(e)}function Sg(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(_g):void 0}}function Ng(e){return Tg(e)}function Tg(e,t){return e==null?e:{name:e.name,displayName:T(e,"displayName")?e.displayName:void 0,provider:e.provider,read:T(e,"read")?xg(e.read):void 0,write:T(e,"write")?Eg(e.write):void 0,proxy:T(e,"proxy")?gg(e.proxy):void 0}}function Rg(e){return Ag(e)}function Ag(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Ng(e.content)}}function Vi(e){return Pg(e)}function Pg(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:T(e,"group")?Sl(e.group):void 0,healthStatus:e.healthStatus,connection:ri(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0,config:Gh(e.config)}}function Fg(e){return Dg(e)}function Dg(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:rg(e.content)}}function Za(e){return Mg(e)}function Mg(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Fg(e.latestRevision)}}function kg(e){return jg(e)}function jg(e,t){return e==null?e:{iconURL:T(e,"iconURL")?e.iconURL:void 0,logoURL:T(e,"logoURL")?e.logoURL:void 0}}function Lg(e){return Kg(e)}function Kg(e,t){return e==null?e:{iconURL:T(e,"iconURL")?e.iconURL:void 0,logoURL:T(e,"logoURL")?e.logoURL:void 0}}function Vg(e){return Ug(e)}function Ug(e,t){return e==null?e:{regular:T(e,"regular")?Lg(e.regular):void 0,darkMode:T(e,"darkMode")?kg(e.darkMode):void 0}}function $g(e){return qg(e)}function qg(e,t){return e==null?e:{name:e.name,displayName:T(e,"displayName")?e.displayName:void 0,docsURL:T(e,"docsURL")?e.docsURL:void 0}}function Hg(e){return Bg(e)}function Bg(e,t){return e==null?e:{name:e.name}}function Jg(e){return Wg(e)}function Wg(e,t){return e==null?e:{create:T(e,"create")?e.create:void 0,update:T(e,"update")?e.update:void 0,_delete:T(e,"delete")?e.delete:void 0,passThrough:T(e,"passThrough")?e.passThrough:void 0}}function Ml(e){return zg(e)}function zg(e,t){return e==null?e:{bulkWrite:Ph(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write,subscribeSupport:T(e,"subscribeSupport")?Jg(e.subscribeSupport):void 0}}function Gg(e){return Qg(e)}function Qg(e,t){return e==null?e:{displayName:e.displayName,baseURL:e.baseURL,support:Ml(e.support)}}function Xg(e){return Yg(e)}function Yg(e,t){return e==null?e:{name:e.name,displayName:e.displayName,path:e.path,capture:T(e,"capture")?e.capture:void 0}}function Zg(e){return ey(e)}function ey(e,t){return e==null?e:{workspaceRefField:T(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:T(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:T(e,"scopesField")?e.scopesField:void 0,otherFields:T(e,"otherFields")?e.otherFields.map(Xg):void 0}}const Ko={AuthorizationCode:"authorizationCode",AuthorizationCodePkce:"authorizationCodePKCE",ClientCredentials:"clientCredentials",Password:"password"};function ty(e){return ny(e)}function ny(e,t){return e==null?e:{grantType:e.grantType,authURL:T(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:T(e,"audience")?e.audience:void 0,tokenMetadataFields:Zg(e.tokenMetadataFields),docsURL:T(e,"docsURL")?e.docsURL:void 0,authURLParams:T(e,"authURLParams")?e.authURLParams:void 0}}function ry(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:We(e.providerMetadata,Us),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 iy(e){return oy(e)}function oy(e,t){return e==null?e:{input:T(e,"input")?e.input.map($g):void 0,postAuthentication:T(e,"postAuthentication")?e.postAuthentication.map(Hg):void 0}}function sy(e){return ay(e)}function ay(e,t){return e==null?e:{subscriptionScope:e.subscriptionScope,targetURLScope:e.targetURLScope,registrationTiming:e.registrationTiming}}function ec(e){return cy(e)}function cy(e,t){return e==null?e:{name:e.name,authType:$p(e.authType),baseURL:e.baseURL,oauth2Opts:T(e,"oauth2Opts")?ty(e.oauth2Opts):void 0,apiKeyOpts:T(e,"apiKeyOpts")?Mp(e.apiKeyOpts):void 0,basicOpts:T(e,"basicOpts")?_h(e.basicOpts):void 0,support:Ml(e.support),providerOpts:e.providerOpts,authHealthCheck:T(e,"authHealthCheck")?Vp(e.authHealthCheck):void 0,displayName:T(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:T(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:T(e,"media")?Vg(e.media):void 0,labels:T(e,"labels")?e.labels:void 0,subscribeOpts:T(e,"subscribeOpts")?sy(e.subscribeOpts):void 0,modules:T(e,"modules")?We(e.modules,Gg):void 0,metadata:T(e,"metadata")?iy(e.metadata):void 0}}function ly(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,connection:fm(e.connection)}}function uy(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:oh(e.read),write:Ch(e.write),proxy:_l(e.proxy)}}function dy(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:uy(e.content)}}function fy(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:dy(e.config)}}function py(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:fy(e.installation)}}function hy(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function my(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:hy(e.project)}}function gy(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 yy(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:gy(e.providerApp)}}class vy extends nn{async deleteConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("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 ur(i)}async deleteConnection(t,n){await this.deleteConnectionRaw(t,n)}async generateConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("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:mg(t.generateConnectionParams)},n);return new je(i,s=>ri(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 ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("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 je(i,s=>ri(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 ie("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 je(i,s=>s.map(ri))}async listConnections(t,n){return await(await this.listConnectionsRaw(t,n)).value()}async updateConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling updateConnection.");if(t.updateConnectionRequest===null||t.updateConnectionRequest===void 0)throw new ie("updateConnectionRequest","Required parameter requestParameters.updateConnectionRequest was null or undefined when calling updateConnection.");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/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"PATCH",headers:o,query:r,body:ly(t.updateConnectionRequest)},n);return new je(i,s=>ri(s))}async updateConnection(t,n){return await(await this.updateConnectionRaw(t,n)).value()}}class wy extends nn{async createInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new ie("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:ym(t.installation)},n);return new je(i,s=>Vi(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 ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new ie("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 ur(i)}async deleteInstallation(t,n){await this.deleteInstallationRaw(t,n)}async getInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new ie("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 je(i,s=>Vi(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 ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("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 je(i,s=>s.map(Vi))}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 ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new ie("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new ie("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:py(t.installationUpdate)},n);return new je(i,s=>Vi(s))}async updateInstallation(t,n){return await(await this.updateInstallationRaw(t,n)).value()}}class Iy extends nn{async batchUpsertIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");if(t.batchUpsertIntegrationsRequest===null||t.batchUpsertIntegrationsRequest===void 0)throw new ie("batchUpsertIntegrationsRequest","Required parameter requestParameters.batchUpsertIntegrationsRequest 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:Eh(t.batchUpsertIntegrationsRequest)},n);return new je(i,s=>s.map(Za))}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 ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new ie("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:ag(t.integration)},n);return new ur(i)}async createIntegration(t,n){await this.createIntegrationRaw(t,n)}async deleteIntegrationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("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 ur(i)}async deleteIntegration(t,n){await this.deleteIntegrationRaw(t,n)}async listIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("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 je(i,s=>s.map(Za))}async listIntegrations(t,n){return await(await this.listIntegrationsRaw(t,n)).value()}}class by extends nn{async oauthConnectRaw(t,n){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new ie("connectOAuthParams","Required parameter requestParameters.connectOAuthParams was null or undefined when calling oauthConnect.");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:"/oauth-connect",method:"POST",headers:o,query:r,body:ry(t.connectOAuthParams)},n);return this.isJsonMime(i.headers.get("content-type"))?new je(i):new Ga(i)}async oauthConnect(t,n){return await(await this.oauthConnectRaw(t,n)).value()}async oauthUpdateRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling oauthUpdate.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling oauthUpdate.");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}:oauth-update".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"PATCH",headers:o,query:r},n);return this.isJsonMime(i.headers.get("content-type"))?new je(i):new Ga(i)}async oauthUpdate(t,n){return await(await this.oauthUpdateRaw(t,n)).value()}}class xy extends nn{async createProjectRaw(t,n){if(t.project===null||t.project===void 0)throw new ie("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:cg(t.project)},n);return new je(i,s=>Ki(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 ie("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 ur(i)}async deleteProject(t,n){await this.deleteProjectRaw(t,n)}async getProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getProject.");const r={};t.includeEntitlements!==void 0&&(r.includeEntitlements=t.includeEntitlements);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}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new je(i,s=>Ki(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 je(o,i=>i.map(Ki))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new ie("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:my(t.projectUpdate)},n);return new je(i,s=>Ki(s))}async updateProject(t,n){return await(await this.updateProjectRaw(t,n)).value()}}class Cy extends nn{async getProviderRaw(t,n){if(t.provider===null||t.provider===void 0)throw new ie("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 je(i,s=>ec(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 je(o,i=>We(i,ec))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class _y extends nn{async createProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new ie("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:lg(t.providerApp)},n);return new je(i,s=>Gi(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 ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new ie("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 ur(i)}async deleteProviderApp(t,n){await this.deleteProviderAppRaw(t,n)}async listProviderAppsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("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 je(i,s=>s.map(Gi))}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 ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new ie("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new ie("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:yy(t.providerAppUpdate)},n);return new je(i,s=>Gi(s))}async updateProviderApp(t,n){return await(await this.updateProviderAppRaw(t,n)).value()}}class Oy extends nn{async createRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");if(t.revision===null||t.revision===void 0)throw new ie("revision","Required parameter requestParameters.revision 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:ug(t.revision)},n);return new ur(i)}async createRevision(t,n){await this.createRevisionRaw(t,n)}async getHydratedRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new ie("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("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 je(i,s=>Rg(s))}async getHydratedRevision(t,n){return await(await this.getHydratedRevisionRaw(t,n)).value()}}class kl{constructor(t){this.connectionApi=new vy(t),this.installationApi=new wy(t),this.integrationApi=new Iy(t),this.oAuthApi=new by(t),this.projectApi=new xy(t),this.providerApi=new Cy(t),this.providerAppApi=new _y(t),this.revisionApi=new Oy(t)}}const jl="2.7.8",Ey="v1",Ui="https://api.withampersand.com";function Ll(){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 Ui;case"mock":return"http://127.0.0.1:4010";case"":return Ui;default:return e??Ui}}catch{return Ui}}const Sy=(e,t)=>`${e}/${t}`;function Ny(){return Sy(Ll(),Ey)}const Ty=Ll(),Kl=Ny(),Ry=new Vs({basePath:Kl,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":jl}});let Ay=new kl(Ry);const $s=()=>Ay;function ut(){const e=yl();return y.useCallback(async()=>{e||console.error("Unable to create API service without API key.");const n=new Vs({basePath:Kl,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":jl,"X-Api-Key":e}});return new kl(n)},[e])}const Py=e=>{const t=ut();return yn({queryKey:["project",e],queryFn:async()=>(await t()).projectApi.getProject({projectIdOrName:e})})},Vl=y.createContext({project:null,appName:"",projectId:"",projectIdOrName:"",isLoading:!0}),Te=()=>{const e=y.useContext(Vl);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function Fy({projectIdOrName:e,children:t}){const{setError:n}=Ft(),{data:r,isLoading:o,isError:i}=Py(e);y.useEffect(()=>{i&&n(ue.PROJECT,e)},[i,e,n]);const s=y.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(Vl.Provider,{value:s,children:t})}function Ul(){const e=ut(),{projectIdOrName:t}=Te();return yn({queryKey:["amp","integrations",t],queryFn:async()=>{if(!t)throw new Error("Project ID or name is required");return(await e()).integrationApi.listIntegrations({projectIdOrName:t})},enabled:!!t})}const Le=async(e,t)=>{var n;if(e instanceof wl){const{status:r,statusText:o}=e.response;console.error(r===500?"Internal Server Error (500):":r===400?"Bad Request (400):":`Error (${r}):`,o);try{const s=await e.response.clone().json(),a=((n=s==null?void 0:s.causes)==null?void 0:n.join(`
2
2
  `))||(s==null?void 0:s.detail);a?(console.error("[Error Message]",a),s!=null&&s.remedy&&console.error("[Remedy]",s.remedy)):console.error("Unexpected error response:",s);const c=`${a} ${s!=null&&s.remedy?`
3
3
 
4
4
  [Remedy] ${s.remedy}`:""}`;t&&t(c)}catch(i){console.error("Error parsing error response body:",i)}}else console.error("Unexpected error:",e.message)},$l=y.createContext({integrations:null,isLoading:!0}),qs=()=>{const e=y.useContext($l);if(!e)throw new Error("useIntegrationList must be used within a IntegrationListProvider");return e};function Dy({children:e}){const{projectIdOrName:t}=Te(),{setError:n,removeError:r}=Ft(),{data:o,isLoading:i,isError:s}=Ul();y.useEffect(()=>{s?(Le(s),n(ue.INTEGRATION_LIST,t)):r(ue.INTEGRATION_LIST,t)},[s,t,r,n]);const a=y.useMemo(()=>({integrations:o||null,isLoading:i}),[o,i]);return l.jsx($l.Provider,{value:a,children:e})}const My=new ip;function ky(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(lp,{client:My,children:l.jsx(Cp,{children:l.jsx(bp,{value:t,children:l.jsx(Fy,{projectIdOrName:i,children:l.jsx(Dy,{children:o})})})})})}const ql=y.createContext(null);function jy(){const e=y.useContext(ql);if(!e)throw new Error(`Cannot call useAmpersandProvider unless your
@@ -48,5 +48,5 @@ Valid keys: `+JSON.stringify(Object.keys(P),null," "));var k=de(ne,Q,L,D,te+"."
48
48
  * @copyright ReactTooltip Team
49
49
  * @license MIT
50
50
  */const bI="react-tooltip-core-styles",xI="react-tooltip-base-styles",Nc={core:!1,base:!1};function Tc({css:e,id:t=xI,type:n="base",ref:r}){var o,i;if(!e||typeof document>"u"||Nc[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=bI),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)),Nc[n]=!0}const Rc=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:r="top",offset:o=10,strategy:i="absolute",middlewares:s=[yI(Number(o)),wI({fallbackAxisSideDirection:"start"}),vI({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(II({element:n,padding:5})),Sc(e,t,{placement:r,strategy:i,middleware:c}).then(({x:f,y:u,placement:d,middlewareData:g})=>{var h,w;const v={left:`${f}px`,top:`${u}px`,border:a},{x:p,y:x}=(h=g.arrow)!==null&&h!==void 0?h:{x:0,y:0},m=(w={top:"bottom",right:"left",bottom:"top",left:"right"}[d.split("-")[0]])!==null&&w!==void 0?w:"bottom",I=a&&{borderBottom:a,borderRight:a};let _=0;if(a){const C=`${a}`.match(/(\d+)px/);_=C!=null&&C[1]?Number(C[1]):1}return{tooltipStyles:v,tooltipArrowStyles:{left:p!=null?`${p}px`:"",top:x!=null?`${x}px`:"",right:"",bottom:"",...I,[m]:`-${4+_}px`},place:d}})):Sc(e,t,{placement:"bottom",strategy:i,middleware:c}).then(({x:f,y:u,placement:d})=>({tooltipStyles:{left:`${f}px`,top:`${u}px`},tooltipArrowStyles:{},place:d}))},Ac=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),Pc=(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},Fc=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",Ns=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((o,i)=>Ns(o,t[i]));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!Fc(e)||!Fc(t))return e===t;const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(o=>Ns(e[o],t[o]))},CI=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"})},Dc=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(CI(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},_I=typeof window<"u"?y.useLayoutEffect:y.useEffect,Tt=e=>{e.current&&(clearTimeout(e.current),e.current=null)},OI="DEFAULT_TOOLTIP_ID",EI={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},SI=y.createContext({getTooltipData:()=>EI});function dd(e=OI){return y.useContext(SI).getTooltipData(e)}var Ir={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"},Go={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 NI=({forwardRef:e,id:t,className:n,classNameArrow:r,variant:o="dark",anchorId:i,anchorSelect:s,place:a="top",offset:c=10,events:f=["hover"],openOnClick:u=!1,positionStrategy:d="absolute",middlewares:g,wrapper:h,delayShow:w=0,delayHide:v=0,float:p=!1,hidden:x=!1,noArrow:m=!1,clickable:I=!1,closeOnEsc:_=!1,closeOnScroll:C=!1,closeOnResize:S=!1,openEvents:R,closeEvents:N,globalCloseEvents:A,imperativeModeOnly:K,style:z,position:H,afterShow:ee,afterHide:q,disableTooltip:ae,content:X,contentWrapperRef:Y,isOpen:fe,defaultIsOpen:Ie=!1,setIsOpen:P,activeAnchor:j,setActiveAnchor:$,border:V,opacity:L,arrowColor:D,role:te="tooltip"})=>{var ne;const B=y.useRef(null),re=y.useRef(null),Q=y.useRef(null),de=y.useRef(null),k=y.useRef(null),[we,J]=y.useState({tooltipStyles:{},tooltipArrowStyles:{},place:a}),[Se,Ve]=y.useState(!1),[Ye,Ue]=y.useState(!1),[be,Dt]=y.useState(null),Ze=y.useRef(!1),wt=y.useRef(null),{anchorRefs:Mt,setActiveAnchor:kt}=dd(t),et=y.useRef(!1),[Ge,$e]=y.useState([]),Pe=y.useRef(!1),jt=u||f.includes("click"),dt=jt||(R==null?void 0:R.click)||(R==null?void 0:R.dblclick)||(R==null?void 0:R.mousedown),sn=R?{...R}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!R&&jt&&Object.assign(sn,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const Yt=N?{...N}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!N&&jt&&Object.assign(Yt,{mouseleave:!1,blur:!1,mouseout:!1});const It=A?{...A}:{escape:_||!1,scroll:C||!1,resize:S||!1,clickOutsideAnchor:dt||!1};K&&(Object.assign(sn,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(Yt,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(It,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),_I(()=>(Pe.current=!0,()=>{Pe.current=!1}),[]);const Fe=W=>{Pe.current&&(W&&Ue(!0),setTimeout(()=>{Pe.current&&(P==null||P(W),fe===void 0&&Ve(W))},10))};y.useEffect(()=>{if(fe===void 0)return()=>null;fe&&Ue(!0);const W=setTimeout(()=>{Ve(fe)},10);return()=>{clearTimeout(W)}},[fe]),y.useEffect(()=>{if(Se!==Ze.current)if(Tt(k),Ze.current=Se,Se)ee==null||ee();else{const W=(ce=>{const le=ce.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"));k.current=setTimeout(()=>{Ue(!1),Dt(null),q==null||q()},W+25)}},[Se]);const an=W=>{J(ce=>Ns(ce,W)?ce:W)},bn=(W=w)=>{Tt(Q),Ye?Fe(!0):Q.current=setTimeout(()=>{Fe(!0)},W)},cn=(W=v)=>{Tt(de),de.current=setTimeout(()=>{et.current||Fe(!1)},W)},Bn=W=>{var ce;if(!W)return;const le=(ce=W.currentTarget)!==null&&ce!==void 0?ce:W.target;if(!(le!=null&&le.isConnected))return $(null),void kt({current:null});w?bn():Fe(!0),$(le),kt({current:le}),Tt(de)},ft=()=>{I?cn(v||100):v?cn():Fe(!1),Tt(Q)},ln=({x:W,y:ce})=>{var le;const Ke={getBoundingClientRect:()=>({x:W,y:ce,width:0,height:0,top:ce,left:W,right:W,bottom:ce})};Rc({place:(le=be==null?void 0:be.place)!==null&&le!==void 0?le:a,offset:c,elementReference:Ke,tooltipReference:B.current,tooltipArrowReference:re.current,strategy:d,middlewares:g,border:V}).then(He=>{an(He)})},xn=W=>{if(!W)return;const ce=W,le={x:ce.clientX,y:ce.clientY};ln(le),wt.current=le},Jn=W=>{var ce;if(!Se)return;const le=W.target;le.isConnected&&(!((ce=B.current)===null||ce===void 0)&&ce.contains(le)||[document.querySelector(`[id='${i}']`),...Ge].some(Ke=>Ke==null?void 0:Ke.contains(le))||(Fe(!1),Tt(Q)))},Cn=Pc(Bn,50),Ae=Pc(ft,50),it=W=>{Ae.cancel(),Cn(W)},oe=()=>{Cn.cancel(),Ae()},ge=y.useCallback(()=>{var W,ce;const le=(W=be==null?void 0:be.position)!==null&&W!==void 0?W:H;le?ln(le):p?wt.current&&ln(wt.current):j!=null&&j.isConnected&&Rc({place:(ce=be==null?void 0:be.place)!==null&&ce!==void 0?ce:a,offset:c,elementReference:j,tooltipReference:B.current,tooltipArrowReference:re.current,strategy:d,middlewares:g,border:V}).then(Ke=>{Pe.current&&an(Ke)})},[Se,j,X,z,a,be==null?void 0:be.place,c,d,H,be==null?void 0:be.position,p]);y.useEffect(()=>{var W,ce;const le=new Set(Mt);Ge.forEach(ye=>{ae!=null&&ae(ye)||le.add({current:ye})});const Ke=document.querySelector(`[id='${i}']`);Ke&&!(ae!=null&&ae(Ke))&&le.add({current:Ke});const He=()=>{Fe(!1)},pt=Dc(j),Qe=Dc(B.current);It.scroll&&(window.addEventListener("scroll",He),pt==null||pt.addEventListener("scroll",He),Qe==null||Qe.addEventListener("scroll",He));let tt=null;It.resize?window.addEventListener("resize",He):j&&B.current&&(tt=gI(j,B.current,ge,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const ht=ye=>{ye.key==="Escape"&&Fe(!1)};It.escape&&window.addEventListener("keydown",ht),It.clickOutsideAnchor&&window.addEventListener("click",Jn);const Ne=[],_n=ye=>!!(ye!=null&&ye.target&&(j!=null&&j.contains(ye.target))),Fo=ye=>{Se&&_n(ye)||Bn(ye)},Lt=ye=>{Se&&_n(ye)&&ft()},Ei=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],Si=["click","dblclick","mousedown","mouseup"];Object.entries(sn).forEach(([ye,Kt])=>{Kt&&(Ei.includes(ye)?Ne.push({event:ye,listener:it}):Si.includes(ye)&&Ne.push({event:ye,listener:Fo}))}),Object.entries(Yt).forEach(([ye,Kt])=>{Kt&&(Ei.includes(ye)?Ne.push({event:ye,listener:oe}):Si.includes(ye)&&Ne.push({event:ye,listener:Lt}))}),p&&Ne.push({event:"pointermove",listener:xn});const Ni=()=>{et.current=!0},Ti=()=>{et.current=!1,ft()},Ri=I&&(Yt.mouseout||Yt.mouseleave);return Ri&&((W=B.current)===null||W===void 0||W.addEventListener("mouseover",Ni),(ce=B.current)===null||ce===void 0||ce.addEventListener("mouseout",Ti)),Ne.forEach(({event:ye,listener:Kt})=>{le.forEach(Xr=>{var Wn;(Wn=Xr.current)===null||Wn===void 0||Wn.addEventListener(ye,Kt)})}),()=>{var ye,Kt;It.scroll&&(window.removeEventListener("scroll",He),pt==null||pt.removeEventListener("scroll",He),Qe==null||Qe.removeEventListener("scroll",He)),It.resize?window.removeEventListener("resize",He):tt==null||tt(),It.clickOutsideAnchor&&window.removeEventListener("click",Jn),It.escape&&window.removeEventListener("keydown",ht),Ri&&((ye=B.current)===null||ye===void 0||ye.removeEventListener("mouseover",Ni),(Kt=B.current)===null||Kt===void 0||Kt.removeEventListener("mouseout",Ti)),Ne.forEach(({event:Xr,listener:Wn})=>{le.forEach(Do=>{var Yr;(Yr=Do.current)===null||Yr===void 0||Yr.removeEventListener(Xr,Wn)})})}},[j,ge,Ye,Mt,Ge,R,N,A,jt,w,v]),y.useEffect(()=>{var W,ce;let le=(ce=(W=be==null?void 0:be.anchorSelect)!==null&&W!==void 0?W:s)!==null&&ce!==void 0?ce:"";!le&&t&&(le=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const Ke=new MutationObserver(He=>{const pt=[],Qe=[];He.forEach(tt=>{if(tt.type==="attributes"&&tt.attributeName==="data-tooltip-id"&&(tt.target.getAttribute("data-tooltip-id")===t?pt.push(tt.target):tt.oldValue===t&&Qe.push(tt.target)),tt.type==="childList"){if(j){const ht=[...tt.removedNodes].filter(Ne=>Ne.nodeType===1);if(le)try{Qe.push(...ht.filter(Ne=>Ne.matches(le))),Qe.push(...ht.flatMap(Ne=>[...Ne.querySelectorAll(le)]))}catch{}ht.some(Ne=>{var _n;return!!(!((_n=Ne==null?void 0:Ne.contains)===null||_n===void 0)&&_n.call(Ne,j))&&(Ue(!1),Fe(!1),$(null),Tt(Q),Tt(de),!0)})}if(le)try{const ht=[...tt.addedNodes].filter(Ne=>Ne.nodeType===1);pt.push(...ht.filter(Ne=>Ne.matches(le))),pt.push(...ht.flatMap(Ne=>[...Ne.querySelectorAll(le)]))}catch{}}}),(pt.length||Qe.length)&&$e(tt=>[...tt.filter(ht=>!Qe.includes(ht)),...pt])});return Ke.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{Ke.disconnect()}},[t,s,be==null?void 0:be.anchorSelect,j]),y.useEffect(()=>{ge()},[ge]),y.useEffect(()=>{if(!(Y!=null&&Y.current))return()=>null;const W=new ResizeObserver(()=>{setTimeout(()=>ge())});return W.observe(Y.current),()=>{W.disconnect()}},[X,Y==null?void 0:Y.current]),y.useEffect(()=>{var W;const ce=document.querySelector(`[id='${i}']`),le=[...Ge,ce];j&&le.includes(j)||$((W=Ge[0])!==null&&W!==void 0?W:ce)},[i,Ge,j]),y.useEffect(()=>(Ie&&Fe(!0),()=>{Tt(Q),Tt(de)}),[]),y.useEffect(()=>{var W;let ce=(W=be==null?void 0:be.anchorSelect)!==null&&W!==void 0?W:s;if(!ce&&t&&(ce=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),ce)try{const le=Array.from(document.querySelectorAll(ce));$e(le)}catch{$e([])}},[t,s,be==null?void 0:be.anchorSelect]),y.useEffect(()=>{Q.current&&(Tt(Q),bn(w))},[w]);const qe=(ne=be==null?void 0:be.content)!==null&&ne!==void 0?ne:X,un=Se&&Object.keys(we.tooltipStyles).length>0;return y.useImperativeHandle(e,()=>({open:W=>{if(W!=null&&W.anchorSelect)try{document.querySelector(W.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${W.anchorSelect}" is not a valid CSS selector`)}Dt(W??null),W!=null&&W.delay?bn(W.delay):Fe(!0)},close:W=>{W!=null&&W.delay?cn(W.delay):Fe(!1)},activeAnchor:j,place:we.place,isOpen:!!(Ye&&!x&&qe&&un)})),Ye&&!x&&qe?y.createElement(h,{id:t,role:te,className:Pt("react-tooltip",Ir.tooltip,Go.tooltip,Go[o],n,`react-tooltip__place-${we.place}`,Ir[un?"show":"closing"],un?"react-tooltip__show":"react-tooltip__closing",d==="fixed"&&Ir.fixed,I&&Ir.clickable),onTransitionEnd:W=>{Tt(k),Se||W.propertyName!=="opacity"||(Ue(!1),Dt(null),q==null||q())},style:{...z,...we.tooltipStyles,opacity:L!==void 0&&un?L:void 0},ref:B},qe,y.createElement(h,{className:Pt("react-tooltip-arrow",Ir.arrow,Go.arrow,r,m&&Ir.noArrow),style:{...we.tooltipArrowStyles,background:D?`linear-gradient(to right bottom, transparent 50%, ${D} 50%)`:void 0},ref:re})):null},TI=({content:e})=>y.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),RI=y.forwardRef(({id:e,anchorId:t,anchorSelect:n,content:r,html:o,render:i,className:s,classNameArrow:a,variant:c="dark",place:f="top",offset:u=10,wrapper:d="div",children:g=null,events:h=["hover"],openOnClick:w=!1,positionStrategy:v="absolute",middlewares:p,delayShow:x=0,delayHide:m=0,float:I=!1,hidden:_=!1,noArrow:C=!1,clickable:S=!1,closeOnEsc:R=!1,closeOnScroll:N=!1,closeOnResize:A=!1,openEvents:K,closeEvents:z,globalCloseEvents:H,imperativeModeOnly:ee=!1,style:q,position:ae,isOpen:X,defaultIsOpen:Y=!1,disableStyleInjection:fe=!1,border:Ie,opacity:P,arrowColor:j,setIsOpen:$,afterShow:V,afterHide:L,disableTooltip:D,role:te="tooltip"},ne)=>{const[B,re]=y.useState(r),[Q,de]=y.useState(o),[k,we]=y.useState(f),[J,Se]=y.useState(c),[Ve,Ye]=y.useState(u),[Ue,be]=y.useState(x),[Dt,Ze]=y.useState(m),[wt,Mt]=y.useState(I),[kt,et]=y.useState(_),[Ge,$e]=y.useState(d),[Pe,jt]=y.useState(h),[dt,sn]=y.useState(v),[Yt,It]=y.useState(null),[Fe,an]=y.useState(null),bn=y.useRef(fe),{anchorRefs:cn,activeAnchor:Bn}=dd(e),ft=Ae=>Ae==null?void 0:Ae.getAttributeNames().reduce((it,oe)=>{var ge;return oe.startsWith("data-tooltip-")&&(it[oe.replace(/^data-tooltip-/,"")]=(ge=Ae==null?void 0:Ae.getAttribute(oe))!==null&&ge!==void 0?ge:null),it},{}),ln=Ae=>{const it={place:oe=>{var ge;we((ge=oe)!==null&&ge!==void 0?ge:f)},content:oe=>{re(oe??r)},html:oe=>{de(oe??o)},variant:oe=>{var ge;Se((ge=oe)!==null&&ge!==void 0?ge:c)},offset:oe=>{Ye(oe===null?u:Number(oe))},wrapper:oe=>{var ge;$e((ge=oe)!==null&&ge!==void 0?ge:d)},events:oe=>{const ge=oe==null?void 0:oe.split(" ");jt(ge??h)},"position-strategy":oe=>{var ge;sn((ge=oe)!==null&&ge!==void 0?ge:v)},"delay-show":oe=>{be(oe===null?x:Number(oe))},"delay-hide":oe=>{Ze(oe===null?m:Number(oe))},float:oe=>{Mt(oe===null?I:oe==="true")},hidden:oe=>{et(oe===null?_:oe==="true")},"class-name":oe=>{It(oe)}};Object.values(it).forEach(oe=>oe(null)),Object.entries(Ae).forEach(([oe,ge])=>{var qe;(qe=it[oe])===null||qe===void 0||qe.call(it,ge)})};y.useEffect(()=>{re(r)},[r]),y.useEffect(()=>{de(o)},[o]),y.useEffect(()=>{we(f)},[f]),y.useEffect(()=>{Se(c)},[c]),y.useEffect(()=>{Ye(u)},[u]),y.useEffect(()=>{be(x)},[x]),y.useEffect(()=>{Ze(m)},[m]),y.useEffect(()=>{Mt(I)},[I]),y.useEffect(()=>{et(_)},[_]),y.useEffect(()=>{sn(v)},[v]),y.useEffect(()=>{bn.current!==fe&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")},[fe]),y.useEffect(()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:fe==="core",disableBase:fe}}))},[]),y.useEffect(()=>{var Ae;const it=new Set(cn);let oe=n;if(!oe&&e&&(oe=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),oe)try{document.querySelectorAll(oe).forEach(ce=>{it.add({current:ce})})}catch{console.warn(`[react-tooltip] "${oe}" is not a valid CSS selector`)}const ge=document.querySelector(`[id='${t}']`);if(ge&&it.add({current:ge}),!it.size)return()=>null;const qe=(Ae=Fe??ge)!==null&&Ae!==void 0?Ae:Bn.current,un=new MutationObserver(ce=>{ce.forEach(le=>{var Ke;if(!qe||le.type!=="attributes"||!(!((Ke=le.attributeName)===null||Ke===void 0)&&Ke.startsWith("data-tooltip-")))return;const He=ft(qe);ln(He)})}),W={attributes:!0,childList:!1,subtree:!1};if(qe){const ce=ft(qe);ln(ce),un.observe(qe,W)}return()=>{un.disconnect()}},[cn,Bn,Fe,t,n]),y.useEffect(()=>{q!=null&&q.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),Ie&&!Ac("border",`${Ie}`)&&console.warn(`[react-tooltip] "${Ie}" is not a valid \`border\`.`),q!=null&&q.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),P&&!Ac("opacity",`${P}`)&&console.warn(`[react-tooltip] "${P}" is not a valid \`opacity\`.`)},[]);let xn=g;const Jn=y.useRef(null);if(i){const Ae=i({content:(Fe==null?void 0:Fe.getAttribute("data-tooltip-content"))||B||null,activeAnchor:Fe});xn=Ae?y.createElement("div",{ref:Jn,className:"react-tooltip-content-wrapper"},Ae):null}else B&&(xn=B);Q&&(xn=y.createElement(TI,{content:Q}));const Cn={forwardRef:ne,id:e,anchorId:t,anchorSelect:n,className:Pt(s,Yt),classNameArrow:a,content:xn,contentWrapperRef:Jn,place:k,variant:J,offset:Ve,wrapper:Ge,events:Pe,openOnClick:w,positionStrategy:dt,middlewares:p,delayShow:Ue,delayHide:Dt,float:wt,hidden:kt,noArrow:C,clickable:S,closeOnEsc:R,closeOnScroll:N,closeOnResize:A,openEvents:K,closeEvents:z,globalCloseEvents:H,imperativeModeOnly:ee,style:q,position:ae,isOpen:X,defaultIsOpen:Y,border:Ie,opacity:P,arrowColor:j,setIsOpen:$,afterShow:V,afterHide:L,disableTooltip:D,activeAnchor:Fe,setActiveAnchor:Ae=>an(Ae),role:te};return y.createElement(NI,{...Cn})});typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",e=>{e.detail.disableCore||Tc({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||Tc({css:`
51
- .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 AI(){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 PI({id:e,tooltipText:t}){return l.jsxs(l.Fragment,{children:[l.jsx("span",{"data-tooltip-id":e,style:{maxWidth:"20rem"},children:AI()}),l.jsx(RI,{id:e,place:"top",content:t,style:{maxWidth:"30rem"}})]})}const fd=y.createContext(null);function pd(){const e=y.useContext(fd);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}const hd=y.createContext(()=>{});function FI(){const e=y.useContext(hd);if(!e)throw new Error("useSetNextTabIndex must be used within a NextTabIndexProvider");return{onNextIncompleteTab:e}}var md=Symbol.for("immer-nothing"),Mc=Symbol.for("immer-draftable"),_t=Symbol.for("immer-state"),DI=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function yt(e,...t){if(process.env.NODE_ENV!=="production"){const n=DI[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var $r=Object.getPrototypeOf;function qr(e){return!!e&&!!e[_t]}function hr(e){var t;return e?gd(e)||Array.isArray(e)||!!e[Mc]||!!((t=e.constructor)!=null&&t[Mc])||Co(e)||_o(e):!1}var MI=Object.prototype.constructor.toString();function gd(e){if(!e||typeof e!="object")return!1;const t=$r(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===MI}function fo(e,t){xo(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function xo(e){const t=e[_t];return t?t.type_:Array.isArray(e)?1:Co(e)?2:_o(e)?3:0}function Ts(e,t){return xo(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function yd(e,t,n){const r=xo(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function kI(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Co(e){return e instanceof Map}function _o(e){return e instanceof Set}function Xn(e){return e.copy_||e.base_}function Rs(e,t){if(Co(e))return new Map(e);if(_o(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=gd(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[_t];let o=Reflect.ownKeys(r);for(let i=0;i<o.length;i++){const s=o[i],a=r[s];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[s]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[s]})}return Object.create($r(e),r)}else{const r=$r(e);if(r!==null&&n)return{...e};const o=Object.create(r);return Object.assign(o,e)}}function ma(e,t=!1){return Oo(e)||qr(e)||!hr(e)||(xo(e)>1&&(e.set=e.add=e.clear=e.delete=jI),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>ma(r,!0))),e}function jI(){yt(2)}function Oo(e){return Object.isFrozen(e)}var LI={};function mr(e){const t=LI[e];return t||yt(0,e),t}var ui;function vd(){return ui}function KI(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function kc(e,t){t&&(mr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function As(e){Ps(e),e.drafts_.forEach(VI),e.drafts_=null}function Ps(e){e===ui&&(ui=e.parent_)}function jc(e){return ui=KI(ui,e)}function VI(e){const t=e[_t];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Lc(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[_t].modified_&&(As(t),yt(4)),hr(e)&&(e=po(t,e),t.parent_||ho(t,e)),t.patches_&&mr("Patches").generateReplacementPatches_(n[_t].base_,e,t.patches_,t.inversePatches_)):e=po(t,n,[]),As(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==md?e:void 0}function po(e,t,n){if(Oo(t))return t;const r=t[_t];if(!r)return fo(t,(o,i)=>Kc(e,r,t,o,i,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return ho(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const o=r.copy_;let i=o,s=!1;r.type_===3&&(i=new Set(o),o.clear(),s=!0),fo(i,(a,c)=>Kc(e,r,o,a,c,n,s)),ho(e,o,!1),n&&e.patches_&&mr("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Kc(e,t,n,r,o,i,s){if(process.env.NODE_ENV!=="production"&&o===n&&yt(5),qr(o)){const a=i&&t&&t.type_!==3&&!Ts(t.assigned_,r)?i.concat(r):void 0,c=po(e,o,a);if(yd(n,r,c),qr(c))e.canAutoFreeze_=!1;else return}else s&&n.add(o);if(hr(o)&&!Oo(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;po(e,o),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&ho(e,o)}}function ho(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ma(t,n)}function UI(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:vd(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,i=ga;n&&(o=[r],i=di);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,a}var ga={get(e,t){if(t===_t)return e;const n=Xn(e);if(!Ts(n,t))return $I(e,n,t);const r=n[t];return e.finalized_||!hr(r)?r:r===Qo(e.base_,t)?(Xo(e),e.copy_[t]=Ds(r,e)):r},has(e,t){return t in Xn(e)},ownKeys(e){return Reflect.ownKeys(Xn(e))},set(e,t,n){const r=wd(Xn(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const o=Qo(Xn(e),t),i=o==null?void 0:o[_t];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(kI(n,o)&&(n!==void 0||Ts(e.base_,t)))return!0;Xo(e),Fs(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Qo(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Xo(e),Fs(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Xn(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){yt(11)},getPrototypeOf(e){return $r(e.base_)},setPrototypeOf(){yt(12)}},di={};fo(ga,(e,t)=>{di[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});di.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&yt(13),di.set.call(this,e,t,void 0)};di.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&yt(14),ga.set.call(this,e[0],t,n,e[0])};function Qo(e,t){const n=e[_t];return(n?Xn(n):e)[t]}function $I(e,t,n){var o;const r=wd(t,n);return r?"value"in r?r.value:(o=r.get)==null?void 0:o.call(e.draft_):void 0}function wd(e,t){if(!(t in e))return;let n=$r(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=$r(n)}}function Fs(e){e.modified_||(e.modified_=!0,e.parent_&&Fs(e.parent_))}function Xo(e){e.copy_||(e.copy_=Rs(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var qI=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const s=this;return function(c=i,...f){return s.produce(c,u=>n.call(this,u,...f))}}typeof n!="function"&&yt(6),r!==void 0&&typeof r!="function"&&yt(7);let o;if(hr(t)){const i=jc(this),s=Ds(t,void 0);let a=!0;try{o=n(s),a=!1}finally{a?As(i):Ps(i)}return kc(i,r),Lc(o,i)}else if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===md&&(o=void 0),this.autoFreeze_&&ma(o,!0),r){const i=[],s=[];mr("Patches").generateReplacementPatches_(t,o,i,s),r(i,s)}return o}else yt(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,c=>t(c,...a));let r,o;return[this.produce(t,n,(s,a)=>{r=s,o=a}),r,o]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){hr(e)||yt(8),qr(e)&&(e=HI(e));const t=jc(this),n=Ds(e,void 0);return n[_t].isManual_=!0,Ps(t),n}finishDraft(e,t){const n=e&&e[_t];(!n||!n.isManual_)&&yt(9);const{scope_:r}=n;return kc(r,t),Lc(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));const r=mr("Patches").applyPatches_;return qr(e)?r(e,t):this.produce(e,o=>r(o,t))}};function Ds(e,t){const n=Co(e)?mr("MapSet").proxyMap_(e,t):_o(e)?mr("MapSet").proxySet_(e,t):UI(e,t);return(t?t.scope_:vd()).drafts_.push(n),n}function HI(e){return qr(e)||yt(10,e),Id(e)}function Id(e){if(!hr(e)||Oo(e))return e;const t=e[_t];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Rs(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Rs(e,!0);return fo(n,(r,o)=>{yd(n,r,Id(o))}),t&&(t.finalized_=!1),n}var Ot=new qI,ti=Ot.produce;Ot.produceWithPatches.bind(Ot);Ot.setAutoFreeze.bind(Ot);Ot.setUseStrictShallowCopy.bind(Ot);Ot.applyPatches.bind(Ot);Ot.createDraft.bind(Ot);Ot.finishDraft.bind(Ot);const bd=y.createContext(void 0),BI={};function ya(){const e=y.useContext(bd);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function JI({children:e}){const{installation:t}=rt(),{hydratedRevision:n,loading:r}=Gr(),[o,i]=y.useState(BI),s=t==null?void 0:t.config;y.useEffect(()=>{n!=null&&n.content&&!r&&s&&!(Object.entries(o).length>0)&&pv(n,s,i)},[n,r,s,o]);const a=y.useCallback((h,w)=>{i(v=>ti(v,p=>{p[h]=ti(p[h],w)}))},[i]),c=y.useCallback((h,w)=>{i(v=>ti(v,p=>{p[h]=w}))},[i]),f=y.useCallback(()=>{i(ti(h=>{const w=h.other.write;w&&(w.isWriteModified=!1)}))},[i]),u=y.useCallback(h=>{i(ti(w=>{var p;const v=(p=w[h])==null?void 0:p.read;v&&(v.isOptionalFieldsModified=!1,v.isRequiredMapFieldsModified=!1,v.isValueMappingsModified=!1)}))},[i]),d=y.useCallback(h=>{h===dr?f():u(h)},[u,f]),g=y.useMemo(()=>({objectConfigurationsState:o,setObjectConfigurationsState:i,setConfigureState:a,resetConfigureState:c,resetPendingConfigurationState:d}),[o,c,d,a]);return l.jsx(bd.Provider,{value:g,children:e})}const Xt=()=>{const{appName:e}=Te(),{objectConfigurationsState:t,setConfigureState:n}=ya(),{selectedObjectName:r}=pd(),o=du(r||"",t);return{appName:e,configureState:o,setConfigureState:n,selectedObjectName:r}};function WI(e,t){var r;const n=((r=e==null?void 0:e.read)==null?void 0:r.selectedFieldMappings)||{};if(t.forEach(o=>{const{field:i,value:s}=o;s===null?delete n[i]:n[i]=s}),e!=null&&e.read){const o=e.read.savedConfig.requiredMapFields,s=!ou(o,n);e.read.isRequiredMapFieldsModified=s}}function fi(e,t,n){t(e,r=>WI(r,n))}const zI="Each field must be mapped to a unique value";function va({field:e,onSelectChange:t,allFields:n}){var m;const{configureState:r,selectedObjectName:o,setConfigureState:i}=Xt(),[s,a]=y.useState(!0),{isError:c,removeError:f,getError:u}=Ft(),d=(m=r==null?void 0:r.read)==null?void 0:m.selectedFieldMappings,g=d==null?void 0:d[e.mapToName];y.useEffect(()=>{e._default&&!g&&o&&r&&fi(o,i,[{field:e.mapToName,value:e._default}]),a(!1)},[e,i,o,g,r]);const h=y.useMemo(()=>n.map(I=>({id:I.fieldName,label:I.displayName,value:I.fieldName})),[n]),w=l.jsx(td,{disabled:s,items:h,selectedValue:g||null,onSelectedItemChange:I=>{t({target:{name:e.mapToName,value:I==null?void 0:I.value}})},placeholder:"Please select one",style:{width:"100%"}}),v=y.useCallback(()=>{o&&(fi(o,i,[{field:e.mapToName,value:null}]),c(ue.MAPPING,o)&&f(ue.MAPPING,o))},[e.mapToName,o,i,c,f]),{hasDuplicationError:p,errorMessage:x}=y.useMemo(()=>{const I=u(ue.MAPPING,o),_=Array.isArray(I)&&I.length>0&&I.includes(e.mapToName);return{hasDuplicationError:_,errorMessage:_?zI:""}},[o,u,e.mapToName]);return l.jsxs(l.Fragment,{children:[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??e.mapToName}),l.jsx("span",{children:(e==null?void 0:e.prompt)&&l.jsx(PI,{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:[w,l.jsx(ze,{type:"button",variant:"ghost",onClick:v,children:"Clear"})]})]},e.mapToName),p&&l.jsxs("span",{style:{color:"red",fontSize:"14px",marginTop:"4px"},children:[" ",x," "]},e.mapToName)]})}const GI="_formControl_9qd8d_1",QI="_formLabel_9qd8d_5",XI="_formLabelRequired_9qd8d_11",YI="_formInput_9qd8d_16",ZI="_formInputInvalid_9qd8d_20",eb="_formError_9qd8d_24",tb="_disabled_9qd8d_30",Qn={formControl:GI,formLabel:QI,formLabelRequired:XI,formInput:YI,formInputInvalid:ZI,formError:eb,disabled:tb};function Eo({id:e,label:t,isRequired:n=!1,isDisabled:r=!1,isInvalid:o=!1,errorMessage:i,children:s}){return l.jsxs("div",{className:Pt(Qn.formControl,{[Qn.disabled]:r}),children:[t&&l.jsx("label",{htmlFor:e,className:Pt(Qn.formLabel,{[Qn.formLabelRequired]:n}),children:t}),l.jsx("div",{id:e,className:Pt(Qn.formInput,{[Qn.formInputInvalid]:o}),children:s}),o&&i&&l.jsx("div",{className:Qn.formError,role:"alert",children:i})]})}const nb="_divider_1kmoj_1",Vc={divider:nb};function So({className:e,style:t}){return l.jsx("hr",{className:e?`${Vc.divider} ${e}`:Vc.divider,style:t})}function Et({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(So,{style:{width:"100%",marginLeft:"1rem"}})})]})}function xd({selectedFieldMappings:e,selectedObjectName:t,fieldName:n,fieldValue:r,setError:o}){if(!e||!t)return!1;if(Object.values(e).some(s=>s===r&&s!==n)){console.error("Each field must be mapped to a unique value",e);const s=Object.keys(e).filter(c=>e[c]===r),a=[n,...s];return o(ue.MAPPING,t,a),!0}return!1}function rb({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(Eo,{id:r.mapToName,children:l.jsx(va,{allFields:n,field:r,onSelectChange:t})},r.mapToName))}):null}function ib(){var w,v;const{selectedObjectName:e,configureState:t,setConfigureState:n}=Xt(),{isError:r,removeError:o,setError:i}=Ft(),s=((w=t==null?void 0:t.read)==null?void 0:w.allFields)||[],{fieldMapping:a}=rt(),c=(v=t==null?void 0:t.read)==null?void 0:v.selectedFieldMappings,f=p=>{const{value:x,name:m}=p.target;!x||xd({selectedFieldMappings:c,selectedObjectName:e,fieldName:m,fieldValue:x,setError:i})||(e&&fi(e,n,[{field:m,value:x}]),r(ue.MAPPING,m)&&o(ue.MAPPING,m),e&&r(ue.MAPPING,e)&&o(ue.MAPPING,e))},u=y.useMemo(()=>!e||!a?[]:Object.values(a[e]||{}).flat().filter(p=>!p.fieldName),[a,e]),d=y.useMemo(()=>{var m;return(((m=t==null?void 0:t.read)==null?void 0:m.optionalMapFields)||[]).filter(I=>!u.some(_=>_.mapToName===I.mapToName))},[t,u]),g=u.length>0;return d.length>0||g?l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Map the following optional fields"}),l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:[d==null?void 0:d.map(p=>l.jsx(Eo,{id:p.mapToName,children:l.jsx(va,{allFields:s,field:p,onSelectChange:f})},p.mapToName)),g&&l.jsx(rb,{dynamicFieldMappings:u,onSelectChange:f,allFields:s})]})]}):null}function ob(){var f;const{selectedObjectName:e,configureState:t,setConfigureState:n}=Xt(),{isError:r,removeError:o,setError:i}=Ft(),s=(f=t==null?void 0:t.read)==null?void 0:f.selectedFieldMappings,a=u=>{const{value:d,name:g}=u.target;!d||xd({selectedFieldMappings:s,selectedObjectName:e,fieldName:g,fieldValue:d,setError:i})||(e&&fi(e,n,[{field:g,value:d}]),r(ue.MAPPING,g)&&o(ue.MAPPING,g),e&&r(ue.MAPPING,e)&&o(ue.MAPPING,e))},c=y.useMemo(()=>{var u;return((u=t==null?void 0:t.read)==null?void 0:u.requiredMapFields)||[]},[t]);return c!=null&&c.length?l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Map the following fields"}),l.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:c.map(u=>{var d;return l.jsx(Eo,{id:u.mapToName,isInvalid:r(ue.MAPPING,u.mapToName),errorMessage:"* required",children:l.jsx(va,{allFields:((d=t==null?void 0:t.read)==null?void 0:d.allFields)||[],field:u,onSelectChange:a})},u.mapToName)})})]}):null}const sb=(e,t)=>e.filter(n=>!t.has(n));function ab(){var g,h,w;const{selectedObjectName:e,configureState:t,setConfigureState:n}=Xt(),{fieldMapping:r}=rt(),o=((g=t==null?void 0:t.read)==null?void 0:g.selectedFieldMappings)||{},i=Object.keys(o),s=((h=t==null?void 0:t.read)==null?void 0:h.requiredMapFields)||[],a=((w=t==null?void 0:t.read)==null?void 0:w.optionalMapFields)||[],c=e&&r?Object.values(r[e]||{}).flat().filter(v=>!v.fieldName):[],f=s.concat(c,a).map(v=>v.mapToName),u=new Set(f),d=sb(i,u);y.useEffect(()=>{e&&d.length&&fi(e,n,d.map(v=>({field:v,value:null})))},[e,n,d])}const cb={backgroundColor:"var(--amp-colors-bg-highlight)",borderColor:"var(--amp-colors-bg-highlight)",padding:".5rem 1rem"};function lb({children:e,style:t}){return l.jsx(vn,{style:{...cb,...t},children:e})}const _i=e=>{const t=ut(),{provider:n}=rt(),r=e||n;return yn({queryKey:["amp","providerInfo",r],queryFn:async()=>{if(!r)throw new Error("Provider not found");return(await t()).providerApi.getProvider({provider:r})},enabled:!!r})},at=e=>{const t=_i(e),{data:n}=t,{provider:r}=rt(),o=n&&Gl(n==null?void 0:n.name,n);return{...t,providerName:o,selectedProvider:e||r}};function ub(){var f,u,d;const{project:e}=Te(),{hydratedRevision:t}=Gr(),{selectedObjectName:n}=Xt(),{providerName:r}=at(),o=e==null?void 0:e.appName,i=(d=(u=(f=t==null?void 0:t.content)==null?void 0:f.read)==null?void 0:u.objects)==null?void 0:d.find(g=>g.objectName===n),s=(i==null?void 0:i.displayName)||n&&Un(n),a=i==null?void 0:i.mapToName,c=(i==null?void 0:i.mapToDisplayName)||a&&Un(a);return c&&o&&r?l.jsx(lb,{style:{marginTop:"1rem"},children:l.jsxs("p",{style:{margin:"1rem 0"},children:[l.jsx("b",{children:c})," in ",o," is mapped to"," ",l.jsx("b",{children:s})," in ",r,"."]})}):null}function Uc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function db(...e){return t=>{let n=!1;const r=e.map(o=>{const i=Uc(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():Uc(e[o],null)}}}}function gr(...e){return M.useCallback(db(...e),e)}function No(e,t=[]){let n=[];function r(i,s){const a=M.createContext(s),c=n.length;n=[...n,s];const f=d=>{var x;const{scope:g,children:h,...w}=d,v=((x=g==null?void 0:g[e])==null?void 0:x[c])||a,p=M.useMemo(()=>w,Object.values(w));return l.jsx(v.Provider,{value:p,children:h})};f.displayName=i+"Provider";function u(d,g){var v;const h=((v=g==null?void 0:g[e])==null?void 0:v[c])||a,w=M.useContext(h);if(w)return w;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[f,u]}const o=()=>{const i=n.map(s=>M.createContext(s));return function(a){const c=(a==null?void 0:a[e])||i;return M.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,fb(o,...t)]}function fb(...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:f})=>{const d=c(i)[`__scope${f}`];return{...a,...d}},{});return M.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Wt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}var pi=globalThis!=null&&globalThis.document?M.useLayoutEffect:()=>{},pb=M[" useInsertionEffect ".trim().toString()]||pi;function wa({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,s]=hb({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const u=M.useRef(e!==void 0);M.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const f=M.useCallback(u=>{var d;if(a){const g=mb(u)?u(e):u;g!==e&&((d=s.current)==null||d.call(s,g))}else i(u)},[a,e,i,s]);return[c,f]}function hb({defaultProp:e,onChange:t}){const[n,r]=M.useState(e),o=M.useRef(n),i=M.useRef(t);return pb(()=>{i.current=t},[t]),M.useEffect(()=>{var s;o.current!==n&&((s=i.current)==null||s.call(i,n),o.current=n)},[n,o]),[n,r,i]}function mb(e){return typeof e=="function"}function gb(e){const t=M.useRef({value:e,previous:e});return M.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function yb(e){const[t,n]=M.useState(void 0);return pi(()=>{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,f=Array.isArray(c)?c[0]:c;s=f.inlineSize,a=f.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 vb(e,t){return M.useReducer((n,r)=>t[n][r]??n,e)}var Ia=e=>{const{present:t,children:n}=e,r=wb(t),o=typeof n=="function"?n({present:r.isPresent}):M.Children.only(n),i=gr(r.ref,Ib(o));return typeof n=="function"||r.isPresent?M.cloneElement(o,{ref:i}):null};Ia.displayName="Presence";function wb(e){const[t,n]=M.useState(),r=M.useRef(null),o=M.useRef(e),i=M.useRef("none"),s=e?"mounted":"unmounted",[a,c]=vb(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return M.useEffect(()=>{const f=Wi(r.current);i.current=a==="mounted"?f:"none"},[a]),pi(()=>{const f=r.current,u=o.current;if(u!==e){const g=i.current,h=Wi(f);e?c("MOUNT"):h==="none"||(f==null?void 0:f.display)==="none"?c("UNMOUNT"):c(u&&g!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),pi(()=>{if(t){let f;const u=t.ownerDocument.defaultView??window,d=h=>{const v=Wi(r.current).includes(h.animationName);if(h.target===t&&v&&(c("ANIMATION_END"),!o.current)){const p=t.style.animationFillMode;t.style.animationFillMode="forwards",f=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=p)})}},g=h=>{h.target===t&&(i.current=Wi(r.current))};return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(f),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:M.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function Wi(e){return(e==null?void 0:e.animationName)||"none"}function Ib(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)}function Ms(e){const t=bb(e),n=M.forwardRef((r,o)=>{const{children:i,...s}=r,a=M.Children.toArray(i),c=a.find(Cb);if(c){const f=c.props.children,u=a.map(d=>d===c?M.Children.count(f)>1?M.Children.only(null):M.isValidElement(f)?f.props.children:null:d);return l.jsx(t,{...s,ref:o,children:M.isValidElement(f)?M.cloneElement(f,void 0,u):null})}return l.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function bb(e){const t=M.forwardRef((n,r)=>{const{children:o,...i}=n,s=M.isValidElement(o)?Ob(o):void 0,a=gr(s,r);if(M.isValidElement(o)){const c=_b(i,o.props);return o.type!==M.Fragment&&(c.ref=a),M.cloneElement(o,c)}return M.Children.count(o)>1?M.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var xb=Symbol("radix.slottable");function Cb(e){return M.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===xb}function _b(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)=>{const c=i(...a);return o(...a),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Ob(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 Eb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],wn=Eb.reduce((e,t)=>{const n=Ms(`Primitive.${t}`),r=M.forwardRef((o,i)=>{const{asChild:s,...a}=o,c=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),To="Checkbox",[Sb,d_]=No(To),[Nb,ba]=Sb(To);function Tb(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:o,disabled:i,form:s,name:a,onCheckedChange:c,required:f,value:u="on",internal_do_not_use_render:d}=e,[g,h]=wa({prop:n,defaultProp:o??!1,onChange:c,caller:To}),[w,v]=M.useState(null),[p,x]=M.useState(null),m=M.useRef(!1),I=w?!!s||!!w.closest("form"):!0,_={checked:g,disabled:i,setChecked:h,control:w,setControl:v,name:a,form:s,value:u,hasConsumerStoppedPropagationRef:m,required:f,defaultChecked:Vn(o)?!1:o,isFormControl:I,bubbleInput:p,setBubbleInput:x};return l.jsx(Nb,{scope:t,..._,children:Rb(d)?d(_):r})}var Cd="CheckboxTrigger",_d=M.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},o)=>{const{control:i,value:s,disabled:a,checked:c,required:f,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:g,isFormControl:h,bubbleInput:w}=ba(Cd,e),v=gr(o,u),p=M.useRef(c);return M.useEffect(()=>{const x=i==null?void 0:i.form;if(x){const m=()=>d(p.current);return x.addEventListener("reset",m),()=>x.removeEventListener("reset",m)}},[i,d]),l.jsx(wn.button,{type:"button",role:"checkbox","aria-checked":Vn(c)?"mixed":c,"aria-required":f,"data-state":Nd(c),"data-disabled":a?"":void 0,disabled:a,value:s,...r,ref:v,onKeyDown:Wt(t,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Wt(n,x=>{d(m=>Vn(m)?!0:!m),w&&h&&(g.current=x.isPropagationStopped(),g.current||x.stopPropagation())})})});_d.displayName=Cd;var xa=M.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:c,onCheckedChange:f,form:u,...d}=e;return l.jsx(Tb,{__scopeCheckbox:n,checked:o,defaultChecked:i,disabled:a,required:s,onCheckedChange:f,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:g})=>l.jsxs(l.Fragment,{children:[l.jsx(_d,{...d,ref:t,__scopeCheckbox:n}),g&&l.jsx(Sd,{__scopeCheckbox:n})]})})});xa.displayName=To;var Od="CheckboxIndicator",Ca=M.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=ba(Od,n);return l.jsx(Ia,{present:r||Vn(i.checked)||i.checked===!0,children:l.jsx(wn.span,{"data-state":Nd(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});Ca.displayName=Od;var Ed="CheckboxBubbleInput",Sd=M.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:o,checked:i,defaultChecked:s,required:a,disabled:c,name:f,value:u,form:d,bubbleInput:g,setBubbleInput:h}=ba(Ed,e),w=gr(n,h),v=gb(i),p=yb(r);M.useEffect(()=>{const m=g;if(!m)return;const I=window.HTMLInputElement.prototype,C=Object.getOwnPropertyDescriptor(I,"checked").set,S=!o.current;if(v!==i&&C){const R=new Event("click",{bubbles:S});m.indeterminate=Vn(i),C.call(m,Vn(i)?!1:i),m.dispatchEvent(R)}},[g,v,i,o]);const x=M.useRef(Vn(i)?!1:i);return l.jsx(wn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??x.current,required:a,disabled:c,name:f,value:u,form:d,...t,tabIndex:-1,ref:w,style:{...t.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Sd.displayName=Ed;function Rb(e){return typeof e=="function"}function Vn(e){return e==="indeterminate"}function Nd(e){return Vn(e)?"indeterminate":e?"checked":"unchecked"}function Td(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 Ab=["color"],Rd=y.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=Td(e,Ab);return y.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}),y.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Pb=["color"],Fb=y.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=Td(e,Pb);return y.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}),y.createElement("path",{d:"M2 7.5C2 7.22386 2.22386 7 2.5 7H12.5C12.7761 7 13 7.22386 13 7.5C13 7.77614 12.7761 8 12.5 8H2.5C2.22386 8 2 7.77614 2 7.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))});const Db="_checkboxGroupContainer_1ya1t_1",Mb="_stack_1ya1t_6",kb="_selectAllContainer_1ya1t_11",jb="_fieldContainer_1ya1t_18",Lb="_checkbox_1ya1t_1",Hr={checkboxGroupContainer:Db,stack:Mb,selectAllContainer:kb,fieldContainer:jb,checkbox:Lb};function Ad({id:e,isChecked:t,label:n,onCheckedChange:r}){return l.jsxs("div",{className:Hr.fieldContainer,children:[l.jsx(xa,{className:Hr.checkbox,id:e,onCheckedChange:r,checked:t,children:l.jsx(Ca,{children:l.jsx(Rd,{})})}),l.jsx("label",{htmlFor:e,style:{overflowWrap:"anywhere"},children:n})]})}function Pd({id:e,isChecked:t,label:n,onCheckedChange:r,isIndeterminate:o}){return l.jsxs("div",{className:Hr.selectAllContainer,children:[l.jsx(xa,{className:Hr.checkbox,id:e,onCheckedChange:r,children:l.jsxs(Ca,{children:[o&&l.jsx(Fb,{}),t===!0&&l.jsx(Rd,{})]})}),l.jsx("label",{htmlFor:e,children:n})]})}function Fd({children:e}){return l.jsx("div",{className:Hr.checkboxGroupContainer,children:e})}function Dd({children:e}){return l.jsx("div",{className:Hr.stack,children:e})}function Kb(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=!ou(s,r);e.read.isOptionalFieldsModified=c}else console.warn("read.savedConfig.optionalFields is undefined")}function $c(e,t,n,r){t(e,o=>Kb(o,n,r))}function Vb(){var d,g;const{appName:e,configureState:t,setConfigureState:n,selectedObjectName:r}=Xt(),o=(d=t==null?void 0:t.read)==null?void 0:d.selectedOptionalFields,i=(h,w)=>{h!=="indeterminate"&&r&&t&&$c(r,n,w,h)},s=(g=t==null?void 0:t.read)==null?void 0:g.optionalFields,a=h=>{r&&s&&s.forEach(w=>{$n(w)||$c(r,n,w.fieldName,h)})},c=!!(s&&s.length>0),f=Object.keys(o||{}).length===(s==null?void 0:s.length),u=!f&&Object.keys(o||{}).length>0;return c&&l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:`${e} reads the following optional fields`}),l.jsxs(Fd,{children:[((s==null?void 0:s.length)||0)>=2&&l.jsx(Pd,{id:"select-all-fields",isChecked:f,label:"Select all",onCheckedChange:a,isIndeterminate:u}),l.jsx(Dd,{children:s.map(h=>$n(h)?null:l.jsx(Ad,{id:h.fieldName,isChecked:!!(o!=null&&o[h==null?void 0:h.fieldName]),label:h.displayName,onCheckedChange:w=>i(w,h.fieldName)},h.fieldName))})]})]})}function Ub(){return l.jsx(Vb,{})}const $b={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 qb({children:e,style:t,...n}){return l.jsx("span",{style:{...$b,...t},...n,children:e})}function Hb(){var n,r,o;const{configureState:e}=Xt(),{appName:t}=Te();return l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:`${t} reads the following fields`}),l.jsx("div",{style:{display:"flex",gap:".5rem",marginBottom:".5rem",flexWrap:"wrap"},children:(r=(n=e==null?void 0:e.read)==null?void 0:n.requiredFields)!=null&&r.length?(o=e.read)==null?void 0:o.requiredFields.map(i=>$n(i)?null:l.jsx(qb,{children:i.displayName},i.fieldName)):"There are no required fields."})]})}function Bb(e,t,n,r,o){e.read&&(e.read.selectedValueMappings||(e.read.selectedValueMappings={}),e.read.selectedValueMappings[o]||(e.read.selectedValueMappings[o]={}),r===""&&e.read.selectedValueMappings[o][n]?delete e.read.selectedValueMappings[o][n]:e.read.selectedValueMappings[o][n]=r)}function Md(e,t,n,r,o){t(e,i=>Bb(i,e,n,r,o))}function Jb(e,t,n){t(e,r=>{r.read&&(r.read.isValueMappingsModified=n)})}function Wb({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(So,{style:{width:"100%",marginLeft:"1rem"}})})]})}function zb({mappedValue:e,onSelectChange:t,fieldName:n,allValueOptions:r,hasError:o}){var C;const{configureState:i,selectedObjectName:s,setConfigureState:a}=Xt(),[c,f]=y.useState(!0),{getError:u,setError:d,resetBoundary:g,isError:h,removeError:w}=Ft(),v=y.useMemo(()=>{var S,R;return((R=(S=i==null?void 0:i.read)==null?void 0:S.selectedValueMappings)==null?void 0:R[n])||{}},[(C=i==null?void 0:i.read)==null?void 0:C.selectedValueMappings,n]),p=y.useMemo(()=>v==null?void 0:v[e.mappedValue],[v,e.mappedValue]);y.useEffect(()=>{f(!1)},[e,a,s,p,i]);const x=y.useMemo(()=>r.map(S=>({id:S.value,label:S.displayValue,value:S.value})),[r]),m=y.useCallback(S=>{if(S){if(Object.values(v).some(R=>R===S.value&&R!==p)){const R=[...Object.entries(v).filter(([N,A])=>A===S.value&&A!==p).map(([N])=>N),e.mappedValue];d(ue.VALUE_MAPPING,n,R);return}u(ue.VALUE_MAPPING,n)&&g(ue.VALUE_MAPPING),t({target:{name:e.mappedValue,value:S.value,fieldName:n}})}},[t,v,p,n,e.mappedValue,g,d,u]),I=y.useMemo(()=>l.jsx(td,{disabled:c,items:x,selectedValue:p||null,onSelectedItemChange:m,placeholder:"Please select one",style:{border:o?"2px solid red":void 0,borderRadius:"8px",width:"100%"}},p),[p,c,x,m,o]),_=y.useCallback(()=>{s&&(Md(s,a,e.mappedValue,"",n),h(ue.VALUE_MAPPING,n)&&w(ue.VALUE_MAPPING,n))},[s,a,e.mappedValue,n,h,w]);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})}),l.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[I,l.jsx(ze,{type:"button",variant:"ghost",onClick:_,children:"Clear"})]})]},e.mappedValue)}function Gb(){var h,w,v;const{fieldMapping:e}=rt(),{selectedObjectName:t,configureState:n,setConfigureState:r}=Xt(),{isError:o,removeError:i,getError:s}=Ft(),a=(h=n==null?void 0:n.read)==null?void 0:h.selectedFieldMappings,c=(w=n==null?void 0:n.read)==null?void 0:w.selectedValueMappings,f=(v=n==null?void 0:n.read)==null?void 0:v.isValueMappingsModified,u=y.useRef(!1),d=y.useMemo(()=>{const p=t&&e?Object.values(e[t]||{}).flat().filter(x=>x.mappedValues).map(x=>({...x})):[];if(a)for(let x=0;x<p.length;x+=1){const{mapToName:m}=p[x];a!=null&&a[m]&&(p[x].fieldName=a[m])}return p},[t,e,a]),g=y.useCallback(p=>{const{value:x,name:m,fieldName:I}=p.target;x&&(t&&Md(t,r,m,x,I),o(ue.VALUE_MAPPING,m)&&i(ue.VALUE_MAPPING,m))},[t,r,o,i]);return y.useEffect(()=>{var p;if(t&&c){const x=((p=e==null?void 0:e[t])==null?void 0:p.filter(I=>I.fieldName&&I.mappedValues.length>0))||[];x.every(I=>{const _=c[I.fieldName]||{};return Object.keys(_).length===Object.keys(I.mappedValues).length})&&x.length>0?!f&&!u.current&&(Jb(t,r,!0),u.current=!0):u.current=!1}},[c,d,t,r,e,f]),d!=null&&d.length?l.jsx(l.Fragment,{children:d.map(p=>{var S,R,N;if(!p.fieldName)return null;const x=(R=(S=n==null?void 0:n.read)==null?void 0:S.allFieldsMetadata)==null?void 0:R[p.fieldName],m=x==null?void 0:x.valueType;if(!["singleSelect","multiSelect"].includes(m))return console.error("fieldName is not a singleSelect or multiSelect",p),null;const I=x==null?void 0:x.values;if(!I)return null;const _=Object.keys(I).length,C=Object.keys((p==null?void 0:p.mappedValues)||[]).length;return _!==C?(console.error("field values and the values to be mapped are not of the same length",p,I),null):l.jsxs(l.Fragment,{children:[l.jsx(Wb,{string:"Map the values for ",fieldName:p.mapToDisplayName||p.mapToName||p.fieldName}),l.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:l.jsx(Eo,{id:p.mapToName||p.fieldName,children:(N=p==null?void 0:p.mappedValues)==null?void 0:N.map(A=>{var ee,q,ae;const K=s(ue.VALUE_MAPPING,p.fieldName),z=Array.isArray(K)&&K.includes(A.mappedValue),H=((ae=(q=(ee=n==null?void 0:n.read)==null?void 0:ee.allFieldsMetadata)==null?void 0:q[p.fieldName])==null?void 0:ae.values)||[];return l.jsxs(l.Fragment,{children:[l.jsx(zb,{allValueOptions:H,mappedValue:A,onSelectChange:g,fieldName:(p==null?void 0:p.fieldName)||"",hasError:z},`${A.mappedValue}-${p.fieldName}`),z&&l.jsx("span",{style:{color:"red",fontSize:"14px",marginTop:"4px"},children:`Each ${p.mapToName||p.fieldName} must be mapped to a unique value`},A.mappedValue)]})})},p.mapToName||p.fieldName)})]})})}):null}function Qb(){return ab(),l.jsxs(l.Fragment,{children:[l.jsx(ub,{}),l.jsx(Hb,{}),l.jsx(ob,{}),l.jsx(ib,{}),l.jsx(Gb,{}),l.jsx(Ub,{})]})}function Xb(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,f=!uv(a,s);e.write.isWriteModified=f}}}function qc(e,t,n,r){t(e,o=>{Xb(o,n,r)})}function Yb(){var d,g,h,w;const{appName:e,selectedObjectName:t,configureState:n,setConfigureState:r}=Xt(),o=(d=n==null?void 0:n.write)==null?void 0:d.selectedWriteObjects,i=(g=n==null?void 0:n.write)==null?void 0:g.writeObjects,s=(v,p)=>{v!=="indeterminate"&&t&&n&&qc(t,r,p,v)},a=v=>{var p,x;t&&n&&((x=(p=n==null?void 0:n.write)==null?void 0:p.writeObjects)==null||x.forEach(m=>{qc(t,r,m.objectName,v)}))},c=!!i,f=Object.keys(o||{}).length===((w=(h=n==null?void 0:n.write)==null?void 0:h.writeObjects)==null?void 0:w.length),u=!f&&Object.keys(o||{}).length>0;return c&&l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:`Allow ${e} to write to these objects`}),l.jsxs(Fd,{children:[((i==null?void 0:i.length)||0)>=2&&l.jsx(Pd,{id:"select-all-fields",onCheckedChange:a,isIndeterminate:u,isChecked:f,label:"Select all"}),l.jsx(Dd,{children:i.map(v=>l.jsx(Ad,{id:v.objectName,onCheckedChange:p=>s(p,v.objectName),isChecked:!!(o!=null&&o[v.objectName]),label:v.displayName},v.objectName))})]})]})}function Zb(){return l.jsx(l.Fragment,{children:l.jsx(Yb,{})})}const ex="_authenticationRow_cjz1t_1",tx="_field_cjz1t_8",nx="_value_cjz1t_12",Yo={authenticationRow:ex,field:tx,value:nx};function Hc({label:e,value:t}){return l.jsxs("div",{className:Yo.authenticationRow,children:[l.jsx("div",{className:Yo.field,children:e}),l.jsx("div",{className:Yo.value,children:t})]})}function rx(){const{selectedConnection:e}=Qt(),{providerName:t}=at(),r=(e==null?void 0:e.provider)==="salesforce"?"subdomain":"workspace",o=`${t} ${r}`;return l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Connection details"}),l.jsxs("div",{style:{paddingBottom:"1rem"},children:[l.jsx(Hc,{label:o,value:e==null?void 0:e.providerWorkspaceRef}),l.jsx(Hc,{label:"Status",value:e==null?void 0:e.status})]})]})}const ix=()=>{const e=ut(),t=vt();return Jr({mutationFn:async({projectIdOrName:n,integrationId:r,installationId:o})=>(await e()).installationApi.deleteInstallation({projectIdOrName:n,integrationId:r,installationId:o}),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","installations"]})},onError:n=>{console.error("Error uninstalling installation."),Le(n)}})};function kd({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={}}){const{projectId:r}=Te(),{integrationId:o,installation:i,setIntegrationDeleted:s,onUninstallSuccess:a}=rt(),[c,f]=y.useState(!1),u=!r||!o||!(i!=null&&i.id)||c,d=ix(),g=async()=>{u||(f(!0),console.warn("uninstalling installation",{projectId:r,integrationId:o,installationId:i.id}),d.mutate({projectIdOrName:r,integrationId:o,installationId:i.id},{onSuccess:()=>{console.warn("successfully uninstalled installation:",i.id),a==null||a(i==null?void 0:i.id),s()},onSettled:()=>f(!1)}))},h=c?"Uninstalling...":e,w=l.jsx(ze,{type:"button",onClick:g,disabled:u,variant:t,style:n,children:h});return i!=null&&i.id?w:null}function ox(){const{installation:e}=rt(),{providerName:t}=at();return e?l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Uninstall entire integration"}),l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",padding:"1rem 0"},children:[e!=null&&e.id?l.jsxs("p",{style:{color:"var(--amp-colors-text-muted)"},children:["By clicking below, you will uninstall the entire ",t," ","integration. You will lose any configuration you've set up."]}):l.jsx("p",{children:"You've successfully uninstalled the integration."}),l.jsx(kd,{buttonText:"Yes, uninstall",buttonVariant:"danger"})]})]}):null}function In({error:e}){return e?l.jsx(Ii,{style:{marginTop:"2em"},children:e}):null}const sx="_input_1ymb7_1",ax="_inputError_1ymb7_27",cx="_error_1ymb7_43",Zo={input:sx,inputError:ax,error:cx};function lx({id:e,type:t,className:n,isError:r=!1,...o}){const i=r?Pt(Zo.inputError,Zo.input):Zo.input;return l.jsx("input",{id:e,type:t,className:Pt(i,n),...o})}const ux="_textarea_18zl4_1",dx="_textareaError_18zl4_14",fx="_error_18zl4_29",es={textarea:ux,textareaError:dx,error:fx};function px({className:e,isError:t=!1,...n}){const r=t?Pt(es.textareaError,es.textarea):es.textarea;return l.jsx("textarea",{className:Pt(e,r),...n})}const Bt={Input:lx,Textarea:px},hx=()=>{const{project:e}=Te(),t=e==null?void 0:e.id,n=ut();return yn({queryKey:["project",t,"entitlements"],queryFn:async()=>{if(!t)throw new Error("Project ID is required");return(await n()).projectApi.getProject({projectIdOrName:t,includeEntitlements:!0})},enabled:!!t})};function jd(){var n,r;const{data:e}=hx();return((r=(n=e==null?void 0:e.entitlements)==null?void 0:n.brandingRemoval)==null?void 0:r.value)===!0?null: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 yr({children:e}){return l.jsx(Wr,{children:l.jsxs(vn,{children:[l.jsx("div",{style:{padding:"3rem 2rem"},children:e}),l.jsx(jd,{})]})})}function vr({children:e}){return l.jsx("h1",{style:{fontWeight:600,lineHeight:1.2,fontSize:"1.2em"},children:e})}function mx({children:e}){return l.jsx("p",{style:{padding:".5em 0"},children:e})}const gx="_link_oo2kv_1",yx={link:gx};function Ld({href:e,className:t,style:n,label:r,children:o,newTab:i=!1}){return l.jsx("a",{className:Pt(yx.link,t),style:n,href:e,"aria-label":r||void 0,target:i?"_blank":"_self",rel:i?"noopener noreferrer":void 0,children:o})}function mo({url:e,providerDisplayName:t,credentialName:n}){return l.jsxs("p",{style:{color:"var(--amp-colors-text-muted)"},children:[l.jsx(Ld,{href:e,newTab:!0,children:l.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," ","about where to find your ",t," ",n,"."]})}function _a(e,t){const n={},r=[];if(e.forEach(o=>{const i=t[o.name];!i||i.trim()===""?r.push(o.displayName||o.name):n[o.name]={value:i,source:"input"}}),r.length>0)throw new Error(`Please fill in the following required fields: ${r.join(", ")}.`);return n}function hi(e,t){return e.every(n=>{const r=t[n.name];return r&&r.trim()!==""})}function Kd({provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:r,buttonVariant:o,submitButtonType:i}){var _,C;const[s,a]=y.useState(!1),c=()=>a(S=>!S),[f,u]=y.useState({apiKey:""}),d=((_=t.metadata)==null?void 0:_.input)||[],g=S=>{const{name:R,value:N}=S.currentTarget;u(A=>({...A,[R]:N.trim()}))},{apiKey:h}=f,{providerName:w}=at(e),v=h.length>0,p=hi(d,f),x=r||!v||!p,m=(C=t.apiKeyOpts)==null?void 0:C.docsURL,I=()=>{const S=_a(d,f);n({apiKey:h,providerMetadata:S})};return l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[m&&l.jsx(mo,{url:m,providerDisplayName:w||Un(e),credentialName:"API key"}),l.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[l.jsx(Bt.Input,{id:"password",name:"password",type:s?"text":"password",placeholder:"API Key",onChange:g}),l.jsx(ze,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:c,variant:o,children:s?"Hide":"Show"})]}),d.map(S=>l.jsxs("div",{children:[S.docsURL&&l.jsx(mo,{url:S.docsURL,providerDisplayName:w||Un(e),credentialName:S.displayName||S.name}),l.jsx(Bt.Input,{id:S.name,name:S.name,type:"text",placeholder:S.displayName||S.name,onChange:g})]},S.name)),l.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:x,type:i||"submit",onClick:I,variant:o,children:"Next"})]})}function vx({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){const{providerName:i}=at(e);return l.jsxs(yr,{children:[l.jsx(vr,{children:`Set up ${i} integration`}),l.jsx(In,{error:r}),l.jsx(Kd,{provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:o})]})}function wx({...e}){return l.jsx(vx,{...e})}const Ix={backgroundColor:"var(--amp-colors-status-success-muted)",borderColor:"var(--amp-colors-status-success-muted)",color:"var(--amp-colors-status-success-dark)",padding:".5rem 1rem"};function Ro({children:e,style:t}){return l.jsx(vn,{style:{...Ix,...t},children:e})}const Oa=()=>{const e=ut(),t=vt(),[n,r]=y.useState(null);return{...Jr({mutationKey:["updateConnection"],mutationFn:async i=>(await e()).connectionApi.updateConnection(i),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","connections"]}),r(null)}}),errorMsg:n}};function bx({provider:e}){const{projectIdOrName:t}=Te(),{providerName:n,data:r}=at(e),{selectedConnection:o,isConnectionsLoading:i}=Qt(),{mutateAsync:s,isPending:a,error:c}=Oa(),[f,u]=y.useState(null),[d,g]=y.useState(!1),h=()=>g(!1),w=()=>{g(!0),u(null)},v=(c==null?void 0:c.message)||f||null,p=async x=>{h(),u(null);try{await s({projectIdOrName:t||"",connectionId:(o==null?void 0:o.id)||"",updateConnectionRequest:{updateMask:["apiKey"],connection:{apiKey:x.apiKey}}},{onError:m=>{console.error("Update connection error:",m),Le(m,u)},onSuccess:()=>{w()}})}catch(m){console.error("Update connection caught error:",m),Le(m,u)}};return r?l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Update connection"}),l.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[l.jsx("p",{children:`Update ${n} API Key`}),d&&l.jsx(Ro,{children:"Connection updated successfully"}),v&&l.jsx(Ii,{children:`Error updating connection ${v}`}),l.jsx(Kd,{provider:r==null?void 0:r.name,providerInfo:r,handleSubmit:p,isButtonDisabled:a||i,buttonVariant:"ghost",submitButtonType:"button"})]})]}):null}function Vd({provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:r,buttonVariant:o}){var I,_;const[i,s]=y.useState(!1),a=()=>s(C=>!C),[c,f]=y.useState({username:"",password:""}),u=((I=t.metadata)==null?void 0:I.input)||[],{username:d,password:g}=c,{providerName:h}=at(e),w=C=>{const{name:S,value:R}=C.currentTarget;f(N=>({...N,[S]:R.trim()}))},v=hi(u,c),p=r||!v,x=()=>{const C=_a(u,c);n({user:d,pass:g,providerMetadata:C})},m=(_=t.basicOpts)==null?void 0:_.docsURL;return l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[m&&l.jsx(mo,{url:m,providerDisplayName:h||Un(e),credentialName:"credentials"}),l.jsx(Bt.Input,{id:"username",name:"username",type:"text",placeholder:"Username",onChange:w}),l.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[l.jsx(Bt.Input,{id:"password",name:"password",type:i?"text":"password",placeholder:"Password",onChange:w}),l.jsx(ze,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:a,variant:o,children:i?"Hide":"Show"})]}),u.map(C=>l.jsxs("div",{children:[C.docsURL&&l.jsx(mo,{url:C.docsURL,providerDisplayName:h||Un(e),credentialName:C.displayName||C.name}),l.jsx(Bt.Input,{id:C.name,name:C.name,type:"text",placeholder:C.displayName||C.name,onChange:w})]},C.name)),l.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:p,type:"button",onClick:x,variant:o,children:"Next"})]})}function xx({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){const{providerName:i}=at(e);return l.jsxs(yr,{children:[l.jsx(vr,{children:`Set up ${i} integration`}),l.jsx(In,{error:r}),l.jsx(Vd,{provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:o})]})}function Cx({...e}){return l.jsx(xx,{...e})}function _x({provider:e}){const{projectIdOrName:t}=Te(),{providerName:n,data:r}=at(e),{selectedConnection:o,isConnectionsLoading:i}=Qt(),{mutateAsync:s,isPending:a,error:c}=Oa(),[f,u]=y.useState(null),[d,g]=y.useState(!1),h=()=>g(!1),w=()=>{g(!0),u(null)},v=(c==null?void 0:c.message)||f||null,p=async x=>{h(),u(null);try{await s({projectIdOrName:t||"",connectionId:(o==null?void 0:o.id)||"",updateConnectionRequest:{updateMask:["basicAuth"],connection:{basicAuth:{username:x.user,password:x.pass}}}},{onError:m=>{console.error(m),Le(m,u)},onSuccess:()=>{w()}})}catch(m){console.error(m),Le(m,u)}};return r?l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Update connection"}),l.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[l.jsx("p",{children:`Update ${n} credentials`}),d&&l.jsx(Ro,{children:"Connection updated successfully"}),v&&l.jsx(Ii,{children:`Error updating connection: ${v}`}),l.jsx(Vd,{provider:r==null?void 0:r.name,providerInfo:r,handleSubmit:p,isButtonDisabled:a||i,buttonVariant:"ghost"})]})]}):null}function Ud({provider:e,handleSubmit:t,isButtonDisabled:n,explicitScopesRequired:r,buttonVariant:o}){var R;const[i,s]=y.useState(!1),[a,c]=y.useState({clientSecret:"",clientId:"",scopes:""}),[f,u]=y.useState(null),{data:d}=_i(e),g=((R=d==null?void 0:d.metadata)==null?void 0:R.input)||[],h=()=>s(N=>!N),w=N=>{const{name:A,value:K}=N.currentTarget;c(z=>({...z,[A]:K.trim()})),u(null)},{clientSecret:v,clientId:p,scopes:x}=a,m=v.length>0,I=p.length>0,_=hi(g,a),C=n||!m||!I||!_,S=()=>{const N=_a(g,a),A={clientId:p,clientSecret:v,providerMetadata:N};r&&x.length>0&&(A.scopes=Xy(x)),t(A)};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.2rem"},children:[l.jsx(Bt.Input,{id:"clientId",name:"clientId",type:"text",placeholder:"Client ID",onChange:w}),l.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[l.jsx(Bt.Input,{id:"clientSecret",name:"clientSecret",type:i?"text":"password",placeholder:"Client Secret",onChange:w}),l.jsx(ze,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:h,variant:o,children:i?"Hide":"Show"})]}),r&&l.jsx(Bt.Textarea,{name:"scopes",placeholder:"Scopes separated by new line",onChange:w}),g.map(N=>l.jsx(Bt.Input,{id:N.name,name:N.name,type:"text",placeholder:N.displayName||N.name,onChange:w},N.name))]}),l.jsx(In,{error:f}),l.jsx("br",{}),l.jsx(ze,{style:{width:"100%"},disabled:C,type:"button",onClick:S,variant:o,children:"Next"})]})}function Ox({provider:e,handleSubmit:t,error:n,isButtonDisabled:r,providerName:o,explicitScopesRequired:i}){return l.jsxs(yr,{children:[l.jsx(vr,{children:`Set up ${o} integration`}),l.jsx(In,{error:n}),l.jsx("br",{}),l.jsx(Ud,{provider:e,handleSubmit:t,isButtonDisabled:r,explicitScopesRequired:i})]})}function Ex({provider:e}){var m;const{projectIdOrName:t}=Te(),{selectedConnection:n,isConnectionsLoading:r}=Qt(),{providerName:o,data:i}=at(e),{mutateAsync:s,isPending:a,error:c}=Oa(),[f,u]=y.useState(null),[d,g]=y.useState(!1),h=()=>{g(!1)},w=()=>{g(!0),u(null)},v=(m=i==null?void 0:i.oauth2Opts)==null?void 0:m.explicitScopesRequired,p=(c==null?void 0:c.message)||f||null,x=async I=>{h(),u(null);try{await s({projectIdOrName:t||"",connectionId:(n==null?void 0:n.id)||"",updateConnectionRequest:{updateMask:["oauth2ClientCredentials"],connection:{oauth2ClientCredentials:{clientId:I.clientId,clientSecret:I.clientSecret,scopes:I.scopes}}}}),w()}catch(_){Le(_,u)}};return l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Update connection"}),l.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[l.jsx("p",{children:`Re-authenticate to ${o}`}),d&&l.jsx(Ro,{children:"Connection updated successfully"}),p&&l.jsx(Ii,{children:`Error updating connection ${p}`}),l.jsx(Ud,{provider:o||"",handleSubmit:x,isButtonDisabled:a||r,explicitScopesRequired:v,buttonVariant:"ghost"})]})]})}const Bc=600,Jc=600,Sx="AUTHORIZATION_SUCCEEDED",Nx="AUTHORIZATION_FAILED";function Tx(e,t,n,r){return y.useCallback(()=>{if(!r)return;const o=window.screenX+(window.outerWidth-Bc)/2,i=window.screenY+(window.outerHeight-Jc)/2.5,s=`width=${Bc},height=${Jc},left=${o},top=${i}`,a=window.open(r,e,s);t(a),window.addEventListener("message",n,!1)},[r,e,t,n])}function Rx(e,t,n,r){const o=vt();return y.useCallback(i=>{var s,a;if(i.origin===Ty){if(i.data.eventType===Sx){const c=(s=i.data.data)==null?void 0:s.connection;c?(e(c),o.setQueriesData({queryKey:["amp","connections"]},()=>[c]),t==null||t.close(),r==null||r(),o.invalidateQueries({queryKey:["amp","connections"]})):console.error("Connection ID not found in event data: ",{event:i})}i.data.eventType===Nx&&(console.error("OAuth failed: ",{event:i}),n==null||n(((a=i==null?void 0:i.data)==null?void 0:a.message)??"Something went wrong. Please try again."))}},[t,n,o,e,r])}function Ea({children:e,oauthUrl:t,windowTitle:n="Connect to Provider",onError:r,error:o,onSuccessConnect:i,isSuccessConnect:s,onWindowClose:a}){const[c,f]=y.useState(null),[u,d]=y.useState(null),g=vt(),h=y.useRef(null),w=Rx(f,u,r,i),v=Tx(n,d,w,t);y.useEffect(()=>{t&&!u&&!c&&!o&&!s&&(r==null||r(null),v())},[t,u,v,c,o,s,r]);const p=y.useCallback(()=>{g.invalidateQueries({queryKey:["amp","connections"]}),d(null),!c&&!o?(console.error("Window closed and no connection was found. Please try again."),r==null||r("Window closed prematurely. Please wait and try again.")):c&&(r==null||r(null)),a==null||a(),setTimeout(()=>{window.removeEventListener("message",w)},1e3)},[c,o,r,a,w,g]);return y.useEffect(()=>{if(u)return h.current=setInterval(()=>{(!u||u.closed)&&(h.current&&clearInterval(h.current),h.current=null,p())},500),()=>{h.current&&(clearInterval(h.current),h.current=null),window.removeEventListener("message",w)}},[p,u,w]),l.jsx("div",{children:e})}const Ax=()=>{const e=ut(),t=vt();return Jr({mutationKey:["updateOauthConnection"],mutationFn:async n=>{const r=await e();if(!n.projectIdOrName||!n.connectionId)throw new Error("Project ID and connection ID are required");return r.oAuthApi.oauthUpdate(n)},onSuccess:()=>{t.invalidateQueries({queryKey:["connections"]})}})};function Px({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return l.jsxs("div",{style:{padding:"1rem 0"},children:[l.jsx("p",{children:`Re-authenticate to ${r}`}),l.jsx(In,{error:t}),l.jsx(ze,{variant:"ghost",style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function Fx({provider:e}){const{selectedConnection:t,isConnectionsLoading:n}=Qt(),r=t==null?void 0:t.id,o=t==null?void 0:t.projectId,{providerName:i}=at(e),{mutateAsync:s,isPending:a,error:c}=Ax(),[f,u]=y.useState(null),[d,g]=y.useState(!1),[h,w]=y.useState(null),v=()=>{g(!1)},p=()=>{g(!0),u(null),w(null)},x=(c==null?void 0:c.message)||f||null,m=async()=>{v(),u(null);try{const _=await s({projectIdOrName:o||"",connectionId:r||""});w(_)}catch(_){Le(_,u)}},I=y.useCallback(_=>{u(_)},[]);return l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Update connection"}),d&&l.jsx(Ro,{children:"Connection updated successfully"}),l.jsx(Ea,{windowTitle:`Connect to ${i}`,oauthUrl:h||null,onError:I,error:x,isSuccessConnect:d,onSuccessConnect:p,children:l.jsx(Px,{handleSubmit:m,error:x,providerName:i,isButtonDisabled:a||n||d})})]})}function $d({provider:e}){var r;const{data:t}=_i(e);if((t==null?void 0:t.authType)===Qa.Basic)return l.jsx(_x,{provider:e});if((t==null?void 0:t.authType)===Qa.ApiKey)return l.jsx(bx,{provider:e});const n=(r=t==null?void 0:t.oauth2Opts)==null?void 0:r.grantType;if(n){if(n===Ko.AuthorizationCode||n===Ko.AuthorizationCodePkce)return l.jsx(Fx,{provider:e});if(n===Ko.ClientCredentials)return l.jsx(Ex,{provider:e})}return null}function Dx(){return l.jsxs(l.Fragment,{children:[l.jsx(rx,{}),l.jsx($d,{}),l.jsx(ox,{})]})}function qd({onSave:e,onReset:t,isLoading:n,isCreateMode:r=!1,errorMsg:o}){var S,R,N,A;const{installation:i}=rt(),{hydratedRevision:s,loading:a}=Gr(),{configureState:c,selectedObjectName:f}=Xt(),u=i==null?void 0:i.config,d=u&&f&&!!tu(u,f)||!1,g=((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),h=(A=c==null?void 0:c.write)==null?void 0:A.isWriteModified,x=a||n||!c||!f||!(g||h||r||f!==dr&&!d),m=f===dr,I=f===ro,_=l.jsx(ze,{type:"submit",disabled:x,children:r?"Install":"Save"}),C=l.jsx(ze,{type:"button",onClick:t,disabled:x,variant:"ghost",children:"Reset"});return n?l.jsx(ci,{}):l.jsxs("form",{style:{width:"34rem"},onSubmit:e,children:[l.jsx("div",{style:{display:"flex",flexDirection:"row-reverse",gap:".8rem",marginBottom:"20px",height:"3rem"},children:!I&&l.jsxs(l.Fragment,{children:[_,C]})}),l.jsxs(vn,{style:{padding:"1rem 2rem",minHeight:"300px",backgroundColor:"var(--amp-colors-bg-primary)",borderColor:"var(--amp-colors-border)"},children:[o&&l.jsx(Ii,{children:typeof o=="string"?o:"Installation Failed."}),a&&l.jsx(ci,{}),s&&!m&&!I&&l.jsx(Qb,{}),s&&m&&!I&&l.jsx(Zb,{}),!a&&I&&l.jsx(Dx,{})]})]})}const Hd=()=>{const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,onInstallSuccess:o,onUpdateSuccess:i}=rt(),{hydratedRevision:s,loading:a}=Gr(),{selectedObjectName:c}=pd(),{selectedConnection:f}=Qt(),u=yl(),{projectId:d}=Te(),{resetBoundary:g,setErrors:h,setError:w,getError:v}=Ft(),{resetConfigureState:p,objectConfigurationsState:x,resetPendingConfigurationState:m}=ya(),I=du(c||"",x),{onNextIncompleteTab:_}=FI(),C=y.useCallback(()=>{g(ue.INSTALLATION_MUTATION)},[g]),S=y.useCallback(N=>N?A=>{w(ue.INSTALLATION_MUTATION,N,A)}:A=>{console.error("objectName is required to set installation error: ",A)},[w]),R=y.useCallback(N=>N?v(ue.INSTALLATION_MUTATION,N):"",[v]);return{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:s,loading:a,selectedObjectName:c,selectedConnection:f,apiKey:u,projectId:d,resetBoundary:g,setErrors:h,setMutateInstallationError:S,getMutateInstallationError:R,resetMutateInstallationErrorState:C,resetConfigureState:p,objectConfigurationsState:x,resetPendingConfigurationState:m,configureState:I,onInstallSuccess:o,onUpdateSuccess:i,onNextIncompleteTab:_}},Mx=void 0;function kx(){const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:o,loading:i,selectedObjectName:s,selectedConnection:a,apiKey:c,projectId:f,resetBoundary:u,setErrors:d,setMutateInstallationError:g,getMutateInstallationError:h,resetMutateInstallationErrorState:w,resetConfigureState:v,objectConfigurationsState:p,resetPendingConfigurationState:x,configureState:m,onInstallSuccess:I,onNextIncompleteTab:_}=Hd(),[C,S]=y.useState(!1),R=s===dr,N=h(s),A=y.useCallback(()=>{u(ue.MAPPING),o!=null&&o.content&&!i&&s&&au(o,Mx,s,v)},[u,o,i,s,v]);y.useEffect(()=>{!m&&(o!=null&&o.content)&&!i&&A()},[m,p,o,i,A]);const K=()=>{w();const{requiredMapFields:ee,selectedFieldMappings:q}=(m==null?void 0:m.read)||{},{errorList:ae}=iu(ee,q,d);ae.length>0||(s&&(a!=null&&a.id)&&c&&f&&e&&t&&n&&o?(S(!0),gv(f,e,t,n,a.id,s,c,o,m,g(s),r,I).finally(()=>{S(!1),x(s),_()})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},z=()=>{w(),s&&(a!=null&&a.id)&&c&&f&&e&&t&&n&&o?(S(!0),wv(f,e,t,n,a.id,c,o,m,g(s),r,I).finally(()=>{S(!1),x(s),_()})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},H=ee=>{ee.preventDefault(),R?z():K()};return l.jsx(qd,{errorMsg:N,isCreateMode:!0,isLoading:C,onSave:H,onReset:A})}function jx({updateConfig:e,projectId:t,integrationId:n,installationId:r,apiKey:o,selectedObjectName:i,setInstallation:s,onUpdateSuccess:a,setError:c}){const f={projectIdOrName:t,installationId:r,integrationId:n,installationUpdate:{updateMask:[`config.content.read.objects.${Zy(i)}`],installation:{config:e}}};return $s().installationApi.updateInstallation(f,{headers:{"X-Api-Key":o,"Content-Type":"application/json"}}).then(u=>{s(u),a==null||a(u.id,u.config)}).catch(u=>{Le(u,c)})}const Lx=(e,t,n,r,o,i)=>{const s=cu(e),a=lu(e),c=uu(e),f={content:{read:{objects:{[t]:{objectName:t,schedule:r,destination:(n==null?void 0:n.destination)||"",selectedFields:s,selectedFieldMappings:a,selectedValueMappings:c||{},backfill:i}}}}};return wi(o)&&(f.content||(f.content={}),f.content.proxy={enabled:!0}),f},Kx=(e,t,n,r,o,i,s,a,c,f,u)=>{const d=Lx(i,r||"",a,a.schedule,c,a.backfill);return d?jx({updateConfig:d,projectId:e,integrationId:t,installationId:n,apiKey:o,selectedObjectName:r,setError:f,setInstallation:s,onUpdateSuccess:u}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Vx=(e,t)=>{const r={content:{write:{objects:pu(e)}}};return wi(t)&&(r.content||(r.content={}),r.content.proxy={enabled:!0}),r},Ux=(e,t,n,r,o,i,s,a,c)=>{const f=Vx(o,i);if(!f)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const u={projectIdOrName:e,installationId:n,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:f}}};return $s().installationApi.updateInstallation(u,{headers:{"X-Api-Key":r,"Content-Type":"application/json"}}).then(d=>{a(d),c==null||c(d.id,d.config)}).catch(d=>{Le(d,s)})};function $x({installation:e,integrationObj:t}){const{setInstallation:n,hydratedRevision:r,loading:o,selectedObjectName:i,apiKey:s,projectId:a,resetBoundary:c,setErrors:f,setMutateInstallationError:u,getMutateInstallationError:d,resetConfigureState:g,resetPendingConfigurationState:h,configureState:w,onUpdateSuccess:v,onNextIncompleteTab:p}=Hd(),[x,m]=y.useState(!1),I=i===dr,_=d(i),{config:C}=e,S=y.useCallback(()=>{c(ue.MAPPING),r!=null&&r.content&&!o&&i&&au(r,C,i,g)},[c,r,o,i,C,g]);y.useEffect(()=>{w||S()},[w,S]);const R=y.useMemo(()=>{var H,ee,q;return(q=(ee=(H=r==null?void 0:r.content)==null?void 0:H.read)==null?void 0:ee.objects)==null?void 0:q.find(ae=>(ae==null?void 0:ae.objectName)===i)},[r,i]),N=()=>{const{requiredMapFields:z,selectedFieldMappings:H}=(w==null?void 0:w.read)||{},{errorList:ee}=iu(z,H,f);ee.length>0||(r&&e&&i&&s&&a&&R?(m(!0),Kx(a,t.id,e.id,i,s,w,n,R,r,u(i),v).finally(()=>{m(!1),h(i),p()})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},A=()=>{e&&i&&s&&a&&r?(m(!0),Ux(a,t.id,e.id,s,w,r,u(i),n,v).finally(()=>{m(!1),h(i),p()})):console.error("UpdateInstallation - onSaveUpdate missing required props")},K=z=>{z.preventDefault(),I?A():N()};return l.jsx(qd,{errorMsg:_,onSave:K,onReset:S,isLoading:x})}function qx(){const{integrationObj:e,installation:t}=rt();return e?t&&e?l.jsx($x,{installation:t,integrationObj:e}):l.jsx(kx,{}):l.jsx(Jl,{message:"We can't load the integration"})}const Hx=()=>{const e=ut(),t=vt(),[n,r]=y.useState(null);return{...Jr({mutationKey:["createInstallation"],mutationFn:async i=>(await e()).installationApi.createInstallation(i),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","installations"]}),r(null)},onError:i=>{console.error("Error creating installation"),Le(i,r)}}),errorMsg:n}};function Bx(){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 Sa({text:e,children:t}){return l.jsx(Wr,{children:l.jsxs(vn,{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"3rem",gap:"3rem"},children:[l.jsx(Bx,{}),l.jsx("p",{children:e}),t]})})}function Jx({provider:e}){const{providerName:t}=at(e),n=`You have successfully installed your ${t} integration.`;return l.jsx(Sa,{text:n,children:l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:l.jsx(kd,{buttonText:"Uninstall",buttonVariant:"outline",buttonStyle:{fontSize:"13px"}})})})}const Wx=e=>{const{read:t,write:n}=(e==null?void 0:e.content)??{};return!t&&!n};function zx({children:e}){var C;const t=y.useRef(!1),{projectId:n}=Te(),{hydratedRevision:r,loading:o}=Gr(),{integrationObj:i,installation:s,groupRef:a,consumerRef:c,onInstallSuccess:f,isIntegrationDeleted:u}=rt(),{mutate:d,isIdle:g,isPending:h,error:w,errorMsg:v}=Hx(),{selectedConnection:p,isConnectionsLoading:x}=Qt(),m=o||h||x,I=(C=r==null?void 0:r.content)==null?void 0:C.provider,_=Wx(r);return y.useEffect(()=>{var S;if(!m&&!x&&r&&_&&!s&&p&&(i!=null&&i.id)&&!u&&I){const R={projectIdOrName:n,integrationId:i==null?void 0:i.id,installation:{groupRef:a,connectionId:p==null?void 0:p.id,config:{content:{provider:I}}}};wi(r)===!0&&(R.installation.config.content.proxy=(S=r==null?void 0:r.content)==null?void 0:S.proxy),g&&!t.current&&(d(R,{onSuccess:N=>{f==null||f(N==null?void 0:N.id,N.config)}}),t.current=!0)}},[r,_,s,p,n,i==null?void 0:i.id,a,c,m,f,u,x,I,d,g]),_&&I&&s?l.jsx(Jx,{provider:I}):w?l.jsx(Jt,{message:v??"Create installation failed"}):i?m?l.jsx(zr,{}):l.jsx("div",{children:e}):l.jsx(Jt,{message:"We can't load the integration"})}function Ao(){const e=ut(),t=vt();return Jr({mutationKey:["createConnection"],mutationFn:async n=>(await e()).connectionApi.generateConnection(n),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","connections"]})},onError:n=>{console.error("Error creating connection and loading provider info"),Le(n)}})}function Gx({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a}){const{projectIdOrName:c}=Te(),f=Ao(),u=y.useCallback(d=>{var v;const{apiKey:g,providerMetadata:h}=d,w={projectIdOrName:c,generateConnectionParams:{providerWorkspaceRef:(v=h==null?void 0:h.workspace)==null?void 0:v.value,groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,apiKey:g,...h&&{providerMetadata:h}}};f.mutate(w)},[c,i,o,r,n,e,f]);return a===null?l.jsx(wx,{provider:e,providerInfo:t,handleSubmit:u,error:null}):s}function Qx({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a}){const{projectIdOrName:c}=Te(),f=Ao(),u=y.useCallback(d=>{var p;const{user:g,pass:h,providerMetadata:w}=d,v={projectIdOrName:c,generateConnectionParams:{providerWorkspaceRef:(p=w==null?void 0:w.workspace)==null?void 0:p.value,groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,basicAuth:{username:g,password:h},...w&&{providerMetadata:w}}};f.mutate(v)},[c,i,o,r,n,e,f]);return a===null?l.jsx(Cx,{provider:e,providerInfo:t,handleSubmit:u,error:null}):s}function Xx({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(yr,{children:[l.jsx(vr,{children:i||`Set up ${r} integration`}),l.jsx(In,{error:t}),o,l.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function Yx({...e}){return l.jsx(Xx,{...e})}function Zx({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,selectedConnection:s,providerName:a}){const{projectIdOrName:c}=Te(),f=Ao(),u=y.useCallback(()=>{const d={projectIdOrName:c,generateConnectionParams:{groupName:o,groupRef:r,consumerName:n,consumerRef:t,provider:e}};f.mutate(d)},[c,o,r,n,t,e,f]);return s===null?l.jsx(Yx,{handleSubmit:u,error:null,providerName:a}):i}const eC=()=>{const e=ut(),{projectIdOrName:t}=Te();return yn({queryKey:["amp","providerApps",t],queryFn:async()=>{if(!t)throw new Error("Project ID is required");return(await e()).providerAppApi.listProviderApps({projectIdOrName:t})},enabled:!!t})},tC=e=>{const t=ut(),n={connectOAuthParams:e};return yn({queryKey:["amp","oauthConnect",e.projectId,e.groupRef,e.consumerRef,e.provider],queryFn:async()=>{if(!e.projectId)throw new Error("Project ID is required");if(!(e!=null&&e.providerAppId))throw new Error("Provider App ID is required");if(!(e!=null&&e.provider))throw new Error("Provider is required");if(!(e!=null&&e.consumerRef))throw new Error("Consumer Ref is required");if(!(e!=null&&e.groupRef))throw new Error("Group Ref is required");return(await t()).oAuthApi.oauthConnect(n)},enabled:!1})},nC=Hs("VITE_AMP_ENABLE_CSRF",!1),rC=Hs("NEXT_AMP_ENABLE_CSRF",!1),iC=Hs("REACT_APP_AMP_ENABLE_CSRF",!1),oC=!!nC||!!rC||!!iC,Bd=(e,t,n,r,o,i,s)=>{var S;const{projectId:a}=Te(),{data:c,isLoading:f,error:u}=_i(n),{data:d,isLoading:g,error:h}=eC(),w=d==null?void 0:d.find(R=>R.provider===n),v=c?Gl(n,c):null,p={providerWorkspaceRef:i||((S=s==null?void 0:s.workspace)==null?void 0:S.value),projectId:a,groupRef:t,groupName:o,consumerRef:e,consumerName:r,providerAppId:w==null?void 0:w.id,provider:n,enableCSRFProtection:oC,providerMetadata:s},{data:x,error:m,isLoading:I,refetch:_}=tC(p);return y.useEffect(()=>{c&&n&&d&&!w&&console.error(`You must first set up a ${v} Provider App using the Ampersand Console. `,{provInfo:c,provider:n,providerApps:d,app:w})},[w,v,c,n,d]),y.useEffect(()=>{u&&(console.error("Error fetching provider info:",u),Le(u))},[u]),y.useEffect(()=>{h&&(console.error("Error fetching provider apps:",h),Le(h))},[h]),y.useEffect(()=>{m&&(console.error("Error fetching OAuth connect:",m),Le(m))},[m]),{url:x,error:u||h||m,isLoading:f||g||I,refetchOauthConnect:async()=>{var R,N;if((c==null?void 0:c.authType)==="oauth2"){if(((R=c==null?void 0:c.oauth2Opts)==null?void 0:R.grantType)==="authorizationCode"||((N=c==null?void 0:c.oauth2Opts)==null?void 0:N.grantType)==="authorizationCodePKCE")return await _();console.error("Provider does not support an OAuth2 web flow grant type.")}else console.error("Provider does not support an OAuth2 web flow.");return null}}};function sC({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return l.jsxs(yr,{children:[l.jsx(vr,{children:`Set up ${r} integration`}),l.jsx(mx,{children:`Click Next to sign into the ${r} account you'd like to sync.`}),l.jsx(In,{error:t}),l.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:n?"Loading...":"Next"})]})}function aC({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,providerName:i}){const[s,a]=y.useState(null),[c,f]=y.useState(!1),{isFetching:u,refetch:d}=Hl({groupRef:r,provider:e}),{url:g,error:h,isLoading:w,refetchOauthConnect:v}=Bd(t,r,e,n,o,void 0,{}),p=(h==null?void 0:h.message)||s||null,x=y.useCallback(C=>{a(C),f(!1),d()},[a,d]),m=y.useCallback(()=>{a(null),f(!1),d()},[a,d]),I=y.useCallback(()=>{f(!1),d()},[f,d]),_=async()=>{var R;a(null);const{data:C}=await d();if(C&&C.length>0)return;const S=await v();S!=null&&S.data?f(!0):x(((R=S==null?void 0:S.error)==null?void 0:R.message)||"Authentication failed")};return l.jsx(Ea,{windowTitle:`Connect to ${i}`,oauthUrl:c&&g||null,onError:x,error:p,onSuccessConnect:m,onWindowClose:I,children:l.jsx(sC,{handleSubmit:_,error:u?"":p,providerName:i,isButtonDisabled:w||u})})}const cC="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function lC({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r}){return l.jsxs(yr,{children:[l.jsx(vr,{children:"Enter your Salesforce subdomain"}),l.jsx(Ld,{href:cC,newTab:!0,children:"What is my Salesforce subdomain?"}),l.jsx(In,{error:n}),l.jsxs("div",{style:{display:"flex",marginTop:"1em",alignItems:"center"},children:[l.jsx(Bt.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(ze,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}function uC({handleSubmit:e,setFormData:t,error:n,isButtonDisabled:r,providerName:o,metadataFields:i}){return l.jsxs(yr,{children:[l.jsxs(vr,{children:["Enter your ",o," workspace"]}),l.jsx(In,{error:n}),l.jsx("br",{}),i.map(s=>l.jsx(Bt.Input,{id:s.name,name:s.name,type:"text",placeholder:s.displayName||s.name,onChange:a=>t(s.name,a.currentTarget.value)},s.name)),l.jsx("br",{}),l.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}const Wc="salesforce";function dC({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,providerName:i}){var q,ae;const[s,a]=y.useState(""),[c,f]=y.useState({}),[u,d]=y.useState(null),[g,h]=y.useState(!1),[w,v]=y.useState({}),{data:p}=_i(e),x=((q=p==null?void 0:p.metadata)==null?void 0:q.input)||[],{url:m,error:I,isLoading:_,refetchOauthConnect:C}=Bd(t,r,e,n,o,e===Wc?s:(ae=w==null?void 0:w.workspace)==null?void 0:ae.value,w),S=(I==null?void 0:I.message)||u||null,R=y.useCallback(X=>{d(X),h(!1)},[]),N=y.useCallback(()=>{d(null),h(!1)},[]),A=y.useCallback(()=>{h(!1)},[h]),K=X=>{a(X),f(Y=>({...Y,workspace:X})),v(Y=>({...Y,workspace:{value:X,source:"input"}}))},z=(X,Y)=>{f(fe=>({...fe,[X]:Y})),v(fe=>({...fe,[X]:{value:Y,source:"input"}}))},H=async()=>{var Y;if(d(null),!hi(x,c)){d("Please fill in all required fields");return}const X=await C();X!=null&&X.data?h(!0):R(((Y=X==null?void 0:X.error)==null?void 0:Y.message)||"Authentication failed")},ee=e===Wc?l.jsx(lC,{handleSubmit:H,setWorkspace:K,error:S,isButtonDisabled:s.length===0}):l.jsx(uC,{handleSubmit:H,setFormData:z,error:S,isButtonDisabled:!hi(x,c)||_,providerName:i,metadataFields:x});return l.jsx(Ea,{windowTitle:`Connect to ${i}`,oauthUrl:g&&m||null,onError:R,error:S,onSuccessConnect:N,onWindowClose:A,children:ee})}function fC({provider:e,providerName:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,explicitScopesRequired:s,selectedConnection:a}){const{projectIdOrName:c}=Te(),f=Ao(),[u,d]=y.useState(null),g=y.useCallback(h=>{var v,p;d(null);const w={projectIdOrName:c,generateConnectionParams:{groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,providerWorkspaceRef:(p=(v=h.providerMetadata)==null?void 0:v.workspace)==null?void 0:p.value,oauth2ClientCredentials:{clientId:h.clientId,clientSecret:h.clientSecret,scopes:h.scopes},...h.providerMetadata&&{providerMetadata:h.providerMetadata}}};f.mutate(w,{onError:()=>d("Error loading provider info")})},[c,i,o,r,n,e,f]);return a===null?l.jsx(Ox,{provider:e,providerName:t,handleSubmit:g,error:u,explicitScopesRequired:s}):l.jsx(ci,{})}function pC({...e}){return l.jsx(fC,{...e})}const hC="authorizationCode",mC="authorizationCodePKCE",gC="clientCredentials";function yC({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,selectedConnection:s,setSelectedConnection:a}){var g;const{providerName:c}=at(e);if(t.oauth2Opts===void 0)return l.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:f,explicitScopesRequired:u}=t.oauth2Opts,d={provider:e,consumerRef:n,consumerName:r,groupRef:o,groupName:i,providerName:c};return f===hC||f===mC?(g=t.metadata)!=null&&g.input?l.jsx(dC,{...d}):l.jsx(aC,{...d}):f===gC?l.jsx(pC,{...d,explicitScopesRequired:u,selectedConnection:s,setSelectedConnection:a}):f==="password"?l.jsx("em",{children:"Password flow not supported yet"}):l.jsxs("em",{children:["Unsupported grant type: ",f]})}function vC(e){const{selectedConnection:t}=Qt();y.useEffect(()=>{e&&t&&e(t)},[e,t])}function wC({onSuccess:e}){vC(e)}function Jd({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,onSuccess:s,onDisconnectSuccess:a,resetComponent:c}){const{data:f,isLoading:u,isError:d,error:g,providerName:h,selectedProvider:w}=at(e),{provider:v,isIntegrationDeleted:p}=rt(),{selectedConnection:x,setSelectedConnection:m}=Qt();wC({onSuccess:s});const I=vt();y.useEffect(()=>{d&&(console.error("Error loading provider info."),Le(g))},[d,g]);const _=y.useCallback(()=>{I.clear(),c()},[c,I]);if(!e&&!v)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");if(p)return l.jsx(Sa,{text:"Integration successfully uninstalled.",children:l.jsx(ze,{type:"button",onClick:_,style:{width:"100%"},children:"Reinstall Integration"})});if(x)return i;if(u)return l.jsx(zr,{});if(f==null)return l.jsx(Jt,{message:"Provider info was not found."});const C={provider:w,consumerRef:t,consumerName:n,groupRef:r,groupName:o,selectedConnection:x,setSelectedConnection:m,providerName:h,providerInfo:f,onDisconnectSuccess:a};return f.authType==="none"?l.jsx(Zx,{...C,children:i}):f.authType==="basic"?l.jsx(Qx,{...C,children:i}):f.authType==="apiKey"?l.jsx(Gx,{...C,children:i}):l.jsx(yC,{...C})}function IC(e){const t=e+"CollectionProvider",[n,r]=No(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=v=>{const{scope:p,children:x}=v,m=y.useRef(null),I=y.useRef(new Map).current;return l.jsx(o,{scope:p,itemMap:I,collectionRef:m,children:x})};s.displayName=t;const a=e+"CollectionSlot",c=Ms(a),f=y.forwardRef((v,p)=>{const{scope:x,children:m}=v,I=i(a,x),_=gr(p,I.collectionRef);return l.jsx(c,{ref:_,children:m})});f.displayName=a;const u=e+"CollectionItemSlot",d="data-radix-collection-item",g=Ms(u),h=y.forwardRef((v,p)=>{const{scope:x,children:m,...I}=v,_=y.useRef(null),C=gr(p,_),S=i(u,x);return y.useEffect(()=>(S.itemMap.set(_,{ref:_,...I}),()=>void S.itemMap.delete(_))),l.jsx(g,{[d]:"",ref:C,children:m})});h.displayName=u;function w(v){const p=i(e+"CollectionConsumer",v);return y.useCallback(()=>{const m=p.collectionRef.current;if(!m)return[];const I=Array.from(m.querySelectorAll(`[${d}]`));return Array.from(p.itemMap.values()).sort((S,R)=>I.indexOf(S.ref.current)-I.indexOf(R.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:s,Slot:f,ItemSlot:h},w,r]}var bC=M[" useId ".trim().toString()]||(()=>{}),xC=0;function Wd(e){const[t,n]=M.useState(bC());return pi(()=>{e||n(r=>r??String(xC++))},[e]),e||(t?`radix-${t}`:"")}function CC(e){const t=M.useRef(e);return M.useEffect(()=>{t.current=e}),M.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}var _C=M.createContext(void 0);function zd(e){const t=M.useContext(_C);return e||t||"ltr"}var ts="rovingFocusGroup.onEntryFocus",OC={bubbles:!1,cancelable:!0},Oi="RovingFocusGroup",[ks,Gd,EC]=IC(Oi),[SC,Qd]=No(Oi,[EC]),[NC,TC]=SC(Oi),Xd=M.forwardRef((e,t)=>l.jsx(ks.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(ks.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(RC,{...e,ref:t})})}));Xd.displayName=Oi;var RC=M.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:f,preventScrollOnEntryFocus:u=!1,...d}=e,g=M.useRef(null),h=gr(t,g),w=zd(i),[v,p]=wa({prop:s,defaultProp:a??null,onChange:c,caller:Oi}),[x,m]=M.useState(!1),I=CC(f),_=Gd(n),C=M.useRef(!1),[S,R]=M.useState(0);return M.useEffect(()=>{const N=g.current;if(N)return N.addEventListener(ts,I),()=>N.removeEventListener(ts,I)},[I]),l.jsx(NC,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:v,onItemFocus:M.useCallback(N=>p(N),[p]),onItemShiftTab:M.useCallback(()=>m(!0),[]),onFocusableItemAdd:M.useCallback(()=>R(N=>N+1),[]),onFocusableItemRemove:M.useCallback(()=>R(N=>N-1),[]),children:l.jsx(wn.div,{tabIndex:x||S===0?-1:0,"data-orientation":r,...d,ref:h,style:{outline:"none",...e.style},onMouseDown:Wt(e.onMouseDown,()=>{C.current=!0}),onFocus:Wt(e.onFocus,N=>{const A=!C.current;if(N.target===N.currentTarget&&A&&!x){const K=new CustomEvent(ts,OC);if(N.currentTarget.dispatchEvent(K),!K.defaultPrevented){const z=_().filter(X=>X.focusable),H=z.find(X=>X.active),ee=z.find(X=>X.id===v),ae=[H,ee,...z].filter(Boolean).map(X=>X.ref.current);ef(ae,u)}}C.current=!1}),onBlur:Wt(e.onBlur,()=>m(!1))})})}),Yd="RovingFocusGroupItem",Zd=M.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:s,...a}=e,c=Wd(),f=i||c,u=TC(Yd,n),d=u.currentTabStopId===f,g=Gd(n),{onFocusableItemAdd:h,onFocusableItemRemove:w,currentTabStopId:v}=u;return M.useEffect(()=>{if(r)return h(),()=>w()},[r,h,w]),l.jsx(ks.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:l.jsx(wn.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:t,onMouseDown:Wt(e.onMouseDown,p=>{r?u.onItemFocus(f):p.preventDefault()}),onFocus:Wt(e.onFocus,()=>u.onItemFocus(f)),onKeyDown:Wt(e.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){u.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const x=FC(p,u.orientation,u.dir);if(x!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let I=g().filter(_=>_.focusable).map(_=>_.ref.current);if(x==="last")I.reverse();else if(x==="prev"||x==="next"){x==="prev"&&I.reverse();const _=I.indexOf(p.currentTarget);I=u.loop?DC(I,_+1):I.slice(_+1)}setTimeout(()=>ef(I))}}),children:typeof s=="function"?s({isCurrentTabStop:d,hasTabStop:v!=null}):s})})});Zd.displayName=Yd;var AC={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function PC(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function FC(e,t,n){const r=PC(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return AC[r]}function ef(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function DC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var MC=Xd,kC=Zd,Po="Tabs",[jC,f_]=No(Po,[Qd]),tf=Qd(),[LC,Na]=jC(Po),nf=M.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:c="automatic",...f}=e,u=zd(a),[d,g]=wa({prop:r,onChange:o,defaultProp:i??"",caller:Po});return l.jsx(LC,{scope:n,baseId:Wd(),value:d,onValueChange:g,orientation:s,dir:u,activationMode:c,children:l.jsx(wn.div,{dir:u,"data-orientation":s,...f,ref:t})})});nf.displayName=Po;var rf="TabsList",of=M.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Na(rf,n),s=tf(n);return l.jsx(MC,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:r,children:l.jsx(wn.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});of.displayName=rf;var sf="TabsTrigger",af=M.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=Na(sf,n),a=tf(n),c=lf(s.baseId,r),f=uf(s.baseId,r),u=r===s.value;return l.jsx(kC,{asChild:!0,...a,focusable:!o,active:u,children:l.jsx(wn.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":f,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...i,ref:t,onMouseDown:Wt(e.onMouseDown,d=>{!o&&d.button===0&&d.ctrlKey===!1?s.onValueChange(r):d.preventDefault()}),onKeyDown:Wt(e.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&s.onValueChange(r)}),onFocus:Wt(e.onFocus,()=>{const d=s.activationMode!=="manual";!u&&!o&&d&&s.onValueChange(r)})})})});af.displayName=sf;var cf="TabsContent",KC=M.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=Na(cf,n),c=lf(a.baseId,r),f=uf(a.baseId,r),u=r===a.value,d=M.useRef(u);return M.useEffect(()=>{const g=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(g)},[]),l.jsx(Ia,{present:o||u,children:({present:g})=>l.jsx(wn.div,{"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!g,id:f,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:d.current?"0s":void 0},children:g&&i})})});KC.displayName=cf;function lf(e,t){return`${e}-trigger-${t}`}function uf(e,t){return`${e}-content-${t}`}var VC=nf,UC=of,df=af;const $C=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 qC(e,t){return t?y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},y.createElement("circle",{cx:"9",cy:"9",r:"5",fill:"#FBD38D"})):e?$C: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 HC(){return l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M8 11C9.65685 11 11 9.65685 11 8C11 6.34315 9.65685 5 8 5C6.34315 5 5 6.34315 5 8C5 9.65685 6.34315 11 8 11Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M12.3378 5.04365C12.4882 5.25907 12.62 5.48699 12.7315 5.7249L14.3503 6.6249C14.5524 7.5302 14.5545 8.4687 14.3565 9.3749L12.7315 10.2749C12.62 10.5128 12.4882 10.7407 12.3378 10.9562L12.369 12.8124C11.683 13.4375 10.871 13.9085 9.98776 14.1937L8.39401 13.2374C8.13185 13.2562 7.86868 13.2562 7.60651 13.2374L6.01901 14.1874C5.13295 13.9075 4.31832 13.4383 3.63151 12.8124L3.66276 10.9624C3.51356 10.744 3.38189 10.5141 3.26901 10.2749L1.65026 9.3749C1.44814 8.46961 1.446 7.53111 1.64401 6.6249L3.26901 5.7249C3.38056 5.48699 3.5123 5.25907 3.66276 5.04365L3.63151 3.1874C4.31754 2.56226 5.1295 2.09128 6.01276 1.80615L7.60651 2.7624C7.86868 2.74365 8.13185 2.74365 8.39401 2.7624L9.98151 1.8124C10.8676 2.09234 11.6822 2.5615 12.369 3.1874L12.3378 5.04365Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const BC="_tabsRoot_ktpr0_1",JC="_tabsList_ktpr0_6",WC="_tabTrigger_ktpr0_12",zC="_danger_ktpr0_29",go={tabsRoot:BC,tabsList:JC,tabTrigger:WC,danger:zC};function GC(){return l.jsxs(l.Fragment,{children:[l.jsx(So,{style:{margin:"1rem 0"}}),l.jsx(df,{value:ro,className:go.tabTrigger,children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[l.jsx(HC,{}),l.jsx("span",{children:"Manage"})]})})]})}function ff({objectName:e,completed:t,pending:n,displayName:r}){return l.jsx(df,{value:e,className:go.tabTrigger,children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[qC(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 QC({completed:e,pending:t,displayName:n}){return l.jsxs(l.Fragment,{children:[l.jsx(So,{style:{margin:"1rem 0"}}),l.jsx(ff,{objectName:dr,completed:e,pending:t,displayName:n},"other-write")]})}function XC({value:e,readNavObjects:t,onValueChange:n,objectConfigurationsState:r,writeNavObject:o}){var i,s;return l.jsx(VC,{value:e,className:go.tabsRoot,onValueChange:n,children:l.jsxs(UC,{className:go.tabsList,children:[t.map(a=>{var c,f,u,d,g,h;return l.jsx(ff,{objectName:a.name,displayName:a.displayName,completed:a.completed,pending:((f=(c=r==null?void 0:r[a.name])==null?void 0:c.read)==null?void 0:f.isOptionalFieldsModified)||((d=(u=r==null?void 0:r[a.name])==null?void 0:u.read)==null?void 0:d.isRequiredMapFieldsModified)||((h=(g=r==null?void 0:r[a.name])==null?void 0:g.read)==null?void 0:h.isValueMappingsModified)||!1},a.name)}),o&&l.jsx(QC,{completed:o.completed,pending:((s=(i=r==null?void 0:r.other)==null?void 0:i.write)==null?void 0:s.isWriteModified)||!1,displayName:"Write"}),l.jsx(GC,{})]})})}function YC(e,t){return t===ro?{name:ro,completed:!1}:e.find(n=>n.name===t)}function ZC({children:e}){var x;const{project:t}=Te(),{installation:n}=rt(),{providerName:r}=at(),{hydratedRevision:o}=Gr(),{objectConfigurationsState:i}=ya(),[s,a]=y.useState(""),c=(t==null?void 0:t.appName)||"",f=n==null?void 0:n.config,u=o&&nu(f,o),d=u!==null,g=!!((x=o==null?void 0:o.content)!=null&&x.write),h=g?ru(f):void 0,w=y.useMemo(()=>{const m=[...u||[]];return h&&g&&m.push(h),m},[u,h,g]),v=YC(w,s),p=y.useCallback(()=>{const m=w.find(I=>v!==I&&!I.completed);m&&a(m.name)},[w,v]);return y.useEffect(()=>{!s&&w.length>0&&a(w[0].name)},[w,s,p]),l.jsx(hd.Provider,{value:p,children:l.jsx(fd.Provider,{value:v==null?void 0:v.name,children:l.jsxs(Wr,{style:{maxWidth:"55rem"},children:[l.jsxs(vn,{style:{display:"flex",gap:"1rem",padding:"3rem",paddingBottom:"6rem",backgroundColor:"var(--amp-colors-bg-primary)"},children:[l.jsxs("div",{style:{width:"20rem"},children:[l.jsxs("h1",{style:{fontSize:"small",fontWeight:"400"},children:[r," integration"]}),l.jsx("h3",{style:{marginBottom:"20px",fontSize:"large",fontWeight:"500"},children:c}),d&&l.jsx(XC,{value:s,readNavObjects:u,onValueChange:m=>a(m),objectConfigurationsState:i,writeNavObject:h})]}),e]}),l.jsx(jd,{})]})})})}function e_({...e}){return l.jsx(ZC,{...e})}const t_="_resetContainer_lkwv9_4",pf={resetContainer:t_};function n_({integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c}){var p;const{projectIdOrName:f,isLoading:u}=Te(),{isLoading:d}=qs(),{isError:g,errorState:h}=Ft(),{seed:w,reset:v}=Zl();return u||d?l.jsx(zr,{}):g(ue.PROJECT,f)?l.jsx(Jt,{message:`Error loading project ${f}`}):g(ue.INTEGRATION_LIST,f)?l.jsx(Jt,{message:"Error retrieving integrations for the project, double check the API key"}):(p=h[ue.INTEGRATION_LIST])!=null&&p.apiError?l.jsx(Jt,{message:"Something went wrong, couldn't find integration information"}):l.jsx("div",{className:pf.resetContainer,children:l.jsx(tv,{integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c,children:l.jsx(Yl,{children:l.jsx(Jd,{consumerRef:t,consumerName:n,groupRef:r,groupName:o,resetComponent:v,children:l.jsx(Nv,{resetComponent:v,children:l.jsx(zx,{children:l.jsx(JI,{children:l.jsx(e_,{children:l.jsx(qx,{})})})})})})})},w)})}function r_(){return l.jsxs(Wr,{style:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[l.jsx(ci,{}),l.jsx("p",{children:"Redirecting"})]})}function i_({redirectURL:e,children:t}){return y.useEffect(()=>{e&&window.location.replace(e)},[e]),e?l.jsx(r_,{}):t}function o_({resetComponent:e,onDisconnectSuccess:t,provider:n}){const[r,o]=y.useState(!1);return l.jsxs(l.Fragment,{children:[r===!1&&l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Manage connection"}),l.jsxs("div",{style:{padding:"1rem 0",width:"100%",display:"flex",flexDirection:"column",gap:"1rem"},children:[l.jsx("p",{children:"Click to reauthenticate or refresh your connection."}),l.jsx(ze,{type:"button",onClick:()=>o(!0),variant:"ghost",style:{fontSize:"13px"},children:"Update connection"})]})]}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx($d,{provider:n}),l.jsx(Et,{string:"Remove connection"}),l.jsx("p",{children:"Click to disconnect your connection from the provider."}),l.jsx(mu,{resetComponent:e,onDisconnectSuccess:t,buttonText:"Remove connection",buttonVariant:"danger",buttonStyle:{fontSize:"13px"}})]})]})}function s_({provider:e,onDisconnectSuccess:t,resetComponent:n}){const{appName:r}=Te(),{providerName:o}=at(e),i=`You have successfully connected your ${o} account to ${r}.`;return l.jsx(Sa,{text:i,children:l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",width:"100%"},children:l.jsx(o_,{resetComponent:n,onDisconnectSuccess:t,provider:e})})})}function a_({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,redirectUrl:i,onSuccess:s,onDisconnectSuccess:a,onConnectSuccess:c}){const{seed:f,reset:u}=Zl(),d=y.useCallback(g=>{s?s(g.id):c&&c(g)},[s,c]);return l.jsx("div",{className:pf.resetContainer,children:l.jsx(Yl,{groupRef:r,provider:e,children:l.jsx(Jd,{resetComponent:u,provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onSuccess:d,onDisconnectSuccess:a,children:l.jsx(i_,{redirectURL:i,children:l.jsx(s_,{resetComponent:u,provider:e,onDisconnectSuccess:a})})})})},f)}const c_=(e,t)=>{const{data:n,isLoading:r,isError:o,error:i}=zl(e,t),s=((n==null?void 0:n.length)||0)>0,a=!!n&&!r,c=n==null?void 0:n[0],f=c==null?void 0:c.config;return y.useEffect(()=>{o&&Le(i)},[o,i]),{isLoaded:a,isIntegrationInstalled:s,isLoading:r,config:f}};exports.AmpersandContext=ql;exports.AmpersandProvider=ky;exports.ConnectProvider=a_;exports.InstallIntegration=n_;exports.useAmpersandProvider=jy;exports.useIsIntegrationInstalled=c_;
51
+ .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 AI(){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 PI({id:e,tooltipText:t}){return l.jsxs(l.Fragment,{children:[l.jsx("span",{"data-tooltip-id":e,style:{maxWidth:"20rem"},children:AI()}),l.jsx(RI,{id:e,place:"top",content:t,style:{maxWidth:"30rem"}})]})}const fd=y.createContext(null);function pd(){const e=y.useContext(fd);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}const hd=y.createContext(()=>{});function FI(){const e=y.useContext(hd);if(!e)throw new Error("useSetNextTabIndex must be used within a NextTabIndexProvider");return{onNextIncompleteTab:e}}var md=Symbol.for("immer-nothing"),Mc=Symbol.for("immer-draftable"),_t=Symbol.for("immer-state"),DI=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function yt(e,...t){if(process.env.NODE_ENV!=="production"){const n=DI[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var $r=Object.getPrototypeOf;function qr(e){return!!e&&!!e[_t]}function hr(e){var t;return e?gd(e)||Array.isArray(e)||!!e[Mc]||!!((t=e.constructor)!=null&&t[Mc])||Co(e)||_o(e):!1}var MI=Object.prototype.constructor.toString();function gd(e){if(!e||typeof e!="object")return!1;const t=$r(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===MI}function fo(e,t){xo(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function xo(e){const t=e[_t];return t?t.type_:Array.isArray(e)?1:Co(e)?2:_o(e)?3:0}function Ts(e,t){return xo(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function yd(e,t,n){const r=xo(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function kI(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Co(e){return e instanceof Map}function _o(e){return e instanceof Set}function Xn(e){return e.copy_||e.base_}function Rs(e,t){if(Co(e))return new Map(e);if(_o(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=gd(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[_t];let o=Reflect.ownKeys(r);for(let i=0;i<o.length;i++){const s=o[i],a=r[s];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[s]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[s]})}return Object.create($r(e),r)}else{const r=$r(e);if(r!==null&&n)return{...e};const o=Object.create(r);return Object.assign(o,e)}}function ma(e,t=!1){return Oo(e)||qr(e)||!hr(e)||(xo(e)>1&&(e.set=e.add=e.clear=e.delete=jI),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>ma(r,!0))),e}function jI(){yt(2)}function Oo(e){return Object.isFrozen(e)}var LI={};function mr(e){const t=LI[e];return t||yt(0,e),t}var ui;function vd(){return ui}function KI(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function kc(e,t){t&&(mr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function As(e){Ps(e),e.drafts_.forEach(VI),e.drafts_=null}function Ps(e){e===ui&&(ui=e.parent_)}function jc(e){return ui=KI(ui,e)}function VI(e){const t=e[_t];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Lc(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[_t].modified_&&(As(t),yt(4)),hr(e)&&(e=po(t,e),t.parent_||ho(t,e)),t.patches_&&mr("Patches").generateReplacementPatches_(n[_t].base_,e,t.patches_,t.inversePatches_)):e=po(t,n,[]),As(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==md?e:void 0}function po(e,t,n){if(Oo(t))return t;const r=t[_t];if(!r)return fo(t,(o,i)=>Kc(e,r,t,o,i,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return ho(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const o=r.copy_;let i=o,s=!1;r.type_===3&&(i=new Set(o),o.clear(),s=!0),fo(i,(a,c)=>Kc(e,r,o,a,c,n,s)),ho(e,o,!1),n&&e.patches_&&mr("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Kc(e,t,n,r,o,i,s){if(process.env.NODE_ENV!=="production"&&o===n&&yt(5),qr(o)){const a=i&&t&&t.type_!==3&&!Ts(t.assigned_,r)?i.concat(r):void 0,c=po(e,o,a);if(yd(n,r,c),qr(c))e.canAutoFreeze_=!1;else return}else s&&n.add(o);if(hr(o)&&!Oo(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;po(e,o),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&ho(e,o)}}function ho(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ma(t,n)}function UI(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:vd(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,i=ga;n&&(o=[r],i=di);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,a}var ga={get(e,t){if(t===_t)return e;const n=Xn(e);if(!Ts(n,t))return $I(e,n,t);const r=n[t];return e.finalized_||!hr(r)?r:r===Qo(e.base_,t)?(Xo(e),e.copy_[t]=Ds(r,e)):r},has(e,t){return t in Xn(e)},ownKeys(e){return Reflect.ownKeys(Xn(e))},set(e,t,n){const r=wd(Xn(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const o=Qo(Xn(e),t),i=o==null?void 0:o[_t];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(kI(n,o)&&(n!==void 0||Ts(e.base_,t)))return!0;Xo(e),Fs(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Qo(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Xo(e),Fs(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Xn(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){yt(11)},getPrototypeOf(e){return $r(e.base_)},setPrototypeOf(){yt(12)}},di={};fo(ga,(e,t)=>{di[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});di.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&yt(13),di.set.call(this,e,t,void 0)};di.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&yt(14),ga.set.call(this,e[0],t,n,e[0])};function Qo(e,t){const n=e[_t];return(n?Xn(n):e)[t]}function $I(e,t,n){var o;const r=wd(t,n);return r?"value"in r?r.value:(o=r.get)==null?void 0:o.call(e.draft_):void 0}function wd(e,t){if(!(t in e))return;let n=$r(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=$r(n)}}function Fs(e){e.modified_||(e.modified_=!0,e.parent_&&Fs(e.parent_))}function Xo(e){e.copy_||(e.copy_=Rs(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var qI=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const s=this;return function(c=i,...f){return s.produce(c,u=>n.call(this,u,...f))}}typeof n!="function"&&yt(6),r!==void 0&&typeof r!="function"&&yt(7);let o;if(hr(t)){const i=jc(this),s=Ds(t,void 0);let a=!0;try{o=n(s),a=!1}finally{a?As(i):Ps(i)}return kc(i,r),Lc(o,i)}else if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===md&&(o=void 0),this.autoFreeze_&&ma(o,!0),r){const i=[],s=[];mr("Patches").generateReplacementPatches_(t,o,i,s),r(i,s)}return o}else yt(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,c=>t(c,...a));let r,o;return[this.produce(t,n,(s,a)=>{r=s,o=a}),r,o]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){hr(e)||yt(8),qr(e)&&(e=HI(e));const t=jc(this),n=Ds(e,void 0);return n[_t].isManual_=!0,Ps(t),n}finishDraft(e,t){const n=e&&e[_t];(!n||!n.isManual_)&&yt(9);const{scope_:r}=n;return kc(r,t),Lc(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));const r=mr("Patches").applyPatches_;return qr(e)?r(e,t):this.produce(e,o=>r(o,t))}};function Ds(e,t){const n=Co(e)?mr("MapSet").proxyMap_(e,t):_o(e)?mr("MapSet").proxySet_(e,t):UI(e,t);return(t?t.scope_:vd()).drafts_.push(n),n}function HI(e){return qr(e)||yt(10,e),Id(e)}function Id(e){if(!hr(e)||Oo(e))return e;const t=e[_t];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Rs(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Rs(e,!0);return fo(n,(r,o)=>{yd(n,r,Id(o))}),t&&(t.finalized_=!1),n}var Ot=new qI,ti=Ot.produce;Ot.produceWithPatches.bind(Ot);Ot.setAutoFreeze.bind(Ot);Ot.setUseStrictShallowCopy.bind(Ot);Ot.applyPatches.bind(Ot);Ot.createDraft.bind(Ot);Ot.finishDraft.bind(Ot);const bd=y.createContext(void 0),BI={};function ya(){const e=y.useContext(bd);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function JI({children:e}){const{installation:t}=rt(),{hydratedRevision:n,loading:r}=Gr(),[o,i]=y.useState(BI),s=t==null?void 0:t.config;y.useEffect(()=>{n!=null&&n.content&&!r&&s&&!(Object.entries(o).length>0)&&pv(n,s,i)},[n,r,s,o]);const a=y.useCallback((h,w)=>{i(v=>ti(v,p=>{p[h]=ti(p[h],w)}))},[i]),c=y.useCallback((h,w)=>{i(v=>ti(v,p=>{p[h]=w}))},[i]),f=y.useCallback(()=>{i(ti(h=>{const w=h.other.write;w&&(w.isWriteModified=!1)}))},[i]),u=y.useCallback(h=>{i(ti(w=>{var p;const v=(p=w[h])==null?void 0:p.read;v&&(v.isOptionalFieldsModified=!1,v.isRequiredMapFieldsModified=!1,v.isValueMappingsModified=!1)}))},[i]),d=y.useCallback(h=>{h===dr?f():u(h)},[u,f]),g=y.useMemo(()=>({objectConfigurationsState:o,setObjectConfigurationsState:i,setConfigureState:a,resetConfigureState:c,resetPendingConfigurationState:d}),[o,c,d,a]);return l.jsx(bd.Provider,{value:g,children:e})}const Xt=()=>{const{appName:e}=Te(),{objectConfigurationsState:t,setConfigureState:n}=ya(),{selectedObjectName:r}=pd(),o=du(r||"",t);return{appName:e,configureState:o,setConfigureState:n,selectedObjectName:r}};function WI(e,t){var r;const n=((r=e==null?void 0:e.read)==null?void 0:r.selectedFieldMappings)||{};if(t.forEach(o=>{const{field:i,value:s}=o;s===null?delete n[i]:n[i]=s}),e!=null&&e.read){const o=e.read.savedConfig.requiredMapFields,s=!ou(o,n);e.read.isRequiredMapFieldsModified=s}}function fi(e,t,n){t(e,r=>WI(r,n))}const zI="Each field must be mapped to a unique value";function va({field:e,onSelectChange:t,allFields:n}){var m;const{configureState:r,selectedObjectName:o,setConfigureState:i}=Xt(),[s,a]=y.useState(!0),{isError:c,removeError:f,getError:u}=Ft(),d=(m=r==null?void 0:r.read)==null?void 0:m.selectedFieldMappings,g=d==null?void 0:d[e.mapToName];y.useEffect(()=>{e._default&&!g&&o&&r&&fi(o,i,[{field:e.mapToName,value:e._default}]),a(!1)},[e,i,o,g,r]);const h=y.useMemo(()=>n.map(I=>({id:I.fieldName,label:I.displayName,value:I.fieldName})),[n]),w=l.jsx(td,{disabled:s,items:h,selectedValue:g||null,onSelectedItemChange:I=>{t({target:{name:e.mapToName,value:I==null?void 0:I.value}})},placeholder:"Please select one",style:{width:"100%"}}),v=y.useCallback(()=>{o&&(fi(o,i,[{field:e.mapToName,value:null}]),c(ue.MAPPING,o)&&f(ue.MAPPING,o))},[e.mapToName,o,i,c,f]),{hasDuplicationError:p,errorMessage:x}=y.useMemo(()=>{const I=u(ue.MAPPING,o),_=Array.isArray(I)&&I.length>0&&I.includes(e.mapToName);return{hasDuplicationError:_,errorMessage:_?zI:""}},[o,u,e.mapToName]);return l.jsxs(l.Fragment,{children:[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??e.mapToName}),l.jsx("span",{children:(e==null?void 0:e.prompt)&&l.jsx(PI,{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:[w,l.jsx(ze,{type:"button",variant:"ghost",onClick:v,children:"Clear"})]})]},e.mapToName),p&&l.jsxs("span",{style:{color:"red",fontSize:"14px",marginTop:"4px"},children:[" ",x," "]},e.mapToName)]})}const GI="_formControl_9qd8d_1",QI="_formLabel_9qd8d_5",XI="_formLabelRequired_9qd8d_11",YI="_formInput_9qd8d_16",ZI="_formInputInvalid_9qd8d_20",eb="_formError_9qd8d_24",tb="_disabled_9qd8d_30",Qn={formControl:GI,formLabel:QI,formLabelRequired:XI,formInput:YI,formInputInvalid:ZI,formError:eb,disabled:tb};function Eo({id:e,label:t,isRequired:n=!1,isDisabled:r=!1,isInvalid:o=!1,errorMessage:i,children:s}){return l.jsxs("div",{className:Pt(Qn.formControl,{[Qn.disabled]:r}),children:[t&&l.jsx("label",{htmlFor:e,className:Pt(Qn.formLabel,{[Qn.formLabelRequired]:n}),children:t}),l.jsx("div",{id:e,className:Pt(Qn.formInput,{[Qn.formInputInvalid]:o}),children:s}),o&&i&&l.jsx("div",{className:Qn.formError,role:"alert",children:i})]})}const nb="_divider_1kmoj_1",Vc={divider:nb};function So({className:e,style:t}){return l.jsx("hr",{className:e?`${Vc.divider} ${e}`:Vc.divider,style:t})}function Et({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(So,{style:{width:"100%",marginLeft:"1rem"}})})]})}function xd({selectedFieldMappings:e,selectedObjectName:t,fieldName:n,fieldValue:r,setError:o}){if(!e||!t)return!1;if(Object.values(e).some(s=>s===r&&s!==n)){console.error("Each field must be mapped to a unique value",e);const s=Object.keys(e).filter(c=>e[c]===r),a=[n,...s];return o(ue.MAPPING,t,a),!0}return!1}function rb({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(Eo,{id:r.mapToName,children:l.jsx(va,{allFields:n,field:r,onSelectChange:t})},r.mapToName))}):null}function ib(){var w,v;const{selectedObjectName:e,configureState:t,setConfigureState:n}=Xt(),{isError:r,removeError:o,setError:i}=Ft(),s=((w=t==null?void 0:t.read)==null?void 0:w.allFields)||[],{fieldMapping:a}=rt(),c=(v=t==null?void 0:t.read)==null?void 0:v.selectedFieldMappings,f=p=>{const{value:x,name:m}=p.target;!x||xd({selectedFieldMappings:c,selectedObjectName:e,fieldName:m,fieldValue:x,setError:i})||(e&&fi(e,n,[{field:m,value:x}]),r(ue.MAPPING,m)&&o(ue.MAPPING,m),e&&r(ue.MAPPING,e)&&o(ue.MAPPING,e))},u=y.useMemo(()=>!e||!a?[]:Object.values(a[e]||{}).flat().filter(p=>!p.fieldName),[a,e]),d=y.useMemo(()=>{var m;return(((m=t==null?void 0:t.read)==null?void 0:m.optionalMapFields)||[]).filter(I=>!u.some(_=>_.mapToName===I.mapToName))},[t,u]),g=u.length>0;return d.length>0||g?l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Map the following optional fields"}),l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:[d==null?void 0:d.map(p=>l.jsx(Eo,{id:p.mapToName,children:l.jsx(va,{allFields:s,field:p,onSelectChange:f})},p.mapToName)),g&&l.jsx(rb,{dynamicFieldMappings:u,onSelectChange:f,allFields:s})]})]}):null}function ob(){var f;const{selectedObjectName:e,configureState:t,setConfigureState:n}=Xt(),{isError:r,removeError:o,setError:i}=Ft(),s=(f=t==null?void 0:t.read)==null?void 0:f.selectedFieldMappings,a=u=>{const{value:d,name:g}=u.target;!d||xd({selectedFieldMappings:s,selectedObjectName:e,fieldName:g,fieldValue:d,setError:i})||(e&&fi(e,n,[{field:g,value:d}]),r(ue.MAPPING,g)&&o(ue.MAPPING,g),e&&r(ue.MAPPING,e)&&o(ue.MAPPING,e))},c=y.useMemo(()=>{var u;return((u=t==null?void 0:t.read)==null?void 0:u.requiredMapFields)||[]},[t]);return c!=null&&c.length?l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Map the following fields"}),l.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:c.map(u=>{var d;return l.jsx(Eo,{id:u.mapToName,isInvalid:r(ue.MAPPING,u.mapToName),errorMessage:"* required",children:l.jsx(va,{allFields:((d=t==null?void 0:t.read)==null?void 0:d.allFields)||[],field:u,onSelectChange:a})},u.mapToName)})})]}):null}const sb=(e,t)=>e.filter(n=>!t.has(n));function ab(){var g,h,w;const{selectedObjectName:e,configureState:t,setConfigureState:n}=Xt(),{fieldMapping:r}=rt(),o=((g=t==null?void 0:t.read)==null?void 0:g.selectedFieldMappings)||{},i=Object.keys(o),s=((h=t==null?void 0:t.read)==null?void 0:h.requiredMapFields)||[],a=((w=t==null?void 0:t.read)==null?void 0:w.optionalMapFields)||[],c=e&&r?Object.values(r[e]||{}).flat().filter(v=>!v.fieldName):[],f=s.concat(c,a).map(v=>v.mapToName),u=new Set(f),d=sb(i,u);y.useEffect(()=>{e&&d.length&&fi(e,n,d.map(v=>({field:v,value:null})))},[e,n,d])}const cb={backgroundColor:"var(--amp-colors-bg-highlight)",borderColor:"var(--amp-colors-bg-highlight)",padding:".5rem 1rem"};function lb({children:e,style:t}){return l.jsx(vn,{style:{...cb,...t},children:e})}const _i=e=>{const t=ut(),{provider:n}=rt(),r=e||n;return yn({queryKey:["amp","providerInfo",r],queryFn:async()=>{if(!r)throw new Error("Provider not found");return(await t()).providerApi.getProvider({provider:r})},enabled:!!r})},at=e=>{const t=_i(e),{data:n}=t,{provider:r}=rt(),o=n&&Gl(n==null?void 0:n.name,n);return{...t,providerName:o,selectedProvider:e||r}};function ub(){var f,u,d;const{project:e}=Te(),{hydratedRevision:t}=Gr(),{selectedObjectName:n}=Xt(),{providerName:r}=at(),o=e==null?void 0:e.appName,i=(d=(u=(f=t==null?void 0:t.content)==null?void 0:f.read)==null?void 0:u.objects)==null?void 0:d.find(g=>g.objectName===n),s=(i==null?void 0:i.displayName)||n&&Un(n),a=i==null?void 0:i.mapToName,c=(i==null?void 0:i.mapToDisplayName)||a&&Un(a);return c&&o&&r?l.jsx(lb,{style:{marginTop:"1rem"},children:l.jsxs("p",{style:{margin:"1rem 0"},children:[l.jsx("b",{children:c})," in ",o," is mapped to"," ",l.jsx("b",{children:s})," in ",r,"."]})}):null}function Uc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function db(...e){return t=>{let n=!1;const r=e.map(o=>{const i=Uc(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():Uc(e[o],null)}}}}function gr(...e){return M.useCallback(db(...e),e)}function No(e,t=[]){let n=[];function r(i,s){const a=M.createContext(s),c=n.length;n=[...n,s];const f=d=>{var x;const{scope:g,children:h,...w}=d,v=((x=g==null?void 0:g[e])==null?void 0:x[c])||a,p=M.useMemo(()=>w,Object.values(w));return l.jsx(v.Provider,{value:p,children:h})};f.displayName=i+"Provider";function u(d,g){var v;const h=((v=g==null?void 0:g[e])==null?void 0:v[c])||a,w=M.useContext(h);if(w)return w;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[f,u]}const o=()=>{const i=n.map(s=>M.createContext(s));return function(a){const c=(a==null?void 0:a[e])||i;return M.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,fb(o,...t)]}function fb(...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:f})=>{const d=c(i)[`__scope${f}`];return{...a,...d}},{});return M.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Wt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}var pi=globalThis!=null&&globalThis.document?M.useLayoutEffect:()=>{},pb=M[" useInsertionEffect ".trim().toString()]||pi;function wa({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,s]=hb({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const u=M.useRef(e!==void 0);M.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const f=M.useCallback(u=>{var d;if(a){const g=mb(u)?u(e):u;g!==e&&((d=s.current)==null||d.call(s,g))}else i(u)},[a,e,i,s]);return[c,f]}function hb({defaultProp:e,onChange:t}){const[n,r]=M.useState(e),o=M.useRef(n),i=M.useRef(t);return pb(()=>{i.current=t},[t]),M.useEffect(()=>{var s;o.current!==n&&((s=i.current)==null||s.call(i,n),o.current=n)},[n,o]),[n,r,i]}function mb(e){return typeof e=="function"}function gb(e){const t=M.useRef({value:e,previous:e});return M.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function yb(e){const[t,n]=M.useState(void 0);return pi(()=>{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,f=Array.isArray(c)?c[0]:c;s=f.inlineSize,a=f.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 vb(e,t){return M.useReducer((n,r)=>t[n][r]??n,e)}var Ia=e=>{const{present:t,children:n}=e,r=wb(t),o=typeof n=="function"?n({present:r.isPresent}):M.Children.only(n),i=gr(r.ref,Ib(o));return typeof n=="function"||r.isPresent?M.cloneElement(o,{ref:i}):null};Ia.displayName="Presence";function wb(e){const[t,n]=M.useState(),r=M.useRef(null),o=M.useRef(e),i=M.useRef("none"),s=e?"mounted":"unmounted",[a,c]=vb(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return M.useEffect(()=>{const f=Wi(r.current);i.current=a==="mounted"?f:"none"},[a]),pi(()=>{const f=r.current,u=o.current;if(u!==e){const g=i.current,h=Wi(f);e?c("MOUNT"):h==="none"||(f==null?void 0:f.display)==="none"?c("UNMOUNT"):c(u&&g!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),pi(()=>{if(t){let f;const u=t.ownerDocument.defaultView??window,d=h=>{const v=Wi(r.current).includes(h.animationName);if(h.target===t&&v&&(c("ANIMATION_END"),!o.current)){const p=t.style.animationFillMode;t.style.animationFillMode="forwards",f=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=p)})}},g=h=>{h.target===t&&(i.current=Wi(r.current))};return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(f),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:M.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function Wi(e){return(e==null?void 0:e.animationName)||"none"}function Ib(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)}function Ms(e){const t=bb(e),n=M.forwardRef((r,o)=>{const{children:i,...s}=r,a=M.Children.toArray(i),c=a.find(Cb);if(c){const f=c.props.children,u=a.map(d=>d===c?M.Children.count(f)>1?M.Children.only(null):M.isValidElement(f)?f.props.children:null:d);return l.jsx(t,{...s,ref:o,children:M.isValidElement(f)?M.cloneElement(f,void 0,u):null})}return l.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function bb(e){const t=M.forwardRef((n,r)=>{const{children:o,...i}=n,s=M.isValidElement(o)?Ob(o):void 0,a=gr(s,r);if(M.isValidElement(o)){const c=_b(i,o.props);return o.type!==M.Fragment&&(c.ref=a),M.cloneElement(o,c)}return M.Children.count(o)>1?M.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var xb=Symbol("radix.slottable");function Cb(e){return M.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===xb}function _b(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)=>{const c=i(...a);return o(...a),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Ob(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 Eb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],wn=Eb.reduce((e,t)=>{const n=Ms(`Primitive.${t}`),r=M.forwardRef((o,i)=>{const{asChild:s,...a}=o,c=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),To="Checkbox",[Sb,d_]=No(To),[Nb,ba]=Sb(To);function Tb(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:o,disabled:i,form:s,name:a,onCheckedChange:c,required:f,value:u="on",internal_do_not_use_render:d}=e,[g,h]=wa({prop:n,defaultProp:o??!1,onChange:c,caller:To}),[w,v]=M.useState(null),[p,x]=M.useState(null),m=M.useRef(!1),I=w?!!s||!!w.closest("form"):!0,_={checked:g,disabled:i,setChecked:h,control:w,setControl:v,name:a,form:s,value:u,hasConsumerStoppedPropagationRef:m,required:f,defaultChecked:Vn(o)?!1:o,isFormControl:I,bubbleInput:p,setBubbleInput:x};return l.jsx(Nb,{scope:t,..._,children:Rb(d)?d(_):r})}var Cd="CheckboxTrigger",_d=M.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},o)=>{const{control:i,value:s,disabled:a,checked:c,required:f,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:g,isFormControl:h,bubbleInput:w}=ba(Cd,e),v=gr(o,u),p=M.useRef(c);return M.useEffect(()=>{const x=i==null?void 0:i.form;if(x){const m=()=>d(p.current);return x.addEventListener("reset",m),()=>x.removeEventListener("reset",m)}},[i,d]),l.jsx(wn.button,{type:"button",role:"checkbox","aria-checked":Vn(c)?"mixed":c,"aria-required":f,"data-state":Nd(c),"data-disabled":a?"":void 0,disabled:a,value:s,...r,ref:v,onKeyDown:Wt(t,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Wt(n,x=>{d(m=>Vn(m)?!0:!m),w&&h&&(g.current=x.isPropagationStopped(),g.current||x.stopPropagation())})})});_d.displayName=Cd;var xa=M.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:c,onCheckedChange:f,form:u,...d}=e;return l.jsx(Tb,{__scopeCheckbox:n,checked:o,defaultChecked:i,disabled:a,required:s,onCheckedChange:f,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:g})=>l.jsxs(l.Fragment,{children:[l.jsx(_d,{...d,ref:t,__scopeCheckbox:n}),g&&l.jsx(Sd,{__scopeCheckbox:n})]})})});xa.displayName=To;var Od="CheckboxIndicator",Ca=M.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=ba(Od,n);return l.jsx(Ia,{present:r||Vn(i.checked)||i.checked===!0,children:l.jsx(wn.span,{"data-state":Nd(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});Ca.displayName=Od;var Ed="CheckboxBubbleInput",Sd=M.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:o,checked:i,defaultChecked:s,required:a,disabled:c,name:f,value:u,form:d,bubbleInput:g,setBubbleInput:h}=ba(Ed,e),w=gr(n,h),v=gb(i),p=yb(r);M.useEffect(()=>{const m=g;if(!m)return;const I=window.HTMLInputElement.prototype,C=Object.getOwnPropertyDescriptor(I,"checked").set,S=!o.current;if(v!==i&&C){const R=new Event("click",{bubbles:S});m.indeterminate=Vn(i),C.call(m,Vn(i)?!1:i),m.dispatchEvent(R)}},[g,v,i,o]);const x=M.useRef(Vn(i)?!1:i);return l.jsx(wn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??x.current,required:a,disabled:c,name:f,value:u,form:d,...t,tabIndex:-1,ref:w,style:{...t.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Sd.displayName=Ed;function Rb(e){return typeof e=="function"}function Vn(e){return e==="indeterminate"}function Nd(e){return Vn(e)?"indeterminate":e?"checked":"unchecked"}function Td(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 Ab=["color"],Rd=y.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=Td(e,Ab);return y.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}),y.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Pb=["color"],Fb=y.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=Td(e,Pb);return y.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}),y.createElement("path",{d:"M2 7.5C2 7.22386 2.22386 7 2.5 7H12.5C12.7761 7 13 7.22386 13 7.5C13 7.77614 12.7761 8 12.5 8H2.5C2.22386 8 2 7.77614 2 7.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))});const Db="_checkboxGroupContainer_1ya1t_1",Mb="_stack_1ya1t_6",kb="_selectAllContainer_1ya1t_11",jb="_fieldContainer_1ya1t_18",Lb="_checkbox_1ya1t_1",Hr={checkboxGroupContainer:Db,stack:Mb,selectAllContainer:kb,fieldContainer:jb,checkbox:Lb};function Ad({id:e,isChecked:t,label:n,onCheckedChange:r}){return l.jsxs("div",{className:Hr.fieldContainer,children:[l.jsx(xa,{className:Hr.checkbox,id:e,onCheckedChange:r,checked:t,children:l.jsx(Ca,{children:l.jsx(Rd,{})})}),l.jsx("label",{htmlFor:e,style:{overflowWrap:"anywhere"},children:n})]})}function Pd({id:e,isChecked:t,label:n,onCheckedChange:r,isIndeterminate:o}){return l.jsxs("div",{className:Hr.selectAllContainer,children:[l.jsx(xa,{className:Hr.checkbox,id:e,onCheckedChange:r,children:l.jsxs(Ca,{children:[o&&l.jsx(Fb,{}),t===!0&&l.jsx(Rd,{})]})}),l.jsx("label",{htmlFor:e,children:n})]})}function Fd({children:e}){return l.jsx("div",{className:Hr.checkboxGroupContainer,children:e})}function Dd({children:e}){return l.jsx("div",{className:Hr.stack,children:e})}function Kb(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=!ou(s,r);e.read.isOptionalFieldsModified=c}else console.warn("read.savedConfig.optionalFields is undefined")}function $c(e,t,n,r){t(e,o=>Kb(o,n,r))}function Vb(){var d,g;const{appName:e,configureState:t,setConfigureState:n,selectedObjectName:r}=Xt(),o=(d=t==null?void 0:t.read)==null?void 0:d.selectedOptionalFields,i=(h,w)=>{h!=="indeterminate"&&r&&t&&$c(r,n,w,h)},s=(g=t==null?void 0:t.read)==null?void 0:g.optionalFields,a=h=>{r&&s&&s.forEach(w=>{$n(w)||$c(r,n,w.fieldName,h)})},c=!!(s&&s.length>0),f=Object.keys(o||{}).length===(s==null?void 0:s.length),u=!f&&Object.keys(o||{}).length>0;return c&&l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:`${e} reads the following optional fields`}),l.jsxs(Fd,{children:[((s==null?void 0:s.length)||0)>=2&&l.jsx(Pd,{id:"select-all-fields",isChecked:f,label:"Select all",onCheckedChange:a,isIndeterminate:u}),l.jsx(Dd,{children:s.map(h=>$n(h)?null:l.jsx(Ad,{id:h.fieldName,isChecked:!!(o!=null&&o[h==null?void 0:h.fieldName]),label:h.displayName,onCheckedChange:w=>i(w,h.fieldName)},h.fieldName))})]})]})}function Ub(){return l.jsx(Vb,{})}const $b={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 qb({children:e,style:t,...n}){return l.jsx("span",{style:{...$b,...t},...n,children:e})}function Hb(){var n,r,o;const{configureState:e}=Xt(),{appName:t}=Te();return l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:`${t} reads the following fields`}),l.jsx("div",{style:{display:"flex",gap:".5rem",marginBottom:".5rem",flexWrap:"wrap"},children:(r=(n=e==null?void 0:e.read)==null?void 0:n.requiredFields)!=null&&r.length?(o=e.read)==null?void 0:o.requiredFields.map(i=>$n(i)?null:l.jsx(qb,{children:i.displayName},i.fieldName)):"There are no required fields."})]})}function Bb(e,t,n,r,o){e.read&&(e.read.selectedValueMappings||(e.read.selectedValueMappings={}),e.read.selectedValueMappings[o]||(e.read.selectedValueMappings[o]={}),r===""&&e.read.selectedValueMappings[o][n]?delete e.read.selectedValueMappings[o][n]:e.read.selectedValueMappings[o][n]=r)}function Md(e,t,n,r,o){t(e,i=>Bb(i,e,n,r,o))}function Jb(e,t,n){t(e,r=>{r.read&&(r.read.isValueMappingsModified=n)})}function Wb({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(So,{style:{width:"100%",marginLeft:"1rem"}})})]})}function zb({mappedValue:e,onSelectChange:t,fieldName:n,allValueOptions:r,hasError:o}){var C;const{configureState:i,selectedObjectName:s,setConfigureState:a}=Xt(),[c,f]=y.useState(!0),{getError:u,setError:d,resetBoundary:g,isError:h,removeError:w}=Ft(),v=y.useMemo(()=>{var S,R;return((R=(S=i==null?void 0:i.read)==null?void 0:S.selectedValueMappings)==null?void 0:R[n])||{}},[(C=i==null?void 0:i.read)==null?void 0:C.selectedValueMappings,n]),p=y.useMemo(()=>v==null?void 0:v[e.mappedValue],[v,e.mappedValue]);y.useEffect(()=>{f(!1)},[e,a,s,p,i]);const x=y.useMemo(()=>r.map(S=>({id:S.value,label:S.displayValue,value:S.value})),[r]),m=y.useCallback(S=>{if(S){if(Object.values(v).some(R=>R===S.value&&R!==p)){const R=[...Object.entries(v).filter(([N,A])=>A===S.value&&A!==p).map(([N])=>N),e.mappedValue];d(ue.VALUE_MAPPING,n,R);return}u(ue.VALUE_MAPPING,n)&&g(ue.VALUE_MAPPING),t({target:{name:e.mappedValue,value:S.value,fieldName:n}})}},[t,v,p,n,e.mappedValue,g,d,u]),I=y.useMemo(()=>l.jsx(td,{disabled:c,items:x,selectedValue:p||null,onSelectedItemChange:m,placeholder:"Please select one",style:{border:o?"2px solid red":void 0,borderRadius:"8px",width:"100%"}},p),[p,c,x,m,o]),_=y.useCallback(()=>{s&&(Md(s,a,e.mappedValue,"",n),h(ue.VALUE_MAPPING,n)&&w(ue.VALUE_MAPPING,n))},[s,a,e.mappedValue,n,h,w]);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})}),l.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[I,l.jsx(ze,{type:"button",variant:"ghost",onClick:_,children:"Clear"})]})]},e.mappedValue)}function Gb(){var h,w,v;const{fieldMapping:e}=rt(),{selectedObjectName:t,configureState:n,setConfigureState:r}=Xt(),{isError:o,removeError:i,getError:s}=Ft(),a=(h=n==null?void 0:n.read)==null?void 0:h.selectedFieldMappings,c=(w=n==null?void 0:n.read)==null?void 0:w.selectedValueMappings,f=(v=n==null?void 0:n.read)==null?void 0:v.isValueMappingsModified,u=y.useRef(!1),d=y.useMemo(()=>{const p=t&&e?Object.values(e[t]||{}).flat().filter(x=>x.mappedValues).map(x=>({...x})):[];if(a)for(let x=0;x<p.length;x+=1){const{mapToName:m}=p[x];a!=null&&a[m]&&(p[x].fieldName=a[m])}return p},[t,e,a]),g=y.useCallback(p=>{const{value:x,name:m,fieldName:I}=p.target;x&&(t&&Md(t,r,m,x,I),o(ue.VALUE_MAPPING,m)&&i(ue.VALUE_MAPPING,m))},[t,r,o,i]);return y.useEffect(()=>{var p;if(t&&c){const x=((p=e==null?void 0:e[t])==null?void 0:p.filter(I=>I.fieldName&&I.mappedValues.length>0))||[];x.every(I=>{const _=c[I.fieldName]||{};return Object.keys(_).length===Object.keys(I.mappedValues).length})&&x.length>0?!f&&!u.current&&(Jb(t,r,!0),u.current=!0):u.current=!1}},[c,d,t,r,e,f]),d!=null&&d.length?l.jsx(l.Fragment,{children:d.map(p=>{var S,R,N;if(!p.fieldName)return null;const x=(R=(S=n==null?void 0:n.read)==null?void 0:S.allFieldsMetadata)==null?void 0:R[p.fieldName],m=x==null?void 0:x.valueType;if(!["singleSelect","multiSelect"].includes(m))return console.error("fieldName is not a singleSelect or multiSelect",p),null;const I=x==null?void 0:x.values;if(!I)return null;const _=Object.keys(I).length,C=Object.keys((p==null?void 0:p.mappedValues)||[]).length;return _!==C?(console.error("field values and the values to be mapped are not of the same length",p,I),null):l.jsxs(l.Fragment,{children:[l.jsx(Wb,{string:"Map the values for ",fieldName:p.mapToDisplayName||p.mapToName||p.fieldName}),l.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:l.jsx(Eo,{id:p.mapToName||p.fieldName,children:(N=p==null?void 0:p.mappedValues)==null?void 0:N.map(A=>{var ee,q,ae;const K=s(ue.VALUE_MAPPING,p.fieldName),z=Array.isArray(K)&&K.includes(A.mappedValue),H=((ae=(q=(ee=n==null?void 0:n.read)==null?void 0:ee.allFieldsMetadata)==null?void 0:q[p.fieldName])==null?void 0:ae.values)||[];return l.jsxs(l.Fragment,{children:[l.jsx(zb,{allValueOptions:H,mappedValue:A,onSelectChange:g,fieldName:(p==null?void 0:p.fieldName)||"",hasError:z},`${A.mappedValue}-${p.fieldName}`),z&&l.jsx("span",{style:{color:"red",fontSize:"14px",marginTop:"4px"},children:`Each ${p.mapToName||p.fieldName} must be mapped to a unique value`},A.mappedValue)]})})},p.mapToName||p.fieldName)})]})})}):null}function Qb(){return ab(),l.jsxs(l.Fragment,{children:[l.jsx(ub,{}),l.jsx(Hb,{}),l.jsx(ob,{}),l.jsx(ib,{}),l.jsx(Gb,{}),l.jsx(Ub,{})]})}function Xb(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,f=!uv(a,s);e.write.isWriteModified=f}}}function qc(e,t,n,r){t(e,o=>{Xb(o,n,r)})}function Yb(){var d,g,h,w;const{appName:e,selectedObjectName:t,configureState:n,setConfigureState:r}=Xt(),o=(d=n==null?void 0:n.write)==null?void 0:d.selectedWriteObjects,i=(g=n==null?void 0:n.write)==null?void 0:g.writeObjects,s=(v,p)=>{v!=="indeterminate"&&t&&n&&qc(t,r,p,v)},a=v=>{var p,x;t&&n&&((x=(p=n==null?void 0:n.write)==null?void 0:p.writeObjects)==null||x.forEach(m=>{qc(t,r,m.objectName,v)}))},c=!!i,f=Object.keys(o||{}).length===((w=(h=n==null?void 0:n.write)==null?void 0:h.writeObjects)==null?void 0:w.length),u=!f&&Object.keys(o||{}).length>0;return c&&l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:`Allow ${e} to write to these objects`}),l.jsxs(Fd,{children:[((i==null?void 0:i.length)||0)>=2&&l.jsx(Pd,{id:"select-all-fields",onCheckedChange:a,isIndeterminate:u,isChecked:f,label:"Select all"}),l.jsx(Dd,{children:i.map(v=>l.jsx(Ad,{id:v.objectName,onCheckedChange:p=>s(p,v.objectName),isChecked:!!(o!=null&&o[v.objectName]),label:v.displayName},v.objectName))})]})]})}function Zb(){return l.jsx(l.Fragment,{children:l.jsx(Yb,{})})}const ex="_authenticationRow_cjz1t_1",tx="_field_cjz1t_8",nx="_value_cjz1t_12",Yo={authenticationRow:ex,field:tx,value:nx};function Hc({label:e,value:t}){return l.jsxs("div",{className:Yo.authenticationRow,children:[l.jsx("div",{className:Yo.field,children:e}),l.jsx("div",{className:Yo.value,children:t})]})}function rx(){const{selectedConnection:e}=Qt(),{providerName:t}=at(),r=(e==null?void 0:e.provider)==="salesforce"?"subdomain":"workspace",o=`${t} ${r}`;return l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Connection details"}),l.jsxs("div",{style:{paddingBottom:"1rem"},children:[l.jsx(Hc,{label:o,value:e==null?void 0:e.providerWorkspaceRef}),l.jsx(Hc,{label:"Status",value:e==null?void 0:e.status})]})]})}const ix=()=>{const e=ut(),t=vt();return Jr({mutationFn:async({projectIdOrName:n,integrationId:r,installationId:o})=>(await e()).installationApi.deleteInstallation({projectIdOrName:n,integrationId:r,installationId:o}),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","installations"]})},onError:n=>{console.error("Error uninstalling installation."),Le(n)}})};function kd({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={}}){const{projectId:r}=Te(),{integrationId:o,installation:i,setIntegrationDeleted:s,onUninstallSuccess:a}=rt(),[c,f]=y.useState(!1),u=!r||!o||!(i!=null&&i.id)||c,d=ix(),g=async()=>{u||(f(!0),console.warn("uninstalling installation",{projectId:r,integrationId:o,installationId:i.id}),d.mutate({projectIdOrName:r,integrationId:o,installationId:i.id},{onSuccess:()=>{console.warn("successfully uninstalled installation:",i.id),a==null||a(i==null?void 0:i.id),s()},onSettled:()=>f(!1)}))},h=c?"Uninstalling...":e,w=l.jsx(ze,{type:"button",onClick:g,disabled:u,variant:t,style:n,children:h});return i!=null&&i.id?w:null}function ox(){const{installation:e}=rt(),{providerName:t}=at();return e?l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Uninstall entire integration"}),l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",padding:"1rem 0"},children:[e!=null&&e.id?l.jsxs("p",{style:{color:"var(--amp-colors-text-muted)"},children:["By clicking below, you will uninstall the entire ",t," ","integration. You will lose any configuration you've set up."]}):l.jsx("p",{children:"You've successfully uninstalled the integration."}),l.jsx(kd,{buttonText:"Yes, uninstall",buttonVariant:"danger"})]})]}):null}function In({error:e}){return e?l.jsx(Ii,{style:{marginTop:"2em"},children:e}):null}const sx="_input_1ymb7_1",ax="_inputError_1ymb7_27",cx="_error_1ymb7_43",Zo={input:sx,inputError:ax,error:cx};function lx({id:e,type:t,className:n,isError:r=!1,...o}){const i=r?Pt(Zo.inputError,Zo.input):Zo.input;return l.jsx("input",{id:e,type:t,className:Pt(i,n),...o})}const ux="_textarea_18zl4_1",dx="_textareaError_18zl4_14",fx="_error_18zl4_29",es={textarea:ux,textareaError:dx,error:fx};function px({className:e,isError:t=!1,...n}){const r=t?Pt(es.textareaError,es.textarea):es.textarea;return l.jsx("textarea",{className:Pt(e,r),...n})}const Bt={Input:lx,Textarea:px},hx=()=>{const{project:e}=Te(),t=e==null?void 0:e.id,n=ut();return yn({queryKey:["project",t,"entitlements"],queryFn:async()=>{if(!t)throw new Error("Project ID is required");return(await n()).projectApi.getProject({projectIdOrName:t,includeEntitlements:!0})},enabled:!!t})};function jd(){var n,r;const{data:e}=hx();return((r=(n=e==null?void 0:e.entitlements)==null?void 0:n.brandingRemoval)==null?void 0:r.value)===!0?null: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 yr({children:e}){return l.jsx(Wr,{children:l.jsxs(vn,{children:[l.jsx("div",{style:{padding:"3rem 2rem"},children:e}),l.jsx(jd,{})]})})}function vr({children:e}){return l.jsx("h1",{style:{fontWeight:600,lineHeight:1.2,fontSize:"1.2em"},children:e})}function mx({children:e}){return l.jsx("p",{style:{padding:".5em 0"},children:e})}const gx="_link_oo2kv_1",yx={link:gx};function Ld({href:e,className:t,style:n,label:r,children:o,newTab:i=!1}){return l.jsx("a",{className:Pt(yx.link,t),style:n,href:e,"aria-label":r||void 0,target:i?"_blank":"_self",rel:i?"noopener noreferrer":void 0,children:o})}function mo({url:e,providerDisplayName:t,credentialName:n}){return l.jsxs("p",{style:{color:"var(--amp-colors-text-muted)"},children:[l.jsx(Ld,{href:e,newTab:!0,children:l.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," ","about where to find your ",t," ",n,"."]})}function _a(e,t){const n={},r=[];if(e.forEach(o=>{const i=t[o.name];!i||i.trim()===""?r.push(o.displayName||o.name):n[o.name]={value:i,source:"input"}}),r.length>0)throw new Error(`Please fill in the following required fields: ${r.join(", ")}.`);return n}function hi(e,t){return e.every(n=>{const r=t[n.name];return r&&r.trim()!==""})}function Kd({provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:r,buttonVariant:o,submitButtonType:i}){var _,C;const[s,a]=y.useState(!1),c=()=>a(S=>!S),[f,u]=y.useState({apiKey:""}),d=((_=t.metadata)==null?void 0:_.input)||[],g=S=>{const{name:R,value:N}=S.currentTarget;u(A=>({...A,[R]:N.trim()}))},{apiKey:h}=f,{providerName:w}=at(e),v=h.length>0,p=hi(d,f),x=r||!v||!p,m=(C=t.apiKeyOpts)==null?void 0:C.docsURL,I=()=>{const S=_a(d,f);n({apiKey:h,providerMetadata:S})};return l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[m&&l.jsx(mo,{url:m,providerDisplayName:w||Un(e),credentialName:"API key"}),l.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[l.jsx(Bt.Input,{id:"apiKey",name:"apiKey",type:s?"text":"password",placeholder:"API Key",onChange:g}),l.jsx(ze,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:c,variant:o,children:s?"Hide":"Show"})]}),d.map(S=>l.jsxs("div",{children:[S.docsURL&&l.jsx(mo,{url:S.docsURL,providerDisplayName:w||Un(e),credentialName:S.displayName||S.name}),l.jsx(Bt.Input,{id:S.name,name:S.name,type:"text",placeholder:S.displayName||S.name,onChange:g})]},S.name)),l.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:x,type:i||"submit",onClick:I,variant:o,children:"Next"})]})}function vx({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){const{providerName:i}=at(e);return l.jsxs(yr,{children:[l.jsx(vr,{children:`Set up ${i} integration`}),l.jsx(In,{error:r}),l.jsx(Kd,{provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:o})]})}function wx({...e}){return l.jsx(vx,{...e})}const Ix={backgroundColor:"var(--amp-colors-status-success-muted)",borderColor:"var(--amp-colors-status-success-muted)",color:"var(--amp-colors-status-success-dark)",padding:".5rem 1rem"};function Ro({children:e,style:t}){return l.jsx(vn,{style:{...Ix,...t},children:e})}const Oa=()=>{const e=ut(),t=vt(),[n,r]=y.useState(null);return{...Jr({mutationKey:["updateConnection"],mutationFn:async i=>(await e()).connectionApi.updateConnection(i),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","connections"]}),r(null)}}),errorMsg:n}};function bx({provider:e}){const{projectIdOrName:t}=Te(),{providerName:n,data:r}=at(e),{selectedConnection:o,isConnectionsLoading:i}=Qt(),{mutateAsync:s,isPending:a,error:c}=Oa(),[f,u]=y.useState(null),[d,g]=y.useState(!1),h=()=>g(!1),w=()=>{g(!0),u(null)},v=(c==null?void 0:c.message)||f||null,p=async x=>{h(),u(null);try{await s({projectIdOrName:t||"",connectionId:(o==null?void 0:o.id)||"",updateConnectionRequest:{updateMask:["apiKey"],connection:{apiKey:x.apiKey}}},{onError:m=>{console.error("Update connection error:",m),Le(m,u)},onSuccess:()=>{w()}})}catch(m){console.error("Update connection caught error:",m),Le(m,u)}};return r?l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Update connection"}),l.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[l.jsx("p",{children:`Update ${n} API Key`}),d&&l.jsx(Ro,{children:"Connection updated successfully"}),v&&l.jsx(Ii,{children:`Error updating connection ${v}`}),l.jsx(Kd,{provider:r==null?void 0:r.name,providerInfo:r,handleSubmit:p,isButtonDisabled:a||i,buttonVariant:"ghost",submitButtonType:"button"})]})]}):null}function Vd({provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:r,buttonVariant:o}){var I,_;const[i,s]=y.useState(!1),a=()=>s(C=>!C),[c,f]=y.useState({username:"",password:""}),u=((I=t.metadata)==null?void 0:I.input)||[],{username:d,password:g}=c,{providerName:h}=at(e),w=C=>{const{name:S,value:R}=C.currentTarget;f(N=>({...N,[S]:R.trim()}))},v=hi(u,c),p=r||!v,x=()=>{const C=_a(u,c);n({user:d,pass:g,providerMetadata:C})},m=(_=t.basicOpts)==null?void 0:_.docsURL;return l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[m&&l.jsx(mo,{url:m,providerDisplayName:h||Un(e),credentialName:"credentials"}),l.jsx(Bt.Input,{id:"username",name:"username",type:"text",placeholder:"Username",onChange:w}),l.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[l.jsx(Bt.Input,{id:"password",name:"password",type:i?"text":"password",placeholder:"Password",onChange:w}),l.jsx(ze,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:a,variant:o,children:i?"Hide":"Show"})]}),u.map(C=>l.jsxs("div",{children:[C.docsURL&&l.jsx(mo,{url:C.docsURL,providerDisplayName:h||Un(e),credentialName:C.displayName||C.name}),l.jsx(Bt.Input,{id:C.name,name:C.name,type:"text",placeholder:C.displayName||C.name,onChange:w})]},C.name)),l.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:p,type:"button",onClick:x,variant:o,children:"Next"})]})}function xx({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){const{providerName:i}=at(e);return l.jsxs(yr,{children:[l.jsx(vr,{children:`Set up ${i} integration`}),l.jsx(In,{error:r}),l.jsx(Vd,{provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:o})]})}function Cx({...e}){return l.jsx(xx,{...e})}function _x({provider:e}){const{projectIdOrName:t}=Te(),{providerName:n,data:r}=at(e),{selectedConnection:o,isConnectionsLoading:i}=Qt(),{mutateAsync:s,isPending:a,error:c}=Oa(),[f,u]=y.useState(null),[d,g]=y.useState(!1),h=()=>g(!1),w=()=>{g(!0),u(null)},v=(c==null?void 0:c.message)||f||null,p=async x=>{h(),u(null);try{await s({projectIdOrName:t||"",connectionId:(o==null?void 0:o.id)||"",updateConnectionRequest:{updateMask:["basicAuth"],connection:{basicAuth:{username:x.user,password:x.pass}}}},{onError:m=>{console.error(m),Le(m,u)},onSuccess:()=>{w()}})}catch(m){console.error(m),Le(m,u)}};return r?l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Update connection"}),l.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[l.jsx("p",{children:`Update ${n} credentials`}),d&&l.jsx(Ro,{children:"Connection updated successfully"}),v&&l.jsx(Ii,{children:`Error updating connection: ${v}`}),l.jsx(Vd,{provider:r==null?void 0:r.name,providerInfo:r,handleSubmit:p,isButtonDisabled:a||i,buttonVariant:"ghost"})]})]}):null}function Ud({provider:e,handleSubmit:t,isButtonDisabled:n,explicitScopesRequired:r,buttonVariant:o}){var R;const[i,s]=y.useState(!1),[a,c]=y.useState({clientSecret:"",clientId:"",scopes:""}),[f,u]=y.useState(null),{data:d}=_i(e),g=((R=d==null?void 0:d.metadata)==null?void 0:R.input)||[],h=()=>s(N=>!N),w=N=>{const{name:A,value:K}=N.currentTarget;c(z=>({...z,[A]:K.trim()})),u(null)},{clientSecret:v,clientId:p,scopes:x}=a,m=v.length>0,I=p.length>0,_=hi(g,a),C=n||!m||!I||!_,S=()=>{const N=_a(g,a),A={clientId:p,clientSecret:v,providerMetadata:N};r&&x.length>0&&(A.scopes=Xy(x)),t(A)};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.2rem"},children:[l.jsx(Bt.Input,{id:"clientId",name:"clientId",type:"text",placeholder:"Client ID",onChange:w}),l.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[l.jsx(Bt.Input,{id:"clientSecret",name:"clientSecret",type:i?"text":"password",placeholder:"Client Secret",onChange:w}),l.jsx(ze,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:h,variant:o,children:i?"Hide":"Show"})]}),r&&l.jsx(Bt.Textarea,{name:"scopes",placeholder:"Scopes separated by new line",onChange:w}),g.map(N=>l.jsx(Bt.Input,{id:N.name,name:N.name,type:"text",placeholder:N.displayName||N.name,onChange:w},N.name))]}),l.jsx(In,{error:f}),l.jsx("br",{}),l.jsx(ze,{style:{width:"100%"},disabled:C,type:"button",onClick:S,variant:o,children:"Next"})]})}function Ox({provider:e,handleSubmit:t,error:n,isButtonDisabled:r,providerName:o,explicitScopesRequired:i}){return l.jsxs(yr,{children:[l.jsx(vr,{children:`Set up ${o} integration`}),l.jsx(In,{error:n}),l.jsx("br",{}),l.jsx(Ud,{provider:e,handleSubmit:t,isButtonDisabled:r,explicitScopesRequired:i})]})}function Ex({provider:e}){var m;const{projectIdOrName:t}=Te(),{selectedConnection:n,isConnectionsLoading:r}=Qt(),{providerName:o,data:i}=at(e),{mutateAsync:s,isPending:a,error:c}=Oa(),[f,u]=y.useState(null),[d,g]=y.useState(!1),h=()=>{g(!1)},w=()=>{g(!0),u(null)},v=(m=i==null?void 0:i.oauth2Opts)==null?void 0:m.explicitScopesRequired,p=(c==null?void 0:c.message)||f||null,x=async I=>{h(),u(null);try{await s({projectIdOrName:t||"",connectionId:(n==null?void 0:n.id)||"",updateConnectionRequest:{updateMask:["oauth2ClientCredentials"],connection:{oauth2ClientCredentials:{clientId:I.clientId,clientSecret:I.clientSecret,scopes:I.scopes}}}}),w()}catch(_){Le(_,u)}};return l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Update connection"}),l.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[l.jsx("p",{children:`Re-authenticate to ${o}`}),d&&l.jsx(Ro,{children:"Connection updated successfully"}),p&&l.jsx(Ii,{children:`Error updating connection ${p}`}),l.jsx(Ud,{provider:o||"",handleSubmit:x,isButtonDisabled:a||r,explicitScopesRequired:v,buttonVariant:"ghost"})]})]})}const Bc=600,Jc=600,Sx="AUTHORIZATION_SUCCEEDED",Nx="AUTHORIZATION_FAILED";function Tx(e,t,n,r){return y.useCallback(()=>{if(!r)return;const o=window.screenX+(window.outerWidth-Bc)/2,i=window.screenY+(window.outerHeight-Jc)/2.5,s=`width=${Bc},height=${Jc},left=${o},top=${i}`,a=window.open(r,e,s);t(a),window.addEventListener("message",n,!1)},[r,e,t,n])}function Rx(e,t,n,r){const o=vt();return y.useCallback(i=>{var s,a;if(i.origin===Ty){if(i.data.eventType===Sx){const c=(s=i.data.data)==null?void 0:s.connection;c?(e(c),o.setQueriesData({queryKey:["amp","connections"]},()=>[c]),t==null||t.close(),r==null||r(),o.invalidateQueries({queryKey:["amp","connections"]})):console.error("Connection ID not found in event data: ",{event:i})}i.data.eventType===Nx&&(console.error("OAuth failed: ",{event:i}),n==null||n(((a=i==null?void 0:i.data)==null?void 0:a.message)??"Something went wrong. Please try again."))}},[t,n,o,e,r])}function Ea({children:e,oauthUrl:t,windowTitle:n="Connect to Provider",onError:r,error:o,onSuccessConnect:i,isSuccessConnect:s,onWindowClose:a}){const[c,f]=y.useState(null),[u,d]=y.useState(null),g=vt(),h=y.useRef(null),w=Rx(f,u,r,i),v=Tx(n,d,w,t);y.useEffect(()=>{t&&!u&&!c&&!o&&!s&&(r==null||r(null),v())},[t,u,v,c,o,s,r]);const p=y.useCallback(()=>{g.invalidateQueries({queryKey:["amp","connections"]}),d(null),!c&&!o?(console.error("Window closed and no connection was found. Please try again."),r==null||r("Window closed prematurely. Please wait and try again.")):c&&(r==null||r(null)),a==null||a(),setTimeout(()=>{window.removeEventListener("message",w)},1e3)},[c,o,r,a,w,g]);return y.useEffect(()=>{if(u)return h.current=setInterval(()=>{(!u||u.closed)&&(h.current&&clearInterval(h.current),h.current=null,p())},500),()=>{h.current&&(clearInterval(h.current),h.current=null),window.removeEventListener("message",w)}},[p,u,w]),l.jsx("div",{children:e})}const Ax=()=>{const e=ut(),t=vt();return Jr({mutationKey:["updateOauthConnection"],mutationFn:async n=>{const r=await e();if(!n.projectIdOrName||!n.connectionId)throw new Error("Project ID and connection ID are required");return r.oAuthApi.oauthUpdate(n)},onSuccess:()=>{t.invalidateQueries({queryKey:["connections"]})}})};function Px({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return l.jsxs("div",{style:{padding:"1rem 0"},children:[l.jsx("p",{children:`Re-authenticate to ${r}`}),l.jsx(In,{error:t}),l.jsx(ze,{variant:"ghost",style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function Fx({provider:e}){const{selectedConnection:t,isConnectionsLoading:n}=Qt(),r=t==null?void 0:t.id,o=t==null?void 0:t.projectId,{providerName:i}=at(e),{mutateAsync:s,isPending:a,error:c}=Ax(),[f,u]=y.useState(null),[d,g]=y.useState(!1),[h,w]=y.useState(null),v=()=>{g(!1)},p=()=>{g(!0),u(null),w(null)},x=(c==null?void 0:c.message)||f||null,m=async()=>{v(),u(null);try{const _=await s({projectIdOrName:o||"",connectionId:r||""});w(_)}catch(_){Le(_,u)}},I=y.useCallback(_=>{u(_)},[]);return l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Update connection"}),d&&l.jsx(Ro,{children:"Connection updated successfully"}),l.jsx(Ea,{windowTitle:`Connect to ${i}`,oauthUrl:h||null,onError:I,error:x,isSuccessConnect:d,onSuccessConnect:p,children:l.jsx(Px,{handleSubmit:m,error:x,providerName:i,isButtonDisabled:a||n||d})})]})}function $d({provider:e}){var r;const{data:t}=_i(e);if((t==null?void 0:t.authType)===Qa.Basic)return l.jsx(_x,{provider:e});if((t==null?void 0:t.authType)===Qa.ApiKey)return l.jsx(bx,{provider:e});const n=(r=t==null?void 0:t.oauth2Opts)==null?void 0:r.grantType;if(n){if(n===Ko.AuthorizationCode||n===Ko.AuthorizationCodePkce)return l.jsx(Fx,{provider:e});if(n===Ko.ClientCredentials)return l.jsx(Ex,{provider:e})}return null}function Dx(){return l.jsxs(l.Fragment,{children:[l.jsx(rx,{}),l.jsx($d,{}),l.jsx(ox,{})]})}function qd({onSave:e,onReset:t,isLoading:n,isCreateMode:r=!1,errorMsg:o}){var S,R,N,A;const{installation:i}=rt(),{hydratedRevision:s,loading:a}=Gr(),{configureState:c,selectedObjectName:f}=Xt(),u=i==null?void 0:i.config,d=u&&f&&!!tu(u,f)||!1,g=((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),h=(A=c==null?void 0:c.write)==null?void 0:A.isWriteModified,x=a||n||!c||!f||!(g||h||r||f!==dr&&!d),m=f===dr,I=f===ro,_=l.jsx(ze,{type:"submit",disabled:x,children:r?"Install":"Save"}),C=l.jsx(ze,{type:"button",onClick:t,disabled:x,variant:"ghost",children:"Reset"});return n?l.jsx(ci,{}):l.jsxs("form",{style:{width:"34rem"},onSubmit:e,children:[l.jsx("div",{style:{display:"flex",flexDirection:"row-reverse",gap:".8rem",marginBottom:"20px",height:"3rem"},children:!I&&l.jsxs(l.Fragment,{children:[_,C]})}),l.jsxs(vn,{style:{padding:"1rem 2rem",minHeight:"300px",backgroundColor:"var(--amp-colors-bg-primary)",borderColor:"var(--amp-colors-border)"},children:[o&&l.jsx(Ii,{children:typeof o=="string"?o:"Installation Failed."}),a&&l.jsx(ci,{}),s&&!m&&!I&&l.jsx(Qb,{}),s&&m&&!I&&l.jsx(Zb,{}),!a&&I&&l.jsx(Dx,{})]})]})}const Hd=()=>{const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,onInstallSuccess:o,onUpdateSuccess:i}=rt(),{hydratedRevision:s,loading:a}=Gr(),{selectedObjectName:c}=pd(),{selectedConnection:f}=Qt(),u=yl(),{projectId:d}=Te(),{resetBoundary:g,setErrors:h,setError:w,getError:v}=Ft(),{resetConfigureState:p,objectConfigurationsState:x,resetPendingConfigurationState:m}=ya(),I=du(c||"",x),{onNextIncompleteTab:_}=FI(),C=y.useCallback(()=>{g(ue.INSTALLATION_MUTATION)},[g]),S=y.useCallback(N=>N?A=>{w(ue.INSTALLATION_MUTATION,N,A)}:A=>{console.error("objectName is required to set installation error: ",A)},[w]),R=y.useCallback(N=>N?v(ue.INSTALLATION_MUTATION,N):"",[v]);return{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:s,loading:a,selectedObjectName:c,selectedConnection:f,apiKey:u,projectId:d,resetBoundary:g,setErrors:h,setMutateInstallationError:S,getMutateInstallationError:R,resetMutateInstallationErrorState:C,resetConfigureState:p,objectConfigurationsState:x,resetPendingConfigurationState:m,configureState:I,onInstallSuccess:o,onUpdateSuccess:i,onNextIncompleteTab:_}},Mx=void 0;function kx(){const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:o,loading:i,selectedObjectName:s,selectedConnection:a,apiKey:c,projectId:f,resetBoundary:u,setErrors:d,setMutateInstallationError:g,getMutateInstallationError:h,resetMutateInstallationErrorState:w,resetConfigureState:v,objectConfigurationsState:p,resetPendingConfigurationState:x,configureState:m,onInstallSuccess:I,onNextIncompleteTab:_}=Hd(),[C,S]=y.useState(!1),R=s===dr,N=h(s),A=y.useCallback(()=>{u(ue.MAPPING),o!=null&&o.content&&!i&&s&&au(o,Mx,s,v)},[u,o,i,s,v]);y.useEffect(()=>{!m&&(o!=null&&o.content)&&!i&&A()},[m,p,o,i,A]);const K=()=>{w();const{requiredMapFields:ee,selectedFieldMappings:q}=(m==null?void 0:m.read)||{},{errorList:ae}=iu(ee,q,d);ae.length>0||(s&&(a!=null&&a.id)&&c&&f&&e&&t&&n&&o?(S(!0),gv(f,e,t,n,a.id,s,c,o,m,g(s),r,I).finally(()=>{S(!1),x(s),_()})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},z=()=>{w(),s&&(a!=null&&a.id)&&c&&f&&e&&t&&n&&o?(S(!0),wv(f,e,t,n,a.id,c,o,m,g(s),r,I).finally(()=>{S(!1),x(s),_()})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},H=ee=>{ee.preventDefault(),R?z():K()};return l.jsx(qd,{errorMsg:N,isCreateMode:!0,isLoading:C,onSave:H,onReset:A})}function jx({updateConfig:e,projectId:t,integrationId:n,installationId:r,apiKey:o,selectedObjectName:i,setInstallation:s,onUpdateSuccess:a,setError:c}){const f={projectIdOrName:t,installationId:r,integrationId:n,installationUpdate:{updateMask:[`config.content.read.objects.${Zy(i)}`],installation:{config:e}}};return $s().installationApi.updateInstallation(f,{headers:{"X-Api-Key":o,"Content-Type":"application/json"}}).then(u=>{s(u),a==null||a(u.id,u.config)}).catch(u=>{Le(u,c)})}const Lx=(e,t,n,r,o,i)=>{const s=cu(e),a=lu(e),c=uu(e),f={content:{read:{objects:{[t]:{objectName:t,schedule:r,destination:(n==null?void 0:n.destination)||"",selectedFields:s,selectedFieldMappings:a,selectedValueMappings:c||{},backfill:i}}}}};return wi(o)&&(f.content||(f.content={}),f.content.proxy={enabled:!0}),f},Kx=(e,t,n,r,o,i,s,a,c,f,u)=>{const d=Lx(i,r||"",a,a.schedule,c,a.backfill);return d?jx({updateConfig:d,projectId:e,integrationId:t,installationId:n,apiKey:o,selectedObjectName:r,setError:f,setInstallation:s,onUpdateSuccess:u}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Vx=(e,t)=>{const r={content:{write:{objects:pu(e)}}};return wi(t)&&(r.content||(r.content={}),r.content.proxy={enabled:!0}),r},Ux=(e,t,n,r,o,i,s,a,c)=>{const f=Vx(o,i);if(!f)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const u={projectIdOrName:e,installationId:n,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:f}}};return $s().installationApi.updateInstallation(u,{headers:{"X-Api-Key":r,"Content-Type":"application/json"}}).then(d=>{a(d),c==null||c(d.id,d.config)}).catch(d=>{Le(d,s)})};function $x({installation:e,integrationObj:t}){const{setInstallation:n,hydratedRevision:r,loading:o,selectedObjectName:i,apiKey:s,projectId:a,resetBoundary:c,setErrors:f,setMutateInstallationError:u,getMutateInstallationError:d,resetConfigureState:g,resetPendingConfigurationState:h,configureState:w,onUpdateSuccess:v,onNextIncompleteTab:p}=Hd(),[x,m]=y.useState(!1),I=i===dr,_=d(i),{config:C}=e,S=y.useCallback(()=>{c(ue.MAPPING),r!=null&&r.content&&!o&&i&&au(r,C,i,g)},[c,r,o,i,C,g]);y.useEffect(()=>{w||S()},[w,S]);const R=y.useMemo(()=>{var H,ee,q;return(q=(ee=(H=r==null?void 0:r.content)==null?void 0:H.read)==null?void 0:ee.objects)==null?void 0:q.find(ae=>(ae==null?void 0:ae.objectName)===i)},[r,i]),N=()=>{const{requiredMapFields:z,selectedFieldMappings:H}=(w==null?void 0:w.read)||{},{errorList:ee}=iu(z,H,f);ee.length>0||(r&&e&&i&&s&&a&&R?(m(!0),Kx(a,t.id,e.id,i,s,w,n,R,r,u(i),v).finally(()=>{m(!1),h(i),p()})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},A=()=>{e&&i&&s&&a&&r?(m(!0),Ux(a,t.id,e.id,s,w,r,u(i),n,v).finally(()=>{m(!1),h(i),p()})):console.error("UpdateInstallation - onSaveUpdate missing required props")},K=z=>{z.preventDefault(),I?A():N()};return l.jsx(qd,{errorMsg:_,onSave:K,onReset:S,isLoading:x})}function qx(){const{integrationObj:e,installation:t}=rt();return e?t&&e?l.jsx($x,{installation:t,integrationObj:e}):l.jsx(kx,{}):l.jsx(Jl,{message:"We can't load the integration"})}const Hx=()=>{const e=ut(),t=vt(),[n,r]=y.useState(null);return{...Jr({mutationKey:["createInstallation"],mutationFn:async i=>(await e()).installationApi.createInstallation(i),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","installations"]}),r(null)},onError:i=>{console.error("Error creating installation"),Le(i,r)}}),errorMsg:n}};function Bx(){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 Sa({text:e,children:t}){return l.jsx(Wr,{children:l.jsxs(vn,{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"3rem",gap:"3rem"},children:[l.jsx(Bx,{}),l.jsx("p",{children:e}),t]})})}function Jx({provider:e}){const{providerName:t}=at(e),n=`You have successfully installed your ${t} integration.`;return l.jsx(Sa,{text:n,children:l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:l.jsx(kd,{buttonText:"Uninstall",buttonVariant:"outline",buttonStyle:{fontSize:"13px"}})})})}const Wx=e=>{const{read:t,write:n}=(e==null?void 0:e.content)??{};return!t&&!n};function zx({children:e}){var C;const t=y.useRef(!1),{projectId:n}=Te(),{hydratedRevision:r,loading:o}=Gr(),{integrationObj:i,installation:s,groupRef:a,consumerRef:c,onInstallSuccess:f,isIntegrationDeleted:u}=rt(),{mutate:d,isIdle:g,isPending:h,error:w,errorMsg:v}=Hx(),{selectedConnection:p,isConnectionsLoading:x}=Qt(),m=o||h||x,I=(C=r==null?void 0:r.content)==null?void 0:C.provider,_=Wx(r);return y.useEffect(()=>{var S;if(!m&&!x&&r&&_&&!s&&p&&(i!=null&&i.id)&&!u&&I){const R={projectIdOrName:n,integrationId:i==null?void 0:i.id,installation:{groupRef:a,connectionId:p==null?void 0:p.id,config:{content:{provider:I}}}};wi(r)===!0&&(R.installation.config.content.proxy=(S=r==null?void 0:r.content)==null?void 0:S.proxy),g&&!t.current&&(d(R,{onSuccess:N=>{f==null||f(N==null?void 0:N.id,N.config)}}),t.current=!0)}},[r,_,s,p,n,i==null?void 0:i.id,a,c,m,f,u,x,I,d,g]),_&&I&&s?l.jsx(Jx,{provider:I}):w?l.jsx(Jt,{message:v??"Create installation failed"}):i?m?l.jsx(zr,{}):l.jsx("div",{children:e}):l.jsx(Jt,{message:"We can't load the integration"})}function Ao(){const e=ut(),t=vt();return Jr({mutationKey:["createConnection"],mutationFn:async n=>(await e()).connectionApi.generateConnection(n),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","connections"]})},onError:n=>{console.error("Error creating connection and loading provider info"),Le(n)}})}function Gx({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a}){const{projectIdOrName:c}=Te(),f=Ao(),u=y.useCallback(d=>{var v;const{apiKey:g,providerMetadata:h}=d,w={projectIdOrName:c,generateConnectionParams:{providerWorkspaceRef:(v=h==null?void 0:h.workspace)==null?void 0:v.value,groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,apiKey:g,...h&&{providerMetadata:h}}};f.mutate(w)},[c,i,o,r,n,e,f]);return a===null?l.jsx(wx,{provider:e,providerInfo:t,handleSubmit:u,error:null}):s}function Qx({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a}){const{projectIdOrName:c}=Te(),f=Ao(),u=y.useCallback(d=>{var p;const{user:g,pass:h,providerMetadata:w}=d,v={projectIdOrName:c,generateConnectionParams:{providerWorkspaceRef:(p=w==null?void 0:w.workspace)==null?void 0:p.value,groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,basicAuth:{username:g,password:h},...w&&{providerMetadata:w}}};f.mutate(v)},[c,i,o,r,n,e,f]);return a===null?l.jsx(Cx,{provider:e,providerInfo:t,handleSubmit:u,error:null}):s}function Xx({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(yr,{children:[l.jsx(vr,{children:i||`Set up ${r} integration`}),l.jsx(In,{error:t}),o,l.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function Yx({...e}){return l.jsx(Xx,{...e})}function Zx({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,selectedConnection:s,providerName:a}){const{projectIdOrName:c}=Te(),f=Ao(),u=y.useCallback(()=>{const d={projectIdOrName:c,generateConnectionParams:{groupName:o,groupRef:r,consumerName:n,consumerRef:t,provider:e}};f.mutate(d)},[c,o,r,n,t,e,f]);return s===null?l.jsx(Yx,{handleSubmit:u,error:null,providerName:a}):i}const eC=()=>{const e=ut(),{projectIdOrName:t}=Te();return yn({queryKey:["amp","providerApps",t],queryFn:async()=>{if(!t)throw new Error("Project ID is required");return(await e()).providerAppApi.listProviderApps({projectIdOrName:t})},enabled:!!t})},tC=e=>{const t=ut(),n={connectOAuthParams:e};return yn({queryKey:["amp","oauthConnect",e.projectId,e.groupRef,e.consumerRef,e.provider],queryFn:async()=>{if(!e.projectId)throw new Error("Project ID is required");if(!(e!=null&&e.providerAppId))throw new Error("Provider App ID is required");if(!(e!=null&&e.provider))throw new Error("Provider is required");if(!(e!=null&&e.consumerRef))throw new Error("Consumer Ref is required");if(!(e!=null&&e.groupRef))throw new Error("Group Ref is required");return(await t()).oAuthApi.oauthConnect(n)},enabled:!1})},nC=Hs("VITE_AMP_ENABLE_CSRF",!1),rC=Hs("NEXT_AMP_ENABLE_CSRF",!1),iC=Hs("REACT_APP_AMP_ENABLE_CSRF",!1),oC=!!nC||!!rC||!!iC,Bd=(e,t,n,r,o,i,s)=>{var S;const{projectId:a}=Te(),{data:c,isLoading:f,error:u}=_i(n),{data:d,isLoading:g,error:h}=eC(),w=d==null?void 0:d.find(R=>R.provider===n),v=c?Gl(n,c):null,p={providerWorkspaceRef:i||((S=s==null?void 0:s.workspace)==null?void 0:S.value),projectId:a,groupRef:t,groupName:o,consumerRef:e,consumerName:r,providerAppId:w==null?void 0:w.id,provider:n,enableCSRFProtection:oC,providerMetadata:s},{data:x,error:m,isLoading:I,refetch:_}=tC(p);return y.useEffect(()=>{c&&n&&d&&!w&&console.error(`You must first set up a ${v} Provider App using the Ampersand Console. `,{provInfo:c,provider:n,providerApps:d,app:w})},[w,v,c,n,d]),y.useEffect(()=>{u&&(console.error("Error fetching provider info:",u),Le(u))},[u]),y.useEffect(()=>{h&&(console.error("Error fetching provider apps:",h),Le(h))},[h]),y.useEffect(()=>{m&&(console.error("Error fetching OAuth connect:",m),Le(m))},[m]),{url:x,error:u||h||m,isLoading:f||g||I,refetchOauthConnect:async()=>{var R,N;if((c==null?void 0:c.authType)==="oauth2"){if(((R=c==null?void 0:c.oauth2Opts)==null?void 0:R.grantType)==="authorizationCode"||((N=c==null?void 0:c.oauth2Opts)==null?void 0:N.grantType)==="authorizationCodePKCE")return await _();console.error("Provider does not support an OAuth2 web flow grant type.")}else console.error("Provider does not support an OAuth2 web flow.");return null}}};function sC({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return l.jsxs(yr,{children:[l.jsx(vr,{children:`Set up ${r} integration`}),l.jsx(mx,{children:`Click Next to sign into the ${r} account you'd like to sync.`}),l.jsx(In,{error:t}),l.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:n?"Loading...":"Next"})]})}function aC({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,providerName:i}){const[s,a]=y.useState(null),[c,f]=y.useState(!1),{isFetching:u,refetch:d}=Hl({groupRef:r,provider:e}),{url:g,error:h,isLoading:w,refetchOauthConnect:v}=Bd(t,r,e,n,o,void 0,{}),p=(h==null?void 0:h.message)||s||null,x=y.useCallback(C=>{a(C),f(!1),d()},[a,d]),m=y.useCallback(()=>{a(null),f(!1),d()},[a,d]),I=y.useCallback(()=>{f(!1),d()},[f,d]),_=async()=>{var R;a(null);const{data:C}=await d();if(C&&C.length>0)return;const S=await v();S!=null&&S.data?f(!0):x(((R=S==null?void 0:S.error)==null?void 0:R.message)||"Authentication failed")};return l.jsx(Ea,{windowTitle:`Connect to ${i}`,oauthUrl:c&&g||null,onError:x,error:p,onSuccessConnect:m,onWindowClose:I,children:l.jsx(sC,{handleSubmit:_,error:u?"":p,providerName:i,isButtonDisabled:w||u})})}const cC="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function lC({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r}){return l.jsxs(yr,{children:[l.jsx(vr,{children:"Enter your Salesforce subdomain"}),l.jsx(Ld,{href:cC,newTab:!0,children:"What is my Salesforce subdomain?"}),l.jsx(In,{error:n}),l.jsxs("div",{style:{display:"flex",marginTop:"1em",alignItems:"center"},children:[l.jsx(Bt.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(ze,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}function uC({handleSubmit:e,setFormData:t,error:n,isButtonDisabled:r,providerName:o,metadataFields:i}){return l.jsxs(yr,{children:[l.jsxs(vr,{children:["Enter your ",o," workspace"]}),l.jsx(In,{error:n}),l.jsx("br",{}),i.map(s=>l.jsx(Bt.Input,{id:s.name,name:s.name,type:"text",placeholder:s.displayName||s.name,onChange:a=>t(s.name,a.currentTarget.value)},s.name)),l.jsx("br",{}),l.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}const Wc="salesforce";function dC({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,providerName:i}){var q,ae;const[s,a]=y.useState(""),[c,f]=y.useState({}),[u,d]=y.useState(null),[g,h]=y.useState(!1),[w,v]=y.useState({}),{data:p}=_i(e),x=((q=p==null?void 0:p.metadata)==null?void 0:q.input)||[],{url:m,error:I,isLoading:_,refetchOauthConnect:C}=Bd(t,r,e,n,o,e===Wc?s:(ae=w==null?void 0:w.workspace)==null?void 0:ae.value,w),S=(I==null?void 0:I.message)||u||null,R=y.useCallback(X=>{d(X),h(!1)},[]),N=y.useCallback(()=>{d(null),h(!1)},[]),A=y.useCallback(()=>{h(!1)},[h]),K=X=>{a(X),f(Y=>({...Y,workspace:X})),v(Y=>({...Y,workspace:{value:X,source:"input"}}))},z=(X,Y)=>{f(fe=>({...fe,[X]:Y})),v(fe=>({...fe,[X]:{value:Y,source:"input"}}))},H=async()=>{var Y;if(d(null),!hi(x,c)){d("Please fill in all required fields");return}const X=await C();X!=null&&X.data?h(!0):R(((Y=X==null?void 0:X.error)==null?void 0:Y.message)||"Authentication failed")},ee=e===Wc?l.jsx(lC,{handleSubmit:H,setWorkspace:K,error:S,isButtonDisabled:s.length===0}):l.jsx(uC,{handleSubmit:H,setFormData:z,error:S,isButtonDisabled:!hi(x,c)||_,providerName:i,metadataFields:x});return l.jsx(Ea,{windowTitle:`Connect to ${i}`,oauthUrl:g&&m||null,onError:R,error:S,onSuccessConnect:N,onWindowClose:A,children:ee})}function fC({provider:e,providerName:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,explicitScopesRequired:s,selectedConnection:a}){const{projectIdOrName:c}=Te(),f=Ao(),[u,d]=y.useState(null),g=y.useCallback(h=>{var v,p;d(null);const w={projectIdOrName:c,generateConnectionParams:{groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,providerWorkspaceRef:(p=(v=h.providerMetadata)==null?void 0:v.workspace)==null?void 0:p.value,oauth2ClientCredentials:{clientId:h.clientId,clientSecret:h.clientSecret,scopes:h.scopes},...h.providerMetadata&&{providerMetadata:h.providerMetadata}}};f.mutate(w,{onError:()=>d("Error loading provider info")})},[c,i,o,r,n,e,f]);return a===null?l.jsx(Ox,{provider:e,providerName:t,handleSubmit:g,error:u,explicitScopesRequired:s}):l.jsx(ci,{})}function pC({...e}){return l.jsx(fC,{...e})}const hC="authorizationCode",mC="authorizationCodePKCE",gC="clientCredentials";function yC({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,selectedConnection:s,setSelectedConnection:a}){var g;const{providerName:c}=at(e);if(t.oauth2Opts===void 0)return l.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:f,explicitScopesRequired:u}=t.oauth2Opts,d={provider:e,consumerRef:n,consumerName:r,groupRef:o,groupName:i,providerName:c};return f===hC||f===mC?(g=t.metadata)!=null&&g.input?l.jsx(dC,{...d}):l.jsx(aC,{...d}):f===gC?l.jsx(pC,{...d,explicitScopesRequired:u,selectedConnection:s,setSelectedConnection:a}):f==="password"?l.jsx("em",{children:"Password flow not supported yet"}):l.jsxs("em",{children:["Unsupported grant type: ",f]})}function vC(e){const{selectedConnection:t}=Qt();y.useEffect(()=>{e&&t&&e(t)},[e,t])}function wC({onSuccess:e}){vC(e)}function Jd({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,onSuccess:s,onDisconnectSuccess:a,resetComponent:c}){const{data:f,isLoading:u,isError:d,error:g,providerName:h,selectedProvider:w}=at(e),{provider:v,isIntegrationDeleted:p}=rt(),{selectedConnection:x,setSelectedConnection:m}=Qt();wC({onSuccess:s});const I=vt();y.useEffect(()=>{d&&(console.error("Error loading provider info."),Le(g))},[d,g]);const _=y.useCallback(()=>{I.clear(),c()},[c,I]);if(!e&&!v)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");if(p)return l.jsx(Sa,{text:"Integration successfully uninstalled.",children:l.jsx(ze,{type:"button",onClick:_,style:{width:"100%"},children:"Reinstall Integration"})});if(x)return i;if(u)return l.jsx(zr,{});if(f==null)return l.jsx(Jt,{message:"Provider info was not found."});const C={provider:w,consumerRef:t,consumerName:n,groupRef:r,groupName:o,selectedConnection:x,setSelectedConnection:m,providerName:h,providerInfo:f,onDisconnectSuccess:a};return f.authType==="none"?l.jsx(Zx,{...C,children:i}):f.authType==="basic"?l.jsx(Qx,{...C,children:i}):f.authType==="apiKey"?l.jsx(Gx,{...C,children:i}):l.jsx(yC,{...C})}function IC(e){const t=e+"CollectionProvider",[n,r]=No(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=v=>{const{scope:p,children:x}=v,m=y.useRef(null),I=y.useRef(new Map).current;return l.jsx(o,{scope:p,itemMap:I,collectionRef:m,children:x})};s.displayName=t;const a=e+"CollectionSlot",c=Ms(a),f=y.forwardRef((v,p)=>{const{scope:x,children:m}=v,I=i(a,x),_=gr(p,I.collectionRef);return l.jsx(c,{ref:_,children:m})});f.displayName=a;const u=e+"CollectionItemSlot",d="data-radix-collection-item",g=Ms(u),h=y.forwardRef((v,p)=>{const{scope:x,children:m,...I}=v,_=y.useRef(null),C=gr(p,_),S=i(u,x);return y.useEffect(()=>(S.itemMap.set(_,{ref:_,...I}),()=>void S.itemMap.delete(_))),l.jsx(g,{[d]:"",ref:C,children:m})});h.displayName=u;function w(v){const p=i(e+"CollectionConsumer",v);return y.useCallback(()=>{const m=p.collectionRef.current;if(!m)return[];const I=Array.from(m.querySelectorAll(`[${d}]`));return Array.from(p.itemMap.values()).sort((S,R)=>I.indexOf(S.ref.current)-I.indexOf(R.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:s,Slot:f,ItemSlot:h},w,r]}var bC=M[" useId ".trim().toString()]||(()=>{}),xC=0;function Wd(e){const[t,n]=M.useState(bC());return pi(()=>{e||n(r=>r??String(xC++))},[e]),e||(t?`radix-${t}`:"")}function CC(e){const t=M.useRef(e);return M.useEffect(()=>{t.current=e}),M.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}var _C=M.createContext(void 0);function zd(e){const t=M.useContext(_C);return e||t||"ltr"}var ts="rovingFocusGroup.onEntryFocus",OC={bubbles:!1,cancelable:!0},Oi="RovingFocusGroup",[ks,Gd,EC]=IC(Oi),[SC,Qd]=No(Oi,[EC]),[NC,TC]=SC(Oi),Xd=M.forwardRef((e,t)=>l.jsx(ks.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(ks.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(RC,{...e,ref:t})})}));Xd.displayName=Oi;var RC=M.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:f,preventScrollOnEntryFocus:u=!1,...d}=e,g=M.useRef(null),h=gr(t,g),w=zd(i),[v,p]=wa({prop:s,defaultProp:a??null,onChange:c,caller:Oi}),[x,m]=M.useState(!1),I=CC(f),_=Gd(n),C=M.useRef(!1),[S,R]=M.useState(0);return M.useEffect(()=>{const N=g.current;if(N)return N.addEventListener(ts,I),()=>N.removeEventListener(ts,I)},[I]),l.jsx(NC,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:v,onItemFocus:M.useCallback(N=>p(N),[p]),onItemShiftTab:M.useCallback(()=>m(!0),[]),onFocusableItemAdd:M.useCallback(()=>R(N=>N+1),[]),onFocusableItemRemove:M.useCallback(()=>R(N=>N-1),[]),children:l.jsx(wn.div,{tabIndex:x||S===0?-1:0,"data-orientation":r,...d,ref:h,style:{outline:"none",...e.style},onMouseDown:Wt(e.onMouseDown,()=>{C.current=!0}),onFocus:Wt(e.onFocus,N=>{const A=!C.current;if(N.target===N.currentTarget&&A&&!x){const K=new CustomEvent(ts,OC);if(N.currentTarget.dispatchEvent(K),!K.defaultPrevented){const z=_().filter(X=>X.focusable),H=z.find(X=>X.active),ee=z.find(X=>X.id===v),ae=[H,ee,...z].filter(Boolean).map(X=>X.ref.current);ef(ae,u)}}C.current=!1}),onBlur:Wt(e.onBlur,()=>m(!1))})})}),Yd="RovingFocusGroupItem",Zd=M.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:s,...a}=e,c=Wd(),f=i||c,u=TC(Yd,n),d=u.currentTabStopId===f,g=Gd(n),{onFocusableItemAdd:h,onFocusableItemRemove:w,currentTabStopId:v}=u;return M.useEffect(()=>{if(r)return h(),()=>w()},[r,h,w]),l.jsx(ks.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:l.jsx(wn.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:t,onMouseDown:Wt(e.onMouseDown,p=>{r?u.onItemFocus(f):p.preventDefault()}),onFocus:Wt(e.onFocus,()=>u.onItemFocus(f)),onKeyDown:Wt(e.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){u.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const x=FC(p,u.orientation,u.dir);if(x!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let I=g().filter(_=>_.focusable).map(_=>_.ref.current);if(x==="last")I.reverse();else if(x==="prev"||x==="next"){x==="prev"&&I.reverse();const _=I.indexOf(p.currentTarget);I=u.loop?DC(I,_+1):I.slice(_+1)}setTimeout(()=>ef(I))}}),children:typeof s=="function"?s({isCurrentTabStop:d,hasTabStop:v!=null}):s})})});Zd.displayName=Yd;var AC={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function PC(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function FC(e,t,n){const r=PC(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return AC[r]}function ef(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function DC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var MC=Xd,kC=Zd,Po="Tabs",[jC,f_]=No(Po,[Qd]),tf=Qd(),[LC,Na]=jC(Po),nf=M.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:c="automatic",...f}=e,u=zd(a),[d,g]=wa({prop:r,onChange:o,defaultProp:i??"",caller:Po});return l.jsx(LC,{scope:n,baseId:Wd(),value:d,onValueChange:g,orientation:s,dir:u,activationMode:c,children:l.jsx(wn.div,{dir:u,"data-orientation":s,...f,ref:t})})});nf.displayName=Po;var rf="TabsList",of=M.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Na(rf,n),s=tf(n);return l.jsx(MC,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:r,children:l.jsx(wn.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});of.displayName=rf;var sf="TabsTrigger",af=M.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=Na(sf,n),a=tf(n),c=lf(s.baseId,r),f=uf(s.baseId,r),u=r===s.value;return l.jsx(kC,{asChild:!0,...a,focusable:!o,active:u,children:l.jsx(wn.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":f,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...i,ref:t,onMouseDown:Wt(e.onMouseDown,d=>{!o&&d.button===0&&d.ctrlKey===!1?s.onValueChange(r):d.preventDefault()}),onKeyDown:Wt(e.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&s.onValueChange(r)}),onFocus:Wt(e.onFocus,()=>{const d=s.activationMode!=="manual";!u&&!o&&d&&s.onValueChange(r)})})})});af.displayName=sf;var cf="TabsContent",KC=M.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=Na(cf,n),c=lf(a.baseId,r),f=uf(a.baseId,r),u=r===a.value,d=M.useRef(u);return M.useEffect(()=>{const g=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(g)},[]),l.jsx(Ia,{present:o||u,children:({present:g})=>l.jsx(wn.div,{"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!g,id:f,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:d.current?"0s":void 0},children:g&&i})})});KC.displayName=cf;function lf(e,t){return`${e}-trigger-${t}`}function uf(e,t){return`${e}-content-${t}`}var VC=nf,UC=of,df=af;const $C=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 qC(e,t){return t?y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},y.createElement("circle",{cx:"9",cy:"9",r:"5",fill:"#FBD38D"})):e?$C: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 HC(){return l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M8 11C9.65685 11 11 9.65685 11 8C11 6.34315 9.65685 5 8 5C6.34315 5 5 6.34315 5 8C5 9.65685 6.34315 11 8 11Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M12.3378 5.04365C12.4882 5.25907 12.62 5.48699 12.7315 5.7249L14.3503 6.6249C14.5524 7.5302 14.5545 8.4687 14.3565 9.3749L12.7315 10.2749C12.62 10.5128 12.4882 10.7407 12.3378 10.9562L12.369 12.8124C11.683 13.4375 10.871 13.9085 9.98776 14.1937L8.39401 13.2374C8.13185 13.2562 7.86868 13.2562 7.60651 13.2374L6.01901 14.1874C5.13295 13.9075 4.31832 13.4383 3.63151 12.8124L3.66276 10.9624C3.51356 10.744 3.38189 10.5141 3.26901 10.2749L1.65026 9.3749C1.44814 8.46961 1.446 7.53111 1.64401 6.6249L3.26901 5.7249C3.38056 5.48699 3.5123 5.25907 3.66276 5.04365L3.63151 3.1874C4.31754 2.56226 5.1295 2.09128 6.01276 1.80615L7.60651 2.7624C7.86868 2.74365 8.13185 2.74365 8.39401 2.7624L9.98151 1.8124C10.8676 2.09234 11.6822 2.5615 12.369 3.1874L12.3378 5.04365Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const BC="_tabsRoot_ktpr0_1",JC="_tabsList_ktpr0_6",WC="_tabTrigger_ktpr0_12",zC="_danger_ktpr0_29",go={tabsRoot:BC,tabsList:JC,tabTrigger:WC,danger:zC};function GC(){return l.jsxs(l.Fragment,{children:[l.jsx(So,{style:{margin:"1rem 0"}}),l.jsx(df,{value:ro,className:go.tabTrigger,children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[l.jsx(HC,{}),l.jsx("span",{children:"Manage"})]})})]})}function ff({objectName:e,completed:t,pending:n,displayName:r}){return l.jsx(df,{value:e,className:go.tabTrigger,children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[qC(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 QC({completed:e,pending:t,displayName:n}){return l.jsxs(l.Fragment,{children:[l.jsx(So,{style:{margin:"1rem 0"}}),l.jsx(ff,{objectName:dr,completed:e,pending:t,displayName:n},"other-write")]})}function XC({value:e,readNavObjects:t,onValueChange:n,objectConfigurationsState:r,writeNavObject:o}){var i,s;return l.jsx(VC,{value:e,className:go.tabsRoot,onValueChange:n,children:l.jsxs(UC,{className:go.tabsList,children:[t.map(a=>{var c,f,u,d,g,h;return l.jsx(ff,{objectName:a.name,displayName:a.displayName,completed:a.completed,pending:((f=(c=r==null?void 0:r[a.name])==null?void 0:c.read)==null?void 0:f.isOptionalFieldsModified)||((d=(u=r==null?void 0:r[a.name])==null?void 0:u.read)==null?void 0:d.isRequiredMapFieldsModified)||((h=(g=r==null?void 0:r[a.name])==null?void 0:g.read)==null?void 0:h.isValueMappingsModified)||!1},a.name)}),o&&l.jsx(QC,{completed:o.completed,pending:((s=(i=r==null?void 0:r.other)==null?void 0:i.write)==null?void 0:s.isWriteModified)||!1,displayName:"Write"}),l.jsx(GC,{})]})})}function YC(e,t){return t===ro?{name:ro,completed:!1}:e.find(n=>n.name===t)}function ZC({children:e}){var x;const{project:t}=Te(),{installation:n}=rt(),{providerName:r}=at(),{hydratedRevision:o}=Gr(),{objectConfigurationsState:i}=ya(),[s,a]=y.useState(""),c=(t==null?void 0:t.appName)||"",f=n==null?void 0:n.config,u=o&&nu(f,o),d=u!==null,g=!!((x=o==null?void 0:o.content)!=null&&x.write),h=g?ru(f):void 0,w=y.useMemo(()=>{const m=[...u||[]];return h&&g&&m.push(h),m},[u,h,g]),v=YC(w,s),p=y.useCallback(()=>{const m=w.find(I=>v!==I&&!I.completed);m&&a(m.name)},[w,v]);return y.useEffect(()=>{!s&&w.length>0&&a(w[0].name)},[w,s,p]),l.jsx(hd.Provider,{value:p,children:l.jsx(fd.Provider,{value:v==null?void 0:v.name,children:l.jsxs(Wr,{style:{maxWidth:"55rem"},children:[l.jsxs(vn,{style:{display:"flex",gap:"1rem",padding:"3rem",paddingBottom:"6rem",backgroundColor:"var(--amp-colors-bg-primary)"},children:[l.jsxs("div",{style:{width:"20rem"},children:[l.jsxs("h1",{style:{fontSize:"small",fontWeight:"400"},children:[r," integration"]}),l.jsx("h3",{style:{marginBottom:"20px",fontSize:"large",fontWeight:"500"},children:c}),d&&l.jsx(XC,{value:s,readNavObjects:u,onValueChange:m=>a(m),objectConfigurationsState:i,writeNavObject:h})]}),e]}),l.jsx(jd,{})]})})})}function e_({...e}){return l.jsx(ZC,{...e})}const t_="_resetContainer_lkwv9_4",pf={resetContainer:t_};function n_({integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c}){var p;const{projectIdOrName:f,isLoading:u}=Te(),{isLoading:d}=qs(),{isError:g,errorState:h}=Ft(),{seed:w,reset:v}=Zl();return u||d?l.jsx(zr,{}):g(ue.PROJECT,f)?l.jsx(Jt,{message:`Error loading project ${f}`}):g(ue.INTEGRATION_LIST,f)?l.jsx(Jt,{message:"Error retrieving integrations for the project, double check the API key"}):(p=h[ue.INTEGRATION_LIST])!=null&&p.apiError?l.jsx(Jt,{message:"Something went wrong, couldn't find integration information"}):l.jsx("div",{className:pf.resetContainer,children:l.jsx(tv,{integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c,children:l.jsx(Yl,{children:l.jsx(Jd,{consumerRef:t,consumerName:n,groupRef:r,groupName:o,resetComponent:v,children:l.jsx(Nv,{resetComponent:v,children:l.jsx(zx,{children:l.jsx(JI,{children:l.jsx(e_,{children:l.jsx(qx,{})})})})})})})},w)})}function r_(){return l.jsxs(Wr,{style:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[l.jsx(ci,{}),l.jsx("p",{children:"Redirecting"})]})}function i_({redirectURL:e,children:t}){return y.useEffect(()=>{e&&window.location.replace(e)},[e]),e?l.jsx(r_,{}):t}function o_({resetComponent:e,onDisconnectSuccess:t,provider:n}){const[r,o]=y.useState(!1);return l.jsxs(l.Fragment,{children:[r===!1&&l.jsxs(l.Fragment,{children:[l.jsx(Et,{string:"Manage connection"}),l.jsxs("div",{style:{padding:"1rem 0",width:"100%",display:"flex",flexDirection:"column",gap:"1rem"},children:[l.jsx("p",{children:"Click to reauthenticate or refresh your connection."}),l.jsx(ze,{type:"button",onClick:()=>o(!0),variant:"ghost",style:{fontSize:"13px"},children:"Update connection"})]})]}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx($d,{provider:n}),l.jsx(Et,{string:"Remove connection"}),l.jsx("p",{children:"Click to disconnect your connection from the provider."}),l.jsx(mu,{resetComponent:e,onDisconnectSuccess:t,buttonText:"Remove connection",buttonVariant:"danger",buttonStyle:{fontSize:"13px"}})]})]})}function s_({provider:e,onDisconnectSuccess:t,resetComponent:n}){const{appName:r}=Te(),{providerName:o}=at(e),i=`You have successfully connected your ${o} account to ${r}.`;return l.jsx(Sa,{text:i,children:l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",width:"100%"},children:l.jsx(o_,{resetComponent:n,onDisconnectSuccess:t,provider:e})})})}function a_({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,redirectUrl:i,onSuccess:s,onDisconnectSuccess:a,onConnectSuccess:c}){const{seed:f,reset:u}=Zl(),d=y.useCallback(g=>{s?s(g.id):c&&c(g)},[s,c]);return l.jsx("div",{className:pf.resetContainer,children:l.jsx(Yl,{groupRef:r,provider:e,children:l.jsx(Jd,{resetComponent:u,provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onSuccess:d,onDisconnectSuccess:a,children:l.jsx(i_,{redirectURL:i,children:l.jsx(s_,{resetComponent:u,provider:e,onDisconnectSuccess:a})})})})},f)}const c_=(e,t)=>{const{data:n,isLoading:r,isError:o,error:i}=zl(e,t),s=((n==null?void 0:n.length)||0)>0,a=!!n&&!r,c=n==null?void 0:n[0],f=c==null?void 0:c.config;return y.useEffect(()=>{o&&Le(i)},[o,i]),{isLoaded:a,isIntegrationInstalled:s,isLoading:r,config:f}};exports.AmpersandContext=ql;exports.AmpersandProvider=ky;exports.ConnectProvider=a_;exports.InstallIntegration=n_;exports.useAmpersandProvider=jy;exports.useIsIntegrationInstalled=c_;
52
52
  //# sourceMappingURL=amp-react.cjs.js.map