@amp-labs/react 2.7.1 → 2.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/amp-react.cjs.js +13 -13
- package/build/amp-react.es.js +3364 -3157
- package/build/index.d.ts +1 -0
- package/package.json +1 -1
package/build/amp-react.cjs.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use strict";var Pa=e=>{throw TypeError(e)};var Ro=(e,t,n)=>t.has(e)||Pa("Cannot "+n);var O=(e,t,n)=>(Ro(e,t,"read from private field"),n?n.call(e):t.get(e)),oe=(e,t,n)=>t.has(e)?Pa("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),J=(e,t,n,r)=>(Ro(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),pe=(e,t,n)=>(Ro(e,t,"access private method"),n);var Ai=(e,t,n,r)=>({set _(o){J(e,t,o,n)},get _(){return O(e,t,r)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),y=require("react");require("react-dom");function Ff(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 V=Ff(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(){}},ar=typeof window>"u"||"Deno"in globalThis;function At(){}function Mf(e,t){return typeof e=="function"?e(t):e}function Qo(e){return typeof e=="number"&&e>=0&&e!==1/0}function Qc(e,t){return Math.max(e+(t||0)-Date.now(),0)}function br(e,t){return typeof e=="function"?e(t):e}function Ht(e,t){return typeof e=="function"?e(t):e}function Da(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==As(s,t.options))return!1}else if(!si(t.queryKey,s))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||o&&o!==t.state.fetchStatus||i&&!i(t))}function Fa(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(cr(t.options.mutationKey)!==cr(i))return!1}else if(!si(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function As(e,t){return((t==null?void 0:t.queryKeyHashFn)||cr)(e)}function cr(e){return JSON.stringify(e,(t,n)=>Yo(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function si(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!si(e[n],t[n])):!1}function Xo(e,t){if(e===t)return e;const n=Ma(e)&&Ma(t);if(n||Yo(e)&&Yo(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{};let l=0;for(let u=0;u<s;u++){const d=n?u:i[u];(!n&&r.includes(d)||n)&&e[d]===void 0&&t[d]===void 0?(a[d]=void 0,l++):(a[d]=Xo(e[d],t[d]),a[d]===e[d]&&e[d]!==void 0&&l++)}return o===s&&l===o?e:a}return t}function Ji(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 Ma(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Yo(e){if(!ja(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!ja(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function ja(e){return Object.prototype.toString.call(e)==="[object Object]"}function jf(e){return new Promise(t=>{setTimeout(t,e)})}function Zo(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 Xo(e,t)}catch(r){console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`)}return Xo(e,t)}return t}function kf(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Lf(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var zi=Symbol();function Xc(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===zi&&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===zi?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Yn,Sn,_r,Vc,Kf=(Vc=class extends Br{constructor(){super();oe(this,Yn);oe(this,Sn);oe(this,_r);J(this,_r,t=>{if(!ar&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){O(this,Sn)||this.setEventListener(O(this,_r))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,Sn))==null||t.call(this),J(this,Sn,void 0))}setEventListener(t){var n;J(this,_r,t),(n=O(this,Sn))==null||n.call(this),J(this,Sn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){O(this,Yn)!==t&&(J(this,Yn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof O(this,Yn)=="boolean"?O(this,Yn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Yn=new WeakMap,Sn=new WeakMap,_r=new WeakMap,Vc),Ps=new Kf,Cr,Nn,Or,$c,Vf=($c=class extends Br{constructor(){super();oe(this,Cr,!0);oe(this,Nn);oe(this,Or);J(this,Or,t=>{if(!ar&&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,Nn)||this.setEventListener(O(this,Or))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,Nn))==null||t.call(this),J(this,Nn,void 0))}setEventListener(t){var n;J(this,Or,t),(n=O(this,Nn))==null||n.call(this),J(this,Nn,t(this.setOnline.bind(this)))}setOnline(t){O(this,Cr)!==t&&(J(this,Cr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return O(this,Cr)}},Cr=new WeakMap,Nn=new WeakMap,Or=new WeakMap,$c),Gi=new Vf;function es(){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 $f(e){return Math.min(1e3*2**e,3e4)}function Yc(e){return(e??"online")==="online"?Gi.isOnline():!0}var Zc=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Ao(e){return e instanceof Zc}function el(e){let t=!1,n=0,r=!1,o;const i=es(),s=v=>{var h;r||(p(new Zc(v)),(h=e.abort)==null||h.call(e))},a=()=>{t=!0},l=()=>{t=!1},u=()=>Ps.isFocused()&&(e.networkMode==="always"||Gi.isOnline())&&e.canRun(),d=()=>Yc(e.networkMode)&&e.canRun(),f=v=>{var h;r||(r=!0,(h=e.onSuccess)==null||h.call(e,v),o==null||o(),i.resolve(v))},p=v=>{var h;r||(r=!0,(h=e.onError)==null||h.call(e,v),o==null||o(),i.reject(v))},m=()=>new Promise(v=>{var h;o=x=>{(r||u())&&v(x)},(h=e.onPause)==null||h.call(e)}).then(()=>{var v;o=void 0,r||(v=e.onContinue)==null||v.call(e)}),w=()=>{if(r)return;let v;const h=n===0?e.initialPromise:void 0;try{v=h??e.fn()}catch(x){v=Promise.reject(x)}Promise.resolve(v).then(f).catch(x=>{var T;if(r)return;const g=e.retry??(ar?0:3),b=e.retryDelay??$f,_=typeof b=="function"?b(n,x):b,C=g===!0||typeof g=="number"&&n<g||typeof g=="function"&&g(n,x);if(t||!C){p(x);return}n++,(T=e.onFail)==null||T.call(e,n,x),jf(_).then(()=>u()?void 0:m()).then(()=>{t?p(x):w()})})};return{promise:i,cancel:s,continue:()=>(o==null||o(),i),cancelRetry:a,continueRetry:l,canStart:d,start:()=>(d()?w():m().then(w),i)}}function Uf(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=a=>setTimeout(a,0);const i=a=>{t?e.push(a):o(()=>{n(a)})},s=()=>{const a=e;e=[],a.length&&o(()=>{r(()=>{a.forEach(l=>{n(l)})})})};return{batch:a=>{let l;t++;try{l=a()}finally{t--,t||s()}return l},batchCalls:a=>(...l)=>{i(()=>{a(...l)})},schedule:i,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{o=a}}}var We=Uf(),Zn,Uc,tl=(Uc=class{constructor(){oe(this,Zn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Qo(this.gcTime)&&J(this,Zn,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ar?1/0:5*60*1e3))}clearGcTimeout(){O(this,Zn)&&(clearTimeout(O(this,Zn)),J(this,Zn,void 0))}},Zn=new WeakMap,Uc),Er,Sr,Rt,er,st,pi,tr,Ut,dn,qc,qf=(qc=class extends tl{constructor(t){super();oe(this,Ut);oe(this,Er);oe(this,Sr);oe(this,Rt);oe(this,er);oe(this,st);oe(this,pi);oe(this,tr);J(this,tr,!1),J(this,pi,t.defaultOptions),this.setOptions(t.options),this.observers=[],J(this,er,t.client),J(this,Rt,O(this,er).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,J(this,Er,Hf(this.options)),this.state=t.state??O(this,Er),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,pi),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&O(this,Rt).remove(this)}setData(t,n){const r=Zo(this.state.data,t,this.options);return pe(this,Ut,dn).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){pe(this,Ut,dn).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,Er))}isActive(){return this.observers.some(t=>Ht(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===zi||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||!Qc(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,tr)?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||pe(this,Ut,dn).call(this,{type:"invalidate"})}fetch(t,n){var l,u,d;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(O(this,st))return O(this,st).continueRetry(),O(this,st).promise}if(t&&this.setOptions(t),!this.options.queryFn){const f=this.observers.find(p=>p.options.queryFn);f&&this.setOptions(f.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(J(this,tr,!0),r.signal)})},i=()=>{const f=Xc(this.options,n),p={client:O(this,er),queryKey:this.queryKey,meta:this.meta};return o(p),J(this,tr,!1),this.options.persister?this.options.persister(f,p,this):f(p)},s={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:O(this,er),state:this.state,fetchFn:i};o(s),(l=this.options.behavior)==null||l.onFetch(s,this),J(this,Sr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=s.fetchOptions)==null?void 0:u.meta))&&pe(this,Ut,dn).call(this,{type:"fetch",meta:(d=s.fetchOptions)==null?void 0:d.meta});const a=f=>{var p,m,w,v;Ao(f)&&f.silent||pe(this,Ut,dn).call(this,{type:"error",error:f}),Ao(f)||((m=(p=O(this,Rt).config).onError)==null||m.call(p,f,this),(v=(w=O(this,Rt).config).onSettled)==null||v.call(w,this.state.data,f,this)),this.scheduleGc()};return J(this,st,el({initialPromise:n==null?void 0:n.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:f=>{var p,m,w,v;if(f===void 0){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(f)}catch(h){a(h);return}(m=(p=O(this,Rt).config).onSuccess)==null||m.call(p,f,this),(v=(w=O(this,Rt).config).onSettled)==null||v.call(w,f,this.state.error,this),this.scheduleGc()},onError:a,onFail:(f,p)=>{pe(this,Ut,dn).call(this,{type:"failed",failureCount:f,error:p})},onPause:()=>{pe(this,Ut,dn).call(this,{type:"pause"})},onContinue:()=>{pe(this,Ut,dn).call(this,{type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0})),O(this,st).start()}},Er=new WeakMap,Sr=new WeakMap,Rt=new WeakMap,er=new WeakMap,st=new WeakMap,pi=new WeakMap,tr=new WeakMap,Ut=new WeakSet,dn=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,...nl(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 Ao(o)&&o.revert&&O(this,Sr)?{...O(this,Sr),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),We.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),O(this,Rt).notify({query:this,type:"updated",action:t})})},qc);function nl(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Yc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Hf(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 Xt,Hc,Bf=(Hc=class extends Br{constructor(t={}){super();oe(this,Xt);this.config=t,J(this,Xt,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??As(o,n);let s=this.get(i);return s||(s=new qf({client:t,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){O(this,Xt).has(t.queryHash)||(O(this,Xt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=O(this,Xt).get(t.queryHash);n&&(t.destroy(),n===t&&O(this,Xt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){We.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return O(this,Xt).get(t)}getAll(){return[...O(this,Xt).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Da(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>Da(t,r)):n}notify(t){We.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){We.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){We.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Xt=new WeakMap,Hc),Yt,ct,nr,Zt,En,Bc,Wf=(Bc=class extends tl{constructor(t){super();oe(this,Zt);oe(this,Yt);oe(this,ct);oe(this,nr);this.mutationId=t.mutationId,J(this,ct,t.mutationCache),J(this,Yt,[]),this.state=t.state||rl(),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,Yt).includes(t)||(O(this,Yt).push(t),this.clearGcTimeout(),O(this,ct).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){J(this,Yt,O(this,Yt).filter(n=>n!==t)),this.scheduleGc(),O(this,ct).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){O(this,Yt).length||(this.state.status==="pending"?this.scheduleGc():O(this,ct).remove(this))}continue(){var t;return((t=O(this,nr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,s,a,l,u,d,f,p,m,w,v,h,x,g,b,_,C,T,S;J(this,nr,el({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(N,D)=>{pe(this,Zt,En).call(this,{type:"failed",failureCount:N,error:D})},onPause:()=>{pe(this,Zt,En).call(this,{type:"pause"})},onContinue:()=>{pe(this,Zt,En).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>O(this,ct).canRun(this)}));const n=this.state.status==="pending",r=!O(this,nr).canStart();try{if(!n){pe(this,Zt,En).call(this,{type:"pending",variables:t,isPaused:r}),await((i=(o=O(this,ct).config).onMutate)==null?void 0:i.call(o,t,this));const D=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));D!==this.state.context&&pe(this,Zt,En).call(this,{type:"pending",context:D,variables:t,isPaused:r})}const N=await O(this,nr).start();return await((u=(l=O(this,ct).config).onSuccess)==null?void 0:u.call(l,N,t,this.state.context,this)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,N,t,this.state.context)),await((m=(p=O(this,ct).config).onSettled)==null?void 0:m.call(p,N,null,this.state.variables,this.state.context,this)),await((v=(w=this.options).onSettled)==null?void 0:v.call(w,N,null,t,this.state.context)),pe(this,Zt,En).call(this,{type:"success",data:N}),N}catch(N){try{throw await((x=(h=O(this,ct).config).onError)==null?void 0:x.call(h,N,t,this.state.context,this)),await((b=(g=this.options).onError)==null?void 0:b.call(g,N,t,this.state.context)),await((C=(_=O(this,ct).config).onSettled)==null?void 0:C.call(_,void 0,N,this.state.variables,this.state.context,this)),await((S=(T=this.options).onSettled)==null?void 0:S.call(T,void 0,N,t,this.state.context)),N}finally{pe(this,Zt,En).call(this,{type:"error",error:N})}}finally{O(this,ct).runNext(this)}}},Yt=new WeakMap,ct=new WeakMap,nr=new WeakMap,Zt=new WeakSet,En=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),We.batch(()=>{O(this,Yt).forEach(r=>{r.onMutationUpdate(t)}),O(this,ct).notify({mutation:this,type:"updated",action:t})})},Bc);function rl(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var fn,qt,hi,Wc,Jf=(Wc=class extends Br{constructor(t={}){super();oe(this,fn);oe(this,qt);oe(this,hi);this.config=t,J(this,fn,new Set),J(this,qt,new Map),J(this,hi,0)}build(t,n,r){const o=new Wf({mutationCache:this,mutationId:++Ai(this,hi)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){O(this,fn).add(t);const n=Pi(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,fn).delete(t)){const n=Pi(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=Pi(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=Pi(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(){We.batch(()=>{O(this,fn).forEach(t=>{this.notify({type:"removed",mutation:t})}),O(this,fn).clear(),O(this,qt).clear()})}getAll(){return Array.from(O(this,fn))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Fa(n,r))}findAll(t={}){return this.getAll().filter(n=>Fa(t,n))}notify(t){We.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return We.batch(()=>Promise.all(t.map(n=>n.continue().catch(At))))}},fn=new WeakMap,qt=new WeakMap,hi=new WeakMap,Wc);function Pi(e){var t;return(t=e.options.scope)==null?void 0:t.id}function ka(e){return{onFetch:(t,n)=>{var d,f,p,m,w;const r=t.options,o=(p=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:p.direction,i=((m=t.state.data)==null?void 0:m.pages)||[],s=((w=t.state.data)==null?void 0:w.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const u=async()=>{let v=!1;const h=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(t.signal.aborted?v=!0:t.signal.addEventListener("abort",()=>{v=!0}),t.signal)})},x=Xc(t.options,t.fetchOptions),g=async(b,_,C)=>{if(v)return Promise.reject();if(_==null&&b.pages.length)return Promise.resolve(b);const T={client:t.client,queryKey:t.queryKey,pageParam:_,direction:C?"backward":"forward",meta:t.options.meta};h(T);const S=await x(T),{maxPages:N}=t.options,D=C?Lf:kf;return{pages:D(b.pages,S,N),pageParams:D(b.pageParams,_,N)}};if(o&&i.length){const b=o==="backward",_=b?zf:La,C={pages:i,pageParams:s},T=_(r,C);a=await g(C,T,b)}else{const b=e??i.length;do{const _=l===0?s[0]??r.initialPageParam:La(r,a);if(l>0&&_==null)break;a=await g(a,_),l++}while(l<b)}return a};t.options.persister?t.fetchFn=()=>{var v,h;return(h=(v=t.options).persister)==null?void 0:h.call(v,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function La(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 zf(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 je,Tn,Rn,Nr,Tr,An,Rr,Ar,Jc,Gf=(Jc=class{constructor(e={}){oe(this,je);oe(this,Tn);oe(this,Rn);oe(this,Nr);oe(this,Tr);oe(this,An);oe(this,Rr);oe(this,Ar);J(this,je,e.queryCache||new Bf),J(this,Tn,e.mutationCache||new Jf),J(this,Rn,e.defaultOptions||{}),J(this,Nr,new Map),J(this,Tr,new Map),J(this,An,0)}mount(){Ai(this,An)._++,O(this,An)===1&&(J(this,Rr,Ps.subscribe(async e=>{e&&(await this.resumePausedMutations(),O(this,je).onFocus())})),J(this,Ar,Gi.subscribe(async e=>{e&&(await this.resumePausedMutations(),O(this,je).onOnline())})))}unmount(){var e,t;Ai(this,An)._--,O(this,An)===0&&((e=O(this,Rr))==null||e.call(this),J(this,Rr,void 0),(t=O(this,Ar))==null||t.call(this),J(this,Ar,void 0))}isFetching(e){return O(this,je).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return O(this,Tn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=O(this,je).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=O(this,je).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(br(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return O(this,je).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,je).get(r.queryHash),i=o==null?void 0:o.state.data,s=Mf(t,i);if(s!==void 0)return O(this,je).build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return We.batch(()=>O(this,je).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,je).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=O(this,je);We.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=O(this,je),r={type:"active",...e};return We.batch(()=>(n.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries(r,t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=We.batch(()=>O(this,je).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(At).catch(At)}invalidateQueries(e,t={}){return We.batch(()=>{if(O(this,je).findAll(e).forEach(r=>{r.invalidate()}),(e==null?void 0:e.refetchType)==="none")return Promise.resolve();const n={...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"};return this.refetchQueries(n,t)})}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=We.batch(()=>O(this,je).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,je).build(this,t);return n.isStaleByTime(br(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=ka(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(At).catch(At)}ensureInfiniteQueryData(e){return e.behavior=ka(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Gi.isOnline()?O(this,Tn).resumePausedMutations():Promise.resolve()}getQueryCache(){return O(this,je)}getMutationCache(){return O(this,Tn)}getDefaultOptions(){return O(this,Rn)}setDefaultOptions(e){J(this,Rn,e)}setQueryDefaults(e,t){O(this,Nr).set(cr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...O(this,Nr).values()],n={};return t.forEach(r=>{si(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){O(this,Tr).set(cr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...O(this,Tr).values()];let n={};return t.forEach(r=>{si(e,r.mutationKey)&&(n={...n,...r.defaultOptions})}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...O(this,Rn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=As(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===zi&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...O(this,Rn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){O(this,je).clear(),O(this,Tn).clear()}},je=new WeakMap,Tn=new WeakMap,Rn=new WeakMap,Nr=new WeakMap,Tr=new WeakMap,An=new WeakMap,Rr=new WeakMap,Ar=new WeakMap,Jc),ht,ye,mi,lt,rr,Pr,Pn,en,gi,Dr,Fr,ir,or,Dn,Mr,Oe,ti,ts,ns,rs,is,os,ss,as,il,zc,Qf=(zc=class extends Br{constructor(t,n){super();oe(this,Oe);oe(this,ht);oe(this,ye);oe(this,mi);oe(this,lt);oe(this,rr);oe(this,Pr);oe(this,Pn);oe(this,en);oe(this,gi);oe(this,Dr);oe(this,Fr);oe(this,ir);oe(this,or);oe(this,Dn);oe(this,Mr,new Set);this.options=n,J(this,ht,t),J(this,en,null),J(this,Pn,es()),this.options.experimental_prefetchInRender||O(this,Pn).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,ye).addObserver(this),Ka(O(this,ye),this.options)?pe(this,Oe,ti).call(this):this.updateResult(),pe(this,Oe,is).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return cs(O(this,ye),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return cs(O(this,ye),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,pe(this,Oe,os).call(this),pe(this,Oe,ss).call(this),O(this,ye).removeObserver(this)}setOptions(t,n){const r=this.options,o=O(this,ye);if(this.options=O(this,ht).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ht(this.options.enabled,O(this,ye))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");pe(this,Oe,as).call(this),O(this,ye).setOptions(this.options),r._defaulted&&!Ji(this.options,r)&&O(this,ht).getQueryCache().notify({type:"observerOptionsUpdated",query:O(this,ye),observer:this});const i=this.hasListeners();i&&Va(O(this,ye),o,this.options,r)&&pe(this,Oe,ti).call(this),this.updateResult(n),i&&(O(this,ye)!==o||Ht(this.options.enabled,O(this,ye))!==Ht(r.enabled,O(this,ye))||br(this.options.staleTime,O(this,ye))!==br(r.staleTime,O(this,ye)))&&pe(this,Oe,ts).call(this);const s=pe(this,Oe,ns).call(this);i&&(O(this,ye)!==o||Ht(this.options.enabled,O(this,ye))!==Ht(r.enabled,O(this,ye))||s!==O(this,Dn))&&pe(this,Oe,rs).call(this,s)}getOptimisticResult(t){const n=O(this,ht).getQueryCache().build(O(this,ht),t),r=this.createResult(n,t);return Yf(this,r)&&(J(this,lt,r),J(this,Pr,this.options),J(this,rr,O(this,ye).state)),r}getCurrentResult(){return O(this,lt)}trackResult(t,n){const r={};return Object.keys(t).forEach(o=>{Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(o),n==null||n(o),t[o])})}),r}trackProp(t){O(this,Mr).add(t)}getCurrentQuery(){return O(this,ye)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=O(this,ht).defaultQueryOptions(t),r=O(this,ht).getQueryCache().build(O(this,ht),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return pe(this,Oe,ti).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),O(this,lt)))}createResult(t,n){var N;const r=O(this,ye),o=this.options,i=O(this,lt),s=O(this,rr),a=O(this,Pr),u=t!==r?t.state:O(this,mi),{state:d}=t;let f={...d},p=!1,m;if(n._optimisticResults){const D=this.hasListeners(),U=!D&&Ka(t,n),G=D&&Va(t,r,n,o);(U||G)&&(f={...f,...nl(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:w,errorUpdatedAt:v,status:h}=f;if(n.select&&f.data!==void 0)if(i&&f.data===(s==null?void 0:s.data)&&n.select===O(this,gi))m=O(this,Dr);else try{J(this,gi,n.select),m=n.select(f.data),m=Zo(i==null?void 0:i.data,m,n),J(this,Dr,m),J(this,en,null)}catch(D){J(this,en,D)}else m=f.data;if(n.placeholderData!==void 0&&m===void 0&&h==="pending"){let D;if(i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))D=i.data;else if(D=typeof n.placeholderData=="function"?n.placeholderData((N=O(this,Fr))==null?void 0:N.state.data,O(this,Fr)):n.placeholderData,n.select&&D!==void 0)try{D=n.select(D),J(this,en,null)}catch(U){J(this,en,U)}D!==void 0&&(h="success",m=Zo(i==null?void 0:i.data,D,n),p=!0)}O(this,en)&&(w=O(this,en),m=O(this,Dr),v=Date.now(),h="error");const x=f.fetchStatus==="fetching",g=h==="pending",b=h==="error",_=g&&x,C=m!==void 0,S={status:h,fetchStatus:f.fetchStatus,isPending:g,isSuccess:h==="success",isError:b,isInitialLoading:_,isLoading:_,data:m,dataUpdatedAt:f.dataUpdatedAt,error:w,errorUpdatedAt:v,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:x,isRefetching:x&&!g,isLoadingError:b&&!C,isPaused:f.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:b&&C,isStale:Ds(t,n),refetch:this.refetch,promise:O(this,Pn)};if(this.options.experimental_prefetchInRender){const D=z=>{S.status==="error"?z.reject(S.error):S.data!==void 0&&z.resolve(S.data)},U=()=>{const z=J(this,Pn,S.promise=es());D(z)},G=O(this,Pn);switch(G.status){case"pending":t.queryHash===r.queryHash&&D(G);break;case"fulfilled":(S.status==="error"||S.data!==G.value)&&U();break;case"rejected":(S.status!=="error"||S.error!==G.reason)&&U();break}}return S}updateResult(t){const n=O(this,lt),r=this.createResult(O(this,ye),this.options);if(J(this,rr,O(this,ye).state),J(this,Pr,this.options),O(this,rr).data!==void 0&&J(this,Fr,O(this,ye)),Ji(r,n))return;J(this,lt,r);const o={},i=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!O(this,Mr).size)return!0;const l=new Set(a??O(this,Mr));return this.options.throwOnError&&l.add("error"),Object.keys(O(this,lt)).some(u=>{const d=u;return O(this,lt)[d]!==n[d]&&l.has(d)})};(t==null?void 0:t.listeners)!==!1&&i()&&(o.listeners=!0),pe(this,Oe,il).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&pe(this,Oe,is).call(this)}},ht=new WeakMap,ye=new WeakMap,mi=new WeakMap,lt=new WeakMap,rr=new WeakMap,Pr=new WeakMap,Pn=new WeakMap,en=new WeakMap,gi=new WeakMap,Dr=new WeakMap,Fr=new WeakMap,ir=new WeakMap,or=new WeakMap,Dn=new WeakMap,Mr=new WeakMap,Oe=new WeakSet,ti=function(t){pe(this,Oe,as).call(this);let n=O(this,ye).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(At)),n},ts=function(){pe(this,Oe,os).call(this);const t=br(this.options.staleTime,O(this,ye));if(ar||O(this,lt).isStale||!Qo(t))return;const r=Qc(O(this,lt).dataUpdatedAt,t)+1;J(this,ir,setTimeout(()=>{O(this,lt).isStale||this.updateResult()},r))},ns=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(O(this,ye)):this.options.refetchInterval)??!1},rs=function(t){pe(this,Oe,ss).call(this),J(this,Dn,t),!(ar||Ht(this.options.enabled,O(this,ye))===!1||!Qo(O(this,Dn))||O(this,Dn)===0)&&J(this,or,setInterval(()=>{(this.options.refetchIntervalInBackground||Ps.isFocused())&&pe(this,Oe,ti).call(this)},O(this,Dn)))},is=function(){pe(this,Oe,ts).call(this),pe(this,Oe,rs).call(this,pe(this,Oe,ns).call(this))},os=function(){O(this,ir)&&(clearTimeout(O(this,ir)),J(this,ir,void 0))},ss=function(){O(this,or)&&(clearInterval(O(this,or)),J(this,or,void 0))},as=function(){const t=O(this,ht).getQueryCache().build(O(this,ht),this.options);if(t===O(this,ye))return;const n=O(this,ye);J(this,ye,t),J(this,mi,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},il=function(t){We.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(O(this,lt))}),O(this,ht).getQueryCache().notify({query:O(this,ye),type:"observerResultsUpdated"})})},zc);function Xf(e,t){return Ht(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ka(e,t){return Xf(e,t)||e.state.data!==void 0&&cs(e,t,t.refetchOnMount)}function cs(e,t,n){if(Ht(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Ds(e,t)}return!1}function Va(e,t,n,r){return(e!==t||Ht(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Ds(e,n)}function Ds(e,t){return Ht(t.enabled,e)!==!1&&e.isStaleByTime(br(t.staleTime,e))}function Yf(e,t){return!Ji(e.getCurrentResult(),t)}var Fn,Mn,mt,pn,gn,Ui,ls,Gc,Zf=(Gc=class extends Br{constructor(n,r){super();oe(this,gn);oe(this,Fn);oe(this,Mn);oe(this,mt);oe(this,pn);J(this,Fn,n),this.setOptions(r),this.bindMethods(),pe(this,gn,Ui).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,Fn).defaultMutationOptions(n),Ji(this.options,r)||O(this,Fn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:O(this,mt),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&cr(r.mutationKey)!==cr(this.options.mutationKey)?this.reset():((o=O(this,mt))==null?void 0:o.state.status)==="pending"&&O(this,mt).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=O(this,mt))==null||n.removeObserver(this)}onMutationUpdate(n){pe(this,gn,Ui).call(this),pe(this,gn,ls).call(this,n)}getCurrentResult(){return O(this,Mn)}reset(){var n;(n=O(this,mt))==null||n.removeObserver(this),J(this,mt,void 0),pe(this,gn,Ui).call(this),pe(this,gn,ls).call(this)}mutate(n,r){var o;return J(this,pn,r),(o=O(this,mt))==null||o.removeObserver(this),J(this,mt,O(this,Fn).getMutationCache().build(O(this,Fn),this.options)),O(this,mt).addObserver(this),O(this,mt).execute(n)}},Fn=new WeakMap,Mn=new WeakMap,mt=new WeakMap,pn=new WeakMap,gn=new WeakSet,Ui=function(){var r;const n=((r=O(this,mt))==null?void 0:r.state)??rl();J(this,Mn,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},ls=function(n){We.batch(()=>{var r,o,i,s,a,l,u,d;if(O(this,pn)&&this.hasListeners()){const f=O(this,Mn).variables,p=O(this,Mn).context;(n==null?void 0:n.type)==="success"?((o=(r=O(this,pn)).onSuccess)==null||o.call(r,n.data,f,p),(s=(i=O(this,pn)).onSettled)==null||s.call(i,n.data,null,f,p)):(n==null?void 0:n.type)==="error"&&((l=(a=O(this,pn)).onError)==null||l.call(a,n.error,f,p),(d=(u=O(this,pn)).onSettled)==null||d.call(u,void 0,n.error,f,p))}this.listeners.forEach(f=>{f(O(this,Mn))})})},Gc),ol=V.createContext(void 0),Ot=e=>{const t=V.useContext(ol);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ep=({client:e,children:t})=>(V.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),c.jsx(ol.Provider,{value:e,children:t})),sl=V.createContext(!1),tp=()=>V.useContext(sl);sl.Provider;function np(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var rp=V.createContext(np()),ip=()=>V.useContext(rp);function al(e,t){return typeof e=="function"?e(...t):!!e}function us(){}var op=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},sp=e=>{V.useEffect(()=>{e.clearReset()},[e])},ap=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||al(n,[e.error,r])),cp=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)))},lp=(e,t)=>e.isLoading&&e.isFetching&&!t,up=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,$a=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function dp(e,t,n){var f,p,m,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=Ot(),o=tp(),i=ip(),s=r.defaultQueryOptions(e);(p=(f=r.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||p.call(f,s),s._optimisticResults=o?"isRestoring":"optimistic",cp(s),op(s,i),sp(i);const a=!r.getQueryCache().get(s.queryHash),[l]=V.useState(()=>new t(r,s)),u=l.getOptimisticResult(s),d=!o&&e.subscribed!==!1;if(V.useSyncExternalStore(V.useCallback(h=>{const x=d?l.subscribe(We.batchCalls(h)):us;return l.updateResult(),x},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),V.useEffect(()=>{l.setOptions(s,{listeners:!1})},[s,l]),up(s,u))throw $a(s,l,i);if(ap({result:u,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw u.error;if((w=(m=r.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||w.call(m,s,u),s.experimental_prefetchInRender&&!ar&&lp(u,o)){const h=a?$a(s,l,i):(v=r.getQueryCache().get(s.queryHash))==null?void 0:v.promise;h==null||h.catch(us).finally(()=>{l.updateResult()})}return s.notifyOnChangeProps?u:l.trackResult(u)}function yn(e,t){return dp(e,Qf)}function Wr(e,t){const n=Ot(),[r]=V.useState(()=>new Zf(n,e));V.useEffect(()=>{r.setOptions(e)},[r,e]);const o=V.useSyncExternalStore(V.useCallback(s=>r.subscribe(We.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=V.useCallback((s,a)=>{r.mutate(s,a).catch(us)},[r]);if(o.error&&al(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:i,mutateAsync:o.mutate}}const cl=y.createContext(null),fp=cl.Provider,ll=()=>{const e=y.useContext(cl);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 ul=y.createContext(void 0);function Dt(){const e=y.useContext(ul);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const pp=(()=>{const e={};return Object.values(ue).forEach(t=>{e[t]={}}),e})();function hp({children:e}){const[t,n]=y.useState(pp),r=y.useCallback((d,f,p=!0)=>{n(m=>{const w={...m};return w[d]=w[d]||{},w[d][f]=p,w})},[n]),o=y.useCallback((d,f)=>{var p;return!!((p=t[d])!=null&&p[f])},[t]),i=y.useCallback((d,f)=>{var p;return(p=t[d])==null?void 0:p[f]},[t]),s=y.useCallback((d,f)=>{n(p=>{var w;const m={...p};return(w=m[d])==null||delete w[f],m})},[n]),a=y.useCallback(d=>{n(f=>{const p={...f};return p[d]={},p})},[n]),l=y.useCallback((d,f)=>{n(p=>{const m={...p};return m[d]=m[d]||{},f.forEach(w=>{m[d][w]=!0}),m})},[n]),u=y.useMemo(()=>({errorState:t,setErrorState:n,setError:r,isError:o,removeError:s,resetBoundary:a,setErrors:l,getError:i}),[t,n,r,o,s,a,l,i]);return c.jsx(ul.Provider,{value:u,children:e})}const mp="https://api.withampersand.com/v1".replace(/\/+$/,"");class Fs{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:mp}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||fl}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 gp=new Fs,fo=class fo{constructor(t=gp){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 wp(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?fo.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 dl(i,"Response returned an error code")}async createFetchParams(t,n){let r=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(r+="?"+this.configuration.queryParamsStringify(t.query));const o=Object.assign({},this.configuration.headers,t.headers);Object.keys(o).forEach(u=>o[u]===void 0?delete o[u]:{});const i=typeof n=="function"?n:async()=>n,s={method:t.method,headers:o,body:t.body,credentials:this.configuration.credentials},a={...s,...await i({init:s,context:t})},l={...a,body:vp(a.body)||a.body instanceof URLSearchParams||yp(a.body)?a.body:JSON.stringify(a.body)};return{url:r,init:l}}clone(){const t=this.constructor,n=new t(this.configuration);return n.middleware=this.middleware.slice(),n}};fo.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let tn=fo;function yp(e){return typeof Blob<"u"&&e instanceof Blob}function vp(e){return typeof FormData<"u"&&e instanceof FormData}class dl extends Error{constructor(t,n){super(n),this.response=t,this.name="ResponseError"}}class wp extends Error{constructor(t,n){super(n),this.cause=t,this.name="FetchError"}}class re extends Error{constructor(t,n){super(n),this.field=t,this.name="RequiredError"}}function R(e,t){const n=e[t];return n!=null}function fl(e,t=""){return Object.keys(e).map(n=>pl(n,e[n],t)).filter(n=>n.length>0).join("&")}function pl(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 pl(e,o,n)}return t instanceof Date?`${encodeURIComponent(r)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?fl(t,r):`${encodeURIComponent(r)}=${encodeURIComponent(String(t))}`}function lr(e,t){return Object.keys(e).reduce((n,r)=>({...n,[r]:t(e[r])}),{})}class ke{constructor(t,n=r=>r){this.raw=t,this.transformer=n}async value(){return this.transformer(await this.raw.json())}}class ur{constructor(t){this.raw=t}async value(){}}class Ua{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function Ip(e){return bp(e)}function bp(e,t){return e==null?e:{fieldUsed:R(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:R(e,"keyFormat")?e.keyFormat:void 0}}function xp(e){return _p(e)}function _p(e,t){return e==null?e:{name:e.name,valuePrefix:R(e,"valuePrefix")?e.valuePrefix:void 0}}function Cp(e){return Op(e)}function Op(e,t){return e==null?e:{name:e.name}}function Ep(e){return Sp(e)}function Sp(e,t){return e==null?e:{attachmentType:e.attachmentType,query:R(e,"query")?Cp(e.query):void 0,header:R(e,"header")?xp(e.header):void 0,docsURL:R(e,"docsURL")?e.docsURL:void 0}}function Np(e){return Tp(e)}function Tp(e,t){return e==null?e:{enabled:R(e,"enabled")?e.enabled:void 0,includeFullRecords:R(e,"includeFullRecords")?e.includeFullRecords:void 0}}function Rp(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,includeFullRecords:e.includeFullRecords}}const qa={Oauth2:"oauth2",ApiKey:"apiKey",Basic:"basic",Jwt:"jwt",None:"none"};function Ap(e){return Pp(e)}function Pp(e,t){return e}function Dp(e){return Fp(e)}function Fp(e,t){return e==null?e:{days:R(e,"days")?e.days:void 0,fullHistory:R(e,"fullHistory")?e.fullHistory:void 0}}function Mp(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function hl(e){return jp(e)}function jp(e,t){return e==null?e:{defaultPeriod:Dp(e.defaultPeriod)}}function kp(e){if(e!==void 0)return e===null?null:{defaultPeriod:Mp(e.defaultPeriod)}}function Lp(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function Kp(e){if(e!==void 0)return e===null?null:{defaultPeriod:Lp(e.defaultPeriod)}}function Vp(e){return $p(e)}function $p(e,t){return e==null?e:{enabled:R(e,"enabled")?e.enabled:void 0}}function ml(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Up(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,schedule:e.schedule,destination:e.destination,selectedFields:e.selectedFields,selectedValueMappings:e.selectedValueMappings,selectedFieldMappings:e.selectedFieldMappings,selectedFieldsAuto:e.selectedFieldsAuto,backfill:Kp(e.backfill)}}function qp(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:lr(e.objects,Up)}}function Hp(e){if(e!==void 0)return e===null?null:{stringValue:e.stringValue,integerValue:e.integerValue,booleanValue:e.booleanValue}}function Bp(e){if(e!==void 0)return e===null?null:{default:Hp(e._default),writeOnCreate:e.writeOnCreate,writeOnUpdate:e.writeOnUpdate}}function Wp(e){let t=!0;return t=t&&"value"in e,t}function Jp(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function zp(e){let t=!0;return t=t&&"value"in e,t}function Gp(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function Qp(e){let t=!0;return t=t&&"value"in e,t}function Xp(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function Yp(e){if(e!==void 0)return e===null?null:Wp(e)?Jp(e):zp(e)?Gp(e):Qp(e)?Xp(e):{}}function Zp(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,selectedValueDefaults:e.selectedValueDefaults===void 0?void 0:lr(e.selectedValueDefaults,Yp),selectedFieldSettings:e.selectedFieldSettings===void 0?void 0:lr(e.selectedFieldSettings,Bp)}}function eh(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:lr(e.objects,Zp)}}function th(e){return nh(e)}function nh(e,t){return e==null?e:{apiKeyAsBasic:R(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:R(e,"apiKeyAsBasicOpts")?Ip(e.apiKeyAsBasicOpts):void 0,docsURL:R(e,"docsURL")?e.docsURL:void 0}}function rh(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function ih(e){return oh(e)}function oh(e,t){return e==null?e:{value:e.value}}function sh(e){return ah(e)}function ah(e,t){return e==null?e:{brandingRemoval:R(e,"brandingRemoval")?ih(e.brandingRemoval):void 0}}function Di(e){return ch(e)}function ch(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:R(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:R(e,"updateTime")?new Date(e.updateTime):void 0,entitlements:R(e,"entitlements")?sh(e.entitlements):void 0}}function lh(e){return uh(e)}function uh(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function dh(e){return fh(e)}function fh(e,t){return e==null?e:{provider:e.provider,read:R(e,"read")?e.read:void 0,write:R(e,"write")?e.write:void 0,proxy:R(e,"proxy")?Vp(e.proxy):void 0}}function ph(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:e.read,write:e.write,proxy:ml(e.proxy)}}function hh(e){return mh(e)}function mh(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:dh(e.content)}}function gh(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:R(e,"updateTime")?new Date(e.updateTime):void 0}}function gl(e){return vh(e)}function vh(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:R(e,"updateTime")?new Date(e.updateTime):void 0}}function wh(e){return Ih(e)}function Ih(e,t){return e==null?e:{token:e.token,issuedAt:R(e,"issuedAt")?new Date(e.issuedAt):void 0,expiresAt:R(e,"expiresAt")?new Date(e.expiresAt):void 0}}function bh(e){return xh(e)}function xh(e,t){return e==null?e:{token:e.token,issuedAt:R(e,"issuedAt")?new Date(e.issuedAt):void 0,expiresAt:R(e,"expiresAt")?new Date(e.expiresAt):void 0}}function _h(e){return Ch(e)}function Ch(e,t){return e==null?e:{accessToken:R(e,"accessToken")?wh(e.accessToken):void 0,refreshToken:R(e,"refreshToken")?bh(e.refreshToken):void 0,scopes:R(e,"scopes")?e.scopes:void 0}}function qi(e){return Oh(e)}function Oh(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:R(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:R(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:R(e,"updateTime")?new Date(e.updateTime):void 0}}function ni(e){return Eh(e)}function Eh(e,t){return e==null?e:{id:e.id,projectId:e.projectId,provider:e.provider,providerApp:R(e,"providerApp")?qi(e.providerApp):void 0,group:gl(e.group),consumer:gh(e.consumer),providerWorkspaceRef:R(e,"providerWorkspaceRef")?e.providerWorkspaceRef:void 0,providerConsumerRef:R(e,"providerConsumerRef")?e.providerConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:R(e,"updateTime")?new Date(e.updateTime):void 0,authScheme:e.authScheme,status:e.status,oauth2AuthorizationCode:R(e,"oauth2AuthorizationCode")?_h(e.oauth2AuthorizationCode):void 0,apiKey:R(e,"apiKey")?e.apiKey:void 0}}function yl(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function vl(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function wl(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 Sh(e){if(e!==void 0)return e===null?null:{token:e.token,expiresAt:e.expiresAt===void 0?void 0:e.expiresAt.toISOString(),issuedAt:e.issuedAt===void 0?void 0:e.issuedAt.toISOString()}}function Nh(e){if(e!==void 0)return e===null?null:{token:e.token,expiresAt:e.expiresAt===void 0?void 0:e.expiresAt.toISOString(),issuedAt:e.issuedAt===void 0?void 0:e.issuedAt.toISOString()}}function Il(e){if(e!==void 0)return e===null?null:{accessToken:Sh(e.accessToken),refreshToken:Nh(e.refreshToken),scopes:e.scopes}}function Th(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,basicAuth:yl(e.basicAuth),oauth2ClientCredentials:vl(e.oauth2ClientCredentials),oauth2PasswordCredentials:wl(e.oauth2PasswordCredentials),oauth2AuthorizationCode:Il(e.oauth2AuthorizationCode)}}function Rh(e){return Ah(e)}function Ah(e,t){return e==null?e:{enabled:R(e,"enabled")?e.enabled:void 0}}function Ph(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Dh(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:ph(e.content)}}function Fh(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:Dh(e.config)}}function Mh(e){return jh(e)}function jh(e,t){return e==null?e:{enabled:R(e,"enabled")?e.enabled:void 0}}function kh(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Lh(e){return Kh(e)}function Kh(e,t){return e==null?e:{mode:R(e,"mode")?e.mode:void 0,pageSize:R(e,"pageSize")?e.pageSize:void 0}}function Vh(e){if(e!==void 0)return e===null?null:{mode:e.mode,pageSize:e.pageSize}}function $h(e){let t=!0;return t=t&&"fieldName"in e,t}function Uh(e,t){return e==null?e:{fieldName:e.fieldName,mapToName:R(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:R(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function qh(e){if(e!==void 0)return e===null?null:{fieldName:e.fieldName,mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName}}function Hh(e){let t=!0;return t=t&&"mapToName"in e,t}function bl(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:R(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:R(e,"default")?e.default:void 0,prompt:R(e,"prompt")?e.prompt:void 0}}function Bh(e){if(e!==void 0)return e===null?null:{mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName,default:e._default,prompt:e.prompt}}function Ha(e){return Wh(e)}function Wh(e,t){return e==null?e:{...Uh(e),...bl(e)}}function Ba(e){if(e!==void 0)return e===null?null:$h(e)?qh(e):Hh(e)?Bh(e):{}}function xl(e){return Jh(e)}function Jh(e,t){return e}function zh(e){return Gh(e)}function Gh(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,mapToName:R(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:R(e,"mapToDisplayName")?e.mapToDisplayName:void 0,requiredFields:R(e,"requiredFields")?e.requiredFields.map(Ha):void 0,optionalFields:R(e,"optionalFields")?e.optionalFields.map(Ha):void 0,optionalFieldsAuto:R(e,"optionalFieldsAuto")?xl(e.optionalFieldsAuto):void 0,backfill:R(e,"backfill")?hl(e.backfill):void 0,delivery:R(e,"delivery")?Lh(e.delivery):void 0}}function Qh(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(Ba),optionalFields:e.optionalFields===void 0?void 0:e.optionalFields.map(Ba),optionalFieldsAuto:e.optionalFieldsAuto,backfill:kp(e.backfill),delivery:Vh(e.delivery)}}function Xh(e){return Yh(e)}function Yh(e,t){return e==null?e:{objects:R(e,"objects")?e.objects.map(zh):void 0}}function Zh(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Qh)}}function em(e){return tm(e)}function tm(e,t){return e==null?e:{enabled:R(e,"enabled")?e.enabled:void 0}}function nm(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function rm(e){return im(e)}function im(e,t){return e==null?e:{enabled:R(e,"enabled")?e.enabled:void 0,watchFieldsAuto:R(e,"watchFieldsAuto")?e.watchFieldsAuto:void 0,requiredWatchFields:R(e,"requiredWatchFields")?e.requiredWatchFields:void 0}}function om(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,watchFieldsAuto:e.watchFieldsAuto,requiredWatchFields:e.requiredWatchFields}}function sm(e){return am(e)}function am(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,inheritFieldsAndMapping:R(e,"inheritFieldsAndMapping")?e.inheritFieldsAndMapping:void 0,createEvent:R(e,"createEvent")?Rh(e.createEvent):void 0,updateEvent:R(e,"updateEvent")?rm(e.updateEvent):void 0,deleteEvent:R(e,"deleteEvent")?em(e.deleteEvent):void 0,associationChangeEvent:R(e,"associationChangeEvent")?Np(e.associationChangeEvent):void 0,otherEvents:R(e,"otherEvents")?e.otherEvents:void 0}}function cm(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,destination:e.destination,inheritFieldsAndMapping:e.inheritFieldsAndMapping,createEvent:Ph(e.createEvent),updateEvent:om(e.updateEvent),deleteEvent:nm(e.deleteEvent),associationChangeEvent:Rp(e.associationChangeEvent),otherEvents:e.otherEvents}}function lm(e){return um(e)}function um(e,t){return e==null?e:{objects:R(e,"objects")?e.objects.map(sm):void 0}}function dm(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(cm)}}function _l(e){return fm(e)}function fm(e,t){return e==null?e:{allowAnyFields:R(e,"allowAnyFields")?e.allowAnyFields:void 0}}function pm(e){if(e!==void 0)return e===null?null:{allowAnyFields:e.allowAnyFields}}function hm(e){return mm(e)}function mm(e,t){return e==null?e:{objectName:e.objectName,inheritMapping:R(e,"inheritMapping")?e.inheritMapping:void 0,valueDefaults:R(e,"valueDefaults")?_l(e.valueDefaults):void 0}}function gm(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,inheritMapping:e.inheritMapping,valueDefaults:pm(e.valueDefaults)}}function ym(e){return vm(e)}function vm(e,t){return e==null?e:{objects:R(e,"objects")?e.objects.map(hm):void 0}}function wm(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(gm)}}function Im(e){return bm(e)}function bm(e,t){return e==null?e:{name:e.name,displayName:R(e,"displayName")?e.displayName:void 0,provider:e.provider,read:R(e,"read")?Xh(e.read):void 0,write:R(e,"write")?ym(e.write):void 0,proxy:R(e,"proxy")?Mh(e.proxy):void 0,subscribe:R(e,"subscribe")?lm(e.subscribe):void 0}}function xm(e){if(e!==void 0)return e===null?null:{name:e.name,displayName:e.displayName,provider:e.provider,read:Zh(e.read),write:wm(e.write),proxy:kh(e.proxy),subscribe:dm(e.subscribe)}}function _m(e){if(e!==void 0)return e===null?null:{specVersion:e.specVersion,content:xm(e.content)}}function Cm(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:_m(e.latestRevision)}}function Om(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function Em(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 Sm(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function Nm(e){return Tm(e)}function Tm(e,t){return e==null?e:{value:e.value,displayValue:e.displayValue}}function Rm(e){return Am(e)}function Am(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,valueType:R(e,"valueType")?e.valueType:void 0,providerType:R(e,"providerType")?e.providerType:void 0,readOnly:R(e,"readOnly")?e.readOnly:void 0,values:R(e,"values")?e.values.map(Nm):void 0}}function Pm(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,basicAuth:yl(e.basicAuth),oauth2ClientCredentials:vl(e.oauth2ClientCredentials),oauth2PasswordCredentials:wl(e.oauth2PasswordCredentials),oauth2AuthorizationCode:Il(e.oauth2AuthorizationCode)}}function Dm(e){return Fm(e)}function Fm(e,t){return e==null?e:{enabled:R(e,"enabled")?e.enabled:void 0}}function Mm(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,mapToName:R(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:R(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function Po(e){return jm(e)}function jm(e,t){return e==null?e:{...Mm(e),...bl(e)}}function km(e){return Lm(e)}function Lm(e,t){return e==null?e:{error:R(e,"error")?e.error:void 0,objectName:e.objectName,displayName:e.displayName,mapToName:R(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:R(e,"mapToDisplayName")?e.mapToDisplayName:void 0,destination:e.destination,schedule:e.schedule,requiredFields:R(e,"requiredFields")?e.requiredFields.map(Po):void 0,optionalFields:R(e,"optionalFields")?e.optionalFields.map(Po):void 0,optionalFieldsAuto:R(e,"optionalFieldsAuto")?xl(e.optionalFieldsAuto):void 0,allFields:R(e,"allFields")?e.allFields.map(Po):void 0,allFieldsMetadata:R(e,"allFieldsMetadata")?lr(e.allFieldsMetadata,Rm):void 0,backfill:R(e,"backfill")?hl(e.backfill):void 0}}function Km(e){return Vm(e)}function Vm(e,t){return e==null?e:{objects:R(e,"objects")?e.objects.map(km):void 0}}function $m(e){return Um(e)}function Um(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,valueDefaults:R(e,"valueDefaults")?_l(e.valueDefaults):void 0}}function qm(e){return Hm(e)}function Hm(e,t){return e==null?e:{objects:R(e,"objects")?e.objects.map($m):void 0}}function Bm(e){return Wm(e)}function Wm(e,t){return e==null?e:{name:e.name,displayName:R(e,"displayName")?e.displayName:void 0,provider:e.provider,read:R(e,"read")?Km(e.read):void 0,write:R(e,"write")?qm(e.write):void 0,proxy:R(e,"proxy")?Dm(e.proxy):void 0}}function Jm(e){return zm(e)}function zm(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Bm(e.content)}}function Fi(e){return Gm(e)}function Gm(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:R(e,"group")?gl(e.group):void 0,healthStatus:e.healthStatus,connection:ni(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:R(e,"updateTime")?new Date(e.updateTime):void 0,config:hh(e.config)}}function Qm(e){return Xm(e)}function Xm(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Im(e.content)}}function Wa(e){return Ym(e)}function Ym(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:R(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Qm(e.latestRevision)}}function Zm(e){return eg(e)}function eg(e,t){return e==null?e:{iconURL:R(e,"iconURL")?e.iconURL:void 0,logoURL:R(e,"logoURL")?e.logoURL:void 0}}function tg(e){return ng(e)}function ng(e,t){return e==null?e:{iconURL:R(e,"iconURL")?e.iconURL:void 0,logoURL:R(e,"logoURL")?e.logoURL:void 0}}function rg(e){return ig(e)}function ig(e,t){return e==null?e:{regular:R(e,"regular")?tg(e.regular):void 0,darkMode:R(e,"darkMode")?Zm(e.darkMode):void 0}}function og(e){return sg(e)}function sg(e,t){return e==null?e:{create:R(e,"create")?e.create:void 0,update:R(e,"update")?e.update:void 0,_delete:R(e,"delete")?e.delete:void 0,passThrough:R(e,"passThrough")?e.passThrough:void 0}}function Cl(e){return ag(e)}function ag(e,t){return e==null?e:{bulkWrite:lh(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write,subscribeSupport:R(e,"subscribeSupport")?og(e.subscribeSupport):void 0}}function cg(e){return lg(e)}function lg(e,t){return e==null?e:{displayName:e.displayName,baseURL:e.baseURL,support:Cl(e.support)}}function ug(e){return dg(e)}function dg(e,t){return e==null?e:{workspaceRefField:R(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:R(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:R(e,"scopesField")?e.scopesField:void 0}}const Do={AuthorizationCode:"authorizationCode",AuthorizationCodePkce:"authorizationCodePKCE",ClientCredentials:"clientCredentials",Password:"password"};function fg(e){return pg(e)}function pg(e,t){return e==null?e:{grantType:e.grantType,authURL:R(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:R(e,"audience")?e.audience:void 0,tokenMetadataFields:ug(e.tokenMetadataFields),docsURL:R(e,"docsURL")?e.docsURL:void 0,authURLParams:R(e,"authURLParams")?e.authURLParams:void 0}}function hg(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,projectId:e.projectId,groupRef:e.groupRef,groupName:e.groupName,consumerRef:e.consumerRef,consumerName:e.consumerName,providerAppId:e.providerAppId,provider:e.provider,enableCSRFProtection:e.enableCSRFProtection}}function mg(e){return gg(e)}function gg(e,t){return e==null?e:{subscriptionScope:e.subscriptionScope,targetURLScope:e.targetURLScope,registrationTiming:e.registrationTiming}}function Ja(e){return yg(e)}function yg(e,t){return e==null?e:{name:e.name,authType:Ap(e.authType),baseURL:e.baseURL,oauth2Opts:R(e,"oauth2Opts")?fg(e.oauth2Opts):void 0,apiKeyOpts:R(e,"apiKeyOpts")?Ep(e.apiKeyOpts):void 0,basicOpts:R(e,"basicOpts")?th(e.basicOpts):void 0,support:Cl(e.support),providerOpts:e.providerOpts,displayName:R(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:R(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:R(e,"media")?rg(e.media):void 0,labels:R(e,"labels")?e.labels:void 0,subscribeOpts:R(e,"subscribeOpts")?mg(e.subscribeOpts):void 0,modules:R(e,"modules")?lr(e.modules,cg):void 0}}function vg(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,connection:Th(e.connection)}}function wg(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:qp(e.read),write:eh(e.write),proxy:ml(e.proxy)}}function Ig(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:wg(e.content)}}function bg(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:Ig(e.config)}}function xg(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:bg(e.installation)}}function _g(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function Cg(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:_g(e.project)}}function Og(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 Eg(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:Og(e.providerApp)}}class Sg extends tn{async deleteConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new re("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 re("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:Pm(t.generateConnectionParams)},n);return new ke(i,s=>ni(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new re("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getConnection.");const r={};t.includeCreds!==void 0&&(r.includeCreds=t.includeCreds),t.includeRefreshToken!==void 0&&(r.includeRefreshToken=t.includeRefreshToken),t.refresh!==void 0&&(r.refresh=t.refresh);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"GET",headers:o,query:r},n);return new ke(i,s=>ni(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listConnections.");const r={};t.provider!==void 0&&(r.provider=t.provider),t.groupRef!==void 0&&(r.groupRef=t.groupRef),t.consumerRef!==void 0&&(r.consumerRef=t.consumerRef);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new ke(i,s=>s.map(ni))}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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new re("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling updateConnection.");if(t.updateConnectionRequest===null||t.updateConnectionRequest===void 0)throw new re("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:vg(t.updateConnectionRequest)},n);return new ke(i,s=>ni(s))}async updateConnection(t,n){return await(await this.updateConnectionRaw(t,n)).value()}}class Ng extends tn{async createInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new re("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new re("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:Fh(t.installation)},n);return new ke(i,s=>Fi(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new re("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new re("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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new re("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new re("installationId","Required parameter requestParameters.installationId was null or undefined when calling getInstallation.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"GET",headers:o,query:r},n);return new ke(i,s=>Fi(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new re("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listInstallations.");const r={};t.groupRef!==void 0&&(r.groupRef=t.groupRef);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"GET",headers:o,query:r},n);return new ke(i,s=>s.map(Fi))}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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new re("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new re("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new re("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:xg(t.installationUpdate)},n);return new ke(i,s=>Fi(s))}async updateInstallation(t,n){return await(await this.updateInstallationRaw(t,n)).value()}}class Tg extends tn{async batchUpsertIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");if(t.batchUpsertIntegrationsRequest===null||t.batchUpsertIntegrationsRequest===void 0)throw new re("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:rh(t.batchUpsertIntegrationsRequest)},n);return new ke(i,s=>s.map(Wa))}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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new re("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:Cm(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new re("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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listIntegrations.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new ke(i,s=>s.map(Wa))}async listIntegrations(t,n){return await(await this.listIntegrationsRaw(t,n)).value()}}class Rg extends tn{async oauthConnectRaw(t,n){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new re("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:hg(t.connectOAuthParams)},n);return this.isJsonMime(i.headers.get("content-type"))?new ke(i):new Ua(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling oauthUpdate.");if(t.connectionId===null||t.connectionId===void 0)throw new re("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 ke(i):new Ua(i)}async oauthUpdate(t,n){return await(await this.oauthUpdateRaw(t,n)).value()}}class Ag extends tn{async createProjectRaw(t,n){if(t.project===null||t.project===void 0)throw new re("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:Om(t.project)},n);return new ke(i,s=>Di(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 re("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 re("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 ke(i,s=>Di(s))}async getProject(t,n){return await(await this.getProjectRaw(t,n)).value()}async listProjectsRaw(t){const n={},r={};this.configuration&&this.configuration.apiKey&&(r["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/projects",method:"GET",headers:r,query:n},t);return new ke(o,i=>i.map(Di))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new re("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:Cg(t.projectUpdate)},n);return new ke(i,s=>Di(s))}async updateProject(t,n){return await(await this.updateProjectRaw(t,n)).value()}}class Pg extends tn{async getProviderRaw(t,n){if(t.provider===null||t.provider===void 0)throw new re("provider","Required parameter requestParameters.provider was null or undefined when calling getProvider.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/providers/{provider}".replace("{provider}",encodeURIComponent(String(t.provider))),method:"GET",headers:o,query:r},n);return new ke(i,s=>Ja(s))}async getProvider(t,n){return await(await this.getProviderRaw(t,n)).value()}async listProvidersRaw(t){const n={},r={};this.configuration&&this.configuration.apiKey&&(r["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const o=await this.request({path:"/providers",method:"GET",headers:r,query:n},t);return new ke(o,i=>lr(i,Ja))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class Dg extends tn{async createProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new re("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:Em(t.providerApp)},n);return new ke(i,s=>qi(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new re("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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listProviderApps.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new ke(i,s=>s.map(qi))}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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new re("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new re("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:Eg(t.providerAppUpdate)},n);return new ke(i,s=>qi(s))}async updateProviderApp(t,n){return await(await this.updateProviderAppRaw(t,n)).value()}}class Fg extends tn{async createRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new re("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");if(t.revision===null||t.revision===void 0)throw new re("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:Sm(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new re("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new re("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new re("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getHydratedRevision.");const r={};t.connectionId!==void 0&&(r.connectionId=t.connectionId);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/revisions/{revisionId}:hydrate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{revisionId}",encodeURIComponent(String(t.revisionId))),method:"GET",headers:o,query:r},n);return new ke(i,s=>Jm(s))}async getHydratedRevision(t,n){return await(await this.getHydratedRevisionRaw(t,n)).value()}}class Ol{constructor(t){this.connectionApi=new Sg(t),this.installationApi=new Ng(t),this.integrationApi=new Tg(t),this.oAuthApi=new Rg(t),this.projectApi=new Ag(t),this.providerApi=new Pg(t),this.providerAppApi=new Dg(t),this.revisionApi=new Fg(t)}}const El="2.7.1",Mg="v1",Mi="https://api.withampersand.com";function Sl(){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 Mi;case"mock":return"http://127.0.0.1:4010";case"":return Mi;default:return e??Mi}}catch{return Mi}}const jg=(e,t)=>`${e}/${t}`;function kg(){return jg(Sl(),Mg)}const Lg=Sl(),Nl=kg(),Kg=new Fs({basePath:Nl,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":El}});let Vg=new Ol(Kg);const Ms=()=>Vg;function ut(){const e=ll();return y.useCallback(async()=>{e||console.error("Unable to create API service without API key.");const n=new Fs({basePath:Nl,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":El,"X-Api-Key":e}});return new Ol(n)},[e])}const $g=e=>{const t=ut();return yn({queryKey:["project",e],queryFn:async()=>(await t()).projectApi.getProject({projectIdOrName:e})})},Tl=y.createContext({project:null,appName:"",projectId:"",projectIdOrName:"",isLoading:!0}),Te=()=>{const e=y.useContext(Tl);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function Ug({projectIdOrName:e,children:t}){const{setError:n}=Dt(),{data:r,isLoading:o,isError:i}=$g(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 c.jsx(Tl.Provider,{value:s,children:t})}function Rl(){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 dl){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 Fa=e=>{throw TypeError(e)};var Ro=(e,t,n)=>t.has(e)||Fa("Cannot "+n);var O=(e,t,n)=>(Ro(e,t,"read from private field"),n?n.call(e):t.get(e)),oe=(e,t,n)=>t.has(e)?Fa("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),W=(e,t,n,r)=>(Ro(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),pe=(e,t,n)=>(Ro(e,t,"access private method"),n);var Ai=(e,t,n,r)=>({set _(o){W(e,t,o,n)},get _(){return O(e,t,r)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),y=require("react");require("react-dom");function Lf(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 V=Lf(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 Pt(){}function Kf(e,t){return typeof e=="function"?e(t):e}function Qo(e){return typeof e=="number"&&e>=0&&e!==1/0}function Xc(e,t){return Math.max(e+(t||0)-Date.now(),0)}function br(e,t){return typeof e=="function"?e(t):e}function Bt(e,t){return typeof e=="function"?e(t):e}function Da(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==As(s,t.options))return!1}else if(!si(t.queryKey,s))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||o&&o!==t.state.fetchStatus||i&&!i(t))}function Ma(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(!si(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function As(e,t){return((t==null?void 0:t.queryKeyHashFn)||lr)(e)}function lr(e){return JSON.stringify(e,(t,n)=>Yo(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function si(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!si(e[n],t[n])):!1}function Xo(e,t){if(e===t)return e;const n=ka(e)&&ka(t);if(n||Yo(e)&&Yo(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{};let l=0;for(let u=0;u<s;u++){const d=n?u:i[u];(!n&&r.includes(d)||n)&&e[d]===void 0&&t[d]===void 0?(a[d]=void 0,l++):(a[d]=Xo(e[d],t[d]),a[d]===e[d]&&e[d]!==void 0&&l++)}return o===s&&l===o?e:a}return t}function Wi(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 ka(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Yo(e){if(!ja(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!ja(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function ja(e){return Object.prototype.toString.call(e)==="[object Object]"}function Vf(e){return new Promise(t=>{setTimeout(t,e)})}function Zo(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 Xo(e,t)}catch(r){console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`)}return Xo(e,t)}return t}function Uf(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function $f(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var zi=Symbol();function Yc(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===zi&&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===zi?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Zn,Nn,_r,Uc,qf=(Uc=class extends Br{constructor(){super();oe(this,Zn);oe(this,Nn);oe(this,_r);W(this,_r,t=>{if(!cr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){O(this,Nn)||this.setEventListener(O(this,_r))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,Nn))==null||t.call(this),W(this,Nn,void 0))}setEventListener(t){var n;W(this,_r,t),(n=O(this,Nn))==null||n.call(this),W(this,Nn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){O(this,Zn)!==t&&(W(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,Nn=new WeakMap,_r=new WeakMap,Uc),Ps=new qf,Cr,Tn,Or,$c,Hf=($c=class extends Br{constructor(){super();oe(this,Cr,!0);oe(this,Tn);oe(this,Or);W(this,Or,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,Tn)||this.setEventListener(O(this,Or))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,Tn))==null||t.call(this),W(this,Tn,void 0))}setEventListener(t){var n;W(this,Or,t),(n=O(this,Tn))==null||n.call(this),W(this,Tn,t(this.setOnline.bind(this)))}setOnline(t){O(this,Cr)!==t&&(W(this,Cr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return O(this,Cr)}},Cr=new WeakMap,Tn=new WeakMap,Or=new WeakMap,$c),Gi=new Hf;function es(){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 Bf(e){return Math.min(1e3*2**e,3e4)}function Zc(e){return(e??"online")==="online"?Gi.isOnline():!0}var el=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Ao(e){return e instanceof el}function tl(e){let t=!1,n=0,r=!1,o;const i=es(),s=v=>{var h;r||(p(new el(v)),(h=e.abort)==null||h.call(e))},a=()=>{t=!0},l=()=>{t=!1},u=()=>Ps.isFocused()&&(e.networkMode==="always"||Gi.isOnline())&&e.canRun(),d=()=>Zc(e.networkMode)&&e.canRun(),f=v=>{var h;r||(r=!0,(h=e.onSuccess)==null||h.call(e,v),o==null||o(),i.resolve(v))},p=v=>{var h;r||(r=!0,(h=e.onError)==null||h.call(e,v),o==null||o(),i.reject(v))},m=()=>new Promise(v=>{var h;o=x=>{(r||u())&&v(x)},(h=e.onPause)==null||h.call(e)}).then(()=>{var v;o=void 0,r||(v=e.onContinue)==null||v.call(e)}),w=()=>{if(r)return;let v;const h=n===0?e.initialPromise:void 0;try{v=h??e.fn()}catch(x){v=Promise.reject(x)}Promise.resolve(v).then(f).catch(x=>{var R;if(r)return;const g=e.retry??(cr?0:3),b=e.retryDelay??Bf,_=typeof b=="function"?b(n,x):b,C=g===!0||typeof g=="number"&&n<g||typeof g=="function"&&g(n,x);if(t||!C){p(x);return}n++,(R=e.onFail)==null||R.call(e,n,x),Vf(_).then(()=>u()?void 0:m()).then(()=>{t?p(x):w()})})};return{promise:i,cancel:s,continue:()=>(o==null||o(),i),cancelRetry:a,continueRetry:l,canStart:d,start:()=>(d()?w():m().then(w),i)}}function Jf(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=a=>setTimeout(a,0);const i=a=>{t?e.push(a):o(()=>{n(a)})},s=()=>{const a=e;e=[],a.length&&o(()=>{r(()=>{a.forEach(l=>{n(l)})})})};return{batch:a=>{let l;t++;try{l=a()}finally{t--,t||s()}return l},batchCalls:a=>(...l)=>{i(()=>{a(...l)})},schedule:i,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{o=a}}}var Je=Jf(),er,qc,nl=(qc=class{constructor(){oe(this,er)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Qo(this.gcTime)&&W(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)),W(this,er,void 0))}},er=new WeakMap,qc),Er,Sr,At,tr,at,pi,nr,qt,fn,Hc,Wf=(Hc=class extends nl{constructor(t){super();oe(this,qt);oe(this,Er);oe(this,Sr);oe(this,At);oe(this,tr);oe(this,at);oe(this,pi);oe(this,nr);W(this,nr,!1),W(this,pi,t.defaultOptions),this.setOptions(t.options),this.observers=[],W(this,tr,t.client),W(this,At,O(this,tr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,W(this,Er,zf(this.options)),this.state=t.state??O(this,Er),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=O(this,at))==null?void 0:t.promise}setOptions(t){this.options={...O(this,pi),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&O(this,At).remove(this)}setData(t,n){const r=Zo(this.state.data,t,this.options);return pe(this,qt,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){pe(this,qt,fn).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=O(this,at))==null?void 0:r.promise;return(o=O(this,at))==null||o.cancel(t),n?n.then(Pt).catch(Pt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(O(this,Er))}isActive(){return this.observers.some(t=>Bt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===zi||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||!Xc(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=O(this,at))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=O(this,at))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),O(this,At).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,at)&&(O(this,nr)?O(this,at).cancel({revert:!0}):O(this,at).cancelRetry()),this.scheduleGc()),O(this,At).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||pe(this,qt,fn).call(this,{type:"invalidate"})}fetch(t,n){var l,u,d;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(O(this,at))return O(this,at).continueRetry(),O(this,at).promise}if(t&&this.setOptions(t),!this.options.queryFn){const f=this.observers.find(p=>p.options.queryFn);f&&this.setOptions(f.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(W(this,nr,!0),r.signal)})},i=()=>{const f=Yc(this.options,n),p={client:O(this,tr),queryKey:this.queryKey,meta:this.meta};return o(p),W(this,nr,!1),this.options.persister?this.options.persister(f,p,this):f(p)},s={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:O(this,tr),state:this.state,fetchFn:i};o(s),(l=this.options.behavior)==null||l.onFetch(s,this),W(this,Sr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=s.fetchOptions)==null?void 0:u.meta))&&pe(this,qt,fn).call(this,{type:"fetch",meta:(d=s.fetchOptions)==null?void 0:d.meta});const a=f=>{var p,m,w,v;Ao(f)&&f.silent||pe(this,qt,fn).call(this,{type:"error",error:f}),Ao(f)||((m=(p=O(this,At).config).onError)==null||m.call(p,f,this),(v=(w=O(this,At).config).onSettled)==null||v.call(w,this.state.data,f,this)),this.scheduleGc()};return W(this,at,tl({initialPromise:n==null?void 0:n.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:f=>{var p,m,w,v;if(f===void 0){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(f)}catch(h){a(h);return}(m=(p=O(this,At).config).onSuccess)==null||m.call(p,f,this),(v=(w=O(this,At).config).onSettled)==null||v.call(w,f,this.state.error,this),this.scheduleGc()},onError:a,onFail:(f,p)=>{pe(this,qt,fn).call(this,{type:"failed",failureCount:f,error:p})},onPause:()=>{pe(this,qt,fn).call(this,{type:"pause"})},onContinue:()=>{pe(this,qt,fn).call(this,{type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0})),O(this,at).start()}},Er=new WeakMap,Sr=new WeakMap,At=new WeakMap,tr=new WeakMap,at=new WeakMap,pi=new WeakMap,nr=new WeakMap,qt=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,...rl(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 Ao(o)&&o.revert&&O(this,Sr)?{...O(this,Sr),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,At).notify({query:this,type:"updated",action:t})})},Hc);function rl(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Zc(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 Yt,Bc,Gf=(Bc=class extends Br{constructor(t={}){super();oe(this,Yt);this.config=t,W(this,Yt,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??As(o,n);let s=this.get(i);return s||(s=new Wf({client:t,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){O(this,Yt).has(t.queryHash)||(O(this,Yt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=O(this,Yt).get(t.queryHash);n&&(t.destroy(),n===t&&O(this,Yt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Je.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return O(this,Yt).get(t)}getAll(){return[...O(this,Yt).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Da(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>Da(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()})})}},Yt=new WeakMap,Bc),Zt,lt,rr,en,Sn,Jc,Qf=(Jc=class extends nl{constructor(t){super();oe(this,en);oe(this,Zt);oe(this,lt);oe(this,rr);this.mutationId=t.mutationId,W(this,lt,t.mutationCache),W(this,Zt,[]),this.state=t.state||il(),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,Zt).includes(t)||(O(this,Zt).push(t),this.clearGcTimeout(),O(this,lt).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){W(this,Zt,O(this,Zt).filter(n=>n!==t)),this.scheduleGc(),O(this,lt).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){O(this,Zt).length||(this.state.status==="pending"?this.scheduleGc():O(this,lt).remove(this))}continue(){var t;return((t=O(this,rr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,s,a,l,u,d,f,p,m,w,v,h,x,g,b,_,C,R,N;W(this,rr,tl({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(T,F)=>{pe(this,en,Sn).call(this,{type:"failed",failureCount:T,error:F})},onPause:()=>{pe(this,en,Sn).call(this,{type:"pause"})},onContinue:()=>{pe(this,en,Sn).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>O(this,lt).canRun(this)}));const n=this.state.status==="pending",r=!O(this,rr).canStart();try{if(!n){pe(this,en,Sn).call(this,{type:"pending",variables:t,isPaused:r}),await((i=(o=O(this,lt).config).onMutate)==null?void 0:i.call(o,t,this));const F=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));F!==this.state.context&&pe(this,en,Sn).call(this,{type:"pending",context:F,variables:t,isPaused:r})}const T=await O(this,rr).start();return await((u=(l=O(this,lt).config).onSuccess)==null?void 0:u.call(l,T,t,this.state.context,this)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,T,t,this.state.context)),await((m=(p=O(this,lt).config).onSettled)==null?void 0:m.call(p,T,null,this.state.variables,this.state.context,this)),await((v=(w=this.options).onSettled)==null?void 0:v.call(w,T,null,t,this.state.context)),pe(this,en,Sn).call(this,{type:"success",data:T}),T}catch(T){try{throw await((x=(h=O(this,lt).config).onError)==null?void 0:x.call(h,T,t,this.state.context,this)),await((b=(g=this.options).onError)==null?void 0:b.call(g,T,t,this.state.context)),await((C=(_=O(this,lt).config).onSettled)==null?void 0:C.call(_,void 0,T,this.state.variables,this.state.context,this)),await((N=(R=this.options).onSettled)==null?void 0:N.call(R,void 0,T,t,this.state.context)),T}finally{pe(this,en,Sn).call(this,{type:"error",error:T})}}finally{O(this,lt).runNext(this)}}},Zt=new WeakMap,lt=new WeakMap,rr=new WeakMap,en=new WeakSet,Sn=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,Zt).forEach(r=>{r.onMutationUpdate(t)}),O(this,lt).notify({mutation:this,type:"updated",action:t})})},Jc);function il(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var pn,Ht,hi,Wc,Xf=(Wc=class extends Br{constructor(t={}){super();oe(this,pn);oe(this,Ht);oe(this,hi);this.config=t,W(this,pn,new Set),W(this,Ht,new Map),W(this,hi,0)}build(t,n,r){const o=new Qf({mutationCache:this,mutationId:++Ai(this,hi)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){O(this,pn).add(t);const n=Pi(t);if(typeof n=="string"){const r=O(this,Ht).get(n);r?r.push(t):O(this,Ht).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(O(this,pn).delete(t)){const n=Pi(t);if(typeof n=="string"){const r=O(this,Ht).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,Ht).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Pi(t);if(typeof n=="string"){const r=O(this,Ht).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=Pi(t);if(typeof n=="string"){const o=(r=O(this,Ht).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,Ht).clear()})}getAll(){return Array.from(O(this,pn))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Ma(n,r))}findAll(t={}){return this.getAll().filter(n=>Ma(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(Pt))))}},pn=new WeakMap,Ht=new WeakMap,hi=new WeakMap,Wc);function Pi(e){var t;return(t=e.options.scope)==null?void 0:t.id}function La(e){return{onFetch:(t,n)=>{var d,f,p,m,w;const r=t.options,o=(p=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:p.direction,i=((m=t.state.data)==null?void 0:m.pages)||[],s=((w=t.state.data)==null?void 0:w.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const u=async()=>{let v=!1;const h=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(t.signal.aborted?v=!0:t.signal.addEventListener("abort",()=>{v=!0}),t.signal)})},x=Yc(t.options,t.fetchOptions),g=async(b,_,C)=>{if(v)return Promise.reject();if(_==null&&b.pages.length)return Promise.resolve(b);const R={client:t.client,queryKey:t.queryKey,pageParam:_,direction:C?"backward":"forward",meta:t.options.meta};h(R);const N=await x(R),{maxPages:T}=t.options,F=C?$f:Uf;return{pages:F(b.pages,N,T),pageParams:F(b.pageParams,_,T)}};if(o&&i.length){const b=o==="backward",_=b?Yf:Ka,C={pages:i,pageParams:s},R=_(r,C);a=await g(C,R,b)}else{const b=e??i.length;do{const _=l===0?s[0]??r.initialPageParam:Ka(r,a);if(l>0&&_==null)break;a=await g(a,_),l++}while(l<b)}return a};t.options.persister?t.fetchFn=()=>{var v,h;return(h=(v=t.options).persister)==null?void 0:h.call(v,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function Ka(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 Yf(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,Rn,An,Nr,Tr,Pn,Rr,Ar,zc,Zf=(zc=class{constructor(e={}){oe(this,ke);oe(this,Rn);oe(this,An);oe(this,Nr);oe(this,Tr);oe(this,Pn);oe(this,Rr);oe(this,Ar);W(this,ke,e.queryCache||new Gf),W(this,Rn,e.mutationCache||new Xf),W(this,An,e.defaultOptions||{}),W(this,Nr,new Map),W(this,Tr,new Map),W(this,Pn,0)}mount(){Ai(this,Pn)._++,O(this,Pn)===1&&(W(this,Rr,Ps.subscribe(async e=>{e&&(await this.resumePausedMutations(),O(this,ke).onFocus())})),W(this,Ar,Gi.subscribe(async e=>{e&&(await this.resumePausedMutations(),O(this,ke).onOnline())})))}unmount(){var e,t;Ai(this,Pn)._--,O(this,Pn)===0&&((e=O(this,Rr))==null||e.call(this),W(this,Rr,void 0),(t=O(this,Ar))==null||t.call(this),W(this,Ar,void 0))}isFetching(e){return O(this,ke).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return O(this,Rn).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(br(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=Kf(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),r={type:"active",...e};return Je.batch(()=>(n.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries(r,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(Pt).catch(Pt)}invalidateQueries(e,t={}){return Je.batch(()=>{if(O(this,ke).findAll(e).forEach(r=>{r.invalidate()}),(e==null?void 0:e.refetchType)==="none")return Promise.resolve();const n={...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"};return this.refetchQueries(n,t)})}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=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(Pt)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Pt)}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(br(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Pt).catch(Pt)}fetchInfiniteQuery(e){return e.behavior=La(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Pt).catch(Pt)}ensureInfiniteQueryData(e){return e.behavior=La(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Gi.isOnline()?O(this,Rn).resumePausedMutations():Promise.resolve()}getQueryCache(){return O(this,ke)}getMutationCache(){return O(this,Rn)}getDefaultOptions(){return O(this,An)}setDefaultOptions(e){W(this,An,e)}setQueryDefaults(e,t){O(this,Nr).set(lr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...O(this,Nr).values()],n={};return t.forEach(r=>{si(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){O(this,Tr).set(lr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...O(this,Tr).values()];let n={};return t.forEach(r=>{si(e,r.mutationKey)&&(n={...n,...r.defaultOptions})}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...O(this,An).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=As(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===zi&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...O(this,An).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){O(this,ke).clear(),O(this,Rn).clear()}},ke=new WeakMap,Rn=new WeakMap,An=new WeakMap,Nr=new WeakMap,Tr=new WeakMap,Pn=new WeakMap,Rr=new WeakMap,Ar=new WeakMap,zc),mt,ye,mi,ut,ir,Pr,Fn,tn,gi,Fr,Dr,or,sr,Dn,Mr,Oe,ti,ts,ns,rs,is,os,ss,as,ol,Gc,ep=(Gc=class extends Br{constructor(t,n){super();oe(this,Oe);oe(this,mt);oe(this,ye);oe(this,mi);oe(this,ut);oe(this,ir);oe(this,Pr);oe(this,Fn);oe(this,tn);oe(this,gi);oe(this,Fr);oe(this,Dr);oe(this,or);oe(this,sr);oe(this,Dn);oe(this,Mr,new Set);this.options=n,W(this,mt,t),W(this,tn,null),W(this,Fn,es()),this.options.experimental_prefetchInRender||O(this,Fn).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,ye).addObserver(this),Va(O(this,ye),this.options)?pe(this,Oe,ti).call(this):this.updateResult(),pe(this,Oe,is).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return cs(O(this,ye),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return cs(O(this,ye),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,pe(this,Oe,os).call(this),pe(this,Oe,ss).call(this),O(this,ye).removeObserver(this)}setOptions(t,n){const r=this.options,o=O(this,ye);if(this.options=O(this,mt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Bt(this.options.enabled,O(this,ye))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");pe(this,Oe,as).call(this),O(this,ye).setOptions(this.options),r._defaulted&&!Wi(this.options,r)&&O(this,mt).getQueryCache().notify({type:"observerOptionsUpdated",query:O(this,ye),observer:this});const i=this.hasListeners();i&&Ua(O(this,ye),o,this.options,r)&&pe(this,Oe,ti).call(this),this.updateResult(n),i&&(O(this,ye)!==o||Bt(this.options.enabled,O(this,ye))!==Bt(r.enabled,O(this,ye))||br(this.options.staleTime,O(this,ye))!==br(r.staleTime,O(this,ye)))&&pe(this,Oe,ts).call(this);const s=pe(this,Oe,ns).call(this);i&&(O(this,ye)!==o||Bt(this.options.enabled,O(this,ye))!==Bt(r.enabled,O(this,ye))||s!==O(this,Dn))&&pe(this,Oe,rs).call(this,s)}getOptimisticResult(t){const n=O(this,mt).getQueryCache().build(O(this,mt),t),r=this.createResult(n,t);return np(this,r)&&(W(this,ut,r),W(this,Pr,this.options),W(this,ir,O(this,ye).state)),r}getCurrentResult(){return O(this,ut)}trackResult(t,n){const r={};return Object.keys(t).forEach(o=>{Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(o),n==null||n(o),t[o])})}),r}trackProp(t){O(this,Mr).add(t)}getCurrentQuery(){return O(this,ye)}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 pe(this,Oe,ti).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),O(this,ut)))}createResult(t,n){var T;const r=O(this,ye),o=this.options,i=O(this,ut),s=O(this,ir),a=O(this,Pr),u=t!==r?t.state:O(this,mi),{state:d}=t;let f={...d},p=!1,m;if(n._optimisticResults){const F=this.hasListeners(),$=!F&&Va(t,n),G=F&&Ua(t,r,n,o);($||G)&&(f={...f,...rl(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:w,errorUpdatedAt:v,status:h}=f;if(n.select&&f.data!==void 0)if(i&&f.data===(s==null?void 0:s.data)&&n.select===O(this,gi))m=O(this,Fr);else try{W(this,gi,n.select),m=n.select(f.data),m=Zo(i==null?void 0:i.data,m,n),W(this,Fr,m),W(this,tn,null)}catch(F){W(this,tn,F)}else m=f.data;if(n.placeholderData!==void 0&&m===void 0&&h==="pending"){let F;if(i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))F=i.data;else if(F=typeof n.placeholderData=="function"?n.placeholderData((T=O(this,Dr))==null?void 0:T.state.data,O(this,Dr)):n.placeholderData,n.select&&F!==void 0)try{F=n.select(F),W(this,tn,null)}catch($){W(this,tn,$)}F!==void 0&&(h="success",m=Zo(i==null?void 0:i.data,F,n),p=!0)}O(this,tn)&&(w=O(this,tn),m=O(this,Fr),v=Date.now(),h="error");const x=f.fetchStatus==="fetching",g=h==="pending",b=h==="error",_=g&&x,C=m!==void 0,N={status:h,fetchStatus:f.fetchStatus,isPending:g,isSuccess:h==="success",isError:b,isInitialLoading:_,isLoading:_,data:m,dataUpdatedAt:f.dataUpdatedAt,error:w,errorUpdatedAt:v,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:x,isRefetching:x&&!g,isLoadingError:b&&!C,isPaused:f.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:b&&C,isStale:Fs(t,n),refetch:this.refetch,promise:O(this,Fn)};if(this.options.experimental_prefetchInRender){const F=z=>{N.status==="error"?z.reject(N.error):N.data!==void 0&&z.resolve(N.data)},$=()=>{const z=W(this,Fn,N.promise=es());F(z)},G=O(this,Fn);switch(G.status){case"pending":t.queryHash===r.queryHash&&F(G);break;case"fulfilled":(N.status==="error"||N.data!==G.value)&&$();break;case"rejected":(N.status!=="error"||N.error!==G.reason)&&$();break}}return N}updateResult(t){const n=O(this,ut),r=this.createResult(O(this,ye),this.options);if(W(this,ir,O(this,ye).state),W(this,Pr,this.options),O(this,ir).data!==void 0&&W(this,Dr,O(this,ye)),Wi(r,n))return;W(this,ut,r);const o={},i=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!O(this,Mr).size)return!0;const l=new Set(a??O(this,Mr));return this.options.throwOnError&&l.add("error"),Object.keys(O(this,ut)).some(u=>{const d=u;return O(this,ut)[d]!==n[d]&&l.has(d)})};(t==null?void 0:t.listeners)!==!1&&i()&&(o.listeners=!0),pe(this,Oe,ol).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&pe(this,Oe,is).call(this)}},mt=new WeakMap,ye=new WeakMap,mi=new WeakMap,ut=new WeakMap,ir=new WeakMap,Pr=new WeakMap,Fn=new WeakMap,tn=new WeakMap,gi=new WeakMap,Fr=new WeakMap,Dr=new WeakMap,or=new WeakMap,sr=new WeakMap,Dn=new WeakMap,Mr=new WeakMap,Oe=new WeakSet,ti=function(t){pe(this,Oe,as).call(this);let n=O(this,ye).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Pt)),n},ts=function(){pe(this,Oe,os).call(this);const t=br(this.options.staleTime,O(this,ye));if(cr||O(this,ut).isStale||!Qo(t))return;const r=Xc(O(this,ut).dataUpdatedAt,t)+1;W(this,or,setTimeout(()=>{O(this,ut).isStale||this.updateResult()},r))},ns=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(O(this,ye)):this.options.refetchInterval)??!1},rs=function(t){pe(this,Oe,ss).call(this),W(this,Dn,t),!(cr||Bt(this.options.enabled,O(this,ye))===!1||!Qo(O(this,Dn))||O(this,Dn)===0)&&W(this,sr,setInterval(()=>{(this.options.refetchIntervalInBackground||Ps.isFocused())&&pe(this,Oe,ti).call(this)},O(this,Dn)))},is=function(){pe(this,Oe,ts).call(this),pe(this,Oe,rs).call(this,pe(this,Oe,ns).call(this))},os=function(){O(this,or)&&(clearTimeout(O(this,or)),W(this,or,void 0))},ss=function(){O(this,sr)&&(clearInterval(O(this,sr)),W(this,sr,void 0))},as=function(){const t=O(this,mt).getQueryCache().build(O(this,mt),this.options);if(t===O(this,ye))return;const n=O(this,ye);W(this,ye,t),W(this,mi,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},ol=function(t){Je.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(O(this,ut))}),O(this,mt).getQueryCache().notify({query:O(this,ye),type:"observerResultsUpdated"})})},Gc);function tp(e,t){return Bt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Va(e,t){return tp(e,t)||e.state.data!==void 0&&cs(e,t,t.refetchOnMount)}function cs(e,t,n){if(Bt(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Fs(e,t)}return!1}function Ua(e,t,n,r){return(e!==t||Bt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Fs(e,n)}function Fs(e,t){return Bt(t.enabled,e)!==!1&&e.isStaleByTime(br(t.staleTime,e))}function np(e,t){return!Wi(e.getCurrentResult(),t)}var Mn,kn,gt,hn,yn,$i,ls,Qc,rp=(Qc=class extends Br{constructor(n,r){super();oe(this,yn);oe(this,Mn);oe(this,kn);oe(this,gt);oe(this,hn);W(this,Mn,n),this.setOptions(r),this.bindMethods(),pe(this,yn,$i).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,Mn).defaultMutationOptions(n),Wi(this.options,r)||O(this,Mn).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){pe(this,yn,$i).call(this),pe(this,yn,ls).call(this,n)}getCurrentResult(){return O(this,kn)}reset(){var n;(n=O(this,gt))==null||n.removeObserver(this),W(this,gt,void 0),pe(this,yn,$i).call(this),pe(this,yn,ls).call(this)}mutate(n,r){var o;return W(this,hn,r),(o=O(this,gt))==null||o.removeObserver(this),W(this,gt,O(this,Mn).getMutationCache().build(O(this,Mn),this.options)),O(this,gt).addObserver(this),O(this,gt).execute(n)}},Mn=new WeakMap,kn=new WeakMap,gt=new WeakMap,hn=new WeakMap,yn=new WeakSet,$i=function(){var r;const n=((r=O(this,gt))==null?void 0:r.state)??il();W(this,kn,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},ls=function(n){Je.batch(()=>{var r,o,i,s,a,l,u,d;if(O(this,hn)&&this.hasListeners()){const f=O(this,kn).variables,p=O(this,kn).context;(n==null?void 0:n.type)==="success"?((o=(r=O(this,hn)).onSuccess)==null||o.call(r,n.data,f,p),(s=(i=O(this,hn)).onSettled)==null||s.call(i,n.data,null,f,p)):(n==null?void 0:n.type)==="error"&&((l=(a=O(this,hn)).onError)==null||l.call(a,n.error,f,p),(d=(u=O(this,hn)).onSettled)==null||d.call(u,void 0,n.error,f,p))}this.listeners.forEach(f=>{f(O(this,kn))})})},Qc),sl=V.createContext(void 0),Et=e=>{const t=V.useContext(sl);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ip=({client:e,children:t})=>(V.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),c.jsx(sl.Provider,{value:e,children:t})),al=V.createContext(!1),op=()=>V.useContext(al);al.Provider;function sp(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var ap=V.createContext(sp()),cp=()=>V.useContext(ap);function cl(e,t){return typeof e=="function"?e(...t):!!e}function us(){}var lp=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},up=e=>{V.useEffect(()=>{e.clearReset()},[e])},dp=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||cl(n,[e.error,r])),fp=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)))},pp=(e,t)=>e.isLoading&&e.isFetching&&!t,hp=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,$a=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function mp(e,t,n){var f,p,m,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=Et(),o=op(),i=cp(),s=r.defaultQueryOptions(e);(p=(f=r.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||p.call(f,s),s._optimisticResults=o?"isRestoring":"optimistic",fp(s),lp(s,i),up(i);const a=!r.getQueryCache().get(s.queryHash),[l]=V.useState(()=>new t(r,s)),u=l.getOptimisticResult(s),d=!o&&e.subscribed!==!1;if(V.useSyncExternalStore(V.useCallback(h=>{const x=d?l.subscribe(Je.batchCalls(h)):us;return l.updateResult(),x},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),V.useEffect(()=>{l.setOptions(s,{listeners:!1})},[s,l]),hp(s,u))throw $a(s,l,i);if(dp({result:u,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw u.error;if((w=(m=r.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||w.call(m,s,u),s.experimental_prefetchInRender&&!cr&&pp(u,o)){const h=a?$a(s,l,i):(v=r.getQueryCache().get(s.queryHash))==null?void 0:v.promise;h==null||h.catch(us).finally(()=>{l.updateResult()})}return s.notifyOnChangeProps?u:l.trackResult(u)}function vn(e,t){return mp(e,ep)}function Jr(e,t){const n=Et(),[r]=V.useState(()=>new rp(n,e));V.useEffect(()=>{r.setOptions(e)},[r,e]);const o=V.useSyncExternalStore(V.useCallback(s=>r.subscribe(Je.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=V.useCallback((s,a)=>{r.mutate(s,a).catch(us)},[r]);if(o.error&&cl(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:i,mutateAsync:o.mutate}}const ll=y.createContext(null),gp=ll.Provider,ul=()=>{const e=y.useContext(ll);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 dl=y.createContext(void 0);function Dt(){const e=y.useContext(dl);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const yp=(()=>{const e={};return Object.values(ue).forEach(t=>{e[t]={}}),e})();function vp({children:e}){const[t,n]=y.useState(yp),r=y.useCallback((d,f,p=!0)=>{n(m=>{const w={...m};return w[d]=w[d]||{},w[d][f]=p,w})},[n]),o=y.useCallback((d,f)=>{var p;return!!((p=t[d])!=null&&p[f])},[t]),i=y.useCallback((d,f)=>{var p;return(p=t[d])==null?void 0:p[f]},[t]),s=y.useCallback((d,f)=>{n(p=>{var w;const m={...p};return(w=m[d])==null||delete w[f],m})},[n]),a=y.useCallback(d=>{n(f=>{const p={...f};return p[d]={},p})},[n]),l=y.useCallback((d,f)=>{n(p=>{const m={...p};return m[d]=m[d]||{},f.forEach(w=>{m[d][w]=!0}),m})},[n]),u=y.useMemo(()=>({errorState:t,setErrorState:n,setError:r,isError:o,removeError:s,resetBoundary:a,setErrors:l,getError:i}),[t,n,r,o,s,a,l,i]);return c.jsx(dl.Provider,{value:u,children:e})}const wp="https://api.withampersand.com/v1".replace(/\/+$/,"");class Ds{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:wp}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||pl}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 Ip=new Ds,fo=class fo{constructor(t=Ip){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 _p(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?fo.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 fl(i,"Response returned an error code")}async createFetchParams(t,n){let r=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(r+="?"+this.configuration.queryParamsStringify(t.query));const o=Object.assign({},this.configuration.headers,t.headers);Object.keys(o).forEach(u=>o[u]===void 0?delete o[u]:{});const i=typeof n=="function"?n:async()=>n,s={method:t.method,headers:o,body:t.body,credentials:this.configuration.credentials},a={...s,...await i({init:s,context:t})},l={...a,body:xp(a.body)||a.body instanceof URLSearchParams||bp(a.body)?a.body:JSON.stringify(a.body)};return{url:r,init:l}}clone(){const t=this.constructor,n=new t(this.configuration);return n.middleware=this.middleware.slice(),n}};fo.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let nn=fo;function bp(e){return typeof Blob<"u"&&e instanceof Blob}function xp(e){return typeof FormData<"u"&&e instanceof FormData}class fl extends Error{constructor(t,n){super(n),this.response=t,this.name="ResponseError"}}class _p extends Error{constructor(t,n){super(n),this.cause=t,this.name="FetchError"}}class re extends Error{constructor(t,n){super(n),this.field=t,this.name="RequiredError"}}function S(e,t){const n=e[t];return n!=null}function pl(e,t=""){return Object.keys(e).map(n=>hl(n,e[n],t)).filter(n=>n.length>0).join("&")}function hl(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 hl(e,o,n)}return t instanceof Date?`${encodeURIComponent(r)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?pl(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 qa{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function Cp(e){return Op(e)}function Op(e,t){return e==null?e:{fieldUsed:S(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:S(e,"keyFormat")?e.keyFormat:void 0}}function Ep(e){return Sp(e)}function Sp(e,t){return e==null?e:{name:e.name,valuePrefix:S(e,"valuePrefix")?e.valuePrefix:void 0}}function Np(e){return Tp(e)}function Tp(e,t){return e==null?e:{name:e.name}}function Rp(e){return Ap(e)}function Ap(e,t){return e==null?e:{attachmentType:e.attachmentType,query:S(e,"query")?Np(e.query):void 0,header:S(e,"header")?Ep(e.header):void 0,docsURL:S(e,"docsURL")?e.docsURL:void 0}}function Pp(e){return Fp(e)}function Fp(e,t){return e==null?e:{enabled:S(e,"enabled")?e.enabled:void 0,includeFullRecords:S(e,"includeFullRecords")?e.includeFullRecords:void 0}}function Dp(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,includeFullRecords:e.includeFullRecords}}const Ha={Oauth2:"oauth2",ApiKey:"apiKey",Basic:"basic",Jwt:"jwt",None:"none"};function Mp(e){return kp(e)}function kp(e,t){return e}function jp(e){return Lp(e)}function Lp(e,t){return e==null?e:{days:S(e,"days")?e.days:void 0,fullHistory:S(e,"fullHistory")?e.fullHistory:void 0}}function Kp(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function ml(e){return Vp(e)}function Vp(e,t){return e==null?e:{defaultPeriod:jp(e.defaultPeriod)}}function Up(e){if(e!==void 0)return e===null?null:{defaultPeriod:Kp(e.defaultPeriod)}}function $p(e){return qp(e)}function qp(e,t){return e==null?e:{days:S(e,"days")?e.days:void 0,fullHistory:S(e,"fullHistory")?e.fullHistory:void 0}}function Hp(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function Bp(e){return Jp(e)}function Jp(e,t){return e==null?e:{defaultPeriod:$p(e.defaultPeriod)}}function gl(e){if(e!==void 0)return e===null?null:{defaultPeriod:Hp(e.defaultPeriod)}}function Wp(e){return zp(e)}function zp(e,t){return e==null?e:{enabled:S(e,"enabled")?e.enabled:void 0}}function yl(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Gp(e){return Qp(e)}function Qp(e,t){return e}function Xp(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:gl(e.backfill)}}function Yp(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:We(e.objects,Xp)}}function Zp(e){return eh(e)}function eh(e,t){return e==null?e:{stringValue:S(e,"stringValue")?e.stringValue:void 0,integerValue:S(e,"integerValue")?e.integerValue:void 0,booleanValue:S(e,"booleanValue")?e.booleanValue:void 0}}function th(e){if(e!==void 0)return e===null?null:{stringValue:e.stringValue,integerValue:e.integerValue,booleanValue:e.booleanValue}}function nh(e){return rh(e)}function rh(e,t){return e==null?e:{_default:S(e,"default")?Zp(e.default):void 0,writeOnCreate:S(e,"writeOnCreate")?e.writeOnCreate:void 0,writeOnUpdate:S(e,"writeOnUpdate")?e.writeOnUpdate:void 0}}function vl(e){if(e!==void 0)return e===null?null:{default:th(e._default),writeOnCreate:e.writeOnCreate,writeOnUpdate:e.writeOnUpdate}}function ih(e){let t=!0;return t=t&&"value"in e,t}function oh(e,t){return e==null?e:{value:e.value,applyOnUpdate:S(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function sh(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function ah(e){let t=!0;return t=t&&"value"in e,t}function ch(e,t){return e==null?e:{value:e.value,applyOnUpdate:S(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function lh(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function uh(e){let t=!0;return t=t&&"value"in e,t}function dh(e,t){return e==null?e:{value:e.value,applyOnUpdate:S(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function fh(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function ph(e){return hh(e)}function hh(e,t){return e==null?e:{...oh(e),...ch(e),...dh(e)}}function wl(e){if(e!==void 0)return e===null?null:ih(e)?sh(e):ah(e)?lh(e):uh(e)?fh(e):{}}function mh(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,selectedValueDefaults:e.selectedValueDefaults===void 0?void 0:We(e.selectedValueDefaults,wl),selectedFieldSettings:e.selectedFieldSettings===void 0?void 0:We(e.selectedFieldSettings,vl)}}function gh(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:We(e.objects,mh)}}function yh(e){return vh(e)}function vh(e,t){return e==null?e:{apiKeyAsBasic:S(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:S(e,"apiKeyAsBasicOpts")?Cp(e.apiKeyAsBasicOpts):void 0,docsURL:S(e,"docsURL")?e.docsURL:void 0}}function wh(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function Ih(e){return bh(e)}function bh(e,t){return e==null?e:{value:e.value}}function xh(e){return _h(e)}function _h(e,t){return e==null?e:{brandingRemoval:S(e,"brandingRemoval")?Ih(e.brandingRemoval):void 0}}function Fi(e){return Ch(e)}function Ch(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:S(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:S(e,"updateTime")?new Date(e.updateTime):void 0,entitlements:S(e,"entitlements")?xh(e.entitlements):void 0}}function Oh(e){return Eh(e)}function Eh(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function Sh(e){return Nh(e)}function Nh(e,t){return e==null?e:{objectName:e.objectName,schedule:e.schedule,destination:e.destination,selectedFields:e.selectedFields,selectedValueMappings:S(e,"selectedValueMappings")?e.selectedValueMappings:void 0,selectedFieldMappings:e.selectedFieldMappings,selectedFieldsAuto:S(e,"selectedFieldsAuto")?Gp(e.selectedFieldsAuto):void 0,backfill:S(e,"backfill")?Bp(e.backfill):void 0}}function Th(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:gl(e.backfill)}}function Rh(e){return Ah(e)}function Ah(e,t){return e==null?e:{objects:We(e.objects,Sh)}}function Ph(e){if(e!==void 0)return e===null?null:{objects:We(e.objects,Th)}}function Fh(e){return Dh(e)}function Dh(e,t){return e==null?e:{objectName:e.objectName,selectedValueDefaults:S(e,"selectedValueDefaults")?We(e.selectedValueDefaults,ph):void 0,selectedFieldSettings:S(e,"selectedFieldSettings")?We(e.selectedFieldSettings,nh):void 0}}function Mh(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,selectedValueDefaults:e.selectedValueDefaults===void 0?void 0:We(e.selectedValueDefaults,wl),selectedFieldSettings:e.selectedFieldSettings===void 0?void 0:We(e.selectedFieldSettings,vl)}}function kh(e){return jh(e)}function jh(e,t){return e==null?e:{objects:S(e,"objects")?We(e.objects,Fh):void 0}}function Lh(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:We(e.objects,Mh)}}function Kh(e){return Vh(e)}function Vh(e,t){return e==null?e:{provider:e.provider,read:S(e,"read")?Rh(e.read):void 0,write:S(e,"write")?kh(e.write):void 0,proxy:S(e,"proxy")?Wp(e.proxy):void 0}}function Uh(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:Ph(e.read),write:Lh(e.write),proxy:yl(e.proxy)}}function $h(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:Kh(e.content)}}function Hh(e){return Bh(e)}function Bh(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:S(e,"updateTime")?new Date(e.updateTime):void 0}}function Il(e){return Jh(e)}function Jh(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:S(e,"updateTime")?new Date(e.updateTime):void 0}}function Wh(e){return zh(e)}function zh(e,t){return e==null?e:{token:e.token,issuedAt:S(e,"issuedAt")?new Date(e.issuedAt):void 0,expiresAt:S(e,"expiresAt")?new Date(e.expiresAt):void 0}}function Gh(e){return Qh(e)}function Qh(e,t){return e==null?e:{token:e.token,issuedAt:S(e,"issuedAt")?new Date(e.issuedAt):void 0,expiresAt:S(e,"expiresAt")?new Date(e.expiresAt):void 0}}function Xh(e){return Yh(e)}function Yh(e,t){return e==null?e:{accessToken:S(e,"accessToken")?Wh(e.accessToken):void 0,refreshToken:S(e,"refreshToken")?Gh(e.refreshToken):void 0,scopes:S(e,"scopes")?e.scopes:void 0}}function qi(e){return Zh(e)}function Zh(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:S(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:S(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:S(e,"updateTime")?new Date(e.updateTime):void 0}}function em(e){return tm(e)}function tm(e,t){return e==null?e:{value:e.value,source:e.source,displayName:S(e,"displayName")?e.displayName:void 0}}function Ms(e){if(e!==void 0)return e===null?null:{value:e.value,source:e.source,displayName:e.displayName}}function ni(e){return nm(e)}function nm(e,t){return e==null?e:{id:e.id,projectId:e.projectId,provider:e.provider,providerApp:S(e,"providerApp")?qi(e.providerApp):void 0,group:Il(e.group),consumer:Hh(e.consumer),providerWorkspaceRef:S(e,"providerWorkspaceRef")?e.providerWorkspaceRef:void 0,providerConsumerRef:S(e,"providerConsumerRef")?e.providerConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:S(e,"updateTime")?new Date(e.updateTime):void 0,authScheme:e.authScheme,status:e.status,oauth2AuthorizationCode:S(e,"oauth2AuthorizationCode")?Xh(e.oauth2AuthorizationCode):void 0,apiKey:S(e,"apiKey")?e.apiKey:void 0,providerMetadata:S(e,"providerMetadata")?We(e.providerMetadata,em):void 0}}function bl(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function xl(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function _l(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 rm(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 im(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 Cl(e){if(e!==void 0)return e===null?null:{accessToken:rm(e.accessToken),refreshToken:im(e.refreshToken),scopes:e.scopes}}function om(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:We(e.providerMetadata,Ms),groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,basicAuth:bl(e.basicAuth),oauth2ClientCredentials:xl(e.oauth2ClientCredentials),oauth2PasswordCredentials:_l(e.oauth2PasswordCredentials),oauth2AuthorizationCode:Cl(e.oauth2AuthorizationCode)}}function sm(e){return am(e)}function am(e,t){return e==null?e:{enabled:S(e,"enabled")?e.enabled:void 0}}function cm(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function lm(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:Uh(e.content)}}function um(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:lm(e.config)}}function dm(e){return fm(e)}function fm(e,t){return e==null?e:{enabled:S(e,"enabled")?e.enabled:void 0}}function pm(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function hm(e){return mm(e)}function mm(e,t){return e==null?e:{mode:S(e,"mode")?e.mode:void 0,pageSize:S(e,"pageSize")?e.pageSize:void 0}}function gm(e){if(e!==void 0)return e===null?null:{mode:e.mode,pageSize:e.pageSize}}function ym(e){let t=!0;return t=t&&"fieldName"in e,t}function vm(e,t){return e==null?e:{fieldName:e.fieldName,mapToName:S(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:S(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function wm(e){if(e!==void 0)return e===null?null:{fieldName:e.fieldName,mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName}}function Im(e){let t=!0;return t=t&&"mapToName"in e,t}function Ol(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:S(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:S(e,"default")?e.default:void 0,prompt:S(e,"prompt")?e.prompt:void 0}}function bm(e){if(e!==void 0)return e===null?null:{mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName,default:e._default,prompt:e.prompt}}function Ba(e){return xm(e)}function xm(e,t){return e==null?e:{...vm(e),...Ol(e)}}function Ja(e){if(e!==void 0)return e===null?null:ym(e)?wm(e):Im(e)?bm(e):{}}function El(e){return _m(e)}function _m(e,t){return e}function Cm(e){return Om(e)}function Om(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,mapToName:S(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:S(e,"mapToDisplayName")?e.mapToDisplayName:void 0,requiredFields:S(e,"requiredFields")?e.requiredFields.map(Ba):void 0,optionalFields:S(e,"optionalFields")?e.optionalFields.map(Ba):void 0,optionalFieldsAuto:S(e,"optionalFieldsAuto")?El(e.optionalFieldsAuto):void 0,backfill:S(e,"backfill")?ml(e.backfill):void 0,delivery:S(e,"delivery")?hm(e.delivery):void 0}}function Em(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(Ja),optionalFields:e.optionalFields===void 0?void 0:e.optionalFields.map(Ja),optionalFieldsAuto:e.optionalFieldsAuto,backfill:Up(e.backfill),delivery:gm(e.delivery)}}function Sm(e){return Nm(e)}function Nm(e,t){return e==null?e:{objects:S(e,"objects")?e.objects.map(Cm):void 0}}function Tm(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Em)}}function Rm(e){return Am(e)}function Am(e,t){return e==null?e:{enabled:S(e,"enabled")?e.enabled:void 0}}function Pm(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Fm(e){return Dm(e)}function Dm(e,t){return e==null?e:{enabled:S(e,"enabled")?e.enabled:void 0,watchFieldsAuto:S(e,"watchFieldsAuto")?e.watchFieldsAuto:void 0,requiredWatchFields:S(e,"requiredWatchFields")?e.requiredWatchFields:void 0}}function Mm(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,watchFieldsAuto:e.watchFieldsAuto,requiredWatchFields:e.requiredWatchFields}}function km(e){return jm(e)}function jm(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,inheritFieldsAndMapping:S(e,"inheritFieldsAndMapping")?e.inheritFieldsAndMapping:void 0,createEvent:S(e,"createEvent")?sm(e.createEvent):void 0,updateEvent:S(e,"updateEvent")?Fm(e.updateEvent):void 0,deleteEvent:S(e,"deleteEvent")?Rm(e.deleteEvent):void 0,associationChangeEvent:S(e,"associationChangeEvent")?Pp(e.associationChangeEvent):void 0,otherEvents:S(e,"otherEvents")?e.otherEvents:void 0}}function Lm(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,destination:e.destination,inheritFieldsAndMapping:e.inheritFieldsAndMapping,createEvent:cm(e.createEvent),updateEvent:Mm(e.updateEvent),deleteEvent:Pm(e.deleteEvent),associationChangeEvent:Dp(e.associationChangeEvent),otherEvents:e.otherEvents}}function Km(e){return Vm(e)}function Vm(e,t){return e==null?e:{objects:S(e,"objects")?e.objects.map(km):void 0}}function Um(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Lm)}}function Sl(e){return $m(e)}function $m(e,t){return e==null?e:{allowAnyFields:S(e,"allowAnyFields")?e.allowAnyFields:void 0}}function qm(e){if(e!==void 0)return e===null?null:{allowAnyFields:e.allowAnyFields}}function Hm(e){return Bm(e)}function Bm(e,t){return e==null?e:{objectName:e.objectName,inheritMapping:S(e,"inheritMapping")?e.inheritMapping:void 0,valueDefaults:S(e,"valueDefaults")?Sl(e.valueDefaults):void 0}}function Jm(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,inheritMapping:e.inheritMapping,valueDefaults:qm(e.valueDefaults)}}function Wm(e){return zm(e)}function zm(e,t){return e==null?e:{objects:S(e,"objects")?e.objects.map(Hm):void 0}}function Gm(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Jm)}}function Qm(e){return Xm(e)}function Xm(e,t){return e==null?e:{name:e.name,displayName:S(e,"displayName")?e.displayName:void 0,provider:e.provider,read:S(e,"read")?Sm(e.read):void 0,write:S(e,"write")?Wm(e.write):void 0,proxy:S(e,"proxy")?dm(e.proxy):void 0,subscribe:S(e,"subscribe")?Km(e.subscribe):void 0}}function Ym(e){if(e!==void 0)return e===null?null:{name:e.name,displayName:e.displayName,provider:e.provider,read:Tm(e.read),write:Gm(e.write),proxy:pm(e.proxy),subscribe:Um(e.subscribe)}}function Zm(e){if(e!==void 0)return e===null?null:{specVersion:e.specVersion,content:Ym(e.content)}}function eg(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:Zm(e.latestRevision)}}function tg(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function ng(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 rg(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function ig(e){return og(e)}function og(e,t){return e==null?e:{value:e.value,displayValue:e.displayValue}}function sg(e){return ag(e)}function ag(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,valueType:S(e,"valueType")?e.valueType:void 0,providerType:S(e,"providerType")?e.providerType:void 0,readOnly:S(e,"readOnly")?e.readOnly:void 0,values:S(e,"values")?e.values.map(ig):void 0}}function cg(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:We(e.providerMetadata,Ms),groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,basicAuth:bl(e.basicAuth),oauth2ClientCredentials:xl(e.oauth2ClientCredentials),oauth2PasswordCredentials:_l(e.oauth2PasswordCredentials),oauth2AuthorizationCode:Cl(e.oauth2AuthorizationCode)}}function lg(e){return ug(e)}function ug(e,t){return e==null?e:{enabled:S(e,"enabled")?e.enabled:void 0}}function dg(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,mapToName:S(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:S(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function Po(e){return fg(e)}function fg(e,t){return e==null?e:{...dg(e),...Ol(e)}}function pg(e){return hg(e)}function hg(e,t){return e==null?e:{error:S(e,"error")?e.error:void 0,objectName:e.objectName,displayName:e.displayName,mapToName:S(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:S(e,"mapToDisplayName")?e.mapToDisplayName:void 0,destination:e.destination,schedule:e.schedule,requiredFields:S(e,"requiredFields")?e.requiredFields.map(Po):void 0,optionalFields:S(e,"optionalFields")?e.optionalFields.map(Po):void 0,optionalFieldsAuto:S(e,"optionalFieldsAuto")?El(e.optionalFieldsAuto):void 0,allFields:S(e,"allFields")?e.allFields.map(Po):void 0,allFieldsMetadata:S(e,"allFieldsMetadata")?We(e.allFieldsMetadata,sg):void 0,backfill:S(e,"backfill")?ml(e.backfill):void 0}}function mg(e){return gg(e)}function gg(e,t){return e==null?e:{objects:S(e,"objects")?e.objects.map(pg):void 0}}function yg(e){return vg(e)}function vg(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,valueDefaults:S(e,"valueDefaults")?Sl(e.valueDefaults):void 0}}function wg(e){return Ig(e)}function Ig(e,t){return e==null?e:{objects:S(e,"objects")?e.objects.map(yg):void 0}}function bg(e){return xg(e)}function xg(e,t){return e==null?e:{name:e.name,displayName:S(e,"displayName")?e.displayName:void 0,provider:e.provider,read:S(e,"read")?mg(e.read):void 0,write:S(e,"write")?wg(e.write):void 0,proxy:S(e,"proxy")?lg(e.proxy):void 0}}function _g(e){return Cg(e)}function Cg(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:bg(e.content)}}function Di(e){return Og(e)}function Og(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:S(e,"group")?Il(e.group):void 0,healthStatus:e.healthStatus,connection:ni(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:S(e,"updateTime")?new Date(e.updateTime):void 0,config:$h(e.config)}}function Eg(e){return Sg(e)}function Sg(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Qm(e.content)}}function Wa(e){return Ng(e)}function Ng(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:S(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Eg(e.latestRevision)}}function Tg(e){return Rg(e)}function Rg(e,t){return e==null?e:{iconURL:S(e,"iconURL")?e.iconURL:void 0,logoURL:S(e,"logoURL")?e.logoURL:void 0}}function Ag(e){return Pg(e)}function Pg(e,t){return e==null?e:{iconURL:S(e,"iconURL")?e.iconURL:void 0,logoURL:S(e,"logoURL")?e.logoURL:void 0}}function Fg(e){return Dg(e)}function Dg(e,t){return e==null?e:{regular:S(e,"regular")?Ag(e.regular):void 0,darkMode:S(e,"darkMode")?Tg(e.darkMode):void 0}}function Mg(e){return kg(e)}function kg(e,t){return e==null?e:{name:e.name,displayName:S(e,"displayName")?e.displayName:void 0,docsURL:S(e,"docsURL")?e.docsURL:void 0}}function jg(e){return Lg(e)}function Lg(e,t){return e==null?e:{name:e.name}}function Kg(e){return Vg(e)}function Vg(e,t){return e==null?e:{create:S(e,"create")?e.create:void 0,update:S(e,"update")?e.update:void 0,_delete:S(e,"delete")?e.delete:void 0,passThrough:S(e,"passThrough")?e.passThrough:void 0}}function Nl(e){return Ug(e)}function Ug(e,t){return e==null?e:{bulkWrite:Oh(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write,subscribeSupport:S(e,"subscribeSupport")?Kg(e.subscribeSupport):void 0}}function $g(e){return qg(e)}function qg(e,t){return e==null?e:{displayName:e.displayName,baseURL:e.baseURL,support:Nl(e.support)}}function Hg(e){return Bg(e)}function Bg(e,t){return e==null?e:{name:e.name,displayName:e.displayName,jqValueSelector:e.jqValueSelector}}function Jg(e){return Wg(e)}function Wg(e,t){return e==null?e:{workspaceRefField:S(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:S(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:S(e,"scopesField")?e.scopesField:void 0,otherFields:S(e,"otherFields")?e.otherFields.map(Hg):void 0}}const Fo={AuthorizationCode:"authorizationCode",AuthorizationCodePkce:"authorizationCodePKCE",ClientCredentials:"clientCredentials",Password:"password"};function zg(e){return Gg(e)}function Gg(e,t){return e==null?e:{grantType:e.grantType,authURL:S(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:S(e,"audience")?e.audience:void 0,tokenMetadataFields:Jg(e.tokenMetadataFields),docsURL:S(e,"docsURL")?e.docsURL:void 0,authURLParams:S(e,"authURLParams")?e.authURLParams:void 0}}function Qg(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:We(e.providerMetadata,Ms),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 Xg(e){return Yg(e)}function Yg(e,t){return e==null?e:{input:S(e,"input")?e.input.map(Mg):void 0,postAuthentication:S(e,"postAuthentication")?e.postAuthentication.map(jg):void 0}}function Zg(e){return ey(e)}function ey(e,t){return e==null?e:{subscriptionScope:e.subscriptionScope,targetURLScope:e.targetURLScope,registrationTiming:e.registrationTiming}}function za(e){return ty(e)}function ty(e,t){return e==null?e:{name:e.name,authType:Mp(e.authType),baseURL:e.baseURL,oauth2Opts:S(e,"oauth2Opts")?zg(e.oauth2Opts):void 0,apiKeyOpts:S(e,"apiKeyOpts")?Rp(e.apiKeyOpts):void 0,basicOpts:S(e,"basicOpts")?yh(e.basicOpts):void 0,support:Nl(e.support),providerOpts:e.providerOpts,displayName:S(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:S(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:S(e,"media")?Fg(e.media):void 0,labels:S(e,"labels")?e.labels:void 0,subscribeOpts:S(e,"subscribeOpts")?Zg(e.subscribeOpts):void 0,modules:S(e,"modules")?We(e.modules,$g):void 0,metadata:S(e,"metadata")?Xg(e.metadata):void 0}}function ny(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,connection:om(e.connection)}}function ry(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:Yp(e.read),write:gh(e.write),proxy:yl(e.proxy)}}function iy(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:ry(e.content)}}function oy(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:iy(e.config)}}function sy(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:oy(e.installation)}}function ay(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function cy(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:ay(e.project)}}function ly(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 uy(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:ly(e.providerApp)}}class dy extends nn{async deleteConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new re("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 re("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:cg(t.generateConnectionParams)},n);return new je(i,s=>ni(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new re("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=>ni(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 re("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(ni))}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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new re("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling updateConnection.");if(t.updateConnectionRequest===null||t.updateConnectionRequest===void 0)throw new re("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:ny(t.updateConnectionRequest)},n);return new je(i,s=>ni(s))}async updateConnection(t,n){return await(await this.updateConnectionRaw(t,n)).value()}}class fy extends nn{async createInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new re("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new re("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:um(t.installation)},n);return new je(i,s=>Di(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new re("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new re("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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new re("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new re("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=>Di(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new re("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(Di))}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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new re("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new re("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new re("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:sy(t.installationUpdate)},n);return new je(i,s=>Di(s))}async updateInstallation(t,n){return await(await this.updateInstallationRaw(t,n)).value()}}class py extends nn{async batchUpsertIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");if(t.batchUpsertIntegrationsRequest===null||t.batchUpsertIntegrationsRequest===void 0)throw new re("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:wh(t.batchUpsertIntegrationsRequest)},n);return new je(i,s=>s.map(Wa))}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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new re("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:eg(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new re("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 re("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(Wa))}async listIntegrations(t,n){return await(await this.listIntegrationsRaw(t,n)).value()}}class hy extends nn{async oauthConnectRaw(t,n){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new re("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:Qg(t.connectOAuthParams)},n);return this.isJsonMime(i.headers.get("content-type"))?new je(i):new qa(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling oauthUpdate.");if(t.connectionId===null||t.connectionId===void 0)throw new re("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 qa(i)}async oauthUpdate(t,n){return await(await this.oauthUpdateRaw(t,n)).value()}}class my extends nn{async createProjectRaw(t,n){if(t.project===null||t.project===void 0)throw new re("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:tg(t.project)},n);return new je(i,s=>Fi(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 re("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 re("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=>Fi(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(Fi))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new re("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:cy(t.projectUpdate)},n);return new je(i,s=>Fi(s))}async updateProject(t,n){return await(await this.updateProjectRaw(t,n)).value()}}class gy extends nn{async getProviderRaw(t,n){if(t.provider===null||t.provider===void 0)throw new re("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=>za(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,za))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class yy extends nn{async createProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new re("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:ng(t.providerApp)},n);return new je(i,s=>qi(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new re("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 re("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(qi))}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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new re("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new re("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:uy(t.providerAppUpdate)},n);return new je(i,s=>qi(s))}async updateProviderApp(t,n){return await(await this.updateProviderAppRaw(t,n)).value()}}class vy extends nn{async createRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new re("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");if(t.revision===null||t.revision===void 0)throw new re("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:rg(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 re("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new re("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new re("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new re("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=>_g(s))}async getHydratedRevision(t,n){return await(await this.getHydratedRevisionRaw(t,n)).value()}}class Tl{constructor(t){this.connectionApi=new dy(t),this.installationApi=new fy(t),this.integrationApi=new py(t),this.oAuthApi=new hy(t),this.projectApi=new my(t),this.providerApi=new gy(t),this.providerAppApi=new yy(t),this.revisionApi=new vy(t)}}const Rl="2.7.2",wy="v1",Mi="https://api.withampersand.com";function Al(){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 Mi;case"mock":return"http://127.0.0.1:4010";case"":return Mi;default:return e??Mi}}catch{return Mi}}const Iy=(e,t)=>`${e}/${t}`;function by(){return Iy(Al(),wy)}const xy=Al(),Pl=by(),_y=new Ds({basePath:Pl,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":Rl}});let Cy=new Tl(_y);const ks=()=>Cy;function dt(){const e=ul();return y.useCallback(async()=>{e||console.error("Unable to create API service without API key.");const n=new Ds({basePath:Pl,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":Rl,"X-Api-Key":e}});return new Tl(n)},[e])}const Oy=e=>{const t=dt();return vn({queryKey:["project",e],queryFn:async()=>(await t()).projectApi.getProject({projectIdOrName:e})})},Fl=y.createContext({project:null,appName:"",projectId:"",projectIdOrName:"",isLoading:!0}),Te=()=>{const e=y.useContext(Fl);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e};function Ey({projectIdOrName:e,children:t}){const{setError:n}=Dt(),{data:r,isLoading:o,isError:i}=Oy(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 c.jsx(Fl.Provider,{value:s,children:t})}function Dl(){const e=dt(),{projectIdOrName:t}=Te();return vn({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 fl){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 l=`${a} ${s!=null&&s.remedy?`
|
|
3
3
|
|
|
4
|
-
[Remedy] ${s.remedy}`:""}`;t&&t(l)}catch(i){console.error("Error parsing error response body:",i)}}else console.error("Unexpected error:",e.message)},
|
|
5
|
-
component is wrapped with AmpersandProvider`);return e}const
|
|
6
|
-
`).filter(n=>n.trim()!==""),cy=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(n=>n.name===e)??null,ly=e=>e.replace(/[.:/\\]/g,"\\$&"),uy=()=>{const[e,t]=y.useState(!1),n=y.useCallback(()=>{t(!0)},[t]),r=y.useCallback(()=>{t(!1)},[t]);return{isIntegrationDeleted:e,setIntegrationDeleted:n,resetIntegrationDeleted:r}},Ll=y.createContext({integrationId:"",provider:"",integrationObj:void 0,consumerRef:"",consumerName:"",groupRef:"",groupName:"",installation:void 0,setInstallation:()=>{},resetInstallations:()=>{},onInstallSuccess:void 0,onUpdateSuccess:void 0,onUninstallSuccess:void 0,isIntegrationDeleted:!1,setIntegrationDeleted:()=>{}});function nt(){const e=y.useContext(Ll);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function dy({children:e,integration:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,onInstallSuccess:s,onUpdateSuccess:a,onUninstallSuccess:l,fieldMapping:u}){const{integrations:d}=js(),{setError:f,isError:p,removeError:m}=Dt(),{isIntegrationDeleted:w,setIntegrationDeleted:v,resetIntegrationDeleted:h}=uy(),x=y.useMemo(()=>cy(t,d||[]),[t,d]),{data:g,isLoading:b,isError:_,error:C}=jl(t,o),T=(g==null?void 0:g[0])||null;y.useEffect(()=>{h()},[t,n,r,o,i,u]),y.useEffect(()=>{x===null&&(d!=null&&d.length)&&console.error(`Integration "${t}" not found in integration list`)},[t,x,d]),y.useEffect(()=>{_?(f(ue.INSTALLATION_LIST,(x==null?void 0:x.id)||""),Le(C)):m(ue.INSTALLATION_LIST,(x==null?void 0:x.id)||"")},[_,x,f,m,C]);const S=Ot(),N=y.useCallback(()=>{S.invalidateQueries({queryKey:["amp","installations"]})},[S]),D=y.useCallback(z=>{S.setQueryData(["amp","installations"],[z]),S.invalidateQueries({queryKey:["amp","installations"]})},[S]),U=(x==null?void 0:x.id)||"",G=y.useMemo(()=>({integrationId:(x==null?void 0:x.id)||"",provider:(x==null?void 0:x.provider)||"",integrationObj:x,consumerRef:n,consumerName:r,groupRef:o,groupName:i,installation:T||void 0,setInstallation:D,resetInstallations:N,onInstallSuccess:s,onUpdateSuccess:a,onUninstallSuccess:l,isIntegrationDeleted:w,setIntegrationDeleted:v,fieldMapping:u}),[x,n,r,o,i,T,D,N,s,a,l,w,v,u]);if(b)return c.jsx(zr,{});if(x===null)return c.jsx(Bt,{message:`Integration "${t}" not found`});if(p(ue.INSTALLATION_LIST,U)){const z=`Error retrieving installation information for integration "${(x==null?void 0:x.name)||"unknown"}"`;return c.jsx(Bt,{message:z})}return c.jsx(Ll.Provider,{value:G,children:e})}const Kl=y.createContext({connections:null,isConnectionsLoading:!0,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{}}),Gt=()=>{const e=y.useContext(Kl);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function Vl({groupRef:e,provider:t,children:n}){const r=Ot(),{setError:o,isError:i}=Dt(),{projectId:s,isLoading:a}=Te(),{integrationId:l,groupRef:u}=nt(),{provider:d}=zg(l),{data:f,isLoading:p,isError:m,error:w}=Jg({groupRef:e||u,provider:d||t}),v=f==null?void 0:f[0],h=y.useCallback(b=>{r.setQueryData(["amp","connections"],()=>b),r.invalidateQueries({queryKey:["amp","connections"]})},[r]),x=y.useCallback(()=>{r.invalidateQueries({queryKey:["amp","connections"]})},[r]);y.useEffect(()=>{m?(o(ue.CONNECTION_LIST,s,!0),Le(w)):o(ue.CONNECTION_LIST,s,!1)},[m,o,s,w]);const g=y.useMemo(()=>({connections:f||null,isConnectionsLoading:p,selectedConnection:v||null,setConnections:h,setSelectedConnection:x}),[f,p,v,h,x]);if(p||a)return c.jsx(zr,{});if(i(ue.PROJECT,s))return c.jsx(Bt,{message:`Error loading project ${s}`});if(i(ue.CONNECTION_LIST,s))return c.jsx(Bt,{message:"Error retrieving existing connections"});if(!s)throw new Error("Project ID not found. ConnectionsProvider must be used within AmpersandProvider");return c.jsx(Kl.Provider,{value:g,children:n})}function $l(){const[e,t]=y.useState(1);return{seed:e,reset:()=>{t(Math.random())}}}const fy="_resetContainer_lkwv9_4",Ul={resetContainer:fy};var ji=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ls(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qi={exports:{}};Qi.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",o=1,i=2,s=9007199254740991,a="[object Arguments]",l="[object Array]",u="[object AsyncFunction]",d="[object Boolean]",f="[object Date]",p="[object Error]",m="[object Function]",w="[object GeneratorFunction]",v="[object Map]",h="[object Number]",x="[object Null]",g="[object Object]",b="[object Promise]",_="[object Proxy]",C="[object RegExp]",T="[object Set]",S="[object String]",N="[object Symbol]",D="[object Undefined]",U="[object WeakMap]",G="[object ArrayBuffer]",z="[object DataView]",ne="[object Float32Array]",B="[object Float64Array]",ce="[object Int8Array]",se="[object Int16Array]",te="[object Int32Array]",ge="[object Uint8Array]",we="[object Uint8ClampedArray]",A="[object Uint16Array]",j="[object Uint32Array]",$=/[\\^$.*+?()[\]{}|]/g,L=/^\[object .+?Constructor\]$/,k=/^(?:0|[1-9]\d*)$/,F={};F[ne]=F[B]=F[ce]=F[se]=F[te]=F[ge]=F[we]=F[A]=F[j]=!0,F[a]=F[l]=F[G]=F[d]=F[z]=F[f]=F[p]=F[m]=F[v]=F[h]=F[g]=F[C]=F[T]=F[S]=F[U]=!1;var Y=typeof ji=="object"&&ji&&ji.Object===Object&&ji,Z=typeof self=="object"&&self&&self.Object===Object&&self,q=Y||Z||Function("return this")(),ee=t&&!t.nodeType&&t,Q=ee&&!0&&e&&!e.nodeType&&e,de=Q&&Q.exports===ee,M=de&&Y.process,ve=function(){try{return M&&M.binding&&M.binding("util")}catch{}}(),H=ve&&ve.isTypedArray;function Ee(I,E){for(var P=-1,X=I==null?0:I.length,Re=0,fe=[];++P<X;){var Me=I[P];E(Me,P,I)&&(fe[Re++]=Me)}return fe}function Ve(I,E){for(var P=-1,X=E.length,Re=I.length;++P<X;)I[Re+P]=E[P];return I}function Xe(I,E){for(var P=-1,X=I==null?0:I.length;++P<X;)if(E(I[P],P,I))return!0;return!1}function $e(I,E){for(var P=-1,X=Array(I);++P<I;)X[P]=E(P);return X}function Ie(I){return function(E){return I(E)}}function Ft(I,E){return I.has(E)}function Ye(I,E){return I==null?void 0:I[E]}function yt(I){var E=-1,P=Array(I.size);return I.forEach(function(X,Re){P[++E]=[Re,X]}),P}function Mt(I,E){return function(P){return I(E(P))}}function jt(I){var E=-1,P=Array(I.size);return I.forEach(function(X){P[++E]=X}),P}var Ze=Array.prototype,ze=Function.prototype,Ue=Object.prototype,Pe=q["__core-js_shared__"],kt=ze.toString,rt=Ue.hasOwnProperty,on=function(){var I=/[^.]+$/.exec(Pe&&Pe.keys&&Pe.keys.IE_PROTO||"");return I?"Symbol(src)_1."+I:""}(),wn=Ue.toString,vt=RegExp("^"+kt.call(rt).replace($,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=de?q.Buffer:void 0,sn=q.Symbol,In=q.Uint8Array,an=Ue.propertyIsEnumerable,qn=Ze.splice,dt=sn?sn.toStringTag:void 0,cn=Object.getOwnPropertySymbols,bn=De?De.isBuffer:void 0,Hn=Mt(Object.keys,Object),xn=vr(q,"DataView"),Ae=vr(q,"Map"),it=vr(q,"Promise"),ie=vr(q,"Set"),me=vr(q,"WeakMap"),qe=vr(Object,"create"),ln=Jn(xn),W=Jn(Ae),ae=Jn(it),le=Jn(ie),Ke=Jn(me),He=sn?sn.prototype:void 0,ft=He?He.valueOf:void 0;function Ge(I){var E=-1,P=I==null?0:I.length;for(this.clear();++E<P;){var X=I[E];this.set(X[0],X[1])}}function et(){this.__data__=qe?qe(null):{},this.size=0}function pt(I){var E=this.has(I)&&delete this.__data__[I];return this.size-=E?1:0,E}function Ne(I){var E=this.__data__;if(qe){var P=E[I];return P===r?void 0:P}return rt.call(E,I)?E[I]:void 0}function Bn(I){var E=this.__data__;return qe?E[I]!==void 0:rt.call(E,I)}function So(I,E){var P=this.__data__;return this.size+=this.has(I)?0:1,P[I]=qe&&E===void 0?r:E,this}Ge.prototype.clear=et,Ge.prototype.delete=pt,Ge.prototype.get=Ne,Ge.prototype.has=Bn,Ge.prototype.set=So;function Et(I){var E=-1,P=I==null?0:I.length;for(this.clear();++E<P;){var X=I[E];this.set(X[0],X[1])}}function xi(){this.__data__=[],this.size=0}function _i(I){var E=this.__data__,P=Ei(E,I);if(P<0)return!1;var X=E.length-1;return P==X?E.pop():qn.call(E,P,1),--this.size,!0}function Ci(I){var E=this.__data__,P=Ei(E,I);return P<0?void 0:E[P][1]}function Se(I){return Ei(this.__data__,I)>-1}function Lt(I,E){var P=this.__data__,X=Ei(P,I);return X<0?(++this.size,P.push([I,E])):P[X][1]=E,this}Et.prototype.clear=xi,Et.prototype.delete=_i,Et.prototype.get=Ci,Et.prototype.has=Se,Et.prototype.set=Lt;function Kt(I){var E=-1,P=I==null?0:I.length;for(this.clear();++E<P;){var X=I[E];this.set(X[0],X[1])}}function Wn(){this.size=0,this.__data__={hash:new Ge,map:new(Ae||Et),string:new Ge}}function No(I){var E=Si(this,I).delete(I);return this.size-=E?1:0,E}function Xr(I){return Si(this,I).get(I)}function rf(I){return Si(this,I).has(I)}function of(I,E){var P=Si(this,I),X=P.size;return P.set(I,E),this.size+=P.size==X?0:1,this}Kt.prototype.clear=Wn,Kt.prototype.delete=No,Kt.prototype.get=Xr,Kt.prototype.has=rf,Kt.prototype.set=of;function Oi(I){var E=-1,P=I==null?0:I.length;for(this.__data__=new Kt;++E<P;)this.add(I[E])}function sf(I){return this.__data__.set(I,r),this}function af(I){return this.__data__.has(I)}Oi.prototype.add=Oi.prototype.push=sf,Oi.prototype.has=af;function _n(I){var E=this.__data__=new Et(I);this.size=E.size}function cf(){this.__data__=new Et,this.size=0}function lf(I){var E=this.__data__,P=E.delete(I);return this.size=E.size,P}function uf(I){return this.__data__.get(I)}function df(I){return this.__data__.has(I)}function ff(I,E){var P=this.__data__;if(P instanceof Et){var X=P.__data__;if(!Ae||X.length<n-1)return X.push([I,E]),this.size=++P.size,this;P=this.__data__=new Kt(X)}return P.set(I,E),this.size=P.size,this}_n.prototype.clear=cf,_n.prototype.delete=lf,_n.prototype.get=uf,_n.prototype.has=df,_n.prototype.set=ff;function pf(I,E){var P=Ni(I),X=!P&&Nf(I),Re=!P&&!X&&To(I),fe=!P&&!X&&!Re&&Ra(I),Me=P||X||Re||fe,Qe=Me?$e(I.length,String):[],tt=Qe.length;for(var Fe in I)rt.call(I,Fe)&&!(Me&&(Fe=="length"||Re&&(Fe=="offset"||Fe=="parent")||fe&&(Fe=="buffer"||Fe=="byteLength"||Fe=="byteOffset")||_f(Fe,tt)))&&Qe.push(Fe);return Qe}function Ei(I,E){for(var P=I.length;P--;)if(Ea(I[P][0],E))return P;return-1}function hf(I,E,P){var X=E(I);return Ni(I)?X:Ve(X,P(I))}function Yr(I){return I==null?I===void 0?D:x:dt&&dt in Object(I)?bf(I):Sf(I)}function xa(I){return Zr(I)&&Yr(I)==a}function _a(I,E,P,X,Re){return I===E?!0:I==null||E==null||!Zr(I)&&!Zr(E)?I!==I&&E!==E:mf(I,E,P,X,_a,Re)}function mf(I,E,P,X,Re,fe){var Me=Ni(I),Qe=Ni(E),tt=Me?l:Cn(I),Fe=Qe?l:Cn(E);tt=tt==a?g:tt,Fe=Fe==a?g:Fe;var wt=tt==g,Vt=Fe==g,ot=tt==Fe;if(ot&&To(I)){if(!To(E))return!1;Me=!0,wt=!1}if(ot&&!wt)return fe||(fe=new _n),Me||Ra(I)?Ca(I,E,P,X,Re,fe):wf(I,E,tt,P,X,Re,fe);if(!(P&o)){var St=wt&&rt.call(I,"__wrapped__"),Nt=Vt&&rt.call(E,"__wrapped__");if(St||Nt){var On=St?I.value():I,un=Nt?E.value():E;return fe||(fe=new _n),Re(On,un,P,X,fe)}}return ot?(fe||(fe=new _n),If(I,E,P,X,Re,fe)):!1}function gf(I){if(!Ta(I)||Of(I))return!1;var E=Sa(I)?vt:L;return E.test(Jn(I))}function yf(I){return Zr(I)&&Na(I.length)&&!!F[Yr(I)]}function vf(I){if(!Ef(I))return Hn(I);var E=[];for(var P in Object(I))rt.call(I,P)&&P!="constructor"&&E.push(P);return E}function Ca(I,E,P,X,Re,fe){var Me=P&o,Qe=I.length,tt=E.length;if(Qe!=tt&&!(Me&&tt>Qe))return!1;var Fe=fe.get(I);if(Fe&&fe.get(E))return Fe==E;var wt=-1,Vt=!0,ot=P&i?new Oi:void 0;for(fe.set(I,E),fe.set(E,I);++wt<Qe;){var St=I[wt],Nt=E[wt];if(X)var On=Me?X(Nt,St,wt,E,I,fe):X(St,Nt,wt,I,E,fe);if(On!==void 0){if(On)continue;Vt=!1;break}if(ot){if(!Xe(E,function(un,zn){if(!Ft(ot,zn)&&(St===un||Re(St,un,P,X,fe)))return ot.push(zn)})){Vt=!1;break}}else if(!(St===Nt||Re(St,Nt,P,X,fe))){Vt=!1;break}}return fe.delete(I),fe.delete(E),Vt}function wf(I,E,P,X,Re,fe,Me){switch(P){case z:if(I.byteLength!=E.byteLength||I.byteOffset!=E.byteOffset)return!1;I=I.buffer,E=E.buffer;case G:return!(I.byteLength!=E.byteLength||!fe(new In(I),new In(E)));case d:case f:case h:return Ea(+I,+E);case p:return I.name==E.name&&I.message==E.message;case C:case S:return I==E+"";case v:var Qe=yt;case T:var tt=X&o;if(Qe||(Qe=jt),I.size!=E.size&&!tt)return!1;var Fe=Me.get(I);if(Fe)return Fe==E;X|=i,Me.set(I,E);var wt=Ca(Qe(I),Qe(E),X,Re,fe,Me);return Me.delete(I),wt;case N:if(ft)return ft.call(I)==ft.call(E)}return!1}function If(I,E,P,X,Re,fe){var Me=P&o,Qe=Oa(I),tt=Qe.length,Fe=Oa(E),wt=Fe.length;if(tt!=wt&&!Me)return!1;for(var Vt=tt;Vt--;){var ot=Qe[Vt];if(!(Me?ot in E:rt.call(E,ot)))return!1}var St=fe.get(I);if(St&&fe.get(E))return St==E;var Nt=!0;fe.set(I,E),fe.set(E,I);for(var On=Me;++Vt<tt;){ot=Qe[Vt];var un=I[ot],zn=E[ot];if(X)var Aa=Me?X(zn,un,ot,E,I,fe):X(un,zn,ot,I,E,fe);if(!(Aa===void 0?un===zn||Re(un,zn,P,X,fe):Aa)){Nt=!1;break}On||(On=ot=="constructor")}if(Nt&&!On){var Ti=I.constructor,Ri=E.constructor;Ti!=Ri&&"constructor"in I&&"constructor"in E&&!(typeof Ti=="function"&&Ti instanceof Ti&&typeof Ri=="function"&&Ri instanceof Ri)&&(Nt=!1)}return fe.delete(I),fe.delete(E),Nt}function Oa(I){return hf(I,Af,xf)}function Si(I,E){var P=I.__data__;return Cf(E)?P[typeof E=="string"?"string":"hash"]:P.map}function vr(I,E){var P=Ye(I,E);return gf(P)?P:void 0}function bf(I){var E=rt.call(I,dt),P=I[dt];try{I[dt]=void 0;var X=!0}catch{}var Re=wn.call(I);return X&&(E?I[dt]=P:delete I[dt]),Re}var xf=cn?function(I){return I==null?[]:(I=Object(I),Ee(cn(I),function(E){return an.call(I,E)}))}:Pf,Cn=Yr;(xn&&Cn(new xn(new ArrayBuffer(1)))!=z||Ae&&Cn(new Ae)!=v||it&&Cn(it.resolve())!=b||ie&&Cn(new ie)!=T||me&&Cn(new me)!=U)&&(Cn=function(I){var E=Yr(I),P=E==g?I.constructor:void 0,X=P?Jn(P):"";if(X)switch(X){case ln:return z;case W:return v;case ae:return b;case le:return T;case Ke:return U}return E});function _f(I,E){return E=E??s,!!E&&(typeof I=="number"||k.test(I))&&I>-1&&I%1==0&&I<E}function Cf(I){var E=typeof I;return E=="string"||E=="number"||E=="symbol"||E=="boolean"?I!=="__proto__":I===null}function Of(I){return!!on&&on in I}function Ef(I){var E=I&&I.constructor,P=typeof E=="function"&&E.prototype||Ue;return I===P}function Sf(I){return wn.call(I)}function Jn(I){if(I!=null){try{return kt.call(I)}catch{}try{return I+""}catch{}}return""}function Ea(I,E){return I===E||I!==I&&E!==E}var Nf=xa(function(){return arguments}())?xa:function(I){return Zr(I)&&rt.call(I,"callee")&&!an.call(I,"callee")},Ni=Array.isArray;function Tf(I){return I!=null&&Na(I.length)&&!Sa(I)}var To=bn||Df;function Rf(I,E){return _a(I,E)}function Sa(I){if(!Ta(I))return!1;var E=Yr(I);return E==m||E==w||E==u||E==_}function Na(I){return typeof I=="number"&&I>-1&&I%1==0&&I<=s}function Ta(I){var E=typeof I;return I!=null&&(E=="object"||E=="function")}function Zr(I){return I!=null&&typeof I=="object"}var Ra=H?Ie(H):yf;function Af(I){return Tf(I)?pf(I):vf(I)}function Pf(){return[]}function Df(){return!1}e.exports=Rf})(Qi,Qi.exports);var py=Qi.exports;const ql=Ls(py),dr="other",Xi="manage-tab";function Ln(e){return!e.fieldName}function hy(e,t){var n;return((n=e==null?void 0:e.objects)==null?void 0:n.find(r=>r.objectName===t))||null}function my(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(n=>!Ln(n)&&!!n.fieldName))||null}function gy(e){var n;return((n=e==null?void 0:e.requiredFields)==null?void 0:n.filter(r=>Ln(r)&&!!r.mapToName))||[]}function yy(e){var n;return((n=e==null?void 0:e.optionalFields)==null?void 0:n.filter(r=>Ln(r)&&!!r.mapToName))||[]}function vy(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(n=>!Ln(n)&&!!n.fieldName))||null}const Hl=(e,t)=>{var n,r,o;return(o=(r=(n=e==null?void 0:e.content)==null?void 0:n.read)==null?void 0:r.objects)==null?void 0:o[t]};function wy(e){return Ln(e)?e.mapToName:e.fieldName}const Bl=(e,t)=>{var r,o,i;const n=[];return(i=(o=(r=t.content)==null?void 0:r.read)==null?void 0:o.objects)==null||i.forEach(s=>{n.push({name:s==null?void 0:s.objectName,displayName:(s==null?void 0:s.mapToDisplayName)||(s==null?void 0:s.displayName)||(s==null?void 0:s.objectName)&&jr(s==null?void 0:s.objectName),completed:e?!!Hl(e,s.objectName):!1})}),n},Wl=e=>{var n;return{name:dr,completed:e?!!((n=e==null?void 0:e.content)!=null&&n.write):!1}};function Iy(e,t){var i;const n=Bl(e,t),o=!!((i=t==null?void 0:t.content)!=null&&i.write)?Wl(e):void 0;return o&&n.push(o),n}function Jl(e,t,n){const r=(e==null?void 0:e.filter(i=>!(t!=null&&t[i==null?void 0:i.mapToName])))||[],o=r.map(i=>i.mapToName);return n(ue.MAPPING,o),r!=null&&r.length&&console.error("required fields not met",r.map(i=>i.mapToDisplayName)),{errorList:o}}function by(e,t){return ql(e,t)}function zl(e,t){return ql(e,t)}const xy=(e,t,n)=>{var h,x,g,b,_,C,T,S,N;if(!e)return null;const r=hy(e,t),o=r&&my(r),i=r&&vy(r),s=r&&gy(r),a=r&&yy(r),l=(r==null?void 0:r.allFields)||[],u=(r==null?void 0:r.allFieldsMetadata)||{},d=n==null?void 0:n.content,f=((g=(x=(h=d==null?void 0:d.read)==null?void 0:h.objects)==null?void 0:x[t])==null?void 0:g.selectedFields)||{},p=((C=(_=(b=d==null?void 0:d.read)==null?void 0:b.objects)==null?void 0:_[t])==null?void 0:C.selectedValueMappings)||{},m=((N=(S=(T=d==null?void 0:d.read)==null?void 0:T.objects)==null?void 0:S[t])==null?void 0:N.selectedFieldMappings)||{},w={...f},v={...m};return{allFields:l,allFieldsMetadata:u,requiredFields:o,optionalFields:i,requiredMapFields:s,optionalMapFields:a,selectedOptionalFields:f,selectedFieldMappings:m,selectedValueMappings:p,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,isValueMappingsModified:!1,savedConfig:{optionalFields:w,requiredMapFields:v,selectedValueMappings:p}}},_y=(e,t)=>{var r,o;if(!e)return null;const n=(o=(r=t==null?void 0:t.content)==null?void 0:r.write)==null?void 0:o.objects;return{writeObjects:(e==null?void 0:e.objects)||[],selectedWriteObjects:n||{},isWriteModified:!1,savedConfig:{selectedWriteObjects:n||{}}}};function Gl(e,t,n){var i,s;const r=(i=e==null?void 0:e.content)==null?void 0:i.read,o=(s=e==null?void 0:e.content)==null?void 0:s.write;return{read:xy(r,t,n),write:_y(o,n)}}const Ql=(e,t,n,r)=>{const o=Gl(e,n,t);r(n,o)},Cy=(e,t,n)=>{const r=Iy(t,e),o={};r.forEach(({name:i,completed:s})=>{s&&(o[i]=Gl(e,i,t))}),n(o)},Xl=e=>{const{requiredFields:t,selectedOptionalFields:n}=(e==null?void 0:e.read)||{},r=new Set;return t==null||t.forEach(i=>r.add(wy(i))),{...Array.from(r).reduce((i,s)=>({...i,[s]:!0}),{}),...n||{}}},Yl=e=>{const{selectedFieldMappings:t}=(e==null?void 0:e.read)||{},n={};return t&&Object.keys(t).forEach(r=>{t[r]!==void 0?n[r]=t[r]||"":console.warn(`Error undefined when generating selectedRequiredMapFieldsSubmit for key: ${r}`)}),n},Zl=e=>{const{selectedValueMappings:t}=(e==null?void 0:e.read)||{};return t};function eu(e,t){return t[e]||void 0}async function tu({createConfig:e,projectId:t,integrationId:n,groupRef:r,connectionId:o,apiKey:i,setError:s,setInstallation:a,onInstallSuccess:l}){const u={projectIdOrName:t,integrationId:n,installation:{groupRef:r,connectionId:o,config:e}};try{const d=await Ms().installationApi.createInstallation(u,{headers:{"X-Api-Key":i,"Content-Type":"application/json"}});a(d),l==null||l(d.id,d.config)}catch(d){Le(d,s)}}function yi(e){var t;return(t=e.content.proxy)==null?void 0:t.enabled}const Oy=(e,t)=>{const n=e.content.read,r=n==null?void 0:n.objects;return r==null?void 0:r.find(o=>o.objectName===t)},Ey=(e,t,n,r)=>{const o=Xl(e),i=Yl(e),s=Zl(e),a=Oy(n,t);if(!a)return console.error(`Error when getting object from hydratedRevision for objectName: ${t}`),null;const l={revisionId:n.id,createdBy:`consumer:${r}`,content:{provider:n.content.provider,read:{objects:{[t]:{objectName:t,schedule:a.schedule,destination:a.destination,selectedFields:o,selectedFieldMappings:i,selectedValueMappings:s||{},backfill:a.backfill}}}}};return yi(n)&&(l.content.proxy={enabled:!0}),l},Sy=(e,t,n,r,o,i,s,a,l,u,d,f)=>{const p=Ey(l,i,a,r);return p?tu({createConfig:p,projectId:e,integrationId:t,groupRef:n,connectionId:o,apiKey:s,setError:u,setInstallation:d,onInstallSuccess:f}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},nu=e=>{var t;return{...(t=e.write)==null?void 0:t.selectedWriteObjects}},Ny=e=>{const t=e.content.write;return t==null?void 0:t.objects},Ty=(e,t,n)=>{if(!Ny(t))return console.error("Error when getting write objects from hydratedRevision"),null;const o=nu(e),i={revisionId:t.id,createdBy:`consumer:${n}`,content:{provider:t.content.provider,read:{objects:{}},write:{objects:o}}};return yi(t)&&(i.content.proxy={enabled:!0}),i},Ry=(e,t,n,r,o,i,s,a,l,u,d)=>{const f=Ty(a,s,r);return f?tu({createConfig:f,projectId:e,integrationId:t,groupRef:n,connectionId:o,apiKey:i,setError:l,setInstallation:u,onInstallSuccess:d}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},Ay={backgroundColor:"var(--amp-colors-status-critical-muted)",borderColor:"var(--amp-colors-status-critical-muted)",color:"var(--amp-colors-status-critical-dark)",padding:".5rem 1rem"};function vi({children:e,style:t}){return c.jsx(vn,{style:{...Ay,...t},children:e})}var ru={exports:{}};/*!
|
|
4
|
+
[Remedy] ${s.remedy}`:""}`;t&&t(l)}catch(i){console.error("Error parsing error response body:",i)}}else console.error("Unexpected error:",e.message)},Ml=y.createContext({integrations:null,isLoading:!0}),js=()=>{const e=y.useContext(Ml);if(!e)throw new Error("useIntegrationList must be used within a IntegrationListProvider");return e};function Sy({children:e}){const{projectIdOrName:t}=Te(),{setError:n,removeError:r}=Dt(),{data:o,isLoading:i,isError:s}=Dl();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 c.jsx(Ml.Provider,{value:a,children:e})}const Ny=new Zf;function Ty(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 c.jsx(ip,{client:Ny,children:c.jsx(vp,{children:c.jsx(gp,{value:t,children:c.jsx(Ey,{projectIdOrName:i,children:c.jsx(Sy,{children:o})})})})})}const kl=y.createContext(null);function Ry(){const e=y.useContext(kl);if(!e)throw new Error(`Cannot call useAmpersandProvider unless your
|
|
5
|
+
component is wrapped with AmpersandProvider`);return e}const Ay=({groupRef:e,provider:t})=>{const{projectIdOrName:n}=Te(),r=dt();return vn({queryKey:["amp","connections",n,e,t],queryFn:async()=>{if(!n)throw new Error("Project ID or name not found. Please wrap this component inside of AmpersandProvider");if(!e)throw new Error("Group reference not found.");if(!t)throw new Error("Provider not found.");return(await r()).connectionApi.listConnections({projectIdOrName:n,groupRef:e,provider:t})},retry:3,enabled:!!n&&!!e&&!!t})},Py=e=>{const t=Dl(),n=t.data,r=n==null?void 0:n.find(o=>o.name===e||o.id===e);return{...t,data:r,provider:r==null?void 0:r.provider}};function Fy(){return c.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("path",{d:"M20.5796 7.72236L3.63955 36.0024C3.29029 36.6072 3.10549 37.293 3.10353 37.9914C3.10158 38.6898 3.28254 39.3766 3.62841 39.9834C3.97428 40.5902 4.473 41.0959 5.07497 41.4501C5.67693 41.8043 6.36115 41.9947 7.05955 42.0024H40.9396C41.638 41.9947 42.3222 41.8043 42.9241 41.4501C43.5261 41.0959 44.0248 40.5902 44.3707 39.9834C44.7166 39.3766 44.8975 38.6898 44.8956 37.9914C44.8936 37.293 44.7088 36.6072 44.3596 36.0024L27.4196 7.72236C27.063 7.13458 26.561 6.6486 25.9619 6.31133C25.3629 5.97406 24.687 5.79688 23.9996 5.79688C23.3121 5.79688 22.6362 5.97406 22.0372 6.31133C21.4381 6.6486 20.9361 7.13458 20.5796 7.72236Z",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M24 18V26",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M24 34H24.02",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]})}const Dy="_box_1p7c5_1",Ga={box:Dy};function wn({children:e,className:t,style:n}){return c.jsx("div",{className:t?`${Ga.box} ${t}`:Ga.box,style:n,children:e})}const My="_container_1wvzr_1",Qa={container:My};function Wr({children:e,className:t,style:n}){return c.jsx("div",{className:t?`${Qa.container} ${t}`:Qa.container,style:n,children:e})}const ky="_errorBoxContainer_4sdb2_1",jy="_errorBox_4sdb2_1",Ly="_errorText_4sdb2_20",ds={errorBoxContainer:ky,errorBox:jy,errorText:Ly};function jl({message:e}){return c.jsx(wn,{className:ds.errorBox,children:c.jsx("p",{className:ds.errorText,children:e})})}function Ll({message:e,children:t}){return c.jsxs(Wr,{className:ds.errorBoxContainer,children:[c.jsx(Fy,{}),c.jsx(jl,{message:e}),t]})}const Ky="_loader_6ubm6_1",Vy="_rotate_6ubm6_1",Uy="_ball1_6ubm6_1",$y="_ball2_6ubm6_1",qy={loader:Ky,rotate:Vy,ball1:Uy,ball2:$y};function Hy(){return c.jsx("span",{className:qy.loader})}function ai(){return c.jsx("div",{style:{display:"flex",width:"100%",height:"100%",justifyContent:"center",marginTop:"20%",marginBottom:"20%"},children:c.jsx(Hy,{})})}function Kl({children:e}){return c.jsx(Wr,{style:{maxWidth:"55rem"},children:c.jsx(wn,{children:e})})}function zr(){return c.jsx(Kl,{children:c.jsx(ai,{})})}function Jt({message:e,children:t}){return c.jsx(Kl,{children:c.jsx(Ll,{message:e,children:t})})}const Vl=(e,t)=>{var s;const n=dt(),{projectIdOrName:r}=Te(),{integrations:o}=js(),i=(s=o==null?void 0:o.find(a=>a.name===e))==null?void 0:s.id;return vn({queryKey:["amp","installations",r,i,t],queryFn:async()=>{if(!r)throw new Error("Project ID is required");if(!i)throw new Error("Integration ID is required");if(!t)throw new Error("Group reference is required");return(await n()).installationApi.listInstallations({projectIdOrName:r,integrationId:i,groupRef:t})},enabled:!!r&&!!i&&!!t&&!!o&&o.length>0})};function Ls(e,t){try{return process.env[e]}catch{return t}}function kr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ul(e,t){return(t==null?void 0:t.displayName)??kr(e)}const By=e=>e.split(`
|
|
6
|
+
`).filter(n=>n.trim()!==""),Jy=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(n=>n.name===e)??null,Wy=e=>e.replace(/[.:/\\]/g,"\\$&"),zy=()=>{const[e,t]=y.useState(!1),n=y.useCallback(()=>{t(!0)},[t]),r=y.useCallback(()=>{t(!1)},[t]);return{isIntegrationDeleted:e,setIntegrationDeleted:n,resetIntegrationDeleted:r}},$l=y.createContext({integrationId:"",provider:"",integrationObj:void 0,consumerRef:"",consumerName:"",groupRef:"",groupName:"",installation:void 0,setInstallation:()=>{},resetInstallations:()=>{},onInstallSuccess:void 0,onUpdateSuccess:void 0,onUninstallSuccess:void 0,isIntegrationDeleted:!1,setIntegrationDeleted:()=>{}});function rt(){const e=y.useContext($l);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function Gy({children:e,integration:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,onInstallSuccess:s,onUpdateSuccess:a,onUninstallSuccess:l,fieldMapping:u}){const{integrations:d}=js(),{setError:f,isError:p,removeError:m}=Dt(),{isIntegrationDeleted:w,setIntegrationDeleted:v,resetIntegrationDeleted:h}=zy(),x=y.useMemo(()=>Jy(t,d||[]),[t,d]),{data:g,isLoading:b,isError:_,error:C}=Vl(t,o),R=(g==null?void 0:g[0])||null;y.useEffect(()=>{h()},[t,n,r,o,i,u]),y.useEffect(()=>{x===null&&(d!=null&&d.length)&&console.error(`Integration "${t}" not found in integration list`)},[t,x,d]),y.useEffect(()=>{_?(f(ue.INSTALLATION_LIST,(x==null?void 0:x.id)||""),Le(C)):m(ue.INSTALLATION_LIST,(x==null?void 0:x.id)||"")},[_,x,f,m,C]);const N=Et(),T=y.useCallback(()=>{N.invalidateQueries({queryKey:["amp","installations"]})},[N]),F=y.useCallback(z=>{N.setQueryData(["amp","installations"],[z]),N.invalidateQueries({queryKey:["amp","installations"]})},[N]),$=(x==null?void 0:x.id)||"",G=y.useMemo(()=>({integrationId:(x==null?void 0:x.id)||"",provider:(x==null?void 0:x.provider)||"",integrationObj:x,consumerRef:n,consumerName:r,groupRef:o,groupName:i,installation:R||void 0,setInstallation:F,resetInstallations:T,onInstallSuccess:s,onUpdateSuccess:a,onUninstallSuccess:l,isIntegrationDeleted:w,setIntegrationDeleted:v,fieldMapping:u}),[x,n,r,o,i,R,F,T,s,a,l,w,v,u]);if(b)return c.jsx(zr,{});if(x===null)return c.jsx(Jt,{message:`Integration "${t}" not found`});if(p(ue.INSTALLATION_LIST,$)){const z=`Error retrieving installation information for integration "${(x==null?void 0:x.name)||"unknown"}"`;return c.jsx(Jt,{message:z})}return c.jsx($l.Provider,{value:G,children:e})}const ql=y.createContext({connections:null,isConnectionsLoading:!0,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{}}),Qt=()=>{const e=y.useContext(ql);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function Hl({groupRef:e,provider:t,children:n}){const r=Et(),{setError:o,isError:i}=Dt(),{projectId:s,isLoading:a}=Te(),{integrationId:l,groupRef:u}=rt(),{provider:d}=Py(l),{data:f,isLoading:p,isError:m,error:w}=Ay({groupRef:e||u,provider:d||t}),v=f==null?void 0:f[0],h=y.useCallback(b=>{r.setQueryData(["amp","connections"],()=>b),r.invalidateQueries({queryKey:["amp","connections"]})},[r]),x=y.useCallback(()=>{r.invalidateQueries({queryKey:["amp","connections"]})},[r]);y.useEffect(()=>{m?(o(ue.CONNECTION_LIST,s,!0),Le(w)):o(ue.CONNECTION_LIST,s,!1)},[m,o,s,w]);const g=y.useMemo(()=>({connections:f||null,isConnectionsLoading:p,selectedConnection:v||null,setConnections:h,setSelectedConnection:x}),[f,p,v,h,x]);if(p||a)return c.jsx(zr,{});if(i(ue.PROJECT,s))return c.jsx(Jt,{message:`Error loading project ${s}`});if(i(ue.CONNECTION_LIST,s))return c.jsx(Jt,{message:"Error retrieving existing connections"});if(!s)throw new Error("Project ID not found. ConnectionsProvider must be used within AmpersandProvider");return c.jsx(ql.Provider,{value:g,children:n})}function Bl(){const[e,t]=y.useState(1);return{seed:e,reset:()=>{t(Math.random())}}}const Qy="_resetContainer_lkwv9_4",Jl={resetContainer:Qy};var ki=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ks(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qi={exports:{}};Qi.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",o=1,i=2,s=9007199254740991,a="[object Arguments]",l="[object Array]",u="[object AsyncFunction]",d="[object Boolean]",f="[object Date]",p="[object Error]",m="[object Function]",w="[object GeneratorFunction]",v="[object Map]",h="[object Number]",x="[object Null]",g="[object Object]",b="[object Promise]",_="[object Proxy]",C="[object RegExp]",R="[object Set]",N="[object String]",T="[object Symbol]",F="[object Undefined]",$="[object WeakMap]",G="[object ArrayBuffer]",z="[object DataView]",ne="[object Float32Array]",B="[object Float64Array]",ce="[object Int8Array]",se="[object Int16Array]",te="[object Int32Array]",ge="[object Uint8Array]",we="[object Uint8ClampedArray]",A="[object Uint16Array]",k="[object Uint32Array]",U=/[\\^$.*+?()[\]{}|]/g,L=/^\[object .+?Constructor\]$/,j=/^(?:0|[1-9]\d*)$/,D={};D[ne]=D[B]=D[ce]=D[se]=D[te]=D[ge]=D[we]=D[A]=D[k]=!0,D[a]=D[l]=D[G]=D[d]=D[z]=D[f]=D[p]=D[m]=D[v]=D[h]=D[g]=D[C]=D[R]=D[N]=D[$]=!1;var Y=typeof ki=="object"&&ki&&ki.Object===Object&&ki,Z=typeof self=="object"&&self&&self.Object===Object&&self,q=Y||Z||Function("return this")(),ee=t&&!t.nodeType&&t,Q=ee&&!0&&e&&!e.nodeType&&e,de=Q&&Q.exports===ee,M=de&&Y.process,ve=function(){try{return M&&M.binding&&M.binding("util")}catch{}}(),H=ve&&ve.isTypedArray;function Ee(I,E){for(var P=-1,X=I==null?0:I.length,Re=0,fe=[];++P<X;){var Me=I[P];E(Me,P,I)&&(fe[Re++]=Me)}return fe}function Ve(I,E){for(var P=-1,X=E.length,Re=I.length;++P<X;)I[Re+P]=E[P];return I}function Ye(I,E){for(var P=-1,X=I==null?0:I.length;++P<X;)if(E(I[P],P,I))return!0;return!1}function Ue(I,E){for(var P=-1,X=Array(I);++P<I;)X[P]=E(P);return X}function Ie(I){return function(E){return I(E)}}function Mt(I,E){return I.has(E)}function Ze(I,E){return I==null?void 0:I[E]}function vt(I){var E=-1,P=Array(I.size);return I.forEach(function(X,Re){P[++E]=[Re,X]}),P}function kt(I,E){return function(P){return I(E(P))}}function jt(I){var E=-1,P=Array(I.size);return I.forEach(function(X){P[++E]=X}),P}var et=Array.prototype,Ge=Function.prototype,$e=Object.prototype,Pe=q["__core-js_shared__"],Lt=Ge.toString,it=$e.hasOwnProperty,sn=function(){var I=/[^.]+$/.exec(Pe&&Pe.keys&&Pe.keys.IE_PROTO||"");return I?"Symbol(src)_1."+I:""}(),In=$e.toString,wt=RegExp("^"+Lt.call(it).replace(U,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Fe=de?q.Buffer:void 0,an=q.Symbol,bn=q.Uint8Array,cn=$e.propertyIsEnumerable,Hn=et.splice,ft=an?an.toStringTag:void 0,ln=Object.getOwnPropertySymbols,xn=Fe?Fe.isBuffer:void 0,Bn=kt(Object.keys,Object),_n=vr(q,"DataView"),Ae=vr(q,"Map"),ot=vr(q,"Promise"),ie=vr(q,"Set"),me=vr(q,"WeakMap"),qe=vr(Object,"create"),un=zn(_n),J=zn(Ae),ae=zn(ot),le=zn(ie),Ke=zn(me),He=an?an.prototype:void 0,pt=He?He.valueOf:void 0;function Qe(I){var E=-1,P=I==null?0:I.length;for(this.clear();++E<P;){var X=I[E];this.set(X[0],X[1])}}function tt(){this.__data__=qe?qe(null):{},this.size=0}function ht(I){var E=this.has(I)&&delete this.__data__[I];return this.size-=E?1:0,E}function Ne(I){var E=this.__data__;if(qe){var P=E[I];return P===r?void 0:P}return it.call(E,I)?E[I]:void 0}function Jn(I){var E=this.__data__;return qe?E[I]!==void 0:it.call(E,I)}function So(I,E){var P=this.__data__;return this.size+=this.has(I)?0:1,P[I]=qe&&E===void 0?r:E,this}Qe.prototype.clear=tt,Qe.prototype.delete=ht,Qe.prototype.get=Ne,Qe.prototype.has=Jn,Qe.prototype.set=So;function St(I){var E=-1,P=I==null?0:I.length;for(this.clear();++E<P;){var X=I[E];this.set(X[0],X[1])}}function xi(){this.__data__=[],this.size=0}function _i(I){var E=this.__data__,P=Ei(E,I);if(P<0)return!1;var X=E.length-1;return P==X?E.pop():Hn.call(E,P,1),--this.size,!0}function Ci(I){var E=this.__data__,P=Ei(E,I);return P<0?void 0:E[P][1]}function Se(I){return Ei(this.__data__,I)>-1}function Kt(I,E){var P=this.__data__,X=Ei(P,I);return X<0?(++this.size,P.push([I,E])):P[X][1]=E,this}St.prototype.clear=xi,St.prototype.delete=_i,St.prototype.get=Ci,St.prototype.has=Se,St.prototype.set=Kt;function Vt(I){var E=-1,P=I==null?0:I.length;for(this.clear();++E<P;){var X=I[E];this.set(X[0],X[1])}}function Wn(){this.size=0,this.__data__={hash:new Qe,map:new(Ae||St),string:new Qe}}function No(I){var E=Si(this,I).delete(I);return this.size-=E?1:0,E}function Xr(I){return Si(this,I).get(I)}function cf(I){return Si(this,I).has(I)}function lf(I,E){var P=Si(this,I),X=P.size;return P.set(I,E),this.size+=P.size==X?0:1,this}Vt.prototype.clear=Wn,Vt.prototype.delete=No,Vt.prototype.get=Xr,Vt.prototype.has=cf,Vt.prototype.set=lf;function Oi(I){var E=-1,P=I==null?0:I.length;for(this.__data__=new Vt;++E<P;)this.add(I[E])}function uf(I){return this.__data__.set(I,r),this}function df(I){return this.__data__.has(I)}Oi.prototype.add=Oi.prototype.push=uf,Oi.prototype.has=df;function Cn(I){var E=this.__data__=new St(I);this.size=E.size}function ff(){this.__data__=new St,this.size=0}function pf(I){var E=this.__data__,P=E.delete(I);return this.size=E.size,P}function hf(I){return this.__data__.get(I)}function mf(I){return this.__data__.has(I)}function gf(I,E){var P=this.__data__;if(P instanceof St){var X=P.__data__;if(!Ae||X.length<n-1)return X.push([I,E]),this.size=++P.size,this;P=this.__data__=new Vt(X)}return P.set(I,E),this.size=P.size,this}Cn.prototype.clear=ff,Cn.prototype.delete=pf,Cn.prototype.get=hf,Cn.prototype.has=mf,Cn.prototype.set=gf;function yf(I,E){var P=Ni(I),X=!P&&Pf(I),Re=!P&&!X&&To(I),fe=!P&&!X&&!Re&&Aa(I),Me=P||X||Re||fe,Xe=Me?Ue(I.length,String):[],nt=Xe.length;for(var De in I)it.call(I,De)&&!(Me&&(De=="length"||Re&&(De=="offset"||De=="parent")||fe&&(De=="buffer"||De=="byteLength"||De=="byteOffset")||Sf(De,nt)))&&Xe.push(De);return Xe}function Ei(I,E){for(var P=I.length;P--;)if(Sa(I[P][0],E))return P;return-1}function vf(I,E,P){var X=E(I);return Ni(I)?X:Ve(X,P(I))}function Yr(I){return I==null?I===void 0?F:x:ft&&ft in Object(I)?Of(I):Af(I)}function _a(I){return Zr(I)&&Yr(I)==a}function Ca(I,E,P,X,Re){return I===E?!0:I==null||E==null||!Zr(I)&&!Zr(E)?I!==I&&E!==E:wf(I,E,P,X,Ca,Re)}function wf(I,E,P,X,Re,fe){var Me=Ni(I),Xe=Ni(E),nt=Me?l:On(I),De=Xe?l:On(E);nt=nt==a?g:nt,De=De==a?g:De;var It=nt==g,Ut=De==g,st=nt==De;if(st&&To(I)){if(!To(E))return!1;Me=!0,It=!1}if(st&&!It)return fe||(fe=new Cn),Me||Aa(I)?Oa(I,E,P,X,Re,fe):_f(I,E,nt,P,X,Re,fe);if(!(P&o)){var Nt=It&&it.call(I,"__wrapped__"),Tt=Ut&&it.call(E,"__wrapped__");if(Nt||Tt){var En=Nt?I.value():I,dn=Tt?E.value():E;return fe||(fe=new Cn),Re(En,dn,P,X,fe)}}return st?(fe||(fe=new Cn),Cf(I,E,P,X,Re,fe)):!1}function If(I){if(!Ra(I)||Tf(I))return!1;var E=Na(I)?wt:L;return E.test(zn(I))}function bf(I){return Zr(I)&&Ta(I.length)&&!!D[Yr(I)]}function xf(I){if(!Rf(I))return Bn(I);var E=[];for(var P in Object(I))it.call(I,P)&&P!="constructor"&&E.push(P);return E}function Oa(I,E,P,X,Re,fe){var Me=P&o,Xe=I.length,nt=E.length;if(Xe!=nt&&!(Me&&nt>Xe))return!1;var De=fe.get(I);if(De&&fe.get(E))return De==E;var It=-1,Ut=!0,st=P&i?new Oi:void 0;for(fe.set(I,E),fe.set(E,I);++It<Xe;){var Nt=I[It],Tt=E[It];if(X)var En=Me?X(Tt,Nt,It,E,I,fe):X(Nt,Tt,It,I,E,fe);if(En!==void 0){if(En)continue;Ut=!1;break}if(st){if(!Ye(E,function(dn,Gn){if(!Mt(st,Gn)&&(Nt===dn||Re(Nt,dn,P,X,fe)))return st.push(Gn)})){Ut=!1;break}}else if(!(Nt===Tt||Re(Nt,Tt,P,X,fe))){Ut=!1;break}}return fe.delete(I),fe.delete(E),Ut}function _f(I,E,P,X,Re,fe,Me){switch(P){case z:if(I.byteLength!=E.byteLength||I.byteOffset!=E.byteOffset)return!1;I=I.buffer,E=E.buffer;case G:return!(I.byteLength!=E.byteLength||!fe(new bn(I),new bn(E)));case d:case f:case h:return Sa(+I,+E);case p:return I.name==E.name&&I.message==E.message;case C:case N:return I==E+"";case v:var Xe=vt;case R:var nt=X&o;if(Xe||(Xe=jt),I.size!=E.size&&!nt)return!1;var De=Me.get(I);if(De)return De==E;X|=i,Me.set(I,E);var It=Oa(Xe(I),Xe(E),X,Re,fe,Me);return Me.delete(I),It;case T:if(pt)return pt.call(I)==pt.call(E)}return!1}function Cf(I,E,P,X,Re,fe){var Me=P&o,Xe=Ea(I),nt=Xe.length,De=Ea(E),It=De.length;if(nt!=It&&!Me)return!1;for(var Ut=nt;Ut--;){var st=Xe[Ut];if(!(Me?st in E:it.call(E,st)))return!1}var Nt=fe.get(I);if(Nt&&fe.get(E))return Nt==E;var Tt=!0;fe.set(I,E),fe.set(E,I);for(var En=Me;++Ut<nt;){st=Xe[Ut];var dn=I[st],Gn=E[st];if(X)var Pa=Me?X(Gn,dn,st,E,I,fe):X(dn,Gn,st,I,E,fe);if(!(Pa===void 0?dn===Gn||Re(dn,Gn,P,X,fe):Pa)){Tt=!1;break}En||(En=st=="constructor")}if(Tt&&!En){var Ti=I.constructor,Ri=E.constructor;Ti!=Ri&&"constructor"in I&&"constructor"in E&&!(typeof Ti=="function"&&Ti instanceof Ti&&typeof Ri=="function"&&Ri instanceof Ri)&&(Tt=!1)}return fe.delete(I),fe.delete(E),Tt}function Ea(I){return vf(I,Mf,Ef)}function Si(I,E){var P=I.__data__;return Nf(E)?P[typeof E=="string"?"string":"hash"]:P.map}function vr(I,E){var P=Ze(I,E);return If(P)?P:void 0}function Of(I){var E=it.call(I,ft),P=I[ft];try{I[ft]=void 0;var X=!0}catch{}var Re=In.call(I);return X&&(E?I[ft]=P:delete I[ft]),Re}var Ef=ln?function(I){return I==null?[]:(I=Object(I),Ee(ln(I),function(E){return cn.call(I,E)}))}:kf,On=Yr;(_n&&On(new _n(new ArrayBuffer(1)))!=z||Ae&&On(new Ae)!=v||ot&&On(ot.resolve())!=b||ie&&On(new ie)!=R||me&&On(new me)!=$)&&(On=function(I){var E=Yr(I),P=E==g?I.constructor:void 0,X=P?zn(P):"";if(X)switch(X){case un:return z;case J:return v;case ae:return b;case le:return R;case Ke:return $}return E});function Sf(I,E){return E=E??s,!!E&&(typeof I=="number"||j.test(I))&&I>-1&&I%1==0&&I<E}function Nf(I){var E=typeof I;return E=="string"||E=="number"||E=="symbol"||E=="boolean"?I!=="__proto__":I===null}function Tf(I){return!!sn&&sn in I}function Rf(I){var E=I&&I.constructor,P=typeof E=="function"&&E.prototype||$e;return I===P}function Af(I){return In.call(I)}function zn(I){if(I!=null){try{return Lt.call(I)}catch{}try{return I+""}catch{}}return""}function Sa(I,E){return I===E||I!==I&&E!==E}var Pf=_a(function(){return arguments}())?_a:function(I){return Zr(I)&&it.call(I,"callee")&&!cn.call(I,"callee")},Ni=Array.isArray;function Ff(I){return I!=null&&Ta(I.length)&&!Na(I)}var To=xn||jf;function Df(I,E){return Ca(I,E)}function Na(I){if(!Ra(I))return!1;var E=Yr(I);return E==m||E==w||E==u||E==_}function Ta(I){return typeof I=="number"&&I>-1&&I%1==0&&I<=s}function Ra(I){var E=typeof I;return I!=null&&(E=="object"||E=="function")}function Zr(I){return I!=null&&typeof I=="object"}var Aa=H?Ie(H):bf;function Mf(I){return Ff(I)?yf(I):xf(I)}function kf(){return[]}function jf(){return!1}e.exports=Df})(Qi,Qi.exports);var Xy=Qi.exports;const Wl=Ks(Xy),dr="other",Xi="manage-tab";function Kn(e){return!e.fieldName}function Yy(e,t){var n;return((n=e==null?void 0:e.objects)==null?void 0:n.find(r=>r.objectName===t))||null}function Zy(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(n=>!Kn(n)&&!!n.fieldName))||null}function ev(e){var n;return((n=e==null?void 0:e.requiredFields)==null?void 0:n.filter(r=>Kn(r)&&!!r.mapToName))||[]}function tv(e){var n;return((n=e==null?void 0:e.optionalFields)==null?void 0:n.filter(r=>Kn(r)&&!!r.mapToName))||[]}function nv(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(n=>!Kn(n)&&!!n.fieldName))||null}const zl=(e,t)=>{var n,r,o;return(o=(r=(n=e==null?void 0:e.content)==null?void 0:n.read)==null?void 0:r.objects)==null?void 0:o[t]};function rv(e){return Kn(e)?e.mapToName:e.fieldName}const Gl=(e,t)=>{var r,o,i;const n=[];return(i=(o=(r=t.content)==null?void 0:r.read)==null?void 0:o.objects)==null||i.forEach(s=>{n.push({name:s==null?void 0:s.objectName,displayName:(s==null?void 0:s.mapToDisplayName)||(s==null?void 0:s.displayName)||(s==null?void 0:s.objectName)&&kr(s==null?void 0:s.objectName),completed:e?!!zl(e,s.objectName):!1})}),n},Ql=e=>{var n;return{name:dr,completed:e?!!((n=e==null?void 0:e.content)!=null&&n.write):!1}};function iv(e,t){var i;const n=Gl(e,t),o=!!((i=t==null?void 0:t.content)!=null&&i.write)?Ql(e):void 0;return o&&n.push(o),n}function Xl(e,t,n){const r=(e==null?void 0:e.filter(i=>!(t!=null&&t[i==null?void 0:i.mapToName])))||[],o=r.map(i=>i.mapToName);return n(ue.MAPPING,o),r!=null&&r.length&&console.error("required fields not met",r.map(i=>i.mapToDisplayName)),{errorList:o}}function ov(e,t){return Wl(e,t)}function Yl(e,t){return Wl(e,t)}const sv=(e,t,n)=>{var h,x,g,b,_,C,R,N,T;if(!e)return null;const r=Yy(e,t),o=r&&Zy(r),i=r&&nv(r),s=r&&ev(r),a=r&&tv(r),l=(r==null?void 0:r.allFields)||[],u=(r==null?void 0:r.allFieldsMetadata)||{},d=n==null?void 0:n.content,f=((g=(x=(h=d==null?void 0:d.read)==null?void 0:h.objects)==null?void 0:x[t])==null?void 0:g.selectedFields)||{},p=((C=(_=(b=d==null?void 0:d.read)==null?void 0:b.objects)==null?void 0:_[t])==null?void 0:C.selectedValueMappings)||{},m=((T=(N=(R=d==null?void 0:d.read)==null?void 0:R.objects)==null?void 0:N[t])==null?void 0:T.selectedFieldMappings)||{},w={...f},v={...m};return{allFields:l,allFieldsMetadata:u,requiredFields:o,optionalFields:i,requiredMapFields:s,optionalMapFields:a,selectedOptionalFields:f,selectedFieldMappings:m,selectedValueMappings:p,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,isValueMappingsModified:!1,savedConfig:{optionalFields:w,requiredMapFields:v,selectedValueMappings:p}}},av=(e,t)=>{var r,o;if(!e)return null;const n=(o=(r=t==null?void 0:t.content)==null?void 0:r.write)==null?void 0:o.objects;return{writeObjects:(e==null?void 0:e.objects)||[],selectedWriteObjects:n||{},isWriteModified:!1,savedConfig:{selectedWriteObjects:n||{}}}};function Zl(e,t,n){var i,s;const r=(i=e==null?void 0:e.content)==null?void 0:i.read,o=(s=e==null?void 0:e.content)==null?void 0:s.write;return{read:sv(r,t,n),write:av(o,n)}}const eu=(e,t,n,r)=>{const o=Zl(e,n,t);r(n,o)},cv=(e,t,n)=>{const r=iv(t,e),o={};r.forEach(({name:i,completed:s})=>{s&&(o[i]=Zl(e,i,t))}),n(o)},tu=e=>{const{requiredFields:t,selectedOptionalFields:n}=(e==null?void 0:e.read)||{},r=new Set;return t==null||t.forEach(i=>r.add(rv(i))),{...Array.from(r).reduce((i,s)=>({...i,[s]:!0}),{}),...n||{}}},nu=e=>{const{selectedFieldMappings:t}=(e==null?void 0:e.read)||{},n={};return t&&Object.keys(t).forEach(r=>{t[r]!==void 0?n[r]=t[r]||"":console.warn(`Error undefined when generating selectedRequiredMapFieldsSubmit for key: ${r}`)}),n},ru=e=>{const{selectedValueMappings:t}=(e==null?void 0:e.read)||{};return t};function iu(e,t){return t[e]||void 0}async function ou({createConfig:e,projectId:t,integrationId:n,groupRef:r,connectionId:o,apiKey:i,setError:s,setInstallation:a,onInstallSuccess:l}){const u={projectIdOrName:t,integrationId:n,installation:{groupRef:r,connectionId:o,config:e}};try{const d=await ks().installationApi.createInstallation(u,{headers:{"X-Api-Key":i,"Content-Type":"application/json"}});a(d),l==null||l(d.id,d.config)}catch(d){Le(d,s)}}function yi(e){var t;return(t=e.content.proxy)==null?void 0:t.enabled}const lv=(e,t)=>{const n=e.content.read,r=n==null?void 0:n.objects;return r==null?void 0:r.find(o=>o.objectName===t)},uv=(e,t,n,r)=>{const o=tu(e),i=nu(e),s=ru(e),a=lv(n,t);if(!a)return console.error(`Error when getting object from hydratedRevision for objectName: ${t}`),null;const l={revisionId:n.id,createdBy:`consumer:${r}`,content:{provider:n.content.provider,read:{objects:{[t]:{objectName:t,schedule:a.schedule,destination:a.destination,selectedFields:o,selectedFieldMappings:i,selectedValueMappings:s||{},backfill:a.backfill}}}}};return yi(n)&&(l.content.proxy={enabled:!0}),l},dv=(e,t,n,r,o,i,s,a,l,u,d,f)=>{const p=uv(l,i,a,r);return p?ou({createConfig:p,projectId:e,integrationId:t,groupRef:n,connectionId:o,apiKey:s,setError:u,setInstallation:d,onInstallSuccess:f}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},su=e=>{var t;return{...(t=e.write)==null?void 0:t.selectedWriteObjects}},fv=e=>{const t=e.content.write;return t==null?void 0:t.objects},pv=(e,t,n)=>{if(!fv(t))return console.error("Error when getting write objects from hydratedRevision"),null;const o=su(e),i={revisionId:t.id,createdBy:`consumer:${n}`,content:{provider:t.content.provider,read:{objects:{}},write:{objects:o}}};return yi(t)&&(i.content.proxy={enabled:!0}),i},hv=(e,t,n,r,o,i,s,a,l,u,d)=>{const f=pv(a,s,r);return f?ou({createConfig:f,projectId:e,integrationId:t,groupRef:n,connectionId:o,apiKey:i,setError:l,setInstallation:u,onInstallSuccess:d}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},mv={backgroundColor:"var(--amp-colors-status-critical-muted)",borderColor:"var(--amp-colors-status-critical-muted)",color:"var(--amp-colors-status-critical-dark)",padding:".5rem 1rem"};function vi({children:e,style:t}){return c.jsx(wn,{style:{...mv,...t},children:e})}var au={exports:{}};/*!
|
|
7
7
|
Copyright (c) 2018 Jed Watson.
|
|
8
8
|
Licensed under the MIT License (MIT), see
|
|
9
9
|
http://jedwatson.github.io/classnames
|
|
10
|
-
*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var i="",s=0;s<arguments.length;s++){var a=arguments[s];a&&(i=o(i,r(a)))}return i}function r(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return n.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var s="";for(var a in i)t.call(i,a)&&i[a]&&(s=o(s,a));return s}function o(i,s){return s?i?i+" "+s:i+s:i}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(ru);var Py=ru.exports;const Pt=Ls(Py),Dy="_button_kwfiu_1",Fy="_buttonError_kwfiu_28",My="_danger_kwfiu_42",jy="_ghost_kwfiu_47",Fo={button:Dy,buttonError:Fy,danger:My,ghost:jy};function Je({className:e,style:t,type:n,children:r,variant:o,...i}){const s=Pt(Fo.button,{[Fo.danger]:o==="danger",[Fo.ghost]:o==="ghost",[e||""]:!!e});return c.jsx("button",{type:n,className:s,style:t,...i,children:r})}const ky=()=>{const e=ut(),t=Ot();return Wr({mutationKey:["deleteConnection"],mutationFn:async({projectIdOrName:n,connectionId:r})=>(await e()).connectionApi.deleteConnection({projectIdOrName:n,connectionId:r}),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","connections"]})},onError:n=>{console.error("Error deleting connection.",{error:n})}})};function iu({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={},onDisconnectSuccess:r,resetComponent:o,onDisconnectError:i}){const{projectId:s}=Te(),{selectedConnection:a}=Gt(),l=ky(),[u,d]=y.useState(!1),f=!s||!a||!a.id||u,p=async()=>{f||(d(!0),console.warn("deleting connection",{projectId:s,connectionId:a==null?void 0:a.id}),l.mutate({projectIdOrName:s,connectionId:a==null?void 0:a.id},{onSuccess:()=>{console.warn("successfully deleted connection:",a==null?void 0:a.id),r==null||r(a),o()},onError:v=>{Le(v,i)},onSettled:()=>d(!1)}))},m=u?"Disconnecting...":e;return c.jsx(Je,{type:"button",onClick:p,disabled:f,variant:t,style:n,children:m})}const ou=y.createContext({hydratedRevision:null,loading:!1,readAction:void 0,writeObjects:[]}),Gr=()=>{const e=y.useContext(ou);if(!e)throw new Error("useHydratedRevision must be used within a HydratedRevisionProvider");return e},Ly=()=>{var u;const e=Ot(),t=ut(),{selectedConnection:n,isConnectionsLoading:r}=Gt(),{projectIdOrName:o}=Te(),{integrationId:i,integrationObj:s}=nt(),a=n==null?void 0:n.id,l=(u=s==null?void 0:s.latestRevision)==null?void 0:u.id;return y.useEffect(()=>{a||e.invalidateQueries({queryKey:["amp","hydratedRevision"]})},[a,e]),yn({queryKey:["amp","hydratedRevision",o,i,l,a],queryFn:async()=>{if(!o)throw new Error("projectIdOrName is required");if(!i)throw new Error("integrationId is required");if(!l)throw new Error("revisionId is required");if(!a)throw new Error("connectionId is required");return(await t()).revisionApi.getHydratedRevision({projectIdOrName:o,integrationId:i,revisionId:l,connectionId:a})},retry:3,enabled:!!o&&!!i&&!!l&&!!a&&!r})};function Ky({children:e,resetComponent:t}){const{integrationId:n,integrationObj:r}=nt(),{isError:o,removeError:i,setError:s}=Dt(),a=(r==null?void 0:r.name)||n,[l,u]=y.useState(null),[d,f]=y.useState(null),{data:p,isLoading:m,isError:w,error:v}=Ly();y.useEffect(()=>{w?(s(ue.HYDRATED_REVISION,a),Le(v,u)):(i(ue.HYDRATED_REVISION,a),u(null),f(null))},[w,a,s,i,v,u]);const h=y.useMemo(()=>{var g,b,_;return{hydratedRevision:p||null,loading:m,readAction:(g=p==null?void 0:p.content)==null?void 0:g.read,writeObjects:((_=(b=p==null?void 0:p.content)==null?void 0:b.write)==null?void 0:_.objects)||[]}},[p,m]);if(m)return c.jsx(zr,{});const x=(r==null?void 0:r.provider)||"provider";if(o(ue.HYDRATED_REVISION,a)){const g=(r==null?void 0:r.name)||n||"unknown integration",b=`${l?`: ${l}`:`Error retrieving objects from ${x} or integration details for ${g}`}`;return c.jsx(Bt,{message:b,children:c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",paddingTop:"1rem"},children:[d&&c.jsx(Dl,{message:d}),c.jsx(iu,{buttonText:"Try again",resetComponent:t,buttonVariant:"danger",onDisconnectError:_=>f(_)})]})})}return c.jsx(ou.Provider,{value:h,children:e})}const su=y.createContext(null);function au(){const e=y.useContext(su);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}const cu=y.createContext(()=>{});function Vy(){const e=y.useContext(cu);if(!e)throw new Error("useSetNextTabIndex must be used within a NextTabIndexProvider");return{onNextIncompleteTab:e}}var lu=Symbol.for("immer-nothing"),Qa=Symbol.for("immer-draftable"),xt=Symbol.for("immer-state"),$y=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 gt(e,...t){if(process.env.NODE_ENV!=="production"){const n=$y[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 kr=Object.getPrototypeOf;function Lr(e){return!!e&&!!e[xt]}function fr(e){var t;return e?uu(e)||Array.isArray(e)||!!e[Qa]||!!((t=e.constructor)!=null&&t[Qa])||ho(e)||mo(e):!1}var Uy=Object.prototype.constructor.toString();function uu(e){if(!e||typeof e!="object")return!1;const t=kr(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)===Uy}function Yi(e,t){po(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function po(e){const t=e[xt];return t?t.type_:Array.isArray(e)?1:ho(e)?2:mo(e)?3:0}function fs(e,t){return po(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function du(e,t,n){const r=po(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function qy(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function ho(e){return e instanceof Map}function mo(e){return e instanceof Set}function Qn(e){return e.copy_||e.base_}function ps(e,t){if(ho(e))return new Map(e);if(mo(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=uu(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[xt];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(kr(e),r)}else{const r=kr(e);if(r!==null&&n)return{...e};const o=Object.create(r);return Object.assign(o,e)}}function Ks(e,t=!1){return go(e)||Lr(e)||!fr(e)||(po(e)>1&&(e.set=e.add=e.clear=e.delete=Hy),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>Ks(r,!0))),e}function Hy(){gt(2)}function go(e){return Object.isFrozen(e)}var By={};function pr(e){const t=By[e];return t||gt(0,e),t}var ci;function fu(){return ci}function Wy(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Xa(e,t){t&&(pr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function hs(e){ms(e),e.drafts_.forEach(Jy),e.drafts_=null}function ms(e){e===ci&&(ci=e.parent_)}function Ya(e){return ci=Wy(ci,e)}function Jy(e){const t=e[xt];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Za(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[xt].modified_&&(hs(t),gt(4)),fr(e)&&(e=Zi(t,e),t.parent_||eo(t,e)),t.patches_&&pr("Patches").generateReplacementPatches_(n[xt].base_,e,t.patches_,t.inversePatches_)):e=Zi(t,n,[]),hs(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==lu?e:void 0}function Zi(e,t,n){if(go(t))return t;const r=t[xt];if(!r)return Yi(t,(o,i)=>ec(e,r,t,o,i,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return eo(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),Yi(i,(a,l)=>ec(e,r,o,a,l,n,s)),eo(e,o,!1),n&&e.patches_&&pr("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function ec(e,t,n,r,o,i,s){if(process.env.NODE_ENV!=="production"&&o===n&>(5),Lr(o)){const a=i&&t&&t.type_!==3&&!fs(t.assigned_,r)?i.concat(r):void 0,l=Zi(e,o,a);if(du(n,r,l),Lr(l))e.canAutoFreeze_=!1;else return}else s&&n.add(o);if(fr(o)&&!go(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Zi(e,o),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&eo(e,o)}}function eo(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ks(t,n)}function zy(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:fu(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,i=Vs;n&&(o=[r],i=li);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,a}var Vs={get(e,t){if(t===xt)return e;const n=Qn(e);if(!fs(n,t))return Gy(e,n,t);const r=n[t];return e.finalized_||!fr(r)?r:r===Mo(e.base_,t)?(jo(e),e.copy_[t]=ys(r,e)):r},has(e,t){return t in Qn(e)},ownKeys(e){return Reflect.ownKeys(Qn(e))},set(e,t,n){const r=pu(Qn(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const o=Mo(Qn(e),t),i=o==null?void 0:o[xt];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(qy(n,o)&&(n!==void 0||fs(e.base_,t)))return!0;jo(e),gs(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 Mo(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,jo(e),gs(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Qn(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){gt(11)},getPrototypeOf(e){return kr(e.base_)},setPrototypeOf(){gt(12)}},li={};Yi(Vs,(e,t)=>{li[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});li.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&>(13),li.set.call(this,e,t,void 0)};li.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&>(14),Vs.set.call(this,e[0],t,n,e[0])};function Mo(e,t){const n=e[xt];return(n?Qn(n):e)[t]}function Gy(e,t,n){var o;const r=pu(t,n);return r?"value"in r?r.value:(o=r.get)==null?void 0:o.call(e.draft_):void 0}function pu(e,t){if(!(t in e))return;let n=kr(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=kr(n)}}function gs(e){e.modified_||(e.modified_=!0,e.parent_&&gs(e.parent_))}function jo(e){e.copy_||(e.copy_=ps(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Qy=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(l=i,...u){return s.produce(l,d=>n.call(this,d,...u))}}typeof n!="function"&>(6),r!==void 0&&typeof r!="function"&>(7);let o;if(fr(t)){const i=Ya(this),s=ys(t,void 0);let a=!0;try{o=n(s),a=!1}finally{a?hs(i):ms(i)}return Xa(i,r),Za(o,i)}else if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===lu&&(o=void 0),this.autoFreeze_&&Ks(o,!0),r){const i=[],s=[];pr("Patches").generateReplacementPatches_(t,o,i,s),r(i,s)}return o}else gt(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,l=>t(l,...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){fr(e)||gt(8),Lr(e)&&(e=Xy(e));const t=Ya(this),n=ys(e,void 0);return n[xt].isManual_=!0,ms(t),n}finishDraft(e,t){const n=e&&e[xt];(!n||!n.isManual_)&>(9);const{scope_:r}=n;return Xa(r,t),Za(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=pr("Patches").applyPatches_;return Lr(e)?r(e,t):this.produce(e,o=>r(o,t))}};function ys(e,t){const n=ho(e)?pr("MapSet").proxyMap_(e,t):mo(e)?pr("MapSet").proxySet_(e,t):zy(e,t);return(t?t.scope_:fu()).drafts_.push(n),n}function Xy(e){return Lr(e)||gt(10,e),hu(e)}function hu(e){if(!fr(e)||go(e))return e;const t=e[xt];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=ps(e,t.scope_.immer_.useStrictShallowCopy_)}else n=ps(e,!0);return Yi(n,(r,o)=>{du(n,r,hu(o))}),t&&(t.finalized_=!1),n}var _t=new Qy,ei=_t.produce;_t.produceWithPatches.bind(_t);_t.setAutoFreeze.bind(_t);_t.setUseStrictShallowCopy.bind(_t);_t.applyPatches.bind(_t);_t.createDraft.bind(_t);_t.finishDraft.bind(_t);const mu=y.createContext(void 0),Yy={};function $s(){const e=y.useContext(mu);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function Zy({children:e}){const{installation:t}=nt(),{hydratedRevision:n,loading:r}=Gr(),[o,i]=y.useState(Yy),s=t==null?void 0:t.config;y.useEffect(()=>{n!=null&&n.content&&!r&&s&&!(Object.entries(o).length>0)&&Cy(n,s,i)},[n,r,s,o]);const a=y.useCallback((m,w)=>{i(v=>ei(v,h=>{h[m]=ei(h[m],w)}))},[i]),l=y.useCallback((m,w)=>{i(v=>ei(v,h=>{h[m]=w}))},[i]),u=y.useCallback(()=>{i(ei(m=>{const w=m.other.write;w&&(w.isWriteModified=!1)}))},[i]),d=y.useCallback(m=>{i(ei(w=>{var h;const v=(h=w[m])==null?void 0:h.read;v&&(v.isOptionalFieldsModified=!1,v.isRequiredMapFieldsModified=!1,v.isValueMappingsModified=!1)}))},[i]),f=y.useCallback(m=>{m===dr?u():d(m)},[d,u]),p=y.useMemo(()=>({objectConfigurationsState:o,setObjectConfigurationsState:i,setConfigureState:a,resetConfigureState:l,resetPendingConfigurationState:f}),[o,l,f,a]);return c.jsx(mu.Provider,{value:p,children:e})}const Qt=()=>{const{appName:e}=Te(),{objectConfigurationsState:t,setConfigureState:n}=$s(),{selectedObjectName:r}=au(),o=eu(r||"",t);return{appName:e,configureState:o,setConfigureState:n,selectedObjectName:r}};function ev(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=!zl(o,n);e.read.isRequiredMapFieldsModified=s}}function ui(e,t,n){t(e,r=>ev(r,n))}const tv=(e,t)=>e.filter(n=>!t.has(n));function nv(){var p,m,w;const{selectedObjectName:e,configureState:t,setConfigureState:n}=Qt(),{fieldMapping:r}=nt(),o=((p=t==null?void 0:t.read)==null?void 0:p.selectedFieldMappings)||{},i=Object.keys(o),s=((m=t==null?void 0:t.read)==null?void 0:m.requiredMapFields)||[],a=((w=t==null?void 0:t.read)==null?void 0:w.optionalMapFields)||[],l=e&&r?Object.values(r[e]||{}).flat().filter(v=>!v.fieldName):[],u=s.concat(l,a).map(v=>v.mapToName),d=new Set(u),f=tv(i,d);y.useEffect(()=>{e&&f.length&&ui(e,n,f.map(v=>({field:v,value:null})))},[e,n,f])}function hn(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function he(){return he=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},he.apply(null,arguments)}function vs(e,t){return vs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},vs(e,t)}function rv(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,vs(e,t)}var ws={exports:{}},ki={exports:{}},be={};/** @license React v16.13.1
|
|
10
|
+
*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var i="",s=0;s<arguments.length;s++){var a=arguments[s];a&&(i=o(i,r(a)))}return i}function r(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return n.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var s="";for(var a in i)t.call(i,a)&&i[a]&&(s=o(s,a));return s}function o(i,s){return s?i?i+" "+s:i+s:i}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(au);var gv=au.exports;const Ft=Ks(gv),yv="_button_kwfiu_1",vv="_buttonError_kwfiu_28",wv="_danger_kwfiu_42",Iv="_ghost_kwfiu_47",Do={button:yv,buttonError:vv,danger:wv,ghost:Iv};function ze({className:e,style:t,type:n,children:r,variant:o,...i}){const s=Ft(Do.button,{[Do.danger]:o==="danger",[Do.ghost]:o==="ghost",[e||""]:!!e});return c.jsx("button",{type:n,className:s,style:t,...i,children:r})}const bv=()=>{const e=dt(),t=Et();return Jr({mutationKey:["deleteConnection"],mutationFn:async({projectIdOrName:n,connectionId:r})=>(await e()).connectionApi.deleteConnection({projectIdOrName:n,connectionId:r}),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","connections"]})},onError:n=>{console.error("Error deleting connection.",{error:n})}})};function cu({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={},onDisconnectSuccess:r,resetComponent:o,onDisconnectError:i}){const{projectId:s}=Te(),{selectedConnection:a}=Qt(),l=bv(),[u,d]=y.useState(!1),f=!s||!a||!a.id||u,p=async()=>{f||(d(!0),console.warn("deleting connection",{projectId:s,connectionId:a==null?void 0:a.id}),l.mutate({projectIdOrName:s,connectionId:a==null?void 0:a.id},{onSuccess:()=>{console.warn("successfully deleted connection:",a==null?void 0:a.id),r==null||r(a),o()},onError:v=>{Le(v,i)},onSettled:()=>d(!1)}))},m=u?"Disconnecting...":e;return c.jsx(ze,{type:"button",onClick:p,disabled:f,variant:t,style:n,children:m})}const lu=y.createContext({hydratedRevision:null,loading:!1,readAction:void 0,writeObjects:[]}),Gr=()=>{const e=y.useContext(lu);if(!e)throw new Error("useHydratedRevision must be used within a HydratedRevisionProvider");return e},xv=()=>{var u;const e=Et(),t=dt(),{selectedConnection:n,isConnectionsLoading:r}=Qt(),{projectIdOrName:o}=Te(),{integrationId:i,integrationObj:s}=rt(),a=n==null?void 0:n.id,l=(u=s==null?void 0:s.latestRevision)==null?void 0:u.id;return y.useEffect(()=>{a||e.invalidateQueries({queryKey:["amp","hydratedRevision"]})},[a,e]),vn({queryKey:["amp","hydratedRevision",o,i,l,a],queryFn:async()=>{if(!o)throw new Error("projectIdOrName is required");if(!i)throw new Error("integrationId is required");if(!l)throw new Error("revisionId is required");if(!a)throw new Error("connectionId is required");return(await t()).revisionApi.getHydratedRevision({projectIdOrName:o,integrationId:i,revisionId:l,connectionId:a})},retry:3,enabled:!!o&&!!i&&!!l&&!!a&&!r})};function _v({children:e,resetComponent:t}){const{integrationId:n,integrationObj:r}=rt(),{isError:o,removeError:i,setError:s}=Dt(),a=(r==null?void 0:r.name)||n,[l,u]=y.useState(null),[d,f]=y.useState(null),{data:p,isLoading:m,isError:w,error:v}=xv();y.useEffect(()=>{w?(s(ue.HYDRATED_REVISION,a),Le(v,u)):(i(ue.HYDRATED_REVISION,a),u(null),f(null))},[w,a,s,i,v,u]);const h=y.useMemo(()=>{var g,b,_;return{hydratedRevision:p||null,loading:m,readAction:(g=p==null?void 0:p.content)==null?void 0:g.read,writeObjects:((_=(b=p==null?void 0:p.content)==null?void 0:b.write)==null?void 0:_.objects)||[]}},[p,m]);if(m)return c.jsx(zr,{});const x=(r==null?void 0:r.provider)||"provider";if(o(ue.HYDRATED_REVISION,a)){const g=(r==null?void 0:r.name)||n||"unknown integration",b=`${l?`: ${l}`:`Error retrieving objects from ${x} or integration details for ${g}`}`;return c.jsx(Jt,{message:b,children:c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",paddingTop:"1rem"},children:[d&&c.jsx(jl,{message:d}),c.jsx(cu,{buttonText:"Try again",resetComponent:t,buttonVariant:"danger",onDisconnectError:_=>f(_)})]})})}return c.jsx(lu.Provider,{value:h,children:e})}const uu=y.createContext(null);function du(){const e=y.useContext(uu);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}const fu=y.createContext(()=>{});function Cv(){const e=y.useContext(fu);if(!e)throw new Error("useSetNextTabIndex must be used within a NextTabIndexProvider");return{onNextIncompleteTab:e}}var pu=Symbol.for("immer-nothing"),Xa=Symbol.for("immer-draftable"),_t=Symbol.for("immer-state"),Ov=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=Ov[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 jr=Object.getPrototypeOf;function Lr(e){return!!e&&!!e[_t]}function fr(e){var t;return e?hu(e)||Array.isArray(e)||!!e[Xa]||!!((t=e.constructor)!=null&&t[Xa])||ho(e)||mo(e):!1}var Ev=Object.prototype.constructor.toString();function hu(e){if(!e||typeof e!="object")return!1;const t=jr(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)===Ev}function Yi(e,t){po(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function po(e){const t=e[_t];return t?t.type_:Array.isArray(e)?1:ho(e)?2:mo(e)?3:0}function fs(e,t){return po(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function mu(e,t,n){const r=po(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function Sv(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function ho(e){return e instanceof Map}function mo(e){return e instanceof Set}function Xn(e){return e.copy_||e.base_}function ps(e,t){if(ho(e))return new Map(e);if(mo(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=hu(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(jr(e),r)}else{const r=jr(e);if(r!==null&&n)return{...e};const o=Object.create(r);return Object.assign(o,e)}}function Vs(e,t=!1){return go(e)||Lr(e)||!fr(e)||(po(e)>1&&(e.set=e.add=e.clear=e.delete=Nv),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>Vs(r,!0))),e}function Nv(){yt(2)}function go(e){return Object.isFrozen(e)}var Tv={};function pr(e){const t=Tv[e];return t||yt(0,e),t}var ci;function gu(){return ci}function Rv(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ya(e,t){t&&(pr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function hs(e){ms(e),e.drafts_.forEach(Av),e.drafts_=null}function ms(e){e===ci&&(ci=e.parent_)}function Za(e){return ci=Rv(ci,e)}function Av(e){const t=e[_t];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ec(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[_t].modified_&&(hs(t),yt(4)),fr(e)&&(e=Zi(t,e),t.parent_||eo(t,e)),t.patches_&&pr("Patches").generateReplacementPatches_(n[_t].base_,e,t.patches_,t.inversePatches_)):e=Zi(t,n,[]),hs(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==pu?e:void 0}function Zi(e,t,n){if(go(t))return t;const r=t[_t];if(!r)return Yi(t,(o,i)=>tc(e,r,t,o,i,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return eo(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),Yi(i,(a,l)=>tc(e,r,o,a,l,n,s)),eo(e,o,!1),n&&e.patches_&&pr("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function tc(e,t,n,r,o,i,s){if(process.env.NODE_ENV!=="production"&&o===n&&yt(5),Lr(o)){const a=i&&t&&t.type_!==3&&!fs(t.assigned_,r)?i.concat(r):void 0,l=Zi(e,o,a);if(mu(n,r,l),Lr(l))e.canAutoFreeze_=!1;else return}else s&&n.add(o);if(fr(o)&&!go(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Zi(e,o),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&eo(e,o)}}function eo(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Vs(t,n)}function Pv(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:gu(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,i=Us;n&&(o=[r],i=li);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,a}var Us={get(e,t){if(t===_t)return e;const n=Xn(e);if(!fs(n,t))return Fv(e,n,t);const r=n[t];return e.finalized_||!fr(r)?r:r===Mo(e.base_,t)?(ko(e),e.copy_[t]=ys(r,e)):r},has(e,t){return t in Xn(e)},ownKeys(e){return Reflect.ownKeys(Xn(e))},set(e,t,n){const r=yu(Xn(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const o=Mo(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(Sv(n,o)&&(n!==void 0||fs(e.base_,t)))return!0;ko(e),gs(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 Mo(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,ko(e),gs(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 jr(e.base_)},setPrototypeOf(){yt(12)}},li={};Yi(Us,(e,t)=>{li[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});li.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&yt(13),li.set.call(this,e,t,void 0)};li.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&yt(14),Us.set.call(this,e[0],t,n,e[0])};function Mo(e,t){const n=e[_t];return(n?Xn(n):e)[t]}function Fv(e,t,n){var o;const r=yu(t,n);return r?"value"in r?r.value:(o=r.get)==null?void 0:o.call(e.draft_):void 0}function yu(e,t){if(!(t in e))return;let n=jr(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=jr(n)}}function gs(e){e.modified_||(e.modified_=!0,e.parent_&&gs(e.parent_))}function ko(e){e.copy_||(e.copy_=ps(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Dv=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(l=i,...u){return s.produce(l,d=>n.call(this,d,...u))}}typeof n!="function"&&yt(6),r!==void 0&&typeof r!="function"&&yt(7);let o;if(fr(t)){const i=Za(this),s=ys(t,void 0);let a=!0;try{o=n(s),a=!1}finally{a?hs(i):ms(i)}return Ya(i,r),ec(o,i)}else if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===pu&&(o=void 0),this.autoFreeze_&&Vs(o,!0),r){const i=[],s=[];pr("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,l=>t(l,...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){fr(e)||yt(8),Lr(e)&&(e=Mv(e));const t=Za(this),n=ys(e,void 0);return n[_t].isManual_=!0,ms(t),n}finishDraft(e,t){const n=e&&e[_t];(!n||!n.isManual_)&&yt(9);const{scope_:r}=n;return Ya(r,t),ec(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=pr("Patches").applyPatches_;return Lr(e)?r(e,t):this.produce(e,o=>r(o,t))}};function ys(e,t){const n=ho(e)?pr("MapSet").proxyMap_(e,t):mo(e)?pr("MapSet").proxySet_(e,t):Pv(e,t);return(t?t.scope_:gu()).drafts_.push(n),n}function Mv(e){return Lr(e)||yt(10,e),vu(e)}function vu(e){if(!fr(e)||go(e))return e;const t=e[_t];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=ps(e,t.scope_.immer_.useStrictShallowCopy_)}else n=ps(e,!0);return Yi(n,(r,o)=>{mu(n,r,vu(o))}),t&&(t.finalized_=!1),n}var Ct=new Dv,ei=Ct.produce;Ct.produceWithPatches.bind(Ct);Ct.setAutoFreeze.bind(Ct);Ct.setUseStrictShallowCopy.bind(Ct);Ct.applyPatches.bind(Ct);Ct.createDraft.bind(Ct);Ct.finishDraft.bind(Ct);const wu=y.createContext(void 0),kv={};function $s(){const e=y.useContext(wu);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function jv({children:e}){const{installation:t}=rt(),{hydratedRevision:n,loading:r}=Gr(),[o,i]=y.useState(kv),s=t==null?void 0:t.config;y.useEffect(()=>{n!=null&&n.content&&!r&&s&&!(Object.entries(o).length>0)&&cv(n,s,i)},[n,r,s,o]);const a=y.useCallback((m,w)=>{i(v=>ei(v,h=>{h[m]=ei(h[m],w)}))},[i]),l=y.useCallback((m,w)=>{i(v=>ei(v,h=>{h[m]=w}))},[i]),u=y.useCallback(()=>{i(ei(m=>{const w=m.other.write;w&&(w.isWriteModified=!1)}))},[i]),d=y.useCallback(m=>{i(ei(w=>{var h;const v=(h=w[m])==null?void 0:h.read;v&&(v.isOptionalFieldsModified=!1,v.isRequiredMapFieldsModified=!1,v.isValueMappingsModified=!1)}))},[i]),f=y.useCallback(m=>{m===dr?u():d(m)},[d,u]),p=y.useMemo(()=>({objectConfigurationsState:o,setObjectConfigurationsState:i,setConfigureState:a,resetConfigureState:l,resetPendingConfigurationState:f}),[o,l,f,a]);return c.jsx(wu.Provider,{value:p,children:e})}const Xt=()=>{const{appName:e}=Te(),{objectConfigurationsState:t,setConfigureState:n}=$s(),{selectedObjectName:r}=du(),o=iu(r||"",t);return{appName:e,configureState:o,setConfigureState:n,selectedObjectName:r}};function Lv(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=!Yl(o,n);e.read.isRequiredMapFieldsModified=s}}function ui(e,t,n){t(e,r=>Lv(r,n))}const Kv=(e,t)=>e.filter(n=>!t.has(n));function Vv(){var p,m,w;const{selectedObjectName:e,configureState:t,setConfigureState:n}=Xt(),{fieldMapping:r}=rt(),o=((p=t==null?void 0:t.read)==null?void 0:p.selectedFieldMappings)||{},i=Object.keys(o),s=((m=t==null?void 0:t.read)==null?void 0:m.requiredMapFields)||[],a=((w=t==null?void 0:t.read)==null?void 0:w.optionalMapFields)||[],l=e&&r?Object.values(r[e]||{}).flat().filter(v=>!v.fieldName):[],u=s.concat(l,a).map(v=>v.mapToName),d=new Set(u),f=Kv(i,d);y.useEffect(()=>{e&&f.length&&ui(e,n,f.map(v=>({field:v,value:null})))},[e,n,f])}function mn(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function he(){return he=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},he.apply(null,arguments)}function vs(e,t){return vs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},vs(e,t)}function Uv(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,vs(e,t)}var ws={exports:{}},ji={exports:{}},be={};/** @license React v16.13.1
|
|
11
11
|
* react-is.production.min.js
|
|
12
12
|
*
|
|
13
13
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var nc;function $v(){if(nc)return be;nc=1;var e=typeof Symbol=="function"&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,s=e?Symbol.for("react.provider"):60109,a=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,u=e?Symbol.for("react.concurrent_mode"):60111,d=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,p=e?Symbol.for("react.suspense_list"):60120,m=e?Symbol.for("react.memo"):60115,w=e?Symbol.for("react.lazy"):60116,v=e?Symbol.for("react.block"):60121,h=e?Symbol.for("react.fundamental"):60117,x=e?Symbol.for("react.responder"):60118,g=e?Symbol.for("react.scope"):60119;function b(C){if(typeof C=="object"&&C!==null){var R=C.$$typeof;switch(R){case t:switch(C=C.type,C){case l:case u:case r:case i:case o:case f:return C;default:switch(C=C&&C.$$typeof,C){case a:case d:case w:case m:case s:return C;default:return R}}case n:return R}}}function _(C){return b(C)===u}return be.AsyncMode=l,be.ConcurrentMode=u,be.ContextConsumer=a,be.ContextProvider=s,be.Element=t,be.ForwardRef=d,be.Fragment=r,be.Lazy=w,be.Memo=m,be.Portal=n,be.Profiler=i,be.StrictMode=o,be.Suspense=f,be.isAsyncMode=function(C){return _(C)||b(C)===l},be.isConcurrentMode=_,be.isContextConsumer=function(C){return b(C)===a},be.isContextProvider=function(C){return b(C)===s},be.isElement=function(C){return typeof C=="object"&&C!==null&&C.$$typeof===t},be.isForwardRef=function(C){return b(C)===d},be.isFragment=function(C){return b(C)===r},be.isLazy=function(C){return b(C)===w},be.isMemo=function(C){return b(C)===m},be.isPortal=function(C){return b(C)===n},be.isProfiler=function(C){return b(C)===i},be.isStrictMode=function(C){return b(C)===o},be.isSuspense=function(C){return b(C)===f},be.isValidElementType=function(C){return typeof C=="string"||typeof C=="function"||C===r||C===u||C===i||C===o||C===f||C===p||typeof C=="object"&&C!==null&&(C.$$typeof===w||C.$$typeof===m||C.$$typeof===s||C.$$typeof===a||C.$$typeof===d||C.$$typeof===h||C.$$typeof===x||C.$$typeof===g||C.$$typeof===v)},be.typeOf=b,be}var xe={};/** @license React v16.13.1
|
|
18
18
|
* react-is.development.js
|
|
19
19
|
*
|
|
20
20
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
21
21
|
*
|
|
22
22
|
* This source code is licensed under the MIT license found in the
|
|
23
23
|
* LICENSE file in the root directory of this source tree.
|
|
24
|
-
*/var
|
|
24
|
+
*/var rc;function qv(){return rc||(rc=1,process.env.NODE_ENV!=="production"&&function(){var e=typeof Symbol=="function"&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,s=e?Symbol.for("react.provider"):60109,a=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,u=e?Symbol.for("react.concurrent_mode"):60111,d=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,p=e?Symbol.for("react.suspense_list"):60120,m=e?Symbol.for("react.memo"):60115,w=e?Symbol.for("react.lazy"):60116,v=e?Symbol.for("react.block"):60121,h=e?Symbol.for("react.fundamental"):60117,x=e?Symbol.for("react.responder"):60118,g=e?Symbol.for("react.scope"):60119;function b(M){return typeof M=="string"||typeof M=="function"||M===r||M===u||M===i||M===o||M===f||M===p||typeof M=="object"&&M!==null&&(M.$$typeof===w||M.$$typeof===m||M.$$typeof===s||M.$$typeof===a||M.$$typeof===d||M.$$typeof===h||M.$$typeof===x||M.$$typeof===g||M.$$typeof===v)}function _(M){if(typeof M=="object"&&M!==null){var ve=M.$$typeof;switch(ve){case t:var H=M.type;switch(H){case l:case u:case r:case i:case o:case f:return H;default:var Ee=H&&H.$$typeof;switch(Ee){case a:case d:case w:case m:case s:return Ee;default:return ve}}case n:return ve}}}var C=l,R=u,N=a,T=s,F=t,$=d,G=r,z=w,ne=m,B=n,ce=i,se=o,te=f,ge=!1;function we(M){return ge||(ge=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),A(M)||_(M)===l}function A(M){return _(M)===u}function k(M){return _(M)===a}function U(M){return _(M)===s}function L(M){return typeof M=="object"&&M!==null&&M.$$typeof===t}function j(M){return _(M)===d}function D(M){return _(M)===r}function Y(M){return _(M)===w}function Z(M){return _(M)===m}function q(M){return _(M)===n}function ee(M){return _(M)===i}function Q(M){return _(M)===o}function de(M){return _(M)===f}xe.AsyncMode=C,xe.ConcurrentMode=R,xe.ContextConsumer=N,xe.ContextProvider=T,xe.Element=F,xe.ForwardRef=$,xe.Fragment=G,xe.Lazy=z,xe.Memo=ne,xe.Portal=B,xe.Profiler=ce,xe.StrictMode=se,xe.Suspense=te,xe.isAsyncMode=we,xe.isConcurrentMode=A,xe.isContextConsumer=k,xe.isContextProvider=U,xe.isElement=L,xe.isForwardRef=j,xe.isFragment=D,xe.isLazy=Y,xe.isMemo=Z,xe.isPortal=q,xe.isProfiler=ee,xe.isStrictMode=Q,xe.isSuspense=de,xe.isValidElementType=b,xe.typeOf=_}()),xe}var ic;function Iu(){return ic||(ic=1,process.env.NODE_ENV==="production"?ji.exports=$v():ji.exports=qv()),ji.exports}/*
|
|
25
25
|
object-assign
|
|
26
26
|
(c) Sindre Sorhus
|
|
27
27
|
@license MIT
|
|
28
|
-
*/var
|
|
29
|
-
Valid keys: `+JSON.stringify(Object.keys(A),null," "));var M=de(Z,Q,
|
|
28
|
+
*/var jo,oc;function Hv(){if(oc)return jo;oc=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function r(i){if(i==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(i)}function o(){try{if(!Object.assign)return!1;var i=new String("abc");if(i[5]="de",Object.getOwnPropertyNames(i)[0]==="5")return!1;for(var s={},a=0;a<10;a++)s["_"+String.fromCharCode(a)]=a;var l=Object.getOwnPropertyNames(s).map(function(d){return s[d]});if(l.join("")!=="0123456789")return!1;var u={};return"abcdefghijklmnopqrst".split("").forEach(function(d){u[d]=d}),Object.keys(Object.assign({},u)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return jo=o()?Object.assign:function(i,s){for(var a,l=r(i),u,d=1;d<arguments.length;d++){a=Object(arguments[d]);for(var f in a)t.call(a,f)&&(l[f]=a[f]);if(e){u=e(a);for(var p=0;p<u.length;p++)n.call(a,u[p])&&(l[u[p]]=a[u[p]])}}return l},jo}var Lo,sc;function qs(){if(sc)return Lo;sc=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Lo=e,Lo}var Ko,ac;function bu(){return ac||(ac=1,Ko=Function.call.bind(Object.prototype.hasOwnProperty)),Ko}var Vo,cc;function Bv(){if(cc)return Vo;cc=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var t=qs(),n={},r=bu();e=function(i){var s="Warning: "+i;typeof console<"u"&&console.error(s);try{throw new Error(s)}catch{}}}function o(i,s,a,l,u){if(process.env.NODE_ENV!=="production"){for(var d in i)if(r(i,d)){var f;try{if(typeof i[d]!="function"){var p=Error((l||"React class")+": "+a+" type `"+d+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[d]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw p.name="Invariant Violation",p}f=i[d](s,d,l,a,null,t)}catch(w){f=w}if(f&&!(f instanceof Error)&&e((l||"React class")+": type specification of "+a+" `"+d+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof f+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),f instanceof Error&&!(f.message in n)){n[f.message]=!0;var m=u?u():"";e("Failed "+a+" type: "+f.message+(m??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Vo=o,Vo}var Uo,lc;function Jv(){if(lc)return Uo;lc=1;var e=Iu(),t=Hv(),n=qs(),r=bu(),o=Bv(),i=function(){};process.env.NODE_ENV!=="production"&&(i=function(a){var l="Warning: "+a;typeof console<"u"&&console.error(l);try{throw new Error(l)}catch{}});function s(){return null}return Uo=function(a,l){var u=typeof Symbol=="function"&&Symbol.iterator,d="@@iterator";function f(A){var k=A&&(u&&A[u]||A[d]);if(typeof k=="function")return k}var p="<<anonymous>>",m={array:x("array"),bigint:x("bigint"),bool:x("boolean"),func:x("function"),number:x("number"),object:x("object"),string:x("string"),symbol:x("symbol"),any:g(),arrayOf:b,element:_(),elementType:C(),instanceOf:R,node:$(),objectOf:T,oneOf:N,oneOfType:F,shape:z,exact:ne};function w(A,k){return A===k?A!==0||1/A===1/k:A!==A&&k!==k}function v(A,k){this.message=A,this.data=k&&typeof k=="object"?k:{},this.stack=""}v.prototype=Error.prototype;function h(A){if(process.env.NODE_ENV!=="production")var k={},U=0;function L(D,Y,Z,q,ee,Q,de){if(q=q||p,Q=Q||Z,de!==n){if(l){var M=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw M.name="Invariant Violation",M}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var ve=q+":"+Z;!k[ve]&&U<3&&(i("You are manually calling a React.PropTypes validation function for the `"+Q+"` prop on `"+q+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),k[ve]=!0,U++)}}return Y[Z]==null?D?Y[Z]===null?new v("The "+ee+" `"+Q+"` is marked as required "+("in `"+q+"`, but its value is `null`.")):new v("The "+ee+" `"+Q+"` is marked as required in "+("`"+q+"`, but its value is `undefined`.")):null:A(Y,Z,q,ee,Q)}var j=L.bind(null,!1);return j.isRequired=L.bind(null,!0),j}function x(A){function k(U,L,j,D,Y,Z){var q=U[L],ee=se(q);if(ee!==A){var Q=te(q);return new v("Invalid "+D+" `"+Y+"` of type "+("`"+Q+"` supplied to `"+j+"`, expected ")+("`"+A+"`."),{expectedType:A})}return null}return h(k)}function g(){return h(s)}function b(A){function k(U,L,j,D,Y){if(typeof A!="function")return new v("Property `"+Y+"` of component `"+j+"` has invalid PropType notation inside arrayOf.");var Z=U[L];if(!Array.isArray(Z)){var q=se(Z);return new v("Invalid "+D+" `"+Y+"` of type "+("`"+q+"` supplied to `"+j+"`, expected an array."))}for(var ee=0;ee<Z.length;ee++){var Q=A(Z,ee,j,D,Y+"["+ee+"]",n);if(Q instanceof Error)return Q}return null}return h(k)}function _(){function A(k,U,L,j,D){var Y=k[U];if(!a(Y)){var Z=se(Y);return new v("Invalid "+j+" `"+D+"` of type "+("`"+Z+"` supplied to `"+L+"`, expected a single ReactElement."))}return null}return h(A)}function C(){function A(k,U,L,j,D){var Y=k[U];if(!e.isValidElementType(Y)){var Z=se(Y);return new v("Invalid "+j+" `"+D+"` of type "+("`"+Z+"` supplied to `"+L+"`, expected a single ReactElement type."))}return null}return h(A)}function R(A){function k(U,L,j,D,Y){if(!(U[L]instanceof A)){var Z=A.name||p,q=we(U[L]);return new v("Invalid "+D+" `"+Y+"` of type "+("`"+q+"` supplied to `"+j+"`, expected ")+("instance of `"+Z+"`."))}return null}return h(k)}function N(A){if(!Array.isArray(A))return process.env.NODE_ENV!=="production"&&(arguments.length>1?i("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):i("Invalid argument supplied to oneOf, expected an array.")),s;function k(U,L,j,D,Y){for(var Z=U[L],q=0;q<A.length;q++)if(w(Z,A[q]))return null;var ee=JSON.stringify(A,function(de,M){var ve=te(M);return ve==="symbol"?String(M):M});return new v("Invalid "+D+" `"+Y+"` of value `"+String(Z)+"` "+("supplied to `"+j+"`, expected one of "+ee+"."))}return h(k)}function T(A){function k(U,L,j,D,Y){if(typeof A!="function")return new v("Property `"+Y+"` of component `"+j+"` has invalid PropType notation inside objectOf.");var Z=U[L],q=se(Z);if(q!=="object")return new v("Invalid "+D+" `"+Y+"` of type "+("`"+q+"` supplied to `"+j+"`, expected an object."));for(var ee in Z)if(r(Z,ee)){var Q=A(Z,ee,j,D,Y+"."+ee,n);if(Q instanceof Error)return Q}return null}return h(k)}function F(A){if(!Array.isArray(A))return process.env.NODE_ENV!=="production"&&i("Invalid argument supplied to oneOfType, expected an instance of array."),s;for(var k=0;k<A.length;k++){var U=A[k];if(typeof U!="function")return i("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+ge(U)+" at index "+k+"."),s}function L(j,D,Y,Z,q){for(var ee=[],Q=0;Q<A.length;Q++){var de=A[Q],M=de(j,D,Y,Z,q,n);if(M==null)return null;M.data&&r(M.data,"expectedType")&&ee.push(M.data.expectedType)}var ve=ee.length>0?", expected one of type ["+ee.join(", ")+"]":"";return new v("Invalid "+Z+" `"+q+"` supplied to "+("`"+Y+"`"+ve+"."))}return h(L)}function $(){function A(k,U,L,j,D){return B(k[U])?null:new v("Invalid "+j+" `"+D+"` supplied to "+("`"+L+"`, expected a ReactNode."))}return h(A)}function G(A,k,U,L,j){return new v((A||"React class")+": "+k+" type `"+U+"."+L+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+j+"`.")}function z(A){function k(U,L,j,D,Y){var Z=U[L],q=se(Z);if(q!=="object")return new v("Invalid "+D+" `"+Y+"` of type `"+q+"` "+("supplied to `"+j+"`, expected `object`."));for(var ee in A){var Q=A[ee];if(typeof Q!="function")return G(j,D,Y,ee,te(Q));var de=Q(Z,ee,j,D,Y+"."+ee,n);if(de)return de}return null}return h(k)}function ne(A){function k(U,L,j,D,Y){var Z=U[L],q=se(Z);if(q!=="object")return new v("Invalid "+D+" `"+Y+"` of type `"+q+"` "+("supplied to `"+j+"`, expected `object`."));var ee=t({},U[L],A);for(var Q in ee){var de=A[Q];if(r(A,Q)&&typeof de!="function")return G(j,D,Y,Q,te(de));if(!de)return new v("Invalid "+D+" `"+Y+"` key `"+Q+"` supplied to `"+j+"`.\nBad object: "+JSON.stringify(U[L],null," ")+`
|
|
29
|
+
Valid keys: `+JSON.stringify(Object.keys(A),null," "));var M=de(Z,Q,j,D,Y+"."+Q,n);if(M)return M}return null}return h(k)}function B(A){switch(typeof A){case"number":case"string":case"undefined":return!0;case"boolean":return!A;case"object":if(Array.isArray(A))return A.every(B);if(A===null||a(A))return!0;var k=f(A);if(k){var U=k.call(A),L;if(k!==A.entries){for(;!(L=U.next()).done;)if(!B(L.value))return!1}else for(;!(L=U.next()).done;){var j=L.value;if(j&&!B(j[1]))return!1}}else return!1;return!0;default:return!1}}function ce(A,k){return A==="symbol"?!0:k?k["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&k instanceof Symbol:!1}function se(A){var k=typeof A;return Array.isArray(A)?"array":A instanceof RegExp?"object":ce(k,A)?"symbol":k}function te(A){if(typeof A>"u"||A===null)return""+A;var k=se(A);if(k==="object"){if(A instanceof Date)return"date";if(A instanceof RegExp)return"regexp"}return k}function ge(A){var k=te(A);switch(k){case"array":case"object":return"an "+k;case"boolean":case"date":case"regexp":return"a "+k;default:return k}}function we(A){return!A.constructor||!A.constructor.name?p:A.constructor.name}return m.checkPropTypes=o,m.resetWarningCache=o.resetWarningCache,m.PropTypes=m,m},Uo}var $o,uc;function Wv(){if(uc)return $o;uc=1;var e=qs();function t(){}function n(){}return n.resetWarningCache=t,$o=function(){function r(s,a,l,u,d,f){if(f!==e){var p=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw p.name="Invariant Violation",p}}r.isRequired=r;function o(){return r}var i={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return i.PropTypes=i,i},$o}if(process.env.NODE_ENV!=="production"){var zv=Iu(),Gv=!0;ws.exports=Jv()(zv.isElement,Gv)}else ws.exports=Wv()();var Qv=ws.exports;const K=Ks(Qv);var Is={exports:{}},_e={};/**
|
|
30
30
|
* @license React
|
|
31
31
|
* react-is.production.min.js
|
|
32
32
|
*
|
|
@@ -34,7 +34,7 @@ Valid keys: `+JSON.stringify(Object.keys(A),null," "));var M=de(Z,Q,k,F,Y+"."+Q
|
|
|
34
34
|
*
|
|
35
35
|
* This source code is licensed under the MIT license found in the
|
|
36
36
|
* LICENSE file in the root directory of this source tree.
|
|
37
|
-
*/var
|
|
37
|
+
*/var dc;function Xv(){if(dc)return _e;dc=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),s=Symbol.for("react.context"),a=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),w;w=Symbol.for("react.module.reference");function v(h){if(typeof h=="object"&&h!==null){var x=h.$$typeof;switch(x){case e:switch(h=h.type,h){case n:case o:case r:case u:case d:return h;default:switch(h=h&&h.$$typeof,h){case a:case s:case l:case p:case f:case i:return h;default:return x}}case t:return x}}}return _e.ContextConsumer=s,_e.ContextProvider=i,_e.Element=e,_e.ForwardRef=l,_e.Fragment=n,_e.Lazy=p,_e.Memo=f,_e.Portal=t,_e.Profiler=o,_e.StrictMode=r,_e.Suspense=u,_e.SuspenseList=d,_e.isAsyncMode=function(){return!1},_e.isConcurrentMode=function(){return!1},_e.isContextConsumer=function(h){return v(h)===s},_e.isContextProvider=function(h){return v(h)===i},_e.isElement=function(h){return typeof h=="object"&&h!==null&&h.$$typeof===e},_e.isForwardRef=function(h){return v(h)===l},_e.isFragment=function(h){return v(h)===n},_e.isLazy=function(h){return v(h)===p},_e.isMemo=function(h){return v(h)===f},_e.isPortal=function(h){return v(h)===t},_e.isProfiler=function(h){return v(h)===o},_e.isStrictMode=function(h){return v(h)===r},_e.isSuspense=function(h){return v(h)===u},_e.isSuspenseList=function(h){return v(h)===d},_e.isValidElementType=function(h){return typeof h=="string"||typeof h=="function"||h===n||h===o||h===r||h===u||h===d||h===m||typeof h=="object"&&h!==null&&(h.$$typeof===p||h.$$typeof===f||h.$$typeof===i||h.$$typeof===s||h.$$typeof===l||h.$$typeof===w||h.getModuleId!==void 0)},_e.typeOf=v,_e}var Ce={};/**
|
|
38
38
|
* @license React
|
|
39
39
|
* react-is.development.js
|
|
40
40
|
*
|
|
@@ -42,10 +42,10 @@ Valid keys: `+JSON.stringify(Object.keys(A),null," "));var M=de(Z,Q,k,F,Y+"."+Q
|
|
|
42
42
|
*
|
|
43
43
|
* This source code is licensed under the MIT license found in the
|
|
44
44
|
* LICENSE file in the root directory of this source tree.
|
|
45
|
-
*/var dc;function hv(){return dc||(dc=1,process.env.NODE_ENV!=="production"&&function(){var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),s=Symbol.for("react.context"),a=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),w=!1,v=!1,h=!1,x=!1,g=!1,b;b=Symbol.for("react.module.reference");function _(H){return!!(typeof H=="string"||typeof H=="function"||H===n||H===o||g||H===r||H===u||H===d||x||H===m||w||v||h||typeof H=="object"&&H!==null&&(H.$$typeof===p||H.$$typeof===f||H.$$typeof===i||H.$$typeof===s||H.$$typeof===l||H.$$typeof===b||H.getModuleId!==void 0))}function C(H){if(typeof H=="object"&&H!==null){var Ee=H.$$typeof;switch(Ee){case e:var Ve=H.type;switch(Ve){case n:case o:case r:case u:case d:return Ve;default:var Xe=Ve&&Ve.$$typeof;switch(Xe){case a:case s:case l:case p:case f:case i:return Xe;default:return Ee}}case t:return Ee}}}var T=s,S=i,N=e,D=l,U=n,G=p,z=f,ne=t,B=o,ce=r,se=u,te=d,ge=!1,we=!1;function A(H){return ge||(ge=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")),!1}function j(H){return we||(we=!0,console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")),!1}function $(H){return C(H)===s}function L(H){return C(H)===i}function k(H){return typeof H=="object"&&H!==null&&H.$$typeof===e}function F(H){return C(H)===l}function Y(H){return C(H)===n}function Z(H){return C(H)===p}function q(H){return C(H)===f}function ee(H){return C(H)===t}function Q(H){return C(H)===o}function de(H){return C(H)===r}function M(H){return C(H)===u}function ve(H){return C(H)===d}Ce.ContextConsumer=T,Ce.ContextProvider=S,Ce.Element=N,Ce.ForwardRef=D,Ce.Fragment=U,Ce.Lazy=G,Ce.Memo=z,Ce.Portal=ne,Ce.Profiler=B,Ce.StrictMode=ce,Ce.Suspense=se,Ce.SuspenseList=te,Ce.isAsyncMode=A,Ce.isConcurrentMode=j,Ce.isContextConsumer=$,Ce.isContextProvider=L,Ce.isElement=k,Ce.isForwardRef=F,Ce.isFragment=Y,Ce.isLazy=Z,Ce.isMemo=q,Ce.isPortal=ee,Ce.isProfiler=Q,Ce.isStrictMode=de,Ce.isSuspense=M,Ce.isSuspenseList=ve,Ce.isValidElementType=_,Ce.typeOf=C}()),Ce}process.env.NODE_ENV==="production"?Is.exports=pv():Is.exports=hv();var fc=Is.exports;const pc=e=>typeof e=="object"&&e!=null&&e.nodeType===1,hc=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",qo=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return hc(n.overflowY,t)||hc(n.overflowX,t)||(r=>{const o=(i=>{if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}})(r);return!!o&&(o.clientHeight<r.scrollHeight||o.clientWidth<r.scrollWidth)})(e)}return!1},Li=(e,t,n,r,o,i,s,a)=>i<e&&s>t||i>e&&s<t?0:i<=e&&a<=n||s>=t&&a>=n?i-e-r:s>t&&a<n||i<e&&a>n?s-t+o:0,mv=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},gv=(e,t)=>{var n,r,o,i;if(typeof document>"u")return[];const{scrollMode:s,block:a,inline:l,boundary:u,skipOverflowHiddenElements:d}=t,f=typeof u=="function"?u:se=>se!==u;if(!pc(e))throw new TypeError("Invalid target");const p=document.scrollingElement||document.documentElement,m=[];let w=e;for(;pc(w)&&f(w);){if(w=mv(w),w===p){m.push(w);break}w!=null&&w===document.body&&qo(w)&&!qo(document.documentElement)||w!=null&&qo(w,d)&&m.push(w)}const v=(r=(n=window.visualViewport)==null?void 0:n.width)!=null?r:innerWidth,h=(i=(o=window.visualViewport)==null?void 0:o.height)!=null?i:innerHeight,{scrollX:x,scrollY:g}=window,{height:b,width:_,top:C,right:T,bottom:S,left:N}=e.getBoundingClientRect(),{top:D,right:U,bottom:G,left:z}=(se=>{const te=window.getComputedStyle(se);return{top:parseFloat(te.scrollMarginTop)||0,right:parseFloat(te.scrollMarginRight)||0,bottom:parseFloat(te.scrollMarginBottom)||0,left:parseFloat(te.scrollMarginLeft)||0}})(e);let ne=a==="start"||a==="nearest"?C-D:a==="end"?S+G:C+b/2-D+G,B=l==="center"?N+_/2-z+U:l==="end"?T+U:N-z;const ce=[];for(let se=0;se<m.length;se++){const te=m[se],{height:ge,width:we,top:A,right:j,bottom:$,left:L}=te.getBoundingClientRect();if(s==="if-needed"&&C>=0&&N>=0&&S<=h&&T<=v&&C>=A&&S<=$&&N>=L&&T<=j)return ce;const k=getComputedStyle(te),F=parseInt(k.borderLeftWidth,10),Y=parseInt(k.borderTopWidth,10),Z=parseInt(k.borderRightWidth,10),q=parseInt(k.borderBottomWidth,10);let ee=0,Q=0;const de="offsetWidth"in te?te.offsetWidth-te.clientWidth-F-Z:0,M="offsetHeight"in te?te.offsetHeight-te.clientHeight-Y-q:0,ve="offsetWidth"in te?te.offsetWidth===0?0:we/te.offsetWidth:0,H="offsetHeight"in te?te.offsetHeight===0?0:ge/te.offsetHeight:0;if(p===te)ee=a==="start"?ne:a==="end"?ne-h:a==="nearest"?Li(g,g+h,h,Y,q,g+ne,g+ne+b,b):ne-h/2,Q=l==="start"?B:l==="center"?B-v/2:l==="end"?B-v:Li(x,x+v,v,F,Z,x+B,x+B+_,_),ee=Math.max(0,ee+g),Q=Math.max(0,Q+x);else{ee=a==="start"?ne-A-Y:a==="end"?ne-$+q+M:a==="nearest"?Li(A,$,ge,Y,q+M,ne,ne+b,b):ne-(A+ge/2)+M/2,Q=l==="start"?B-L-F:l==="center"?B-(L+we/2)+de/2:l==="end"?B-j+Z+de:Li(L,j,we,F,Z+de,B,B+_,_);const{scrollLeft:Ee,scrollTop:Ve}=te;ee=H===0?0:Math.max(0,Math.min(Ve+ee/H,te.scrollHeight-ge/H+M)),Q=ve===0?0:Math.max(0,Math.min(Ee+Q/ve,te.scrollWidth-we/ve+de)),ne+=Ve-ee,B+=Ee-Q}ce.push({el:te,top:ee,left:Q})}return ce};var Kr=function(){return Kr=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Kr.apply(this,arguments)};var yv=0;function mc(e){return typeof e=="function"?e:It}function It(){}function vu(e,t){if(e){var n=gv(e,{boundary:t,block:"nearest",scrollMode:"if-needed"});n.forEach(function(r){var o=r.el,i=r.top,s=r.left;o.scrollTop=i,o.scrollLeft=s})}}function gc(e,t,n){var r=e===t||t instanceof n.Node&&e.contains&&e.contains(t);return r}function qs(e,t){var n;function r(){n&&clearTimeout(n)}function o(){for(var i=arguments.length,s=new Array(i),a=0;a<i;a++)s[a]=arguments[a];r(),n=setTimeout(function(){n=null,e.apply(void 0,s)},t)}return o.cancel=r,o}function Be(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){for(var o=arguments.length,i=new Array(o>1?o-1:0),s=1;s<o;s++)i[s-1]=arguments[s];return t.some(function(a){return a&&a.apply(void 0,[r].concat(i)),r.preventDownshiftDefault||r.hasOwnProperty("nativeEvent")&&r.nativeEvent.preventDownshiftDefault})}}function Ir(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){t.forEach(function(o){typeof o=="function"?o(r):o&&(o.current=r)})}}function wu(){return String(yv++)}function vv(e){var t=e.isOpen,n=e.resultCount,r=e.previousResultCount;return t?n?n!==r?n+" result"+(n===1?" is":"s are")+" available, use up and down arrow keys to navigate. Press Enter key to select.":"":"No results are available.":""}function yc(e,t){return e=Array.isArray(e)?e[0]:e,!e&&t?t:e}function Iu(e){return typeof e.type=="string"}function bu(e){return e.props}function wv(e,t){console.error('The property "'+t+'" is required in "'+e+'"')}var Iv=["highlightedIndex","inputValue","isOpen","selectedItem","type"];function Ki(e){e===void 0&&(e={});var t={};return Iv.forEach(function(n){e.hasOwnProperty(n)&&(t[n]=e[n])}),t}function to(e,t){return!e||!t?e:Object.keys(e).reduce(function(n,r){return n[r]=no(t,r)?t[r]:e[r],n},{})}function no(e,t){return e[t]!==void 0}function bs(e){var t=e.key,n=e.keyCode;return n>=37&&n<=40&&t.indexOf("Arrow")!==0?"Arrow"+t:t}function bv(e){return Object.prototype.toString.call(e)==="[object Object]"}function Xn(e,t,n,r,o){var i=n.length;if(i===0)return-1;var s=i-1;(typeof e!="number"||e<0||e>s)&&(e=t>0?-1:s+1);var a=e+t;a<0?a=s:a>s&&(a=0);var l=Vr(a,t<0,n,r,o);return l===-1?e>=i?-1:e:l}function Vr(e,t,n,r,o){o===void 0&&(o=!1);var i=n.length;if(t){for(var s=e;s>=0;s--)if(!r(n[s],s))return s}else for(var a=e;a<i;a++)if(!r(n[a],a))return a;return o?Vr(t?i-1:0,t,n,r):-1}function ro(e,t,n,r){return r===void 0&&(r=!0),n&&t.some(function(o){return o&&(gc(o,e,n)||r&&gc(o,n.document.activeElement,n))})}var Hs=It;process.env.NODE_ENV!=="production"&&(Hs=function(t,n,r){var o="This prop should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled Downshift element for the lifetime of the component. More info: https://github.com/downshift-js/downshift#control-props";Object.keys(t).forEach(function(i){n[i]!==void 0&&r[i]===void 0?console.error('downshift: A component has changed the controlled prop "'+i+'" to be uncontrolled. '+o):n[i]===void 0&&r[i]!==void 0&&console.error('downshift: A component has changed the uncontrolled prop "'+i+'" to be controlled. '+o)})});var xv=qs(function(e){xu(e).textContent=""},500);function xu(e){var t=e.getElementById("a11y-status-message");return t||(t=e.createElement("div"),t.setAttribute("id","a11y-status-message"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions text"),Object.assign(t.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),e.body.appendChild(t),t)}function _u(e,t){if(!(!e||!t)){var n=xu(t);n.textContent=e,xv(t)}}function _v(e){var t=e==null?void 0:e.getElementById("a11y-status-message");t&&t.remove()}var Cu=process.env.NODE_ENV!=="production"?"__autocomplete_unknown__":0,Ou=process.env.NODE_ENV!=="production"?"__autocomplete_mouseup__":1,Eu=process.env.NODE_ENV!=="production"?"__autocomplete_item_mouseenter__":2,Hi=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_arrow_up__":3,Bi=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_arrow_down__":4,Su=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_escape__":5,Nu=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_enter__":6,Tu=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_home__":7,Ru=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_end__":8,Au=process.env.NODE_ENV!=="production"?"__autocomplete_click_item__":9,Pu=process.env.NODE_ENV!=="production"?"__autocomplete_blur_input__":10,Du=process.env.NODE_ENV!=="production"?"__autocomplete_change_input__":11,Fu=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_space_button__":12,xs=process.env.NODE_ENV!=="production"?"__autocomplete_click_button__":13,Mu=process.env.NODE_ENV!=="production"?"__autocomplete_blur_button__":14,ju=process.env.NODE_ENV!=="production"?"__autocomplete_controlled_prop_updated_selected_item__":15,ku=process.env.NODE_ENV!=="production"?"__autocomplete_touchend__":16,Cv=Object.freeze({__proto__:null,blurButton:Mu,blurInput:Pu,changeInput:Du,clickButton:xs,clickItem:Au,controlledPropUpdatedSelectedItem:ju,itemMouseEnter:Eu,keyDownArrowDown:Bi,keyDownArrowUp:Hi,keyDownEnd:Ru,keyDownEnter:Nu,keyDownEscape:Su,keyDownHome:Tu,keyDownSpaceButton:Fu,mouseUp:Ou,touchEnd:ku,unknown:Cu}),Ov=["refKey","ref"],Ev=["onClick","onPress","onKeyDown","onKeyUp","onBlur"],Sv=["onKeyDown","onBlur","onChange","onInput","onChangeText"],Nv=["refKey","ref"],Tv=["onMouseMove","onMouseDown","onClick","onPress","index","item"],Rv=function(){var e=function(t){function n(o){var i;i=t.call(this,o)||this,i.id=i.props.id||"downshift-"+wu(),i.menuId=i.props.menuId||i.id+"-menu",i.labelId=i.props.labelId||i.id+"-label",i.inputId=i.props.inputId||i.id+"-input",i.getItemId=i.props.getItemId||function(g){return i.id+"-item-"+g},i.items=[],i.itemCount=null,i.previousResultCount=0,i.timeoutIds=[],i.internalSetTimeout=function(g,b){var _=setTimeout(function(){i.timeoutIds=i.timeoutIds.filter(function(C){return C!==_}),g()},b);i.timeoutIds.push(_)},i.setItemCount=function(g){i.itemCount=g},i.unsetItemCount=function(){i.itemCount=null},i.isItemDisabled=function(g,b){var _=i.getItemNodeFromIndex(b);return _&&_.hasAttribute("disabled")},i.setHighlightedIndex=function(g,b){g===void 0&&(g=i.props.defaultHighlightedIndex),b===void 0&&(b={}),b=Ki(b),i.internalSetState(he({highlightedIndex:g},b))},i.clearSelection=function(g){i.internalSetState({selectedItem:null,inputValue:"",highlightedIndex:i.props.defaultHighlightedIndex,isOpen:i.props.defaultIsOpen},g)},i.selectItem=function(g,b,_){b=Ki(b),i.internalSetState(he({isOpen:i.props.defaultIsOpen,highlightedIndex:i.props.defaultHighlightedIndex,selectedItem:g,inputValue:i.props.itemToString(g)},b),_)},i.selectItemAtIndex=function(g,b,_){var C=i.items[g];C!=null&&i.selectItem(C,b,_)},i.selectHighlightedItem=function(g,b){return i.selectItemAtIndex(i.getState().highlightedIndex,g,b)},i.internalSetState=function(g,b){var _,C,T={},S=typeof g=="function";return!S&&g.hasOwnProperty("inputValue")&&i.props.onInputValueChange(g.inputValue,he({},i.getStateAndHelpers(),g)),i.setState(function(N){var D;N=i.getState(N);var U=S?g(N):g;U=i.props.stateReducer(N,U),_=U.hasOwnProperty("selectedItem");var G={};return _&&U.selectedItem!==N.selectedItem&&(C=U.selectedItem),(D=U).type||(D.type=Cu),Object.keys(U).forEach(function(z){N[z]!==U[z]&&(T[z]=U[z]),z!=="type"&&(U[z],no(i.props,z)||(G[z]=U[z]))}),S&&U.hasOwnProperty("inputValue")&&i.props.onInputValueChange(U.inputValue,he({},i.getStateAndHelpers(),U)),G},function(){mc(b)();var N=Object.keys(T).length>1;N&&i.props.onStateChange(T,i.getStateAndHelpers()),_&&i.props.onSelect(g.selectedItem,i.getStateAndHelpers()),C!==void 0&&i.props.onChange(C,i.getStateAndHelpers()),i.props.onUserAction(T,i.getStateAndHelpers())})},i.rootRef=function(g){return i._rootNode=g},i.getRootProps=function(g,b){var _,C=g===void 0?{}:g,T=C.refKey,S=T===void 0?"ref":T,N=C.ref,D=hn(C,Ov),U=b===void 0?{}:b,G=U.suppressRefError,z=G===void 0?!1:G;i.getRootProps.called=!0,i.getRootProps.refKey=S,i.getRootProps.suppressRefError=z;var ne=i.getState(),B=ne.isOpen;return he((_={},_[S]=Ir(N,i.rootRef),_.role="combobox",_["aria-expanded"]=B,_["aria-haspopup"]="listbox",_["aria-owns"]=B?i.menuId:void 0,_["aria-labelledby"]=i.labelId,_),D)},i.keyDownHandlers={ArrowDown:function(b){var _=this;if(b.preventDefault(),this.getState().isOpen){var C=b.shiftKey?5:1;this.moveHighlightedIndex(C,{type:Bi})}else this.internalSetState({isOpen:!0,type:Bi},function(){var T=_.getItemCount();if(T>0){var S=_.getState(),N=S.highlightedIndex,D=Xn(N,1,{length:T},_.isItemDisabled,!0);_.setHighlightedIndex(D,{type:Bi})}})},ArrowUp:function(b){var _=this;if(b.preventDefault(),this.getState().isOpen){var C=b.shiftKey?-5:-1;this.moveHighlightedIndex(C,{type:Hi})}else this.internalSetState({isOpen:!0,type:Hi},function(){var T=_.getItemCount();if(T>0){var S=_.getState(),N=S.highlightedIndex,D=Xn(N,-1,{length:T},_.isItemDisabled,!0);_.setHighlightedIndex(D,{type:Hi})}})},Enter:function(b){if(b.which!==229){var _=this.getState(),C=_.isOpen,T=_.highlightedIndex;if(C&&T!=null){b.preventDefault();var S=this.items[T],N=this.getItemNodeFromIndex(T);if(S==null||N&&N.hasAttribute("disabled"))return;this.selectHighlightedItem({type:Nu})}}},Escape:function(b){b.preventDefault(),this.reset(he({type:Su},!this.state.isOpen&&{selectedItem:null,inputValue:""}))}},i.buttonKeyDownHandlers=he({},i.keyDownHandlers,{" ":function(b){b.preventDefault(),this.toggleMenu({type:Fu})}}),i.inputKeyDownHandlers=he({},i.keyDownHandlers,{Home:function(b){var _=this.getState(),C=_.isOpen;if(C){b.preventDefault();var T=this.getItemCount();if(!(T<=0||!C)){var S=Vr(0,!1,{length:T},this.isItemDisabled);this.setHighlightedIndex(S,{type:Tu})}}},End:function(b){var _=this.getState(),C=_.isOpen;if(C){b.preventDefault();var T=this.getItemCount();if(!(T<=0||!C)){var S=Vr(T-1,!0,{length:T},this.isItemDisabled);this.setHighlightedIndex(S,{type:Ru})}}}}),i.getToggleButtonProps=function(g){var b=g===void 0?{}:g,_=b.onClick;b.onPress;var C=b.onKeyDown,T=b.onKeyUp,S=b.onBlur,N=hn(b,Ev),D=i.getState(),U=D.isOpen,G={onClick:Be(_,i.buttonHandleClick),onKeyDown:Be(C,i.buttonHandleKeyDown),onKeyUp:Be(T,i.buttonHandleKeyUp),onBlur:Be(S,i.buttonHandleBlur)},z=N.disabled?{}:G;return he({type:"button",role:"button","aria-label":U?"close menu":"open menu","aria-haspopup":!0,"data-toggle":!0},z,N)},i.buttonHandleKeyUp=function(g){g.preventDefault()},i.buttonHandleKeyDown=function(g){var b=bs(g);i.buttonKeyDownHandlers[b]&&i.buttonKeyDownHandlers[b].call(i,g)},i.buttonHandleClick=function(g){if(g.preventDefault(),i.props.environment){var b=i.props.environment.document,_=b.body,C=b.activeElement;_&&_===C&&g.target.focus()}process.env.NODE_ENV==="test"?i.toggleMenu({type:xs}):i.internalSetTimeout(function(){return i.toggleMenu({type:xs})})},i.buttonHandleBlur=function(g){var b=g.target;i.internalSetTimeout(function(){if(!(i.isMouseDown||!i.props.environment)){var _=i.props.environment.document.activeElement;(_==null||_.id!==i.inputId)&&_!==b&&i.reset({type:Mu})}})},i.getLabelProps=function(g){return he({htmlFor:i.inputId,id:i.labelId},g)},i.getInputProps=function(g){var b=g===void 0?{}:g,_=b.onKeyDown,C=b.onBlur,T=b.onChange,S=b.onInput;b.onChangeText;var N=hn(b,Sv),D,U={};D="onChange";var G=i.getState(),z=G.inputValue,ne=G.isOpen,B=G.highlightedIndex;if(!N.disabled){var ce;U=(ce={},ce[D]=Be(T,S,i.inputHandleChange),ce.onKeyDown=Be(_,i.inputHandleKeyDown),ce.onBlur=Be(C,i.inputHandleBlur),ce)}return he({"aria-autocomplete":"list","aria-activedescendant":ne&&typeof B=="number"&&B>=0?i.getItemId(B):void 0,"aria-controls":ne?i.menuId:void 0,"aria-labelledby":N&&N["aria-label"]?void 0:i.labelId,autoComplete:"off",value:z,id:i.inputId},U,N)},i.inputHandleKeyDown=function(g){var b=bs(g);b&&i.inputKeyDownHandlers[b]&&i.inputKeyDownHandlers[b].call(i,g)},i.inputHandleChange=function(g){i.internalSetState({type:Du,isOpen:!0,inputValue:g.target.value,highlightedIndex:i.props.defaultHighlightedIndex})},i.inputHandleBlur=function(){i.internalSetTimeout(function(){var g;if(!(i.isMouseDown||!i.props.environment)){var b=i.props.environment.document.activeElement,_=(b==null||(g=b.dataset)==null?void 0:g.toggle)&&i._rootNode&&i._rootNode.contains(b);_||i.reset({type:Pu})}})},i.menuRef=function(g){i._menuNode=g},i.getMenuProps=function(g,b){var _,C=g===void 0?{}:g,T=C.refKey,S=T===void 0?"ref":T,N=C.ref,D=hn(C,Nv),U=b===void 0?{}:b,G=U.suppressRefError,z=G===void 0?!1:G;return i.getMenuProps.called=!0,i.getMenuProps.refKey=S,i.getMenuProps.suppressRefError=z,he((_={},_[S]=Ir(N,i.menuRef),_.role="listbox",_["aria-labelledby"]=D&&D["aria-label"]?void 0:i.labelId,_.id=i.menuId,_),D)},i.getItemProps=function(g){var b,_=g===void 0?{}:g,C=_.onMouseMove,T=_.onMouseDown,S=_.onClick;_.onPress;var N=_.index,D=_.item,U=D===void 0?process.env.NODE_ENV==="production"?void 0:wv("getItemProps","item"):D,G=hn(_,Tv);N===void 0?(i.items.push(U),N=i.items.indexOf(U)):i.items[N]=U;var z="onClick",ne=S,B=(b={onMouseMove:Be(C,function(){N!==i.getState().highlightedIndex&&(i.setHighlightedIndex(N,{type:Eu}),i.avoidScrolling=!0,i.internalSetTimeout(function(){return i.avoidScrolling=!1},250))}),onMouseDown:Be(T,function(se){se.preventDefault()})},b[z]=Be(ne,function(){i.selectItemAtIndex(N,{type:Au})}),b),ce=G.disabled?{onMouseDown:B.onMouseDown}:B;return he({id:i.getItemId(N),role:"option","aria-selected":i.getState().highlightedIndex===N},ce,G)},i.clearItems=function(){i.items=[]},i.reset=function(g,b){g===void 0&&(g={}),g=Ki(g),i.internalSetState(function(_){var C=_.selectedItem;return he({isOpen:i.props.defaultIsOpen,highlightedIndex:i.props.defaultHighlightedIndex,inputValue:i.props.itemToString(C)},g)},b)},i.toggleMenu=function(g,b){g===void 0&&(g={}),g=Ki(g),i.internalSetState(function(_){var C=_.isOpen;return he({isOpen:!C},C&&{highlightedIndex:i.props.defaultHighlightedIndex},g)},function(){var _=i.getState(),C=_.isOpen,T=_.highlightedIndex;C&&i.getItemCount()>0&&typeof T=="number"&&i.setHighlightedIndex(T,g),mc(b)()})},i.openMenu=function(g){i.internalSetState({isOpen:!0},g)},i.closeMenu=function(g){i.internalSetState({isOpen:!1},g)},i.updateStatus=qs(function(){var g;if((g=i.props)!=null&&(g=g.environment)!=null&&g.document){var b=i.getState(),_=i.items[b.highlightedIndex],C=i.getItemCount(),T=i.props.getA11yStatusMessage(he({itemToString:i.props.itemToString,previousResultCount:i.previousResultCount,resultCount:C,highlightedItem:_},b));i.previousResultCount=C,_u(T,i.props.environment.document)}},200);var s=i.props,a=s.defaultHighlightedIndex,l=s.initialHighlightedIndex,u=l===void 0?a:l,d=s.defaultIsOpen,f=s.initialIsOpen,p=f===void 0?d:f,m=s.initialInputValue,w=m===void 0?"":m,v=s.initialSelectedItem,h=v===void 0?null:v,x=i.getState({highlightedIndex:u,isOpen:p,inputValue:w,selectedItem:h});return x.selectedItem!=null&&i.props.initialInputValue===void 0&&(x.inputValue=i.props.itemToString(x.selectedItem)),i.state=x,i}rv(n,t);var r=n.prototype;return r.internalClearTimeouts=function(){this.timeoutIds.forEach(function(i){clearTimeout(i)}),this.timeoutIds=[]},r.getState=function(i){return i===void 0&&(i=this.state),to(i,this.props)},r.getItemCount=function(){var i=this.items.length;return this.itemCount!=null?i=this.itemCount:this.props.itemCount!==void 0&&(i=this.props.itemCount),i},r.getItemNodeFromIndex=function(i){return this.props.environment?this.props.environment.document.getElementById(this.getItemId(i)):null},r.scrollHighlightedItemIntoView=function(){{var i=this.getItemNodeFromIndex(this.getState().highlightedIndex);this.props.scrollIntoView(i,this._menuNode)}},r.moveHighlightedIndex=function(i,s){var a=this.getItemCount(),l=this.getState(),u=l.highlightedIndex;if(a>0){var d=Xn(u,i,{length:a},this.isItemDisabled,!0);this.setHighlightedIndex(d,s)}},r.getStateAndHelpers=function(){var i=this.getState(),s=i.highlightedIndex,a=i.inputValue,l=i.selectedItem,u=i.isOpen,d=this.props.itemToString,f=this.id,p=this.getRootProps,m=this.getToggleButtonProps,w=this.getLabelProps,v=this.getMenuProps,h=this.getInputProps,x=this.getItemProps,g=this.openMenu,b=this.closeMenu,_=this.toggleMenu,C=this.selectItem,T=this.selectItemAtIndex,S=this.selectHighlightedItem,N=this.setHighlightedIndex,D=this.clearSelection,U=this.clearItems,G=this.reset,z=this.setItemCount,ne=this.unsetItemCount,B=this.internalSetState;return{getRootProps:p,getToggleButtonProps:m,getLabelProps:w,getMenuProps:v,getInputProps:h,getItemProps:x,reset:G,openMenu:g,closeMenu:b,toggleMenu:_,selectItem:C,selectItemAtIndex:T,selectHighlightedItem:S,setHighlightedIndex:N,clearSelection:D,clearItems:U,setItemCount:z,unsetItemCount:ne,setState:B,itemToString:d,id:f,highlightedIndex:s,inputValue:a,isOpen:u,selectedItem:l}},r.componentDidMount=function(){var i=this;if(process.env.NODE_ENV!=="production"&&this.getMenuProps.called&&!this.getMenuProps.suppressRefError&&vc(this._menuNode,this.getMenuProps),!this.props.environment)this.cleanup=function(){i.internalClearTimeouts()};else{var s=function(){i.isMouseDown=!0},a=function(m){i.isMouseDown=!1;var w=ro(m.target,[i._rootNode,i._menuNode],i.props.environment);!w&&i.getState().isOpen&&i.reset({type:Ou},function(){return i.props.onOuterClick(i.getStateAndHelpers())})},l=function(){i.isTouchMove=!1},u=function(){i.isTouchMove=!0},d=function(m){var w=ro(m.target,[i._rootNode,i._menuNode],i.props.environment,!1);!i.isTouchMove&&!w&&i.getState().isOpen&&i.reset({type:ku},function(){return i.props.onOuterClick(i.getStateAndHelpers())})},f=this.props.environment;f.addEventListener("mousedown",s),f.addEventListener("mouseup",a),f.addEventListener("touchstart",l),f.addEventListener("touchmove",u),f.addEventListener("touchend",d),this.cleanup=function(){i.internalClearTimeouts(),i.updateStatus.cancel(),f.removeEventListener("mousedown",s),f.removeEventListener("mouseup",a),f.removeEventListener("touchstart",l),f.removeEventListener("touchmove",u),f.removeEventListener("touchend",d)}}},r.shouldScroll=function(i,s){var a=this.props.highlightedIndex===void 0?this.getState():this.props,l=a.highlightedIndex,u=s.highlightedIndex===void 0?i:s,d=u.highlightedIndex,f=l&&this.getState().isOpen&&!i.isOpen,p=l!==d;return f||p},r.componentDidUpdate=function(i,s){process.env.NODE_ENV!=="production"&&(Hs(this.state,i,this.props),this.getMenuProps.called&&!this.getMenuProps.suppressRefError&&vc(this._menuNode,this.getMenuProps)),no(this.props,"selectedItem")&&this.props.selectedItemChanged(i.selectedItem,this.props.selectedItem)&&this.internalSetState({type:ju,inputValue:this.props.itemToString(this.props.selectedItem)}),!this.avoidScrolling&&this.shouldScroll(s,i)&&this.scrollHighlightedItemIntoView(),this.updateStatus()},r.componentWillUnmount=function(){this.cleanup()},r.render=function(){var i=yc(this.props.children,It);this.clearItems(),this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getRootProps.suppressRefError=void 0,this.getMenuProps.called=!1,this.getMenuProps.refKey=void 0,this.getMenuProps.suppressRefError=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var s=yc(i(this.getStateAndHelpers()));if(!s)return null;if(this.getRootProps.called||this.props.suppressRefError)return process.env.NODE_ENV!=="production"&&!this.getRootProps.suppressRefError&&!this.props.suppressRefError&&Av(s,this.getRootProps),s;if(Iu(s))return y.cloneElement(s,this.getRootProps(bu(s)));if(process.env.NODE_ENV!=="production")throw new Error("downshift: If you return a non-DOM element, you must apply the getRootProps function")},n}(y.Component);return e.defaultProps={defaultHighlightedIndex:null,defaultIsOpen:!1,getA11yStatusMessage:vv,itemToString:function(n){return n==null?"":(process.env.NODE_ENV!=="production"&&bv(n)&&!n.hasOwnProperty("toString")&&console.warn("downshift: An object was passed to the default implementation of `itemToString`. You should probably provide your own `itemToString` implementation. Please refer to the `itemToString` API documentation.","The object that was passed:",n),String(n))},onStateChange:It,onInputValueChange:It,onUserAction:It,onChange:It,onSelect:It,onOuterClick:It,selectedItemChanged:function(n,r){return n!==r},environment:typeof window>"u"?void 0:window,stateReducer:function(n,r){return r},suppressRefError:!1,scrollIntoView:vu},e.stateChangeTypes=Cv,e}();process.env.NODE_ENV!=="production"&&(Rv.propTypes={children:K.func,defaultHighlightedIndex:K.number,defaultIsOpen:K.bool,initialHighlightedIndex:K.number,initialSelectedItem:K.any,initialInputValue:K.string,initialIsOpen:K.bool,getA11yStatusMessage:K.func,itemToString:K.func,onChange:K.func,onSelect:K.func,onStateChange:K.func,onInputValueChange:K.func,onUserAction:K.func,onOuterClick:K.func,selectedItemChanged:K.func,stateReducer:K.func,itemCount:K.number,id:K.string,environment:K.shape({addEventListener:K.func.isRequired,removeEventListener:K.func.isRequired,document:K.shape({createElement:K.func.isRequired,getElementById:K.func.isRequired,activeElement:K.any.isRequired,body:K.any.isRequired}).isRequired,Node:K.func.isRequired}),suppressRefError:K.bool,scrollIntoView:K.func,selectedItem:K.any,isOpen:K.bool,inputValue:K.string,highlightedIndex:K.number,labelId:K.string,inputId:K.string,menuId:K.string,getItemId:K.func});function vc(e,t){var n=t.refKey;e||console.error('downshift: The ref prop "'+n+'" from getMenuProps was not applied correctly on your menu element.')}function Av(e,t){var n=t.refKey,r=n!=="ref",o=!Iu(e);o&&!r&&!fc.isForwardRef(e)?console.error("downshift: You returned a non-DOM element. You must specify a refKey in getRootProps"):!o&&r&&console.error('downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "'+n+'"'),!fc.isForwardRef(e)&&!bu(e)[n]&&console.error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.')}var Lu={highlightedIndex:-1,isOpen:!1,selectedItem:null,inputValue:""};function Pv(e,t,n){var r=e.props,o=e.type,i={};Object.keys(t).forEach(function(s){Dv(s,e,t,n),n[s]!==t[s]&&(i[s]=n[s])}),r.onStateChange&&Object.keys(i).length&&r.onStateChange(he({type:o},i))}function Dv(e,t,n,r){var o=t.props,i=t.type,s="on"+Bs(e)+"Change";o[s]&&r[e]!==void 0&&r[e]!==n[e]&&o[s](he({type:i},r))}function Fv(e,t){return t.changes}var wc=qs(function(e,t){_u(e,t)},200),Mv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?y.useLayoutEffect:y.useEffect,jv="useId"in y?function(t){var n=t.id,r=t.labelId,o=t.menuId,i=t.getItemId,s=t.toggleButtonId,a=t.inputId,l="downshift-"+y.useId();n||(n=l);var u=y.useRef({labelId:r||n+"-label",menuId:o||n+"-menu",getItemId:i||function(d){return n+"-item-"+d},toggleButtonId:s||n+"-toggle-button",inputId:a||n+"-input"});return u.current}:function(t){var n=t.id,r=n===void 0?"downshift-"+wu():n,o=t.labelId,i=t.menuId,s=t.getItemId,a=t.toggleButtonId,l=t.inputId,u=y.useRef({labelId:o||r+"-label",menuId:i||r+"-menu",getItemId:s||function(d){return r+"-item-"+d},toggleButtonId:a||r+"-toggle-button",inputId:l||r+"-input"});return u.current};function kv(e,t,n,r){var o,i;if(e===void 0){if(t===void 0)throw new Error(r);o=n[t],i=t}else i=t===void 0?n.indexOf(e):t,o=e;return[o,i]}function Bs(e){return""+e.slice(0,1).toUpperCase()+e.slice(1)}function Ku(e){var t=y.useRef(e);return t.current=e,t}function Lv(e,t,n,r){var o=y.useRef(),i=y.useRef(),s=y.useCallback(function(m,w){i.current=w,m=to(m,w.props);var v=e(m,w),h=w.props.stateReducer(m,he({},w,{changes:v}));return h},[e]),a=y.useReducer(s,t,n),l=a[0],u=a[1],d=Ku(t),f=y.useCallback(function(m){return u(he({props:d.current},m))},[d]),p=i.current;return y.useEffect(function(){var m=to(o.current,p==null?void 0:p.props),w=p&&o.current&&!r(m,l);w&&Pv(p,m,l),o.current=l},[l,p,r]),[l,f]}var ri={itemToString:function(t){return t?String(t):""},itemToKey:function(t){return t},stateReducer:Fv,scrollIntoView:vu,environment:typeof window>"u"?void 0:window};function jn(e,t,n){n===void 0&&(n=Lu);var r=e["default"+Bs(t)];return r!==void 0?r:n[t]}function ii(e,t,n){n===void 0&&(n=Lu);var r=e[t];if(r!==void 0)return r;var o=e["initial"+Bs(t)];return o!==void 0?o:jn(e,t,n)}function Kv(e){var t=ii(e,"selectedItem"),n=ii(e,"isOpen"),r=Hv(e),o=ii(e,"inputValue");return{highlightedIndex:r<0&&t&&n?e.items.findIndex(function(i){return e.itemToKey(i)===e.itemToKey(t)}):r,isOpen:n,selectedItem:t,inputValue:o}}function oi(e,t,n){var r=e.items,o=e.initialHighlightedIndex,i=e.defaultHighlightedIndex,s=e.isItemDisabled,a=e.itemToKey,l=t.selectedItem,u=t.highlightedIndex;return r.length===0?-1:o!==void 0&&u===o&&!s(r[o],o)?o:i!==void 0&&!s(r[i],i)?i:l?r.findIndex(function(d){return a(l)===a(d)}):n<0&&!s(r[r.length-1],r.length-1)?r.length-1:n>0&&!s(r[0],0)?0:-1}function Vv(e,t,n){var r=y.useRef({isMouseDown:!1,isTouchMove:!1,isTouchEnd:!1});return y.useEffect(function(){if(!e)return It;var o=n.map(function(d){return d.current});function i(){r.current.isTouchEnd=!1,r.current.isMouseDown=!0}function s(d){r.current.isMouseDown=!1,ro(d.target,o,e)||t()}function a(){r.current.isTouchEnd=!1,r.current.isTouchMove=!1}function l(){r.current.isTouchMove=!0}function u(d){r.current.isTouchEnd=!0,!r.current.isTouchMove&&!ro(d.target,o,e,!1)&&t()}return e.addEventListener("mousedown",i),e.addEventListener("mouseup",s),e.addEventListener("touchstart",a),e.addEventListener("touchmove",l),e.addEventListener("touchend",u),function(){e.removeEventListener("mousedown",i),e.removeEventListener("mouseup",s),e.removeEventListener("touchstart",a),e.removeEventListener("touchmove",l),e.removeEventListener("touchend",u)}},[n,e,t]),r.current}var Vu=function(){return It};process.env.NODE_ENV!=="production"&&(Vu=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o=y.useRef(n.reduce(function(s,a){return s[a]={},s},{}));y.useEffect(function(){Object.keys(o.current).forEach(function(s){var a=o.current[s];if(!Object.keys(a).length){console.error("downshift: You forgot to call the "+s+" getter function on your component / element.");return}var l=a.suppressRefError,u=a.refKey,d=a.elementRef;l||d!=null&&d.current||console.error('downshift: The ref prop "'+u+'" from '+s+" was not applied correctly on your element.")})},[]);var i=y.useCallback(function(s,a,l,u){o.current[s]={suppressRefError:a,refKey:l,elementRef:u}},[]);return i});function $v(e,t,n,r){r===void 0&&(r={});var o=r.document,i=yo();y.useEffect(function(){if(!(!e||i||!o)){var s=e(t);wc(s,o)}},n),y.useEffect(function(){return function(){wc.cancel(),_v(o)}},[o])}function Uv(e){var t=e.highlightedIndex,n=e.isOpen,r=e.itemRefs,o=e.getItemNodeFromIndex,i=e.menuElement,s=e.scrollIntoView,a=y.useRef(!0);return Mv(function(){t<0||!n||!Object.keys(r.current).length||(a.current===!1?a.current=!0:s(o(t),i))},[t]),a}var $u=It;process.env.NODE_ENV!=="production"&&($u=function(t){var n=t.props,r=t.state,o=y.useRef(n),i=yo();y.useEffect(function(){i||(Hs(r,o.current,n),o.current=n)},[r,n,i])});function Ic(e,t,n){var r;n===void 0&&(n=!0);var o=((r=e.items)==null?void 0:r.length)&&t>=0;return he({isOpen:!1,highlightedIndex:-1},o&&he({selectedItem:e.items[t],isOpen:jn(e,"isOpen"),highlightedIndex:jn(e,"highlightedIndex")},n&&{inputValue:e.itemToString(e.items[t])}))}function qv(e,t){return e.isOpen===t.isOpen&&e.inputValue===t.inputValue&&e.highlightedIndex===t.highlightedIndex&&e.selectedItem===t.selectedItem}function yo(){var e=y.useRef(!0);return y.useEffect(function(){return e.current=!1,function(){e.current=!0}},[]),e.current}function _s(e){var t=jn(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}function Hv(e){var t=ii(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}var Wi={environment:K.shape({addEventListener:K.func.isRequired,removeEventListener:K.func.isRequired,document:K.shape({createElement:K.func.isRequired,getElementById:K.func.isRequired,activeElement:K.any.isRequired,body:K.any.isRequired}).isRequired,Node:K.func.isRequired}),itemToString:K.func,itemToKey:K.func,stateReducer:K.func},Uu=he({},Wi,{getA11yStatusMessage:K.func,highlightedIndex:K.number,defaultHighlightedIndex:K.number,initialHighlightedIndex:K.number,isOpen:K.bool,defaultIsOpen:K.bool,initialIsOpen:K.bool,selectedItem:K.any,initialSelectedItem:K.any,defaultSelectedItem:K.any,id:K.string,labelId:K.string,menuId:K.string,getItemId:K.func,toggleButtonId:K.string,onSelectedItemChange:K.func,onHighlightedIndexChange:K.func,onStateChange:K.func,onIsOpenChange:K.func,scrollIntoView:K.func});function Bv(e,t,n){var r=t.type,o=t.props,i;switch(r){case n.ItemMouseMove:i={highlightedIndex:t.disabled?-1:t.index};break;case n.MenuMouseLeave:i={highlightedIndex:-1};break;case n.ToggleButtonClick:case n.FunctionToggleMenu:i={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:oi(o,e,0)};break;case n.FunctionOpenMenu:i={isOpen:!0,highlightedIndex:oi(o,e,0)};break;case n.FunctionCloseMenu:i={isOpen:!1};break;case n.FunctionSetHighlightedIndex:i={highlightedIndex:o.isItemDisabled(o.items[t.highlightedIndex],t.highlightedIndex)?-1:t.highlightedIndex};break;case n.FunctionSetInputValue:i={inputValue:t.inputValue};break;case n.FunctionReset:i={highlightedIndex:_s(o),isOpen:jn(o,"isOpen"),selectedItem:jn(o,"selectedItem"),inputValue:jn(o,"inputValue")};break;default:throw new Error("Reducer called without proper action type.")}return he({},e,i)}Kr(Kr({},Uu),{items:K.array.isRequired,isItemDisabled:K.func});Kr(Kr({},ri),{isItemDisabled:function(){return!1}});process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;var Ws=process.env.NODE_ENV!=="production"?"__input_keydown_arrow_down__":0,Js=process.env.NODE_ENV!=="production"?"__input_keydown_arrow_up__":1,zs=process.env.NODE_ENV!=="production"?"__input_keydown_escape__":2,Gs=process.env.NODE_ENV!=="production"?"__input_keydown_home__":3,Qs=process.env.NODE_ENV!=="production"?"__input_keydown_end__":4,Xs=process.env.NODE_ENV!=="production"?"__input_keydown_page_up__":5,Ys=process.env.NODE_ENV!=="production"?"__input_keydown_page_down__":6,Zs=process.env.NODE_ENV!=="production"?"__input_keydown_enter__":7,ea=process.env.NODE_ENV!=="production"?"__input_change__":8,io=process.env.NODE_ENV!=="production"?"__input_blur__":9,ta=process.env.NODE_ENV!=="production"?"__input_click__":10,qu=process.env.NODE_ENV!=="production"?"__menu_mouse_leave__":11,Hu=process.env.NODE_ENV!=="production"?"__item_mouse_move__":12,na=process.env.NODE_ENV!=="production"?"__item_click__":13,Bu=process.env.NODE_ENV!=="production"?"__togglebutton_click__":14,Wu=process.env.NODE_ENV!=="production"?"__function_toggle_menu__":15,Ju=process.env.NODE_ENV!=="production"?"__function_open_menu__":16,zu=process.env.NODE_ENV!=="production"?"__function_close_menu__":17,Gu=process.env.NODE_ENV!=="production"?"__function_set_highlighted_index__":18,ra=process.env.NODE_ENV!=="production"?"__function_select_item__":19,Qu=process.env.NODE_ENV!=="production"?"__function_set_input_value__":20,Xu=process.env.NODE_ENV!=="production"?"__function_reset__":21,ia=process.env.NODE_ENV!=="production"?"__controlled_prop_updated_selected_item__":22,Yu=Object.freeze({__proto__:null,ControlledPropUpdatedSelectedItem:ia,FunctionCloseMenu:zu,FunctionOpenMenu:Ju,FunctionReset:Xu,FunctionSelectItem:ra,FunctionSetHighlightedIndex:Gu,FunctionSetInputValue:Qu,FunctionToggleMenu:Wu,InputBlur:io,InputChange:ea,InputClick:ta,InputKeyDownArrowDown:Ws,InputKeyDownArrowUp:Js,InputKeyDownEnd:Qs,InputKeyDownEnter:Zs,InputKeyDownEscape:zs,InputKeyDownHome:Gs,InputKeyDownPageDown:Ys,InputKeyDownPageUp:Xs,ItemClick:na,ItemMouseMove:Hu,MenuMouseLeave:qu,ToggleButtonClick:Bu});function Wv(e){var t=Kv(e),n=t.selectedItem,r=t.inputValue;return r===""&&n&&e.defaultInputValue===void 0&&e.initialInputValue===void 0&&e.inputValue===void 0&&(r=e.itemToString(n)),he({},t,{inputValue:r})}var Jv=he({},Uu,{items:K.array.isRequired,isItemDisabled:K.func,inputValue:K.string,defaultInputValue:K.string,initialInputValue:K.string,inputId:K.string,onInputValueChange:K.func});function zv(e,t,n,r){var o=y.useRef(),i=Lv(e,t,n,r),s=i[0],a=i[1],l=yo();return y.useEffect(function(){if(no(t,"selectedItem")){if(!l){var u=t.itemToKey(t.selectedItem)!==t.itemToKey(o.current);u&&a({type:ia,inputValue:t.itemToString(t.selectedItem)})}o.current=s.selectedItem===o.current?t.selectedItem:s.selectedItem}},[s.selectedItem,t.selectedItem]),[to(s,t),a]}var Zu=It;process.env.NODE_ENV!=="production"&&(Zu=function(t,n){K.checkPropTypes(Jv,t,"prop",n.name)});var Gv=he({},ri,{isItemDisabled:function(){return!1}});function Qv(e,t){var n,r=t.type,o=t.props,i=t.altKey,s;switch(r){case na:s={isOpen:jn(o,"isOpen"),highlightedIndex:_s(o),selectedItem:o.items[t.index],inputValue:o.itemToString(o.items[t.index])};break;case Ws:e.isOpen?s={highlightedIndex:Xn(e.highlightedIndex,1,o.items,o.isItemDisabled,!0)}:s={highlightedIndex:i&&e.selectedItem==null?-1:oi(o,e,1),isOpen:o.items.length>=0};break;case Js:e.isOpen?i?s=Ic(o,e.highlightedIndex):s={highlightedIndex:Xn(e.highlightedIndex,-1,o.items,o.isItemDisabled,!0)}:s={highlightedIndex:oi(o,e,-1),isOpen:o.items.length>=0};break;case Zs:s=Ic(o,e.highlightedIndex);break;case zs:s=he({isOpen:!1,highlightedIndex:-1},!e.isOpen&&{selectedItem:null,inputValue:""});break;case Xs:s={highlightedIndex:Xn(e.highlightedIndex,-10,o.items,o.isItemDisabled,!0)};break;case Ys:s={highlightedIndex:Xn(e.highlightedIndex,10,o.items,o.isItemDisabled,!0)};break;case Gs:s={highlightedIndex:Vr(0,!1,o.items,o.isItemDisabled)};break;case Qs:s={highlightedIndex:Vr(o.items.length-1,!0,o.items,o.isItemDisabled)};break;case io:s=he({isOpen:!1,highlightedIndex:-1},e.highlightedIndex>=0&&((n=o.items)==null?void 0:n.length)&&t.selectItem&&{selectedItem:o.items[e.highlightedIndex],inputValue:o.itemToString(o.items[e.highlightedIndex])});break;case ea:s={isOpen:!0,highlightedIndex:_s(o),inputValue:t.inputValue};break;case ta:s={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:oi(o,e,0)};break;case ra:s={selectedItem:t.selectedItem,inputValue:o.itemToString(t.selectedItem)};break;case ia:s={inputValue:t.inputValue};break;default:return Bv(e,t,Yu)}return he({},e,s)}var Xv=["onMouseLeave","refKey","ref"],Yv=["item","index","refKey","ref","onMouseMove","onMouseDown","onClick","onPress","disabled"],Zv=["onClick","onPress","refKey","ref"],ew=["onKeyDown","onChange","onInput","onBlur","onChangeText","onClick","refKey","ref"];oa.stateChangeTypes=Yu;function oa(e){e===void 0&&(e={}),Zu(e,oa);var t=he({},Gv,e),n=t.items,r=t.scrollIntoView,o=t.environment,i=t.getA11yStatusMessage,s=zv(Qv,t,Wv,qv),a=s[0],l=s[1],u=a.isOpen,d=a.highlightedIndex,f=a.selectedItem,p=a.inputValue,m=y.useRef(null),w=y.useRef({}),v=y.useRef(null),h=y.useRef(null),x=yo(),g=jv(t),b=y.useRef(),_=Ku({state:a,props:t}),C=y.useCallback(function($){return w.current[g.getItemId($)]},[g]);$v(i,a,[u,d,f,p],o);var T=Uv({menuElement:m.current,highlightedIndex:d,isOpen:u,itemRefs:w,scrollIntoView:r,getItemNodeFromIndex:C});$u({props:t,state:a}),y.useEffect(function(){var $=ii(t,"isOpen");$&&v.current&&v.current.focus()},[]),y.useEffect(function(){x||(b.current=n.length)});var S=Vv(o,y.useCallback(function(){_.current.state.isOpen&&l({type:io,selectItem:!1})},[l,_]),y.useMemo(function(){return[m,h,v]},[m.current,h.current,v.current])),N=Vu("getInputProps","getMenuProps");y.useEffect(function(){u||(w.current={})},[u]),y.useEffect(function(){var $;!u||!(o!=null&&o.document)||!(v!=null&&($=v.current)!=null&&$.focus)||o.document.activeElement!==v.current&&v.current.focus()},[u,o]);var D=y.useMemo(function(){return{ArrowDown:function(L){L.preventDefault(),l({type:Ws,altKey:L.altKey})},ArrowUp:function(L){L.preventDefault(),l({type:Js,altKey:L.altKey})},Home:function(L){_.current.state.isOpen&&(L.preventDefault(),l({type:Gs}))},End:function(L){_.current.state.isOpen&&(L.preventDefault(),l({type:Qs}))},Escape:function(L){var k=_.current.state;(k.isOpen||k.inputValue||k.selectedItem||k.highlightedIndex>-1)&&(L.preventDefault(),l({type:zs}))},Enter:function(L){var k=_.current.state;!k.isOpen||L.which===229||(L.preventDefault(),l({type:Zs}))},PageUp:function(L){_.current.state.isOpen&&(L.preventDefault(),l({type:Xs}))},PageDown:function(L){_.current.state.isOpen&&(L.preventDefault(),l({type:Ys}))}}},[l,_]),U=y.useCallback(function($){return he({id:g.labelId,htmlFor:g.inputId},$)},[g]),G=y.useCallback(function($,L){var k,F=$===void 0?{}:$,Y=F.onMouseLeave,Z=F.refKey,q=Z===void 0?"ref":Z,ee=F.ref,Q=hn(F,Xv),de=L===void 0?{}:L,M=de.suppressRefError,ve=M===void 0?!1:M;return N("getMenuProps",ve,q,m),he((k={},k[q]=Ir(ee,function(H){m.current=H}),k.id=g.menuId,k.role="listbox",k["aria-labelledby"]=Q&&Q["aria-label"]?void 0:""+g.labelId,k.onMouseLeave=Be(Y,function(){l({type:qu})}),k),Q)},[l,N,g]),z=y.useCallback(function($){var L,k,F=$===void 0?{}:$,Y=F.item,Z=F.index,q=F.refKey,ee=q===void 0?"ref":q,Q=F.ref,de=F.onMouseMove,M=F.onMouseDown,ve=F.onClick;F.onPress;var H=F.disabled,Ee=hn(F,Yv);H!==void 0&&console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.');var Ve=_.current,Xe=Ve.props,$e=Ve.state,Ie=kv(Y,Z,Xe.items,"Pass either item or index to getItemProps!"),Ft=Ie[0],Ye=Ie[1],yt=Xe.isItemDisabled(Ft,Ye),Mt="onClick",jt=ve,Ze=function(){S.isTouchEnd||Ye===$e.highlightedIndex||(T.current=!1,l({type:Hu,index:Ye,disabled:yt}))},ze=function(){l({type:na,index:Ye})},Ue=function(kt){return kt.preventDefault()};return he((L={},L[ee]=Ir(Q,function(Pe){Pe&&(w.current[g.getItemId(Ye)]=Pe)}),L["aria-disabled"]=yt,L["aria-selected"]=Ye===$e.highlightedIndex,L.id=g.getItemId(Ye),L.role="option",L),!yt&&(k={},k[Mt]=Be(jt,ze),k),{onMouseMove:Be(de,Ze),onMouseDown:Be(M,Ue)},Ee)},[l,g,_,S,T]),ne=y.useCallback(function($){var L,k=$===void 0?{}:$,F=k.onClick;k.onPress;var Y=k.refKey,Z=Y===void 0?"ref":Y,q=k.ref,ee=hn(k,Zv),Q=_.current.state,de=function(){l({type:Bu})};return he((L={},L[Z]=Ir(q,function(M){h.current=M}),L["aria-controls"]=g.menuId,L["aria-expanded"]=Q.isOpen,L.id=g.toggleButtonId,L.tabIndex=-1,L),!ee.disabled&&he({},{onClick:Be(F,de)}),ee)},[l,_,g]),B=y.useCallback(function($,L){var k,F=$===void 0?{}:$,Y=F.onKeyDown,Z=F.onChange,q=F.onInput,ee=F.onBlur;F.onChangeText;var Q=F.onClick,de=F.refKey,M=de===void 0?"ref":de,ve=F.ref,H=hn(F,ew),Ee=L===void 0?{}:L,Ve=Ee.suppressRefError,Xe=Ve===void 0?!1:Ve;N("getInputProps",Xe,M,v);var $e=_.current.state,Ie=function(Ue){var Pe=bs(Ue);Pe&&D[Pe]&&D[Pe](Ue)},Ft=function(Ue){l({type:ea,inputValue:Ue.target.value})},Ye=function(Ue){if(o!=null&&o.document&&$e.isOpen&&!S.isMouseDown){var Pe=Ue.relatedTarget===null&&o.document.activeElement!==o.document.body;l({type:io,selectItem:!Pe})}},yt=function(){l({type:ta})},Mt="onChange",jt={};if(!H.disabled){var Ze;jt=(Ze={},Ze[Mt]=Be(Z,q,Ft),Ze.onKeyDown=Be(Y,Ie),Ze.onBlur=Be(ee,Ye),Ze.onClick=Be(Q,yt),Ze)}return he((k={},k[M]=Ir(ve,function(ze){v.current=ze}),k["aria-activedescendant"]=$e.isOpen&&$e.highlightedIndex>-1?g.getItemId($e.highlightedIndex):"",k["aria-autocomplete"]="list",k["aria-controls"]=g.menuId,k["aria-expanded"]=$e.isOpen,k["aria-labelledby"]=H&&H["aria-label"]?void 0:g.labelId,k.autoComplete="off",k.id=g.inputId,k.role="combobox",k.value=$e.inputValue,k),jt,H)},[l,g,o,D,_,S,N]),ce=y.useCallback(function(){l({type:Wu})},[l]),se=y.useCallback(function(){l({type:zu})},[l]),te=y.useCallback(function(){l({type:Ju})},[l]),ge=y.useCallback(function($){l({type:Gu,highlightedIndex:$})},[l]),we=y.useCallback(function($){l({type:ra,selectedItem:$})},[l]),A=y.useCallback(function($){l({type:Qu,inputValue:$})},[l]),j=y.useCallback(function(){l({type:Xu})},[l]);return{getItemProps:z,getLabelProps:U,getMenuProps:G,getInputProps:B,getToggleButtonProps:ne,toggleMenu:ce,openMenu:te,closeMenu:se,setHighlightedIndex:ge,setInputValue:A,selectItem:we,reset:j,highlightedIndex:d,isOpen:u,selectedItem:f,inputValue:p}}Wi.stateReducer,Wi.itemToKey,Wi.environment,K.array,K.array,K.array,K.func,K.number,K.number,K.number,K.func,K.func,K.string,K.string;ri.itemToKey,ri.stateReducer,ri.environment;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;const tw="_comboboxContainer_1lcc8_1",nw="_label_1lcc8_8",rw="_inputContainer_1lcc8_12",iw="_input_1lcc8_12",ow="_toggleButton_1lcc8_33",sw="_menu_1lcc8_39",aw="_menuBottom_1lcc8_55",cw="_menuTop_1lcc8_61",lw="_menuItem_1lcc8_66",uw="_highlighted_1lcc8_73",dw="_selected_1lcc8_77",fw="_hidden_1lcc8_81",$t={comboboxContainer:tw,label:nw,inputContainer:rw,input:iw,toggleButton:ow,menu:sw,menuBottom:aw,menuTop:cw,menuItem:lw,highlighted:uw,selected:dw,hidden:fw};function pw(e){const t=e.toLowerCase();return function(r){return!e||r.label.toLowerCase().includes(t)||r.value.toLowerCase().includes(t)}}function ed({items:e,selectedValue:t,onSelectedItemChange:n,placeholder:r,disabled:o,style:i,menuPosition:s="bottom"}){const[a,l]=y.useState(e),u=y.useRef(null);y.useEffect(()=>l(e),[e]);const d=y.useCallback(S=>{(S==null?void 0:S.length)>0?l(e.filter(pw(S))):l(e)},[e]),{isOpen:f,getToggleButtonProps:p,getMenuProps:m,getInputProps:w,highlightedIndex:v,getItemProps:h,setInputValue:x,selectedItem:g}=oa({items:a,selectedItem:t?e.find(S=>S.value===t):null,itemToString:S=>(S==null?void 0:S.label)||"",onInputValueChange:({inputValue:S})=>d(S),onSelectedItemChange:({selectedItem:S})=>{var N;n(S),(N=u.current)==null||N.blur()}}),b=()=>{x(""),l(e)},_=()=>b(),C=y.useMemo(()=>{var S;return(S=e.find(N=>N.value===t))==null?void 0:S.label},[e,t]),T=()=>{t&&C&&t!==(g==null?void 0:g.value)&&x(C||"")};return c.jsxs("div",{style:{position:"relative",...i},children:[c.jsx("div",{className:$t.comboboxContainer,children:c.jsxs("div",{className:$t.inputContainer,children:[c.jsx("input",{style:{border:"none"},disabled:o,placeholder:r,className:$t.input,...w({onFocus:_,onBlur:T,ref:u})}),c.jsx("button",{style:{border:"none"},disabled:o,"aria-label":"toggle menu",className:$t.toggleButton,type:"button",...p(),children:f?c.jsx(c.Fragment,{children:"↑"}):c.jsx(c.Fragment,{children:"↓"})})]})}),c.jsx("ul",{className:`${$t.menu} ${f&&e.length?"":$t.hidden} ${s==="top"?$t.menuTop:$t.menuBottom}`,...m(),children:f&&a.map((S,N)=>c.jsx("li",{className:`${$t.menuItem} ${v===N?$t.highlighted:""} ${t===(S==null?void 0:S.value)?$t.selected:""}`,...h({item:S,index:N}),children:c.jsx("span",{children:S.label})},S.id))})]})}const $r=Math.min,sr=Math.max,oo=Math.round,Vi=Math.floor,Kn=e=>({x:e,y:e}),hw={left:"right",right:"left",bottom:"top",top:"bottom"},mw={start:"end",end:"start"};function Cs(e,t,n){return sr(e,$r(t,n))}function wi(e,t){return typeof e=="function"?e(t):e}function hr(e){return e.split("-")[0]}function Ii(e){return e.split("-")[1]}function td(e){return e==="x"?"y":"x"}function sa(e){return e==="y"?"height":"width"}function Ur(e){return["top","bottom"].includes(hr(e))?"y":"x"}function aa(e){return td(Ur(e))}function gw(e,t,n){n===void 0&&(n=!1);const r=Ii(e),o=aa(e),i=sa(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=so(s)),[s,so(s)]}function yw(e){const t=so(e);return[Os(e),t,Os(t)]}function Os(e){return e.replace(/start|end/g,t=>mw[t])}function vw(e,t,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:s;default:return[]}}function ww(e,t,n,r){const o=Ii(e);let i=vw(hr(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(Os)))),i}function so(e){return e.replace(/left|right|bottom|top/g,t=>hw[t])}function Iw(e){return{top:0,right:0,bottom:0,left:0,...e}}function nd(e){return typeof e!="number"?Iw(e):{top:e,right:e,bottom:e,left:e}}function ao(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function bc(e,t,n){let{reference:r,floating:o}=e;const i=Ur(t),s=aa(t),a=sa(s),l=hr(t),u=i==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let m;switch(l){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(Ii(t)){case"start":m[s]-=p*(n&&u?-1:1);break;case"end":m[s]+=p*(n&&u?-1:1);break}return m}const bw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,a=i.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(t));let u=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=bc(u,r,l),p=r,m={},w=0;for(let v=0;v<a.length;v++){const{name:h,fn:x}=a[v],{x:g,y:b,data:_,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:p,strategy:o,middlewareData:m,rects:u,platform:s,elements:{reference:e,floating:t}});d=g??d,f=b??f,m={...m,[h]:{...m[h],..._}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(u=C.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=bc(u,p,l)),v=-1)}return{x:d,y:f,placement:p,strategy:o,middlewareData:m}};async function rd(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=wi(t,e),w=nd(m),h=a[p?f==="floating"?"reference":"floating":f],x=ao(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(h)))==null||n?h:h.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),g=f==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,b=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),_=await(i.isElement==null?void 0:i.isElement(b))?await(i.getScale==null?void 0:i.getScale(b))||{x:1,y:1}:{x:1,y:1},C=ao(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:g,offsetParent:b,strategy:l}):g);return{top:(x.top-C.top+w.top)/_.y,bottom:(C.bottom-x.bottom+w.bottom)/_.y,left:(x.left-C.left+w.left)/_.x,right:(C.right-x.right+w.right)/_.x}}const xw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=wi(e,t)||{};if(u==null)return{};const f=nd(d),p={x:n,y:r},m=aa(o),w=sa(m),v=await s.getDimensions(u),h=m==="y",x=h?"top":"left",g=h?"bottom":"right",b=h?"clientHeight":"clientWidth",_=i.reference[w]+i.reference[m]-p[m]-i.floating[w],C=p[m]-i.reference[m],T=await(s.getOffsetParent==null?void 0:s.getOffsetParent(u));let S=T?T[b]:0;(!S||!await(s.isElement==null?void 0:s.isElement(T)))&&(S=a.floating[b]||i.floating[w]);const N=_/2-C/2,D=S/2-v[w]/2-1,U=$r(f[x],D),G=$r(f[g],D),z=U,ne=S-v[w]-G,B=S/2-v[w]/2+N,ce=Cs(z,B,ne),se=!l.arrow&&Ii(o)!=null&&B!==ce&&i.reference[w]/2-(B<z?U:G)-v[w]/2<0,te=se?B<z?B-z:B-ne:0;return{[m]:p[m]+te,data:{[m]:ce,centerOffset:B-ce-te,...se&&{alignmentOffset:te}},reset:se}}}),_w=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:v=!0,...h}=wi(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const x=hr(o),g=Ur(a),b=hr(a)===a,_=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=p||(b||!v?[so(a)]:yw(a)),T=w!=="none";!p&&T&&C.push(...ww(a,v,w,_));const S=[a,...C],N=await rd(t,h),D=[];let U=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&D.push(N[x]),f){const B=gw(o,s,_);D.push(N[B[0]],N[B[1]])}if(U=[...U,{placement:o,overflows:D}],!D.every(B=>B<=0)){var G,z;const B=(((G=i.flip)==null?void 0:G.index)||0)+1,ce=S[B];if(ce)return{data:{index:B,overflows:U},reset:{placement:ce}};let se=(z=U.filter(te=>te.overflows[0]<=0).sort((te,ge)=>te.overflows[1]-ge.overflows[1])[0])==null?void 0:z.placement;if(!se)switch(m){case"bestFit":{var ne;const te=(ne=U.filter(ge=>{if(T){const we=Ur(ge.placement);return we===g||we==="y"}return!0}).map(ge=>[ge.placement,ge.overflows.filter(we=>we>0).reduce((we,A)=>we+A,0)]).sort((ge,we)=>ge[1]-we[1])[0])==null?void 0:ne[0];te&&(se=te);break}case"initialPlacement":se=a;break}if(o!==se)return{reset:{placement:se}}}return{}}}};async function Cw(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=hr(n),a=Ii(n),l=Ur(n)==="y",u=["left","top"].includes(s)?-1:1,d=i&&l?-1:1,f=wi(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(m=a==="end"?w*-1:w),l?{x:m*d,y:p*u}:{x:p*u,y:m*d}}const Ow=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:a}=t,l=await Cw(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:i+l.y,data:{...l,placement:s}}}}},Ew=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:a={fn:h=>{let{x,y:g}=h;return{x,y:g}}},...l}=wi(e,t),u={x:n,y:r},d=await rd(t,l),f=Ur(hr(o)),p=td(f);let m=u[p],w=u[f];if(i){const h=p==="y"?"top":"left",x=p==="y"?"bottom":"right",g=m+d[h],b=m-d[x];m=Cs(g,m,b)}if(s){const h=f==="y"?"top":"left",x=f==="y"?"bottom":"right",g=w+d[h],b=w-d[x];w=Cs(g,w,b)}const v=a.fn({...t,[p]:m,[f]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[p]:i,[f]:s}}}}}};function vo(){return typeof window<"u"}function Qr(e){return id(e)?(e.nodeName||"").toLowerCase():"#document"}function bt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function rn(e){var t;return(t=(id(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function id(e){return vo()?e instanceof Node||e instanceof bt(e).Node:!1}function Jt(e){return vo()?e instanceof Element||e instanceof bt(e).Element:!1}function nn(e){return vo()?e instanceof HTMLElement||e instanceof bt(e).HTMLElement:!1}function xc(e){return!vo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof bt(e).ShadowRoot}function bi(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=zt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function Sw(e){return["table","td","th"].includes(Qr(e))}function wo(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function ca(e){const t=la(),n=Jt(e)?zt(e):e;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function Nw(e){let t=Vn(e);for(;nn(t)&&!qr(t);){if(ca(t))return t;if(wo(t))return null;t=Vn(t)}return null}function la(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function qr(e){return["html","body","#document"].includes(Qr(e))}function zt(e){return bt(e).getComputedStyle(e)}function Io(e){return Jt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Vn(e){if(Qr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xc(e)&&e.host||rn(e);return xc(t)?t.host:t}function od(e){const t=Vn(e);return qr(t)?e.ownerDocument?e.ownerDocument.body:e.body:nn(t)&&bi(t)?t:od(t)}function di(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=od(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=bt(o);if(i){const a=Es(s);return t.concat(s,s.visualViewport||[],bi(o)?o:[],a&&n?di(a):[])}return t.concat(o,di(o,[],n))}function Es(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sd(e){const t=zt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=nn(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=oo(n)!==i||oo(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function ua(e){return Jt(e)?e:e.contextElement}function xr(e){const t=ua(e);if(!nn(t))return Kn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=sd(t);let s=(i?oo(n.width):n.width)/r,a=(i?oo(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const Tw=Kn(0);function ad(e){const t=bt(e);return!la()||!t.visualViewport?Tw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Rw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==bt(e)?!1:t}function mr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=ua(e);let s=Kn(1);t&&(r?Jt(r)&&(s=xr(r)):s=xr(e));const a=Rw(i,n,r)?ad(i):Kn(0);let l=(o.left+a.x)/s.x,u=(o.top+a.y)/s.y,d=o.width/s.x,f=o.height/s.y;if(i){const p=bt(i),m=r&&Jt(r)?bt(r):r;let w=p,v=Es(w);for(;v&&r&&m!==w;){const h=xr(v),x=v.getBoundingClientRect(),g=zt(v),b=x.left+(v.clientLeft+parseFloat(g.paddingLeft))*h.x,_=x.top+(v.clientTop+parseFloat(g.paddingTop))*h.y;l*=h.x,u*=h.y,d*=h.x,f*=h.y,l+=b,u+=_,w=bt(v),v=Es(w)}}return ao({width:d,height:f,x:l,y:u})}function Aw(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=rn(r),a=t?wo(t.floating):!1;if(r===s||a&&i)return n;let l={scrollLeft:0,scrollTop:0},u=Kn(1);const d=Kn(0),f=nn(r);if((f||!f&&!i)&&((Qr(r)!=="body"||bi(s))&&(l=Io(r)),nn(r))){const p=mr(r);u=xr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x,y:n.y*u.y-l.scrollTop*u.y+d.y}}function Pw(e){return Array.from(e.getClientRects())}function Ss(e,t){const n=Io(e).scrollLeft;return t?t.left+n:mr(rn(e)).left+n}function Dw(e){const t=rn(e),n=Io(e),r=e.ownerDocument.body,o=sr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=sr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+Ss(e);const a=-n.scrollTop;return zt(r).direction==="rtl"&&(s+=sr(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function Fw(e,t){const n=bt(e),r=rn(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,a=0,l=0;if(o){i=o.width,s=o.height;const u=la();(!u||u&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:i,height:s,x:a,y:l}}function Mw(e,t){const n=mr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=nn(e)?xr(e):Kn(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,l=o*i.x,u=r*i.y;return{width:s,height:a,x:l,y:u}}function _c(e,t,n){let r;if(t==="viewport")r=Fw(e,n);else if(t==="document")r=Dw(rn(e));else if(Jt(t))r=Mw(t,n);else{const o=ad(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return ao(r)}function cd(e,t){const n=Vn(e);return n===t||!Jt(n)||qr(n)?!1:zt(n).position==="fixed"||cd(n,t)}function jw(e,t){const n=t.get(e);if(n)return n;let r=di(e,[],!1).filter(a=>Jt(a)&&Qr(a)!=="body"),o=null;const i=zt(e).position==="fixed";let s=i?Vn(e):e;for(;Jt(s)&&!qr(s);){const a=zt(s),l=ca(s);!l&&a.position==="fixed"&&(o=null),(i?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||bi(s)&&!l&&cd(e,s))?r=r.filter(d=>d!==s):o=a,s=Vn(s)}return t.set(e,r),r}function kw(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?wo(t)?[]:jw(t,this._c):[].concat(n),r],a=s[0],l=s.reduce((u,d)=>{const f=_c(t,d,o);return u.top=sr(f.top,u.top),u.right=$r(f.right,u.right),u.bottom=$r(f.bottom,u.bottom),u.left=sr(f.left,u.left),u},_c(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Lw(e){const{width:t,height:n}=sd(e);return{width:t,height:n}}function Kw(e,t,n){const r=nn(t),o=rn(t),i=n==="fixed",s=mr(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const l=Kn(0);if(r||!r&&!i)if((Qr(t)!=="body"||bi(o))&&(a=Io(t)),r){const m=mr(t,!0,i,t);l.x=m.x+t.clientLeft,l.y=m.y+t.clientTop}else o&&(l.x=Ss(o));let u=0,d=0;if(o&&!r&&!i){const m=o.getBoundingClientRect();d=m.top+a.scrollTop,u=m.left+a.scrollLeft-Ss(o,m)}const f=s.left+a.scrollLeft-l.x-u,p=s.top+a.scrollTop-l.y-d;return{x:f,y:p,width:s.width,height:s.height}}function Ho(e){return zt(e).position==="static"}function Cc(e,t){if(!nn(e)||zt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return rn(e)===n&&(n=n.ownerDocument.body),n}function ld(e,t){const n=bt(e);if(wo(e))return n;if(!nn(e)){let o=Vn(e);for(;o&&!qr(o);){if(Jt(o)&&!Ho(o))return o;o=Vn(o)}return n}let r=Cc(e,t);for(;r&&Sw(r)&&Ho(r);)r=Cc(r,t);return r&&qr(r)&&Ho(r)&&!ca(r)?n:r||Nw(e)||n}const Vw=async function(e){const t=this.getOffsetParent||ld,n=this.getDimensions,r=await n(e.floating);return{reference:Kw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function $w(e){return zt(e).direction==="rtl"}const Uw={convertOffsetParentRelativeRectToViewportRelativeRect:Aw,getDocumentElement:rn,getClippingRect:kw,getOffsetParent:ld,getElementRects:Vw,getClientRects:Pw,getDimensions:Lw,getScale:xr,isElement:Jt,isRTL:$w};function qw(e,t){let n=null,r;const o=rn(e);function i(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function s(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const{left:u,top:d,width:f,height:p}=e.getBoundingClientRect();if(a||t(),!f||!p)return;const m=Vi(d),w=Vi(o.clientWidth-(u+f)),v=Vi(o.clientHeight-(d+p)),h=Vi(u),g={rootMargin:-m+"px "+-w+"px "+-v+"px "+-h+"px",threshold:sr(0,$r(1,l))||1};let b=!0;function _(C){const T=C[0].intersectionRatio;if(T!==l){if(!b)return s();T?s(!1,T):r=setTimeout(()=>{s(!1,1e-7)},1e3)}b=!1}try{n=new IntersectionObserver(_,{...g,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,g)}n.observe(e)}return s(!0),i}function Hw(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=ua(e),d=o||i?[...u?di(u):[],...di(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),i&&x.addEventListener("resize",n)});const f=u&&a?qw(u,n):null;let p=-1,m=null;s&&(m=new ResizeObserver(x=>{let[g]=x;g&&g.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var b;(b=m)==null||b.observe(t)})),n()}),u&&!l&&m.observe(u),m.observe(t));let w,v=l?mr(e):null;l&&h();function h(){const x=mr(e);v&&(x.x!==v.x||x.y!==v.y||x.width!==v.width||x.height!==v.height)&&n(),v=x,w=requestAnimationFrame(h)}return n(),()=>{var x;d.forEach(g=>{o&&g.removeEventListener("scroll",n),i&&g.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,l&&cancelAnimationFrame(w)}}const Bw=Ow,Ww=Ew,Jw=_w,zw=xw,Oc=(e,t,n)=>{const r=new Map,o={platform:Uw,...n},i={...o.platform,_c:r};return bw(e,t,{...o,platform:i})};/*
|
|
45
|
+
*/var fc;function Yv(){return fc||(fc=1,process.env.NODE_ENV!=="production"&&function(){var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),s=Symbol.for("react.context"),a=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),w=!1,v=!1,h=!1,x=!1,g=!1,b;b=Symbol.for("react.module.reference");function _(H){return!!(typeof H=="string"||typeof H=="function"||H===n||H===o||g||H===r||H===u||H===d||x||H===m||w||v||h||typeof H=="object"&&H!==null&&(H.$$typeof===p||H.$$typeof===f||H.$$typeof===i||H.$$typeof===s||H.$$typeof===l||H.$$typeof===b||H.getModuleId!==void 0))}function C(H){if(typeof H=="object"&&H!==null){var Ee=H.$$typeof;switch(Ee){case e:var Ve=H.type;switch(Ve){case n:case o:case r:case u:case d:return Ve;default:var Ye=Ve&&Ve.$$typeof;switch(Ye){case a:case s:case l:case p:case f:case i:return Ye;default:return Ee}}case t:return Ee}}}var R=s,N=i,T=e,F=l,$=n,G=p,z=f,ne=t,B=o,ce=r,se=u,te=d,ge=!1,we=!1;function A(H){return ge||(ge=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")),!1}function k(H){return we||(we=!0,console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")),!1}function U(H){return C(H)===s}function L(H){return C(H)===i}function j(H){return typeof H=="object"&&H!==null&&H.$$typeof===e}function D(H){return C(H)===l}function Y(H){return C(H)===n}function Z(H){return C(H)===p}function q(H){return C(H)===f}function ee(H){return C(H)===t}function Q(H){return C(H)===o}function de(H){return C(H)===r}function M(H){return C(H)===u}function ve(H){return C(H)===d}Ce.ContextConsumer=R,Ce.ContextProvider=N,Ce.Element=T,Ce.ForwardRef=F,Ce.Fragment=$,Ce.Lazy=G,Ce.Memo=z,Ce.Portal=ne,Ce.Profiler=B,Ce.StrictMode=ce,Ce.Suspense=se,Ce.SuspenseList=te,Ce.isAsyncMode=A,Ce.isConcurrentMode=k,Ce.isContextConsumer=U,Ce.isContextProvider=L,Ce.isElement=j,Ce.isForwardRef=D,Ce.isFragment=Y,Ce.isLazy=Z,Ce.isMemo=q,Ce.isPortal=ee,Ce.isProfiler=Q,Ce.isStrictMode=de,Ce.isSuspense=M,Ce.isSuspenseList=ve,Ce.isValidElementType=_,Ce.typeOf=C}()),Ce}process.env.NODE_ENV==="production"?Is.exports=Xv():Is.exports=Yv();var pc=Is.exports;const hc=e=>typeof e=="object"&&e!=null&&e.nodeType===1,mc=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",qo=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return mc(n.overflowY,t)||mc(n.overflowX,t)||(r=>{const o=(i=>{if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}})(r);return!!o&&(o.clientHeight<r.scrollHeight||o.clientWidth<r.scrollWidth)})(e)}return!1},Li=(e,t,n,r,o,i,s,a)=>i<e&&s>t||i>e&&s<t?0:i<=e&&a<=n||s>=t&&a>=n?i-e-r:s>t&&a<n||i<e&&a>n?s-t+o:0,Zv=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},ew=(e,t)=>{var n,r,o,i;if(typeof document>"u")return[];const{scrollMode:s,block:a,inline:l,boundary:u,skipOverflowHiddenElements:d}=t,f=typeof u=="function"?u:se=>se!==u;if(!hc(e))throw new TypeError("Invalid target");const p=document.scrollingElement||document.documentElement,m=[];let w=e;for(;hc(w)&&f(w);){if(w=Zv(w),w===p){m.push(w);break}w!=null&&w===document.body&&qo(w)&&!qo(document.documentElement)||w!=null&&qo(w,d)&&m.push(w)}const v=(r=(n=window.visualViewport)==null?void 0:n.width)!=null?r:innerWidth,h=(i=(o=window.visualViewport)==null?void 0:o.height)!=null?i:innerHeight,{scrollX:x,scrollY:g}=window,{height:b,width:_,top:C,right:R,bottom:N,left:T}=e.getBoundingClientRect(),{top:F,right:$,bottom:G,left:z}=(se=>{const te=window.getComputedStyle(se);return{top:parseFloat(te.scrollMarginTop)||0,right:parseFloat(te.scrollMarginRight)||0,bottom:parseFloat(te.scrollMarginBottom)||0,left:parseFloat(te.scrollMarginLeft)||0}})(e);let ne=a==="start"||a==="nearest"?C-F:a==="end"?N+G:C+b/2-F+G,B=l==="center"?T+_/2-z+$:l==="end"?R+$:T-z;const ce=[];for(let se=0;se<m.length;se++){const te=m[se],{height:ge,width:we,top:A,right:k,bottom:U,left:L}=te.getBoundingClientRect();if(s==="if-needed"&&C>=0&&T>=0&&N<=h&&R<=v&&C>=A&&N<=U&&T>=L&&R<=k)return ce;const j=getComputedStyle(te),D=parseInt(j.borderLeftWidth,10),Y=parseInt(j.borderTopWidth,10),Z=parseInt(j.borderRightWidth,10),q=parseInt(j.borderBottomWidth,10);let ee=0,Q=0;const de="offsetWidth"in te?te.offsetWidth-te.clientWidth-D-Z:0,M="offsetHeight"in te?te.offsetHeight-te.clientHeight-Y-q:0,ve="offsetWidth"in te?te.offsetWidth===0?0:we/te.offsetWidth:0,H="offsetHeight"in te?te.offsetHeight===0?0:ge/te.offsetHeight:0;if(p===te)ee=a==="start"?ne:a==="end"?ne-h:a==="nearest"?Li(g,g+h,h,Y,q,g+ne,g+ne+b,b):ne-h/2,Q=l==="start"?B:l==="center"?B-v/2:l==="end"?B-v:Li(x,x+v,v,D,Z,x+B,x+B+_,_),ee=Math.max(0,ee+g),Q=Math.max(0,Q+x);else{ee=a==="start"?ne-A-Y:a==="end"?ne-U+q+M:a==="nearest"?Li(A,U,ge,Y,q+M,ne,ne+b,b):ne-(A+ge/2)+M/2,Q=l==="start"?B-L-D:l==="center"?B-(L+we/2)+de/2:l==="end"?B-k+Z+de:Li(L,k,we,D,Z+de,B,B+_,_);const{scrollLeft:Ee,scrollTop:Ve}=te;ee=H===0?0:Math.max(0,Math.min(Ve+ee/H,te.scrollHeight-ge/H+M)),Q=ve===0?0:Math.max(0,Math.min(Ee+Q/ve,te.scrollWidth-we/ve+de)),ne+=Ve-ee,B+=Ee-Q}ce.push({el:te,top:ee,left:Q})}return ce};var Kr=function(){return Kr=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Kr.apply(this,arguments)};var tw=0;function gc(e){return typeof e=="function"?e:bt}function bt(){}function xu(e,t){if(e){var n=ew(e,{boundary:t,block:"nearest",scrollMode:"if-needed"});n.forEach(function(r){var o=r.el,i=r.top,s=r.left;o.scrollTop=i,o.scrollLeft=s})}}function yc(e,t,n){var r=e===t||t instanceof n.Node&&e.contains&&e.contains(t);return r}function Hs(e,t){var n;function r(){n&&clearTimeout(n)}function o(){for(var i=arguments.length,s=new Array(i),a=0;a<i;a++)s[a]=arguments[a];r(),n=setTimeout(function(){n=null,e.apply(void 0,s)},t)}return o.cancel=r,o}function Be(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){for(var o=arguments.length,i=new Array(o>1?o-1:0),s=1;s<o;s++)i[s-1]=arguments[s];return t.some(function(a){return a&&a.apply(void 0,[r].concat(i)),r.preventDownshiftDefault||r.hasOwnProperty("nativeEvent")&&r.nativeEvent.preventDownshiftDefault})}}function Ir(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){t.forEach(function(o){typeof o=="function"?o(r):o&&(o.current=r)})}}function _u(){return String(tw++)}function nw(e){var t=e.isOpen,n=e.resultCount,r=e.previousResultCount;return t?n?n!==r?n+" result"+(n===1?" is":"s are")+" available, use up and down arrow keys to navigate. Press Enter key to select.":"":"No results are available.":""}function vc(e,t){return e=Array.isArray(e)?e[0]:e,!e&&t?t:e}function Cu(e){return typeof e.type=="string"}function Ou(e){return e.props}function rw(e,t){console.error('The property "'+t+'" is required in "'+e+'"')}var iw=["highlightedIndex","inputValue","isOpen","selectedItem","type"];function Ki(e){e===void 0&&(e={});var t={};return iw.forEach(function(n){e.hasOwnProperty(n)&&(t[n]=e[n])}),t}function to(e,t){return!e||!t?e:Object.keys(e).reduce(function(n,r){return n[r]=no(t,r)?t[r]:e[r],n},{})}function no(e,t){return e[t]!==void 0}function bs(e){var t=e.key,n=e.keyCode;return n>=37&&n<=40&&t.indexOf("Arrow")!==0?"Arrow"+t:t}function ow(e){return Object.prototype.toString.call(e)==="[object Object]"}function Yn(e,t,n,r,o){var i=n.length;if(i===0)return-1;var s=i-1;(typeof e!="number"||e<0||e>s)&&(e=t>0?-1:s+1);var a=e+t;a<0?a=s:a>s&&(a=0);var l=Vr(a,t<0,n,r,o);return l===-1?e>=i?-1:e:l}function Vr(e,t,n,r,o){o===void 0&&(o=!1);var i=n.length;if(t){for(var s=e;s>=0;s--)if(!r(n[s],s))return s}else for(var a=e;a<i;a++)if(!r(n[a],a))return a;return o?Vr(t?i-1:0,t,n,r):-1}function ro(e,t,n,r){return r===void 0&&(r=!0),n&&t.some(function(o){return o&&(yc(o,e,n)||r&&yc(o,n.document.activeElement,n))})}var Bs=bt;process.env.NODE_ENV!=="production"&&(Bs=function(t,n,r){var o="This prop should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled Downshift element for the lifetime of the component. More info: https://github.com/downshift-js/downshift#control-props";Object.keys(t).forEach(function(i){n[i]!==void 0&&r[i]===void 0?console.error('downshift: A component has changed the controlled prop "'+i+'" to be uncontrolled. '+o):n[i]===void 0&&r[i]!==void 0&&console.error('downshift: A component has changed the uncontrolled prop "'+i+'" to be controlled. '+o)})});var sw=Hs(function(e){Eu(e).textContent=""},500);function Eu(e){var t=e.getElementById("a11y-status-message");return t||(t=e.createElement("div"),t.setAttribute("id","a11y-status-message"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions text"),Object.assign(t.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),e.body.appendChild(t),t)}function Su(e,t){if(!(!e||!t)){var n=Eu(t);n.textContent=e,sw(t)}}function aw(e){var t=e==null?void 0:e.getElementById("a11y-status-message");t&&t.remove()}var Nu=process.env.NODE_ENV!=="production"?"__autocomplete_unknown__":0,Tu=process.env.NODE_ENV!=="production"?"__autocomplete_mouseup__":1,Ru=process.env.NODE_ENV!=="production"?"__autocomplete_item_mouseenter__":2,Hi=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_arrow_up__":3,Bi=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_arrow_down__":4,Au=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_escape__":5,Pu=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_enter__":6,Fu=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_home__":7,Du=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_end__":8,Mu=process.env.NODE_ENV!=="production"?"__autocomplete_click_item__":9,ku=process.env.NODE_ENV!=="production"?"__autocomplete_blur_input__":10,ju=process.env.NODE_ENV!=="production"?"__autocomplete_change_input__":11,Lu=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_space_button__":12,xs=process.env.NODE_ENV!=="production"?"__autocomplete_click_button__":13,Ku=process.env.NODE_ENV!=="production"?"__autocomplete_blur_button__":14,Vu=process.env.NODE_ENV!=="production"?"__autocomplete_controlled_prop_updated_selected_item__":15,Uu=process.env.NODE_ENV!=="production"?"__autocomplete_touchend__":16,cw=Object.freeze({__proto__:null,blurButton:Ku,blurInput:ku,changeInput:ju,clickButton:xs,clickItem:Mu,controlledPropUpdatedSelectedItem:Vu,itemMouseEnter:Ru,keyDownArrowDown:Bi,keyDownArrowUp:Hi,keyDownEnd:Du,keyDownEnter:Pu,keyDownEscape:Au,keyDownHome:Fu,keyDownSpaceButton:Lu,mouseUp:Tu,touchEnd:Uu,unknown:Nu}),lw=["refKey","ref"],uw=["onClick","onPress","onKeyDown","onKeyUp","onBlur"],dw=["onKeyDown","onBlur","onChange","onInput","onChangeText"],fw=["refKey","ref"],pw=["onMouseMove","onMouseDown","onClick","onPress","index","item"],hw=function(){var e=function(t){function n(o){var i;i=t.call(this,o)||this,i.id=i.props.id||"downshift-"+_u(),i.menuId=i.props.menuId||i.id+"-menu",i.labelId=i.props.labelId||i.id+"-label",i.inputId=i.props.inputId||i.id+"-input",i.getItemId=i.props.getItemId||function(g){return i.id+"-item-"+g},i.items=[],i.itemCount=null,i.previousResultCount=0,i.timeoutIds=[],i.internalSetTimeout=function(g,b){var _=setTimeout(function(){i.timeoutIds=i.timeoutIds.filter(function(C){return C!==_}),g()},b);i.timeoutIds.push(_)},i.setItemCount=function(g){i.itemCount=g},i.unsetItemCount=function(){i.itemCount=null},i.isItemDisabled=function(g,b){var _=i.getItemNodeFromIndex(b);return _&&_.hasAttribute("disabled")},i.setHighlightedIndex=function(g,b){g===void 0&&(g=i.props.defaultHighlightedIndex),b===void 0&&(b={}),b=Ki(b),i.internalSetState(he({highlightedIndex:g},b))},i.clearSelection=function(g){i.internalSetState({selectedItem:null,inputValue:"",highlightedIndex:i.props.defaultHighlightedIndex,isOpen:i.props.defaultIsOpen},g)},i.selectItem=function(g,b,_){b=Ki(b),i.internalSetState(he({isOpen:i.props.defaultIsOpen,highlightedIndex:i.props.defaultHighlightedIndex,selectedItem:g,inputValue:i.props.itemToString(g)},b),_)},i.selectItemAtIndex=function(g,b,_){var C=i.items[g];C!=null&&i.selectItem(C,b,_)},i.selectHighlightedItem=function(g,b){return i.selectItemAtIndex(i.getState().highlightedIndex,g,b)},i.internalSetState=function(g,b){var _,C,R={},N=typeof g=="function";return!N&&g.hasOwnProperty("inputValue")&&i.props.onInputValueChange(g.inputValue,he({},i.getStateAndHelpers(),g)),i.setState(function(T){var F;T=i.getState(T);var $=N?g(T):g;$=i.props.stateReducer(T,$),_=$.hasOwnProperty("selectedItem");var G={};return _&&$.selectedItem!==T.selectedItem&&(C=$.selectedItem),(F=$).type||(F.type=Nu),Object.keys($).forEach(function(z){T[z]!==$[z]&&(R[z]=$[z]),z!=="type"&&($[z],no(i.props,z)||(G[z]=$[z]))}),N&&$.hasOwnProperty("inputValue")&&i.props.onInputValueChange($.inputValue,he({},i.getStateAndHelpers(),$)),G},function(){gc(b)();var T=Object.keys(R).length>1;T&&i.props.onStateChange(R,i.getStateAndHelpers()),_&&i.props.onSelect(g.selectedItem,i.getStateAndHelpers()),C!==void 0&&i.props.onChange(C,i.getStateAndHelpers()),i.props.onUserAction(R,i.getStateAndHelpers())})},i.rootRef=function(g){return i._rootNode=g},i.getRootProps=function(g,b){var _,C=g===void 0?{}:g,R=C.refKey,N=R===void 0?"ref":R,T=C.ref,F=mn(C,lw),$=b===void 0?{}:b,G=$.suppressRefError,z=G===void 0?!1:G;i.getRootProps.called=!0,i.getRootProps.refKey=N,i.getRootProps.suppressRefError=z;var ne=i.getState(),B=ne.isOpen;return he((_={},_[N]=Ir(T,i.rootRef),_.role="combobox",_["aria-expanded"]=B,_["aria-haspopup"]="listbox",_["aria-owns"]=B?i.menuId:void 0,_["aria-labelledby"]=i.labelId,_),F)},i.keyDownHandlers={ArrowDown:function(b){var _=this;if(b.preventDefault(),this.getState().isOpen){var C=b.shiftKey?5:1;this.moveHighlightedIndex(C,{type:Bi})}else this.internalSetState({isOpen:!0,type:Bi},function(){var R=_.getItemCount();if(R>0){var N=_.getState(),T=N.highlightedIndex,F=Yn(T,1,{length:R},_.isItemDisabled,!0);_.setHighlightedIndex(F,{type:Bi})}})},ArrowUp:function(b){var _=this;if(b.preventDefault(),this.getState().isOpen){var C=b.shiftKey?-5:-1;this.moveHighlightedIndex(C,{type:Hi})}else this.internalSetState({isOpen:!0,type:Hi},function(){var R=_.getItemCount();if(R>0){var N=_.getState(),T=N.highlightedIndex,F=Yn(T,-1,{length:R},_.isItemDisabled,!0);_.setHighlightedIndex(F,{type:Hi})}})},Enter:function(b){if(b.which!==229){var _=this.getState(),C=_.isOpen,R=_.highlightedIndex;if(C&&R!=null){b.preventDefault();var N=this.items[R],T=this.getItemNodeFromIndex(R);if(N==null||T&&T.hasAttribute("disabled"))return;this.selectHighlightedItem({type:Pu})}}},Escape:function(b){b.preventDefault(),this.reset(he({type:Au},!this.state.isOpen&&{selectedItem:null,inputValue:""}))}},i.buttonKeyDownHandlers=he({},i.keyDownHandlers,{" ":function(b){b.preventDefault(),this.toggleMenu({type:Lu})}}),i.inputKeyDownHandlers=he({},i.keyDownHandlers,{Home:function(b){var _=this.getState(),C=_.isOpen;if(C){b.preventDefault();var R=this.getItemCount();if(!(R<=0||!C)){var N=Vr(0,!1,{length:R},this.isItemDisabled);this.setHighlightedIndex(N,{type:Fu})}}},End:function(b){var _=this.getState(),C=_.isOpen;if(C){b.preventDefault();var R=this.getItemCount();if(!(R<=0||!C)){var N=Vr(R-1,!0,{length:R},this.isItemDisabled);this.setHighlightedIndex(N,{type:Du})}}}}),i.getToggleButtonProps=function(g){var b=g===void 0?{}:g,_=b.onClick;b.onPress;var C=b.onKeyDown,R=b.onKeyUp,N=b.onBlur,T=mn(b,uw),F=i.getState(),$=F.isOpen,G={onClick:Be(_,i.buttonHandleClick),onKeyDown:Be(C,i.buttonHandleKeyDown),onKeyUp:Be(R,i.buttonHandleKeyUp),onBlur:Be(N,i.buttonHandleBlur)},z=T.disabled?{}:G;return he({type:"button",role:"button","aria-label":$?"close menu":"open menu","aria-haspopup":!0,"data-toggle":!0},z,T)},i.buttonHandleKeyUp=function(g){g.preventDefault()},i.buttonHandleKeyDown=function(g){var b=bs(g);i.buttonKeyDownHandlers[b]&&i.buttonKeyDownHandlers[b].call(i,g)},i.buttonHandleClick=function(g){if(g.preventDefault(),i.props.environment){var b=i.props.environment.document,_=b.body,C=b.activeElement;_&&_===C&&g.target.focus()}process.env.NODE_ENV==="test"?i.toggleMenu({type:xs}):i.internalSetTimeout(function(){return i.toggleMenu({type:xs})})},i.buttonHandleBlur=function(g){var b=g.target;i.internalSetTimeout(function(){if(!(i.isMouseDown||!i.props.environment)){var _=i.props.environment.document.activeElement;(_==null||_.id!==i.inputId)&&_!==b&&i.reset({type:Ku})}})},i.getLabelProps=function(g){return he({htmlFor:i.inputId,id:i.labelId},g)},i.getInputProps=function(g){var b=g===void 0?{}:g,_=b.onKeyDown,C=b.onBlur,R=b.onChange,N=b.onInput;b.onChangeText;var T=mn(b,dw),F,$={};F="onChange";var G=i.getState(),z=G.inputValue,ne=G.isOpen,B=G.highlightedIndex;if(!T.disabled){var ce;$=(ce={},ce[F]=Be(R,N,i.inputHandleChange),ce.onKeyDown=Be(_,i.inputHandleKeyDown),ce.onBlur=Be(C,i.inputHandleBlur),ce)}return he({"aria-autocomplete":"list","aria-activedescendant":ne&&typeof B=="number"&&B>=0?i.getItemId(B):void 0,"aria-controls":ne?i.menuId:void 0,"aria-labelledby":T&&T["aria-label"]?void 0:i.labelId,autoComplete:"off",value:z,id:i.inputId},$,T)},i.inputHandleKeyDown=function(g){var b=bs(g);b&&i.inputKeyDownHandlers[b]&&i.inputKeyDownHandlers[b].call(i,g)},i.inputHandleChange=function(g){i.internalSetState({type:ju,isOpen:!0,inputValue:g.target.value,highlightedIndex:i.props.defaultHighlightedIndex})},i.inputHandleBlur=function(){i.internalSetTimeout(function(){var g;if(!(i.isMouseDown||!i.props.environment)){var b=i.props.environment.document.activeElement,_=(b==null||(g=b.dataset)==null?void 0:g.toggle)&&i._rootNode&&i._rootNode.contains(b);_||i.reset({type:ku})}})},i.menuRef=function(g){i._menuNode=g},i.getMenuProps=function(g,b){var _,C=g===void 0?{}:g,R=C.refKey,N=R===void 0?"ref":R,T=C.ref,F=mn(C,fw),$=b===void 0?{}:b,G=$.suppressRefError,z=G===void 0?!1:G;return i.getMenuProps.called=!0,i.getMenuProps.refKey=N,i.getMenuProps.suppressRefError=z,he((_={},_[N]=Ir(T,i.menuRef),_.role="listbox",_["aria-labelledby"]=F&&F["aria-label"]?void 0:i.labelId,_.id=i.menuId,_),F)},i.getItemProps=function(g){var b,_=g===void 0?{}:g,C=_.onMouseMove,R=_.onMouseDown,N=_.onClick;_.onPress;var T=_.index,F=_.item,$=F===void 0?process.env.NODE_ENV==="production"?void 0:rw("getItemProps","item"):F,G=mn(_,pw);T===void 0?(i.items.push($),T=i.items.indexOf($)):i.items[T]=$;var z="onClick",ne=N,B=(b={onMouseMove:Be(C,function(){T!==i.getState().highlightedIndex&&(i.setHighlightedIndex(T,{type:Ru}),i.avoidScrolling=!0,i.internalSetTimeout(function(){return i.avoidScrolling=!1},250))}),onMouseDown:Be(R,function(se){se.preventDefault()})},b[z]=Be(ne,function(){i.selectItemAtIndex(T,{type:Mu})}),b),ce=G.disabled?{onMouseDown:B.onMouseDown}:B;return he({id:i.getItemId(T),role:"option","aria-selected":i.getState().highlightedIndex===T},ce,G)},i.clearItems=function(){i.items=[]},i.reset=function(g,b){g===void 0&&(g={}),g=Ki(g),i.internalSetState(function(_){var C=_.selectedItem;return he({isOpen:i.props.defaultIsOpen,highlightedIndex:i.props.defaultHighlightedIndex,inputValue:i.props.itemToString(C)},g)},b)},i.toggleMenu=function(g,b){g===void 0&&(g={}),g=Ki(g),i.internalSetState(function(_){var C=_.isOpen;return he({isOpen:!C},C&&{highlightedIndex:i.props.defaultHighlightedIndex},g)},function(){var _=i.getState(),C=_.isOpen,R=_.highlightedIndex;C&&i.getItemCount()>0&&typeof R=="number"&&i.setHighlightedIndex(R,g),gc(b)()})},i.openMenu=function(g){i.internalSetState({isOpen:!0},g)},i.closeMenu=function(g){i.internalSetState({isOpen:!1},g)},i.updateStatus=Hs(function(){var g;if((g=i.props)!=null&&(g=g.environment)!=null&&g.document){var b=i.getState(),_=i.items[b.highlightedIndex],C=i.getItemCount(),R=i.props.getA11yStatusMessage(he({itemToString:i.props.itemToString,previousResultCount:i.previousResultCount,resultCount:C,highlightedItem:_},b));i.previousResultCount=C,Su(R,i.props.environment.document)}},200);var s=i.props,a=s.defaultHighlightedIndex,l=s.initialHighlightedIndex,u=l===void 0?a:l,d=s.defaultIsOpen,f=s.initialIsOpen,p=f===void 0?d:f,m=s.initialInputValue,w=m===void 0?"":m,v=s.initialSelectedItem,h=v===void 0?null:v,x=i.getState({highlightedIndex:u,isOpen:p,inputValue:w,selectedItem:h});return x.selectedItem!=null&&i.props.initialInputValue===void 0&&(x.inputValue=i.props.itemToString(x.selectedItem)),i.state=x,i}Uv(n,t);var r=n.prototype;return r.internalClearTimeouts=function(){this.timeoutIds.forEach(function(i){clearTimeout(i)}),this.timeoutIds=[]},r.getState=function(i){return i===void 0&&(i=this.state),to(i,this.props)},r.getItemCount=function(){var i=this.items.length;return this.itemCount!=null?i=this.itemCount:this.props.itemCount!==void 0&&(i=this.props.itemCount),i},r.getItemNodeFromIndex=function(i){return this.props.environment?this.props.environment.document.getElementById(this.getItemId(i)):null},r.scrollHighlightedItemIntoView=function(){{var i=this.getItemNodeFromIndex(this.getState().highlightedIndex);this.props.scrollIntoView(i,this._menuNode)}},r.moveHighlightedIndex=function(i,s){var a=this.getItemCount(),l=this.getState(),u=l.highlightedIndex;if(a>0){var d=Yn(u,i,{length:a},this.isItemDisabled,!0);this.setHighlightedIndex(d,s)}},r.getStateAndHelpers=function(){var i=this.getState(),s=i.highlightedIndex,a=i.inputValue,l=i.selectedItem,u=i.isOpen,d=this.props.itemToString,f=this.id,p=this.getRootProps,m=this.getToggleButtonProps,w=this.getLabelProps,v=this.getMenuProps,h=this.getInputProps,x=this.getItemProps,g=this.openMenu,b=this.closeMenu,_=this.toggleMenu,C=this.selectItem,R=this.selectItemAtIndex,N=this.selectHighlightedItem,T=this.setHighlightedIndex,F=this.clearSelection,$=this.clearItems,G=this.reset,z=this.setItemCount,ne=this.unsetItemCount,B=this.internalSetState;return{getRootProps:p,getToggleButtonProps:m,getLabelProps:w,getMenuProps:v,getInputProps:h,getItemProps:x,reset:G,openMenu:g,closeMenu:b,toggleMenu:_,selectItem:C,selectItemAtIndex:R,selectHighlightedItem:N,setHighlightedIndex:T,clearSelection:F,clearItems:$,setItemCount:z,unsetItemCount:ne,setState:B,itemToString:d,id:f,highlightedIndex:s,inputValue:a,isOpen:u,selectedItem:l}},r.componentDidMount=function(){var i=this;if(process.env.NODE_ENV!=="production"&&this.getMenuProps.called&&!this.getMenuProps.suppressRefError&&wc(this._menuNode,this.getMenuProps),!this.props.environment)this.cleanup=function(){i.internalClearTimeouts()};else{var s=function(){i.isMouseDown=!0},a=function(m){i.isMouseDown=!1;var w=ro(m.target,[i._rootNode,i._menuNode],i.props.environment);!w&&i.getState().isOpen&&i.reset({type:Tu},function(){return i.props.onOuterClick(i.getStateAndHelpers())})},l=function(){i.isTouchMove=!1},u=function(){i.isTouchMove=!0},d=function(m){var w=ro(m.target,[i._rootNode,i._menuNode],i.props.environment,!1);!i.isTouchMove&&!w&&i.getState().isOpen&&i.reset({type:Uu},function(){return i.props.onOuterClick(i.getStateAndHelpers())})},f=this.props.environment;f.addEventListener("mousedown",s),f.addEventListener("mouseup",a),f.addEventListener("touchstart",l),f.addEventListener("touchmove",u),f.addEventListener("touchend",d),this.cleanup=function(){i.internalClearTimeouts(),i.updateStatus.cancel(),f.removeEventListener("mousedown",s),f.removeEventListener("mouseup",a),f.removeEventListener("touchstart",l),f.removeEventListener("touchmove",u),f.removeEventListener("touchend",d)}}},r.shouldScroll=function(i,s){var a=this.props.highlightedIndex===void 0?this.getState():this.props,l=a.highlightedIndex,u=s.highlightedIndex===void 0?i:s,d=u.highlightedIndex,f=l&&this.getState().isOpen&&!i.isOpen,p=l!==d;return f||p},r.componentDidUpdate=function(i,s){process.env.NODE_ENV!=="production"&&(Bs(this.state,i,this.props),this.getMenuProps.called&&!this.getMenuProps.suppressRefError&&wc(this._menuNode,this.getMenuProps)),no(this.props,"selectedItem")&&this.props.selectedItemChanged(i.selectedItem,this.props.selectedItem)&&this.internalSetState({type:Vu,inputValue:this.props.itemToString(this.props.selectedItem)}),!this.avoidScrolling&&this.shouldScroll(s,i)&&this.scrollHighlightedItemIntoView(),this.updateStatus()},r.componentWillUnmount=function(){this.cleanup()},r.render=function(){var i=vc(this.props.children,bt);this.clearItems(),this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getRootProps.suppressRefError=void 0,this.getMenuProps.called=!1,this.getMenuProps.refKey=void 0,this.getMenuProps.suppressRefError=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var s=vc(i(this.getStateAndHelpers()));if(!s)return null;if(this.getRootProps.called||this.props.suppressRefError)return process.env.NODE_ENV!=="production"&&!this.getRootProps.suppressRefError&&!this.props.suppressRefError&&mw(s,this.getRootProps),s;if(Cu(s))return y.cloneElement(s,this.getRootProps(Ou(s)));if(process.env.NODE_ENV!=="production")throw new Error("downshift: If you return a non-DOM element, you must apply the getRootProps function")},n}(y.Component);return e.defaultProps={defaultHighlightedIndex:null,defaultIsOpen:!1,getA11yStatusMessage:nw,itemToString:function(n){return n==null?"":(process.env.NODE_ENV!=="production"&&ow(n)&&!n.hasOwnProperty("toString")&&console.warn("downshift: An object was passed to the default implementation of `itemToString`. You should probably provide your own `itemToString` implementation. Please refer to the `itemToString` API documentation.","The object that was passed:",n),String(n))},onStateChange:bt,onInputValueChange:bt,onUserAction:bt,onChange:bt,onSelect:bt,onOuterClick:bt,selectedItemChanged:function(n,r){return n!==r},environment:typeof window>"u"?void 0:window,stateReducer:function(n,r){return r},suppressRefError:!1,scrollIntoView:xu},e.stateChangeTypes=cw,e}();process.env.NODE_ENV!=="production"&&(hw.propTypes={children:K.func,defaultHighlightedIndex:K.number,defaultIsOpen:K.bool,initialHighlightedIndex:K.number,initialSelectedItem:K.any,initialInputValue:K.string,initialIsOpen:K.bool,getA11yStatusMessage:K.func,itemToString:K.func,onChange:K.func,onSelect:K.func,onStateChange:K.func,onInputValueChange:K.func,onUserAction:K.func,onOuterClick:K.func,selectedItemChanged:K.func,stateReducer:K.func,itemCount:K.number,id:K.string,environment:K.shape({addEventListener:K.func.isRequired,removeEventListener:K.func.isRequired,document:K.shape({createElement:K.func.isRequired,getElementById:K.func.isRequired,activeElement:K.any.isRequired,body:K.any.isRequired}).isRequired,Node:K.func.isRequired}),suppressRefError:K.bool,scrollIntoView:K.func,selectedItem:K.any,isOpen:K.bool,inputValue:K.string,highlightedIndex:K.number,labelId:K.string,inputId:K.string,menuId:K.string,getItemId:K.func});function wc(e,t){var n=t.refKey;e||console.error('downshift: The ref prop "'+n+'" from getMenuProps was not applied correctly on your menu element.')}function mw(e,t){var n=t.refKey,r=n!=="ref",o=!Cu(e);o&&!r&&!pc.isForwardRef(e)?console.error("downshift: You returned a non-DOM element. You must specify a refKey in getRootProps"):!o&&r&&console.error('downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "'+n+'"'),!pc.isForwardRef(e)&&!Ou(e)[n]&&console.error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.')}var $u={highlightedIndex:-1,isOpen:!1,selectedItem:null,inputValue:""};function gw(e,t,n){var r=e.props,o=e.type,i={};Object.keys(t).forEach(function(s){yw(s,e,t,n),n[s]!==t[s]&&(i[s]=n[s])}),r.onStateChange&&Object.keys(i).length&&r.onStateChange(he({type:o},i))}function yw(e,t,n,r){var o=t.props,i=t.type,s="on"+Js(e)+"Change";o[s]&&r[e]!==void 0&&r[e]!==n[e]&&o[s](he({type:i},r))}function vw(e,t){return t.changes}var Ic=Hs(function(e,t){Su(e,t)},200),ww=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?y.useLayoutEffect:y.useEffect,Iw="useId"in y?function(t){var n=t.id,r=t.labelId,o=t.menuId,i=t.getItemId,s=t.toggleButtonId,a=t.inputId,l="downshift-"+y.useId();n||(n=l);var u=y.useRef({labelId:r||n+"-label",menuId:o||n+"-menu",getItemId:i||function(d){return n+"-item-"+d},toggleButtonId:s||n+"-toggle-button",inputId:a||n+"-input"});return u.current}:function(t){var n=t.id,r=n===void 0?"downshift-"+_u():n,o=t.labelId,i=t.menuId,s=t.getItemId,a=t.toggleButtonId,l=t.inputId,u=y.useRef({labelId:o||r+"-label",menuId:i||r+"-menu",getItemId:s||function(d){return r+"-item-"+d},toggleButtonId:a||r+"-toggle-button",inputId:l||r+"-input"});return u.current};function bw(e,t,n,r){var o,i;if(e===void 0){if(t===void 0)throw new Error(r);o=n[t],i=t}else i=t===void 0?n.indexOf(e):t,o=e;return[o,i]}function Js(e){return""+e.slice(0,1).toUpperCase()+e.slice(1)}function qu(e){var t=y.useRef(e);return t.current=e,t}function xw(e,t,n,r){var o=y.useRef(),i=y.useRef(),s=y.useCallback(function(m,w){i.current=w,m=to(m,w.props);var v=e(m,w),h=w.props.stateReducer(m,he({},w,{changes:v}));return h},[e]),a=y.useReducer(s,t,n),l=a[0],u=a[1],d=qu(t),f=y.useCallback(function(m){return u(he({props:d.current},m))},[d]),p=i.current;return y.useEffect(function(){var m=to(o.current,p==null?void 0:p.props),w=p&&o.current&&!r(m,l);w&&gw(p,m,l),o.current=l},[l,p,r]),[l,f]}var ri={itemToString:function(t){return t?String(t):""},itemToKey:function(t){return t},stateReducer:vw,scrollIntoView:xu,environment:typeof window>"u"?void 0:window};function jn(e,t,n){n===void 0&&(n=$u);var r=e["default"+Js(t)];return r!==void 0?r:n[t]}function ii(e,t,n){n===void 0&&(n=$u);var r=e[t];if(r!==void 0)return r;var o=e["initial"+Js(t)];return o!==void 0?o:jn(e,t,n)}function _w(e){var t=ii(e,"selectedItem"),n=ii(e,"isOpen"),r=Nw(e),o=ii(e,"inputValue");return{highlightedIndex:r<0&&t&&n?e.items.findIndex(function(i){return e.itemToKey(i)===e.itemToKey(t)}):r,isOpen:n,selectedItem:t,inputValue:o}}function oi(e,t,n){var r=e.items,o=e.initialHighlightedIndex,i=e.defaultHighlightedIndex,s=e.isItemDisabled,a=e.itemToKey,l=t.selectedItem,u=t.highlightedIndex;return r.length===0?-1:o!==void 0&&u===o&&!s(r[o],o)?o:i!==void 0&&!s(r[i],i)?i:l?r.findIndex(function(d){return a(l)===a(d)}):n<0&&!s(r[r.length-1],r.length-1)?r.length-1:n>0&&!s(r[0],0)?0:-1}function Cw(e,t,n){var r=y.useRef({isMouseDown:!1,isTouchMove:!1,isTouchEnd:!1});return y.useEffect(function(){if(!e)return bt;var o=n.map(function(d){return d.current});function i(){r.current.isTouchEnd=!1,r.current.isMouseDown=!0}function s(d){r.current.isMouseDown=!1,ro(d.target,o,e)||t()}function a(){r.current.isTouchEnd=!1,r.current.isTouchMove=!1}function l(){r.current.isTouchMove=!0}function u(d){r.current.isTouchEnd=!0,!r.current.isTouchMove&&!ro(d.target,o,e,!1)&&t()}return e.addEventListener("mousedown",i),e.addEventListener("mouseup",s),e.addEventListener("touchstart",a),e.addEventListener("touchmove",l),e.addEventListener("touchend",u),function(){e.removeEventListener("mousedown",i),e.removeEventListener("mouseup",s),e.removeEventListener("touchstart",a),e.removeEventListener("touchmove",l),e.removeEventListener("touchend",u)}},[n,e,t]),r.current}var Hu=function(){return bt};process.env.NODE_ENV!=="production"&&(Hu=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o=y.useRef(n.reduce(function(s,a){return s[a]={},s},{}));y.useEffect(function(){Object.keys(o.current).forEach(function(s){var a=o.current[s];if(!Object.keys(a).length){console.error("downshift: You forgot to call the "+s+" getter function on your component / element.");return}var l=a.suppressRefError,u=a.refKey,d=a.elementRef;l||d!=null&&d.current||console.error('downshift: The ref prop "'+u+'" from '+s+" was not applied correctly on your element.")})},[]);var i=y.useCallback(function(s,a,l,u){o.current[s]={suppressRefError:a,refKey:l,elementRef:u}},[]);return i});function Ow(e,t,n,r){r===void 0&&(r={});var o=r.document,i=yo();y.useEffect(function(){if(!(!e||i||!o)){var s=e(t);Ic(s,o)}},n),y.useEffect(function(){return function(){Ic.cancel(),aw(o)}},[o])}function Ew(e){var t=e.highlightedIndex,n=e.isOpen,r=e.itemRefs,o=e.getItemNodeFromIndex,i=e.menuElement,s=e.scrollIntoView,a=y.useRef(!0);return ww(function(){t<0||!n||!Object.keys(r.current).length||(a.current===!1?a.current=!0:s(o(t),i))},[t]),a}var Bu=bt;process.env.NODE_ENV!=="production"&&(Bu=function(t){var n=t.props,r=t.state,o=y.useRef(n),i=yo();y.useEffect(function(){i||(Bs(r,o.current,n),o.current=n)},[r,n,i])});function bc(e,t,n){var r;n===void 0&&(n=!0);var o=((r=e.items)==null?void 0:r.length)&&t>=0;return he({isOpen:!1,highlightedIndex:-1},o&&he({selectedItem:e.items[t],isOpen:jn(e,"isOpen"),highlightedIndex:jn(e,"highlightedIndex")},n&&{inputValue:e.itemToString(e.items[t])}))}function Sw(e,t){return e.isOpen===t.isOpen&&e.inputValue===t.inputValue&&e.highlightedIndex===t.highlightedIndex&&e.selectedItem===t.selectedItem}function yo(){var e=y.useRef(!0);return y.useEffect(function(){return e.current=!1,function(){e.current=!0}},[]),e.current}function _s(e){var t=jn(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}function Nw(e){var t=ii(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}var Ji={environment:K.shape({addEventListener:K.func.isRequired,removeEventListener:K.func.isRequired,document:K.shape({createElement:K.func.isRequired,getElementById:K.func.isRequired,activeElement:K.any.isRequired,body:K.any.isRequired}).isRequired,Node:K.func.isRequired}),itemToString:K.func,itemToKey:K.func,stateReducer:K.func},Ju=he({},Ji,{getA11yStatusMessage:K.func,highlightedIndex:K.number,defaultHighlightedIndex:K.number,initialHighlightedIndex:K.number,isOpen:K.bool,defaultIsOpen:K.bool,initialIsOpen:K.bool,selectedItem:K.any,initialSelectedItem:K.any,defaultSelectedItem:K.any,id:K.string,labelId:K.string,menuId:K.string,getItemId:K.func,toggleButtonId:K.string,onSelectedItemChange:K.func,onHighlightedIndexChange:K.func,onStateChange:K.func,onIsOpenChange:K.func,scrollIntoView:K.func});function Tw(e,t,n){var r=t.type,o=t.props,i;switch(r){case n.ItemMouseMove:i={highlightedIndex:t.disabled?-1:t.index};break;case n.MenuMouseLeave:i={highlightedIndex:-1};break;case n.ToggleButtonClick:case n.FunctionToggleMenu:i={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:oi(o,e,0)};break;case n.FunctionOpenMenu:i={isOpen:!0,highlightedIndex:oi(o,e,0)};break;case n.FunctionCloseMenu:i={isOpen:!1};break;case n.FunctionSetHighlightedIndex:i={highlightedIndex:o.isItemDisabled(o.items[t.highlightedIndex],t.highlightedIndex)?-1:t.highlightedIndex};break;case n.FunctionSetInputValue:i={inputValue:t.inputValue};break;case n.FunctionReset:i={highlightedIndex:_s(o),isOpen:jn(o,"isOpen"),selectedItem:jn(o,"selectedItem"),inputValue:jn(o,"inputValue")};break;default:throw new Error("Reducer called without proper action type.")}return he({},e,i)}Kr(Kr({},Ju),{items:K.array.isRequired,isItemDisabled:K.func});Kr(Kr({},ri),{isItemDisabled:function(){return!1}});process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;var Ws=process.env.NODE_ENV!=="production"?"__input_keydown_arrow_down__":0,zs=process.env.NODE_ENV!=="production"?"__input_keydown_arrow_up__":1,Gs=process.env.NODE_ENV!=="production"?"__input_keydown_escape__":2,Qs=process.env.NODE_ENV!=="production"?"__input_keydown_home__":3,Xs=process.env.NODE_ENV!=="production"?"__input_keydown_end__":4,Ys=process.env.NODE_ENV!=="production"?"__input_keydown_page_up__":5,Zs=process.env.NODE_ENV!=="production"?"__input_keydown_page_down__":6,ea=process.env.NODE_ENV!=="production"?"__input_keydown_enter__":7,ta=process.env.NODE_ENV!=="production"?"__input_change__":8,io=process.env.NODE_ENV!=="production"?"__input_blur__":9,na=process.env.NODE_ENV!=="production"?"__input_click__":10,Wu=process.env.NODE_ENV!=="production"?"__menu_mouse_leave__":11,zu=process.env.NODE_ENV!=="production"?"__item_mouse_move__":12,ra=process.env.NODE_ENV!=="production"?"__item_click__":13,Gu=process.env.NODE_ENV!=="production"?"__togglebutton_click__":14,Qu=process.env.NODE_ENV!=="production"?"__function_toggle_menu__":15,Xu=process.env.NODE_ENV!=="production"?"__function_open_menu__":16,Yu=process.env.NODE_ENV!=="production"?"__function_close_menu__":17,Zu=process.env.NODE_ENV!=="production"?"__function_set_highlighted_index__":18,ia=process.env.NODE_ENV!=="production"?"__function_select_item__":19,ed=process.env.NODE_ENV!=="production"?"__function_set_input_value__":20,td=process.env.NODE_ENV!=="production"?"__function_reset__":21,oa=process.env.NODE_ENV!=="production"?"__controlled_prop_updated_selected_item__":22,nd=Object.freeze({__proto__:null,ControlledPropUpdatedSelectedItem:oa,FunctionCloseMenu:Yu,FunctionOpenMenu:Xu,FunctionReset:td,FunctionSelectItem:ia,FunctionSetHighlightedIndex:Zu,FunctionSetInputValue:ed,FunctionToggleMenu:Qu,InputBlur:io,InputChange:ta,InputClick:na,InputKeyDownArrowDown:Ws,InputKeyDownArrowUp:zs,InputKeyDownEnd:Xs,InputKeyDownEnter:ea,InputKeyDownEscape:Gs,InputKeyDownHome:Qs,InputKeyDownPageDown:Zs,InputKeyDownPageUp:Ys,ItemClick:ra,ItemMouseMove:zu,MenuMouseLeave:Wu,ToggleButtonClick:Gu});function Rw(e){var t=_w(e),n=t.selectedItem,r=t.inputValue;return r===""&&n&&e.defaultInputValue===void 0&&e.initialInputValue===void 0&&e.inputValue===void 0&&(r=e.itemToString(n)),he({},t,{inputValue:r})}var Aw=he({},Ju,{items:K.array.isRequired,isItemDisabled:K.func,inputValue:K.string,defaultInputValue:K.string,initialInputValue:K.string,inputId:K.string,onInputValueChange:K.func});function Pw(e,t,n,r){var o=y.useRef(),i=xw(e,t,n,r),s=i[0],a=i[1],l=yo();return y.useEffect(function(){if(no(t,"selectedItem")){if(!l){var u=t.itemToKey(t.selectedItem)!==t.itemToKey(o.current);u&&a({type:oa,inputValue:t.itemToString(t.selectedItem)})}o.current=s.selectedItem===o.current?t.selectedItem:s.selectedItem}},[s.selectedItem,t.selectedItem]),[to(s,t),a]}var rd=bt;process.env.NODE_ENV!=="production"&&(rd=function(t,n){K.checkPropTypes(Aw,t,"prop",n.name)});var Fw=he({},ri,{isItemDisabled:function(){return!1}});function Dw(e,t){var n,r=t.type,o=t.props,i=t.altKey,s;switch(r){case ra:s={isOpen:jn(o,"isOpen"),highlightedIndex:_s(o),selectedItem:o.items[t.index],inputValue:o.itemToString(o.items[t.index])};break;case Ws:e.isOpen?s={highlightedIndex:Yn(e.highlightedIndex,1,o.items,o.isItemDisabled,!0)}:s={highlightedIndex:i&&e.selectedItem==null?-1:oi(o,e,1),isOpen:o.items.length>=0};break;case zs:e.isOpen?i?s=bc(o,e.highlightedIndex):s={highlightedIndex:Yn(e.highlightedIndex,-1,o.items,o.isItemDisabled,!0)}:s={highlightedIndex:oi(o,e,-1),isOpen:o.items.length>=0};break;case ea:s=bc(o,e.highlightedIndex);break;case Gs:s=he({isOpen:!1,highlightedIndex:-1},!e.isOpen&&{selectedItem:null,inputValue:""});break;case Ys:s={highlightedIndex:Yn(e.highlightedIndex,-10,o.items,o.isItemDisabled,!0)};break;case Zs:s={highlightedIndex:Yn(e.highlightedIndex,10,o.items,o.isItemDisabled,!0)};break;case Qs:s={highlightedIndex:Vr(0,!1,o.items,o.isItemDisabled)};break;case Xs:s={highlightedIndex:Vr(o.items.length-1,!0,o.items,o.isItemDisabled)};break;case io:s=he({isOpen:!1,highlightedIndex:-1},e.highlightedIndex>=0&&((n=o.items)==null?void 0:n.length)&&t.selectItem&&{selectedItem:o.items[e.highlightedIndex],inputValue:o.itemToString(o.items[e.highlightedIndex])});break;case ta:s={isOpen:!0,highlightedIndex:_s(o),inputValue:t.inputValue};break;case na:s={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:oi(o,e,0)};break;case ia:s={selectedItem:t.selectedItem,inputValue:o.itemToString(t.selectedItem)};break;case oa:s={inputValue:t.inputValue};break;default:return Tw(e,t,nd)}return he({},e,s)}var Mw=["onMouseLeave","refKey","ref"],kw=["item","index","refKey","ref","onMouseMove","onMouseDown","onClick","onPress","disabled"],jw=["onClick","onPress","refKey","ref"],Lw=["onKeyDown","onChange","onInput","onBlur","onChangeText","onClick","refKey","ref"];sa.stateChangeTypes=nd;function sa(e){e===void 0&&(e={}),rd(e,sa);var t=he({},Fw,e),n=t.items,r=t.scrollIntoView,o=t.environment,i=t.getA11yStatusMessage,s=Pw(Dw,t,Rw,Sw),a=s[0],l=s[1],u=a.isOpen,d=a.highlightedIndex,f=a.selectedItem,p=a.inputValue,m=y.useRef(null),w=y.useRef({}),v=y.useRef(null),h=y.useRef(null),x=yo(),g=Iw(t),b=y.useRef(),_=qu({state:a,props:t}),C=y.useCallback(function(U){return w.current[g.getItemId(U)]},[g]);Ow(i,a,[u,d,f,p],o);var R=Ew({menuElement:m.current,highlightedIndex:d,isOpen:u,itemRefs:w,scrollIntoView:r,getItemNodeFromIndex:C});Bu({props:t,state:a}),y.useEffect(function(){var U=ii(t,"isOpen");U&&v.current&&v.current.focus()},[]),y.useEffect(function(){x||(b.current=n.length)});var N=Cw(o,y.useCallback(function(){_.current.state.isOpen&&l({type:io,selectItem:!1})},[l,_]),y.useMemo(function(){return[m,h,v]},[m.current,h.current,v.current])),T=Hu("getInputProps","getMenuProps");y.useEffect(function(){u||(w.current={})},[u]),y.useEffect(function(){var U;!u||!(o!=null&&o.document)||!(v!=null&&(U=v.current)!=null&&U.focus)||o.document.activeElement!==v.current&&v.current.focus()},[u,o]);var F=y.useMemo(function(){return{ArrowDown:function(L){L.preventDefault(),l({type:Ws,altKey:L.altKey})},ArrowUp:function(L){L.preventDefault(),l({type:zs,altKey:L.altKey})},Home:function(L){_.current.state.isOpen&&(L.preventDefault(),l({type:Qs}))},End:function(L){_.current.state.isOpen&&(L.preventDefault(),l({type:Xs}))},Escape:function(L){var j=_.current.state;(j.isOpen||j.inputValue||j.selectedItem||j.highlightedIndex>-1)&&(L.preventDefault(),l({type:Gs}))},Enter:function(L){var j=_.current.state;!j.isOpen||L.which===229||(L.preventDefault(),l({type:ea}))},PageUp:function(L){_.current.state.isOpen&&(L.preventDefault(),l({type:Ys}))},PageDown:function(L){_.current.state.isOpen&&(L.preventDefault(),l({type:Zs}))}}},[l,_]),$=y.useCallback(function(U){return he({id:g.labelId,htmlFor:g.inputId},U)},[g]),G=y.useCallback(function(U,L){var j,D=U===void 0?{}:U,Y=D.onMouseLeave,Z=D.refKey,q=Z===void 0?"ref":Z,ee=D.ref,Q=mn(D,Mw),de=L===void 0?{}:L,M=de.suppressRefError,ve=M===void 0?!1:M;return T("getMenuProps",ve,q,m),he((j={},j[q]=Ir(ee,function(H){m.current=H}),j.id=g.menuId,j.role="listbox",j["aria-labelledby"]=Q&&Q["aria-label"]?void 0:""+g.labelId,j.onMouseLeave=Be(Y,function(){l({type:Wu})}),j),Q)},[l,T,g]),z=y.useCallback(function(U){var L,j,D=U===void 0?{}:U,Y=D.item,Z=D.index,q=D.refKey,ee=q===void 0?"ref":q,Q=D.ref,de=D.onMouseMove,M=D.onMouseDown,ve=D.onClick;D.onPress;var H=D.disabled,Ee=mn(D,kw);H!==void 0&&console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.');var Ve=_.current,Ye=Ve.props,Ue=Ve.state,Ie=bw(Y,Z,Ye.items,"Pass either item or index to getItemProps!"),Mt=Ie[0],Ze=Ie[1],vt=Ye.isItemDisabled(Mt,Ze),kt="onClick",jt=ve,et=function(){N.isTouchEnd||Ze===Ue.highlightedIndex||(R.current=!1,l({type:zu,index:Ze,disabled:vt}))},Ge=function(){l({type:ra,index:Ze})},$e=function(Lt){return Lt.preventDefault()};return he((L={},L[ee]=Ir(Q,function(Pe){Pe&&(w.current[g.getItemId(Ze)]=Pe)}),L["aria-disabled"]=vt,L["aria-selected"]=Ze===Ue.highlightedIndex,L.id=g.getItemId(Ze),L.role="option",L),!vt&&(j={},j[kt]=Be(jt,Ge),j),{onMouseMove:Be(de,et),onMouseDown:Be(M,$e)},Ee)},[l,g,_,N,R]),ne=y.useCallback(function(U){var L,j=U===void 0?{}:U,D=j.onClick;j.onPress;var Y=j.refKey,Z=Y===void 0?"ref":Y,q=j.ref,ee=mn(j,jw),Q=_.current.state,de=function(){l({type:Gu})};return he((L={},L[Z]=Ir(q,function(M){h.current=M}),L["aria-controls"]=g.menuId,L["aria-expanded"]=Q.isOpen,L.id=g.toggleButtonId,L.tabIndex=-1,L),!ee.disabled&&he({},{onClick:Be(D,de)}),ee)},[l,_,g]),B=y.useCallback(function(U,L){var j,D=U===void 0?{}:U,Y=D.onKeyDown,Z=D.onChange,q=D.onInput,ee=D.onBlur;D.onChangeText;var Q=D.onClick,de=D.refKey,M=de===void 0?"ref":de,ve=D.ref,H=mn(D,Lw),Ee=L===void 0?{}:L,Ve=Ee.suppressRefError,Ye=Ve===void 0?!1:Ve;T("getInputProps",Ye,M,v);var Ue=_.current.state,Ie=function($e){var Pe=bs($e);Pe&&F[Pe]&&F[Pe]($e)},Mt=function($e){l({type:ta,inputValue:$e.target.value})},Ze=function($e){if(o!=null&&o.document&&Ue.isOpen&&!N.isMouseDown){var Pe=$e.relatedTarget===null&&o.document.activeElement!==o.document.body;l({type:io,selectItem:!Pe})}},vt=function(){l({type:na})},kt="onChange",jt={};if(!H.disabled){var et;jt=(et={},et[kt]=Be(Z,q,Mt),et.onKeyDown=Be(Y,Ie),et.onBlur=Be(ee,Ze),et.onClick=Be(Q,vt),et)}return he((j={},j[M]=Ir(ve,function(Ge){v.current=Ge}),j["aria-activedescendant"]=Ue.isOpen&&Ue.highlightedIndex>-1?g.getItemId(Ue.highlightedIndex):"",j["aria-autocomplete"]="list",j["aria-controls"]=g.menuId,j["aria-expanded"]=Ue.isOpen,j["aria-labelledby"]=H&&H["aria-label"]?void 0:g.labelId,j.autoComplete="off",j.id=g.inputId,j.role="combobox",j.value=Ue.inputValue,j),jt,H)},[l,g,o,F,_,N,T]),ce=y.useCallback(function(){l({type:Qu})},[l]),se=y.useCallback(function(){l({type:Yu})},[l]),te=y.useCallback(function(){l({type:Xu})},[l]),ge=y.useCallback(function(U){l({type:Zu,highlightedIndex:U})},[l]),we=y.useCallback(function(U){l({type:ia,selectedItem:U})},[l]),A=y.useCallback(function(U){l({type:ed,inputValue:U})},[l]),k=y.useCallback(function(){l({type:td})},[l]);return{getItemProps:z,getLabelProps:$,getMenuProps:G,getInputProps:B,getToggleButtonProps:ne,toggleMenu:ce,openMenu:te,closeMenu:se,setHighlightedIndex:ge,setInputValue:A,selectItem:we,reset:k,highlightedIndex:d,isOpen:u,selectedItem:f,inputValue:p}}Ji.stateReducer,Ji.itemToKey,Ji.environment,K.array,K.array,K.array,K.func,K.number,K.number,K.number,K.func,K.func,K.string,K.string;ri.itemToKey,ri.stateReducer,ri.environment;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;process.env.NODE_ENV;const Kw="_comboboxContainer_1lcc8_1",Vw="_label_1lcc8_8",Uw="_inputContainer_1lcc8_12",$w="_input_1lcc8_12",qw="_toggleButton_1lcc8_33",Hw="_menu_1lcc8_39",Bw="_menuBottom_1lcc8_55",Jw="_menuTop_1lcc8_61",Ww="_menuItem_1lcc8_66",zw="_highlighted_1lcc8_73",Gw="_selected_1lcc8_77",Qw="_hidden_1lcc8_81",$t={comboboxContainer:Kw,label:Vw,inputContainer:Uw,input:$w,toggleButton:qw,menu:Hw,menuBottom:Bw,menuTop:Jw,menuItem:Ww,highlighted:zw,selected:Gw,hidden:Qw};function Xw(e){const t=e.toLowerCase();return function(r){return!e||r.label.toLowerCase().includes(t)||r.value.toLowerCase().includes(t)}}function id({items:e,selectedValue:t,onSelectedItemChange:n,placeholder:r,disabled:o,style:i,menuPosition:s="bottom"}){const[a,l]=y.useState(e),u=y.useRef(null);y.useEffect(()=>l(e),[e]);const d=y.useCallback(N=>{(N==null?void 0:N.length)>0?l(e.filter(Xw(N))):l(e)},[e]),{isOpen:f,getToggleButtonProps:p,getMenuProps:m,getInputProps:w,highlightedIndex:v,getItemProps:h,setInputValue:x,selectedItem:g}=sa({items:a,selectedItem:t?e.find(N=>N.value===t):null,itemToString:N=>(N==null?void 0:N.label)||"",onInputValueChange:({inputValue:N})=>d(N),onSelectedItemChange:({selectedItem:N})=>{var T;n(N),(T=u.current)==null||T.blur()}}),b=()=>{x(""),l(e)},_=()=>b(),C=y.useMemo(()=>{var N;return(N=e.find(T=>T.value===t))==null?void 0:N.label},[e,t]),R=()=>{t&&C&&t!==(g==null?void 0:g.value)&&x(C||"")};return c.jsxs("div",{style:{position:"relative",...i},children:[c.jsx("div",{className:$t.comboboxContainer,children:c.jsxs("div",{className:$t.inputContainer,children:[c.jsx("input",{style:{border:"none"},disabled:o,placeholder:r,className:$t.input,...w({onFocus:_,onBlur:R,ref:u})}),c.jsx("button",{style:{border:"none"},disabled:o,"aria-label":"toggle menu",className:$t.toggleButton,type:"button",...p(),children:f?c.jsx(c.Fragment,{children:"↑"}):c.jsx(c.Fragment,{children:"↓"})})]})}),c.jsx("ul",{className:`${$t.menu} ${f&&e.length?"":$t.hidden} ${s==="top"?$t.menuTop:$t.menuBottom}`,...m(),children:f&&a.map((N,T)=>c.jsx("li",{className:`${$t.menuItem} ${v===T?$t.highlighted:""} ${t===(N==null?void 0:N.value)?$t.selected:""}`,...h({item:N,index:T}),children:c.jsx("span",{children:N.label})},N.id))})]})}const Ur=Math.min,ar=Math.max,oo=Math.round,Vi=Math.floor,Vn=e=>({x:e,y:e}),Yw={left:"right",right:"left",bottom:"top",top:"bottom"},Zw={start:"end",end:"start"};function Cs(e,t,n){return ar(e,Ur(t,n))}function wi(e,t){return typeof e=="function"?e(t):e}function hr(e){return e.split("-")[0]}function Ii(e){return e.split("-")[1]}function od(e){return e==="x"?"y":"x"}function aa(e){return e==="y"?"height":"width"}function $r(e){return["top","bottom"].includes(hr(e))?"y":"x"}function ca(e){return od($r(e))}function eI(e,t,n){n===void 0&&(n=!1);const r=Ii(e),o=ca(e),i=aa(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=so(s)),[s,so(s)]}function tI(e){const t=so(e);return[Os(e),t,Os(t)]}function Os(e){return e.replace(/start|end/g,t=>Zw[t])}function nI(e,t,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:s;default:return[]}}function rI(e,t,n,r){const o=Ii(e);let i=nI(hr(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(Os)))),i}function so(e){return e.replace(/left|right|bottom|top/g,t=>Yw[t])}function iI(e){return{top:0,right:0,bottom:0,left:0,...e}}function sd(e){return typeof e!="number"?iI(e):{top:e,right:e,bottom:e,left:e}}function ao(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function xc(e,t,n){let{reference:r,floating:o}=e;const i=$r(t),s=ca(t),a=aa(s),l=hr(t),u=i==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let m;switch(l){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(Ii(t)){case"start":m[s]-=p*(n&&u?-1:1);break;case"end":m[s]+=p*(n&&u?-1:1);break}return m}const oI=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,a=i.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(t));let u=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=xc(u,r,l),p=r,m={},w=0;for(let v=0;v<a.length;v++){const{name:h,fn:x}=a[v],{x:g,y:b,data:_,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:p,strategy:o,middlewareData:m,rects:u,platform:s,elements:{reference:e,floating:t}});d=g??d,f=b??f,m={...m,[h]:{...m[h],..._}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(u=C.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=xc(u,p,l)),v=-1)}return{x:d,y:f,placement:p,strategy:o,middlewareData:m}};async function ad(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=wi(t,e),w=sd(m),h=a[p?f==="floating"?"reference":"floating":f],x=ao(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(h)))==null||n?h:h.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),g=f==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,b=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),_=await(i.isElement==null?void 0:i.isElement(b))?await(i.getScale==null?void 0:i.getScale(b))||{x:1,y:1}:{x:1,y:1},C=ao(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:g,offsetParent:b,strategy:l}):g);return{top:(x.top-C.top+w.top)/_.y,bottom:(C.bottom-x.bottom+w.bottom)/_.y,left:(x.left-C.left+w.left)/_.x,right:(C.right-x.right+w.right)/_.x}}const sI=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=wi(e,t)||{};if(u==null)return{};const f=sd(d),p={x:n,y:r},m=ca(o),w=aa(m),v=await s.getDimensions(u),h=m==="y",x=h?"top":"left",g=h?"bottom":"right",b=h?"clientHeight":"clientWidth",_=i.reference[w]+i.reference[m]-p[m]-i.floating[w],C=p[m]-i.reference[m],R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(u));let N=R?R[b]:0;(!N||!await(s.isElement==null?void 0:s.isElement(R)))&&(N=a.floating[b]||i.floating[w]);const T=_/2-C/2,F=N/2-v[w]/2-1,$=Ur(f[x],F),G=Ur(f[g],F),z=$,ne=N-v[w]-G,B=N/2-v[w]/2+T,ce=Cs(z,B,ne),se=!l.arrow&&Ii(o)!=null&&B!==ce&&i.reference[w]/2-(B<z?$:G)-v[w]/2<0,te=se?B<z?B-z:B-ne:0;return{[m]:p[m]+te,data:{[m]:ce,centerOffset:B-ce-te,...se&&{alignmentOffset:te}},reset:se}}}),aI=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:v=!0,...h}=wi(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const x=hr(o),g=$r(a),b=hr(a)===a,_=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=p||(b||!v?[so(a)]:tI(a)),R=w!=="none";!p&&R&&C.push(...rI(a,v,w,_));const N=[a,...C],T=await ad(t,h),F=[];let $=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&F.push(T[x]),f){const B=eI(o,s,_);F.push(T[B[0]],T[B[1]])}if($=[...$,{placement:o,overflows:F}],!F.every(B=>B<=0)){var G,z;const B=(((G=i.flip)==null?void 0:G.index)||0)+1,ce=N[B];if(ce)return{data:{index:B,overflows:$},reset:{placement:ce}};let se=(z=$.filter(te=>te.overflows[0]<=0).sort((te,ge)=>te.overflows[1]-ge.overflows[1])[0])==null?void 0:z.placement;if(!se)switch(m){case"bestFit":{var ne;const te=(ne=$.filter(ge=>{if(R){const we=$r(ge.placement);return we===g||we==="y"}return!0}).map(ge=>[ge.placement,ge.overflows.filter(we=>we>0).reduce((we,A)=>we+A,0)]).sort((ge,we)=>ge[1]-we[1])[0])==null?void 0:ne[0];te&&(se=te);break}case"initialPlacement":se=a;break}if(o!==se)return{reset:{placement:se}}}return{}}}};async function cI(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=hr(n),a=Ii(n),l=$r(n)==="y",u=["left","top"].includes(s)?-1:1,d=i&&l?-1:1,f=wi(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(m=a==="end"?w*-1:w),l?{x:m*d,y:p*u}:{x:p*u,y:m*d}}const lI=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:a}=t,l=await cI(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:i+l.y,data:{...l,placement:s}}}}},uI=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:a={fn:h=>{let{x,y:g}=h;return{x,y:g}}},...l}=wi(e,t),u={x:n,y:r},d=await ad(t,l),f=$r(hr(o)),p=od(f);let m=u[p],w=u[f];if(i){const h=p==="y"?"top":"left",x=p==="y"?"bottom":"right",g=m+d[h],b=m-d[x];m=Cs(g,m,b)}if(s){const h=f==="y"?"top":"left",x=f==="y"?"bottom":"right",g=w+d[h],b=w-d[x];w=Cs(g,w,b)}const v=a.fn({...t,[p]:m,[f]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[p]:i,[f]:s}}}}}};function vo(){return typeof window<"u"}function Qr(e){return cd(e)?(e.nodeName||"").toLowerCase():"#document"}function xt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function on(e){var t;return(t=(cd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function cd(e){return vo()?e instanceof Node||e instanceof xt(e).Node:!1}function zt(e){return vo()?e instanceof Element||e instanceof xt(e).Element:!1}function rn(e){return vo()?e instanceof HTMLElement||e instanceof xt(e).HTMLElement:!1}function _c(e){return!vo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof xt(e).ShadowRoot}function bi(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Gt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function dI(e){return["table","td","th"].includes(Qr(e))}function wo(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function la(e){const t=ua(),n=zt(e)?Gt(e):e;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function fI(e){let t=Un(e);for(;rn(t)&&!qr(t);){if(la(t))return t;if(wo(t))return null;t=Un(t)}return null}function ua(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function qr(e){return["html","body","#document"].includes(Qr(e))}function Gt(e){return xt(e).getComputedStyle(e)}function Io(e){return zt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Un(e){if(Qr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||_c(e)&&e.host||on(e);return _c(t)?t.host:t}function ld(e){const t=Un(e);return qr(t)?e.ownerDocument?e.ownerDocument.body:e.body:rn(t)&&bi(t)?t:ld(t)}function di(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ld(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=xt(o);if(i){const a=Es(s);return t.concat(s,s.visualViewport||[],bi(o)?o:[],a&&n?di(a):[])}return t.concat(o,di(o,[],n))}function Es(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ud(e){const t=Gt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=rn(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=oo(n)!==i||oo(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function da(e){return zt(e)?e:e.contextElement}function xr(e){const t=da(e);if(!rn(t))return Vn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=ud(t);let s=(i?oo(n.width):n.width)/r,a=(i?oo(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const pI=Vn(0);function dd(e){const t=xt(e);return!ua()||!t.visualViewport?pI:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function hI(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==xt(e)?!1:t}function mr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=da(e);let s=Vn(1);t&&(r?zt(r)&&(s=xr(r)):s=xr(e));const a=hI(i,n,r)?dd(i):Vn(0);let l=(o.left+a.x)/s.x,u=(o.top+a.y)/s.y,d=o.width/s.x,f=o.height/s.y;if(i){const p=xt(i),m=r&&zt(r)?xt(r):r;let w=p,v=Es(w);for(;v&&r&&m!==w;){const h=xr(v),x=v.getBoundingClientRect(),g=Gt(v),b=x.left+(v.clientLeft+parseFloat(g.paddingLeft))*h.x,_=x.top+(v.clientTop+parseFloat(g.paddingTop))*h.y;l*=h.x,u*=h.y,d*=h.x,f*=h.y,l+=b,u+=_,w=xt(v),v=Es(w)}}return ao({width:d,height:f,x:l,y:u})}function mI(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=on(r),a=t?wo(t.floating):!1;if(r===s||a&&i)return n;let l={scrollLeft:0,scrollTop:0},u=Vn(1);const d=Vn(0),f=rn(r);if((f||!f&&!i)&&((Qr(r)!=="body"||bi(s))&&(l=Io(r)),rn(r))){const p=mr(r);u=xr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x,y:n.y*u.y-l.scrollTop*u.y+d.y}}function gI(e){return Array.from(e.getClientRects())}function Ss(e,t){const n=Io(e).scrollLeft;return t?t.left+n:mr(on(e)).left+n}function yI(e){const t=on(e),n=Io(e),r=e.ownerDocument.body,o=ar(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=ar(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+Ss(e);const a=-n.scrollTop;return Gt(r).direction==="rtl"&&(s+=ar(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function vI(e,t){const n=xt(e),r=on(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,a=0,l=0;if(o){i=o.width,s=o.height;const u=ua();(!u||u&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:i,height:s,x:a,y:l}}function wI(e,t){const n=mr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=rn(e)?xr(e):Vn(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,l=o*i.x,u=r*i.y;return{width:s,height:a,x:l,y:u}}function Cc(e,t,n){let r;if(t==="viewport")r=vI(e,n);else if(t==="document")r=yI(on(e));else if(zt(t))r=wI(t,n);else{const o=dd(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return ao(r)}function fd(e,t){const n=Un(e);return n===t||!zt(n)||qr(n)?!1:Gt(n).position==="fixed"||fd(n,t)}function II(e,t){const n=t.get(e);if(n)return n;let r=di(e,[],!1).filter(a=>zt(a)&&Qr(a)!=="body"),o=null;const i=Gt(e).position==="fixed";let s=i?Un(e):e;for(;zt(s)&&!qr(s);){const a=Gt(s),l=la(s);!l&&a.position==="fixed"&&(o=null),(i?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||bi(s)&&!l&&fd(e,s))?r=r.filter(d=>d!==s):o=a,s=Un(s)}return t.set(e,r),r}function bI(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?wo(t)?[]:II(t,this._c):[].concat(n),r],a=s[0],l=s.reduce((u,d)=>{const f=Cc(t,d,o);return u.top=ar(f.top,u.top),u.right=Ur(f.right,u.right),u.bottom=Ur(f.bottom,u.bottom),u.left=ar(f.left,u.left),u},Cc(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function xI(e){const{width:t,height:n}=ud(e);return{width:t,height:n}}function _I(e,t,n){const r=rn(t),o=on(t),i=n==="fixed",s=mr(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const l=Vn(0);if(r||!r&&!i)if((Qr(t)!=="body"||bi(o))&&(a=Io(t)),r){const m=mr(t,!0,i,t);l.x=m.x+t.clientLeft,l.y=m.y+t.clientTop}else o&&(l.x=Ss(o));let u=0,d=0;if(o&&!r&&!i){const m=o.getBoundingClientRect();d=m.top+a.scrollTop,u=m.left+a.scrollLeft-Ss(o,m)}const f=s.left+a.scrollLeft-l.x-u,p=s.top+a.scrollTop-l.y-d;return{x:f,y:p,width:s.width,height:s.height}}function Ho(e){return Gt(e).position==="static"}function Oc(e,t){if(!rn(e)||Gt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return on(e)===n&&(n=n.ownerDocument.body),n}function pd(e,t){const n=xt(e);if(wo(e))return n;if(!rn(e)){let o=Un(e);for(;o&&!qr(o);){if(zt(o)&&!Ho(o))return o;o=Un(o)}return n}let r=Oc(e,t);for(;r&&dI(r)&&Ho(r);)r=Oc(r,t);return r&&qr(r)&&Ho(r)&&!la(r)?n:r||fI(e)||n}const CI=async function(e){const t=this.getOffsetParent||pd,n=this.getDimensions,r=await n(e.floating);return{reference:_I(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function OI(e){return Gt(e).direction==="rtl"}const EI={convertOffsetParentRelativeRectToViewportRelativeRect:mI,getDocumentElement:on,getClippingRect:bI,getOffsetParent:pd,getElementRects:CI,getClientRects:gI,getDimensions:xI,getScale:xr,isElement:zt,isRTL:OI};function SI(e,t){let n=null,r;const o=on(e);function i(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function s(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const{left:u,top:d,width:f,height:p}=e.getBoundingClientRect();if(a||t(),!f||!p)return;const m=Vi(d),w=Vi(o.clientWidth-(u+f)),v=Vi(o.clientHeight-(d+p)),h=Vi(u),g={rootMargin:-m+"px "+-w+"px "+-v+"px "+-h+"px",threshold:ar(0,Ur(1,l))||1};let b=!0;function _(C){const R=C[0].intersectionRatio;if(R!==l){if(!b)return s();R?s(!1,R):r=setTimeout(()=>{s(!1,1e-7)},1e3)}b=!1}try{n=new IntersectionObserver(_,{...g,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,g)}n.observe(e)}return s(!0),i}function NI(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=da(e),d=o||i?[...u?di(u):[],...di(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),i&&x.addEventListener("resize",n)});const f=u&&a?SI(u,n):null;let p=-1,m=null;s&&(m=new ResizeObserver(x=>{let[g]=x;g&&g.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var b;(b=m)==null||b.observe(t)})),n()}),u&&!l&&m.observe(u),m.observe(t));let w,v=l?mr(e):null;l&&h();function h(){const x=mr(e);v&&(x.x!==v.x||x.y!==v.y||x.width!==v.width||x.height!==v.height)&&n(),v=x,w=requestAnimationFrame(h)}return n(),()=>{var x;d.forEach(g=>{o&&g.removeEventListener("scroll",n),i&&g.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,l&&cancelAnimationFrame(w)}}const TI=lI,RI=uI,AI=aI,PI=sI,Ec=(e,t,n)=>{const r=new Map,o={platform:EI,...n},i={...o.platform,_c:r};return oI(e,t,{...o,platform:i})};/*
|
|
46
46
|
* React Tooltip
|
|
47
47
|
* {@link https://github.com/ReactTooltip/react-tooltip}
|
|
48
48
|
* @copyright ReactTooltip Team
|
|
49
49
|
* @license MIT
|
|
50
|
-
*/const Gw="react-tooltip-core-styles",Qw="react-tooltip-base-styles",Ec={core:!1,base:!1};function Sc({css:e,id:t=Qw,type:n="base",ref:r}){var o,i;if(!e||typeof document>"u"||Ec[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=Gw),r||(r={});const{insertAt:s}=r;if(document.getElementById(t))return;const a=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.id=t,l.type="text/css",s==="top"&&a.firstChild?a.insertBefore(l,a.firstChild):a.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e)),Ec[n]=!0}const Nc=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:r="top",offset:o=10,strategy:i="absolute",middlewares:s=[Bw(Number(o)),Jw({fallbackAxisSideDirection:"start"}),Ww({padding:5})],border:a})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};if(t===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};const l=s;return n?(l.push(zw({element:n,padding:5})),Oc(e,t,{placement:r,strategy:i,middleware:l}).then(({x:u,y:d,placement:f,middlewareData:p})=>{var m,w;const v={left:`${u}px`,top:`${d}px`,border:a},{x:h,y:x}=(m=p.arrow)!==null&&m!==void 0?m:{x:0,y:0},g=(w={top:"bottom",right:"left",bottom:"top",left:"right"}[f.split("-")[0]])!==null&&w!==void 0?w:"bottom",b=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:h!=null?`${h}px`:"",top:x!=null?`${x}px`:"",right:"",bottom:"",...b,[g]:`-${4+_}px`},place:f}})):Oc(e,t,{placement:"bottom",strategy:i,middleware:l}).then(({x:u,y:d,placement:f})=>({tooltipStyles:{left:`${u}px`,top:`${d}px`},tooltipArrowStyles:{},place:f}))},Tc=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),Rc=(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},Ac=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(!Ac(e)||!Ac(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]))},Xw=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"})},Pc=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(Xw(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},Yw=typeof window<"u"?y.useLayoutEffect:y.useEffect,Tt=e=>{e.current&&(clearTimeout(e.current),e.current=null)},Zw="DEFAULT_TOOLTIP_ID",eI={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},tI=y.createContext({getTooltipData:()=>eI});function ud(e=Zw){return y.useContext(tI).getTooltipData(e)}var wr={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"},Bo={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:l=10,events:u=["hover"],openOnClick:d=!1,positionStrategy:f="absolute",middlewares:p,wrapper:m,delayShow:w=0,delayHide:v=0,float:h=!1,hidden:x=!1,noArrow:g=!1,clickable:b=!1,closeOnEsc:_=!1,closeOnScroll:C=!1,closeOnResize:T=!1,openEvents:S,closeEvents:N,globalCloseEvents:D,imperativeModeOnly:U,style:G,position:z,afterShow:ne,afterHide:B,disableTooltip:ce,content:se,contentWrapperRef:te,isOpen:ge,defaultIsOpen:we=!1,setIsOpen:A,activeAnchor:j,setActiveAnchor:$,border:L,opacity:k,arrowColor:F,role:Y="tooltip"})=>{var Z;const q=y.useRef(null),ee=y.useRef(null),Q=y.useRef(null),de=y.useRef(null),M=y.useRef(null),[ve,H]=y.useState({tooltipStyles:{},tooltipArrowStyles:{},place:a}),[Ee,Ve]=y.useState(!1),[Xe,$e]=y.useState(!1),[Ie,Ft]=y.useState(null),Ye=y.useRef(!1),yt=y.useRef(null),{anchorRefs:Mt,setActiveAnchor:jt}=ud(t),Ze=y.useRef(!1),[ze,Ue]=y.useState([]),Pe=y.useRef(!1),kt=d||u.includes("click"),rt=kt||(S==null?void 0:S.click)||(S==null?void 0:S.dblclick)||(S==null?void 0:S.mousedown),on=S?{...S}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!S&&kt&&Object.assign(on,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const wn=N?{...N}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!N&&kt&&Object.assign(wn,{mouseleave:!1,blur:!1,mouseout:!1});const vt=D?{...D}:{escape:_||!1,scroll:C||!1,resize:T||!1,clickOutsideAnchor:rt||!1};U&&(Object.assign(on,{mouseenter:!1,focus:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(wn,{mouseleave:!1,blur:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(vt,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),Yw(()=>(Pe.current=!0,()=>{Pe.current=!1}),[]);const De=W=>{Pe.current&&(W&&$e(!0),setTimeout(()=>{Pe.current&&(A==null||A(W),ge===void 0&&Ve(W))},10))};y.useEffect(()=>{if(ge===void 0)return()=>null;ge&&$e(!0);const W=setTimeout(()=>{Ve(ge)},10);return()=>{clearTimeout(W)}},[ge]),y.useEffect(()=>{if(Ee!==Ye.current)if(Tt(M),Ye.current=Ee,Ee)ne==null||ne();else{const W=(ae=>{const le=ae.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"));M.current=setTimeout(()=>{$e(!1),Ft(null),B==null||B()},W+25)}},[Ee]);const sn=W=>{H(ae=>Ns(ae,W)?ae:W)},In=(W=w)=>{Tt(Q),Xe?De(!0):Q.current=setTimeout(()=>{De(!0)},W)},an=(W=v)=>{Tt(de),de.current=setTimeout(()=>{Ze.current||De(!1)},W)},qn=W=>{var ae;if(!W)return;const le=(ae=W.currentTarget)!==null&&ae!==void 0?ae:W.target;if(!(le!=null&&le.isConnected))return $(null),void jt({current:null});w?In():De(!0),$(le),jt({current:le}),Tt(de)},dt=()=>{b?an(v||100):v?an():De(!1),Tt(Q)},cn=({x:W,y:ae})=>{var le;const Ke={getBoundingClientRect:()=>({x:W,y:ae,width:0,height:0,top:ae,left:W,right:W,bottom:ae})};Nc({place:(le=Ie==null?void 0:Ie.place)!==null&&le!==void 0?le:a,offset:l,elementReference:Ke,tooltipReference:q.current,tooltipArrowReference:ee.current,strategy:f,middlewares:p,border:L}).then(He=>{sn(He)})},bn=W=>{if(!W)return;const ae=W,le={x:ae.clientX,y:ae.clientY};cn(le),yt.current=le},Hn=W=>{var ae;if(!Ee)return;const le=W.target;le.isConnected&&(!((ae=q.current)===null||ae===void 0)&&ae.contains(le)||[document.querySelector(`[id='${i}']`),...ze].some(Ke=>Ke==null?void 0:Ke.contains(le))||(De(!1),Tt(Q)))},xn=Rc(qn,50),Ae=Rc(dt,50),it=W=>{Ae.cancel(),xn(W)},ie=()=>{xn.cancel(),Ae()},me=y.useCallback(()=>{var W,ae;const le=(W=Ie==null?void 0:Ie.position)!==null&&W!==void 0?W:z;le?cn(le):h?yt.current&&cn(yt.current):j!=null&&j.isConnected&&Nc({place:(ae=Ie==null?void 0:Ie.place)!==null&&ae!==void 0?ae:a,offset:l,elementReference:j,tooltipReference:q.current,tooltipArrowReference:ee.current,strategy:f,middlewares:p,border:L}).then(Ke=>{Pe.current&&sn(Ke)})},[Ee,j,se,G,a,Ie==null?void 0:Ie.place,l,f,z,Ie==null?void 0:Ie.position,h]);y.useEffect(()=>{var W,ae;const le=new Set(Mt);ze.forEach(Se=>{ce!=null&&ce(Se)||le.add({current:Se})});const Ke=document.querySelector(`[id='${i}']`);Ke&&!(ce!=null&&ce(Ke))&&le.add({current:Ke});const He=()=>{De(!1)},ft=Pc(j),Ge=Pc(q.current);vt.scroll&&(window.addEventListener("scroll",He),ft==null||ft.addEventListener("scroll",He),Ge==null||Ge.addEventListener("scroll",He));let et=null;vt.resize?window.addEventListener("resize",He):j&&q.current&&(et=Hw(j,q.current,me,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const pt=Se=>{Se.key==="Escape"&&De(!1)};vt.escape&&window.addEventListener("keydown",pt),vt.clickOutsideAnchor&&window.addEventListener("click",Hn);const Ne=[],Bn=Se=>{Ee&&(Se==null?void 0:Se.target)===j||qn(Se)},So=Se=>{Ee&&(Se==null?void 0:Se.target)===j&&dt()},Et=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],xi=["click","dblclick","mousedown","mouseup"];Object.entries(on).forEach(([Se,Lt])=>{Lt&&(Et.includes(Se)?Ne.push({event:Se,listener:it}):xi.includes(Se)&&Ne.push({event:Se,listener:Bn}))}),Object.entries(wn).forEach(([Se,Lt])=>{Lt&&(Et.includes(Se)?Ne.push({event:Se,listener:ie}):xi.includes(Se)&&Ne.push({event:Se,listener:So}))}),h&&Ne.push({event:"pointermove",listener:bn});const _i=()=>{Ze.current=!0},Ci=()=>{Ze.current=!1,dt()};return b&&!rt&&((W=q.current)===null||W===void 0||W.addEventListener("mouseenter",_i),(ae=q.current)===null||ae===void 0||ae.addEventListener("mouseleave",Ci)),Ne.forEach(({event:Se,listener:Lt})=>{le.forEach(Kt=>{var Wn;(Wn=Kt.current)===null||Wn===void 0||Wn.addEventListener(Se,Lt)})}),()=>{var Se,Lt;vt.scroll&&(window.removeEventListener("scroll",He),ft==null||ft.removeEventListener("scroll",He),Ge==null||Ge.removeEventListener("scroll",He)),vt.resize?window.removeEventListener("resize",He):et==null||et(),vt.clickOutsideAnchor&&window.removeEventListener("click",Hn),vt.escape&&window.removeEventListener("keydown",pt),b&&!rt&&((Se=q.current)===null||Se===void 0||Se.removeEventListener("mouseenter",_i),(Lt=q.current)===null||Lt===void 0||Lt.removeEventListener("mouseleave",Ci)),Ne.forEach(({event:Kt,listener:Wn})=>{le.forEach(No=>{var Xr;(Xr=No.current)===null||Xr===void 0||Xr.removeEventListener(Kt,Wn)})})}},[j,me,Xe,Mt,ze,S,N,D,kt,w,v]),y.useEffect(()=>{var W,ae;let le=(ae=(W=Ie==null?void 0:Ie.anchorSelect)!==null&&W!==void 0?W:s)!==null&&ae!==void 0?ae:"";!le&&t&&(le=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const Ke=new MutationObserver(He=>{const ft=[],Ge=[];He.forEach(et=>{if(et.type==="attributes"&&et.attributeName==="data-tooltip-id"&&(et.target.getAttribute("data-tooltip-id")===t?ft.push(et.target):et.oldValue===t&&Ge.push(et.target)),et.type==="childList"){if(j){const pt=[...et.removedNodes].filter(Ne=>Ne.nodeType===1);if(le)try{Ge.push(...pt.filter(Ne=>Ne.matches(le))),Ge.push(...pt.flatMap(Ne=>[...Ne.querySelectorAll(le)]))}catch{}pt.some(Ne=>{var Bn;return!!(!((Bn=Ne==null?void 0:Ne.contains)===null||Bn===void 0)&&Bn.call(Ne,j))&&($e(!1),De(!1),$(null),Tt(Q),Tt(de),!0)})}if(le)try{const pt=[...et.addedNodes].filter(Ne=>Ne.nodeType===1);ft.push(...pt.filter(Ne=>Ne.matches(le))),ft.push(...pt.flatMap(Ne=>[...Ne.querySelectorAll(le)]))}catch{}}}),(ft.length||Ge.length)&&Ue(et=>[...et.filter(pt=>!Ge.includes(pt)),...ft])});return Ke.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{Ke.disconnect()}},[t,s,Ie==null?void 0:Ie.anchorSelect,j]),y.useEffect(()=>{me()},[me]),y.useEffect(()=>{if(!(te!=null&&te.current))return()=>null;const W=new ResizeObserver(()=>{setTimeout(()=>me())});return W.observe(te.current),()=>{W.disconnect()}},[se,te==null?void 0:te.current]),y.useEffect(()=>{var W;const ae=document.querySelector(`[id='${i}']`),le=[...ze,ae];j&&le.includes(j)||$((W=ze[0])!==null&&W!==void 0?W:ae)},[i,ze,j]),y.useEffect(()=>(we&&De(!0),()=>{Tt(Q),Tt(de)}),[]),y.useEffect(()=>{var W;let ae=(W=Ie==null?void 0:Ie.anchorSelect)!==null&&W!==void 0?W:s;if(!ae&&t&&(ae=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),ae)try{const le=Array.from(document.querySelectorAll(ae));Ue(le)}catch{Ue([])}},[t,s,Ie==null?void 0:Ie.anchorSelect]),y.useEffect(()=>{Q.current&&(Tt(Q),In(w))},[w]);const qe=(Z=Ie==null?void 0:Ie.content)!==null&&Z!==void 0?Z:se,ln=Ee&&Object.keys(ve.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`)}Ft(W??null),W!=null&&W.delay?In(W.delay):De(!0)},close:W=>{W!=null&&W.delay?an(W.delay):De(!1)},activeAnchor:j,place:ve.place,isOpen:!!(Xe&&!x&&qe&&ln)})),Xe&&!x&&qe?y.createElement(m,{id:t,role:Y,className:Pt("react-tooltip",wr.tooltip,Bo.tooltip,Bo[o],n,`react-tooltip__place-${ve.place}`,wr[ln?"show":"closing"],ln?"react-tooltip__show":"react-tooltip__closing",f==="fixed"&&wr.fixed,b&&wr.clickable),onTransitionEnd:W=>{Tt(M),Ee||W.propertyName!=="opacity"||($e(!1),Ft(null),B==null||B())},style:{...G,...ve.tooltipStyles,opacity:k!==void 0&&ln?k:void 0},ref:q},qe,y.createElement(m,{className:Pt("react-tooltip-arrow",wr.arrow,Bo.arrow,r,g&&wr.noArrow),style:{...ve.tooltipArrowStyles,background:F?`linear-gradient(to right bottom, transparent 50%, ${F} 50%)`:void 0},ref:ee})):null},rI=({content:e})=>y.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),iI=y.forwardRef(({id:e,anchorId:t,anchorSelect:n,content:r,html:o,render:i,className:s,classNameArrow:a,variant:l="dark",place:u="top",offset:d=10,wrapper:f="div",children:p=null,events:m=["hover"],openOnClick:w=!1,positionStrategy:v="absolute",middlewares:h,delayShow:x=0,delayHide:g=0,float:b=!1,hidden:_=!1,noArrow:C=!1,clickable:T=!1,closeOnEsc:S=!1,closeOnScroll:N=!1,closeOnResize:D=!1,openEvents:U,closeEvents:G,globalCloseEvents:z,imperativeModeOnly:ne=!1,style:B,position:ce,isOpen:se,defaultIsOpen:te=!1,disableStyleInjection:ge=!1,border:we,opacity:A,arrowColor:j,setIsOpen:$,afterShow:L,afterHide:k,disableTooltip:F,role:Y="tooltip"},Z)=>{const[q,ee]=y.useState(r),[Q,de]=y.useState(o),[M,ve]=y.useState(u),[H,Ee]=y.useState(l),[Ve,Xe]=y.useState(d),[$e,Ie]=y.useState(x),[Ft,Ye]=y.useState(g),[yt,Mt]=y.useState(b),[jt,Ze]=y.useState(_),[ze,Ue]=y.useState(f),[Pe,kt]=y.useState(m),[rt,on]=y.useState(v),[wn,vt]=y.useState(null),[De,sn]=y.useState(null),In=y.useRef(ge),{anchorRefs:an,activeAnchor:qn}=ud(e),dt=Ae=>Ae==null?void 0:Ae.getAttributeNames().reduce((it,ie)=>{var me;return ie.startsWith("data-tooltip-")&&(it[ie.replace(/^data-tooltip-/,"")]=(me=Ae==null?void 0:Ae.getAttribute(ie))!==null&&me!==void 0?me:null),it},{}),cn=Ae=>{const it={place:ie=>{var me;ve((me=ie)!==null&&me!==void 0?me:u)},content:ie=>{ee(ie??r)},html:ie=>{de(ie??o)},variant:ie=>{var me;Ee((me=ie)!==null&&me!==void 0?me:l)},offset:ie=>{Xe(ie===null?d:Number(ie))},wrapper:ie=>{var me;Ue((me=ie)!==null&&me!==void 0?me:f)},events:ie=>{const me=ie==null?void 0:ie.split(" ");kt(me??m)},"position-strategy":ie=>{var me;on((me=ie)!==null&&me!==void 0?me:v)},"delay-show":ie=>{Ie(ie===null?x:Number(ie))},"delay-hide":ie=>{Ye(ie===null?g:Number(ie))},float:ie=>{Mt(ie===null?b:ie==="true")},hidden:ie=>{Ze(ie===null?_:ie==="true")},"class-name":ie=>{vt(ie)}};Object.values(it).forEach(ie=>ie(null)),Object.entries(Ae).forEach(([ie,me])=>{var qe;(qe=it[ie])===null||qe===void 0||qe.call(it,me)})};y.useEffect(()=>{ee(r)},[r]),y.useEffect(()=>{de(o)},[o]),y.useEffect(()=>{ve(u)},[u]),y.useEffect(()=>{Ee(l)},[l]),y.useEffect(()=>{Xe(d)},[d]),y.useEffect(()=>{Ie(x)},[x]),y.useEffect(()=>{Ye(g)},[g]),y.useEffect(()=>{Mt(b)},[b]),y.useEffect(()=>{Ze(_)},[_]),y.useEffect(()=>{on(v)},[v]),y.useEffect(()=>{In.current!==ge&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")},[ge]),y.useEffect(()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:ge==="core",disableBase:ge}}))},[]),y.useEffect(()=>{var Ae;const it=new Set(an);let ie=n;if(!ie&&e&&(ie=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),ie)try{document.querySelectorAll(ie).forEach(ae=>{it.add({current:ae})})}catch{console.warn(`[react-tooltip] "${ie}" is not a valid CSS selector`)}const me=document.querySelector(`[id='${t}']`);if(me&&it.add({current:me}),!it.size)return()=>null;const qe=(Ae=De??me)!==null&&Ae!==void 0?Ae:qn.current,ln=new MutationObserver(ae=>{ae.forEach(le=>{var Ke;if(!qe||le.type!=="attributes"||!(!((Ke=le.attributeName)===null||Ke===void 0)&&Ke.startsWith("data-tooltip-")))return;const He=dt(qe);cn(He)})}),W={attributes:!0,childList:!1,subtree:!1};if(qe){const ae=dt(qe);cn(ae),ln.observe(qe,W)}return()=>{ln.disconnect()}},[an,qn,De,t,n]),y.useEffect(()=>{B!=null&&B.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),we&&!Tc("border",`${we}`)&&console.warn(`[react-tooltip] "${we}" is not a valid \`border\`.`),B!=null&&B.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),A&&!Tc("opacity",`${A}`)&&console.warn(`[react-tooltip] "${A}" is not a valid \`opacity\`.`)},[]);let bn=p;const Hn=y.useRef(null);if(i){const Ae=i({content:(De==null?void 0:De.getAttribute("data-tooltip-content"))||q||null,activeAnchor:De});bn=Ae?y.createElement("div",{ref:Hn,className:"react-tooltip-content-wrapper"},Ae):null}else q&&(bn=q);Q&&(bn=y.createElement(rI,{content:Q}));const xn={forwardRef:Z,id:e,anchorId:t,anchorSelect:n,className:Pt(s,wn),classNameArrow:a,content:bn,contentWrapperRef:Hn,place:M,variant:H,offset:Ve,wrapper:ze,events:Pe,openOnClick:w,positionStrategy:rt,middlewares:h,delayShow:$e,delayHide:Ft,float:yt,hidden:jt,noArrow:C,clickable:T,closeOnEsc:S,closeOnScroll:N,closeOnResize:D,openEvents:U,closeEvents:G,globalCloseEvents:z,imperativeModeOnly:ne,style:B,position:ce,isOpen:se,defaultIsOpen:te,border:we,opacity:A,arrowColor:j,setIsOpen:$,afterShow:L,afterHide:k,disableTooltip:F,activeAnchor:De,setActiveAnchor:Ae=>sn(Ae),role:Y};return y.createElement(nI,{...xn})});typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",e=>{e.detail.disableCore||Sc({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||Sc({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 oI(){return c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:[c.jsxs("g",{clipPath:"url(#clip0_2896_16290)",children:[c.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"}),c.jsx("path",{d:"M8.00293 5.83301L7.99768 5.83301",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})]}),c.jsx("defs",{children:c.jsx("clipPath",{id:"clip0_2896_16290",children:c.jsx("rect",{width:"16",height:"16",fill:"white",transform:"translate(16 16.5) rotate(180)"})})})]})}function sI({id:e,tooltipText:t}){return c.jsxs(c.Fragment,{children:[c.jsx("span",{"data-tooltip-id":e,style:{maxWidth:"20rem"},children:oI()}),c.jsx(iI,{id:e,place:"top",content:t,style:{maxWidth:"30rem"}})]})}const aI="Each field must be mapped to a unique value";function da({field:e,onSelectChange:t,allFields:n}){var g;const{configureState:r,selectedObjectName:o,setConfigureState:i}=Qt(),[s,a]=y.useState(!0),{isError:l,removeError:u,getError:d}=Dt(),f=(g=r==null?void 0:r.read)==null?void 0:g.selectedFieldMappings,p=f==null?void 0:f[e.mapToName];y.useEffect(()=>{e._default&&!p&&o&&r&&ui(o,i,[{field:e.mapToName,value:e._default}]),a(!1)},[e,i,o,p,r]);const m=y.useMemo(()=>n.map(b=>({id:b.fieldName,label:b.displayName,value:b.fieldName})),[n]),w=c.jsx(ed,{disabled:s,items:m,selectedValue:p||null,onSelectedItemChange:b=>{t({target:{name:e.mapToName,value:b==null?void 0:b.value}})},placeholder:"Please select one",style:{width:"100%"}}),v=y.useCallback(()=>{o&&(ui(o,i,[{field:e.mapToName,value:null}]),l(ue.MAPPING,o)&&u(ue.MAPPING,o))},[e.mapToName,o,i,l,u]),{hasDuplicationError:h,errorMessage:x}=y.useMemo(()=>{const b=d(ue.MAPPING,o),_=Array.isArray(b)&&b.length>0&&b.includes(e.mapToName);return{hasDuplicationError:_,errorMessage:_?aI:""}},[o,d,e.mapToName]);return c.jsxs(c.Fragment,{children:[c.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[c.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem",marginBottom:".25rem"},children:[c.jsx("span",{style:{fontWeight:500},children:e.mapToDisplayName??e.mapToName}),c.jsx("span",{children:(e==null?void 0:e.prompt)&&c.jsx(sI,{id:`tooltip-id-${e==null?void 0:e.prompt}`,tooltipText:e==null?void 0:e.prompt})})]}),c.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[w,c.jsx(Je,{type:"button",variant:"ghost",onClick:v,children:"Clear"})]})]},e.mapToName),h&&c.jsxs("span",{style:{color:"red",fontSize:"14px",marginTop:"4px"},children:[" ",x," "]},e.mapToName)]})}const cI="_formControl_9qd8d_1",lI="_formLabel_9qd8d_5",uI="_formLabelRequired_9qd8d_11",dI="_formInput_9qd8d_16",fI="_formInputInvalid_9qd8d_20",pI="_formError_9qd8d_24",hI="_disabled_9qd8d_30",Gn={formControl:cI,formLabel:lI,formLabelRequired:uI,formInput:dI,formInputInvalid:fI,formError:pI,disabled:hI};function bo({id:e,label:t,isRequired:n=!1,isDisabled:r=!1,isInvalid:o=!1,errorMessage:i,children:s}){return c.jsxs("div",{className:Pt(Gn.formControl,{[Gn.disabled]:r}),children:[t&&c.jsx("label",{htmlFor:e,className:Pt(Gn.formLabel,{[Gn.formLabelRequired]:n}),children:t}),c.jsx("div",{id:e,className:Pt(Gn.formInput,{[Gn.formInputInvalid]:o}),children:s}),o&&i&&c.jsx("div",{className:Gn.formError,role:"alert",children:i})]})}const mI="_divider_1kmoj_1",Dc={divider:mI};function xo({className:e,style:t}){return c.jsx("hr",{className:e?`${Dc.divider} ${e}`:Dc.divider,style:t})}function Ct({string:e}){return c.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"1rem",paddingBottom:".5rem"},children:[c.jsx("h3",{style:{color:"var(--amp-colors-text-muted)",fontSize:"1rem",fontWeight:"400"},children:e}),c.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:c.jsx(xo,{style:{width:"100%",marginLeft:"1rem"}})})]})}function dd({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(l=>e[l]===r),a=[n,...s];return o(ue.MAPPING,t,a),!0}return!1}function gI({dynamicFieldMappings:e,onSelectChange:t,allFields:n}){return e.length?c.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:e.map(r=>c.jsx(bo,{id:r.mapToName,children:c.jsx(da,{allFields:n,field:r,onSelectChange:t})},r.mapToName))}):null}function yI(){var w,v;const{selectedObjectName:e,configureState:t,setConfigureState:n}=Qt(),{isError:r,removeError:o,setError:i}=Dt(),s=((w=t==null?void 0:t.read)==null?void 0:w.allFields)||[],{fieldMapping:a}=nt(),l=(v=t==null?void 0:t.read)==null?void 0:v.selectedFieldMappings,u=h=>{const{value:x,name:g}=h.target;!x||dd({selectedFieldMappings:l,selectedObjectName:e,fieldName:g,fieldValue:x,setError:i})||(e&&ui(e,n,[{field:g,value:x}]),r(ue.MAPPING,g)&&o(ue.MAPPING,g),e&&r(ue.MAPPING,e)&&o(ue.MAPPING,e))},d=y.useMemo(()=>!e||!a?[]:Object.values(a[e]||{}).flat().filter(h=>!h.fieldName),[a,e]),f=y.useMemo(()=>{var g;return(((g=t==null?void 0:t.read)==null?void 0:g.optionalMapFields)||[]).filter(b=>!d.some(_=>_.mapToName===b.mapToName))},[t,d]),p=d.length>0;return f.length>0||p?c.jsxs(c.Fragment,{children:[c.jsx(Ct,{string:"Map the following optional fields"}),c.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:[f==null?void 0:f.map(h=>c.jsx(bo,{id:h.mapToName,children:c.jsx(da,{allFields:s,field:h,onSelectChange:u})},h.mapToName)),p&&c.jsx(gI,{dynamicFieldMappings:d,onSelectChange:u,allFields:s})]})]}):null}function vI(){var u;const{selectedObjectName:e,configureState:t,setConfigureState:n}=Qt(),{isError:r,removeError:o,setError:i}=Dt(),s=(u=t==null?void 0:t.read)==null?void 0:u.selectedFieldMappings,a=d=>{const{value:f,name:p}=d.target;!f||dd({selectedFieldMappings:s,selectedObjectName:e,fieldName:p,fieldValue:f,setError:i})||(e&&ui(e,n,[{field:p,value:f}]),r(ue.MAPPING,p)&&o(ue.MAPPING,p),e&&r(ue.MAPPING,e)&&o(ue.MAPPING,e))},l=y.useMemo(()=>{var d;return((d=t==null?void 0:t.read)==null?void 0:d.requiredMapFields)||[]},[t]);return l!=null&&l.length?c.jsxs(c.Fragment,{children:[c.jsx(Ct,{string:"Map the following fields"}),c.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:l.map(d=>{var f;return c.jsx(bo,{id:d.mapToName,isInvalid:r(ue.MAPPING,d.mapToName),errorMessage:"* required",children:c.jsx(da,{allFields:((f=t==null?void 0:t.read)==null?void 0:f.allFields)||[],field:d,onSelectChange:a})},d.mapToName)})})]}):null}const wI={backgroundColor:"var(--amp-colors-bg-highlight)",borderColor:"var(--amp-colors-bg-highlight)",padding:".5rem 1rem"};function II({children:e,style:t}){return c.jsx(vn,{style:{...wI,...t},children:e})}const fa=e=>{const t=ut(),{provider:n}=nt(),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=fa(e),{data:n}=t,{provider:r}=nt(),o=n&&kl(n==null?void 0:n.name,n);return{...t,providerName:o,selectedProvider:e||r}};function bI(){var u,d,f;const{project:e}=Te(),{hydratedRevision:t}=Gr(),{selectedObjectName:n}=Qt(),{providerName:r}=at(),o=e==null?void 0:e.appName,i=(f=(d=(u=t==null?void 0:t.content)==null?void 0:u.read)==null?void 0:d.objects)==null?void 0:f.find(p=>p.objectName===n),s=(i==null?void 0:i.displayName)||n&&jr(n),a=i==null?void 0:i.mapToName,l=(i==null?void 0:i.mapToDisplayName)||a&&jr(a);return l&&o&&r?c.jsx(II,{style:{marginTop:"1rem"},children:c.jsxs("p",{style:{margin:"1rem 0"},children:[c.jsx("b",{children:l})," in ",o," is mapped to ",c.jsx("b",{children:s})," in ",r,"."]})}):null}function Fc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function fd(...e){return t=>{let n=!1;const r=e.map(o=>{const i=Fc(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():Fc(e[o],null)}}}}function fi(...e){return V.useCallback(fd(...e),e)}function _o(e,t=[]){let n=[];function r(i,s){const a=V.createContext(s),l=n.length;n=[...n,s];const u=f=>{var x;const{scope:p,children:m,...w}=f,v=((x=p==null?void 0:p[e])==null?void 0:x[l])||a,h=V.useMemo(()=>w,Object.values(w));return c.jsx(v.Provider,{value:h,children:m})};u.displayName=i+"Provider";function d(f,p){var v;const m=((v=p==null?void 0:p[e])==null?void 0:v[l])||a,w=V.useContext(m);if(w)return w;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[u,d]}const o=()=>{const i=n.map(s=>V.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return V.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,xI(o,...t)]}function xI(...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:l,scopeName:u})=>{const f=l(i)[`__scope${u}`];return{...a,...f}},{});return V.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)}}function pa(e){const t=V.useRef(e);return V.useEffect(()=>{t.current=e}),V.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function ha({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=_I({defaultProp:t,onChange:n}),i=e!==void 0,s=i?e:r,a=pa(n),l=V.useCallback(u=>{if(i){const f=typeof u=="function"?u(e):u;f!==e&&a(f)}else o(u)},[i,e,o,a]);return[s,l]}function _I({defaultProp:e,onChange:t}){const n=V.useState(e),[r]=n,o=V.useRef(r),i=pa(t);return V.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}function CI(e){const t=V.useRef({value:e,previous:e});return V.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var co=globalThis!=null&&globalThis.document?V.useLayoutEffect:()=>{};function OI(e){const[t,n]=V.useState(void 0);return co(()=>{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 l=i.borderBoxSize,u=Array.isArray(l)?l[0]:l;s=u.inlineSize,a=u.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}function EI(e,t){return V.useReducer((n,r)=>t[n][r]??n,e)}var ma=e=>{const{present:t,children:n}=e,r=SI(t),o=typeof n=="function"?n({present:r.isPresent}):V.Children.only(n),i=fi(r.ref,NI(o));return typeof n=="function"||r.isPresent?V.cloneElement(o,{ref:i}):null};ma.displayName="Presence";function SI(e){const[t,n]=V.useState(),r=V.useRef({}),o=V.useRef(e),i=V.useRef("none"),s=e?"mounted":"unmounted",[a,l]=EI(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return V.useEffect(()=>{const u=$i(r.current);i.current=a==="mounted"?u:"none"},[a]),co(()=>{const u=r.current,d=o.current;if(d!==e){const p=i.current,m=$i(u);e?l("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&p!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),co(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const v=$i(r.current).includes(m.animationName);if(m.target===t&&v&&(l("ANIMATION_END"),!o.current)){const h=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=h)})}},p=m=>{m.target===t&&(i.current=$i(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:V.useCallback(u=>{u&&(r.current=getComputedStyle(u)),n(u)},[])}}function $i(e){return(e==null?void 0:e.animationName)||"none"}function NI(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 lo=V.forwardRef((e,t)=>{const{children:n,...r}=e,o=V.Children.toArray(n),i=o.find(RI);if(i){const s=i.props.children,a=o.map(l=>l===i?V.Children.count(s)>1?V.Children.only(null):V.isValidElement(s)?s.props.children:null:l);return c.jsx(Ts,{...r,ref:t,children:V.isValidElement(s)?V.cloneElement(s,void 0,a):null})}return c.jsx(Ts,{...r,ref:t,children:n})});lo.displayName="Slot";var Ts=V.forwardRef((e,t)=>{const{children:n,...r}=e;if(V.isValidElement(n)){const o=PI(n),i=AI(r,n.props);return n.type!==V.Fragment&&(i.ref=t?fd(t,o):o),V.cloneElement(n,i)}return V.Children.count(n)>1?V.Children.only(null):null});Ts.displayName="SlotClone";var TI=({children:e})=>c.jsx(c.Fragment,{children:e});function RI(e){return V.isValidElement(e)&&e.type===TI}function AI(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function PI(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 DI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],$n=DI.reduce((e,t)=>{const n=V.forwardRef((r,o)=>{const{asChild:i,...s}=r,a=i?lo:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...s,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),ga="Checkbox",[FI,y_]=_o(ga),[MI,jI]=FI(ga),pd=V.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[p,m]=V.useState(null),w=fi(t,_=>m(_)),v=V.useRef(!1),h=p?d||!!p.closest("form"):!0,[x=!1,g]=ha({prop:o,defaultProp:i,onChange:u}),b=V.useRef(x);return V.useEffect(()=>{const _=p==null?void 0:p.form;if(_){const C=()=>g(b.current);return _.addEventListener("reset",C),()=>_.removeEventListener("reset",C)}},[p,g]),c.jsxs(MI,{scope:n,state:x,disabled:a,children:[c.jsx($n.button,{type:"button",role:"checkbox","aria-checked":kn(x)?"mixed":x,"aria-required":s,"data-state":gd(x),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:w,onKeyDown:Wt(e.onKeyDown,_=>{_.key==="Enter"&&_.preventDefault()}),onClick:Wt(e.onClick,_=>{g(C=>kn(C)?!0:!C),h&&(v.current=_.isPropagationStopped(),v.current||_.stopPropagation())})}),h&&c.jsx(kI,{control:p,bubbles:!v.current,name:r,value:l,checked:x,required:s,disabled:a,form:d,style:{transform:"translateX(-100%)"},defaultChecked:kn(i)?!1:i})]})});pd.displayName=ga;var hd="CheckboxIndicator",md=V.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=jI(hd,n);return c.jsx(ma,{present:r||kn(i.state)||i.state===!0,children:c.jsx($n.span,{"data-state":gd(i.state),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});md.displayName=hd;var kI=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...i}=e,s=V.useRef(null),a=CI(n),l=OI(t);V.useEffect(()=>{const d=s.current,f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(a!==n&&m){const w=new Event("click",{bubbles:r});d.indeterminate=kn(n),m.call(d,kn(n)?!1:n),d.dispatchEvent(w)}},[a,n,r]);const u=V.useRef(kn(n)?!1:n);return c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??u.current,...i,tabIndex:-1,ref:s,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function kn(e){return e==="indeterminate"}function gd(e){return kn(e)?"indeterminate":e?"checked":"unchecked"}var yd=pd,vd=md;function wd(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 LI=["color"],Id=y.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=wd(e,LI);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"}))}),KI=["color"],VI=y.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=wd(e,KI);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 $I="_checkboxGroupContainer_1ya1t_1",UI="_stack_1ya1t_6",qI="_selectAllContainer_1ya1t_11",HI="_fieldContainer_1ya1t_18",BI="_checkbox_1ya1t_1",Hr={checkboxGroupContainer:$I,stack:UI,selectAllContainer:qI,fieldContainer:HI,checkbox:BI};function bd({id:e,isChecked:t,label:n,onCheckedChange:r}){return c.jsxs("div",{className:Hr.fieldContainer,children:[c.jsx(yd,{className:Hr.checkbox,id:e,onCheckedChange:r,checked:t,children:c.jsx(vd,{children:c.jsx(Id,{})})}),c.jsx("label",{htmlFor:e,style:{overflowWrap:"anywhere"},children:n})]})}function xd({id:e,isChecked:t,label:n,onCheckedChange:r,isIndeterminate:o}){return c.jsxs("div",{className:Hr.selectAllContainer,children:[c.jsx(yd,{className:Hr.checkbox,id:e,onCheckedChange:r,children:c.jsxs(vd,{children:[o&&c.jsx(VI,{}),t===!0&&c.jsx(Id,{})]})}),c.jsx("label",{htmlFor:e,children:n})]})}function _d({children:e}){return c.jsx("div",{className:Hr.checkboxGroupContainer,children:e})}function Cd({children:e}){return c.jsx("div",{className:Hr.stack,children:e})}function WI(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,l=!zl(s,r);e.read.isOptionalFieldsModified=l}else console.warn("read.savedConfig.optionalFields is undefined")}function Mc(e,t,n,r){t(e,o=>WI(o,n,r))}function JI(){var f,p;const{appName:e,configureState:t,setConfigureState:n,selectedObjectName:r}=Qt(),o=(f=t==null?void 0:t.read)==null?void 0:f.selectedOptionalFields,i=(m,w)=>{m!=="indeterminate"&&r&&t&&Mc(r,n,w,m)},s=(p=t==null?void 0:t.read)==null?void 0:p.optionalFields,a=m=>{r&&s&&s.forEach(w=>{Ln(w)||Mc(r,n,w.fieldName,m)})},l=!!(s&&s.length>0),u=Object.keys(o||{}).length===(s==null?void 0:s.length),d=!u&&Object.keys(o||{}).length>0;return l&&c.jsxs(c.Fragment,{children:[c.jsx(Ct,{string:`${e} reads the following optional fields`}),c.jsxs(_d,{children:[((s==null?void 0:s.length)||0)>=2&&c.jsx(xd,{id:"select-all-fields",isChecked:u,label:"Select all",onCheckedChange:a,isIndeterminate:d}),c.jsx(Cd,{children:s.map(m=>Ln(m)?null:c.jsx(bd,{id:m.fieldName,isChecked:!!(o!=null&&o[m==null?void 0:m.fieldName]),label:m.displayName,onCheckedChange:w=>i(w,m.fieldName)},m.fieldName))})]})]})}function zI(){return c.jsx(JI,{})}const GI={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 QI({children:e,style:t,...n}){return c.jsx("span",{style:{...GI,...t},...n,children:e})}function XI(){var r,o,i;const{configureState:e,selectedObjectName:t}=Qt(),{appName:n}=Te();return c.jsxs(c.Fragment,{children:[c.jsx(Ct,{string:`${n} reads the following fields`}),c.jsx("div",{style:{display:"flex",gap:".5rem",marginBottom:".5rem",flexWrap:"wrap"},children:(o=(r=e==null?void 0:e.read)==null?void 0:r.requiredFields)!=null&&o.length?(i=e.read)==null?void 0:i.requiredFields.map(s=>Ln(s)?null:c.jsx(QI,{children:s.displayName},s.fieldName)):"There are no required fields."})]})}function YI(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 Od(e,t,n,r,o){t(e,i=>YI(i,e,n,r,o))}function ZI(e,t,n){t(e,r=>{r.read&&(r.read.isValueMappingsModified=n)})}function eb({string:e,fieldName:t}){return c.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"1rem",paddingBottom:".5rem"},children:[c.jsxs("h3",{style:{color:"var(--amp-colors-text-muted)",fontSize:"1rem",fontWeight:"400"},children:[e,c.jsx("b",{children:t})]}),c.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:c.jsx(xo,{style:{width:"100%",marginLeft:"1rem"}})})]})}function tb({mappedValue:e,onSelectChange:t,fieldName:n,allValueOptions:r,hasError:o}){var C;const{configureState:i,selectedObjectName:s,setConfigureState:a}=Qt(),[l,u]=y.useState(!0),{getError:d,setError:f,resetBoundary:p,isError:m,removeError:w}=Dt(),v=y.useMemo(()=>{var T,S;return((S=(T=i==null?void 0:i.read)==null?void 0:T.selectedValueMappings)==null?void 0:S[n])||{}},[(C=i==null?void 0:i.read)==null?void 0:C.selectedValueMappings,n]),h=y.useMemo(()=>v==null?void 0:v[e.mappedValue],[v,e.mappedValue]);y.useEffect(()=>{u(!1)},[e,a,s,h,i]);const x=y.useMemo(()=>r.map(T=>({id:T.value,label:T.displayValue,value:T.value})),[r]),g=y.useCallback(T=>{if(T){if(Object.values(v).some(S=>S===T.value&&S!==h)){const S=[...Object.entries(v).filter(([N,D])=>D===T.value&&D!==h).map(([N])=>N),e.mappedValue];f(ue.VALUE_MAPPING,n,S);return}d(ue.VALUE_MAPPING,n)&&p(ue.VALUE_MAPPING),t({target:{name:e.mappedValue,value:T.value,fieldName:n}})}},[t,v,h,n,e.mappedValue,p,f,d]),b=y.useMemo(()=>c.jsx(ed,{disabled:l,items:x,selectedValue:h||null,onSelectedItemChange:g,placeholder:"Please select one",style:{border:o?"2px solid red":void 0,borderRadius:"8px",width:"100%"}},h),[h,l,x,g,o]),_=y.useCallback(()=>{s&&(Od(s,a,e.mappedValue,"",n),m(ue.VALUE_MAPPING,n)&&w(ue.VALUE_MAPPING,n))},[s,a,e.mappedValue,n,m,w]);return c.jsxs("div",{style:{display:"flex",flexDirection:"column",marginBottom:".25rem"},children:[c.jsx("div",{style:{display:"flex",flexDirection:"row",gap:".25rem",marginBottom:".25rem"},children:c.jsx("span",{style:{fontWeight:500},children:e.mappedDisplayValue})}),c.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[b,c.jsx(Je,{type:"button",variant:"ghost",onClick:_,children:"Clear"})]})]},e.mappedValue)}function nb(){var m,w,v;const{fieldMapping:e}=nt(),{selectedObjectName:t,configureState:n,setConfigureState:r}=Qt(),{isError:o,removeError:i,getError:s}=Dt(),a=(m=n==null?void 0:n.read)==null?void 0:m.selectedFieldMappings,l=(w=n==null?void 0:n.read)==null?void 0:w.selectedValueMappings,u=(v=n==null?void 0:n.read)==null?void 0:v.isValueMappingsModified,d=y.useRef(!1),f=y.useMemo(()=>{const h=t&&e?Object.values(e[t]||{}).flat().filter(x=>x.mappedValues).map(x=>({...x})):[];if(a)for(let x=0;x<h.length;x+=1){const{mapToName:g}=h[x];a!=null&&a[g]&&(h[x].fieldName=a[g])}return h},[t,e,a]),p=y.useCallback(h=>{const{value:x,name:g,fieldName:b}=h.target;x&&(t&&Od(t,r,g,x,b),o(ue.VALUE_MAPPING,g)&&i(ue.VALUE_MAPPING,g))},[t,r,o,i]);return y.useEffect(()=>{var h;if(t&&l){const x=((h=e==null?void 0:e[t])==null?void 0:h.filter(b=>b.fieldName&&b.mappedValues.length>0))||[];x.every(b=>{const _=l[b.fieldName]||{};return Object.keys(_).length===Object.keys(b.mappedValues).length})&&x.length>0?!u&&!d.current&&(ZI(t,r,!0),d.current=!0):d.current=!1}},[l,f,t,r,e,u]),f!=null&&f.length?c.jsx(c.Fragment,{children:f.map(h=>{var T,S,N;if(!h.fieldName)return null;const x=(S=(T=n==null?void 0:n.read)==null?void 0:T.allFieldsMetadata)==null?void 0:S[h.fieldName],g=x==null?void 0:x.valueType;if(!["singleSelect","multiSelect"].includes(g))return console.error("fieldName is not a singleSelect or multiSelect",h),null;const b=x==null?void 0:x.values;if(!b)return null;const _=Object.keys(b).length,C=Object.keys((h==null?void 0:h.mappedValues)||[]).length;return _!==C?(console.error("field values and the values to be mapped are not of the same length",h,b),null):c.jsxs(c.Fragment,{children:[c.jsx(eb,{string:"Map the values for ",fieldName:h.mapToDisplayName||h.mapToName||h.fieldName}),c.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:c.jsx(bo,{id:h.mapToName||h.fieldName,children:(N=h==null?void 0:h.mappedValues)==null?void 0:N.map(D=>{var ne,B,ce;const U=s(ue.VALUE_MAPPING,h.fieldName),G=Array.isArray(U)&&U.includes(D.mappedValue),z=((ce=(B=(ne=n==null?void 0:n.read)==null?void 0:ne.allFieldsMetadata)==null?void 0:B[h.fieldName])==null?void 0:ce.values)||[];return c.jsxs(c.Fragment,{children:[c.jsx(tb,{allValueOptions:z,mappedValue:D,onSelectChange:p,fieldName:(h==null?void 0:h.fieldName)||"",hasError:G},`${D.mappedValue}-${h.fieldName}`),G&&c.jsx("span",{style:{color:"red",fontSize:"14px",marginTop:"4px"},children:`Each ${h.mapToName||h.fieldName} must be mapped to a unique value`},D.mappedValue)]})})},h.mapToName||h.fieldName)})]})})}):null}function rb(){return nv(),c.jsxs(c.Fragment,{children:[c.jsx(bI,{}),c.jsx(XI,{}),c.jsx(vI,{}),c.jsx(yI,{}),c.jsx(nb,{}),c.jsx(zI,{})]})}function ib(e,t,n){var r,o,i;if(((r=e==null?void 0:e.write)==null?void 0:r.selectedWriteObjects)===null&&(e.write.selectedWriteObjects={}),e!=null&&e.write){const s=e.write.selectedWriteObjects;if(n&&(s[t]={objectName:t}),n||delete s[t],(i=(o=e==null?void 0:e.write)==null?void 0:o.savedConfig)!=null&&i.selectedWriteObjects){const a=e.write.savedConfig.selectedWriteObjects,u=!by(a,s);e.write.isWriteModified=u}}}function jc(e,t,n,r){t(e,o=>{ib(o,n,r)})}function ob(){var f,p,m,w;const{appName:e,selectedObjectName:t,configureState:n,setConfigureState:r}=Qt(),o=(f=n==null?void 0:n.write)==null?void 0:f.selectedWriteObjects,i=(p=n==null?void 0:n.write)==null?void 0:p.writeObjects,s=(v,h)=>{v!=="indeterminate"&&t&&n&&jc(t,r,h,v)},a=v=>{var h,x;t&&n&&((x=(h=n==null?void 0:n.write)==null?void 0:h.writeObjects)==null||x.forEach(g=>{jc(t,r,g.objectName,v)}))},l=!!i,u=Object.keys(o||{}).length===((w=(m=n==null?void 0:n.write)==null?void 0:m.writeObjects)==null?void 0:w.length),d=!u&&Object.keys(o||{}).length>0;return l&&c.jsxs(c.Fragment,{children:[c.jsx(Ct,{string:`Allow ${e} to write to these objects`}),c.jsxs(_d,{children:[((i==null?void 0:i.length)||0)>=2&&c.jsx(xd,{id:"select-all-fields",onCheckedChange:a,isIndeterminate:d,isChecked:u,label:"Select all"}),c.jsx(Cd,{children:i.map(v=>c.jsx(bd,{id:v.objectName,onCheckedChange:h=>s(h,v.objectName),isChecked:!!(o!=null&&o[v.objectName]),label:v.displayName},v.objectName))})]})]})}function sb(){return c.jsx(c.Fragment,{children:c.jsx(ob,{})})}const ab="_link_oo2kv_1",cb={link:ab};function Ed({href:e,className:t,style:n,label:r,children:o,newTab:i=!1}){return c.jsx("a",{className:Pt(cb.link,t),style:n,href:e,"aria-label":r||void 0,target:i?"_blank":"_self",rel:i?"noopener noreferrer":void 0,children:o})}function Sd({url:e,providerDisplayName:t,credentialName:n}){return c.jsxs("p",{style:{color:"var(--amp-colors-text-muted)"},children:[c.jsx(Ed,{href:e,newTab:!0,children:c.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," about where to find your ",t," ",n,"."]})}function Un({error:e}){return e?c.jsx(vi,{style:{marginTop:"2em"},children:e}):null}const lb="_input_1ymb7_1",ub="_inputError_1ymb7_27",db="_error_1ymb7_43",Wo={input:lb,inputError:ub,error:db};function fb({id:e,type:t,className:n,isError:r=!1,...o}){const i=r?Pt(Wo.inputError,Wo.input):Wo.input;return c.jsx("input",{id:e,type:t,className:Pt(i,n),...o})}const pb="_textarea_18zl4_1",hb="_textareaError_18zl4_14",mb="_error_18zl4_29",Jo={textarea:pb,textareaError:hb,error:mb};function gb({className:e,isError:t=!1,...n}){const r=t?Pt(Jo.textareaError,Jo.textarea):Jo.textarea;return c.jsx("textarea",{className:Pt(e,r),...n})}const mn={Input:fb,Textarea:gb},yb=()=>{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 Nd(){var n,r;const{data:e}=yb();return((r=(n=e==null?void 0:e.entitlements)==null?void 0:n.brandingRemoval)==null?void 0:r.value)===!0?null:c.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:[c.jsx("p",{style:{color:"light-dark(gray, #EFEFEF)"},children:"Secured by"}),c.jsx("a",{href:"https://www.withampersand.com/",target:"_blank","aria-label":"Go to Ampersand",rel:"noreferrer noopener",children:c.jsxs("picture",{children:[c.jsx("source",{srcSet:"https://res.cloudinary.com/dycvts6vp/image/upload/v1723671980/ampersand-logo-black.svg",media:"(prefers-color-scheme: light)"}),c.jsx("source",{srcSet:"https://res.cloudinary.com/dycvts6vp/image/upload/v1735853540/ampersand_logo_white.svg",media:"(prefers-color-scheme: dark)"}),c.jsx("img",{style:{height:".8em"},src:"https://res.cloudinary.com/dycvts6vp/image/upload/v1723671980/ampersand-logo-black.svg",alt:"Ampersand"})]})})]})}function gr({children:e}){return c.jsx(Jr,{children:c.jsxs(vn,{children:[c.jsx("div",{style:{padding:"3rem 2rem"},children:e}),c.jsx(Nd,{})]})})}function yr({children:e}){return c.jsx("h1",{style:{fontWeight:600,lineHeight:1.2,fontSize:"1.2em"},children:e})}function vb({children:e}){return c.jsx("p",{style:{padding:".5em 0"},children:e})}function Td({provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:r,buttonVariant:o,submitButtonType:i}){var h;const[s,a]=y.useState(!1),l=()=>a(x=>!x),[u,d]=y.useState(""),f=x=>d(x.currentTarget.value),{providerName:p}=at(e),m=u.length>0,w=r||!m,v=(h=t.apiKeyOpts)==null?void 0:h.docsURL;return c.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[v&&c.jsx(Sd,{url:v,providerDisplayName:p||jr(e),credentialName:"API key"}),c.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[c.jsx(mn.Input,{id:"password",name:"password",type:s?"text":"password",placeholder:"API Key",onChange:x=>f(x)}),c.jsx(Je,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:l,variant:o,children:s?"Hide":"Show"})]}),c.jsx(Je,{style:{marginTop:"1em",width:"100%"},disabled:w,type:i||"submit",onClick:()=>n({apiKey:u}),variant:o,children:"Next"})]})}function wb({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){const{providerName:i}=at(e);return c.jsxs(gr,{children:[c.jsx(yr,{children:`Set up ${i} integration`}),c.jsx(Un,{error:r}),c.jsx(Td,{provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:o})]})}function Ib({...e}){return c.jsx(wb,{...e})}const bb={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 Co({children:e,style:t}){return c.jsx(vn,{style:{...bb,...t},children:e})}const ya=()=>{const e=ut(),t=Ot(),[n,r]=y.useState(null);return{...Wr({mutationKey:["updateConnection"],mutationFn:async i=>(await e()).connectionApi.updateConnection(i),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","connections"]}),r(null)}}),errorMsg:n}};function xb({provider:e}){const{projectIdOrName:t}=Te(),{providerName:n,data:r}=at(e),{selectedConnection:o,isConnectionsLoading:i}=Gt(),{mutateAsync:s,isPending:a,error:l}=ya(),[u,d]=y.useState(null),[f,p]=y.useState(!1),m=()=>p(!1),w=()=>{p(!0),d(null)},v=(l==null?void 0:l.message)||u||null,h=async x=>{m(),d(null);try{await s({projectIdOrName:t||"",connectionId:(o==null?void 0:o.id)||"",updateConnectionRequest:{updateMask:["apiKey"],connection:{apiKey:x.apiKey}}},{onError:g=>{console.error("Update connection error:",g),Le(g,d)},onSuccess:()=>{w()}})}catch(g){console.error("Update connection caught error:",g),Le(g,d)}};return r?c.jsxs(c.Fragment,{children:[c.jsx(Ct,{string:"Update connection"}),c.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[c.jsx("p",{children:`Update ${n} API Key`}),f&&c.jsx(Co,{children:"Connection updated successfully"}),v&&c.jsx(vi,{children:`Error updating connection ${v}`}),c.jsx(Td,{provider:r==null?void 0:r.name,providerInfo:r,handleSubmit:h,isButtonDisabled:a||i,buttonVariant:"ghost",submitButtonType:"button"})]})]}):null}function Rd({provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:r,buttonVariant:o}){var h;const[i,s]=y.useState(!1),a=()=>s(x=>!x),[l,u]=y.useState({username:"",password:""}),{username:d,password:f}=l,{providerName:p}=at(e),m=x=>{const{name:g,value:b}=x.currentTarget;u(_=>({..._,[g]:b}))},w=r,v=(h=t.basicOpts)==null?void 0:h.docsURL;return c.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[v&&c.jsx(Sd,{url:v,providerDisplayName:p||jr(e),credentialName:"credentials"}),c.jsx(mn.Input,{id:"username",name:"username",type:"text",placeholder:"Username",onChange:x=>m(x)}),c.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[c.jsx(mn.Input,{id:"password",name:"password",type:i?"text":"password",placeholder:"Password",onChange:x=>m(x)}),c.jsx(Je,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:a,variant:o,children:i?"Hide":"Show"})]}),c.jsx(Je,{style:{marginTop:"1em",width:"100%"},disabled:w,type:"button",onClick:()=>n({user:d,pass:f}),variant:o,children:"Next"})]})}function _b({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){const{providerName:i}=at(e);return c.jsxs(gr,{children:[c.jsx(yr,{children:`Set up ${i} integration`}),c.jsx(Un,{error:r}),c.jsx(Rd,{provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:o})]})}function Cb({...e}){return c.jsx(_b,{...e})}function Ob({provider:e}){const{projectIdOrName:t}=Te(),{providerName:n,data:r}=at(e),{selectedConnection:o,isConnectionsLoading:i}=Gt(),{mutateAsync:s,isPending:a,error:l}=ya(),[u,d]=y.useState(null),[f,p]=y.useState(!1),m=()=>p(!1),w=()=>{p(!0),d(null)},v=(l==null?void 0:l.message)||u||null,h=async x=>{m(),d(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:g=>{console.error(g),Le(g,d)},onSuccess:()=>{w()}})}catch(g){console.error(g),Le(g,d)}};return r?c.jsxs(c.Fragment,{children:[c.jsx(Ct,{string:"Update connection"}),c.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[c.jsx("p",{children:`Update ${n} credentials`}),f&&c.jsx(Co,{children:"Connection updated successfully"}),v&&c.jsx(vi,{children:`Error updating connection: ${v}`}),c.jsx(Rd,{provider:r==null?void 0:r.name,providerInfo:r,handleSubmit:h,isButtonDisabled:a||i,buttonVariant:"ghost"})]})]}):null}function Ad({handleSubmit:e,isButtonDisabled:t,explicitScopesRequired:n,explicitWorkspaceRequired:r,buttonVariant:o}){const[i,s]=y.useState(!1),[a,l]=y.useState({clientSecret:"",clientId:"",workspace:"",scopes:""}),u=()=>s(_=>!_),d=_=>{const{name:C,value:T}=_.currentTarget;l(S=>({...S,[C]:T}))},{clientSecret:f,clientId:p,workspace:m,scopes:w}=a,v=f.length>0,h=p.length>0,x=r?m.length>0:!0,g=t||!v||!h||!x,b=()=>{const _={clientId:p,clientSecret:f};r&&(_.workspace=m),n&&w.length>0&&(_.scopes=ay(w)),e(_)};return c.jsxs(c.Fragment,{children:[c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.2rem"},children:[r&&c.jsx(mn.Input,{id:"workspace",name:"workspace",type:"text",placeholder:"MyWorkspace",onChange:_=>d(_)}),c.jsx(mn.Input,{id:"clientId",name:"clientId",type:"text",placeholder:"Client ID",onChange:_=>d(_)}),c.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[c.jsx(mn.Input,{id:"clientSecret",name:"clientSecret",type:i?"text":"password",placeholder:"Client Secret",onChange:_=>d(_)}),c.jsx(Je,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:u,variant:o,children:i?"Hide":"Show"})]}),n&&c.jsx(mn.Textarea,{name:"scopes",placeholder:"Scopes separated by new line",onChange:_=>d(_)})]}),c.jsx("br",{}),c.jsx(Je,{style:{width:"100%"},disabled:g,type:"button",onClick:b,variant:o,children:"Next"})]})}function Eb({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r,explicitScopesRequired:o,explicitWorkspaceRequired:i}){return c.jsxs(gr,{children:[c.jsx(yr,{children:`Set up ${r} integration`}),c.jsx(Un,{error:t}),c.jsx("br",{}),c.jsx(Ad,{handleSubmit:e,isButtonDisabled:n,explicitScopesRequired:o,explicitWorkspaceRequired:i})]})}function Sb({provider:e}){var g;const{projectIdOrName:t}=Te(),{selectedConnection:n,isConnectionsLoading:r}=Gt(),{providerName:o,data:i}=at(e),{mutateAsync:s,isPending:a,error:l}=ya(),[u,d]=y.useState(null),[f,p]=y.useState(!1),m=()=>{p(!1)},w=()=>{p(!0),d(null)},v=(g=i==null?void 0:i.oauth2Opts)==null?void 0:g.explicitScopesRequired,h=(l==null?void 0:l.message)||u||null,x=async b=>{m(),d(null);try{await s({projectIdOrName:t||"",connectionId:(n==null?void 0:n.id)||"",updateConnectionRequest:{updateMask:["oauth2ClientCredentials"],connection:{oauth2ClientCredentials:{clientId:b.clientId,clientSecret:b.clientSecret,scopes:b.scopes}}}}),w()}catch(_){Le(_,d)}};return c.jsxs(c.Fragment,{children:[c.jsx(Ct,{string:"Update connection"}),c.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[c.jsx("p",{children:`Re-authenticate to ${o}`}),f&&c.jsx(Co,{children:"Connection updated successfully"}),h&&c.jsx(vi,{children:`Error updating connection ${h}`}),c.jsx(Ad,{handleSubmit:x,isButtonDisabled:a||r,explicitScopesRequired:v,explicitWorkspaceRequired:!1,buttonVariant:"ghost"})]})]})}const kc=600,Lc=600,Nb="AUTHORIZATION_SUCCEEDED",Tb="AUTHORIZATION_FAILED";function Rb(e,t,n,r){return y.useCallback(()=>{if(!r)return;const o=window.screenX+(window.outerWidth-kc)/2,i=window.screenY+(window.outerHeight-Lc)/2.5,s=`width=${kc},height=${Lc},left=${o},top=${i}`,a=window.open(r,e,s);t(a),window.addEventListener("message",n,!1)},[r,e,t,n])}function Ab(e,t,n,r){const o=Ot();return y.useCallback(i=>{var s,a;if(i.origin===Lg){if(i.data.eventType===Nb){const l=(s=i.data.data)==null?void 0:s.connection;l?(e(l),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===Tb&&(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 va({children:e,oauthUrl:t,windowTitle:n="Connect to Provider",onError:r,error:o,onSuccessConnect:i,isSuccessConnect:s}){const[a,l]=y.useState(null),[u,d]=y.useState(null),f=Ab(l,u,r,i),p=Rb(n,d,f,t);return y.useEffect(()=>{t&&!u&&!a&&!o&&!s&&p()},[t,u,p,a,o,s]),y.useEffect(()=>{if(!u)return;const m=setInterval(()=>{u.closed&&(clearInterval(m),window.removeEventListener("message",f),d(null),!a&&!o?(console.error("OAuth failed. Please try again."),r==null||r("Authentication was cancelled. Please try again.")):a&&(r==null||r(null)))},500);return()=>{clearInterval(m),window.removeEventListener("message",f)}},[u,a,o,f,r]),c.jsx("div",{children:e})}const Pb=()=>{const e=ut(),t=Ot();return Wr({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 Db({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return c.jsxs("div",{style:{padding:"1rem 0"},children:[c.jsx("p",{children:`Re-authenticate to ${r}`}),c.jsx(Un,{error:t}),c.jsx(Je,{variant:"ghost",style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function Fb({provider:e}){const{selectedConnection:t,isConnectionsLoading:n}=Gt(),r=t==null?void 0:t.id,o=t==null?void 0:t.projectId,{providerName:i}=at(e),{mutateAsync:s,isPending:a,error:l}=Pb(),[u,d]=y.useState(null),[f,p]=y.useState(!1),[m,w]=y.useState(null),v=()=>{p(!1)},h=()=>{p(!0),d(null),w(null)},x=(l==null?void 0:l.message)||u||null,g=async()=>{v(),d(null);try{const _=await s({projectIdOrName:o||"",connectionId:r||""});w(_)}catch(_){Le(_,d)}},b=y.useCallback(_=>{d(_)},[]);return c.jsxs(c.Fragment,{children:[c.jsx(Ct,{string:"Update connection"}),f&&c.jsx(Co,{children:"Connection updated successfully"}),c.jsx(va,{windowTitle:`Connect to ${i}`,oauthUrl:m||null,onError:b,error:x,isSuccessConnect:f,onSuccessConnect:h,children:c.jsx(Db,{handleSubmit:g,error:x,providerName:i,isButtonDisabled:a||n||f})})]})}function Pd({provider:e}){var r;const{data:t}=fa(e);if((t==null?void 0:t.authType)===qa.Basic)return c.jsx(Ob,{provider:e});if((t==null?void 0:t.authType)===qa.ApiKey)return c.jsx(xb,{provider:e});const n=(r=t==null?void 0:t.oauth2Opts)==null?void 0:r.grantType;if(n){if(n===Do.AuthorizationCode||n===Do.AuthorizationCodePkce)return c.jsx(Fb,{provider:e});if(n===Do.ClientCredentials)return c.jsx(Sb,{provider:e})}return null}const Mb="_authenticationRow_cjz1t_1",jb="_field_cjz1t_8",kb="_value_cjz1t_12",zo={authenticationRow:Mb,field:jb,value:kb};function Kc({label:e,value:t}){return c.jsxs("div",{className:zo.authenticationRow,children:[c.jsx("div",{className:zo.field,children:e}),c.jsx("div",{className:zo.value,children:t})]})}function Lb(){const{selectedConnection:e}=Gt(),{providerName:t}=at(),r=(e==null?void 0:e.provider)==="salesforce"?"subdomain":"workspace",o=`${t} ${r}`;return c.jsxs(c.Fragment,{children:[c.jsx(Ct,{string:"Connection details"}),c.jsxs("div",{style:{paddingBottom:"1rem"},children:[c.jsx(Kc,{label:o,value:e==null?void 0:e.providerWorkspaceRef}),c.jsx(Kc,{label:"Status",value:e==null?void 0:e.status})]})]})}const Kb=()=>{const e=ut(),t=Ot();return Wr({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 Dd({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={}}){const{projectId:r}=Te(),{integrationId:o,installation:i,setIntegrationDeleted:s,onUninstallSuccess:a}=nt(),[l,u]=y.useState(!1),d=!r||!o||!(i!=null&&i.id)||l,f=Kb(),p=async()=>{d||(u(!0),console.warn("uninstalling installation",{projectId:r,integrationId:o,installationId:i.id}),f.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:()=>u(!1)}))},m=l?"Uninstalling...":e,w=c.jsx(Je,{type:"button",onClick:p,disabled:d,variant:t,style:n,children:m});return i!=null&&i.id?w:null}function Vb(){const{installation:e}=nt(),{providerName:t}=at();return e?c.jsxs(c.Fragment,{children:[c.jsx(Ct,{string:"Uninstall entire integration"}),c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",padding:"1rem 0"},children:[e!=null&&e.id?c.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."]}):c.jsx("p",{children:"You've successfully uninstalled the integration."}),c.jsx(Dd,{buttonText:"Yes, uninstall",buttonVariant:"danger"})]})]}):null}function $b(){return c.jsxs(c.Fragment,{children:[c.jsx(Lb,{}),c.jsx(Pd,{}),c.jsx(Vb,{})]})}function Fd({onSave:e,onReset:t,isLoading:n,isCreateMode:r=!1,errorMsg:o}){var T,S,N,D;const{installation:i}=nt(),{hydratedRevision:s,loading:a}=Gr(),{configureState:l,selectedObjectName:u}=Qt(),d=i==null?void 0:i.config,f=d&&u&&!!Hl(d,u)||!1,p=((T=l==null?void 0:l.read)==null?void 0:T.isOptionalFieldsModified)||((S=l==null?void 0:l.read)==null?void 0:S.isRequiredMapFieldsModified)||((N=l==null?void 0:l.read)==null?void 0:N.isValueMappingsModified),m=(D=l==null?void 0:l.write)==null?void 0:D.isWriteModified,x=a||n||!l||!u||!(p||m||r||u!==dr&&!f),g=u===dr,b=u===Xi,_=c.jsx(Je,{type:"submit",disabled:x,children:r?"Install":"Save"}),C=c.jsx(Je,{type:"button",onClick:t,disabled:x,variant:"ghost",children:"Reset"});return n?c.jsx(ai,{}):c.jsxs("form",{style:{width:"34rem"},onSubmit:e,children:[c.jsx("div",{style:{display:"flex",flexDirection:"row-reverse",gap:".8rem",marginBottom:"20px",height:"3rem"},children:!b&&c.jsxs(c.Fragment,{children:[_,C]})}),c.jsxs(vn,{style:{padding:"1rem 2rem",minHeight:"300px",backgroundColor:"var(--amp-colors-bg-primary)",borderColor:"var(--amp-colors-border)"},children:[o&&c.jsx(vi,{children:typeof o=="string"?o:"Installation Failed."}),a&&c.jsx(ai,{}),s&&!g&&!b&&c.jsx(rb,{}),s&&g&&!b&&c.jsx(sb,{}),!a&&b&&c.jsx($b,{})]})]})}const Md=()=>{const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,onInstallSuccess:o,onUpdateSuccess:i}=nt(),{hydratedRevision:s,loading:a}=Gr(),{selectedObjectName:l}=au(),{selectedConnection:u}=Gt(),d=ll(),{projectId:f}=Te(),{resetBoundary:p,setErrors:m,setError:w,getError:v}=Dt(),{resetConfigureState:h,objectConfigurationsState:x,resetPendingConfigurationState:g}=$s(),b=eu(l||"",x),{onNextIncompleteTab:_}=Vy(),C=y.useCallback(()=>{p(ue.INSTALLATION_MUTATION)},[p]),T=y.useCallback(N=>N?D=>{w(ue.INSTALLATION_MUTATION,N,D)}:D=>{console.error("objectName is required to set installation error: ",D)},[w]),S=y.useCallback(N=>N?v(ue.INSTALLATION_MUTATION,N):"",[v]);return{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:s,loading:a,selectedObjectName:l,selectedConnection:u,apiKey:d,projectId:f,resetBoundary:p,setErrors:m,setMutateInstallationError:T,getMutateInstallationError:S,resetMutateInstallationErrorState:C,resetConfigureState:h,objectConfigurationsState:x,resetPendingConfigurationState:g,configureState:b,onInstallSuccess:o,onUpdateSuccess:i,onNextIncompleteTab:_}},Ub=void 0;function qb(){const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:o,loading:i,selectedObjectName:s,selectedConnection:a,apiKey:l,projectId:u,resetBoundary:d,setErrors:f,setMutateInstallationError:p,getMutateInstallationError:m,resetMutateInstallationErrorState:w,resetConfigureState:v,objectConfigurationsState:h,resetPendingConfigurationState:x,configureState:g,onInstallSuccess:b,onNextIncompleteTab:_}=Md(),[C,T]=y.useState(!1),S=s===dr,N=m(s),D=y.useCallback(()=>{d(ue.MAPPING),o!=null&&o.content&&!i&&s&&Ql(o,Ub,s,v)},[d,o,i,s,v]);y.useEffect(()=>{!g&&(o!=null&&o.content)&&!i&&D()},[g,h,o,i,D]);const U=()=>{w();const{requiredMapFields:ne,selectedFieldMappings:B}=(g==null?void 0:g.read)||{},{errorList:ce}=Jl(ne,B,f);ce.length>0||(s&&(a!=null&&a.id)&&l&&u&&e&&t&&n&&o?(T(!0),Sy(u,e,t,n,a.id,s,l,o,g,p(s),r,b).finally(()=>{T(!1),x(s),_()})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},G=()=>{w(),s&&(a!=null&&a.id)&&l&&u&&e&&t&&n&&o?(T(!0),Ry(u,e,t,n,a.id,l,o,g,p(s),r,b).finally(()=>{T(!1),x(s),_()})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},z=ne=>{ne.preventDefault(),S?G():U()};return c.jsx(Fd,{errorMsg:N,isCreateMode:!0,isLoading:C,onSave:z,onReset:D})}function Hb({updateConfig:e,projectId:t,integrationId:n,installationId:r,apiKey:o,selectedObjectName:i,setInstallation:s,onUpdateSuccess:a,setError:l}){const u={projectIdOrName:t,installationId:r,integrationId:n,installationUpdate:{updateMask:[`config.content.read.objects.${ly(i)}`],installation:{config:e}}};return Ms().installationApi.updateInstallation(u,{headers:{"X-Api-Key":o,"Content-Type":"application/json"}}).then(d=>{s(d),a==null||a(d.id,d.config)}).catch(d=>{Le(d,l)})}const Bb=(e,t,n,r,o,i)=>{const s=Xl(e),a=Yl(e),l=Zl(e),u={content:{read:{objects:{[t]:{objectName:t,schedule:r,destination:(n==null?void 0:n.destination)||"",selectedFields:s,selectedFieldMappings:a,selectedValueMappings:l||{},backfill:i}}}}};return yi(o)&&(u.content||(u.content={}),u.content.proxy={enabled:!0}),u},Wb=(e,t,n,r,o,i,s,a,l,u,d)=>{const f=Bb(i,r||"",a,a.schedule,l,a.backfill);return f?Hb({updateConfig:f,projectId:e,integrationId:t,installationId:n,apiKey:o,selectedObjectName:r,setError:u,setInstallation:s,onUpdateSuccess:d}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Jb=(e,t)=>{const r={content:{write:{objects:nu(e)}}};return yi(t)&&(r.content||(r.content={}),r.content.proxy={enabled:!0}),r},zb=(e,t,n,r,o,i,s,a,l)=>{const u=Jb(o,i);if(!u)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const d={projectIdOrName:e,installationId:n,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:u}}};return Ms().installationApi.updateInstallation(d,{headers:{"X-Api-Key":r,"Content-Type":"application/json"}}).then(f=>{a(f),l==null||l(f.id,f.config)}).catch(f=>{Le(f,s)})};function Gb({installation:e,integrationObj:t}){const{setInstallation:n,hydratedRevision:r,loading:o,selectedObjectName:i,apiKey:s,projectId:a,resetBoundary:l,setErrors:u,setMutateInstallationError:d,getMutateInstallationError:f,resetConfigureState:p,resetPendingConfigurationState:m,configureState:w,onUpdateSuccess:v,onNextIncompleteTab:h}=Md(),[x,g]=y.useState(!1),b=i===dr,_=f(i),{config:C}=e,T=y.useCallback(()=>{l(ue.MAPPING),r!=null&&r.content&&!o&&i&&Ql(r,C,i,p)},[l,r,o,i,C,p]);y.useEffect(()=>{w||T()},[w,T]);const S=y.useMemo(()=>{var z,ne,B;return(B=(ne=(z=r==null?void 0:r.content)==null?void 0:z.read)==null?void 0:ne.objects)==null?void 0:B.find(ce=>(ce==null?void 0:ce.objectName)===i)},[r,i]),N=()=>{const{requiredMapFields:G,selectedFieldMappings:z}=(w==null?void 0:w.read)||{},{errorList:ne}=Jl(G,z,u);ne.length>0||(r&&e&&i&&s&&a&&S?(g(!0),Wb(a,t.id,e.id,i,s,w,n,S,r,d(i),v).finally(()=>{g(!1),m(i),h()})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},D=()=>{e&&i&&s&&a&&r?(g(!0),zb(a,t.id,e.id,s,w,r,d(i),n,v).finally(()=>{g(!1),m(i),h()})):console.error("UpdateInstallation - onSaveUpdate missing required props")},U=G=>{G.preventDefault(),b?D():N()};return c.jsx(Fd,{errorMsg:_,onSave:U,onReset:T,isLoading:x})}function Qb(){const{integrationObj:e,installation:t}=nt();return e?t&&e?c.jsx(Gb,{installation:t,integrationObj:e}):c.jsx(qb,{}):c.jsx(Fl,{message:"We can't load the integration"})}const Xb=()=>{const e=ut(),t=Ot(),[n,r]=y.useState(null);return{...Wr({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 Yb(){return c.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"#BBF7D0"}),c.jsx("path",{d:"M34.6666 18.6667L20 32.0001L13.3333 25.9395",stroke:"#16A34A",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}function wa({text:e,children:t}){return c.jsx(Jr,{children:c.jsxs(vn,{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"3rem",gap:"3rem"},children:[c.jsx(Yb,{}),c.jsx("p",{children:e}),t]})})}function Zb({provider:e}){const{providerName:t}=at(e),n=`You have successfully installed your ${t} integration.`;return c.jsx(wa,{text:n,children:c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:c.jsx(Dd,{buttonText:"Uninstall",buttonVariant:"outline",buttonStyle:{fontSize:"13px"}})})})}const ex=e=>{const{read:t,write:n}=(e==null?void 0:e.content)??{};return!t&&!n};function tx({children:e}){var C;const t=y.useRef(!1),{projectId:n}=Te(),{hydratedRevision:r,loading:o}=Gr(),{integrationObj:i,installation:s,groupRef:a,consumerRef:l,onInstallSuccess:u,isIntegrationDeleted:d}=nt(),{mutate:f,isIdle:p,isPending:m,error:w,errorMsg:v}=Xb(),{selectedConnection:h,isConnectionsLoading:x}=Gt(),g=o||m||x,b=(C=r==null?void 0:r.content)==null?void 0:C.provider,_=ex(r);return y.useEffect(()=>{var T;if(!g&&!x&&r&&_&&!s&&h&&(i!=null&&i.id)&&!d&&b){const S={projectIdOrName:n,integrationId:i==null?void 0:i.id,installation:{groupRef:a,connectionId:h==null?void 0:h.id,config:{content:{provider:b}}}};yi(r)===!0&&(S.installation.config.content.proxy=(T=r==null?void 0:r.content)==null?void 0:T.proxy),p&&!t.current&&(f(S,{onSuccess:N=>{u==null||u(N==null?void 0:N.id,N.config)}}),t.current=!0)}},[r,_,s,h,n,i==null?void 0:i.id,a,l,g,u,d,x,b,f,p]),_&&b&&s?c.jsx(Zb,{provider:b}):w?c.jsx(Bt,{message:v??"Create installation failed"}):i?g?c.jsx(zr,{}):c.jsx("div",{children:e}):c.jsx(Bt,{message:"We can't load the integration"})}function Oo(){const e=ut(),t=Ot();return Wr({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 nx({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a}){const{projectIdOrName:l}=Te(),u=Oo(),d=y.useCallback(f=>{const{apiKey:p}=f,m={projectIdOrName:l,generateConnectionParams:{groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,apiKey:p}};u.mutate(m)},[l,i,o,r,n,e,u]);return a===null?c.jsx(Ib,{provider:e,providerInfo:t,handleSubmit:d,error:null}):s}function rx({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a}){const{projectIdOrName:l}=Te(),u=Oo(),d=y.useCallback(f=>{const{user:p,pass:m}=f,w={projectIdOrName:l,generateConnectionParams:{groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,basicAuth:{username:p,password:m}}};u.mutate(w)},[l,i,o,r,n,e,u]);return a===null?c.jsx(Cb,{provider:e,providerInfo:t,handleSubmit:d,error:null}):s}function ix({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 c.jsxs(gr,{children:[c.jsx(yr,{children:i||`Set up ${r} integration`}),c.jsx(Un,{error:t}),o,c.jsx(Je,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function ox({...e}){return c.jsx(ix,{...e})}function sx({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,selectedConnection:s,providerName:a}){const{projectIdOrName:l}=Te(),u=Oo(),d=y.useCallback(()=>{const f={projectIdOrName:l,generateConnectionParams:{groupName:o,groupRef:r,consumerName:n,consumerRef:t,provider:e}};u.mutate(f)},[l,o,r,n,t,e,u]);return s===null?c.jsx(ox,{handleSubmit:d,error:null,providerName:a}):i}const ax=()=>{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})},cx=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})},lx=ks("VITE_AMP_ENABLE_CSRF",!1),ux=ks("NEXT_AMP_ENABLE_CSRF",!1),dx=ks("REACT_APP_AMP_ENABLE_CSRF",!1),fx=!!lx||!!ux||!!dx,jd=(e,t,n,r,o,i)=>{const{projectId:s}=Te(),{data:a,isLoading:l,error:u}=fa(n),{data:d,isLoading:f,error:p}=ax(),m=d==null?void 0:d.find(C=>C.provider===n),w=a?kl(n,a):null,v={providerWorkspaceRef:r,projectId:s,groupRef:t,groupName:i,consumerRef:e,consumerName:o,providerAppId:m==null?void 0:m.id,provider:n,enableCSRFProtection:fx},{data:h,error:x,isLoading:g,refetch:b}=cx(v);return y.useEffect(()=>{a&&n&&!m&&console.error(`You must first set up a ${w} Provider App using the Ampersand Console.`)},[m,w,a,n]),y.useEffect(()=>{u&&(console.error("Error fetching provider info:",u),Le(u))},[u]),y.useEffect(()=>{p&&(console.error("Error fetching provider apps:",p),Le(p))},[p]),y.useEffect(()=>{x&&(console.error("Error fetching OAuth connect:",x),Le(x))},[x]),{url:h,error:u||p||x,isLoading:l||f||g,refetchOauthConnect:()=>{var C,T;(a==null?void 0:a.authType)==="oauth2"?((C=a==null?void 0:a.oauth2Opts)==null?void 0:C.grantType)==="authorizationCode"||((T=a==null?void 0:a.oauth2Opts)==null?void 0:T.grantType)==="authorizationCodePKCE"?b():console.error("Provider does not support an OAuth2 web flow grant type."):console.error("Provider does not support an OAuth2 web flow.")}}};function px({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return c.jsxs(gr,{children:[c.jsx(yr,{children:`Set up ${r} integration`}),c.jsx(vb,{children:`Click Next to sign into the ${r} account you'd like to sync.`}),c.jsx(Un,{error:t}),c.jsx(Je,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function hx({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,providerName:i}){const[s,a]=y.useState(null),{url:l,error:u,isLoading:d,refetchOauthConnect:f}=jd(t,r,e,void 0,n,o),p=(u==null?void 0:u.message)||s||null,m=async()=>{a(null),f()},w=y.useCallback(v=>{a(v)},[]);return c.jsx(va,{windowTitle:`Connect to ${i}`,oauthUrl:l||null,onError:w,children:c.jsx(px,{handleSubmit:m,error:p,providerName:i,isButtonDisabled:d})})}const mx="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function gx({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r}){return c.jsxs(gr,{children:[c.jsx(yr,{children:"Enter your Salesforce subdomain"}),c.jsx(Ed,{href:mx,newTab:!0,children:"What is my Salesforce subdomain?"}),c.jsx(Un,{error:n}),c.jsxs("div",{style:{display:"flex",marginTop:"1em",alignItems:"center"},children:[c.jsx(mn.Input,{id:"salesforce-subdomain",type:"text",placeholder:"my-domain",onChange:o=>t(o.currentTarget.value)}),c.jsx("p",{style:{lineHeight:"2.2em",marginLeft:"0.4em"},children:".my.salesforce.com"})]}),c.jsx(Je,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}function yx({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r,providerName:o}){return c.jsxs(gr,{children:[c.jsxs(yr,{children:["Enter your ",o," workspace"]}),c.jsx(Un,{error:n}),c.jsx("br",{}),c.jsx(mn.Input,{id:"workspace",type:"text",placeholder:"MyWorkspace",onChange:i=>t(i.currentTarget.value)}),c.jsx("br",{}),c.jsx(Je,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}const vx="salesforce";function wx({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,providerName:i}){const[s,a]=y.useState(""),[l,u]=y.useState(null),{url:d,error:f,isLoading:p,refetchOauthConnect:m}=jd(t,r,e,s,n,o),w=(f==null?void 0:f.message)||l||null,v=async()=>{if(u(null),!s){u("Workspace is required");return}m()},h=y.useCallback(g=>{u(g)},[]),x=e===vx?c.jsx(gx,{handleSubmit:v,setWorkspace:a,error:w,isButtonDisabled:s.length===0}):c.jsx(yx,{handleSubmit:v,setWorkspace:a,error:w,isButtonDisabled:s.length===0||p,providerName:i});return c.jsx(va,{windowTitle:`Connect to ${i}`,oauthUrl:d||null,onError:h,error:w,children:x})}function Ix({provider:e,providerName:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,explicitScopesRequired:s,explicitWorkspaceRequired:a,selectedConnection:l}){const{projectIdOrName:u}=Te(),d=Oo(),[f,p]=y.useState(null),m=y.useCallback(w=>{p(null);const v={projectIdOrName:u,generateConnectionParams:{groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,providerWorkspaceRef:w.workspace,oauth2ClientCredentials:{clientId:w.clientId,clientSecret:w.clientSecret,scopes:w.scopes}}};d.mutate(v,{onError:()=>p("Error loading provider info")})},[u,i,o,r,n,e,d]);return l===null?c.jsx(Eb,{providerName:t,handleSubmit:m,error:f,explicitScopesRequired:s,explicitWorkspaceRequired:a}):c.jsx(ai,{})}function bx({...e}){return c.jsx(Ix,{...e})}const xx="authorizationCode",_x="authorizationCodePKCE",Cx="clientCredentials";function Ox({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,selectedConnection:s,setSelectedConnection:a}){const{providerName:l}=at(e);if(t.oauth2Opts===void 0)return c.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:u,explicitScopesRequired:d,explicitWorkspaceRequired:f}=t.oauth2Opts,p={provider:e,consumerRef:n,consumerName:r,groupRef:o,groupName:i,providerName:l};return u===xx||u===_x?f?c.jsx(wx,{...p}):c.jsx(hx,{...p}):u===Cx?c.jsx(bx,{...p,explicitWorkspaceRequired:f,explicitScopesRequired:d,selectedConnection:s,setSelectedConnection:a}):u==="password"?c.jsx("em",{children:"Password flow not supported yet"}):c.jsxs("em",{children:["Unsupported grant type: ",u]})}function Ex(e){const{selectedConnection:t}=Gt();y.useEffect(()=>{e&&t&&e(t)},[e,t])}function Sx({onSuccess:e}){Ex(e)}function kd({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,onSuccess:s,onDisconnectSuccess:a,resetComponent:l}){const{data:u,isLoading:d,isError:f,error:p,providerName:m,selectedProvider:w}=at(e),{provider:v,isIntegrationDeleted:h}=nt(),{selectedConnection:x,setSelectedConnection:g}=Gt();Sx({onSuccess:s});const b=Ot();y.useEffect(()=>{f&&(console.error("Error loading provider info."),Le(p))},[f,p]);const _=y.useCallback(()=>{b.clear(),l()},[l,b]);if(!e&&!v)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");if(h)return c.jsx(wa,{text:"Integration successfully uninstalled.",children:c.jsx(Je,{type:"button",onClick:_,style:{width:"100%"},children:"Reinstall Integration"})});if(x)return i;if(d)return c.jsx(zr,{});if(u==null)return c.jsx(Bt,{message:"Provider info was not found."});const C={provider:w,consumerRef:t,consumerName:n,groupRef:r,groupName:o,selectedConnection:x,setSelectedConnection:g,providerName:m,providerInfo:u,onDisconnectSuccess:a};return u.authType==="none"?c.jsx(sx,{...C,children:i}):u.authType==="basic"?c.jsx(rx,{...C,children:i}):u.authType==="apiKey"?c.jsx(nx,{...C,children:i}):c.jsx(Ox,{...C})}function Nx(e){const t=e+"CollectionProvider",[n,r]=_o(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=m=>{const{scope:w,children:v}=m,h=y.useRef(null),x=y.useRef(new Map).current;return c.jsx(o,{scope:w,itemMap:x,collectionRef:h,children:v})};s.displayName=t;const a=e+"CollectionSlot",l=y.forwardRef((m,w)=>{const{scope:v,children:h}=m,x=i(a,v),g=fi(w,x.collectionRef);return c.jsx(lo,{ref:g,children:h})});l.displayName=a;const u=e+"CollectionItemSlot",d="data-radix-collection-item",f=y.forwardRef((m,w)=>{const{scope:v,children:h,...x}=m,g=y.useRef(null),b=fi(w,g),_=i(u,v);return y.useEffect(()=>(_.itemMap.set(g,{ref:g,...x}),()=>void _.itemMap.delete(g))),c.jsx(lo,{[d]:"",ref:b,children:h})});f.displayName=u;function p(m){const w=i(e+"CollectionConsumer",m);return y.useCallback(()=>{const h=w.collectionRef.current;if(!h)return[];const x=Array.from(h.querySelectorAll(`[${d}]`));return Array.from(w.itemMap.values()).sort((_,C)=>x.indexOf(_.ref.current)-x.indexOf(C.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:s,Slot:l,ItemSlot:f},p,r]}var Tx=V.useId||(()=>{}),Rx=0;function Ld(e){const[t,n]=V.useState(Tx());return co(()=>{e||n(r=>r??String(Rx++))},[e]),e||(t?`radix-${t}`:"")}var Ax=V.createContext(void 0);function Kd(e){const t=V.useContext(Ax);return e||t||"ltr"}var Go="rovingFocusGroup.onEntryFocus",Px={bubbles:!1,cancelable:!0},Eo="RovingFocusGroup",[Rs,Vd,Dx]=Nx(Eo),[Fx,$d]=_o(Eo,[Dx]),[Mx,jx]=Fx(Eo),Ud=V.forwardRef((e,t)=>c.jsx(Rs.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Rs.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(kx,{...e,ref:t})})}));Ud.displayName=Eo;var kx=V.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,p=V.useRef(null),m=fi(t,p),w=Kd(i),[v=null,h]=ha({prop:s,defaultProp:a,onChange:l}),[x,g]=V.useState(!1),b=pa(u),_=Vd(n),C=V.useRef(!1),[T,S]=V.useState(0);return V.useEffect(()=>{const N=p.current;if(N)return N.addEventListener(Go,b),()=>N.removeEventListener(Go,b)},[b]),c.jsx(Mx,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:v,onItemFocus:V.useCallback(N=>h(N),[h]),onItemShiftTab:V.useCallback(()=>g(!0),[]),onFocusableItemAdd:V.useCallback(()=>S(N=>N+1),[]),onFocusableItemRemove:V.useCallback(()=>S(N=>N-1),[]),children:c.jsx($n.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:Wt(e.onMouseDown,()=>{C.current=!0}),onFocus:Wt(e.onFocus,N=>{const D=!C.current;if(N.target===N.currentTarget&&D&&!x){const U=new CustomEvent(Go,Px);if(N.currentTarget.dispatchEvent(U),!U.defaultPrevented){const G=_().filter(se=>se.focusable),z=G.find(se=>se.active),ne=G.find(se=>se.id===v),ce=[z,ne,...G].filter(Boolean).map(se=>se.ref.current);Bd(ce,d)}}C.current=!1}),onBlur:Wt(e.onBlur,()=>g(!1))})})}),qd="RovingFocusGroupItem",Hd=V.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,...s}=e,a=Ld(),l=i||a,u=jx(qd,n),d=u.currentTabStopId===l,f=Vd(n),{onFocusableItemAdd:p,onFocusableItemRemove:m}=u;return V.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),c.jsx(Rs.ItemSlot,{scope:n,id:l,focusable:r,active:o,children:c.jsx($n.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:Wt(e.onMouseDown,w=>{r?u.onItemFocus(l):w.preventDefault()}),onFocus:Wt(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:Wt(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){u.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const v=Vx(w,u.orientation,u.dir);if(v!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let x=f().filter(g=>g.focusable).map(g=>g.ref.current);if(v==="last")x.reverse();else if(v==="prev"||v==="next"){v==="prev"&&x.reverse();const g=x.indexOf(w.currentTarget);x=u.loop?$x(x,g+1):x.slice(g+1)}setTimeout(()=>Bd(x))}})})})});Hd.displayName=qd;var Lx={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Kx(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Vx(e,t,n){const r=Kx(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Lx[r]}function Bd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function $x(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ux=Ud,qx=Hd,Ia="Tabs",[Hx,v_]=_o(Ia,[$d]),Wd=$d(),[Bx,ba]=Hx(Ia),Jd=V.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:l="automatic",...u}=e,d=Kd(a),[f,p]=ha({prop:r,onChange:o,defaultProp:i});return c.jsx(Bx,{scope:n,baseId:Ld(),value:f,onValueChange:p,orientation:s,dir:d,activationMode:l,children:c.jsx($n.div,{dir:d,"data-orientation":s,...u,ref:t})})});Jd.displayName=Ia;var zd="TabsList",Gd=V.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=ba(zd,n),s=Wd(n);return c.jsx(Ux,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:r,children:c.jsx($n.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});Gd.displayName=zd;var Qd="TabsTrigger",Xd=V.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=ba(Qd,n),a=Wd(n),l=Zd(s.baseId,r),u=ef(s.baseId,r),d=r===s.value;return c.jsx(qx,{asChild:!0,...a,focusable:!o,active:d,children:c.jsx($n.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":u,"data-state":d?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l,...i,ref:t,onMouseDown:Wt(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(r):f.preventDefault()}),onKeyDown:Wt(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(r)}),onFocus:Wt(e.onFocus,()=>{const f=s.activationMode!=="manual";!d&&!o&&f&&s.onValueChange(r)})})})});Xd.displayName=Qd;var Yd="TabsContent",Wx=V.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=ba(Yd,n),l=Zd(a.baseId,r),u=ef(a.baseId,r),d=r===a.value,f=V.useRef(d);return V.useEffect(()=>{const p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),c.jsx(ma,{present:o||d,children:({present:p})=>c.jsx($n.div,{"data-state":d?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!p,id:u,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:p&&i})})});Wx.displayName=Yd;function Zd(e,t){return`${e}-trigger-${t}`}function ef(e,t){return`${e}-content-${t}`}var Jx=Jd,zx=Gd,tf=Xd;const Gx=c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[c.jsx("circle",{cx:"9",cy:"9",r:"9",fill:"#BBF7D0"}),c.jsx("path",{d:"M13 7L7.5 12L5 9.72727",stroke:"#16A34A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function Qx(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?Gx:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:c.jsx("circle",{cx:"9",cy:"9",r:"5",fill:"#BFDBFE"})})}function Xx(){return c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.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"}),c.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 Yx="_tabsRoot_ktpr0_1",Zx="_tabsList_ktpr0_6",e_="_tabTrigger_ktpr0_12",t_="_danger_ktpr0_29",uo={tabsRoot:Yx,tabsList:Zx,tabTrigger:e_,danger:t_};function n_(){return c.jsxs(c.Fragment,{children:[c.jsx(xo,{style:{margin:"1rem 0"}}),c.jsx(tf,{value:Xi,className:uo.tabTrigger,children:c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[c.jsx(Xx,{}),c.jsx("span",{children:"Manage"})]})})]})}function nf({objectName:e,completed:t,pending:n,displayName:r}){return c.jsx(tf,{value:e,className:uo.tabTrigger,children:c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[Qx(t,n),c.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[c.jsx("span",{children:r||e}),n&&c.jsx("span",{style:{fontSize:".8rem",fontStyle:"italic"},children:"pending"})]})]})})}function r_({completed:e,pending:t,displayName:n}){return c.jsxs(c.Fragment,{children:[c.jsx(xo,{style:{margin:"1rem 0"}}),c.jsx(nf,{objectName:dr,completed:e,pending:t,displayName:n},"other-write")]})}function i_({value:e,readNavObjects:t,onValueChange:n,objectConfigurationsState:r,writeNavObject:o}){var i,s;return c.jsx(Jx,{value:e,className:uo.tabsRoot,onValueChange:n,children:c.jsxs(zx,{className:uo.tabsList,children:[t.map(a=>{var l,u,d,f,p,m;return c.jsx(nf,{objectName:a.name,displayName:a.displayName,completed:a.completed,pending:((u=(l=r==null?void 0:r[a.name])==null?void 0:l.read)==null?void 0:u.isOptionalFieldsModified)||((f=(d=r==null?void 0:r[a.name])==null?void 0:d.read)==null?void 0:f.isRequiredMapFieldsModified)||((m=(p=r==null?void 0:r[a.name])==null?void 0:p.read)==null?void 0:m.isValueMappingsModified)||!1},a.name)}),o&&c.jsx(r_,{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"}),c.jsx(n_,{})]})})}function o_(e,t){return t===Xi?{name:Xi,completed:!1}:e.find(n=>n.name===t)}function s_({children:e}){var x;const{project:t}=Te(),{installation:n}=nt(),{providerName:r}=at(),{hydratedRevision:o}=Gr(),{objectConfigurationsState:i}=$s(),[s,a]=y.useState(""),l=(t==null?void 0:t.appName)||"",u=n==null?void 0:n.config,d=o&&Bl(u,o),f=d!==null,p=!!((x=o==null?void 0:o.content)!=null&&x.write),m=p?Wl(u):void 0,w=y.useMemo(()=>{const g=[...d||[]];return m&&p&&g.push(m),g},[d,m,p]),v=o_(w,s),h=y.useCallback(()=>{const g=w.find(b=>v!==b&&!b.completed);g&&a(g.name)},[w,v]);return y.useEffect(()=>{!s&&w.length>0&&a(w[0].name)},[w,s,h]),c.jsx(cu.Provider,{value:h,children:c.jsx(su.Provider,{value:v==null?void 0:v.name,children:c.jsxs(Jr,{style:{maxWidth:"55rem"},children:[c.jsxs(vn,{style:{display:"flex",gap:"1rem",padding:"3rem",paddingBottom:"6rem",backgroundColor:"var(--amp-colors-bg-primary)"},children:[c.jsxs("div",{style:{width:"20rem"},children:[c.jsxs("h1",{style:{fontSize:"small",fontWeight:"400"},children:[r," integration"]}),c.jsx("h3",{style:{marginBottom:"20px",fontSize:"large",fontWeight:"500"},children:l}),f&&c.jsx(i_,{value:s,readNavObjects:d,onValueChange:g=>a(g),objectConfigurationsState:i,writeNavObject:m})]}),e]}),c.jsx(Nd,{})]})})})}function a_({...e}){return c.jsx(s_,{...e})}function c_({integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:l}){var h;const{projectIdOrName:u,isLoading:d}=Te(),{isLoading:f}=js(),{isError:p,errorState:m}=Dt(),{seed:w,reset:v}=$l();return d||f?c.jsx(zr,{}):p(ue.PROJECT,u)?c.jsx(Bt,{message:`Error loading project ${u}`}):p(ue.INTEGRATION_LIST,u)?c.jsx(Bt,{message:"Error retrieving integrations for the project, double check the API key"}):(h=m[ue.INTEGRATION_LIST])!=null&&h.apiError?c.jsx(Bt,{message:"Something went wrong, couldn't find integration information"}):c.jsx("div",{className:Ul.resetContainer,children:c.jsx(dy,{integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:l,children:c.jsx(Vl,{children:c.jsx(kd,{consumerRef:t,consumerName:n,groupRef:r,groupName:o,resetComponent:v,children:c.jsx(Ky,{resetComponent:v,children:c.jsx(tx,{children:c.jsx(Zy,{children:c.jsx(a_,{children:c.jsx(Qb,{})})})})})})})},w)})}function l_(){return c.jsxs(Jr,{style:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[c.jsx(ai,{}),c.jsx("p",{children:"Redirecting"})]})}function u_({redirectURL:e,children:t}){return y.useEffect(()=>{e&&window.location.replace(e)},[e]),e?c.jsx(l_,{}):t}function d_({resetComponent:e,onDisconnectSuccess:t,provider:n}){const[r,o]=y.useState(!1);return c.jsxs(c.Fragment,{children:[r===!1&&c.jsxs(c.Fragment,{children:[c.jsx(Ct,{string:"Manage connection"}),c.jsxs("div",{style:{padding:"1rem 0",width:"100%",display:"flex",flexDirection:"column",gap:"1rem"},children:[c.jsx("p",{children:"Click to reauthenticate or refresh your connection."}),c.jsx(Je,{type:"button",onClick:()=>o(!0),variant:"ghost",style:{fontSize:"13px"},children:"Update connection"})]})]}),r===!0&&c.jsxs(c.Fragment,{children:[c.jsx(Pd,{provider:n}),c.jsx(Ct,{string:"Remove connection"}),c.jsx("p",{children:"Click to disconnect your connection from the provider."}),c.jsx(iu,{resetComponent:e,onDisconnectSuccess:t,buttonText:"Remove connection",buttonVariant:"danger",buttonStyle:{fontSize:"13px"}})]})]})}function f_({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 c.jsx(wa,{text:i,children:c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",width:"100%"},children:c.jsx(d_,{resetComponent:n,onDisconnectSuccess:t,provider:e})})})}function p_({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,redirectUrl:i,onSuccess:s,onDisconnectSuccess:a,onConnectSuccess:l}){const{seed:u,reset:d}=$l(),f=y.useCallback(p=>{s?s(p.id):l&&l(p)},[s,l]);return c.jsx("div",{className:Ul.resetContainer,children:c.jsx(Vl,{groupRef:r,provider:e,children:c.jsx(kd,{resetComponent:d,provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onSuccess:f,onDisconnectSuccess:a,children:c.jsx(u_,{redirectURL:i,children:c.jsx(f_,{resetComponent:d,provider:e,onDisconnectSuccess:a})})})})},u)}const h_=(e,t)=>{const{data:n,isLoading:r,isError:o,error:i}=jl(e,t),s=((n==null?void 0:n.length)||0)>0,a=!!n&&!r;return y.useEffect(()=>{o&&Le(i)},[o,i]),{isLoaded:a,isIntegrationInstalled:s,isLoading:r}};exports.AmpersandContext=Pl;exports.AmpersandProvider=Bg;exports.ConnectProvider=p_;exports.InstallIntegration=c_;exports.useAmpersandProvider=Wg;exports.useIsIntegrationInstalled=h_;
|
|
50
|
+
*/const FI="react-tooltip-core-styles",DI="react-tooltip-base-styles",Sc={core:!1,base:!1};function Nc({css:e,id:t=DI,type:n="base",ref:r}){var o,i;if(!e||typeof document>"u"||Sc[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=FI),r||(r={});const{insertAt:s}=r;if(document.getElementById(t))return;const a=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.id=t,l.type="text/css",s==="top"&&a.firstChild?a.insertBefore(l,a.firstChild):a.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e)),Sc[n]=!0}const Tc=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:r="top",offset:o=10,strategy:i="absolute",middlewares:s=[TI(Number(o)),AI({fallbackAxisSideDirection:"start"}),RI({padding:5})],border:a})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};if(t===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};const l=s;return n?(l.push(PI({element:n,padding:5})),Ec(e,t,{placement:r,strategy:i,middleware:l}).then(({x:u,y:d,placement:f,middlewareData:p})=>{var m,w;const v={left:`${u}px`,top:`${d}px`,border:a},{x:h,y:x}=(m=p.arrow)!==null&&m!==void 0?m:{x:0,y:0},g=(w={top:"bottom",right:"left",bottom:"top",left:"right"}[f.split("-")[0]])!==null&&w!==void 0?w:"bottom",b=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:h!=null?`${h}px`:"",top:x!=null?`${x}px`:"",right:"",bottom:"",...b,[g]:`-${4+_}px`},place:f}})):Ec(e,t,{placement:"bottom",strategy:i,middleware:l}).then(({x:u,y:d,placement:f})=>({tooltipStyles:{left:`${u}px`,top:`${d}px`},tooltipArrowStyles:{},place:f}))},Rc=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),Ac=(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},Pc=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(!Pc(e)||!Pc(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]))},MI=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"})},Fc=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(MI(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},kI=typeof window<"u"?y.useLayoutEffect:y.useEffect,Rt=e=>{e.current&&(clearTimeout(e.current),e.current=null)},jI="DEFAULT_TOOLTIP_ID",LI={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},KI=y.createContext({getTooltipData:()=>LI});function hd(e=jI){return y.useContext(KI).getTooltipData(e)}var wr={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"},Bo={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 VI=({forwardRef:e,id:t,className:n,classNameArrow:r,variant:o="dark",anchorId:i,anchorSelect:s,place:a="top",offset:l=10,events:u=["hover"],openOnClick:d=!1,positionStrategy:f="absolute",middlewares:p,wrapper:m,delayShow:w=0,delayHide:v=0,float:h=!1,hidden:x=!1,noArrow:g=!1,clickable:b=!1,closeOnEsc:_=!1,closeOnScroll:C=!1,closeOnResize:R=!1,openEvents:N,closeEvents:T,globalCloseEvents:F,imperativeModeOnly:$,style:G,position:z,afterShow:ne,afterHide:B,disableTooltip:ce,content:se,contentWrapperRef:te,isOpen:ge,defaultIsOpen:we=!1,setIsOpen:A,activeAnchor:k,setActiveAnchor:U,border:L,opacity:j,arrowColor:D,role:Y="tooltip"})=>{var Z;const q=y.useRef(null),ee=y.useRef(null),Q=y.useRef(null),de=y.useRef(null),M=y.useRef(null),[ve,H]=y.useState({tooltipStyles:{},tooltipArrowStyles:{},place:a}),[Ee,Ve]=y.useState(!1),[Ye,Ue]=y.useState(!1),[Ie,Mt]=y.useState(null),Ze=y.useRef(!1),vt=y.useRef(null),{anchorRefs:kt,setActiveAnchor:jt}=hd(t),et=y.useRef(!1),[Ge,$e]=y.useState([]),Pe=y.useRef(!1),Lt=d||u.includes("click"),it=Lt||(N==null?void 0:N.click)||(N==null?void 0:N.dblclick)||(N==null?void 0:N.mousedown),sn=N?{...N}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!N&&Lt&&Object.assign(sn,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const In=T?{...T}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!T&&Lt&&Object.assign(In,{mouseleave:!1,blur:!1,mouseout:!1});const wt=F?{...F}:{escape:_||!1,scroll:C||!1,resize:R||!1,clickOutsideAnchor:it||!1};$&&(Object.assign(sn,{mouseenter:!1,focus:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(In,{mouseleave:!1,blur:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(wt,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),kI(()=>(Pe.current=!0,()=>{Pe.current=!1}),[]);const Fe=J=>{Pe.current&&(J&&Ue(!0),setTimeout(()=>{Pe.current&&(A==null||A(J),ge===void 0&&Ve(J))},10))};y.useEffect(()=>{if(ge===void 0)return()=>null;ge&&Ue(!0);const J=setTimeout(()=>{Ve(ge)},10);return()=>{clearTimeout(J)}},[ge]),y.useEffect(()=>{if(Ee!==Ze.current)if(Rt(M),Ze.current=Ee,Ee)ne==null||ne();else{const J=(ae=>{const le=ae.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"));M.current=setTimeout(()=>{Ue(!1),Mt(null),B==null||B()},J+25)}},[Ee]);const an=J=>{H(ae=>Ns(ae,J)?ae:J)},bn=(J=w)=>{Rt(Q),Ye?Fe(!0):Q.current=setTimeout(()=>{Fe(!0)},J)},cn=(J=v)=>{Rt(de),de.current=setTimeout(()=>{et.current||Fe(!1)},J)},Hn=J=>{var ae;if(!J)return;const le=(ae=J.currentTarget)!==null&&ae!==void 0?ae:J.target;if(!(le!=null&&le.isConnected))return U(null),void jt({current:null});w?bn():Fe(!0),U(le),jt({current:le}),Rt(de)},ft=()=>{b?cn(v||100):v?cn():Fe(!1),Rt(Q)},ln=({x:J,y:ae})=>{var le;const Ke={getBoundingClientRect:()=>({x:J,y:ae,width:0,height:0,top:ae,left:J,right:J,bottom:ae})};Tc({place:(le=Ie==null?void 0:Ie.place)!==null&&le!==void 0?le:a,offset:l,elementReference:Ke,tooltipReference:q.current,tooltipArrowReference:ee.current,strategy:f,middlewares:p,border:L}).then(He=>{an(He)})},xn=J=>{if(!J)return;const ae=J,le={x:ae.clientX,y:ae.clientY};ln(le),vt.current=le},Bn=J=>{var ae;if(!Ee)return;const le=J.target;le.isConnected&&(!((ae=q.current)===null||ae===void 0)&&ae.contains(le)||[document.querySelector(`[id='${i}']`),...Ge].some(Ke=>Ke==null?void 0:Ke.contains(le))||(Fe(!1),Rt(Q)))},_n=Ac(Hn,50),Ae=Ac(ft,50),ot=J=>{Ae.cancel(),_n(J)},ie=()=>{_n.cancel(),Ae()},me=y.useCallback(()=>{var J,ae;const le=(J=Ie==null?void 0:Ie.position)!==null&&J!==void 0?J:z;le?ln(le):h?vt.current&&ln(vt.current):k!=null&&k.isConnected&&Tc({place:(ae=Ie==null?void 0:Ie.place)!==null&&ae!==void 0?ae:a,offset:l,elementReference:k,tooltipReference:q.current,tooltipArrowReference:ee.current,strategy:f,middlewares:p,border:L}).then(Ke=>{Pe.current&&an(Ke)})},[Ee,k,se,G,a,Ie==null?void 0:Ie.place,l,f,z,Ie==null?void 0:Ie.position,h]);y.useEffect(()=>{var J,ae;const le=new Set(kt);Ge.forEach(Se=>{ce!=null&&ce(Se)||le.add({current:Se})});const Ke=document.querySelector(`[id='${i}']`);Ke&&!(ce!=null&&ce(Ke))&&le.add({current:Ke});const He=()=>{Fe(!1)},pt=Fc(k),Qe=Fc(q.current);wt.scroll&&(window.addEventListener("scroll",He),pt==null||pt.addEventListener("scroll",He),Qe==null||Qe.addEventListener("scroll",He));let tt=null;wt.resize?window.addEventListener("resize",He):k&&q.current&&(tt=NI(k,q.current,me,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const ht=Se=>{Se.key==="Escape"&&Fe(!1)};wt.escape&&window.addEventListener("keydown",ht),wt.clickOutsideAnchor&&window.addEventListener("click",Bn);const Ne=[],Jn=Se=>{Ee&&(Se==null?void 0:Se.target)===k||Hn(Se)},So=Se=>{Ee&&(Se==null?void 0:Se.target)===k&&ft()},St=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],xi=["click","dblclick","mousedown","mouseup"];Object.entries(sn).forEach(([Se,Kt])=>{Kt&&(St.includes(Se)?Ne.push({event:Se,listener:ot}):xi.includes(Se)&&Ne.push({event:Se,listener:Jn}))}),Object.entries(In).forEach(([Se,Kt])=>{Kt&&(St.includes(Se)?Ne.push({event:Se,listener:ie}):xi.includes(Se)&&Ne.push({event:Se,listener:So}))}),h&&Ne.push({event:"pointermove",listener:xn});const _i=()=>{et.current=!0},Ci=()=>{et.current=!1,ft()};return b&&!it&&((J=q.current)===null||J===void 0||J.addEventListener("mouseenter",_i),(ae=q.current)===null||ae===void 0||ae.addEventListener("mouseleave",Ci)),Ne.forEach(({event:Se,listener:Kt})=>{le.forEach(Vt=>{var Wn;(Wn=Vt.current)===null||Wn===void 0||Wn.addEventListener(Se,Kt)})}),()=>{var Se,Kt;wt.scroll&&(window.removeEventListener("scroll",He),pt==null||pt.removeEventListener("scroll",He),Qe==null||Qe.removeEventListener("scroll",He)),wt.resize?window.removeEventListener("resize",He):tt==null||tt(),wt.clickOutsideAnchor&&window.removeEventListener("click",Bn),wt.escape&&window.removeEventListener("keydown",ht),b&&!it&&((Se=q.current)===null||Se===void 0||Se.removeEventListener("mouseenter",_i),(Kt=q.current)===null||Kt===void 0||Kt.removeEventListener("mouseleave",Ci)),Ne.forEach(({event:Vt,listener:Wn})=>{le.forEach(No=>{var Xr;(Xr=No.current)===null||Xr===void 0||Xr.removeEventListener(Vt,Wn)})})}},[k,me,Ye,kt,Ge,N,T,F,Lt,w,v]),y.useEffect(()=>{var J,ae;let le=(ae=(J=Ie==null?void 0:Ie.anchorSelect)!==null&&J!==void 0?J:s)!==null&&ae!==void 0?ae:"";!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(k){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 Jn;return!!(!((Jn=Ne==null?void 0:Ne.contains)===null||Jn===void 0)&&Jn.call(Ne,k))&&(Ue(!1),Fe(!1),U(null),Rt(Q),Rt(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,Ie==null?void 0:Ie.anchorSelect,k]),y.useEffect(()=>{me()},[me]),y.useEffect(()=>{if(!(te!=null&&te.current))return()=>null;const J=new ResizeObserver(()=>{setTimeout(()=>me())});return J.observe(te.current),()=>{J.disconnect()}},[se,te==null?void 0:te.current]),y.useEffect(()=>{var J;const ae=document.querySelector(`[id='${i}']`),le=[...Ge,ae];k&&le.includes(k)||U((J=Ge[0])!==null&&J!==void 0?J:ae)},[i,Ge,k]),y.useEffect(()=>(we&&Fe(!0),()=>{Rt(Q),Rt(de)}),[]),y.useEffect(()=>{var J;let ae=(J=Ie==null?void 0:Ie.anchorSelect)!==null&&J!==void 0?J:s;if(!ae&&t&&(ae=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),ae)try{const le=Array.from(document.querySelectorAll(ae));$e(le)}catch{$e([])}},[t,s,Ie==null?void 0:Ie.anchorSelect]),y.useEffect(()=>{Q.current&&(Rt(Q),bn(w))},[w]);const qe=(Z=Ie==null?void 0:Ie.content)!==null&&Z!==void 0?Z:se,un=Ee&&Object.keys(ve.tooltipStyles).length>0;return y.useImperativeHandle(e,()=>({open:J=>{if(J!=null&&J.anchorSelect)try{document.querySelector(J.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${J.anchorSelect}" is not a valid CSS selector`)}Mt(J??null),J!=null&&J.delay?bn(J.delay):Fe(!0)},close:J=>{J!=null&&J.delay?cn(J.delay):Fe(!1)},activeAnchor:k,place:ve.place,isOpen:!!(Ye&&!x&&qe&&un)})),Ye&&!x&&qe?y.createElement(m,{id:t,role:Y,className:Ft("react-tooltip",wr.tooltip,Bo.tooltip,Bo[o],n,`react-tooltip__place-${ve.place}`,wr[un?"show":"closing"],un?"react-tooltip__show":"react-tooltip__closing",f==="fixed"&&wr.fixed,b&&wr.clickable),onTransitionEnd:J=>{Rt(M),Ee||J.propertyName!=="opacity"||(Ue(!1),Mt(null),B==null||B())},style:{...G,...ve.tooltipStyles,opacity:j!==void 0&&un?j:void 0},ref:q},qe,y.createElement(m,{className:Ft("react-tooltip-arrow",wr.arrow,Bo.arrow,r,g&&wr.noArrow),style:{...ve.tooltipArrowStyles,background:D?`linear-gradient(to right bottom, transparent 50%, ${D} 50%)`:void 0},ref:ee})):null},UI=({content:e})=>y.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),$I=y.forwardRef(({id:e,anchorId:t,anchorSelect:n,content:r,html:o,render:i,className:s,classNameArrow:a,variant:l="dark",place:u="top",offset:d=10,wrapper:f="div",children:p=null,events:m=["hover"],openOnClick:w=!1,positionStrategy:v="absolute",middlewares:h,delayShow:x=0,delayHide:g=0,float:b=!1,hidden:_=!1,noArrow:C=!1,clickable:R=!1,closeOnEsc:N=!1,closeOnScroll:T=!1,closeOnResize:F=!1,openEvents:$,closeEvents:G,globalCloseEvents:z,imperativeModeOnly:ne=!1,style:B,position:ce,isOpen:se,defaultIsOpen:te=!1,disableStyleInjection:ge=!1,border:we,opacity:A,arrowColor:k,setIsOpen:U,afterShow:L,afterHide:j,disableTooltip:D,role:Y="tooltip"},Z)=>{const[q,ee]=y.useState(r),[Q,de]=y.useState(o),[M,ve]=y.useState(u),[H,Ee]=y.useState(l),[Ve,Ye]=y.useState(d),[Ue,Ie]=y.useState(x),[Mt,Ze]=y.useState(g),[vt,kt]=y.useState(b),[jt,et]=y.useState(_),[Ge,$e]=y.useState(f),[Pe,Lt]=y.useState(m),[it,sn]=y.useState(v),[In,wt]=y.useState(null),[Fe,an]=y.useState(null),bn=y.useRef(ge),{anchorRefs:cn,activeAnchor:Hn}=hd(e),ft=Ae=>Ae==null?void 0:Ae.getAttributeNames().reduce((ot,ie)=>{var me;return ie.startsWith("data-tooltip-")&&(ot[ie.replace(/^data-tooltip-/,"")]=(me=Ae==null?void 0:Ae.getAttribute(ie))!==null&&me!==void 0?me:null),ot},{}),ln=Ae=>{const ot={place:ie=>{var me;ve((me=ie)!==null&&me!==void 0?me:u)},content:ie=>{ee(ie??r)},html:ie=>{de(ie??o)},variant:ie=>{var me;Ee((me=ie)!==null&&me!==void 0?me:l)},offset:ie=>{Ye(ie===null?d:Number(ie))},wrapper:ie=>{var me;$e((me=ie)!==null&&me!==void 0?me:f)},events:ie=>{const me=ie==null?void 0:ie.split(" ");Lt(me??m)},"position-strategy":ie=>{var me;sn((me=ie)!==null&&me!==void 0?me:v)},"delay-show":ie=>{Ie(ie===null?x:Number(ie))},"delay-hide":ie=>{Ze(ie===null?g:Number(ie))},float:ie=>{kt(ie===null?b:ie==="true")},hidden:ie=>{et(ie===null?_:ie==="true")},"class-name":ie=>{wt(ie)}};Object.values(ot).forEach(ie=>ie(null)),Object.entries(Ae).forEach(([ie,me])=>{var qe;(qe=ot[ie])===null||qe===void 0||qe.call(ot,me)})};y.useEffect(()=>{ee(r)},[r]),y.useEffect(()=>{de(o)},[o]),y.useEffect(()=>{ve(u)},[u]),y.useEffect(()=>{Ee(l)},[l]),y.useEffect(()=>{Ye(d)},[d]),y.useEffect(()=>{Ie(x)},[x]),y.useEffect(()=>{Ze(g)},[g]),y.useEffect(()=>{kt(b)},[b]),y.useEffect(()=>{et(_)},[_]),y.useEffect(()=>{sn(v)},[v]),y.useEffect(()=>{bn.current!==ge&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")},[ge]),y.useEffect(()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:ge==="core",disableBase:ge}}))},[]),y.useEffect(()=>{var Ae;const ot=new Set(cn);let ie=n;if(!ie&&e&&(ie=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),ie)try{document.querySelectorAll(ie).forEach(ae=>{ot.add({current:ae})})}catch{console.warn(`[react-tooltip] "${ie}" is not a valid CSS selector`)}const me=document.querySelector(`[id='${t}']`);if(me&&ot.add({current:me}),!ot.size)return()=>null;const qe=(Ae=Fe??me)!==null&&Ae!==void 0?Ae:Hn.current,un=new MutationObserver(ae=>{ae.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)})}),J={attributes:!0,childList:!1,subtree:!1};if(qe){const ae=ft(qe);ln(ae),un.observe(qe,J)}return()=>{un.disconnect()}},[cn,Hn,Fe,t,n]),y.useEffect(()=>{B!=null&&B.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),we&&!Rc("border",`${we}`)&&console.warn(`[react-tooltip] "${we}" is not a valid \`border\`.`),B!=null&&B.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),A&&!Rc("opacity",`${A}`)&&console.warn(`[react-tooltip] "${A}" is not a valid \`opacity\`.`)},[]);let xn=p;const Bn=y.useRef(null);if(i){const Ae=i({content:(Fe==null?void 0:Fe.getAttribute("data-tooltip-content"))||q||null,activeAnchor:Fe});xn=Ae?y.createElement("div",{ref:Bn,className:"react-tooltip-content-wrapper"},Ae):null}else q&&(xn=q);Q&&(xn=y.createElement(UI,{content:Q}));const _n={forwardRef:Z,id:e,anchorId:t,anchorSelect:n,className:Ft(s,In),classNameArrow:a,content:xn,contentWrapperRef:Bn,place:M,variant:H,offset:Ve,wrapper:Ge,events:Pe,openOnClick:w,positionStrategy:it,middlewares:h,delayShow:Ue,delayHide:Mt,float:vt,hidden:jt,noArrow:C,clickable:R,closeOnEsc:N,closeOnScroll:T,closeOnResize:F,openEvents:$,closeEvents:G,globalCloseEvents:z,imperativeModeOnly:ne,style:B,position:ce,isOpen:se,defaultIsOpen:te,border:we,opacity:A,arrowColor:k,setIsOpen:U,afterShow:L,afterHide:j,disableTooltip:D,activeAnchor:Fe,setActiveAnchor:Ae=>an(Ae),role:Y};return y.createElement(VI,{..._n})});typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",e=>{e.detail.disableCore||Nc({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||Nc({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 qI(){return c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:[c.jsxs("g",{clipPath:"url(#clip0_2896_16290)",children:[c.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"}),c.jsx("path",{d:"M8.00293 5.83301L7.99768 5.83301",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})]}),c.jsx("defs",{children:c.jsx("clipPath",{id:"clip0_2896_16290",children:c.jsx("rect",{width:"16",height:"16",fill:"white",transform:"translate(16 16.5) rotate(180)"})})})]})}function HI({id:e,tooltipText:t}){return c.jsxs(c.Fragment,{children:[c.jsx("span",{"data-tooltip-id":e,style:{maxWidth:"20rem"},children:qI()}),c.jsx($I,{id:e,place:"top",content:t,style:{maxWidth:"30rem"}})]})}const BI="Each field must be mapped to a unique value";function fa({field:e,onSelectChange:t,allFields:n}){var g;const{configureState:r,selectedObjectName:o,setConfigureState:i}=Xt(),[s,a]=y.useState(!0),{isError:l,removeError:u,getError:d}=Dt(),f=(g=r==null?void 0:r.read)==null?void 0:g.selectedFieldMappings,p=f==null?void 0:f[e.mapToName];y.useEffect(()=>{e._default&&!p&&o&&r&&ui(o,i,[{field:e.mapToName,value:e._default}]),a(!1)},[e,i,o,p,r]);const m=y.useMemo(()=>n.map(b=>({id:b.fieldName,label:b.displayName,value:b.fieldName})),[n]),w=c.jsx(id,{disabled:s,items:m,selectedValue:p||null,onSelectedItemChange:b=>{t({target:{name:e.mapToName,value:b==null?void 0:b.value}})},placeholder:"Please select one",style:{width:"100%"}}),v=y.useCallback(()=>{o&&(ui(o,i,[{field:e.mapToName,value:null}]),l(ue.MAPPING,o)&&u(ue.MAPPING,o))},[e.mapToName,o,i,l,u]),{hasDuplicationError:h,errorMessage:x}=y.useMemo(()=>{const b=d(ue.MAPPING,o),_=Array.isArray(b)&&b.length>0&&b.includes(e.mapToName);return{hasDuplicationError:_,errorMessage:_?BI:""}},[o,d,e.mapToName]);return c.jsxs(c.Fragment,{children:[c.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[c.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem",marginBottom:".25rem"},children:[c.jsx("span",{style:{fontWeight:500},children:e.mapToDisplayName??e.mapToName}),c.jsx("span",{children:(e==null?void 0:e.prompt)&&c.jsx(HI,{id:`tooltip-id-${e==null?void 0:e.prompt}`,tooltipText:e==null?void 0:e.prompt})})]}),c.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[w,c.jsx(ze,{type:"button",variant:"ghost",onClick:v,children:"Clear"})]})]},e.mapToName),h&&c.jsxs("span",{style:{color:"red",fontSize:"14px",marginTop:"4px"},children:[" ",x," "]},e.mapToName)]})}const JI="_formControl_9qd8d_1",WI="_formLabel_9qd8d_5",zI="_formLabelRequired_9qd8d_11",GI="_formInput_9qd8d_16",QI="_formInputInvalid_9qd8d_20",XI="_formError_9qd8d_24",YI="_disabled_9qd8d_30",Qn={formControl:JI,formLabel:WI,formLabelRequired:zI,formInput:GI,formInputInvalid:QI,formError:XI,disabled:YI};function bo({id:e,label:t,isRequired:n=!1,isDisabled:r=!1,isInvalid:o=!1,errorMessage:i,children:s}){return c.jsxs("div",{className:Ft(Qn.formControl,{[Qn.disabled]:r}),children:[t&&c.jsx("label",{htmlFor:e,className:Ft(Qn.formLabel,{[Qn.formLabelRequired]:n}),children:t}),c.jsx("div",{id:e,className:Ft(Qn.formInput,{[Qn.formInputInvalid]:o}),children:s}),o&&i&&c.jsx("div",{className:Qn.formError,role:"alert",children:i})]})}const ZI="_divider_1kmoj_1",Dc={divider:ZI};function xo({className:e,style:t}){return c.jsx("hr",{className:e?`${Dc.divider} ${e}`:Dc.divider,style:t})}function Ot({string:e}){return c.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"1rem",paddingBottom:".5rem"},children:[c.jsx("h3",{style:{color:"var(--amp-colors-text-muted)",fontSize:"1rem",fontWeight:"400"},children:e}),c.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:c.jsx(xo,{style:{width:"100%",marginLeft:"1rem"}})})]})}function md({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(l=>e[l]===r),a=[n,...s];return o(ue.MAPPING,t,a),!0}return!1}function eb({dynamicFieldMappings:e,onSelectChange:t,allFields:n}){return e.length?c.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:e.map(r=>c.jsx(bo,{id:r.mapToName,children:c.jsx(fa,{allFields:n,field:r,onSelectChange:t})},r.mapToName))}):null}function tb(){var w,v;const{selectedObjectName:e,configureState:t,setConfigureState:n}=Xt(),{isError:r,removeError:o,setError:i}=Dt(),s=((w=t==null?void 0:t.read)==null?void 0:w.allFields)||[],{fieldMapping:a}=rt(),l=(v=t==null?void 0:t.read)==null?void 0:v.selectedFieldMappings,u=h=>{const{value:x,name:g}=h.target;!x||md({selectedFieldMappings:l,selectedObjectName:e,fieldName:g,fieldValue:x,setError:i})||(e&&ui(e,n,[{field:g,value:x}]),r(ue.MAPPING,g)&&o(ue.MAPPING,g),e&&r(ue.MAPPING,e)&&o(ue.MAPPING,e))},d=y.useMemo(()=>!e||!a?[]:Object.values(a[e]||{}).flat().filter(h=>!h.fieldName),[a,e]),f=y.useMemo(()=>{var g;return(((g=t==null?void 0:t.read)==null?void 0:g.optionalMapFields)||[]).filter(b=>!d.some(_=>_.mapToName===b.mapToName))},[t,d]),p=d.length>0;return f.length>0||p?c.jsxs(c.Fragment,{children:[c.jsx(Ot,{string:"Map the following optional fields"}),c.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:[f==null?void 0:f.map(h=>c.jsx(bo,{id:h.mapToName,children:c.jsx(fa,{allFields:s,field:h,onSelectChange:u})},h.mapToName)),p&&c.jsx(eb,{dynamicFieldMappings:d,onSelectChange:u,allFields:s})]})]}):null}function nb(){var u;const{selectedObjectName:e,configureState:t,setConfigureState:n}=Xt(),{isError:r,removeError:o,setError:i}=Dt(),s=(u=t==null?void 0:t.read)==null?void 0:u.selectedFieldMappings,a=d=>{const{value:f,name:p}=d.target;!f||md({selectedFieldMappings:s,selectedObjectName:e,fieldName:p,fieldValue:f,setError:i})||(e&&ui(e,n,[{field:p,value:f}]),r(ue.MAPPING,p)&&o(ue.MAPPING,p),e&&r(ue.MAPPING,e)&&o(ue.MAPPING,e))},l=y.useMemo(()=>{var d;return((d=t==null?void 0:t.read)==null?void 0:d.requiredMapFields)||[]},[t]);return l!=null&&l.length?c.jsxs(c.Fragment,{children:[c.jsx(Ot,{string:"Map the following fields"}),c.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:l.map(d=>{var f;return c.jsx(bo,{id:d.mapToName,isInvalid:r(ue.MAPPING,d.mapToName),errorMessage:"* required",children:c.jsx(fa,{allFields:((f=t==null?void 0:t.read)==null?void 0:f.allFields)||[],field:d,onSelectChange:a})},d.mapToName)})})]}):null}const rb={backgroundColor:"var(--amp-colors-bg-highlight)",borderColor:"var(--amp-colors-bg-highlight)",padding:".5rem 1rem"};function ib({children:e,style:t}){return c.jsx(wn,{style:{...rb,...t},children:e})}const pa=e=>{const t=dt(),{provider:n}=rt(),r=e||n;return vn({queryKey:["amp","providerInfo",r],queryFn:async()=>{if(!r)throw new Error("Provider not found");return(await t()).providerApi.getProvider({provider:r})},enabled:!!r})},ct=e=>{const t=pa(e),{data:n}=t,{provider:r}=rt(),o=n&&Ul(n==null?void 0:n.name,n);return{...t,providerName:o,selectedProvider:e||r}};function ob(){var u,d,f;const{project:e}=Te(),{hydratedRevision:t}=Gr(),{selectedObjectName:n}=Xt(),{providerName:r}=ct(),o=e==null?void 0:e.appName,i=(f=(d=(u=t==null?void 0:t.content)==null?void 0:u.read)==null?void 0:d.objects)==null?void 0:f.find(p=>p.objectName===n),s=(i==null?void 0:i.displayName)||n&&kr(n),a=i==null?void 0:i.mapToName,l=(i==null?void 0:i.mapToDisplayName)||a&&kr(a);return l&&o&&r?c.jsx(ib,{style:{marginTop:"1rem"},children:c.jsxs("p",{style:{margin:"1rem 0"},children:[c.jsx("b",{children:l})," in ",o," is mapped to ",c.jsx("b",{children:s})," in ",r,"."]})}):null}function Mc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function gd(...e){return t=>{let n=!1;const r=e.map(o=>{const i=Mc(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():Mc(e[o],null)}}}}function fi(...e){return V.useCallback(gd(...e),e)}function _o(e,t=[]){let n=[];function r(i,s){const a=V.createContext(s),l=n.length;n=[...n,s];const u=f=>{var x;const{scope:p,children:m,...w}=f,v=((x=p==null?void 0:p[e])==null?void 0:x[l])||a,h=V.useMemo(()=>w,Object.values(w));return c.jsx(v.Provider,{value:h,children:m})};u.displayName=i+"Provider";function d(f,p){var v;const m=((v=p==null?void 0:p[e])==null?void 0:v[l])||a,w=V.useContext(m);if(w)return w;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[u,d]}const o=()=>{const i=n.map(s=>V.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return V.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,sb(o,...t)]}function sb(...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:l,scopeName:u})=>{const f=l(i)[`__scope${u}`];return{...a,...f}},{});return V.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)}}function ha(e){const t=V.useRef(e);return V.useEffect(()=>{t.current=e}),V.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function ma({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=ab({defaultProp:t,onChange:n}),i=e!==void 0,s=i?e:r,a=ha(n),l=V.useCallback(u=>{if(i){const f=typeof u=="function"?u(e):u;f!==e&&a(f)}else o(u)},[i,e,o,a]);return[s,l]}function ab({defaultProp:e,onChange:t}){const n=V.useState(e),[r]=n,o=V.useRef(r),i=ha(t);return V.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}function cb(e){const t=V.useRef({value:e,previous:e});return V.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var co=globalThis!=null&&globalThis.document?V.useLayoutEffect:()=>{};function lb(e){const[t,n]=V.useState(void 0);return co(()=>{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 l=i.borderBoxSize,u=Array.isArray(l)?l[0]:l;s=u.inlineSize,a=u.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}function ub(e,t){return V.useReducer((n,r)=>t[n][r]??n,e)}var ga=e=>{const{present:t,children:n}=e,r=db(t),o=typeof n=="function"?n({present:r.isPresent}):V.Children.only(n),i=fi(r.ref,fb(o));return typeof n=="function"||r.isPresent?V.cloneElement(o,{ref:i}):null};ga.displayName="Presence";function db(e){const[t,n]=V.useState(),r=V.useRef({}),o=V.useRef(e),i=V.useRef("none"),s=e?"mounted":"unmounted",[a,l]=ub(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return V.useEffect(()=>{const u=Ui(r.current);i.current=a==="mounted"?u:"none"},[a]),co(()=>{const u=r.current,d=o.current;if(d!==e){const p=i.current,m=Ui(u);e?l("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&p!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),co(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const v=Ui(r.current).includes(m.animationName);if(m.target===t&&v&&(l("ANIMATION_END"),!o.current)){const h=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=h)})}},p=m=>{m.target===t&&(i.current=Ui(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:V.useCallback(u=>{u&&(r.current=getComputedStyle(u)),n(u)},[])}}function Ui(e){return(e==null?void 0:e.animationName)||"none"}function fb(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 lo=V.forwardRef((e,t)=>{const{children:n,...r}=e,o=V.Children.toArray(n),i=o.find(hb);if(i){const s=i.props.children,a=o.map(l=>l===i?V.Children.count(s)>1?V.Children.only(null):V.isValidElement(s)?s.props.children:null:l);return c.jsx(Ts,{...r,ref:t,children:V.isValidElement(s)?V.cloneElement(s,void 0,a):null})}return c.jsx(Ts,{...r,ref:t,children:n})});lo.displayName="Slot";var Ts=V.forwardRef((e,t)=>{const{children:n,...r}=e;if(V.isValidElement(n)){const o=gb(n),i=mb(r,n.props);return n.type!==V.Fragment&&(i.ref=t?gd(t,o):o),V.cloneElement(n,i)}return V.Children.count(n)>1?V.Children.only(null):null});Ts.displayName="SlotClone";var pb=({children:e})=>c.jsx(c.Fragment,{children:e});function hb(e){return V.isValidElement(e)&&e.type===pb}function mb(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function gb(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 yb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],$n=yb.reduce((e,t)=>{const n=V.forwardRef((r,o)=>{const{asChild:i,...s}=r,a=i?lo:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...s,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),ya="Checkbox",[vb,tC]=_o(ya),[wb,Ib]=vb(ya),yd=V.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[p,m]=V.useState(null),w=fi(t,_=>m(_)),v=V.useRef(!1),h=p?d||!!p.closest("form"):!0,[x=!1,g]=ma({prop:o,defaultProp:i,onChange:u}),b=V.useRef(x);return V.useEffect(()=>{const _=p==null?void 0:p.form;if(_){const C=()=>g(b.current);return _.addEventListener("reset",C),()=>_.removeEventListener("reset",C)}},[p,g]),c.jsxs(wb,{scope:n,state:x,disabled:a,children:[c.jsx($n.button,{type:"button",role:"checkbox","aria-checked":Ln(x)?"mixed":x,"aria-required":s,"data-state":Id(x),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:w,onKeyDown:Wt(e.onKeyDown,_=>{_.key==="Enter"&&_.preventDefault()}),onClick:Wt(e.onClick,_=>{g(C=>Ln(C)?!0:!C),h&&(v.current=_.isPropagationStopped(),v.current||_.stopPropagation())})}),h&&c.jsx(bb,{control:p,bubbles:!v.current,name:r,value:l,checked:x,required:s,disabled:a,form:d,style:{transform:"translateX(-100%)"},defaultChecked:Ln(i)?!1:i})]})});yd.displayName=ya;var vd="CheckboxIndicator",wd=V.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=Ib(vd,n);return c.jsx(ga,{present:r||Ln(i.state)||i.state===!0,children:c.jsx($n.span,{"data-state":Id(i.state),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});wd.displayName=vd;var bb=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...i}=e,s=V.useRef(null),a=cb(n),l=lb(t);V.useEffect(()=>{const d=s.current,f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(a!==n&&m){const w=new Event("click",{bubbles:r});d.indeterminate=Ln(n),m.call(d,Ln(n)?!1:n),d.dispatchEvent(w)}},[a,n,r]);const u=V.useRef(Ln(n)?!1:n);return c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??u.current,...i,tabIndex:-1,ref:s,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function Ln(e){return e==="indeterminate"}function Id(e){return Ln(e)?"indeterminate":e?"checked":"unchecked"}var bd=yd,xd=wd;function _d(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 xb=["color"],Cd=y.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=_d(e,xb);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"}))}),_b=["color"],Cb=y.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=_d(e,_b);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 Ob="_checkboxGroupContainer_1ya1t_1",Eb="_stack_1ya1t_6",Sb="_selectAllContainer_1ya1t_11",Nb="_fieldContainer_1ya1t_18",Tb="_checkbox_1ya1t_1",Hr={checkboxGroupContainer:Ob,stack:Eb,selectAllContainer:Sb,fieldContainer:Nb,checkbox:Tb};function Od({id:e,isChecked:t,label:n,onCheckedChange:r}){return c.jsxs("div",{className:Hr.fieldContainer,children:[c.jsx(bd,{className:Hr.checkbox,id:e,onCheckedChange:r,checked:t,children:c.jsx(xd,{children:c.jsx(Cd,{})})}),c.jsx("label",{htmlFor:e,style:{overflowWrap:"anywhere"},children:n})]})}function Ed({id:e,isChecked:t,label:n,onCheckedChange:r,isIndeterminate:o}){return c.jsxs("div",{className:Hr.selectAllContainer,children:[c.jsx(bd,{className:Hr.checkbox,id:e,onCheckedChange:r,children:c.jsxs(xd,{children:[o&&c.jsx(Cb,{}),t===!0&&c.jsx(Cd,{})]})}),c.jsx("label",{htmlFor:e,children:n})]})}function Sd({children:e}){return c.jsx("div",{className:Hr.checkboxGroupContainer,children:e})}function Nd({children:e}){return c.jsx("div",{className:Hr.stack,children:e})}function Rb(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,l=!Yl(s,r);e.read.isOptionalFieldsModified=l}else console.warn("read.savedConfig.optionalFields is undefined")}function kc(e,t,n,r){t(e,o=>Rb(o,n,r))}function Ab(){var f,p;const{appName:e,configureState:t,setConfigureState:n,selectedObjectName:r}=Xt(),o=(f=t==null?void 0:t.read)==null?void 0:f.selectedOptionalFields,i=(m,w)=>{m!=="indeterminate"&&r&&t&&kc(r,n,w,m)},s=(p=t==null?void 0:t.read)==null?void 0:p.optionalFields,a=m=>{r&&s&&s.forEach(w=>{Kn(w)||kc(r,n,w.fieldName,m)})},l=!!(s&&s.length>0),u=Object.keys(o||{}).length===(s==null?void 0:s.length),d=!u&&Object.keys(o||{}).length>0;return l&&c.jsxs(c.Fragment,{children:[c.jsx(Ot,{string:`${e} reads the following optional fields`}),c.jsxs(Sd,{children:[((s==null?void 0:s.length)||0)>=2&&c.jsx(Ed,{id:"select-all-fields",isChecked:u,label:"Select all",onCheckedChange:a,isIndeterminate:d}),c.jsx(Nd,{children:s.map(m=>Kn(m)?null:c.jsx(Od,{id:m.fieldName,isChecked:!!(o!=null&&o[m==null?void 0:m.fieldName]),label:m.displayName,onCheckedChange:w=>i(w,m.fieldName)},m.fieldName))})]})]})}function Pb(){return c.jsx(Ab,{})}const Fb={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 Db({children:e,style:t,...n}){return c.jsx("span",{style:{...Fb,...t},...n,children:e})}function Mb(){var r,o,i;const{configureState:e,selectedObjectName:t}=Xt(),{appName:n}=Te();return c.jsxs(c.Fragment,{children:[c.jsx(Ot,{string:`${n} reads the following fields`}),c.jsx("div",{style:{display:"flex",gap:".5rem",marginBottom:".5rem",flexWrap:"wrap"},children:(o=(r=e==null?void 0:e.read)==null?void 0:r.requiredFields)!=null&&o.length?(i=e.read)==null?void 0:i.requiredFields.map(s=>Kn(s)?null:c.jsx(Db,{children:s.displayName},s.fieldName)):"There are no required fields."})]})}function kb(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 Td(e,t,n,r,o){t(e,i=>kb(i,e,n,r,o))}function jb(e,t,n){t(e,r=>{r.read&&(r.read.isValueMappingsModified=n)})}function Lb({string:e,fieldName:t}){return c.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"1rem",paddingBottom:".5rem"},children:[c.jsxs("h3",{style:{color:"var(--amp-colors-text-muted)",fontSize:"1rem",fontWeight:"400"},children:[e,c.jsx("b",{children:t})]}),c.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:c.jsx(xo,{style:{width:"100%",marginLeft:"1rem"}})})]})}function Kb({mappedValue:e,onSelectChange:t,fieldName:n,allValueOptions:r,hasError:o}){var C;const{configureState:i,selectedObjectName:s,setConfigureState:a}=Xt(),[l,u]=y.useState(!0),{getError:d,setError:f,resetBoundary:p,isError:m,removeError:w}=Dt(),v=y.useMemo(()=>{var R,N;return((N=(R=i==null?void 0:i.read)==null?void 0:R.selectedValueMappings)==null?void 0:N[n])||{}},[(C=i==null?void 0:i.read)==null?void 0:C.selectedValueMappings,n]),h=y.useMemo(()=>v==null?void 0:v[e.mappedValue],[v,e.mappedValue]);y.useEffect(()=>{u(!1)},[e,a,s,h,i]);const x=y.useMemo(()=>r.map(R=>({id:R.value,label:R.displayValue,value:R.value})),[r]),g=y.useCallback(R=>{if(R){if(Object.values(v).some(N=>N===R.value&&N!==h)){const N=[...Object.entries(v).filter(([T,F])=>F===R.value&&F!==h).map(([T])=>T),e.mappedValue];f(ue.VALUE_MAPPING,n,N);return}d(ue.VALUE_MAPPING,n)&&p(ue.VALUE_MAPPING),t({target:{name:e.mappedValue,value:R.value,fieldName:n}})}},[t,v,h,n,e.mappedValue,p,f,d]),b=y.useMemo(()=>c.jsx(id,{disabled:l,items:x,selectedValue:h||null,onSelectedItemChange:g,placeholder:"Please select one",style:{border:o?"2px solid red":void 0,borderRadius:"8px",width:"100%"}},h),[h,l,x,g,o]),_=y.useCallback(()=>{s&&(Td(s,a,e.mappedValue,"",n),m(ue.VALUE_MAPPING,n)&&w(ue.VALUE_MAPPING,n))},[s,a,e.mappedValue,n,m,w]);return c.jsxs("div",{style:{display:"flex",flexDirection:"column",marginBottom:".25rem"},children:[c.jsx("div",{style:{display:"flex",flexDirection:"row",gap:".25rem",marginBottom:".25rem"},children:c.jsx("span",{style:{fontWeight:500},children:e.mappedDisplayValue})}),c.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[b,c.jsx(ze,{type:"button",variant:"ghost",onClick:_,children:"Clear"})]})]},e.mappedValue)}function Vb(){var m,w,v;const{fieldMapping:e}=rt(),{selectedObjectName:t,configureState:n,setConfigureState:r}=Xt(),{isError:o,removeError:i,getError:s}=Dt(),a=(m=n==null?void 0:n.read)==null?void 0:m.selectedFieldMappings,l=(w=n==null?void 0:n.read)==null?void 0:w.selectedValueMappings,u=(v=n==null?void 0:n.read)==null?void 0:v.isValueMappingsModified,d=y.useRef(!1),f=y.useMemo(()=>{const h=t&&e?Object.values(e[t]||{}).flat().filter(x=>x.mappedValues).map(x=>({...x})):[];if(a)for(let x=0;x<h.length;x+=1){const{mapToName:g}=h[x];a!=null&&a[g]&&(h[x].fieldName=a[g])}return h},[t,e,a]),p=y.useCallback(h=>{const{value:x,name:g,fieldName:b}=h.target;x&&(t&&Td(t,r,g,x,b),o(ue.VALUE_MAPPING,g)&&i(ue.VALUE_MAPPING,g))},[t,r,o,i]);return y.useEffect(()=>{var h;if(t&&l){const x=((h=e==null?void 0:e[t])==null?void 0:h.filter(b=>b.fieldName&&b.mappedValues.length>0))||[];x.every(b=>{const _=l[b.fieldName]||{};return Object.keys(_).length===Object.keys(b.mappedValues).length})&&x.length>0?!u&&!d.current&&(jb(t,r,!0),d.current=!0):d.current=!1}},[l,f,t,r,e,u]),f!=null&&f.length?c.jsx(c.Fragment,{children:f.map(h=>{var R,N,T;if(!h.fieldName)return null;const x=(N=(R=n==null?void 0:n.read)==null?void 0:R.allFieldsMetadata)==null?void 0:N[h.fieldName],g=x==null?void 0:x.valueType;if(!["singleSelect","multiSelect"].includes(g))return console.error("fieldName is not a singleSelect or multiSelect",h),null;const b=x==null?void 0:x.values;if(!b)return null;const _=Object.keys(b).length,C=Object.keys((h==null?void 0:h.mappedValues)||[]).length;return _!==C?(console.error("field values and the values to be mapped are not of the same length",h,b),null):c.jsxs(c.Fragment,{children:[c.jsx(Lb,{string:"Map the values for ",fieldName:h.mapToDisplayName||h.mapToName||h.fieldName}),c.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:c.jsx(bo,{id:h.mapToName||h.fieldName,children:(T=h==null?void 0:h.mappedValues)==null?void 0:T.map(F=>{var ne,B,ce;const $=s(ue.VALUE_MAPPING,h.fieldName),G=Array.isArray($)&&$.includes(F.mappedValue),z=((ce=(B=(ne=n==null?void 0:n.read)==null?void 0:ne.allFieldsMetadata)==null?void 0:B[h.fieldName])==null?void 0:ce.values)||[];return c.jsxs(c.Fragment,{children:[c.jsx(Kb,{allValueOptions:z,mappedValue:F,onSelectChange:p,fieldName:(h==null?void 0:h.fieldName)||"",hasError:G},`${F.mappedValue}-${h.fieldName}`),G&&c.jsx("span",{style:{color:"red",fontSize:"14px",marginTop:"4px"},children:`Each ${h.mapToName||h.fieldName} must be mapped to a unique value`},F.mappedValue)]})})},h.mapToName||h.fieldName)})]})})}):null}function Ub(){return Vv(),c.jsxs(c.Fragment,{children:[c.jsx(ob,{}),c.jsx(Mb,{}),c.jsx(nb,{}),c.jsx(tb,{}),c.jsx(Vb,{}),c.jsx(Pb,{})]})}function $b(e,t,n){var r,o,i;if(((r=e==null?void 0:e.write)==null?void 0:r.selectedWriteObjects)===null&&(e.write.selectedWriteObjects={}),e!=null&&e.write){const s=e.write.selectedWriteObjects;if(n&&(s[t]={objectName:t}),n||delete s[t],(i=(o=e==null?void 0:e.write)==null?void 0:o.savedConfig)!=null&&i.selectedWriteObjects){const a=e.write.savedConfig.selectedWriteObjects,u=!ov(a,s);e.write.isWriteModified=u}}}function jc(e,t,n,r){t(e,o=>{$b(o,n,r)})}function qb(){var f,p,m,w;const{appName:e,selectedObjectName:t,configureState:n,setConfigureState:r}=Xt(),o=(f=n==null?void 0:n.write)==null?void 0:f.selectedWriteObjects,i=(p=n==null?void 0:n.write)==null?void 0:p.writeObjects,s=(v,h)=>{v!=="indeterminate"&&t&&n&&jc(t,r,h,v)},a=v=>{var h,x;t&&n&&((x=(h=n==null?void 0:n.write)==null?void 0:h.writeObjects)==null||x.forEach(g=>{jc(t,r,g.objectName,v)}))},l=!!i,u=Object.keys(o||{}).length===((w=(m=n==null?void 0:n.write)==null?void 0:m.writeObjects)==null?void 0:w.length),d=!u&&Object.keys(o||{}).length>0;return l&&c.jsxs(c.Fragment,{children:[c.jsx(Ot,{string:`Allow ${e} to write to these objects`}),c.jsxs(Sd,{children:[((i==null?void 0:i.length)||0)>=2&&c.jsx(Ed,{id:"select-all-fields",onCheckedChange:a,isIndeterminate:d,isChecked:u,label:"Select all"}),c.jsx(Nd,{children:i.map(v=>c.jsx(Od,{id:v.objectName,onCheckedChange:h=>s(h,v.objectName),isChecked:!!(o!=null&&o[v.objectName]),label:v.displayName},v.objectName))})]})]})}function Hb(){return c.jsx(c.Fragment,{children:c.jsx(qb,{})})}const Bb="_link_oo2kv_1",Jb={link:Bb};function Rd({href:e,className:t,style:n,label:r,children:o,newTab:i=!1}){return c.jsx("a",{className:Ft(Jb.link,t),style:n,href:e,"aria-label":r||void 0,target:i?"_blank":"_self",rel:i?"noopener noreferrer":void 0,children:o})}function Ad({url:e,providerDisplayName:t,credentialName:n}){return c.jsxs("p",{style:{color:"var(--amp-colors-text-muted)"},children:[c.jsx(Rd,{href:e,newTab:!0,children:c.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," about where to find your ",t," ",n,"."]})}function qn({error:e}){return e?c.jsx(vi,{style:{marginTop:"2em"},children:e}):null}const Wb="_input_1ymb7_1",zb="_inputError_1ymb7_27",Gb="_error_1ymb7_43",Jo={input:Wb,inputError:zb,error:Gb};function Qb({id:e,type:t,className:n,isError:r=!1,...o}){const i=r?Ft(Jo.inputError,Jo.input):Jo.input;return c.jsx("input",{id:e,type:t,className:Ft(i,n),...o})}const Xb="_textarea_18zl4_1",Yb="_textareaError_18zl4_14",Zb="_error_18zl4_29",Wo={textarea:Xb,textareaError:Yb,error:Zb};function ex({className:e,isError:t=!1,...n}){const r=t?Ft(Wo.textareaError,Wo.textarea):Wo.textarea;return c.jsx("textarea",{className:Ft(e,r),...n})}const gn={Input:Qb,Textarea:ex},tx=()=>{const{project:e}=Te(),t=e==null?void 0:e.id,n=dt();return vn({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 Pd(){var n,r;const{data:e}=tx();return((r=(n=e==null?void 0:e.entitlements)==null?void 0:n.brandingRemoval)==null?void 0:r.value)===!0?null:c.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:[c.jsx("p",{style:{color:"light-dark(gray, #EFEFEF)"},children:"Secured by"}),c.jsx("a",{href:"https://www.withampersand.com/",target:"_blank","aria-label":"Go to Ampersand",rel:"noreferrer noopener",children:c.jsxs("picture",{children:[c.jsx("source",{srcSet:"https://res.cloudinary.com/dycvts6vp/image/upload/v1723671980/ampersand-logo-black.svg",media:"(prefers-color-scheme: light)"}),c.jsx("source",{srcSet:"https://res.cloudinary.com/dycvts6vp/image/upload/v1735853540/ampersand_logo_white.svg",media:"(prefers-color-scheme: dark)"}),c.jsx("img",{style:{height:".8em"},src:"https://res.cloudinary.com/dycvts6vp/image/upload/v1723671980/ampersand-logo-black.svg",alt:"Ampersand"})]})})]})}function gr({children:e}){return c.jsx(Wr,{children:c.jsxs(wn,{children:[c.jsx("div",{style:{padding:"3rem 2rem"},children:e}),c.jsx(Pd,{})]})})}function yr({children:e}){return c.jsx("h1",{style:{fontWeight:600,lineHeight:1.2,fontSize:"1.2em"},children:e})}function nx({children:e}){return c.jsx("p",{style:{padding:".5em 0"},children:e})}function Fd({provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:r,buttonVariant:o,submitButtonType:i}){var h;const[s,a]=y.useState(!1),l=()=>a(x=>!x),[u,d]=y.useState(""),f=x=>d(x.currentTarget.value),{providerName:p}=ct(e),m=u.length>0,w=r||!m,v=(h=t.apiKeyOpts)==null?void 0:h.docsURL;return c.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[v&&c.jsx(Ad,{url:v,providerDisplayName:p||kr(e),credentialName:"API key"}),c.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[c.jsx(gn.Input,{id:"password",name:"password",type:s?"text":"password",placeholder:"API Key",onChange:x=>f(x)}),c.jsx(ze,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:l,variant:o,children:s?"Hide":"Show"})]}),c.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:w,type:i||"submit",onClick:()=>n({apiKey:u}),variant:o,children:"Next"})]})}function rx({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){const{providerName:i}=ct(e);return c.jsxs(gr,{children:[c.jsx(yr,{children:`Set up ${i} integration`}),c.jsx(qn,{error:r}),c.jsx(Fd,{provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:o})]})}function ix({...e}){return c.jsx(rx,{...e})}const ox={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 Co({children:e,style:t}){return c.jsx(wn,{style:{...ox,...t},children:e})}const va=()=>{const e=dt(),t=Et(),[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 sx({provider:e}){const{projectIdOrName:t}=Te(),{providerName:n,data:r}=ct(e),{selectedConnection:o,isConnectionsLoading:i}=Qt(),{mutateAsync:s,isPending:a,error:l}=va(),[u,d]=y.useState(null),[f,p]=y.useState(!1),m=()=>p(!1),w=()=>{p(!0),d(null)},v=(l==null?void 0:l.message)||u||null,h=async x=>{m(),d(null);try{await s({projectIdOrName:t||"",connectionId:(o==null?void 0:o.id)||"",updateConnectionRequest:{updateMask:["apiKey"],connection:{apiKey:x.apiKey}}},{onError:g=>{console.error("Update connection error:",g),Le(g,d)},onSuccess:()=>{w()}})}catch(g){console.error("Update connection caught error:",g),Le(g,d)}};return r?c.jsxs(c.Fragment,{children:[c.jsx(Ot,{string:"Update connection"}),c.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[c.jsx("p",{children:`Update ${n} API Key`}),f&&c.jsx(Co,{children:"Connection updated successfully"}),v&&c.jsx(vi,{children:`Error updating connection ${v}`}),c.jsx(Fd,{provider:r==null?void 0:r.name,providerInfo:r,handleSubmit:h,isButtonDisabled:a||i,buttonVariant:"ghost",submitButtonType:"button"})]})]}):null}function Dd({provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:r,buttonVariant:o}){var h;const[i,s]=y.useState(!1),a=()=>s(x=>!x),[l,u]=y.useState({username:"",password:""}),{username:d,password:f}=l,{providerName:p}=ct(e),m=x=>{const{name:g,value:b}=x.currentTarget;u(_=>({..._,[g]:b}))},w=r,v=(h=t.basicOpts)==null?void 0:h.docsURL;return c.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[v&&c.jsx(Ad,{url:v,providerDisplayName:p||kr(e),credentialName:"credentials"}),c.jsx(gn.Input,{id:"username",name:"username",type:"text",placeholder:"Username",onChange:x=>m(x)}),c.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[c.jsx(gn.Input,{id:"password",name:"password",type:i?"text":"password",placeholder:"Password",onChange:x=>m(x)}),c.jsx(ze,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:a,variant:o,children:i?"Hide":"Show"})]}),c.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:w,type:"button",onClick:()=>n({user:d,pass:f}),variant:o,children:"Next"})]})}function ax({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){const{providerName:i}=ct(e);return c.jsxs(gr,{children:[c.jsx(yr,{children:`Set up ${i} integration`}),c.jsx(qn,{error:r}),c.jsx(Dd,{provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:o})]})}function cx({...e}){return c.jsx(ax,{...e})}function lx({provider:e}){const{projectIdOrName:t}=Te(),{providerName:n,data:r}=ct(e),{selectedConnection:o,isConnectionsLoading:i}=Qt(),{mutateAsync:s,isPending:a,error:l}=va(),[u,d]=y.useState(null),[f,p]=y.useState(!1),m=()=>p(!1),w=()=>{p(!0),d(null)},v=(l==null?void 0:l.message)||u||null,h=async x=>{m(),d(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:g=>{console.error(g),Le(g,d)},onSuccess:()=>{w()}})}catch(g){console.error(g),Le(g,d)}};return r?c.jsxs(c.Fragment,{children:[c.jsx(Ot,{string:"Update connection"}),c.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[c.jsx("p",{children:`Update ${n} credentials`}),f&&c.jsx(Co,{children:"Connection updated successfully"}),v&&c.jsx(vi,{children:`Error updating connection: ${v}`}),c.jsx(Dd,{provider:r==null?void 0:r.name,providerInfo:r,handleSubmit:h,isButtonDisabled:a||i,buttonVariant:"ghost"})]})]}):null}function Md({handleSubmit:e,isButtonDisabled:t,explicitScopesRequired:n,explicitWorkspaceRequired:r,buttonVariant:o}){const[i,s]=y.useState(!1),[a,l]=y.useState({clientSecret:"",clientId:"",workspace:"",scopes:""}),u=()=>s(_=>!_),d=_=>{const{name:C,value:R}=_.currentTarget;l(N=>({...N,[C]:R}))},{clientSecret:f,clientId:p,workspace:m,scopes:w}=a,v=f.length>0,h=p.length>0,x=r?m.length>0:!0,g=t||!v||!h||!x,b=()=>{const _={clientId:p,clientSecret:f};r&&(_.workspace=m),n&&w.length>0&&(_.scopes=By(w)),e(_)};return c.jsxs(c.Fragment,{children:[c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.2rem"},children:[r&&c.jsx(gn.Input,{id:"workspace",name:"workspace",type:"text",placeholder:"MyWorkspace",onChange:_=>d(_)}),c.jsx(gn.Input,{id:"clientId",name:"clientId",type:"text",placeholder:"Client ID",onChange:_=>d(_)}),c.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[c.jsx(gn.Input,{id:"clientSecret",name:"clientSecret",type:i?"text":"password",placeholder:"Client Secret",onChange:_=>d(_)}),c.jsx(ze,{type:"button",style:{height:"2.5rem",width:"5rem"},onClick:u,variant:o,children:i?"Hide":"Show"})]}),n&&c.jsx(gn.Textarea,{name:"scopes",placeholder:"Scopes separated by new line",onChange:_=>d(_)})]}),c.jsx("br",{}),c.jsx(ze,{style:{width:"100%"},disabled:g,type:"button",onClick:b,variant:o,children:"Next"})]})}function ux({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r,explicitScopesRequired:o,explicitWorkspaceRequired:i}){return c.jsxs(gr,{children:[c.jsx(yr,{children:`Set up ${r} integration`}),c.jsx(qn,{error:t}),c.jsx("br",{}),c.jsx(Md,{handleSubmit:e,isButtonDisabled:n,explicitScopesRequired:o,explicitWorkspaceRequired:i})]})}function dx({provider:e}){var g;const{projectIdOrName:t}=Te(),{selectedConnection:n,isConnectionsLoading:r}=Qt(),{providerName:o,data:i}=ct(e),{mutateAsync:s,isPending:a,error:l}=va(),[u,d]=y.useState(null),[f,p]=y.useState(!1),m=()=>{p(!1)},w=()=>{p(!0),d(null)},v=(g=i==null?void 0:i.oauth2Opts)==null?void 0:g.explicitScopesRequired,h=(l==null?void 0:l.message)||u||null,x=async b=>{m(),d(null);try{await s({projectIdOrName:t||"",connectionId:(n==null?void 0:n.id)||"",updateConnectionRequest:{updateMask:["oauth2ClientCredentials"],connection:{oauth2ClientCredentials:{clientId:b.clientId,clientSecret:b.clientSecret,scopes:b.scopes}}}}),w()}catch(_){Le(_,d)}};return c.jsxs(c.Fragment,{children:[c.jsx(Ot,{string:"Update connection"}),c.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[c.jsx("p",{children:`Re-authenticate to ${o}`}),f&&c.jsx(Co,{children:"Connection updated successfully"}),h&&c.jsx(vi,{children:`Error updating connection ${h}`}),c.jsx(Md,{handleSubmit:x,isButtonDisabled:a||r,explicitScopesRequired:v,explicitWorkspaceRequired:!1,buttonVariant:"ghost"})]})]})}const Lc=600,Kc=600,fx="AUTHORIZATION_SUCCEEDED",px="AUTHORIZATION_FAILED";function hx(e,t,n,r){return y.useCallback(()=>{if(!r)return;const o=window.screenX+(window.outerWidth-Lc)/2,i=window.screenY+(window.outerHeight-Kc)/2.5,s=`width=${Lc},height=${Kc},left=${o},top=${i}`,a=window.open(r,e,s);t(a),window.addEventListener("message",n,!1)},[r,e,t,n])}function mx(e,t,n,r){const o=Et();return y.useCallback(i=>{var s,a;if(i.origin===xy){if(i.data.eventType===fx){const l=(s=i.data.data)==null?void 0:s.connection;l?(e(l),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===px&&(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 wa({children:e,oauthUrl:t,windowTitle:n="Connect to Provider",onError:r,error:o,onSuccessConnect:i,isSuccessConnect:s}){const[a,l]=y.useState(null),[u,d]=y.useState(null),f=mx(l,u,r,i),p=hx(n,d,f,t);return y.useEffect(()=>{t&&!u&&!a&&!o&&!s&&p()},[t,u,p,a,o,s]),y.useEffect(()=>{if(!u)return;const m=setInterval(()=>{u.closed&&(clearInterval(m),window.removeEventListener("message",f),d(null),!a&&!o?(console.error("OAuth failed. Please try again."),r==null||r("Authentication was cancelled. Please try again.")):a&&(r==null||r(null)))},500);return()=>{clearInterval(m),window.removeEventListener("message",f)}},[u,a,o,f,r]),c.jsx("div",{children:e})}const gx=()=>{const e=dt(),t=Et();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 yx({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return c.jsxs("div",{style:{padding:"1rem 0"},children:[c.jsx("p",{children:`Re-authenticate to ${r}`}),c.jsx(qn,{error:t}),c.jsx(ze,{variant:"ghost",style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function vx({provider:e}){const{selectedConnection:t,isConnectionsLoading:n}=Qt(),r=t==null?void 0:t.id,o=t==null?void 0:t.projectId,{providerName:i}=ct(e),{mutateAsync:s,isPending:a,error:l}=gx(),[u,d]=y.useState(null),[f,p]=y.useState(!1),[m,w]=y.useState(null),v=()=>{p(!1)},h=()=>{p(!0),d(null),w(null)},x=(l==null?void 0:l.message)||u||null,g=async()=>{v(),d(null);try{const _=await s({projectIdOrName:o||"",connectionId:r||""});w(_)}catch(_){Le(_,d)}},b=y.useCallback(_=>{d(_)},[]);return c.jsxs(c.Fragment,{children:[c.jsx(Ot,{string:"Update connection"}),f&&c.jsx(Co,{children:"Connection updated successfully"}),c.jsx(wa,{windowTitle:`Connect to ${i}`,oauthUrl:m||null,onError:b,error:x,isSuccessConnect:f,onSuccessConnect:h,children:c.jsx(yx,{handleSubmit:g,error:x,providerName:i,isButtonDisabled:a||n||f})})]})}function kd({provider:e}){var r;const{data:t}=pa(e);if((t==null?void 0:t.authType)===Ha.Basic)return c.jsx(lx,{provider:e});if((t==null?void 0:t.authType)===Ha.ApiKey)return c.jsx(sx,{provider:e});const n=(r=t==null?void 0:t.oauth2Opts)==null?void 0:r.grantType;if(n){if(n===Fo.AuthorizationCode||n===Fo.AuthorizationCodePkce)return c.jsx(vx,{provider:e});if(n===Fo.ClientCredentials)return c.jsx(dx,{provider:e})}return null}const wx="_authenticationRow_cjz1t_1",Ix="_field_cjz1t_8",bx="_value_cjz1t_12",zo={authenticationRow:wx,field:Ix,value:bx};function Vc({label:e,value:t}){return c.jsxs("div",{className:zo.authenticationRow,children:[c.jsx("div",{className:zo.field,children:e}),c.jsx("div",{className:zo.value,children:t})]})}function xx(){const{selectedConnection:e}=Qt(),{providerName:t}=ct(),r=(e==null?void 0:e.provider)==="salesforce"?"subdomain":"workspace",o=`${t} ${r}`;return c.jsxs(c.Fragment,{children:[c.jsx(Ot,{string:"Connection details"}),c.jsxs("div",{style:{paddingBottom:"1rem"},children:[c.jsx(Vc,{label:o,value:e==null?void 0:e.providerWorkspaceRef}),c.jsx(Vc,{label:"Status",value:e==null?void 0:e.status})]})]})}const _x=()=>{const e=dt(),t=Et();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 jd({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={}}){const{projectId:r}=Te(),{integrationId:o,installation:i,setIntegrationDeleted:s,onUninstallSuccess:a}=rt(),[l,u]=y.useState(!1),d=!r||!o||!(i!=null&&i.id)||l,f=_x(),p=async()=>{d||(u(!0),console.warn("uninstalling installation",{projectId:r,integrationId:o,installationId:i.id}),f.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:()=>u(!1)}))},m=l?"Uninstalling...":e,w=c.jsx(ze,{type:"button",onClick:p,disabled:d,variant:t,style:n,children:m});return i!=null&&i.id?w:null}function Cx(){const{installation:e}=rt(),{providerName:t}=ct();return e?c.jsxs(c.Fragment,{children:[c.jsx(Ot,{string:"Uninstall entire integration"}),c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",padding:"1rem 0"},children:[e!=null&&e.id?c.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."]}):c.jsx("p",{children:"You've successfully uninstalled the integration."}),c.jsx(jd,{buttonText:"Yes, uninstall",buttonVariant:"danger"})]})]}):null}function Ox(){return c.jsxs(c.Fragment,{children:[c.jsx(xx,{}),c.jsx(kd,{}),c.jsx(Cx,{})]})}function Ld({onSave:e,onReset:t,isLoading:n,isCreateMode:r=!1,errorMsg:o}){var R,N,T,F;const{installation:i}=rt(),{hydratedRevision:s,loading:a}=Gr(),{configureState:l,selectedObjectName:u}=Xt(),d=i==null?void 0:i.config,f=d&&u&&!!zl(d,u)||!1,p=((R=l==null?void 0:l.read)==null?void 0:R.isOptionalFieldsModified)||((N=l==null?void 0:l.read)==null?void 0:N.isRequiredMapFieldsModified)||((T=l==null?void 0:l.read)==null?void 0:T.isValueMappingsModified),m=(F=l==null?void 0:l.write)==null?void 0:F.isWriteModified,x=a||n||!l||!u||!(p||m||r||u!==dr&&!f),g=u===dr,b=u===Xi,_=c.jsx(ze,{type:"submit",disabled:x,children:r?"Install":"Save"}),C=c.jsx(ze,{type:"button",onClick:t,disabled:x,variant:"ghost",children:"Reset"});return n?c.jsx(ai,{}):c.jsxs("form",{style:{width:"34rem"},onSubmit:e,children:[c.jsx("div",{style:{display:"flex",flexDirection:"row-reverse",gap:".8rem",marginBottom:"20px",height:"3rem"},children:!b&&c.jsxs(c.Fragment,{children:[_,C]})}),c.jsxs(wn,{style:{padding:"1rem 2rem",minHeight:"300px",backgroundColor:"var(--amp-colors-bg-primary)",borderColor:"var(--amp-colors-border)"},children:[o&&c.jsx(vi,{children:typeof o=="string"?o:"Installation Failed."}),a&&c.jsx(ai,{}),s&&!g&&!b&&c.jsx(Ub,{}),s&&g&&!b&&c.jsx(Hb,{}),!a&&b&&c.jsx(Ox,{})]})]})}const Kd=()=>{const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,onInstallSuccess:o,onUpdateSuccess:i}=rt(),{hydratedRevision:s,loading:a}=Gr(),{selectedObjectName:l}=du(),{selectedConnection:u}=Qt(),d=ul(),{projectId:f}=Te(),{resetBoundary:p,setErrors:m,setError:w,getError:v}=Dt(),{resetConfigureState:h,objectConfigurationsState:x,resetPendingConfigurationState:g}=$s(),b=iu(l||"",x),{onNextIncompleteTab:_}=Cv(),C=y.useCallback(()=>{p(ue.INSTALLATION_MUTATION)},[p]),R=y.useCallback(T=>T?F=>{w(ue.INSTALLATION_MUTATION,T,F)}:F=>{console.error("objectName is required to set installation error: ",F)},[w]),N=y.useCallback(T=>T?v(ue.INSTALLATION_MUTATION,T):"",[v]);return{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:s,loading:a,selectedObjectName:l,selectedConnection:u,apiKey:d,projectId:f,resetBoundary:p,setErrors:m,setMutateInstallationError:R,getMutateInstallationError:N,resetMutateInstallationErrorState:C,resetConfigureState:h,objectConfigurationsState:x,resetPendingConfigurationState:g,configureState:b,onInstallSuccess:o,onUpdateSuccess:i,onNextIncompleteTab:_}},Ex=void 0;function Sx(){const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:o,loading:i,selectedObjectName:s,selectedConnection:a,apiKey:l,projectId:u,resetBoundary:d,setErrors:f,setMutateInstallationError:p,getMutateInstallationError:m,resetMutateInstallationErrorState:w,resetConfigureState:v,objectConfigurationsState:h,resetPendingConfigurationState:x,configureState:g,onInstallSuccess:b,onNextIncompleteTab:_}=Kd(),[C,R]=y.useState(!1),N=s===dr,T=m(s),F=y.useCallback(()=>{d(ue.MAPPING),o!=null&&o.content&&!i&&s&&eu(o,Ex,s,v)},[d,o,i,s,v]);y.useEffect(()=>{!g&&(o!=null&&o.content)&&!i&&F()},[g,h,o,i,F]);const $=()=>{w();const{requiredMapFields:ne,selectedFieldMappings:B}=(g==null?void 0:g.read)||{},{errorList:ce}=Xl(ne,B,f);ce.length>0||(s&&(a!=null&&a.id)&&l&&u&&e&&t&&n&&o?(R(!0),dv(u,e,t,n,a.id,s,l,o,g,p(s),r,b).finally(()=>{R(!1),x(s),_()})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},G=()=>{w(),s&&(a!=null&&a.id)&&l&&u&&e&&t&&n&&o?(R(!0),hv(u,e,t,n,a.id,l,o,g,p(s),r,b).finally(()=>{R(!1),x(s),_()})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},z=ne=>{ne.preventDefault(),N?G():$()};return c.jsx(Ld,{errorMsg:T,isCreateMode:!0,isLoading:C,onSave:z,onReset:F})}function Nx({updateConfig:e,projectId:t,integrationId:n,installationId:r,apiKey:o,selectedObjectName:i,setInstallation:s,onUpdateSuccess:a,setError:l}){const u={projectIdOrName:t,installationId:r,integrationId:n,installationUpdate:{updateMask:[`config.content.read.objects.${Wy(i)}`],installation:{config:e}}};return ks().installationApi.updateInstallation(u,{headers:{"X-Api-Key":o,"Content-Type":"application/json"}}).then(d=>{s(d),a==null||a(d.id,d.config)}).catch(d=>{Le(d,l)})}const Tx=(e,t,n,r,o,i)=>{const s=tu(e),a=nu(e),l=ru(e),u={content:{read:{objects:{[t]:{objectName:t,schedule:r,destination:(n==null?void 0:n.destination)||"",selectedFields:s,selectedFieldMappings:a,selectedValueMappings:l||{},backfill:i}}}}};return yi(o)&&(u.content||(u.content={}),u.content.proxy={enabled:!0}),u},Rx=(e,t,n,r,o,i,s,a,l,u,d)=>{const f=Tx(i,r||"",a,a.schedule,l,a.backfill);return f?Nx({updateConfig:f,projectId:e,integrationId:t,installationId:n,apiKey:o,selectedObjectName:r,setError:u,setInstallation:s,onUpdateSuccess:d}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Ax=(e,t)=>{const r={content:{write:{objects:su(e)}}};return yi(t)&&(r.content||(r.content={}),r.content.proxy={enabled:!0}),r},Px=(e,t,n,r,o,i,s,a,l)=>{const u=Ax(o,i);if(!u)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const d={projectIdOrName:e,installationId:n,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:u}}};return ks().installationApi.updateInstallation(d,{headers:{"X-Api-Key":r,"Content-Type":"application/json"}}).then(f=>{a(f),l==null||l(f.id,f.config)}).catch(f=>{Le(f,s)})};function Fx({installation:e,integrationObj:t}){const{setInstallation:n,hydratedRevision:r,loading:o,selectedObjectName:i,apiKey:s,projectId:a,resetBoundary:l,setErrors:u,setMutateInstallationError:d,getMutateInstallationError:f,resetConfigureState:p,resetPendingConfigurationState:m,configureState:w,onUpdateSuccess:v,onNextIncompleteTab:h}=Kd(),[x,g]=y.useState(!1),b=i===dr,_=f(i),{config:C}=e,R=y.useCallback(()=>{l(ue.MAPPING),r!=null&&r.content&&!o&&i&&eu(r,C,i,p)},[l,r,o,i,C,p]);y.useEffect(()=>{w||R()},[w,R]);const N=y.useMemo(()=>{var z,ne,B;return(B=(ne=(z=r==null?void 0:r.content)==null?void 0:z.read)==null?void 0:ne.objects)==null?void 0:B.find(ce=>(ce==null?void 0:ce.objectName)===i)},[r,i]),T=()=>{const{requiredMapFields:G,selectedFieldMappings:z}=(w==null?void 0:w.read)||{},{errorList:ne}=Xl(G,z,u);ne.length>0||(r&&e&&i&&s&&a&&N?(g(!0),Rx(a,t.id,e.id,i,s,w,n,N,r,d(i),v).finally(()=>{g(!1),m(i),h()})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},F=()=>{e&&i&&s&&a&&r?(g(!0),Px(a,t.id,e.id,s,w,r,d(i),n,v).finally(()=>{g(!1),m(i),h()})):console.error("UpdateInstallation - onSaveUpdate missing required props")},$=G=>{G.preventDefault(),b?F():T()};return c.jsx(Ld,{errorMsg:_,onSave:$,onReset:R,isLoading:x})}function Dx(){const{integrationObj:e,installation:t}=rt();return e?t&&e?c.jsx(Fx,{installation:t,integrationObj:e}):c.jsx(Sx,{}):c.jsx(Ll,{message:"We can't load the integration"})}const Mx=()=>{const e=dt(),t=Et(),[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 kx(){return c.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"#BBF7D0"}),c.jsx("path",{d:"M34.6666 18.6667L20 32.0001L13.3333 25.9395",stroke:"#16A34A",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ia({text:e,children:t}){return c.jsx(Wr,{children:c.jsxs(wn,{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"3rem",gap:"3rem"},children:[c.jsx(kx,{}),c.jsx("p",{children:e}),t]})})}function jx({provider:e}){const{providerName:t}=ct(e),n=`You have successfully installed your ${t} integration.`;return c.jsx(Ia,{text:n,children:c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:c.jsx(jd,{buttonText:"Uninstall",buttonVariant:"outline",buttonStyle:{fontSize:"13px"}})})})}const Lx=e=>{const{read:t,write:n}=(e==null?void 0:e.content)??{};return!t&&!n};function Kx({children:e}){var C;const t=y.useRef(!1),{projectId:n}=Te(),{hydratedRevision:r,loading:o}=Gr(),{integrationObj:i,installation:s,groupRef:a,consumerRef:l,onInstallSuccess:u,isIntegrationDeleted:d}=rt(),{mutate:f,isIdle:p,isPending:m,error:w,errorMsg:v}=Mx(),{selectedConnection:h,isConnectionsLoading:x}=Qt(),g=o||m||x,b=(C=r==null?void 0:r.content)==null?void 0:C.provider,_=Lx(r);return y.useEffect(()=>{var R;if(!g&&!x&&r&&_&&!s&&h&&(i!=null&&i.id)&&!d&&b){const N={projectIdOrName:n,integrationId:i==null?void 0:i.id,installation:{groupRef:a,connectionId:h==null?void 0:h.id,config:{content:{provider:b}}}};yi(r)===!0&&(N.installation.config.content.proxy=(R=r==null?void 0:r.content)==null?void 0:R.proxy),p&&!t.current&&(f(N,{onSuccess:T=>{u==null||u(T==null?void 0:T.id,T.config)}}),t.current=!0)}},[r,_,s,h,n,i==null?void 0:i.id,a,l,g,u,d,x,b,f,p]),_&&b&&s?c.jsx(jx,{provider:b}):w?c.jsx(Jt,{message:v??"Create installation failed"}):i?g?c.jsx(zr,{}):c.jsx("div",{children:e}):c.jsx(Jt,{message:"We can't load the integration"})}function Oo(){const e=dt(),t=Et();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 Vx({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a}){const{projectIdOrName:l}=Te(),u=Oo(),d=y.useCallback(f=>{const{apiKey:p}=f,m={projectIdOrName:l,generateConnectionParams:{groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,apiKey:p}};u.mutate(m)},[l,i,o,r,n,e,u]);return a===null?c.jsx(ix,{provider:e,providerInfo:t,handleSubmit:d,error:null}):s}function Ux({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a}){const{projectIdOrName:l}=Te(),u=Oo(),d=y.useCallback(f=>{const{user:p,pass:m}=f,w={projectIdOrName:l,generateConnectionParams:{groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,basicAuth:{username:p,password:m}}};u.mutate(w)},[l,i,o,r,n,e,u]);return a===null?c.jsx(cx,{provider:e,providerInfo:t,handleSubmit:d,error:null}):s}function $x({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 c.jsxs(gr,{children:[c.jsx(yr,{children:i||`Set up ${r} integration`}),c.jsx(qn,{error:t}),o,c.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function qx({...e}){return c.jsx($x,{...e})}function Hx({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,selectedConnection:s,providerName:a}){const{projectIdOrName:l}=Te(),u=Oo(),d=y.useCallback(()=>{const f={projectIdOrName:l,generateConnectionParams:{groupName:o,groupRef:r,consumerName:n,consumerRef:t,provider:e}};u.mutate(f)},[l,o,r,n,t,e,u]);return s===null?c.jsx(qx,{handleSubmit:d,error:null,providerName:a}):i}const Bx=()=>{const e=dt(),{projectIdOrName:t}=Te();return vn({queryKey:["amp","providerApps",t],queryFn:async()=>{if(!t)throw new Error("Project ID is required");return(await e()).providerAppApi.listProviderApps({projectIdOrName:t})},enabled:!!t})},Jx=e=>{const t=dt(),n={connectOAuthParams:e};return vn({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})},Wx=Ls("VITE_AMP_ENABLE_CSRF",!1),zx=Ls("NEXT_AMP_ENABLE_CSRF",!1),Gx=Ls("REACT_APP_AMP_ENABLE_CSRF",!1),Qx=!!Wx||!!zx||!!Gx,Vd=(e,t,n,r,o,i)=>{const{projectId:s}=Te(),{data:a,isLoading:l,error:u}=pa(n),{data:d,isLoading:f,error:p}=Bx(),m=d==null?void 0:d.find(C=>C.provider===n),w=a?Ul(n,a):null,v={providerWorkspaceRef:r,projectId:s,groupRef:t,groupName:i,consumerRef:e,consumerName:o,providerAppId:m==null?void 0:m.id,provider:n,enableCSRFProtection:Qx},{data:h,error:x,isLoading:g,refetch:b}=Jx(v);return y.useEffect(()=>{a&&n&&!m&&console.error(`You must first set up a ${w} Provider App using the Ampersand Console.`)},[m,w,a,n]),y.useEffect(()=>{u&&(console.error("Error fetching provider info:",u),Le(u))},[u]),y.useEffect(()=>{p&&(console.error("Error fetching provider apps:",p),Le(p))},[p]),y.useEffect(()=>{x&&(console.error("Error fetching OAuth connect:",x),Le(x))},[x]),{url:h,error:u||p||x,isLoading:l||f||g,refetchOauthConnect:()=>{var C,R;(a==null?void 0:a.authType)==="oauth2"?((C=a==null?void 0:a.oauth2Opts)==null?void 0:C.grantType)==="authorizationCode"||((R=a==null?void 0:a.oauth2Opts)==null?void 0:R.grantType)==="authorizationCodePKCE"?b():console.error("Provider does not support an OAuth2 web flow grant type."):console.error("Provider does not support an OAuth2 web flow.")}}};function Xx({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return c.jsxs(gr,{children:[c.jsx(yr,{children:`Set up ${r} integration`}),c.jsx(nx,{children:`Click Next to sign into the ${r} account you'd like to sync.`}),c.jsx(qn,{error:t}),c.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function Yx({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,providerName:i}){const[s,a]=y.useState(null),{url:l,error:u,isLoading:d,refetchOauthConnect:f}=Vd(t,r,e,void 0,n,o),p=(u==null?void 0:u.message)||s||null,m=async()=>{a(null),f()},w=y.useCallback(v=>{a(v)},[]);return c.jsx(wa,{windowTitle:`Connect to ${i}`,oauthUrl:l||null,onError:w,children:c.jsx(Xx,{handleSubmit:m,error:p,providerName:i,isButtonDisabled:d})})}const Zx="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function e_({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r}){return c.jsxs(gr,{children:[c.jsx(yr,{children:"Enter your Salesforce subdomain"}),c.jsx(Rd,{href:Zx,newTab:!0,children:"What is my Salesforce subdomain?"}),c.jsx(qn,{error:n}),c.jsxs("div",{style:{display:"flex",marginTop:"1em",alignItems:"center"},children:[c.jsx(gn.Input,{id:"salesforce-subdomain",type:"text",placeholder:"my-domain",onChange:o=>t(o.currentTarget.value)}),c.jsx("p",{style:{lineHeight:"2.2em",marginLeft:"0.4em"},children:".my.salesforce.com"})]}),c.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}function t_({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r,providerName:o}){return c.jsxs(gr,{children:[c.jsxs(yr,{children:["Enter your ",o," workspace"]}),c.jsx(qn,{error:n}),c.jsx("br",{}),c.jsx(gn.Input,{id:"workspace",type:"text",placeholder:"MyWorkspace",onChange:i=>t(i.currentTarget.value)}),c.jsx("br",{}),c.jsx(ze,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}const n_="salesforce";function r_({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,providerName:i}){const[s,a]=y.useState(""),[l,u]=y.useState(null),{url:d,error:f,isLoading:p,refetchOauthConnect:m}=Vd(t,r,e,s,n,o),w=(f==null?void 0:f.message)||l||null,v=async()=>{if(u(null),!s){u("Workspace is required");return}m()},h=y.useCallback(g=>{u(g)},[]),x=e===n_?c.jsx(e_,{handleSubmit:v,setWorkspace:a,error:w,isButtonDisabled:s.length===0}):c.jsx(t_,{handleSubmit:v,setWorkspace:a,error:w,isButtonDisabled:s.length===0||p,providerName:i});return c.jsx(wa,{windowTitle:`Connect to ${i}`,oauthUrl:d||null,onError:h,error:w,children:x})}function i_({provider:e,providerName:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,explicitScopesRequired:s,explicitWorkspaceRequired:a,selectedConnection:l}){const{projectIdOrName:u}=Te(),d=Oo(),[f,p]=y.useState(null),m=y.useCallback(w=>{p(null);const v={projectIdOrName:u,generateConnectionParams:{groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,providerWorkspaceRef:w.workspace,oauth2ClientCredentials:{clientId:w.clientId,clientSecret:w.clientSecret,scopes:w.scopes}}};d.mutate(v,{onError:()=>p("Error loading provider info")})},[u,i,o,r,n,e,d]);return l===null?c.jsx(ux,{providerName:t,handleSubmit:m,error:f,explicitScopesRequired:s,explicitWorkspaceRequired:a}):c.jsx(ai,{})}function o_({...e}){return c.jsx(i_,{...e})}const s_="authorizationCode",a_="authorizationCodePKCE",c_="clientCredentials";function l_({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,selectedConnection:s,setSelectedConnection:a}){const{providerName:l}=ct(e);if(t.oauth2Opts===void 0)return c.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:u,explicitScopesRequired:d,explicitWorkspaceRequired:f}=t.oauth2Opts,p={provider:e,consumerRef:n,consumerName:r,groupRef:o,groupName:i,providerName:l};return u===s_||u===a_?f?c.jsx(r_,{...p}):c.jsx(Yx,{...p}):u===c_?c.jsx(o_,{...p,explicitWorkspaceRequired:f,explicitScopesRequired:d,selectedConnection:s,setSelectedConnection:a}):u==="password"?c.jsx("em",{children:"Password flow not supported yet"}):c.jsxs("em",{children:["Unsupported grant type: ",u]})}function u_(e){const{selectedConnection:t}=Qt();y.useEffect(()=>{e&&t&&e(t)},[e,t])}function d_({onSuccess:e}){u_(e)}function Ud({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,onSuccess:s,onDisconnectSuccess:a,resetComponent:l}){const{data:u,isLoading:d,isError:f,error:p,providerName:m,selectedProvider:w}=ct(e),{provider:v,isIntegrationDeleted:h}=rt(),{selectedConnection:x,setSelectedConnection:g}=Qt();d_({onSuccess:s});const b=Et();y.useEffect(()=>{f&&(console.error("Error loading provider info."),Le(p))},[f,p]);const _=y.useCallback(()=>{b.clear(),l()},[l,b]);if(!e&&!v)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");if(h)return c.jsx(Ia,{text:"Integration successfully uninstalled.",children:c.jsx(ze,{type:"button",onClick:_,style:{width:"100%"},children:"Reinstall Integration"})});if(x)return i;if(d)return c.jsx(zr,{});if(u==null)return c.jsx(Jt,{message:"Provider info was not found."});const C={provider:w,consumerRef:t,consumerName:n,groupRef:r,groupName:o,selectedConnection:x,setSelectedConnection:g,providerName:m,providerInfo:u,onDisconnectSuccess:a};return u.authType==="none"?c.jsx(Hx,{...C,children:i}):u.authType==="basic"?c.jsx(Ux,{...C,children:i}):u.authType==="apiKey"?c.jsx(Vx,{...C,children:i}):c.jsx(l_,{...C})}function f_(e){const t=e+"CollectionProvider",[n,r]=_o(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=m=>{const{scope:w,children:v}=m,h=y.useRef(null),x=y.useRef(new Map).current;return c.jsx(o,{scope:w,itemMap:x,collectionRef:h,children:v})};s.displayName=t;const a=e+"CollectionSlot",l=y.forwardRef((m,w)=>{const{scope:v,children:h}=m,x=i(a,v),g=fi(w,x.collectionRef);return c.jsx(lo,{ref:g,children:h})});l.displayName=a;const u=e+"CollectionItemSlot",d="data-radix-collection-item",f=y.forwardRef((m,w)=>{const{scope:v,children:h,...x}=m,g=y.useRef(null),b=fi(w,g),_=i(u,v);return y.useEffect(()=>(_.itemMap.set(g,{ref:g,...x}),()=>void _.itemMap.delete(g))),c.jsx(lo,{[d]:"",ref:b,children:h})});f.displayName=u;function p(m){const w=i(e+"CollectionConsumer",m);return y.useCallback(()=>{const h=w.collectionRef.current;if(!h)return[];const x=Array.from(h.querySelectorAll(`[${d}]`));return Array.from(w.itemMap.values()).sort((_,C)=>x.indexOf(_.ref.current)-x.indexOf(C.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:s,Slot:l,ItemSlot:f},p,r]}var p_=V.useId||(()=>{}),h_=0;function $d(e){const[t,n]=V.useState(p_());return co(()=>{e||n(r=>r??String(h_++))},[e]),e||(t?`radix-${t}`:"")}var m_=V.createContext(void 0);function qd(e){const t=V.useContext(m_);return e||t||"ltr"}var Go="rovingFocusGroup.onEntryFocus",g_={bubbles:!1,cancelable:!0},Eo="RovingFocusGroup",[Rs,Hd,y_]=f_(Eo),[v_,Bd]=_o(Eo,[y_]),[w_,I_]=v_(Eo),Jd=V.forwardRef((e,t)=>c.jsx(Rs.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Rs.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(b_,{...e,ref:t})})}));Jd.displayName=Eo;var b_=V.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,p=V.useRef(null),m=fi(t,p),w=qd(i),[v=null,h]=ma({prop:s,defaultProp:a,onChange:l}),[x,g]=V.useState(!1),b=ha(u),_=Hd(n),C=V.useRef(!1),[R,N]=V.useState(0);return V.useEffect(()=>{const T=p.current;if(T)return T.addEventListener(Go,b),()=>T.removeEventListener(Go,b)},[b]),c.jsx(w_,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:v,onItemFocus:V.useCallback(T=>h(T),[h]),onItemShiftTab:V.useCallback(()=>g(!0),[]),onFocusableItemAdd:V.useCallback(()=>N(T=>T+1),[]),onFocusableItemRemove:V.useCallback(()=>N(T=>T-1),[]),children:c.jsx($n.div,{tabIndex:x||R===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:Wt(e.onMouseDown,()=>{C.current=!0}),onFocus:Wt(e.onFocus,T=>{const F=!C.current;if(T.target===T.currentTarget&&F&&!x){const $=new CustomEvent(Go,g_);if(T.currentTarget.dispatchEvent($),!$.defaultPrevented){const G=_().filter(se=>se.focusable),z=G.find(se=>se.active),ne=G.find(se=>se.id===v),ce=[z,ne,...G].filter(Boolean).map(se=>se.ref.current);Gd(ce,d)}}C.current=!1}),onBlur:Wt(e.onBlur,()=>g(!1))})})}),Wd="RovingFocusGroupItem",zd=V.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,...s}=e,a=$d(),l=i||a,u=I_(Wd,n),d=u.currentTabStopId===l,f=Hd(n),{onFocusableItemAdd:p,onFocusableItemRemove:m}=u;return V.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),c.jsx(Rs.ItemSlot,{scope:n,id:l,focusable:r,active:o,children:c.jsx($n.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:Wt(e.onMouseDown,w=>{r?u.onItemFocus(l):w.preventDefault()}),onFocus:Wt(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:Wt(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){u.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const v=C_(w,u.orientation,u.dir);if(v!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let x=f().filter(g=>g.focusable).map(g=>g.ref.current);if(v==="last")x.reverse();else if(v==="prev"||v==="next"){v==="prev"&&x.reverse();const g=x.indexOf(w.currentTarget);x=u.loop?O_(x,g+1):x.slice(g+1)}setTimeout(()=>Gd(x))}})})})});zd.displayName=Wd;var x_={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function __(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function C_(e,t,n){const r=__(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return x_[r]}function Gd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function O_(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var E_=Jd,S_=zd,ba="Tabs",[N_,nC]=_o(ba,[Bd]),Qd=Bd(),[T_,xa]=N_(ba),Xd=V.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:l="automatic",...u}=e,d=qd(a),[f,p]=ma({prop:r,onChange:o,defaultProp:i});return c.jsx(T_,{scope:n,baseId:$d(),value:f,onValueChange:p,orientation:s,dir:d,activationMode:l,children:c.jsx($n.div,{dir:d,"data-orientation":s,...u,ref:t})})});Xd.displayName=ba;var Yd="TabsList",Zd=V.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=xa(Yd,n),s=Qd(n);return c.jsx(E_,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:r,children:c.jsx($n.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});Zd.displayName=Yd;var ef="TabsTrigger",tf=V.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=xa(ef,n),a=Qd(n),l=rf(s.baseId,r),u=of(s.baseId,r),d=r===s.value;return c.jsx(S_,{asChild:!0,...a,focusable:!o,active:d,children:c.jsx($n.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":u,"data-state":d?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l,...i,ref:t,onMouseDown:Wt(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(r):f.preventDefault()}),onKeyDown:Wt(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(r)}),onFocus:Wt(e.onFocus,()=>{const f=s.activationMode!=="manual";!d&&!o&&f&&s.onValueChange(r)})})})});tf.displayName=ef;var nf="TabsContent",R_=V.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=xa(nf,n),l=rf(a.baseId,r),u=of(a.baseId,r),d=r===a.value,f=V.useRef(d);return V.useEffect(()=>{const p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),c.jsx(ga,{present:o||d,children:({present:p})=>c.jsx($n.div,{"data-state":d?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!p,id:u,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:p&&i})})});R_.displayName=nf;function rf(e,t){return`${e}-trigger-${t}`}function of(e,t){return`${e}-content-${t}`}var A_=Xd,P_=Zd,sf=tf;const F_=c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[c.jsx("circle",{cx:"9",cy:"9",r:"9",fill:"#BBF7D0"}),c.jsx("path",{d:"M13 7L7.5 12L5 9.72727",stroke:"#16A34A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function D_(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?F_:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:c.jsx("circle",{cx:"9",cy:"9",r:"5",fill:"#BFDBFE"})})}function M_(){return c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.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"}),c.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 k_="_tabsRoot_ktpr0_1",j_="_tabsList_ktpr0_6",L_="_tabTrigger_ktpr0_12",K_="_danger_ktpr0_29",uo={tabsRoot:k_,tabsList:j_,tabTrigger:L_,danger:K_};function V_(){return c.jsxs(c.Fragment,{children:[c.jsx(xo,{style:{margin:"1rem 0"}}),c.jsx(sf,{value:Xi,className:uo.tabTrigger,children:c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[c.jsx(M_,{}),c.jsx("span",{children:"Manage"})]})})]})}function af({objectName:e,completed:t,pending:n,displayName:r}){return c.jsx(sf,{value:e,className:uo.tabTrigger,children:c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[D_(t,n),c.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[c.jsx("span",{children:r||e}),n&&c.jsx("span",{style:{fontSize:".8rem",fontStyle:"italic"},children:"pending"})]})]})})}function U_({completed:e,pending:t,displayName:n}){return c.jsxs(c.Fragment,{children:[c.jsx(xo,{style:{margin:"1rem 0"}}),c.jsx(af,{objectName:dr,completed:e,pending:t,displayName:n},"other-write")]})}function $_({value:e,readNavObjects:t,onValueChange:n,objectConfigurationsState:r,writeNavObject:o}){var i,s;return c.jsx(A_,{value:e,className:uo.tabsRoot,onValueChange:n,children:c.jsxs(P_,{className:uo.tabsList,children:[t.map(a=>{var l,u,d,f,p,m;return c.jsx(af,{objectName:a.name,displayName:a.displayName,completed:a.completed,pending:((u=(l=r==null?void 0:r[a.name])==null?void 0:l.read)==null?void 0:u.isOptionalFieldsModified)||((f=(d=r==null?void 0:r[a.name])==null?void 0:d.read)==null?void 0:f.isRequiredMapFieldsModified)||((m=(p=r==null?void 0:r[a.name])==null?void 0:p.read)==null?void 0:m.isValueMappingsModified)||!1},a.name)}),o&&c.jsx(U_,{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"}),c.jsx(V_,{})]})})}function q_(e,t){return t===Xi?{name:Xi,completed:!1}:e.find(n=>n.name===t)}function H_({children:e}){var x;const{project:t}=Te(),{installation:n}=rt(),{providerName:r}=ct(),{hydratedRevision:o}=Gr(),{objectConfigurationsState:i}=$s(),[s,a]=y.useState(""),l=(t==null?void 0:t.appName)||"",u=n==null?void 0:n.config,d=o&&Gl(u,o),f=d!==null,p=!!((x=o==null?void 0:o.content)!=null&&x.write),m=p?Ql(u):void 0,w=y.useMemo(()=>{const g=[...d||[]];return m&&p&&g.push(m),g},[d,m,p]),v=q_(w,s),h=y.useCallback(()=>{const g=w.find(b=>v!==b&&!b.completed);g&&a(g.name)},[w,v]);return y.useEffect(()=>{!s&&w.length>0&&a(w[0].name)},[w,s,h]),c.jsx(fu.Provider,{value:h,children:c.jsx(uu.Provider,{value:v==null?void 0:v.name,children:c.jsxs(Wr,{style:{maxWidth:"55rem"},children:[c.jsxs(wn,{style:{display:"flex",gap:"1rem",padding:"3rem",paddingBottom:"6rem",backgroundColor:"var(--amp-colors-bg-primary)"},children:[c.jsxs("div",{style:{width:"20rem"},children:[c.jsxs("h1",{style:{fontSize:"small",fontWeight:"400"},children:[r," integration"]}),c.jsx("h3",{style:{marginBottom:"20px",fontSize:"large",fontWeight:"500"},children:l}),f&&c.jsx($_,{value:s,readNavObjects:d,onValueChange:g=>a(g),objectConfigurationsState:i,writeNavObject:m})]}),e]}),c.jsx(Pd,{})]})})})}function B_({...e}){return c.jsx(H_,{...e})}function J_({integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:l}){var h;const{projectIdOrName:u,isLoading:d}=Te(),{isLoading:f}=js(),{isError:p,errorState:m}=Dt(),{seed:w,reset:v}=Bl();return d||f?c.jsx(zr,{}):p(ue.PROJECT,u)?c.jsx(Jt,{message:`Error loading project ${u}`}):p(ue.INTEGRATION_LIST,u)?c.jsx(Jt,{message:"Error retrieving integrations for the project, double check the API key"}):(h=m[ue.INTEGRATION_LIST])!=null&&h.apiError?c.jsx(Jt,{message:"Something went wrong, couldn't find integration information"}):c.jsx("div",{className:Jl.resetContainer,children:c.jsx(Gy,{integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:l,children:c.jsx(Hl,{children:c.jsx(Ud,{consumerRef:t,consumerName:n,groupRef:r,groupName:o,resetComponent:v,children:c.jsx(_v,{resetComponent:v,children:c.jsx(Kx,{children:c.jsx(jv,{children:c.jsx(B_,{children:c.jsx(Dx,{})})})})})})})},w)})}function W_(){return c.jsxs(Wr,{style:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[c.jsx(ai,{}),c.jsx("p",{children:"Redirecting"})]})}function z_({redirectURL:e,children:t}){return y.useEffect(()=>{e&&window.location.replace(e)},[e]),e?c.jsx(W_,{}):t}function G_({resetComponent:e,onDisconnectSuccess:t,provider:n}){const[r,o]=y.useState(!1);return c.jsxs(c.Fragment,{children:[r===!1&&c.jsxs(c.Fragment,{children:[c.jsx(Ot,{string:"Manage connection"}),c.jsxs("div",{style:{padding:"1rem 0",width:"100%",display:"flex",flexDirection:"column",gap:"1rem"},children:[c.jsx("p",{children:"Click to reauthenticate or refresh your connection."}),c.jsx(ze,{type:"button",onClick:()=>o(!0),variant:"ghost",style:{fontSize:"13px"},children:"Update connection"})]})]}),r===!0&&c.jsxs(c.Fragment,{children:[c.jsx(kd,{provider:n}),c.jsx(Ot,{string:"Remove connection"}),c.jsx("p",{children:"Click to disconnect your connection from the provider."}),c.jsx(cu,{resetComponent:e,onDisconnectSuccess:t,buttonText:"Remove connection",buttonVariant:"danger",buttonStyle:{fontSize:"13px"}})]})]})}function Q_({provider:e,onDisconnectSuccess:t,resetComponent:n}){const{appName:r}=Te(),{providerName:o}=ct(e),i=`You have successfully connected your ${o} account to ${r}.`;return c.jsx(Ia,{text:i,children:c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",width:"100%"},children:c.jsx(G_,{resetComponent:n,onDisconnectSuccess:t,provider:e})})})}function X_({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,redirectUrl:i,onSuccess:s,onDisconnectSuccess:a,onConnectSuccess:l}){const{seed:u,reset:d}=Bl(),f=y.useCallback(p=>{s?s(p.id):l&&l(p)},[s,l]);return c.jsx("div",{className:Jl.resetContainer,children:c.jsx(Hl,{groupRef:r,provider:e,children:c.jsx(Ud,{resetComponent:d,provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onSuccess:f,onDisconnectSuccess:a,children:c.jsx(z_,{redirectURL:i,children:c.jsx(Q_,{resetComponent:d,provider:e,onDisconnectSuccess:a})})})})},u)}const Y_=(e,t)=>{const{data:n,isLoading:r,isError:o,error:i}=Vl(e,t),s=((n==null?void 0:n.length)||0)>0,a=!!n&&!r,l=n==null?void 0:n[0],u=l==null?void 0:l.config;return y.useEffect(()=>{o&&Le(i)},[o,i]),{isLoaded:a,isIntegrationInstalled:s,isLoading:r,config:u}};exports.AmpersandContext=kl;exports.AmpersandProvider=Ty;exports.ConnectProvider=X_;exports.InstallIntegration=J_;exports.useAmpersandProvider=Ry;exports.useIsIntegrationInstalled=Y_;
|