@amp-labs/react 2.8.7 → 2.8.9
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.cjs.js.map +1 -1
- package/build/amp-react.es.js +6213 -6117
- package/build/amp-react.es.js.map +1 -1
- package/build/index.d.ts +33 -3
- package/build/style.css +1 -1
- package/package.json +3 -3
package/build/amp-react.cjs.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use strict";var Rp=Object.defineProperty;var pc=e=>{throw TypeError(e)};var Pp=(e,t,n)=>t in e?Rp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Fe=(e,t,n)=>Pp(e,typeof t!="symbol"?t+"":t,n),ts=(e,t,n)=>t.has(e)||pc("Cannot "+n);var E=(e,t,n)=>(ts(e,t,"read from private field"),n?n.call(e):t.get(e)),se=(e,t,n)=>t.has(e)?pc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),G=(e,t,n,r)=>(ts(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),he=(e,t,n)=>(ts(e,t,"access private method"),n);var Xi=(e,t,n,r)=>({set _(o){G(e,t,o,n)},get _(){return E(e,t,r)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),b=require("react");require("react-dom");function Fp(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 j=Fp(b);var ai=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(){}},xr=typeof window>"u"||"Deno"in globalThis;function ht(){}function Dp(e,t){return typeof e=="function"?e(t):e}function Cs(e){return typeof e=="number"&&e>=0&&e!==1/0}function ql(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Gn(e,t){return typeof e=="function"?e(t):e}function Kt(e,t){return typeof e=="function"?e(t):e}function hc(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==sa(s,t.options))return!1}else if(!Ci(t.queryKey,s))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||o&&o!==t.state.fetchStatus||i&&!i(t))}function mc(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Sr(t.options.mutationKey)!==Sr(i))return!1}else if(!Ci(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function sa(e,t){return((t==null?void 0:t.queryKeyHashFn)||Sr)(e)}function Sr(e){return JSON.stringify(e,(t,n)=>Ss(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function Ci(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Ci(e[n],t[n])):!1}function xs(e,t){if(e===t)return e;const n=gc(e)&&gc(t);if(n||Ss(e)&&Ss(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{},c=new Set(r);let d=0;for(let u=0;u<s;u++){const f=n?u:i[u];(!n&&c.has(f)||n)&&e[f]===void 0&&t[f]===void 0?(a[f]=void 0,d++):(a[f]=xs(e[f],t[f]),a[f]===e[f]&&e[f]!==void 0&&d++)}return o===s&&d===o?e:a}return t}function go(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 gc(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ss(e){if(!yc(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!yc(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function yc(e){return Object.prototype.toString.call(e)==="[object Object]"}function Mp(e){return new Promise(t=>{setTimeout(t,e)})}function Es(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 xs(e,t)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return xs(e,t)}return t}function kp(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Lp(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var yo=Symbol();function Vl(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===yo&&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===yo?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Hl(e,t){return typeof e=="function"?e(...t):!!e}var pr,Kn,jr,Pl,jp=(Pl=class extends ai{constructor(){super();se(this,pr);se(this,Kn);se(this,jr);G(this,jr,t=>{if(!xr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){E(this,Kn)||this.setEventListener(E(this,jr))}onUnsubscribe(){var t;this.hasListeners()||((t=E(this,Kn))==null||t.call(this),G(this,Kn,void 0))}setEventListener(t){var n;G(this,jr,t),(n=E(this,Kn))==null||n.call(this),G(this,Kn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){E(this,pr)!==t&&(G(this,pr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof E(this,pr)=="boolean"?E(this,pr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},pr=new WeakMap,Kn=new WeakMap,jr=new WeakMap,Pl),aa=new jp,Kr,Un,Ur,Fl,Kp=(Fl=class extends ai{constructor(){super();se(this,Kr,!0);se(this,Un);se(this,Ur);G(this,Ur,t=>{if(!xr&&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(){E(this,Un)||this.setEventListener(E(this,Ur))}onUnsubscribe(){var t;this.hasListeners()||((t=E(this,Un))==null||t.call(this),G(this,Un,void 0))}setEventListener(t){var n;G(this,Ur,t),(n=E(this,Un))==null||n.call(this),G(this,Un,t(this.setOnline.bind(this)))}setOnline(t){E(this,Kr)!==t&&(G(this,Kr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return E(this,Kr)}},Kr=new WeakMap,Un=new WeakMap,Ur=new WeakMap,Fl),vo=new Kp;function Os(){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 Up(e){return Math.min(1e3*2**e,3e4)}function Jl(e){return(e??"online")==="online"?vo.isOnline():!0}var Wl=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function ns(e){return e instanceof Wl}function Bl(e){let t=!1,n=0,r=!1,o;const i=Os(),s=v=>{var p;r||(m(new Wl(v)),(p=e.abort)==null||p.call(e))},a=()=>{t=!0},c=()=>{t=!1},d=()=>aa.isFocused()&&(e.networkMode==="always"||vo.isOnline())&&e.canRun(),u=()=>Jl(e.networkMode)&&e.canRun(),f=v=>{var p;r||(r=!0,(p=e.onSuccess)==null||p.call(e,v),o==null||o(),i.resolve(v))},m=v=>{var p;r||(r=!0,(p=e.onError)==null||p.call(e,v),o==null||o(),i.reject(v))},g=()=>new Promise(v=>{var p;o=x=>{(r||d())&&v(x)},(p=e.onPause)==null||p.call(e)}).then(()=>{var v;o=void 0,r||(v=e.onContinue)==null||v.call(e)}),y=()=>{if(r)return;let v;const p=n===0?e.initialPromise:void 0;try{v=p??e.fn()}catch(x){v=Promise.reject(x)}Promise.resolve(v).then(f).catch(x=>{var A;if(r)return;const h=e.retry??(xr?0:3),w=e.retryDelay??Up,I=typeof w=="function"?w(n,x):w,S=h===!0||typeof h=="number"&&n<h||typeof h=="function"&&h(n,x);if(t||!S){m(x);return}n++,(A=e.onFail)==null||A.call(e,n,x),Mp(I).then(()=>d()?void 0:g()).then(()=>{t?m(x):y()})})};return{promise:i,cancel:s,continue:()=>(o==null||o(),i),cancelRetry:a,continueRetry:c,canStart:u,start:()=>(u()?y():g().then(y),i)}}var $p=e=>setTimeout(e,0);function qp(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=$p;const i=a=>{t?e.push(a):o(()=>{n(a)})},s=()=>{const a=e;e=[],a.length&&o(()=>{r(()=>{a.forEach(c=>{n(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||s()}return c},batchCalls:a=>(...c)=>{i(()=>{a(...c)})},schedule:i,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{o=a}}}var Ge=qp(),hr,Dl,zl=(Dl=class{constructor(){se(this,hr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Cs(this.gcTime)&&G(this,hr,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(xr?1/0:5*60*1e3))}clearGcTimeout(){E(this,hr)&&(clearTimeout(E(this,hr)),G(this,hr,void 0))}},hr=new WeakMap,Dl),$r,mr,jt,gr,ct,Ai,yr,Gt,bn,Ml,Vp=(Ml=class extends zl{constructor(t){super();se(this,Gt);se(this,$r);se(this,mr);se(this,jt);se(this,gr);se(this,ct);se(this,Ai);se(this,yr);G(this,yr,!1),G(this,Ai,t.defaultOptions),this.setOptions(t.options),this.observers=[],G(this,gr,t.client),G(this,jt,E(this,gr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,G(this,$r,Hp(this.options)),this.state=t.state??E(this,$r),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=E(this,ct))==null?void 0:t.promise}setOptions(t){this.options={...E(this,Ai),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&E(this,jt).remove(this)}setData(t,n){const r=Es(this.state.data,t,this.options);return he(this,Gt,bn).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){he(this,Gt,bn).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=E(this,ct))==null?void 0:r.promise;return(o=E(this,ct))==null||o.cancel(t),n?n.then(ht).catch(ht):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(E(this,$r))}isActive(){return this.observers.some(t=>Kt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===yo||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Gn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!ql(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=E(this,ct))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=E(this,ct))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),E(this,jt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(E(this,ct)&&(E(this,yr)?E(this,ct).cancel({revert:!0}):E(this,ct).cancelRetry()),this.scheduleGc()),E(this,jt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||he(this,Gt,bn).call(this,{type:"invalidate"})}fetch(t,n){var d,u,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(E(this,ct))return E(this,ct).continueRetry(),E(this,ct).promise}if(t&&this.setOptions(t),!this.options.queryFn){const m=this.observers.find(g=>g.options.queryFn);m&&this.setOptions(m.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=m=>{Object.defineProperty(m,"signal",{enumerable:!0,get:()=>(G(this,yr,!0),r.signal)})},i=()=>{const m=Vl(this.options,n),y=(()=>{const v={client:E(this,gr),queryKey:this.queryKey,meta:this.meta};return o(v),v})();return G(this,yr,!1),this.options.persister?this.options.persister(m,y,this):m(y)},a=(()=>{const m={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:E(this,gr),state:this.state,fetchFn:i};return o(m),m})();(d=this.options.behavior)==null||d.onFetch(a,this),G(this,mr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=a.fetchOptions)==null?void 0:u.meta))&&he(this,Gt,bn).call(this,{type:"fetch",meta:(f=a.fetchOptions)==null?void 0:f.meta});const c=m=>{var g,y,v,p;ns(m)&&m.silent||he(this,Gt,bn).call(this,{type:"error",error:m}),ns(m)||((y=(g=E(this,jt).config).onError)==null||y.call(g,m,this),(p=(v=E(this,jt).config).onSettled)==null||p.call(v,this.state.data,m,this)),this.scheduleGc()};return G(this,ct,Bl({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,abort:r.abort.bind(r),onSuccess:m=>{var g,y,v,p;if(m===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}`),c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(m)}catch(x){c(x);return}(y=(g=E(this,jt).config).onSuccess)==null||y.call(g,m,this),(p=(v=E(this,jt).config).onSettled)==null||p.call(v,m,this.state.error,this),this.scheduleGc()},onError:c,onFail:(m,g)=>{he(this,Gt,bn).call(this,{type:"failed",failureCount:m,error:g})},onPause:()=>{he(this,Gt,bn).call(this,{type:"pause"})},onContinue:()=>{he(this,Gt,bn).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0})),E(this,ct).start()}},$r=new WeakMap,mr=new WeakMap,jt=new WeakMap,gr=new WeakMap,ct=new WeakMap,Ai=new WeakMap,yr=new WeakMap,Gt=new WeakSet,bn=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,...Gl(r.data,this.options),fetchMeta:t.meta??null};case"success":return G(this,mr,void 0),{...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 ns(o)&&o.revert&&E(this,mr)?{...E(this,mr),fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Ge.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),E(this,jt).notify({query:this,type:"updated",action:t})})},Ml);function Gl(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Jl(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Hp(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 on,kl,Jp=(kl=class extends ai{constructor(t={}){super();se(this,on);this.config=t,G(this,on,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??sa(o,n);let s=this.get(i);return s||(s=new Vp({client:t,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){E(this,on).has(t.queryHash)||(E(this,on).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=E(this,on).get(t.queryHash);n&&(t.destroy(),n===t&&E(this,on).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Ge.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return E(this,on).get(t)}getAll(){return[...E(this,on).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>hc(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>hc(t,r)):n}notify(t){Ge.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Ge.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ge.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},on=new WeakMap,kl),sn,ft,vr,an,jn,Ll,Wp=(Ll=class extends zl{constructor(t){super();se(this,an);se(this,sn);se(this,ft);se(this,vr);this.mutationId=t.mutationId,G(this,ft,t.mutationCache),G(this,sn,[]),this.state=t.state||Ql(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){E(this,sn).includes(t)||(E(this,sn).push(t),this.clearGcTimeout(),E(this,ft).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){G(this,sn,E(this,sn).filter(n=>n!==t)),this.scheduleGc(),E(this,ft).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){E(this,sn).length||(this.state.status==="pending"?this.scheduleGc():E(this,ft).remove(this))}continue(){var t;return((t=E(this,vr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,s,a,c,d,u,f,m,g,y,v,p,x,h,w,I,S,A,O,N;const n=()=>{he(this,an,jn).call(this,{type:"continue"})};G(this,vr,Bl({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(R,P)=>{he(this,an,jn).call(this,{type:"failed",failureCount:R,error:P})},onPause:()=>{he(this,an,jn).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>E(this,ft).canRun(this)}));const r=this.state.status==="pending",o=!E(this,vr).canStart();try{if(r)n();else{he(this,an,jn).call(this,{type:"pending",variables:t,isPaused:o}),await((s=(i=E(this,ft).config).onMutate)==null?void 0:s.call(i,t,this));const P=await((c=(a=this.options).onMutate)==null?void 0:c.call(a,t));P!==this.state.context&&he(this,an,jn).call(this,{type:"pending",context:P,variables:t,isPaused:o})}const R=await E(this,vr).start();return await((u=(d=E(this,ft).config).onSuccess)==null?void 0:u.call(d,R,t,this.state.context,this)),await((m=(f=this.options).onSuccess)==null?void 0:m.call(f,R,t,this.state.context)),await((y=(g=E(this,ft).config).onSettled)==null?void 0:y.call(g,R,null,this.state.variables,this.state.context,this)),await((p=(v=this.options).onSettled)==null?void 0:p.call(v,R,null,t,this.state.context)),he(this,an,jn).call(this,{type:"success",data:R}),R}catch(R){try{throw await((h=(x=E(this,ft).config).onError)==null?void 0:h.call(x,R,t,this.state.context,this)),await((I=(w=this.options).onError)==null?void 0:I.call(w,R,t,this.state.context)),await((A=(S=E(this,ft).config).onSettled)==null?void 0:A.call(S,void 0,R,this.state.variables,this.state.context,this)),await((N=(O=this.options).onSettled)==null?void 0:N.call(O,void 0,R,t,this.state.context)),R}finally{he(this,an,jn).call(this,{type:"error",error:R})}}finally{E(this,ft).runNext(this)}}},sn=new WeakMap,ft=new WeakMap,vr=new WeakMap,an=new WeakSet,jn=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),Ge.batch(()=>{E(this,sn).forEach(r=>{r.onMutationUpdate(t)}),E(this,ft).notify({mutation:this,type:"updated",action:t})})},Ll);function Ql(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var In,Qt,Ri,jl,Bp=(jl=class extends ai{constructor(t={}){super();se(this,In);se(this,Qt);se(this,Ri);this.config=t,G(this,In,new Set),G(this,Qt,new Map),G(this,Ri,0)}build(t,n,r){const o=new Wp({mutationCache:this,mutationId:++Xi(this,Ri)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){E(this,In).add(t);const n=Yi(t);if(typeof n=="string"){const r=E(this,Qt).get(n);r?r.push(t):E(this,Qt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(E(this,In).delete(t)){const n=Yi(t);if(typeof n=="string"){const r=E(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&&E(this,Qt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Yi(t);if(typeof n=="string"){const r=E(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=Yi(t);if(typeof n=="string"){const o=(r=E(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(){Ge.batch(()=>{E(this,In).forEach(t=>{this.notify({type:"removed",mutation:t})}),E(this,In).clear(),E(this,Qt).clear()})}getAll(){return Array.from(E(this,In))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>mc(n,r))}findAll(t={}){return this.getAll().filter(n=>mc(t,n))}notify(t){Ge.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Ge.batch(()=>Promise.all(t.map(n=>n.continue().catch(ht))))}},In=new WeakMap,Qt=new WeakMap,Ri=new WeakMap,jl);function Yi(e){var t;return(t=e.options.scope)==null?void 0:t.id}function vc(e){return{onFetch:(t,n)=>{var u,f,m,g,y;const r=t.options,o=(m=(f=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:f.fetchMore)==null?void 0:m.direction,i=((g=t.state.data)==null?void 0:g.pages)||[],s=((y=t.state.data)==null?void 0:y.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const d=async()=>{let v=!1;const p=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(t.signal.aborted?v=!0:t.signal.addEventListener("abort",()=>{v=!0}),t.signal)})},x=Vl(t.options,t.fetchOptions),h=async(w,I,S)=>{if(v)return Promise.reject();if(I==null&&w.pages.length)return Promise.resolve(w);const O=(()=>{const J={client:t.client,queryKey:t.queryKey,pageParam:I,direction:S?"backward":"forward",meta:t.options.meta};return p(J),J})(),N=await x(O),{maxPages:R}=t.options,P=S?Lp:kp;return{pages:P(w.pages,N,R),pageParams:P(w.pageParams,I,R)}};if(o&&i.length){const w=o==="backward",I=w?zp:wc,S={pages:i,pageParams:s},A=I(r,S);a=await h(S,A,w)}else{const w=e??i.length;do{const I=c===0?s[0]??r.initialPageParam:wc(r,a);if(c>0&&I==null)break;a=await h(a,I),c++}while(c<w)}return a};t.options.persister?t.fetchFn=()=>{var v,p;return(p=(v=t.options).persister)==null?void 0:p.call(v,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function wc(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 zp(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,$n,qn,qr,Vr,Vn,Hr,Jr,Kl,Gp=(Kl=class{constructor(e={}){se(this,Ke);se(this,$n);se(this,qn);se(this,qr);se(this,Vr);se(this,Vn);se(this,Hr);se(this,Jr);G(this,Ke,e.queryCache||new Jp),G(this,$n,e.mutationCache||new Bp),G(this,qn,e.defaultOptions||{}),G(this,qr,new Map),G(this,Vr,new Map),G(this,Vn,0)}mount(){Xi(this,Vn)._++,E(this,Vn)===1&&(G(this,Hr,aa.subscribe(async e=>{e&&(await this.resumePausedMutations(),E(this,Ke).onFocus())})),G(this,Jr,vo.subscribe(async e=>{e&&(await this.resumePausedMutations(),E(this,Ke).onOnline())})))}unmount(){var e,t;Xi(this,Vn)._--,E(this,Vn)===0&&((e=E(this,Hr))==null||e.call(this),G(this,Hr,void 0),(t=E(this,Jr))==null||t.call(this),G(this,Jr,void 0))}isFetching(e){return E(this,Ke).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return E(this,$n).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=E(this,Ke).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=E(this,Ke).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Gn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return E(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=E(this,Ke).get(r.queryHash),i=o==null?void 0:o.state.data,s=Dp(t,i);if(s!==void 0)return E(this,Ke).build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return Ge.batch(()=>E(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=E(this,Ke).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=E(this,Ke);Ge.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=E(this,Ke);return Ge.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Ge.batch(()=>E(this,Ke).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(ht).catch(ht)}invalidateQueries(e,t={}){return Ge.batch(()=>(E(this,Ke).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ge.batch(()=>E(this,Ke).findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(ht)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(ht)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=E(this,Ke).build(this,t);return n.isStaleByTime(Gn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ht).catch(ht)}fetchInfiniteQuery(e){return e.behavior=vc(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ht).catch(ht)}ensureInfiniteQueryData(e){return e.behavior=vc(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return vo.isOnline()?E(this,$n).resumePausedMutations():Promise.resolve()}getQueryCache(){return E(this,Ke)}getMutationCache(){return E(this,$n)}getDefaultOptions(){return E(this,qn)}setDefaultOptions(e){G(this,qn,e)}setQueryDefaults(e,t){E(this,qr).set(Sr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...E(this,qr).values()],n={};return t.forEach(r=>{Ci(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){E(this,Vr).set(Sr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...E(this,Vr).values()],n={};return t.forEach(r=>{Ci(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...E(this,qn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=sa(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===yo&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...E(this,qn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){E(this,Ke).clear(),E(this,$n).clear()}},Ke=new WeakMap,$n=new WeakMap,qn=new WeakMap,qr=new WeakMap,Vr=new WeakMap,Vn=new WeakMap,Hr=new WeakMap,Jr=new WeakMap,Kl),wt,ye,Pi,pt,wr,Wr,Hn,Jn,Fi,Br,zr,br,Ir,Wn,Gr,Ee,yi,_s,Ns,Ts,As,Rs,Ps,Fs,Xl,Ul,Qp=(Ul=class extends ai{constructor(t,n){super();se(this,Ee);se(this,wt);se(this,ye);se(this,Pi);se(this,pt);se(this,wr);se(this,Wr);se(this,Hn);se(this,Jn);se(this,Fi);se(this,Br);se(this,zr);se(this,br);se(this,Ir);se(this,Wn);se(this,Gr,new Set);this.options=n,G(this,wt,t),G(this,Jn,null),G(this,Hn,Os()),this.options.experimental_prefetchInRender||E(this,Hn).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&&(E(this,ye).addObserver(this),bc(E(this,ye),this.options)?he(this,Ee,yi).call(this):this.updateResult(),he(this,Ee,As).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ds(E(this,ye),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ds(E(this,ye),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,he(this,Ee,Rs).call(this),he(this,Ee,Ps).call(this),E(this,ye).removeObserver(this)}setOptions(t){const n=this.options,r=E(this,ye);if(this.options=E(this,wt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Kt(this.options.enabled,E(this,ye))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");he(this,Ee,Fs).call(this),E(this,ye).setOptions(this.options),n._defaulted&&!go(this.options,n)&&E(this,wt).getQueryCache().notify({type:"observerOptionsUpdated",query:E(this,ye),observer:this});const o=this.hasListeners();o&&Ic(E(this,ye),r,this.options,n)&&he(this,Ee,yi).call(this),this.updateResult(),o&&(E(this,ye)!==r||Kt(this.options.enabled,E(this,ye))!==Kt(n.enabled,E(this,ye))||Gn(this.options.staleTime,E(this,ye))!==Gn(n.staleTime,E(this,ye)))&&he(this,Ee,_s).call(this);const i=he(this,Ee,Ns).call(this);o&&(E(this,ye)!==r||Kt(this.options.enabled,E(this,ye))!==Kt(n.enabled,E(this,ye))||i!==E(this,Wn))&&he(this,Ee,Ts).call(this,i)}getOptimisticResult(t){const n=E(this,wt).getQueryCache().build(E(this,wt),t),r=this.createResult(n,t);return Yp(this,r)&&(G(this,pt,r),G(this,Wr,this.options),G(this,wr,E(this,ye).state)),r}getCurrentResult(){return E(this,pt)}trackResult(t,n){return new Proxy(t,{get:(r,o)=>(this.trackProp(o),n==null||n(o),Reflect.get(r,o))})}trackProp(t){E(this,Gr).add(t)}getCurrentQuery(){return E(this,ye)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=E(this,wt).defaultQueryOptions(t),r=E(this,wt).getQueryCache().build(E(this,wt),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return he(this,Ee,yi).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),E(this,pt)))}createResult(t,n){var R;const r=E(this,ye),o=this.options,i=E(this,pt),s=E(this,wr),a=E(this,Wr),d=t!==r?t.state:E(this,Pi),{state:u}=t;let f={...u},m=!1,g;if(n._optimisticResults){const P=this.hasListeners(),J=!P&&bc(t,n),K=P&&Ic(t,r,n,o);(J||K)&&(f={...f,...Gl(u.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:y,errorUpdatedAt:v,status:p}=f;g=f.data;let x=!1;if(n.placeholderData!==void 0&&g===void 0&&p==="pending"){let P;i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(P=i.data,x=!0):P=typeof n.placeholderData=="function"?n.placeholderData((R=E(this,zr))==null?void 0:R.state.data,E(this,zr)):n.placeholderData,P!==void 0&&(p="success",g=Es(i==null?void 0:i.data,P,n),m=!0)}if(n.select&&g!==void 0&&!x)if(i&&g===(s==null?void 0:s.data)&&n.select===E(this,Fi))g=E(this,Br);else try{G(this,Fi,n.select),g=n.select(g),g=Es(i==null?void 0:i.data,g,n),G(this,Br,g),G(this,Jn,null)}catch(P){G(this,Jn,P)}E(this,Jn)&&(y=E(this,Jn),g=E(this,Br),v=Date.now(),p="error");const h=f.fetchStatus==="fetching",w=p==="pending",I=p==="error",S=w&&h,A=g!==void 0,N={status:p,fetchStatus:f.fetchStatus,isPending:w,isSuccess:p==="success",isError:I,isInitialLoading:S,isLoading:S,data:g,dataUpdatedAt:f.dataUpdatedAt,error:y,errorUpdatedAt:v,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>d.dataUpdateCount||f.errorUpdateCount>d.errorUpdateCount,isFetching:h,isRefetching:h&&!w,isLoadingError:I&&!A,isPaused:f.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:I&&A,isStale:ca(t,n),refetch:this.refetch,promise:E(this,Hn),isEnabled:Kt(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const P=M=>{N.status==="error"?M.reject(N.error):N.data!==void 0&&M.resolve(N.data)},J=()=>{const M=G(this,Hn,N.promise=Os());P(M)},K=E(this,Hn);switch(K.status){case"pending":t.queryHash===r.queryHash&&P(K);break;case"fulfilled":(N.status==="error"||N.data!==K.value)&&J();break;case"rejected":(N.status!=="error"||N.error!==K.reason)&&J();break}}return N}updateResult(){const t=E(this,pt),n=this.createResult(E(this,ye),this.options);if(G(this,wr,E(this,ye).state),G(this,Wr,this.options),E(this,wr).data!==void 0&&G(this,zr,E(this,ye)),go(n,t))return;G(this,pt,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options,i=typeof o=="function"?o():o;if(i==="all"||!i&&!E(this,Gr).size)return!0;const s=new Set(i??E(this,Gr));return this.options.throwOnError&&s.add("error"),Object.keys(E(this,pt)).some(a=>{const c=a;return E(this,pt)[c]!==t[c]&&s.has(c)})};he(this,Ee,Xl).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&he(this,Ee,As).call(this)}},wt=new WeakMap,ye=new WeakMap,Pi=new WeakMap,pt=new WeakMap,wr=new WeakMap,Wr=new WeakMap,Hn=new WeakMap,Jn=new WeakMap,Fi=new WeakMap,Br=new WeakMap,zr=new WeakMap,br=new WeakMap,Ir=new WeakMap,Wn=new WeakMap,Gr=new WeakMap,Ee=new WeakSet,yi=function(t){he(this,Ee,Fs).call(this);let n=E(this,ye).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(ht)),n},_s=function(){he(this,Ee,Rs).call(this);const t=Gn(this.options.staleTime,E(this,ye));if(xr||E(this,pt).isStale||!Cs(t))return;const r=ql(E(this,pt).dataUpdatedAt,t)+1;G(this,br,setTimeout(()=>{E(this,pt).isStale||this.updateResult()},r))},Ns=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(E(this,ye)):this.options.refetchInterval)??!1},Ts=function(t){he(this,Ee,Ps).call(this),G(this,Wn,t),!(xr||Kt(this.options.enabled,E(this,ye))===!1||!Cs(E(this,Wn))||E(this,Wn)===0)&&G(this,Ir,setInterval(()=>{(this.options.refetchIntervalInBackground||aa.isFocused())&&he(this,Ee,yi).call(this)},E(this,Wn)))},As=function(){he(this,Ee,_s).call(this),he(this,Ee,Ts).call(this,he(this,Ee,Ns).call(this))},Rs=function(){E(this,br)&&(clearTimeout(E(this,br)),G(this,br,void 0))},Ps=function(){E(this,Ir)&&(clearInterval(E(this,Ir)),G(this,Ir,void 0))},Fs=function(){const t=E(this,wt).getQueryCache().build(E(this,wt),this.options);if(t===E(this,ye))return;const n=E(this,ye);G(this,ye,t),G(this,Pi,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Xl=function(t){Ge.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(E(this,pt))}),E(this,wt).getQueryCache().notify({query:E(this,ye),type:"observerResultsUpdated"})})},Ul);function Xp(e,t){return Kt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function bc(e,t){return Xp(e,t)||e.state.data!==void 0&&Ds(e,t,t.refetchOnMount)}function Ds(e,t,n){if(Kt(t.enabled,e)!==!1&&Gn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&ca(e,t)}return!1}function Ic(e,t,n,r){return(e!==t||Kt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ca(e,n)}function ca(e,t){return Kt(t.enabled,e)!==!1&&e.isStaleByTime(Gn(t.staleTime,e))}function Yp(e,t){return!go(e.getCurrentResult(),t)}var Bn,zn,bt,Cn,Sn,lo,Ms,$l,Zp=($l=class extends ai{constructor(n,r){super();se(this,Sn);se(this,Bn);se(this,zn);se(this,bt);se(this,Cn);G(this,Bn,n),this.setOptions(r),this.bindMethods(),he(this,Sn,lo).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=E(this,Bn).defaultMutationOptions(n),go(this.options,r)||E(this,Bn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:E(this,bt),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Sr(r.mutationKey)!==Sr(this.options.mutationKey)?this.reset():((o=E(this,bt))==null?void 0:o.state.status)==="pending"&&E(this,bt).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=E(this,bt))==null||n.removeObserver(this)}onMutationUpdate(n){he(this,Sn,lo).call(this),he(this,Sn,Ms).call(this,n)}getCurrentResult(){return E(this,zn)}reset(){var n;(n=E(this,bt))==null||n.removeObserver(this),G(this,bt,void 0),he(this,Sn,lo).call(this),he(this,Sn,Ms).call(this)}mutate(n,r){var o;return G(this,Cn,r),(o=E(this,bt))==null||o.removeObserver(this),G(this,bt,E(this,Bn).getMutationCache().build(E(this,Bn),this.options)),E(this,bt).addObserver(this),E(this,bt).execute(n)}},Bn=new WeakMap,zn=new WeakMap,bt=new WeakMap,Cn=new WeakMap,Sn=new WeakSet,lo=function(){var r;const n=((r=E(this,bt))==null?void 0:r.state)??Ql();G(this,zn,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Ms=function(n){Ge.batch(()=>{var r,o,i,s,a,c,d,u;if(E(this,Cn)&&this.hasListeners()){const f=E(this,zn).variables,m=E(this,zn).context;(n==null?void 0:n.type)==="success"?((o=(r=E(this,Cn)).onSuccess)==null||o.call(r,n.data,f,m),(s=(i=E(this,Cn)).onSettled)==null||s.call(i,n.data,null,f,m)):(n==null?void 0:n.type)==="error"&&((c=(a=E(this,Cn)).onError)==null||c.call(a,n.error,f,m),(u=(d=E(this,Cn)).onSettled)==null||u.call(d,void 0,n.error,f,m))}this.listeners.forEach(f=>{f(E(this,zn))})})},$l),Yl=j.createContext(void 0),$e=e=>{const t=j.useContext(Yl);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},eh=({client:e,children:t})=>(j.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),l.jsx(Yl.Provider,{value:e,children:t})),Zl=j.createContext(!1),th=()=>j.useContext(Zl);Zl.Provider;function nh(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var rh=j.createContext(nh()),ih=()=>j.useContext(rh),oh=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},sh=e=>{j.useEffect(()=>{e.clearReset()},[e])},ah=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||Hl(n,[e.error,r])),ch=e=>{if(e.suspense){const t=r=>r==="static"?r:Math.max(r??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...r)=>t(n(...r)):t(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},lh=(e,t)=>e.isLoading&&e.isFetching&&!t,uh=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Cc=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function dh(e,t,n){var f,m,g,y,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=th(),o=ih(),i=$e(),s=i.defaultQueryOptions(e);(m=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||m.call(f,s),process.env.NODE_ENV!=="production"&&(s.queryFn||console.error(`[${s.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),s._optimisticResults=r?"isRestoring":"optimistic",ch(s),oh(s,o),sh(o);const a=!i.getQueryCache().get(s.queryHash),[c]=j.useState(()=>new t(i,s)),d=c.getOptimisticResult(s),u=!r&&e.subscribed!==!1;if(j.useSyncExternalStore(j.useCallback(p=>{const x=u?c.subscribe(Ge.batchCalls(p)):ht;return c.updateResult(),x},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),j.useEffect(()=>{c.setOptions(s)},[s,c]),uh(s,d))throw Cc(s,c,o);if(ah({result:d,errorResetBoundary:o,throwOnError:s.throwOnError,query:i.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw d.error;if((y=(g=i.getDefaultOptions().queries)==null?void 0:g._experimental_afterQuery)==null||y.call(g,s,d),s.experimental_prefetchInRender&&!xr&&lh(d,r)){const p=a?Cc(s,c,o):(v=i.getQueryCache().get(s.queryHash))==null?void 0:v.promise;p==null||p.catch(ht).finally(()=>{c.updateResult()})}return s.notifyOnChangeProps?d:c.trackResult(d)}function er(e,t){return dh(e,Qp)}function On(e,t){const n=$e(),[r]=j.useState(()=>new Zp(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);const o=j.useSyncExternalStore(j.useCallback(s=>r.subscribe(Ge.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=j.useCallback((s,a)=>{r.mutate(s,a).catch(ht)},[r]);if(o.error&&Hl(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:i,mutateAsync:o.mutate}}const eu=b.createContext(null),fh=eu.Provider,tu=()=>b.useContext(eu);var de=(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))(de||{});const nu=b.createContext(void 0);function qt(){const e=b.useContext(nu);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const ph=(()=>{const e={};return Object.values(de).forEach(t=>{e[t]={}}),e})();function hh({children:e}){const[t,n]=b.useState(ph),r=b.useCallback((u,f,m=!0)=>{n(g=>{const y={...g};return y[u]=y[u]||{},y[u][f]=m,y})},[n]),o=b.useCallback((u,f)=>{var m;return!!((m=t[u])!=null&&m[f])},[t]),i=b.useCallback((u,f)=>{var m;return(m=t[u])==null?void 0:m[f]},[t]),s=b.useCallback((u,f)=>{n(m=>{var y;const g={...m};return(y=g[u])==null||delete y[f],g})},[n]),a=b.useCallback(u=>{n(f=>{const m={...f};return m[u]={},m})},[n]),c=b.useCallback((u,f)=>{n(m=>{const g={...m};return g[u]=g[u]||{},f.forEach(y=>{g[u][y]=!0}),g})},[n]),d=b.useMemo(()=>({errorState:t,setErrorState:n,setError:r,isError:o,removeError:s,resetBoundary:a,setErrors:c,getError:i}),[t,n,r,o,s,a,c,i]);return l.jsx(nu.Provider,{value:d,children:e})}const Zi=new TextEncoder,xi=new TextDecoder;function mh(...e){const t=e.reduce((o,{length:i})=>o+i,0),n=new Uint8Array(t);let r=0;for(const o of e)n.set(o,r),r+=o.length;return n}function gh(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function uo(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e=="string"?e:xi.decode(e),{alphabet:"base64url"});let t=e;t instanceof Uint8Array&&(t=xi.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return gh(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}}class tr extends Error{constructor(n,r){var o;super(n,r);Fe(this,"code","ERR_JOSE_GENERIC");this.name=this.constructor.name,(o=Error.captureStackTrace)==null||o.call(Error,this,this.constructor)}}Fe(tr,"code","ERR_JOSE_GENERIC");class zt extends tr{constructor(n,r,o="unspecified",i="unspecified"){super(n,{cause:{claim:o,reason:i,payload:r}});Fe(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");Fe(this,"claim");Fe(this,"reason");Fe(this,"payload");this.claim=o,this.reason=i,this.payload=r}}Fe(zt,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");class ks extends tr{constructor(n,r,o="unspecified",i="unspecified"){super(n,{cause:{claim:o,reason:i,payload:r}});Fe(this,"code","ERR_JWT_EXPIRED");Fe(this,"claim");Fe(this,"reason");Fe(this,"payload");this.claim=o,this.reason=i,this.payload=r}}Fe(ks,"code","ERR_JWT_EXPIRED");class ru extends tr{constructor(){super(...arguments);Fe(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}}Fe(ru,"code","ERR_JOSE_ALG_NOT_ALLOWED");class dr extends tr{constructor(){super(...arguments);Fe(this,"code","ERR_JOSE_NOT_SUPPORTED")}}Fe(dr,"code","ERR_JOSE_NOT_SUPPORTED");class Ye extends tr{constructor(){super(...arguments);Fe(this,"code","ERR_JWS_INVALID")}}Fe(Ye,"code","ERR_JWS_INVALID");class la extends tr{constructor(){super(...arguments);Fe(this,"code","ERR_JWT_INVALID")}}Fe(la,"code","ERR_JWT_INVALID");class iu extends tr{constructor(n="signature verification failed",r){super(n,r);Fe(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}}Fe(iu,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");function wn(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function gi(e,t){return e.name===t}function rs(e){return parseInt(e.name.slice(4),10)}function yh(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function vh(e,t){if(!e.usages.includes(t))throw new TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function wh(e,t,n){switch(t){case"HS256":case"HS384":case"HS512":{if(!gi(e.algorithm,"HMAC"))throw wn("HMAC");const r=parseInt(t.slice(2),10);if(rs(e.algorithm.hash)!==r)throw wn(`SHA-${r}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!gi(e.algorithm,"RSASSA-PKCS1-v1_5"))throw wn("RSASSA-PKCS1-v1_5");const r=parseInt(t.slice(2),10);if(rs(e.algorithm.hash)!==r)throw wn(`SHA-${r}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!gi(e.algorithm,"RSA-PSS"))throw wn("RSA-PSS");const r=parseInt(t.slice(2),10);if(rs(e.algorithm.hash)!==r)throw wn(`SHA-${r}`,"algorithm.hash");break}case"Ed25519":case"EdDSA":{if(!gi(e.algorithm,"Ed25519"))throw wn("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!gi(e.algorithm,"ECDSA"))throw wn("ECDSA");const r=yh(t);if(e.algorithm.namedCurve!==r)throw wn(r,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}vh(e,n)}function ou(e,t,...n){var r;if(n=n.filter(Boolean),n.length>2){const o=n.pop();e+=`one of type ${n.join(", ")}, or ${o}.`}else n.length===2?e+=`one of type ${n[0]} or ${n[1]}.`:e+=`of type ${n[0]}.`;return t==null?e+=` Received ${t}`:typeof t=="function"&&t.name?e+=` Received function ${t.name}`:typeof t=="object"&&t!=null&&(r=t.constructor)!=null&&r.name&&(e+=` Received an instance of ${t.constructor.name}`),e}const bh=(e,...t)=>ou("Key must be ",e,...t);function su(e,t,...n){return ou(`Key for the ${e} algorithm must be `,t,...n)}function au(e){return(e==null?void 0:e[Symbol.toStringTag])==="CryptoKey"}function cu(e){return(e==null?void 0:e[Symbol.toStringTag])==="KeyObject"}const lu=e=>au(e)||cu(e),Ih=(...e)=>{const t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let n;for(const r of t){const o=Object.keys(r);if(!n||n.size===0){n=new Set(o);continue}for(const i of o){if(n.has(i))return!1;n.add(i)}}return!0};function Ch(e){return typeof e=="object"&&e!==null}const wo=e=>{if(!Ch(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t},xh=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:n}=t.algorithm;if(typeof n!="number"||n<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}};function Sh(e){let t,n;switch(e.kty){case"RSA":{switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},n=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},n=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},n=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new dr('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"},n=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},n=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},n=e.d?["deriveBits"]:[];break;default:throw new dr('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(e.alg){case"Ed25519":case"EdDSA":t={name:"Ed25519"},n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},n=e.d?["deriveBits"]:[];break;default:throw new dr('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new dr('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:n}}const Eh=async e=>{if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:t,keyUsages:n}=Sh(e),r={...e};return delete r.alg,delete r.use,crypto.subtle.importKey("jwk",r,t,e.ext??!e.d,e.key_ops??n)},Oh=(e,t,n,r,o)=>{if(o.crit!==void 0&&(r==null?void 0:r.crit)===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!r||r.crit===void 0)return new Set;if(!Array.isArray(r.crit)||r.crit.length===0||r.crit.some(s=>typeof s!="string"||s.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let i;n!==void 0?i=new Map([...Object.entries(n),...t.entries()]):i=t;for(const s of r.crit){if(!i.has(s))throw new dr(`Extension Header Parameter "${s}" is not recognized`);if(o[s]===void 0)throw new e(`Extension Header Parameter "${s}" is missing`);if(i.get(s)&&r[s]===void 0)throw new e(`Extension Header Parameter "${s}" MUST be integrity protected`)}return new Set(r.crit)},_h=(e,t)=>{if(t!==void 0&&(!Array.isArray(t)||t.some(n=>typeof n!="string")))throw new TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)};function ua(e){return wo(e)&&typeof e.kty=="string"}function Nh(e){return e.kty!=="oct"&&typeof e.d=="string"}function Th(e){return e.kty!=="oct"&&typeof e.d>"u"}function Ah(e){return e.kty==="oct"&&typeof e.k=="string"}let kr;const xc=async(e,t,n,r=!1)=>{kr||(kr=new WeakMap);let o=kr.get(e);if(o!=null&&o[n])return o[n];const i=await Eh({...t,alg:n});return r&&Object.freeze(e),o?o[n]=i:kr.set(e,{[n]:i}),i},Rh=(e,t)=>{var s;kr||(kr=new WeakMap);let n=kr.get(e);if(n!=null&&n[t])return n[t];const r=e.type==="public",o=!!r;let i;if(e.asymmetricKeyType==="x25519"){switch(t){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw new TypeError("given KeyObject instance cannot be used for this algorithm")}i=e.toCryptoKey(e.asymmetricKeyType,o,r?[]:["deriveBits"])}if(e.asymmetricKeyType==="ed25519"){if(t!=="EdDSA"&&t!=="Ed25519")throw new TypeError("given KeyObject instance cannot be used for this algorithm");i=e.toCryptoKey(e.asymmetricKeyType,o,[r?"verify":"sign"])}if(e.asymmetricKeyType==="rsa"){let a;switch(t){case"RSA-OAEP":a="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":a="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":a="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":a="SHA-512";break;default:throw new TypeError("given KeyObject instance cannot be used for this algorithm")}if(t.startsWith("RSA-OAEP"))return e.toCryptoKey({name:"RSA-OAEP",hash:a},o,r?["encrypt"]:["decrypt"]);i=e.toCryptoKey({name:t.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:a},o,[r?"verify":"sign"])}if(e.asymmetricKeyType==="ec"){const c=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get((s=e.asymmetricKeyDetails)==null?void 0:s.namedCurve);if(!c)throw new TypeError("given KeyObject instance cannot be used for this algorithm");t==="ES256"&&c==="P-256"&&(i=e.toCryptoKey({name:"ECDSA",namedCurve:c},o,[r?"verify":"sign"])),t==="ES384"&&c==="P-384"&&(i=e.toCryptoKey({name:"ECDSA",namedCurve:c},o,[r?"verify":"sign"])),t==="ES512"&&c==="P-521"&&(i=e.toCryptoKey({name:"ECDSA",namedCurve:c},o,[r?"verify":"sign"])),t.startsWith("ECDH-ES")&&(i=e.toCryptoKey({name:"ECDH",namedCurve:c},o,r?[]:["deriveBits"]))}if(!i)throw new TypeError("given KeyObject instance cannot be used for this algorithm");return n?n[t]=i:kr.set(e,{[t]:i}),i},Ph=async(e,t)=>{if(e instanceof Uint8Array||au(e))return e;if(cu(e)){if(e.type==="secret")return e.export();if("toCryptoKey"in e&&typeof e.toCryptoKey=="function")try{return Rh(e,t)}catch(r){if(r instanceof TypeError)throw r}let n=e.export({format:"jwk"});return xc(e,n,t)}if(ua(e))return e.k?uo(e.k):xc(e,e,t,!0);throw new Error("unreachable")},Dr=e=>e==null?void 0:e[Symbol.toStringTag],Ls=(e,t,n)=>{var r,o;if(t.use!==void 0){let i;switch(n){case"sign":case"verify":i="sig";break;case"encrypt":case"decrypt":i="enc";break}if(t.use!==i)throw new TypeError(`Invalid key for this operation, its "use" must be "${i}" when present`)}if(t.alg!==void 0&&t.alg!==e)throw new TypeError(`Invalid key for this operation, its "alg" must be "${e}" when present`);if(Array.isArray(t.key_ops)){let i;switch(!0){case n==="verify":case e==="dir":case e.includes("CBC-HS"):i=n;break;case e.startsWith("PBES2"):i="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):!e.includes("GCM")&&e.endsWith("KW")?i="unwrapKey":i=n;break;case n==="encrypt":i="wrapKey";break;case n==="decrypt":i=e.startsWith("RSA")?"unwrapKey":"deriveBits";break}if(i&&((o=(r=t.key_ops)==null?void 0:r.includes)==null?void 0:o.call(r,i))===!1)throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${i}" when present`)}return!0},Fh=(e,t,n)=>{if(!(t instanceof Uint8Array)){if(ua(t)){if(Ah(t)&&Ls(e,t,n))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!lu(t))throw new TypeError(su(e,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if(t.type!=="secret")throw new TypeError(`${Dr(t)} instances for symmetric algorithms must be of type "secret"`)}},Dh=(e,t,n)=>{if(ua(t))switch(n){case"decrypt":case"sign":if(Nh(t)&&Ls(e,t,n))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"encrypt":case"verify":if(Th(t)&&Ls(e,t,n))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!lu(t))throw new TypeError(su(e,t,"CryptoKey","KeyObject","JSON Web Key"));if(t.type==="secret")throw new TypeError(`${Dr(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.type==="public")switch(n){case"sign":throw new TypeError(`${Dr(t)} instances for asymmetric algorithm signing must be of type "private"`);case"decrypt":throw new TypeError(`${Dr(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if(t.type==="private")switch(n){case"verify":throw new TypeError(`${Dr(t)} instances for asymmetric algorithm verifying must be of type "public"`);case"encrypt":throw new TypeError(`${Dr(t)} instances for asymmetric algorithm encryption must be of type "public"`)}},Mh=(e,t,n)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(e)||/^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(e)?Fh(e,t,n):Dh(e,t,n)},kh=(e,t)=>{const n=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:n,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:n,name:"RSA-PSS",saltLength:parseInt(e.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:n,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:n,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};default:throw new dr(`alg ${e} is not supported either by JOSE or your javascript runtime`)}},Lh=async(e,t,n)=>{if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError(bh(t,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[n])}return wh(t,e,n),t},jh=async(e,t,n,r)=>{const o=await Lh(e,t,"verify");xh(e,o);const i=kh(e,o.algorithm);try{return await crypto.subtle.verify(i,o,n,r)}catch{return!1}};async function Kh(e,t,n){if(!wo(e))throw new Ye("Flattened JWS must be an object");if(e.protected===void 0&&e.header===void 0)throw new Ye('Flattened JWS must have either of the "protected" or "header" members');if(e.protected!==void 0&&typeof e.protected!="string")throw new Ye("JWS Protected Header incorrect type");if(e.payload===void 0)throw new Ye("JWS Payload missing");if(typeof e.signature!="string")throw new Ye("JWS Signature missing or incorrect type");if(e.header!==void 0&&!wo(e.header))throw new Ye("JWS Unprotected Header incorrect type");let r={};if(e.protected)try{const p=uo(e.protected);r=JSON.parse(xi.decode(p))}catch{throw new Ye("JWS Protected Header is invalid")}if(!Ih(r,e.header))throw new Ye("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const o={...r,...e.header},i=Oh(Ye,new Map([["b64",!0]]),n==null?void 0:n.crit,r,o);let s=!0;if(i.has("b64")&&(s=r.b64,typeof s!="boolean"))throw new Ye('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:a}=o;if(typeof a!="string"||!a)throw new Ye('JWS "alg" (Algorithm) Header Parameter missing or invalid');const c=n&&_h("algorithms",n.algorithms);if(c&&!c.has(a))throw new ru('"alg" (Algorithm) Header Parameter value not allowed');if(s){if(typeof e.payload!="string")throw new Ye("JWS Payload must be a string")}else if(typeof e.payload!="string"&&!(e.payload instanceof Uint8Array))throw new Ye("JWS Payload must be a string or an Uint8Array instance");let d=!1;typeof t=="function"&&(t=await t(r,e),d=!0),Mh(a,t,"verify");const u=mh(Zi.encode(e.protected??""),Zi.encode("."),typeof e.payload=="string"?Zi.encode(e.payload):e.payload);let f;try{f=uo(e.signature)}catch{throw new Ye("Failed to base64url decode the signature")}const m=await Ph(t,a);if(!await jh(a,m,f,u))throw new iu;let y;if(s)try{y=uo(e.payload)}catch{throw new Ye("Failed to base64url decode the payload")}else typeof e.payload=="string"?y=Zi.encode(e.payload):y=e.payload;const v={payload:y};return e.protected!==void 0&&(v.protectedHeader=r),e.header!==void 0&&(v.unprotectedHeader=e.header),d?{...v,key:m}:v}async function Uh(e,t,n){if(e instanceof Uint8Array&&(e=xi.decode(e)),typeof e!="string")throw new Ye("Compact JWS must be a string or Uint8Array");const{0:r,1:o,2:i,length:s}=e.split(".");if(s!==3)throw new Ye("Invalid Compact JWS");const a=await Kh({payload:o,protected:r,signature:i},t,n),c={payload:a.payload,protectedHeader:a.protectedHeader};return typeof t=="function"?{...c,key:a.key}:c}const $h=e=>Math.floor(e.getTime()/1e3),uu=60,du=uu*60,da=du*24,qh=da*7,Vh=da*365.25,Hh=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,Sc=e=>{const t=Hh.exec(e);if(!t||t[4]&&t[1])throw new TypeError("Invalid time period format");const n=parseFloat(t[2]),r=t[3].toLowerCase();let o;switch(r){case"sec":case"secs":case"second":case"seconds":case"s":o=Math.round(n);break;case"minute":case"minutes":case"min":case"mins":case"m":o=Math.round(n*uu);break;case"hour":case"hours":case"hr":case"hrs":case"h":o=Math.round(n*du);break;case"day":case"days":case"d":o=Math.round(n*da);break;case"week":case"weeks":case"w":o=Math.round(n*qh);break;default:o=Math.round(n*Vh);break}return t[1]==="-"||t[4]==="ago"?-o:o},Ec=e=>e.includes("/")?e.toLowerCase():`application/${e.toLowerCase()}`,Jh=(e,t)=>typeof e=="string"?t.includes(e):Array.isArray(e)?t.some(Set.prototype.has.bind(new Set(e))):!1;function Wh(e,t,n={}){let r;try{r=JSON.parse(xi.decode(t))}catch{}if(!wo(r))throw new la("JWT Claims Set must be a top-level JSON object");const{typ:o}=n;if(o&&(typeof e.typ!="string"||Ec(e.typ)!==Ec(o)))throw new zt('unexpected "typ" JWT header value',r,"typ","check_failed");const{requiredClaims:i=[],issuer:s,subject:a,audience:c,maxTokenAge:d}=n,u=[...i];d!==void 0&&u.push("iat"),c!==void 0&&u.push("aud"),a!==void 0&&u.push("sub"),s!==void 0&&u.push("iss");for(const y of new Set(u.reverse()))if(!(y in r))throw new zt(`missing required "${y}" claim`,r,y,"missing");if(s&&!(Array.isArray(s)?s:[s]).includes(r.iss))throw new zt('unexpected "iss" claim value',r,"iss","check_failed");if(a&&r.sub!==a)throw new zt('unexpected "sub" claim value',r,"sub","check_failed");if(c&&!Jh(r.aud,typeof c=="string"?[c]:c))throw new zt('unexpected "aud" claim value',r,"aud","check_failed");let f;switch(typeof n.clockTolerance){case"string":f=Sc(n.clockTolerance);break;case"number":f=n.clockTolerance;break;case"undefined":f=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:m}=n,g=$h(m||new Date);if((r.iat!==void 0||d)&&typeof r.iat!="number")throw new zt('"iat" claim must be a number',r,"iat","invalid");if(r.nbf!==void 0){if(typeof r.nbf!="number")throw new zt('"nbf" claim must be a number',r,"nbf","invalid");if(r.nbf>g+f)throw new zt('"nbf" claim timestamp check failed',r,"nbf","check_failed")}if(r.exp!==void 0){if(typeof r.exp!="number")throw new zt('"exp" claim must be a number',r,"exp","invalid");if(r.exp<=g-f)throw new ks('"exp" claim timestamp check failed',r,"exp","check_failed")}if(d){const y=g-r.iat,v=typeof d=="number"?d:Sc(d);if(y-f>v)throw new ks('"iat" claim timestamp check failed (too far in the past)',r,"iat","check_failed");if(y<0-f)throw new zt('"iat" claim timestamp check failed (it should be in the past)',r,"iat","check_failed")}return r}async function Bh(e,t,n){var s;const r=await Uh(e,t,n);if((s=r.protectedHeader.crit)!=null&&s.includes("b64")&&r.protectedHeader.b64===!1)throw new la("JWTs MUST NOT use unencoded payload");const i={payload:Wh(r.protectedHeader,r.payload,n),protectedHeader:r.protectedHeader};return typeof t=="function"?{...i,key:r.key}:i}const js="amp-labs_jwt_",zh=10*60*1e3,Oc=(e,t)=>`${e}:${t}`,_c=e=>`${js}${e}`,fu=b.createContext(null),Gh=async e=>{try{const n=(await Bh(e,new Uint8Array(0),{algorithms:[]})).payload;return n.exp&&typeof n.exp=="number"?n.exp*1e3:null}catch(t){return console.warn("Failed to decode JWT token:",t),null}};function Qh({getTokenCallback:e,children:t}){const[n,r]=b.useState(new Map);b.useEffect(()=>{try{const c=new Map,d=Date.now();Object.keys(sessionStorage).forEach(u=>{if(u.startsWith(js)){const f=u.replace(js,""),m=sessionStorage.getItem(u);if(m)try{const g=JSON.parse(m);g.expiresAt>d?c.set(f,g):sessionStorage.removeItem(u)}catch{sessionStorage.removeItem(u)}}}),c.size>0&&r(c)}catch{console.warn("Failed to load JWT tokens from sessionStorage")}},[]);const o=b.useCallback((c,d)=>{const u=Oc(c,d),f=Date.now(),m=n.get(u);if(m&&m.expiresAt>f)return m.token;n.delete(u);const g=_c(u),y=sessionStorage.getItem(g);if(y)try{const v=JSON.parse(y);if(v.expiresAt>f)return r(p=>new Map(p).set(u,v)),v.token;sessionStorage.removeItem(g)}catch{sessionStorage.removeItem(g)}return null},[n]),i=b.useCallback(async(c,d,u)=>{const f=Oc(c,d),g=await Gh(u)||Date.now()+zh,y={token:u,expiresAt:g};r(v=>new Map(v).set(f,y));try{sessionStorage.setItem(_c(f),JSON.stringify(y))}catch{console.warn("Failed to store JWT token in sessionStorage")}},[]),s=b.useCallback(async({consumerRef:c,groupRef:d})=>{const u=o(c,d);if(u)return u;if(!e)throw new Error("JWT token callback not provided");try{const f=await e({consumerRef:c,groupRef:d});return await i(c,d,f),f}catch(f){throw console.error("Failed to get JWT token:",f),new Error("Failed to get JWT token")}},[e,o,i]),a={getToken:e?s:void 0};return l.jsx(fu.Provider,{value:a,children:t})}const Xh=()=>{const e=b.useContext(fu);if(!e)throw new Error("useJwtToken must be used within a JwtTokenProvider");return e},fa=b.createContext(null);function Re(){const e=b.useContext(fa);if(!e)throw new Error(`Cannot call useAmpersandProvider unless your
|
|
2
|
-
component is wrapped with AmpersandProvider`);return e}const Yh=new Gp;function Zh(e){const{options:{apiKey:t,projectId:n,project:r,getToken:o},children:i}=e,s=r||n;if(n&&r)throw new Error("Use AmpersandProvider either with projectId or project but not both.");if(!s)throw new Error("Cannot use AmpersandProvider without a projectId or name.");if(!t&&!o)throw new Error("Cannot use AmpersandProvider without an apiKey or getToken.");if(t&&o)throw new Error("Cannot use AmpersandProvider with both apiKey and getToken.");const a={options:e.options,projectIdOrName:s};return l.jsx(eh,{client:Yh,children:l.jsx(fa.Provider,{value:a,children:l.jsx(hh,{children:l.jsx(Qh,{getTokenCallback:o||null,children:l.jsx(fh,{value:t||null,children:i})})})})})}const em="https://api.withampersand.com/v1".replace(/\/+$/,"");class pa{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:em}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||hu}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 tm=new pa,Do=class Do{constructor(t=tm){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 im(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?Do.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 pu(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(d=>o[d]===void 0?delete o[d]:{});const i=typeof n=="function"?n:async()=>n,s={method:t.method,headers:o,body:t.body,credentials:this.configuration.credentials},a={...s,...await i({init:s,context:t})},c={...a,body:rm(a.body)||a.body instanceof URLSearchParams||nm(a.body)?a.body:JSON.stringify(a.body)};return{url:r,init:c}}clone(){const t=this.constructor,n=new t(this.configuration);return n.middleware=this.middleware.slice(),n}};Do.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let cn=Do;function nm(e){return typeof Blob<"u"&&e instanceof Blob}function rm(e){return typeof FormData<"u"&&e instanceof FormData}class pu extends Error{constructor(t,n){super(n),this.response=t,this.name="ResponseError"}}class im extends Error{constructor(t,n){super(n),this.cause=t,this.name="FetchError"}}class ie extends Error{constructor(t,n){super(n),this.field=t,this.name="RequiredError"}}function T(e,t){const n=e[t];return n!=null}function hu(e,t=""){return Object.keys(e).map(n=>mu(n,e[n],t)).filter(n=>n.length>0).join("&")}function mu(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 mu(e,o,n)}return t instanceof Date?`${encodeURIComponent(r)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?hu(t,r):`${encodeURIComponent(r)}=${encodeURIComponent(String(t))}`}function Ve(e,t){return Object.keys(e).reduce((n,r)=>({...n,[r]:t(e[r])}),{})}class Ue{constructor(t,n=r=>r){this.raw=t,this.transformer=n}async value(){return this.transformer(await this.raw.json())}}class Qr{constructor(t){this.raw=t}async value(){}}class Nc{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function om(e){return sm(e)}function sm(e,t){return e==null?e:{fieldUsed:T(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:T(e,"keyFormat")?e.keyFormat:void 0}}function am(e){return cm(e)}function cm(e,t){return e==null?e:{name:e.name,valuePrefix:T(e,"valuePrefix")?e.valuePrefix:void 0}}function lm(e){return um(e)}function um(e,t){return e==null?e:{name:e.name}}function dm(e){return fm(e)}function fm(e,t){return e==null?e:{attachmentType:e.attachmentType,query:T(e,"query")?lm(e.query):void 0,header:T(e,"header")?am(e.header):void 0,docsURL:T(e,"docsURL")?e.docsURL:void 0}}function pm(e){return hm(e)}function hm(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0,includeFullRecords:T(e,"includeFullRecords")?e.includeFullRecords:void 0}}function mm(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,includeFullRecords:e.includeFullRecords}}function gm(e){return ym(e)}function ym(e,t){return e==null?e:{url:e.url,method:T(e,"method")?e.method:void 0,successStatusCodes:T(e,"successStatusCodes")?e.successStatusCodes:void 0}}const Tc={Oauth2:"oauth2",ApiKey:"apiKey",Basic:"basic",Jwt:"jwt",Custom:"custom",None:"none"};function vm(e){return wm(e)}function wm(e,t){return e}function bm(e){return Im(e)}function Im(e,t){return e==null?e:{days:T(e,"days")?e.days:void 0,fullHistory:T(e,"fullHistory")?e.fullHistory:void 0}}function Cm(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function gu(e){return xm(e)}function xm(e,t){return e==null?e:{defaultPeriod:bm(e.defaultPeriod)}}function Sm(e){if(e!==void 0)return e===null?null:{defaultPeriod:Cm(e.defaultPeriod)}}function Em(e){return Om(e)}function Om(e,t){return e==null?e:{days:T(e,"days")?e.days:void 0,fullHistory:T(e,"fullHistory")?e.fullHistory:void 0}}function _m(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function Nm(e){return Tm(e)}function Tm(e,t){return e==null?e:{defaultPeriod:Em(e.defaultPeriod)}}function yu(e){if(e!==void 0)return e===null?null:{defaultPeriod:_m(e.defaultPeriod)}}function Am(e){return Rm(e)}function Rm(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function vu(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Pm(e){return Fm(e)}function Fm(e,t){return e}function Dm(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:yu(e.backfill)}}function Mm(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Ve(e.objects,Dm)}}function km(e){return Lm(e)}function Lm(e,t){return e==null?e:{stringValue:T(e,"stringValue")?e.stringValue:void 0,integerValue:T(e,"integerValue")?e.integerValue:void 0,booleanValue:T(e,"booleanValue")?e.booleanValue:void 0}}function jm(e){if(e!==void 0)return e===null?null:{stringValue:e.stringValue,integerValue:e.integerValue,booleanValue:e.booleanValue}}const Km={Always:"always",Never:"never"},Um={Always:"always",Never:"never"};function $m(e){return qm(e)}function qm(e,t){return e==null?e:{default:T(e,"default")?km(e.default):void 0,writeOnCreate:T(e,"writeOnCreate")?e.writeOnCreate:void 0,writeOnUpdate:T(e,"writeOnUpdate")?e.writeOnUpdate:void 0}}function wu(e){if(e!==void 0)return e===null?null:{default:jm(e.default),writeOnCreate:e.writeOnCreate,writeOnUpdate:e.writeOnUpdate}}function Vm(e){let t=!0;return t=t&&"value"in e,t}function Hm(e,t){return e==null?e:{value:e.value,applyOnUpdate:T(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function Jm(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function Wm(e){let t=!0;return t=t&&"value"in e,t}function Bm(e,t){return e==null?e:{value:e.value,applyOnUpdate:T(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function zm(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function Gm(e){let t=!0;return t=t&&"value"in e,t}function Qm(e,t){return e==null?e:{value:e.value,applyOnUpdate:T(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function Xm(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function Ym(e){return Zm(e)}function Zm(e,t){return e==null?e:{...Hm(e),...Bm(e),...Qm(e)}}function bu(e){if(e!==void 0)return e===null?null:Vm(e)?Jm(e):Wm(e)?zm(e):Gm(e)?Xm(e):{}}function eg(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,selectedValueDefaults:e.selectedValueDefaults===void 0?void 0:Ve(e.selectedValueDefaults,bu),selectedFieldSettings:e.selectedFieldSettings===void 0?void 0:Ve(e.selectedFieldSettings,wu)}}function tg(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Ve(e.objects,eg)}}function ng(e){return rg(e)}function rg(e,t){return e==null?e:{enabled:e.enabled}}function ig(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function og(e){return sg(e)}function sg(e,t){return e==null?e:{enabled:e.enabled}}function ag(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function cg(e){return lg(e)}function lg(e,t){return e==null?e:{enabled:e.enabled,watchFieldsAuto:T(e,"watchFieldsAuto")?e.watchFieldsAuto:void 0,requiredWatchFields:T(e,"requiredWatchFields")?e.requiredWatchFields:void 0}}function ug(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,watchFieldsAuto:e.watchFieldsAuto,requiredWatchFields:e.requiredWatchFields}}function dg(e){return fg(e)}function fg(e,t){return e==null?e:{apiKeyAsBasic:T(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:T(e,"apiKeyAsBasicOpts")?om(e.apiKeyAsBasicOpts):void 0,docsURL:T(e,"docsURL")?e.docsURL:void 0}}function pg(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function hg(e){return mg(e)}function mg(e,t){return e==null?e:{value:e.value}}function gg(e){return yg(e)}function yg(e,t){return e==null?e:{brandingRemoval:T(e,"brandingRemoval")?hg(e.brandingRemoval):void 0}}function eo(e){return vg(e)}function vg(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:T(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0,entitlements:T(e,"entitlements")?gg(e.entitlements):void 0}}function wg(e){return bg(e)}function bg(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function Ig(e){return Cg(e)}function Cg(e,t){return e==null?e:{objectName:e.objectName,schedule:e.schedule,destination:e.destination,selectedFields:e.selectedFields,selectedValueMappings:T(e,"selectedValueMappings")?e.selectedValueMappings:void 0,selectedFieldMappings:e.selectedFieldMappings,selectedFieldsAuto:T(e,"selectedFieldsAuto")?Pm(e.selectedFieldsAuto):void 0,backfill:T(e,"backfill")?Nm(e.backfill):void 0}}function xg(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:yu(e.backfill)}}function Sg(e){return Eg(e)}function Eg(e,t){return e==null?e:{objects:Ve(e.objects,Ig)}}function Og(e){if(e!==void 0)return e===null?null:{objects:Ve(e.objects,xg)}}function _g(e){return Ng(e)}function Ng(e,t){return e==null?e:{inheritFieldsAndMappings:e.inheritFieldsAndMappings,objectName:e.objectName,destination:e.destination,createEvent:T(e,"createEvent")?ng(e.createEvent):void 0,updateEvent:T(e,"updateEvent")?cg(e.updateEvent):void 0,deleteEvent:T(e,"deleteEvent")?og(e.deleteEvent):void 0}}function Tg(e){if(e!==void 0)return e===null?null:{inheritFieldsAndMappings:e.inheritFieldsAndMappings,objectName:e.objectName,destination:e.destination,createEvent:ig(e.createEvent),updateEvent:ug(e.updateEvent),deleteEvent:ag(e.deleteEvent)}}function Ag(e){return Rg(e)}function Rg(e,t){return e==null?e:{objects:Ve(e.objects,_g)}}function Pg(e){if(e!==void 0)return e===null?null:{objects:Ve(e.objects,Tg)}}function Fg(e){return Dg(e)}function Dg(e,t){return e==null?e:{objectName:e.objectName,selectedValueDefaults:T(e,"selectedValueDefaults")?Ve(e.selectedValueDefaults,Ym):void 0,selectedFieldSettings:T(e,"selectedFieldSettings")?Ve(e.selectedFieldSettings,$m):void 0}}function Mg(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,selectedValueDefaults:e.selectedValueDefaults===void 0?void 0:Ve(e.selectedValueDefaults,bu),selectedFieldSettings:e.selectedFieldSettings===void 0?void 0:Ve(e.selectedFieldSettings,wu)}}function kg(e){return Lg(e)}function Lg(e,t){return e==null?e:{objects:T(e,"objects")?Ve(e.objects,Fg):void 0}}function jg(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Ve(e.objects,Mg)}}function Kg(e){return Ug(e)}function Ug(e,t){return e==null?e:{provider:e.provider,read:T(e,"read")?Sg(e.read):void 0,write:T(e,"write")?kg(e.write):void 0,proxy:T(e,"proxy")?Am(e.proxy):void 0,subscribe:T(e,"subscribe")?Ag(e.subscribe):void 0}}function $g(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:Og(e.read),write:jg(e.write),proxy:vu(e.proxy),subscribe:Pg(e.subscribe)}}function qg(e){return Vg(e)}function Vg(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:Kg(e.content)}}function Hg(e){return Jg(e)}function Jg(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0}}function Iu(e){return Wg(e)}function Wg(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0}}function Bg(e){return zg(e)}function zg(e,t){return e==null?e:{token:e.token,issuedAt:T(e,"issuedAt")?new Date(e.issuedAt):void 0,expiresAt:T(e,"expiresAt")?new Date(e.expiresAt):void 0}}function Gg(e){return Qg(e)}function Qg(e,t){return e==null?e:{token:e.token,issuedAt:T(e,"issuedAt")?new Date(e.issuedAt):void 0,expiresAt:T(e,"expiresAt")?new Date(e.expiresAt):void 0}}function Xg(e){return Yg(e)}function Yg(e,t){return e==null?e:{accessToken:T(e,"accessToken")?Bg(e.accessToken):void 0,refreshToken:T(e,"refreshToken")?Gg(e.refreshToken):void 0,scopes:T(e,"scopes")?e.scopes:void 0}}function fo(e){return Zg(e)}function Zg(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:T(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:T(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0}}function ey(e){return ty(e)}function ty(e,t){return e==null?e:{value:e.value,source:e.source,displayName:T(e,"displayName")?e.displayName:void 0}}function ha(e){if(e!==void 0)return e===null?null:{value:e.value,source:e.source,displayName:e.displayName}}function vi(e){return ny(e)}function ny(e,t){return e==null?e:{id:e.id,projectId:e.projectId,provider:e.provider,providerApp:T(e,"providerApp")?fo(e.providerApp):void 0,group:Iu(e.group),consumer:Hg(e.consumer),providerWorkspaceRef:T(e,"providerWorkspaceRef")?e.providerWorkspaceRef:void 0,providerConsumerRef:T(e,"providerConsumerRef")?e.providerConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0,authScheme:e.authScheme,status:e.status,oauth2AuthorizationCode:T(e,"oauth2AuthorizationCode")?Xg(e.oauth2AuthorizationCode):void 0,apiKey:T(e,"apiKey")?e.apiKey:void 0,providerMetadata:T(e,"providerMetadata")?Ve(e.providerMetadata,ey):void 0}}function Cu(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function xu(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function Su(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 ry(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 iy(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 Eu(e){if(e!==void 0)return e===null?null:{accessToken:ry(e.accessToken),refreshToken:iy(e.refreshToken),scopes:e.scopes}}function oy(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:Ve(e.providerMetadata,ha),groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,customAuth:e.customAuth,basicAuth:Cu(e.basicAuth),oauth2ClientCredentials:xu(e.oauth2ClientCredentials),oauth2PasswordCredentials:Su(e.oauth2PasswordCredentials),oauth2AuthorizationCode:Eu(e.oauth2AuthorizationCode)}}function sy(e){return ay(e)}function ay(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function cy(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function ly(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:$g(e.content)}}function uy(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:ly(e.config)}}function dy(e){return fy(e)}function fy(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function py(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function hy(e){return my(e)}function my(e,t){return e==null?e:{mode:T(e,"mode")?e.mode:void 0,pageSize:T(e,"pageSize")?e.pageSize:void 0}}function gy(e){if(e!==void 0)return e===null?null:{mode:e.mode,pageSize:e.pageSize}}function yy(e){let t=!0;return t=t&&"fieldName"in e,t}function vy(e,t){return e==null?e:{fieldName:e.fieldName,mapToName:T(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function wy(e){if(e!==void 0)return e===null?null:{fieldName:e.fieldName,mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName}}function by(e){let t=!0;return t=t&&"mapToName"in e,t}function Ou(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:T(e,"default")?e.default:void 0,prompt:T(e,"prompt")?e.prompt:void 0}}function Iy(e){if(e!==void 0)return e===null?null:{mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName,default:e._default,prompt:e.prompt}}function Ac(e){return Cy(e)}function Cy(e,t){return e==null?e:{...vy(e),...Ou(e)}}function Rc(e){if(e!==void 0)return e===null?null:yy(e)?wy(e):by(e)?Iy(e):{}}function _u(e){return xy(e)}function xy(e,t){return e}function Sy(e){return Ey(e)}function Ey(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,mapToName:T(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0,requiredFields:T(e,"requiredFields")?e.requiredFields.map(Ac):void 0,optionalFields:T(e,"optionalFields")?e.optionalFields.map(Ac):void 0,optionalFieldsAuto:T(e,"optionalFieldsAuto")?_u(e.optionalFieldsAuto):void 0,backfill:T(e,"backfill")?gu(e.backfill):void 0,delivery:T(e,"delivery")?hy(e.delivery):void 0}}function Oy(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(Rc),optionalFields:e.optionalFields===void 0?void 0:e.optionalFields.map(Rc),optionalFieldsAuto:e.optionalFieldsAuto,backfill:Sm(e.backfill),delivery:gy(e.delivery)}}function _y(e){return Ny(e)}function Ny(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(Sy):void 0}}function Ty(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Oy)}}function Ay(e){return Ry(e)}function Ry(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function Py(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Fy(e){return Dy(e)}function Dy(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0,watchFieldsAuto:T(e,"watchFieldsAuto")?e.watchFieldsAuto:void 0,requiredWatchFields:T(e,"requiredWatchFields")?e.requiredWatchFields:void 0}}function My(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,watchFieldsAuto:e.watchFieldsAuto,requiredWatchFields:e.requiredWatchFields}}function ky(e){return Ly(e)}function Ly(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,inheritFieldsAndMapping:T(e,"inheritFieldsAndMapping")?e.inheritFieldsAndMapping:void 0,createEvent:T(e,"createEvent")?sy(e.createEvent):void 0,updateEvent:T(e,"updateEvent")?Fy(e.updateEvent):void 0,deleteEvent:T(e,"deleteEvent")?Ay(e.deleteEvent):void 0,associationChangeEvent:T(e,"associationChangeEvent")?pm(e.associationChangeEvent):void 0,otherEvents:T(e,"otherEvents")?e.otherEvents:void 0}}function jy(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,destination:e.destination,inheritFieldsAndMapping:e.inheritFieldsAndMapping,createEvent:cy(e.createEvent),updateEvent:My(e.updateEvent),deleteEvent:Py(e.deleteEvent),associationChangeEvent:mm(e.associationChangeEvent),otherEvents:e.otherEvents}}function Ky(e){return Uy(e)}function Uy(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(ky):void 0}}function $y(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(jy)}}function Nu(e){return qy(e)}function qy(e,t){return e==null?e:{allowAnyFields:T(e,"allowAnyFields")?e.allowAnyFields:void 0}}function Vy(e){if(e!==void 0)return e===null?null:{allowAnyFields:e.allowAnyFields}}function Hy(e){return Jy(e)}function Jy(e,t){return e==null?e:{objectName:e.objectName,inheritMapping:T(e,"inheritMapping")?e.inheritMapping:void 0,valueDefaults:T(e,"valueDefaults")?Nu(e.valueDefaults):void 0}}function Wy(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,inheritMapping:e.inheritMapping,valueDefaults:Vy(e.valueDefaults)}}function By(e){return zy(e)}function zy(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(Hy):void 0}}function Gy(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Wy)}}function Qy(e){return Xy(e)}function Xy(e,t){return e==null?e:{name:e.name,displayName:T(e,"displayName")?e.displayName:void 0,provider:e.provider,read:T(e,"read")?_y(e.read):void 0,write:T(e,"write")?By(e.write):void 0,proxy:T(e,"proxy")?dy(e.proxy):void 0,subscribe:T(e,"subscribe")?Ky(e.subscribe):void 0}}function Yy(e){if(e!==void 0)return e===null?null:{name:e.name,displayName:e.displayName,provider:e.provider,read:Ty(e.read),write:Gy(e.write),proxy:py(e.proxy),subscribe:$y(e.subscribe)}}function Zy(e){if(e!==void 0)return e===null?null:{specVersion:e.specVersion,content:Yy(e.content)}}function ev(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:Zy(e.latestRevision)}}function tv(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function nv(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 rv(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function iv(e){return ov(e)}function ov(e,t){return e==null?e:{name:e.name,valueTemplate:e.valueTemplate}}function sv(e){return av(e)}function av(e,t){return e==null?e:{name:e.name,displayName:e.displayName,prompt:T(e,"prompt")?e.prompt:void 0,docsURL:T(e,"docsURL")?e.docsURL:void 0}}function cv(e){return lv(e)}function lv(e,t){return e==null?e:{name:e.name,valueTemplate:e.valueTemplate}}function uv(e){return dv(e)}function dv(e,t){return e==null?e:{headers:T(e,"headers")?e.headers.map(iv):void 0,queryParams:T(e,"queryParams")?e.queryParams.map(cv):void 0,inputs:T(e,"inputs")?e.inputs.map(sv):void 0}}function fv(e){return pv(e)}function pv(e,t){return e==null?e:{value:e.value,displayValue:e.displayValue}}function hv(e){return mv(e)}function mv(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,valueType:T(e,"valueType")?e.valueType:void 0,providerType:T(e,"providerType")?e.providerType:void 0,readOnly:T(e,"readOnly")?e.readOnly:void 0,values:T(e,"values")?e.values.map(fv):void 0}}function gv(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:Ve(e.providerMetadata,ha),groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,customAuth:e.customAuth,basicAuth:Cu(e.basicAuth),oauth2ClientCredentials:xu(e.oauth2ClientCredentials),oauth2PasswordCredentials:Su(e.oauth2PasswordCredentials),oauth2AuthorizationCode:Eu(e.oauth2AuthorizationCode)}}function yv(e){return vv(e)}function vv(e,t){return e==null?e:{enabled:T(e,"enabled")?e.enabled:void 0}}function wv(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,mapToName:T(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function is(e){return bv(e)}function bv(e,t){return e==null?e:{...wv(e),...Ou(e)}}function Iv(e){return Cv(e)}function Cv(e,t){return e==null?e:{error:T(e,"error")?e.error:void 0,objectName:e.objectName,displayName:e.displayName,mapToName:T(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:T(e,"mapToDisplayName")?e.mapToDisplayName:void 0,destination:e.destination,schedule:e.schedule,requiredFields:T(e,"requiredFields")?e.requiredFields.map(is):void 0,optionalFields:T(e,"optionalFields")?e.optionalFields.map(is):void 0,optionalFieldsAuto:T(e,"optionalFieldsAuto")?_u(e.optionalFieldsAuto):void 0,allFieldsMetadata:T(e,"allFieldsMetadata")?Ve(e.allFieldsMetadata,hv):void 0,allFields:T(e,"allFields")?e.allFields.map(is):void 0,backfill:T(e,"backfill")?gu(e.backfill):void 0}}function xv(e){return Sv(e)}function Sv(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(Iv):void 0}}function Ev(e){return Ov(e)}function Ov(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,valueDefaults:T(e,"valueDefaults")?Nu(e.valueDefaults):void 0}}function _v(e){return Nv(e)}function Nv(e,t){return e==null?e:{objects:T(e,"objects")?e.objects.map(Ev):void 0}}function Tv(e){return Av(e)}function Av(e,t){return e==null?e:{name:e.name,displayName:T(e,"displayName")?e.displayName:void 0,provider:e.provider,read:T(e,"read")?xv(e.read):void 0,write:T(e,"write")?_v(e.write):void 0,proxy:T(e,"proxy")?yv(e.proxy):void 0}}function Rv(e){return Pv(e)}function Pv(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Tv(e.content)}}function to(e){return Fv(e)}function Fv(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:T(e,"group")?Iu(e.group):void 0,healthStatus:e.healthStatus,connection:vi(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0,config:qg(e.config)}}function Dv(e){return Mv(e)}function Mv(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:Qy(e.content)}}function Pc(e){return kv(e)}function kv(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:T(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Dv(e.latestRevision)}}function Lv(e){return jv(e)}function jv(e,t){return e==null?e:{iconURL:T(e,"iconURL")?e.iconURL:void 0,logoURL:T(e,"logoURL")?e.logoURL:void 0}}function Kv(e){return Uv(e)}function Uv(e,t){return e==null?e:{iconURL:T(e,"iconURL")?e.iconURL:void 0,logoURL:T(e,"logoURL")?e.logoURL:void 0}}function $v(e){return qv(e)}function qv(e,t){return e==null?e:{regular:T(e,"regular")?Kv(e.regular):void 0,darkMode:T(e,"darkMode")?Lv(e.darkMode):void 0}}function Vv(e){return Hv(e)}function Hv(e,t){return e==null?e:{name:e.name,displayName:T(e,"displayName")?e.displayName:void 0,defaultValue:T(e,"defaultValue")?e.defaultValue:void 0,docsURL:T(e,"docsURL")?e.docsURL:void 0,moduleDependencies:T(e,"moduleDependencies")?e.moduleDependencies:void 0}}function Jv(e){return Wv(e)}function Wv(e,t){return e==null?e:{name:e.name,moduleDependencies:T(e,"moduleDependencies")?e.moduleDependencies:void 0}}function Bv(e){return zv(e)}function zv(e,t){return e==null?e:{create:T(e,"create")?e.create:void 0,update:T(e,"update")?e.update:void 0,_delete:T(e,"delete")?e.delete:void 0,passThrough:T(e,"passThrough")?e.passThrough:void 0}}function Tu(e){return Gv(e)}function Gv(e,t){return e==null?e:{bulkWrite:wg(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write,subscribeSupport:T(e,"subscribeSupport")?Bv(e.subscribeSupport):void 0}}function Qv(e){return Xv(e)}function Xv(e,t){return e==null?e:{displayName:e.displayName,baseURL:e.baseURL,support:Tu(e.support)}}function Yv(e){return Zv(e)}function Zv(e,t){return e==null?e:{name:e.name,displayName:e.displayName,path:e.path,capture:T(e,"capture")?e.capture:void 0}}function ew(e){return tw(e)}function tw(e,t){return e==null?e:{workspaceRefField:T(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:T(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:T(e,"scopesField")?e.scopesField:void 0,otherFields:T(e,"otherFields")?e.otherFields.map(Yv):void 0}}const os={AuthorizationCode:"authorizationCode",AuthorizationCodePkce:"authorizationCodePKCE",ClientCredentials:"clientCredentials",Password:"password"};function nw(e){return rw(e)}function rw(e,t){return e==null?e:{grantType:e.grantType,authURL:T(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:T(e,"audience")?e.audience:void 0,tokenMetadataFields:ew(e.tokenMetadataFields),docsURL:T(e,"docsURL")?e.docsURL:void 0,authURLParams:T(e,"authURLParams")?e.authURLParams:void 0}}function iw(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:Ve(e.providerMetadata,ha),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 ow(e){return sw(e)}function sw(e,t){return e==null?e:{input:T(e,"input")?e.input.map(Vv):void 0,postAuthentication:T(e,"postAuthentication")?e.postAuthentication.map(Jv):void 0}}function aw(e){return cw(e)}function cw(e,t){return e==null?e:{subscriptionScope:e.subscriptionScope,targetURLScope:e.targetURLScope,registrationTiming:e.registrationTiming}}function Fc(e){return lw(e)}function lw(e,t){return e==null?e:{name:e.name,authType:vm(e.authType),baseURL:e.baseURL,defaultModule:e.defaultModule,oauth2Opts:T(e,"oauth2Opts")?nw(e.oauth2Opts):void 0,apiKeyOpts:T(e,"apiKeyOpts")?dm(e.apiKeyOpts):void 0,basicOpts:T(e,"basicOpts")?dg(e.basicOpts):void 0,customOpts:T(e,"customOpts")?uv(e.customOpts):void 0,support:Tu(e.support),providerOpts:e.providerOpts,authHealthCheck:T(e,"authHealthCheck")?gm(e.authHealthCheck):void 0,displayName:T(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:T(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:T(e,"media")?$v(e.media):void 0,labels:T(e,"labels")?e.labels:void 0,subscribeOpts:T(e,"subscribeOpts")?aw(e.subscribeOpts):void 0,modules:T(e,"modules")?Ve(e.modules,Qv):void 0,metadata:T(e,"metadata")?ow(e.metadata):void 0}}function uw(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,connection:oy(e.connection)}}function dw(e){if(e!==void 0)return e===null?null:{provider:e.provider,read:Mm(e.read),write:tg(e.write),proxy:vu(e.proxy)}}function fw(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:dw(e.content)}}function pw(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:fw(e.config)}}function hw(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:pw(e.installation)}}function mw(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function gw(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:mw(e.project)}}function yw(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 vw(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:yw(e.providerApp)}}class ww extends cn{async deleteConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling deleteConnection.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"DELETE",headers:o,query:r},n);return new Qr(i)}async deleteConnection(t,n){await this.deleteConnectionRaw(t,n)}async generateConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling generateConnection.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections:generate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:r,body:gv(t.generateConnectionParams)},n);return new Ue(i,s=>vi(s))}async generateConnection(t,n){return await(await this.generateConnectionRaw(t,n)).value()}async getConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getConnection.");const r={};t.includeCreds!==void 0&&(r.includeCreds=t.includeCreds),t.includeRefreshToken!==void 0&&(r.includeRefreshToken=t.includeRefreshToken),t.refresh!==void 0&&(r.refresh=t.refresh);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"GET",headers:o,query:r},n);return new Ue(i,s=>vi(s))}async getConnection(t,n){return await(await this.getConnectionRaw(t,n)).value()}async listConnectionsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listConnections.");const r={};t.provider!==void 0&&(r.provider=t.provider),t.groupRef!==void 0&&(r.groupRef=t.groupRef),t.consumerRef!==void 0&&(r.consumerRef=t.consumerRef);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Ue(i,s=>s.map(vi))}async listConnections(t,n){return await(await this.listConnectionsRaw(t,n)).value()}async updateConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling updateConnection.");if(t.updateConnectionRequest===null||t.updateConnectionRequest===void 0)throw new ie("updateConnectionRequest","Required parameter requestParameters.updateConnectionRequest was null or undefined when calling updateConnection.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"PATCH",headers:o,query:r,body:uw(t.updateConnectionRequest)},n);return new Ue(i,s=>vi(s))}async updateConnection(t,n){return await(await this.updateConnectionRaw(t,n)).value()}}class bw extends cn{async createInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new ie("installation","Required parameter requestParameters.installation was null or undefined when calling createInstallation.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:o,query:r,body:uy(t.installation)},n);return new Ue(i,s=>to(s))}async createInstallation(t,n){return await(await this.createInstallationRaw(t,n)).value()}async deleteInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new ie("installationId","Required parameter requestParameters.installationId was null or undefined when calling deleteInstallation.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"DELETE",headers:o,query:r},n);return new Qr(i)}async deleteInstallation(t,n){await this.deleteInstallationRaw(t,n)}async getInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new ie("installationId","Required parameter requestParameters.installationId was null or undefined when calling getInstallation.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"GET",headers:o,query:r},n);return new Ue(i,s=>to(s))}async getInstallation(t,n){return await(await this.getInstallationRaw(t,n)).value()}async listInstallationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listInstallations.");const r={};t.groupRef!==void 0&&(r.groupRef=t.groupRef);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"GET",headers:o,query:r},n);return new Ue(i,s=>s.map(to))}async listInstallations(t,n){return await(await this.listInstallationsRaw(t,n)).value()}async updateInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new ie("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new ie("installationUpdate","Required parameter requestParameters.installationUpdate was null or undefined when calling updateInstallation.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/installations/{installationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{installationId}",encodeURIComponent(String(t.installationId))),method:"PATCH",headers:o,query:r,body:hw(t.installationUpdate)},n);return new Ue(i,s=>to(s))}async updateInstallation(t,n){return await(await this.updateInstallationRaw(t,n)).value()}}class Iw extends cn{async batchUpsertIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");if(t.batchUpsertIntegrationsRequest===null||t.batchUpsertIntegrationsRequest===void 0)throw new ie("batchUpsertIntegrationsRequest","Required parameter requestParameters.batchUpsertIntegrationsRequest was null or undefined when calling batchUpsertIntegrations.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations:batch".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PUT",headers:o,query:r,body:pg(t.batchUpsertIntegrationsRequest)},n);return new Ue(i,s=>s.map(Pc))}async batchUpsertIntegrations(t,n){return await(await this.batchUpsertIntegrationsRaw(t,n)).value()}async createIntegrationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new ie("integration","Required parameter requestParameters.integration was null or undefined when calling createIntegration.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:r,body:ev(t.integration)},n);return new Qr(i)}async createIntegration(t,n){await this.createIntegrationRaw(t,n)}async deleteIntegrationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteIntegration.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"DELETE",headers:o,query:r},n);return new Qr(i)}async deleteIntegration(t,n){await this.deleteIntegrationRaw(t,n)}async listIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listIntegrations.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Ue(i,s=>s.map(Pc))}async listIntegrations(t,n){return await(await this.listIntegrationsRaw(t,n)).value()}}class Cw extends cn{async oauthConnectRaw(t,n){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new ie("connectOAuthParams","Required parameter requestParameters.connectOAuthParams was null or undefined when calling oauthConnect.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/oauth-connect",method:"POST",headers:o,query:r,body:iw(t.connectOAuthParams)},n);return this.isJsonMime(i.headers.get("content-type"))?new Ue(i):new Nc(i)}async oauthConnect(t,n){return await(await this.oauthConnectRaw(t,n)).value()}async oauthUpdateRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling oauthUpdate.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling oauthUpdate.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/connections/{connectionId}:oauth-update".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{connectionId}",encodeURIComponent(String(t.connectionId))),method:"PATCH",headers:o,query:r},n);return this.isJsonMime(i.headers.get("content-type"))?new Ue(i):new Nc(i)}async oauthUpdate(t,n){return await(await this.oauthUpdateRaw(t,n)).value()}}class xw extends cn{async createProjectRaw(t,n){if(t.project===null||t.project===void 0)throw new ie("project","Required parameter requestParameters.project was null or undefined when calling createProject.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects",method:"POST",headers:o,query:r,body:tv(t.project)},n);return new Ue(i,s=>eo(s))}async createProject(t,n){return await(await this.createProjectRaw(t,n)).value()}async getProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getProject.");const r={};t.includeEntitlements!==void 0&&(r.includeEntitlements=t.includeEntitlements);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Ue(i,s=>eo(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 Ue(o,i=>i.map(eo))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new ie("projectUpdate","Required parameter requestParameters.projectUpdate was null or undefined when calling updateProject.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PATCH",headers:o,query:r,body:gw(t.projectUpdate)},n);return new Ue(i,s=>eo(s))}async updateProject(t,n){return await(await this.updateProjectRaw(t,n)).value()}}class Sw extends cn{async getProviderRaw(t,n){if(t.provider===null||t.provider===void 0)throw new ie("provider","Required parameter requestParameters.provider was null or undefined when calling getProvider.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/providers/{provider}".replace("{provider}",encodeURIComponent(String(t.provider))),method:"GET",headers:o,query:r},n);return new Ue(i,s=>Fc(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 Ue(o,i=>Ve(i,Fc))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class Ew extends cn{async createProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new ie("providerApp","Required parameter requestParameters.providerApp was null or undefined when calling createProviderApp.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:r,body:nv(t.providerApp)},n);return new Ue(i,s=>fo(s))}async createProviderApp(t,n){return await(await this.createProviderAppRaw(t,n)).value()}async deleteProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new ie("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling deleteProviderApp.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"DELETE",headers:o,query:r},n);return new Qr(i)}async deleteProviderApp(t,n){await this.deleteProviderAppRaw(t,n)}async listProviderAppsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listProviderApps.");const r={},o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Ue(i,s=>s.map(fo))}async listProviderApps(t,n){return await(await this.listProviderAppsRaw(t,n)).value()}async updateProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new ie("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new ie("providerAppUpdate","Required parameter requestParameters.providerAppUpdate was null or undefined when calling updateProviderApp.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/provider-apps/{providerAppId}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{providerAppId}",encodeURIComponent(String(t.providerAppId))),method:"PATCH",headers:o,query:r,body:vw(t.providerAppUpdate)},n);return new Ue(i,s=>fo(s))}async updateProviderApp(t,n){return await(await this.updateProviderAppRaw(t,n)).value()}}class Ow extends cn{async createRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");if(t.revision===null||t.revision===void 0)throw new ie("revision","Required parameter requestParameters.revision was null or undefined when calling createRevision.");const r={},o={};o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/revisions".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))),method:"POST",headers:o,query:r,body:rv(t.revision)},n);return new Qr(i)}async createRevision(t,n){await this.createRevisionRaw(t,n)}async getHydratedRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ie("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new ie("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new ie("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new ie("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getHydratedRevision.");const r={};t.connectionId!==void 0&&(r.connectionId=t.connectionId);const o={};this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key"));const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationId}/revisions/{revisionId}:hydrate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))).replace("{integrationId}",encodeURIComponent(String(t.integrationId))).replace("{revisionId}",encodeURIComponent(String(t.revisionId))),method:"GET",headers:o,query:r},n);return new Ue(i,s=>Rv(s))}async getHydratedRevision(t,n){return await(await this.getHydratedRevisionRaw(t,n)).value()}}var Au=Symbol.for("immer-nothing"),Dc=Symbol.for("immer-draftable"),Tt=Symbol.for("immer-state"),_w=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 Ct(e,...t){if(process.env.NODE_ENV!=="production"){const n=_w[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 Xr=Object.getPrototypeOf;function Yr(e){return!!e&&!!e[Tt]}function Er(e){var t;return e?Ru(e)||Array.isArray(e)||!!e[Dc]||!!((t=e.constructor)!=null&&t[Dc])||ko(e)||Lo(e):!1}var Nw=Object.prototype.constructor.toString();function Ru(e){if(!e||typeof e!="object")return!1;const t=Xr(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)===Nw}function bo(e,t){Mo(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Mo(e){const t=e[Tt];return t?t.type_:Array.isArray(e)?1:ko(e)?2:Lo(e)?3:0}function Ks(e,t){return Mo(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Pu(e,t,n){const r=Mo(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function Tw(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function ko(e){return e instanceof Map}function Lo(e){return e instanceof Set}function ur(e){return e.copy_||e.base_}function Us(e,t){if(ko(e))return new Map(e);if(Lo(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=Ru(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[Tt];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(Xr(e),r)}else{const r=Xr(e);if(r!==null&&n)return{...e};const o=Object.create(r);return Object.assign(o,e)}}function ma(e,t=!1){return jo(e)||Yr(e)||!Er(e)||(Mo(e)>1&&(e.set=e.add=e.clear=e.delete=Aw),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>ma(r,!0))),e}function Aw(){Ct(2)}function jo(e){return Object.isFrozen(e)}var Rw={};function Or(e){const t=Rw[e];return t||Ct(0,e),t}var Si;function Fu(){return Si}function Pw(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Mc(e,t){t&&(Or("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function $s(e){qs(e),e.drafts_.forEach(Fw),e.drafts_=null}function qs(e){e===Si&&(Si=e.parent_)}function kc(e){return Si=Pw(Si,e)}function Fw(e){const t=e[Tt];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Lc(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[Tt].modified_&&($s(t),Ct(4)),Er(e)&&(e=Io(t,e),t.parent_||Co(t,e)),t.patches_&&Or("Patches").generateReplacementPatches_(n[Tt].base_,e,t.patches_,t.inversePatches_)):e=Io(t,n,[]),$s(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Au?e:void 0}function Io(e,t,n){if(jo(t))return t;const r=t[Tt];if(!r)return bo(t,(o,i)=>jc(e,r,t,o,i,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return Co(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),bo(i,(a,c)=>jc(e,r,o,a,c,n,s)),Co(e,o,!1),n&&e.patches_&&Or("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function jc(e,t,n,r,o,i,s){if(process.env.NODE_ENV!=="production"&&o===n&&Ct(5),Yr(o)){const a=i&&t&&t.type_!==3&&!Ks(t.assigned_,r)?i.concat(r):void 0,c=Io(e,o,a);if(Pu(n,r,c),Yr(c))e.canAutoFreeze_=!1;else return}else s&&n.add(o);if(Er(o)&&!jo(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Io(e,o),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&Co(e,o)}}function Co(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ma(t,n)}function Dw(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=ga;n&&(o=[r],i=Ei);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,a}var ga={get(e,t){if(t===Tt)return e;const n=ur(e);if(!Ks(n,t))return Mw(e,n,t);const r=n[t];return e.finalized_||!Er(r)?r:r===ss(e.base_,t)?(as(e),e.copy_[t]=Hs(r,e)):r},has(e,t){return t in ur(e)},ownKeys(e){return Reflect.ownKeys(ur(e))},set(e,t,n){const r=Du(ur(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const o=ss(ur(e),t),i=o==null?void 0:o[Tt];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(Tw(n,o)&&(n!==void 0||Ks(e.base_,t)))return!0;as(e),Vs(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 ss(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,as(e),Vs(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=ur(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){Ct(11)},getPrototypeOf(e){return Xr(e.base_)},setPrototypeOf(){Ct(12)}},Ei={};bo(ga,(e,t)=>{Ei[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Ei.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Ct(13),Ei.set.call(this,e,t,void 0)};Ei.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Ct(14),ga.set.call(this,e[0],t,n,e[0])};function ss(e,t){const n=e[Tt];return(n?ur(n):e)[t]}function Mw(e,t,n){var o;const r=Du(t,n);return r?"value"in r?r.value:(o=r.get)==null?void 0:o.call(e.draft_):void 0}function Du(e,t){if(!(t in e))return;let n=Xr(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Xr(n)}}function Vs(e){e.modified_||(e.modified_=!0,e.parent_&&Vs(e.parent_))}function as(e){e.copy_||(e.copy_=Us(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var kw=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const s=this;return function(c=i,...d){return s.produce(c,u=>n.call(this,u,...d))}}typeof n!="function"&&Ct(6),r!==void 0&&typeof r!="function"&&Ct(7);let o;if(Er(t)){const i=kc(this),s=Hs(t,void 0);let a=!0;try{o=n(s),a=!1}finally{a?$s(i):qs(i)}return Mc(i,r),Lc(o,i)}else if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===Au&&(o=void 0),this.autoFreeze_&&ma(o,!0),r){const i=[],s=[];Or("Patches").generateReplacementPatches_(t,o,i,s),r(i,s)}return o}else Ct(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,c=>t(c,...a));let r,o;return[this.produce(t,n,(s,a)=>{r=s,o=a}),r,o]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Er(e)||Ct(8),Yr(e)&&(e=Lw(e));const t=kc(this),n=Hs(e,void 0);return n[Tt].isManual_=!0,qs(t),n}finishDraft(e,t){const n=e&&e[Tt];(!n||!n.isManual_)&&Ct(9);const{scope_:r}=n;return Mc(r,t),Lc(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));const r=Or("Patches").applyPatches_;return Yr(e)?r(e,t):this.produce(e,o=>r(o,t))}};function Hs(e,t){const n=ko(e)?Or("MapSet").proxyMap_(e,t):Lo(e)?Or("MapSet").proxySet_(e,t):Dw(e,t);return(t?t.scope_:Fu()).drafts_.push(n),n}function Lw(e){return Yr(e)||Ct(10,e),Mu(e)}function Mu(e){if(!Er(e)||jo(e))return e;const t=e[Tt];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Us(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Us(e,!0);return bo(n,(r,o)=>{Pu(n,r,Mu(o))}),t&&(t.finalized_=!1),n}var At=new kw,It=At.produce;At.produceWithPatches.bind(At);At.setAutoFreeze.bind(At);At.setUseStrictShallowCopy.bind(At);At.applyPatches.bind(At);At.createDraft.bind(At);At.finishDraft.bind(At);const De=async(e,t)=>{var n;if(e instanceof pu){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 Tp=Object.defineProperty;var hc=e=>{throw TypeError(e)};var Ap=(e,t,n)=>t in e?Tp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var De=(e,t,n)=>Ap(e,typeof t!="symbol"?t+"":t,n),ns=(e,t,n)=>t.has(e)||hc("Cannot "+n);var O=(e,t,n)=>(ns(e,t,"read from private field"),n?n.call(e):t.get(e)),ie=(e,t,n)=>t.has(e)?hc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),G=(e,t,n,r)=>(ns(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),pe=(e,t,n)=>(ns(e,t,"access private method"),n);var Zi=(e,t,n,r)=>({set _(o){G(e,t,o,n)},get _(){return O(e,t,r)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),b=require("react");require("react-dom");function Rp(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 j=Rp(b);var ai=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 ht(){}function Pp(e,t){return typeof e=="function"?e(t):e}function Ss(e){return typeof e=="number"&&e>=0&&e!==1/0}function Ku(e,t){return Math.max(e+(t||0)-Date.now(),0)}function zn(e,t){return typeof e=="function"?e(t):e}function Kt(e,t){return typeof e=="function"?e(t):e}function mc(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==aa(s,t.options))return!1}else if(!xi(t.queryKey,s))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||o&&o!==t.state.fetchStatus||i&&!i(t))}function gc(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Sr(t.options.mutationKey)!==Sr(i))return!1}else if(!xi(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function aa(e,t){return((t==null?void 0:t.queryKeyHashFn)||Sr)(e)}function Sr(e){return JSON.stringify(e,(t,n)=>Os(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function xi(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>xi(e[n],t[n])):!1}function xs(e,t){if(e===t)return e;const n=yc(e)&&yc(t);if(n||Os(e)&&Os(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{},c=new Set(r);let f=0;for(let d=0;d<s;d++){const l=n?d:i[d];(!n&&c.has(l)||n)&&e[l]===void 0&&t[l]===void 0?(a[l]=void 0,f++):(a[l]=xs(e[l],t[l]),a[l]===e[l]&&e[l]!==void 0&&f++)}return o===s&&f===o?e:a}return t}function yo(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 yc(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Os(e){if(!vc(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!vc(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function vc(e){return Object.prototype.toString.call(e)==="[object Object]"}function Fp(e){return new Promise(t=>{setTimeout(t,e)})}function Es(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 xs(e,t)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return xs(e,t)}return t}function Dp(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Mp(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var vo=Symbol();function $u(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===vo&&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===vo?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Uu(e,t){return typeof e=="function"?e(...t):!!e}var pr,Kn,Lr,Tu,kp=(Tu=class extends ai{constructor(){super();ie(this,pr);ie(this,Kn);ie(this,Lr);G(this,Lr,t=>{if(!Cr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){O(this,Kn)||this.setEventListener(O(this,Lr))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,Kn))==null||t.call(this),G(this,Kn,void 0))}setEventListener(t){var n;G(this,Lr,t),(n=O(this,Kn))==null||n.call(this),G(this,Kn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){O(this,pr)!==t&&(G(this,pr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof O(this,pr)=="boolean"?O(this,pr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},pr=new WeakMap,Kn=new WeakMap,Lr=new WeakMap,Tu),ca=new kp,jr,$n,Kr,Au,Lp=(Au=class extends ai{constructor(){super();ie(this,jr,!0);ie(this,$n);ie(this,Kr);G(this,Kr,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,$n)||this.setEventListener(O(this,Kr))}onUnsubscribe(){var t;this.hasListeners()||((t=O(this,$n))==null||t.call(this),G(this,$n,void 0))}setEventListener(t){var n;G(this,Kr,t),(n=O(this,$n))==null||n.call(this),G(this,$n,t(this.setOnline.bind(this)))}setOnline(t){O(this,jr)!==t&&(G(this,jr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return O(this,jr)}},jr=new WeakMap,$n=new WeakMap,Kr=new WeakMap,Au),wo=new Lp;function _s(){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 jp(e){return Math.min(1e3*2**e,3e4)}function qu(e){return(e??"online")==="online"?wo.isOnline():!0}var Vu=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Hu(e){let t=!1,n=0,r;const o=_s(),i=()=>o.status!=="pending",s=w=>{var h;i()||(m(new Vu(w)),(h=e.abort)==null||h.call(e))},a=()=>{t=!0},c=()=>{t=!1},f=()=>ca.isFocused()&&(e.networkMode==="always"||wo.isOnline())&&e.canRun(),d=()=>qu(e.networkMode)&&e.canRun(),l=w=>{i()||(r==null||r(),o.resolve(w))},m=w=>{i()||(r==null||r(),o.reject(w))},g=()=>new Promise(w=>{var h;r=S=>{(i()||f())&&w(S)},(h=e.onPause)==null||h.call(e)}).then(()=>{var w;r=void 0,i()||(w=e.onContinue)==null||w.call(e)}),v=()=>{if(i())return;let w;const h=n===0?e.initialPromise:void 0;try{w=h??e.fn()}catch(S){w=Promise.reject(S)}Promise.resolve(w).then(l).catch(S=>{var T;if(i())return;const p=e.retry??(Cr?0:3),y=e.retryDelay??jp,I=typeof y=="function"?y(n,S):y,x=p===!0||typeof p=="number"&&n<p||typeof p=="function"&&p(n,S);if(t||!x){m(S);return}n++,(T=e.onFail)==null||T.call(e,n,S),Fp(I).then(()=>f()?void 0:g()).then(()=>{t?m(S):v()})})};return{promise:o,status:()=>o.status,cancel:s,continue:()=>(r==null||r(),o),cancelRetry:a,continueRetry:c,canStart:d,start:()=>(d()?v():g().then(v),o)}}var Kp=e=>setTimeout(e,0);function $p(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=Kp;const i=a=>{t?e.push(a):o(()=>{n(a)})},s=()=>{const a=e;e=[],a.length&&o(()=>{r(()=>{a.forEach(c=>{n(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||s()}return c},batchCalls:a=>(...c)=>{i(()=>{a(...c)})},schedule:i,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{o=a}}}var ze=$p(),hr,Ru,Bu=(Ru=class{constructor(){ie(this,hr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ss(this.gcTime)&&G(this,hr,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Cr?1/0:5*60*1e3))}clearGcTimeout(){O(this,hr)&&(clearTimeout(O(this,hr)),G(this,hr,void 0))}},hr=new WeakMap,Ru),$r,Ur,jt,mr,Ye,Pi,gr,Gt,bn,Pu,Up=(Pu=class extends Bu{constructor(t){super();ie(this,Gt);ie(this,$r);ie(this,Ur);ie(this,jt);ie(this,mr);ie(this,Ye);ie(this,Pi);ie(this,gr);G(this,gr,!1),G(this,Pi,t.defaultOptions),this.setOptions(t.options),this.observers=[],G(this,mr,t.client),G(this,jt,O(this,mr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,G(this,$r,qp(this.options)),this.state=t.state??O(this,$r),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=O(this,Ye))==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,jt).remove(this)}setData(t,n){const r=Es(this.state.data,t,this.options);return pe(this,Gt,bn).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,Gt,bn).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=O(this,Ye))==null?void 0:r.promise;return(o=O(this,Ye))==null||o.cancel(t),n?n.then(ht).catch(ht):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(O(this,$r))}isActive(){return this.observers.some(t=>Kt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===vo||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>zn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Ku(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=O(this,Ye))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=O(this,Ye))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),O(this,jt).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,Ye)&&(O(this,gr)?O(this,Ye).cancel({revert:!0}):O(this,Ye).cancelRetry()),this.scheduleGc()),O(this,jt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||pe(this,Gt,bn).call(this,{type:"invalidate"})}async fetch(t,n){var c,f,d,l,m,g,v,w,h,S,p,y;if(this.state.fetchStatus!=="idle"&&((c=O(this,Ye))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(O(this,Ye))return O(this,Ye).continueRetry(),O(this,Ye).promise}if(t&&this.setOptions(t),!this.options.queryFn){const I=this.observers.find(x=>x.options.queryFn);I&&this.setOptions(I.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=I=>{Object.defineProperty(I,"signal",{enumerable:!0,get:()=>(G(this,gr,!0),r.signal)})},i=()=>{const I=$u(this.options,n),T=(()=>{const E={client:O(this,mr),queryKey:this.queryKey,meta:this.meta};return o(E),E})();return G(this,gr,!1),this.options.persister?this.options.persister(I,T,this):I(T)},a=(()=>{const I={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:O(this,mr),state:this.state,fetchFn:i};return o(I),I})();(f=this.options.behavior)==null||f.onFetch(a,this),G(this,Ur,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=a.fetchOptions)==null?void 0:d.meta))&&pe(this,Gt,bn).call(this,{type:"fetch",meta:(l=a.fetchOptions)==null?void 0:l.meta}),G(this,Ye,Hu({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,abort:r.abort.bind(r),onFail:(I,x)=>{pe(this,Gt,bn).call(this,{type:"failed",failureCount:I,error:x})},onPause:()=>{pe(this,Gt,bn).call(this,{type:"pause"})},onContinue:()=>{pe(this,Gt,bn).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const I=await O(this,Ye).start();if(I===void 0)throw 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}`),new Error(`${this.queryHash} data is undefined`);return this.setData(I),(g=(m=O(this,jt).config).onSuccess)==null||g.call(m,I,this),(w=(v=O(this,jt).config).onSettled)==null||w.call(v,I,this.state.error,this),I}catch(I){if(I instanceof Vu){if(I.silent)return O(this,Ye).promise;if(I.revert){if(this.setState({...O(this,Ur),fetchStatus:"idle"}),this.state.data===void 0)throw I;return this.state.data}}throw pe(this,Gt,bn).call(this,{type:"error",error:I}),(S=(h=O(this,jt).config).onError)==null||S.call(h,I,this),(y=(p=O(this,jt).config).onSettled)==null||y.call(p,this.state.data,I,this),I}finally{this.scheduleGc()}}},$r=new WeakMap,Ur=new WeakMap,jt=new WeakMap,mr=new WeakMap,Ye=new WeakMap,Pi=new WeakMap,gr=new WeakMap,Gt=new WeakSet,bn=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,...Ju(r.data,this.options),fetchMeta:t.meta??null};case"success":const o={...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}};return G(this,Ur,t.manual?o:void 0),o;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),ze.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),O(this,jt).notify({query:this,type:"updated",action:t})})},Pu);function Ju(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:qu(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function qp(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 on,Fu,Vp=(Fu=class extends ai{constructor(t={}){super();ie(this,on);this.config=t,G(this,on,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??aa(o,n);let s=this.get(i);return s||(s=new Up({client:t,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){O(this,on).has(t.queryHash)||(O(this,on).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=O(this,on).get(t.queryHash);n&&(t.destroy(),n===t&&O(this,on).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ze.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return O(this,on).get(t)}getAll(){return[...O(this,on).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>mc(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>mc(t,r)):n}notify(t){ze.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){ze.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ze.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},on=new WeakMap,Fu),sn,ft,yr,an,jn,Du,Hp=(Du=class extends Bu{constructor(t){super();ie(this,an);ie(this,sn);ie(this,ft);ie(this,yr);this.mutationId=t.mutationId,G(this,ft,t.mutationCache),G(this,sn,[]),this.state=t.state||Wu(),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,sn).includes(t)||(O(this,sn).push(t),this.clearGcTimeout(),O(this,ft).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){G(this,sn,O(this,sn).filter(n=>n!==t)),this.scheduleGc(),O(this,ft).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){O(this,sn).length||(this.state.status==="pending"?this.scheduleGc():O(this,ft).remove(this))}continue(){var t;return((t=O(this,yr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,s,a,c,f,d,l,m,g,v,w,h,S,p,y,I,x,T,E,A;const n=()=>{pe(this,an,jn).call(this,{type:"continue"})};G(this,yr,Hu({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(R,P)=>{pe(this,an,jn).call(this,{type:"failed",failureCount:R,error:P})},onPause:()=>{pe(this,an,jn).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>O(this,ft).canRun(this)}));const r=this.state.status==="pending",o=!O(this,yr).canStart();try{if(r)n();else{pe(this,an,jn).call(this,{type:"pending",variables:t,isPaused:o}),await((s=(i=O(this,ft).config).onMutate)==null?void 0:s.call(i,t,this));const P=await((c=(a=this.options).onMutate)==null?void 0:c.call(a,t));P!==this.state.context&&pe(this,an,jn).call(this,{type:"pending",context:P,variables:t,isPaused:o})}const R=await O(this,yr).start();return await((d=(f=O(this,ft).config).onSuccess)==null?void 0:d.call(f,R,t,this.state.context,this)),await((m=(l=this.options).onSuccess)==null?void 0:m.call(l,R,t,this.state.context)),await((v=(g=O(this,ft).config).onSettled)==null?void 0:v.call(g,R,null,this.state.variables,this.state.context,this)),await((h=(w=this.options).onSettled)==null?void 0:h.call(w,R,null,t,this.state.context)),pe(this,an,jn).call(this,{type:"success",data:R}),R}catch(R){try{throw await((p=(S=O(this,ft).config).onError)==null?void 0:p.call(S,R,t,this.state.context,this)),await((I=(y=this.options).onError)==null?void 0:I.call(y,R,t,this.state.context)),await((T=(x=O(this,ft).config).onSettled)==null?void 0:T.call(x,void 0,R,this.state.variables,this.state.context,this)),await((A=(E=this.options).onSettled)==null?void 0:A.call(E,void 0,R,t,this.state.context)),R}finally{pe(this,an,jn).call(this,{type:"error",error:R})}}finally{O(this,ft).runNext(this)}}},sn=new WeakMap,ft=new WeakMap,yr=new WeakMap,an=new WeakSet,jn=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),ze.batch(()=>{O(this,sn).forEach(r=>{r.onMutationUpdate(t)}),O(this,ft).notify({mutation:this,type:"updated",action:t})})},Du);function Wu(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var In,Qt,Fi,Mu,Bp=(Mu=class extends ai{constructor(t={}){super();ie(this,In);ie(this,Qt);ie(this,Fi);this.config=t,G(this,In,new Set),G(this,Qt,new Map),G(this,Fi,0)}build(t,n,r){const o=new Hp({mutationCache:this,mutationId:++Zi(this,Fi)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){O(this,In).add(t);const n=eo(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,In).delete(t)){const n=eo(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=eo(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=eo(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(){ze.batch(()=>{O(this,In).forEach(t=>{this.notify({type:"removed",mutation:t})}),O(this,In).clear(),O(this,Qt).clear()})}getAll(){return Array.from(O(this,In))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>gc(n,r))}findAll(t={}){return this.getAll().filter(n=>gc(t,n))}notify(t){ze.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return ze.batch(()=>Promise.all(t.map(n=>n.continue().catch(ht))))}},In=new WeakMap,Qt=new WeakMap,Fi=new WeakMap,Mu);function eo(e){var t;return(t=e.options.scope)==null?void 0:t.id}function wc(e){return{onFetch:(t,n)=>{var d,l,m,g,v;const r=t.options,o=(m=(l=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:l.fetchMore)==null?void 0:m.direction,i=((g=t.state.data)==null?void 0:g.pages)||[],s=((v=t.state.data)==null?void 0:v.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const f=async()=>{let w=!1;const h=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(t.signal.aborted?w=!0:t.signal.addEventListener("abort",()=>{w=!0}),t.signal)})},S=$u(t.options,t.fetchOptions),p=async(y,I,x)=>{if(w)return Promise.reject();if(I==null&&y.pages.length)return Promise.resolve(y);const E=(()=>{const K={client:t.client,queryKey:t.queryKey,pageParam:I,direction:x?"backward":"forward",meta:t.options.meta};return h(K),K})(),A=await S(E),{maxPages:R}=t.options,P=x?Mp:Dp;return{pages:P(y.pages,A,R),pageParams:P(y.pageParams,I,R)}};if(o&&i.length){const y=o==="backward",I=y?Jp:bc,x={pages:i,pageParams:s},T=I(r,x);a=await p(x,T,y)}else{const y=e??i.length;do{const I=c===0?s[0]??r.initialPageParam:bc(r,a);if(c>0&&I==null)break;a=await p(a,I),c++}while(c<y)}return a};t.options.persister?t.fetchFn=()=>{var w,h;return(h=(w=t.options).persister)==null?void 0:h.call(w,f,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=f}}}function bc(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 Jp(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,Un,qn,qr,Vr,Vn,Hr,Br,ku,Wp=(ku=class{constructor(e={}){ie(this,Ke);ie(this,Un);ie(this,qn);ie(this,qr);ie(this,Vr);ie(this,Vn);ie(this,Hr);ie(this,Br);G(this,Ke,e.queryCache||new Vp),G(this,Un,e.mutationCache||new Bp),G(this,qn,e.defaultOptions||{}),G(this,qr,new Map),G(this,Vr,new Map),G(this,Vn,0)}mount(){Zi(this,Vn)._++,O(this,Vn)===1&&(G(this,Hr,ca.subscribe(async e=>{e&&(await this.resumePausedMutations(),O(this,Ke).onFocus())})),G(this,Br,wo.subscribe(async e=>{e&&(await this.resumePausedMutations(),O(this,Ke).onOnline())})))}unmount(){var e,t;Zi(this,Vn)._--,O(this,Vn)===0&&((e=O(this,Hr))==null||e.call(this),G(this,Hr,void 0),(t=O(this,Br))==null||t.call(this),G(this,Br,void 0))}isFetching(e){return O(this,Ke).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return O(this,Un).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(zn(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=Pp(t,i);if(s!==void 0)return O(this,Ke).build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return ze.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);ze.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=O(this,Ke);return ze.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=ze.batch(()=>O(this,Ke).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(ht).catch(ht)}invalidateQueries(e,t={}){return ze.batch(()=>(O(this,Ke).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=ze.batch(()=>O(this,Ke).findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(ht)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(ht)}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(zn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ht).catch(ht)}fetchInfiniteQuery(e){return e.behavior=wc(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ht).catch(ht)}ensureInfiniteQueryData(e){return e.behavior=wc(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return wo.isOnline()?O(this,Un).resumePausedMutations():Promise.resolve()}getQueryCache(){return O(this,Ke)}getMutationCache(){return O(this,Un)}getDefaultOptions(){return O(this,qn)}setDefaultOptions(e){G(this,qn,e)}setQueryDefaults(e,t){O(this,qr).set(Sr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...O(this,qr).values()],n={};return t.forEach(r=>{xi(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){O(this,Vr).set(Sr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...O(this,Vr).values()],n={};return t.forEach(r=>{xi(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...O(this,qn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=aa(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===vo&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...O(this,qn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){O(this,Ke).clear(),O(this,Un).clear()}},Ke=new WeakMap,Un=new WeakMap,qn=new WeakMap,qr=new WeakMap,Vr=new WeakMap,Vn=new WeakMap,Hr=new WeakMap,Br=new WeakMap,ku),wt,ye,Di,pt,vr,Jr,Cn,Hn,Mi,Wr,zr,wr,br,Bn,Gr,xe,wi,Ns,Ts,As,Rs,Ps,Fs,Ds,zu,Lu,zp=(Lu=class extends ai{constructor(t,n){super();ie(this,xe);ie(this,wt);ie(this,ye);ie(this,Di);ie(this,pt);ie(this,vr);ie(this,Jr);ie(this,Cn);ie(this,Hn);ie(this,Mi);ie(this,Wr);ie(this,zr);ie(this,wr);ie(this,br);ie(this,Bn);ie(this,Gr,new Set);this.options=n,G(this,wt,t),G(this,Hn,null),G(this,Cn,_s()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(O(this,ye).addObserver(this),Ic(O(this,ye),this.options)?pe(this,xe,wi).call(this):this.updateResult(),pe(this,xe,Rs).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ms(O(this,ye),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ms(O(this,ye),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,pe(this,xe,Ps).call(this),pe(this,xe,Fs).call(this),O(this,ye).removeObserver(this)}setOptions(t){const n=this.options,r=O(this,ye);if(this.options=O(this,wt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Kt(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,xe,Ds).call(this),O(this,ye).setOptions(this.options),n._defaulted&&!yo(this.options,n)&&O(this,wt).getQueryCache().notify({type:"observerOptionsUpdated",query:O(this,ye),observer:this});const o=this.hasListeners();o&&Cc(O(this,ye),r,this.options,n)&&pe(this,xe,wi).call(this),this.updateResult(),o&&(O(this,ye)!==r||Kt(this.options.enabled,O(this,ye))!==Kt(n.enabled,O(this,ye))||zn(this.options.staleTime,O(this,ye))!==zn(n.staleTime,O(this,ye)))&&pe(this,xe,Ns).call(this);const i=pe(this,xe,Ts).call(this);o&&(O(this,ye)!==r||Kt(this.options.enabled,O(this,ye))!==Kt(n.enabled,O(this,ye))||i!==O(this,Bn))&&pe(this,xe,As).call(this,i)}getOptimisticResult(t){const n=O(this,wt).getQueryCache().build(O(this,wt),t),r=this.createResult(n,t);return Qp(this,r)&&(G(this,pt,r),G(this,Jr,this.options),G(this,vr,O(this,ye).state)),r}getCurrentResult(){return O(this,pt)}trackResult(t,n){return new Proxy(t,{get:(r,o)=>(this.trackProp(o),n==null||n(o),o==="promise"&&!this.options.experimental_prefetchInRender&&O(this,Cn).status==="pending"&&O(this,Cn).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(r,o))})}trackProp(t){O(this,Gr).add(t)}getCurrentQuery(){return O(this,ye)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=O(this,wt).defaultQueryOptions(t),r=O(this,wt).getQueryCache().build(O(this,wt),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return pe(this,xe,wi).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),O(this,pt)))}createResult(t,n){var R;const r=O(this,ye),o=this.options,i=O(this,pt),s=O(this,vr),a=O(this,Jr),f=t!==r?t.state:O(this,Di),{state:d}=t;let l={...d},m=!1,g;if(n._optimisticResults){const P=this.hasListeners(),K=!P&&Ic(t,n),q=P&&Cc(t,r,n,o);(K||q)&&(l={...l,...Ju(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:v,errorUpdatedAt:w,status:h}=l;g=l.data;let S=!1;if(n.placeholderData!==void 0&&g===void 0&&h==="pending"){let P;i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(P=i.data,S=!0):P=typeof n.placeholderData=="function"?n.placeholderData((R=O(this,zr))==null?void 0:R.state.data,O(this,zr)):n.placeholderData,P!==void 0&&(h="success",g=Es(i==null?void 0:i.data,P,n),m=!0)}if(n.select&&g!==void 0&&!S)if(i&&g===(s==null?void 0:s.data)&&n.select===O(this,Mi))g=O(this,Wr);else try{G(this,Mi,n.select),g=n.select(g),g=Es(i==null?void 0:i.data,g,n),G(this,Wr,g),G(this,Hn,null)}catch(P){G(this,Hn,P)}O(this,Hn)&&(v=O(this,Hn),g=O(this,Wr),w=Date.now(),h="error");const p=l.fetchStatus==="fetching",y=h==="pending",I=h==="error",x=y&&p,T=g!==void 0,A={status:h,fetchStatus:l.fetchStatus,isPending:y,isSuccess:h==="success",isError:I,isInitialLoading:x,isLoading:x,data:g,dataUpdatedAt:l.dataUpdatedAt,error:v,errorUpdatedAt:w,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>f.dataUpdateCount||l.errorUpdateCount>f.errorUpdateCount,isFetching:p,isRefetching:p&&!y,isLoadingError:I&&!T,isPaused:l.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:I&&T,isStale:ua(t,n),refetch:this.refetch,promise:O(this,Cn),isEnabled:Kt(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const P=V=>{A.status==="error"?V.reject(A.error):A.data!==void 0&&V.resolve(A.data)},K=()=>{const V=G(this,Cn,A.promise=_s());P(V)},q=O(this,Cn);switch(q.status){case"pending":t.queryHash===r.queryHash&&P(q);break;case"fulfilled":(A.status==="error"||A.data!==q.value)&&K();break;case"rejected":(A.status!=="error"||A.error!==q.reason)&&K();break}}return A}updateResult(){const t=O(this,pt),n=this.createResult(O(this,ye),this.options);if(G(this,vr,O(this,ye).state),G(this,Jr,this.options),O(this,vr).data!==void 0&&G(this,zr,O(this,ye)),yo(n,t))return;G(this,pt,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options,i=typeof o=="function"?o():o;if(i==="all"||!i&&!O(this,Gr).size)return!0;const s=new Set(i??O(this,Gr));return this.options.throwOnError&&s.add("error"),Object.keys(O(this,pt)).some(a=>{const c=a;return O(this,pt)[c]!==t[c]&&s.has(c)})};pe(this,xe,zu).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&pe(this,xe,Rs).call(this)}},wt=new WeakMap,ye=new WeakMap,Di=new WeakMap,pt=new WeakMap,vr=new WeakMap,Jr=new WeakMap,Cn=new WeakMap,Hn=new WeakMap,Mi=new WeakMap,Wr=new WeakMap,zr=new WeakMap,wr=new WeakMap,br=new WeakMap,Bn=new WeakMap,Gr=new WeakMap,xe=new WeakSet,wi=function(t){pe(this,xe,Ds).call(this);let n=O(this,ye).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(ht)),n},Ns=function(){pe(this,xe,Ps).call(this);const t=zn(this.options.staleTime,O(this,ye));if(Cr||O(this,pt).isStale||!Ss(t))return;const r=Ku(O(this,pt).dataUpdatedAt,t)+1;G(this,wr,setTimeout(()=>{O(this,pt).isStale||this.updateResult()},r))},Ts=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(O(this,ye)):this.options.refetchInterval)??!1},As=function(t){pe(this,xe,Fs).call(this),G(this,Bn,t),!(Cr||Kt(this.options.enabled,O(this,ye))===!1||!Ss(O(this,Bn))||O(this,Bn)===0)&&G(this,br,setInterval(()=>{(this.options.refetchIntervalInBackground||ca.isFocused())&&pe(this,xe,wi).call(this)},O(this,Bn)))},Rs=function(){pe(this,xe,Ns).call(this),pe(this,xe,As).call(this,pe(this,xe,Ts).call(this))},Ps=function(){O(this,wr)&&(clearTimeout(O(this,wr)),G(this,wr,void 0))},Fs=function(){O(this,br)&&(clearInterval(O(this,br)),G(this,br,void 0))},Ds=function(){const t=O(this,wt).getQueryCache().build(O(this,wt),this.options);if(t===O(this,ye))return;const n=O(this,ye);G(this,ye,t),G(this,Di,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},zu=function(t){ze.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(O(this,pt))}),O(this,wt).getQueryCache().notify({query:O(this,ye),type:"observerResultsUpdated"})})},Lu);function Gp(e,t){return Kt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ic(e,t){return Gp(e,t)||e.state.data!==void 0&&Ms(e,t,t.refetchOnMount)}function Ms(e,t,n){if(Kt(t.enabled,e)!==!1&&zn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&ua(e,t)}return!1}function Cc(e,t,n,r){return(e!==t||Kt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ua(e,n)}function ua(e,t){return Kt(t.enabled,e)!==!1&&e.isStaleByTime(zn(t.staleTime,e))}function Qp(e,t){return!yo(e.getCurrentResult(),t)}var Jn,Wn,bt,Sn,On,lo,ks,ju,Xp=(ju=class extends ai{constructor(n,r){super();ie(this,On);ie(this,Jn);ie(this,Wn);ie(this,bt);ie(this,Sn);G(this,Jn,n),this.setOptions(r),this.bindMethods(),pe(this,On,lo).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var o;const r=this.options;this.options=O(this,Jn).defaultMutationOptions(n),yo(this.options,r)||O(this,Jn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:O(this,bt),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Sr(r.mutationKey)!==Sr(this.options.mutationKey)?this.reset():((o=O(this,bt))==null?void 0:o.state.status)==="pending"&&O(this,bt).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=O(this,bt))==null||n.removeObserver(this)}onMutationUpdate(n){pe(this,On,lo).call(this),pe(this,On,ks).call(this,n)}getCurrentResult(){return O(this,Wn)}reset(){var n;(n=O(this,bt))==null||n.removeObserver(this),G(this,bt,void 0),pe(this,On,lo).call(this),pe(this,On,ks).call(this)}mutate(n,r){var o;return G(this,Sn,r),(o=O(this,bt))==null||o.removeObserver(this),G(this,bt,O(this,Jn).getMutationCache().build(O(this,Jn),this.options)),O(this,bt).addObserver(this),O(this,bt).execute(n)}},Jn=new WeakMap,Wn=new WeakMap,bt=new WeakMap,Sn=new WeakMap,On=new WeakSet,lo=function(){var r;const n=((r=O(this,bt))==null?void 0:r.state)??Wu();G(this,Wn,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},ks=function(n){ze.batch(()=>{var r,o,i,s,a,c,f,d;if(O(this,Sn)&&this.hasListeners()){const l=O(this,Wn).variables,m=O(this,Wn).context;(n==null?void 0:n.type)==="success"?((o=(r=O(this,Sn)).onSuccess)==null||o.call(r,n.data,l,m),(s=(i=O(this,Sn)).onSettled)==null||s.call(i,n.data,null,l,m)):(n==null?void 0:n.type)==="error"&&((c=(a=O(this,Sn)).onError)==null||c.call(a,n.error,l,m),(d=(f=O(this,Sn)).onSettled)==null||d.call(f,void 0,n.error,l,m))}this.listeners.forEach(l=>{l(O(this,Wn))})})},ju),Gu=j.createContext(void 0),Ue=e=>{const t=j.useContext(Gu);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Yp=({client:e,children:t})=>(j.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),u.jsx(Gu.Provider,{value:e,children:t})),Qu=j.createContext(!1),Zp=()=>j.useContext(Qu);Qu.Provider;function eh(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var th=j.createContext(eh()),nh=()=>j.useContext(th),rh=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},ih=e=>{j.useEffect(()=>{e.clearReset()},[e])},oh=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||Uu(n,[e.error,r])),sh=e=>{if(e.suspense){const t=r=>r==="static"?r:Math.max(r??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...r)=>t(n(...r)):t(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},ah=(e,t)=>e.isLoading&&e.isFetching&&!t,ch=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Sc=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function uh(e,t,n){var l,m,g,v,w;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=Zp(),o=nh(),i=Ue(),s=i.defaultQueryOptions(e);(m=(l=i.getDefaultOptions().queries)==null?void 0:l._experimental_beforeQuery)==null||m.call(l,s),process.env.NODE_ENV!=="production"&&(s.queryFn||console.error(`[${s.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),s._optimisticResults=r?"isRestoring":"optimistic",sh(s),rh(s,o),ih(o);const a=!i.getQueryCache().get(s.queryHash),[c]=j.useState(()=>new t(i,s)),f=c.getOptimisticResult(s),d=!r&&e.subscribed!==!1;if(j.useSyncExternalStore(j.useCallback(h=>{const S=d?c.subscribe(ze.batchCalls(h)):ht;return c.updateResult(),S},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),j.useEffect(()=>{c.setOptions(s)},[s,c]),ch(s,f))throw Sc(s,c,o);if(oh({result:f,errorResetBoundary:o,throwOnError:s.throwOnError,query:i.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw f.error;if((v=(g=i.getDefaultOptions().queries)==null?void 0:g._experimental_afterQuery)==null||v.call(g,s,f),s.experimental_prefetchInRender&&!Cr&&ah(f,r)){const h=a?Sc(s,c,o):(w=i.getQueryCache().get(s.queryHash))==null?void 0:w.promise;h==null||h.catch(ht).finally(()=>{c.updateResult()})}return s.notifyOnChangeProps?f:c.trackResult(f)}function Zn(e,t){return uh(e,zp)}function En(e,t){const n=Ue(),[r]=j.useState(()=>new Xp(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);const o=j.useSyncExternalStore(j.useCallback(s=>r.subscribe(ze.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=j.useCallback((s,a)=>{r.mutate(s,a).catch(ht)},[r]);if(o.error&&Uu(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:i,mutateAsync:o.mutate}}const Xu=b.createContext(null),lh=Xu.Provider,Yu=()=>b.useContext(Xu);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 Zu=b.createContext(void 0);function qt(){const e=b.useContext(Zu);if(!e)throw new Error("useErrorState must be used within a ErrorProvider");return e}const dh=(()=>{const e={};return Object.values(ue).forEach(t=>{e[t]={}}),e})();function fh({children:e}){const[t,n]=b.useState(dh),r=b.useCallback((d,l,m=!0)=>{n(g=>{const v={...g};return v[d]=v[d]||{},v[d][l]=m,v})},[n]),o=b.useCallback((d,l)=>{var m;return!!((m=t[d])!=null&&m[l])},[t]),i=b.useCallback((d,l)=>{var m;return(m=t[d])==null?void 0:m[l]},[t]),s=b.useCallback((d,l)=>{n(m=>{var v;const g={...m};return(v=g[d])==null||delete v[l],g})},[n]),a=b.useCallback(d=>{n(l=>{const m={...l};return m[d]={},m})},[n]),c=b.useCallback((d,l)=>{n(m=>{const g={...m};return g[d]=g[d]||{},l.forEach(v=>{g[d][v]=!0}),g})},[n]),f=b.useMemo(()=>({errorState:t,setErrorState:n,setError:r,isError:o,removeError:s,resetBoundary:a,setErrors:c,getError:i}),[t,n,r,o,s,a,c,i]);return u.jsx(Zu.Provider,{value:f,children:e})}const to=new TextEncoder,Oi=new TextDecoder;function ph(...e){const t=e.reduce((o,{length:i})=>o+i,0),n=new Uint8Array(t);let r=0;for(const o of e)n.set(o,r),r+=o.length;return n}function hh(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function fo(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e=="string"?e:Oi.decode(e),{alphabet:"base64url"});let t=e;t instanceof Uint8Array&&(t=Oi.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return hh(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}}class er extends Error{constructor(n,r){var o;super(n,r);De(this,"code","ERR_JOSE_GENERIC");this.name=this.constructor.name,(o=Error.captureStackTrace)==null||o.call(Error,this,this.constructor)}}De(er,"code","ERR_JOSE_GENERIC");class zt extends er{constructor(n,r,o="unspecified",i="unspecified"){super(n,{cause:{claim:o,reason:i,payload:r}});De(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");De(this,"claim");De(this,"reason");De(this,"payload");this.claim=o,this.reason=i,this.payload=r}}De(zt,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");class Ls extends er{constructor(n,r,o="unspecified",i="unspecified"){super(n,{cause:{claim:o,reason:i,payload:r}});De(this,"code","ERR_JWT_EXPIRED");De(this,"claim");De(this,"reason");De(this,"payload");this.claim=o,this.reason=i,this.payload=r}}De(Ls,"code","ERR_JWT_EXPIRED");class el extends er{constructor(){super(...arguments);De(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}}De(el,"code","ERR_JOSE_ALG_NOT_ALLOWED");class dr extends er{constructor(){super(...arguments);De(this,"code","ERR_JOSE_NOT_SUPPORTED")}}De(dr,"code","ERR_JOSE_NOT_SUPPORTED");class Xe extends er{constructor(){super(...arguments);De(this,"code","ERR_JWS_INVALID")}}De(Xe,"code","ERR_JWS_INVALID");class la extends er{constructor(){super(...arguments);De(this,"code","ERR_JWT_INVALID")}}De(la,"code","ERR_JWT_INVALID");class tl extends er{constructor(n="signature verification failed",r){super(n,r);De(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}}De(tl,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");function wn(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function gi(e,t){return e.name===t}function rs(e){return parseInt(e.name.slice(4),10)}function mh(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function gh(e,t){if(!e.usages.includes(t))throw new TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function yh(e,t,n){switch(t){case"HS256":case"HS384":case"HS512":{if(!gi(e.algorithm,"HMAC"))throw wn("HMAC");const r=parseInt(t.slice(2),10);if(rs(e.algorithm.hash)!==r)throw wn(`SHA-${r}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!gi(e.algorithm,"RSASSA-PKCS1-v1_5"))throw wn("RSASSA-PKCS1-v1_5");const r=parseInt(t.slice(2),10);if(rs(e.algorithm.hash)!==r)throw wn(`SHA-${r}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!gi(e.algorithm,"RSA-PSS"))throw wn("RSA-PSS");const r=parseInt(t.slice(2),10);if(rs(e.algorithm.hash)!==r)throw wn(`SHA-${r}`,"algorithm.hash");break}case"Ed25519":case"EdDSA":{if(!gi(e.algorithm,"Ed25519"))throw wn("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!gi(e.algorithm,"ECDSA"))throw wn("ECDSA");const r=mh(t);if(e.algorithm.namedCurve!==r)throw wn(r,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}gh(e,n)}function nl(e,t,...n){var r;if(n=n.filter(Boolean),n.length>2){const o=n.pop();e+=`one of type ${n.join(", ")}, or ${o}.`}else n.length===2?e+=`one of type ${n[0]} or ${n[1]}.`:e+=`of type ${n[0]}.`;return t==null?e+=` Received ${t}`:typeof t=="function"&&t.name?e+=` Received function ${t.name}`:typeof t=="object"&&t!=null&&(r=t.constructor)!=null&&r.name&&(e+=` Received an instance of ${t.constructor.name}`),e}const vh=(e,...t)=>nl("Key must be ",e,...t);function rl(e,t,...n){return nl(`Key for the ${e} algorithm must be `,t,...n)}function il(e){return(e==null?void 0:e[Symbol.toStringTag])==="CryptoKey"}function ol(e){return(e==null?void 0:e[Symbol.toStringTag])==="KeyObject"}const sl=e=>il(e)||ol(e),wh=(...e)=>{const t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let n;for(const r of t){const o=Object.keys(r);if(!n||n.size===0){n=new Set(o);continue}for(const i of o){if(n.has(i))return!1;n.add(i)}}return!0};function bh(e){return typeof e=="object"&&e!==null}const bo=e=>{if(!bh(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t},Ih=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:n}=t.algorithm;if(typeof n!="number"||n<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}};function Ch(e){let t,n;switch(e.kty){case"RSA":{switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},n=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},n=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},n=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new dr('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"},n=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},n=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},n=e.d?["deriveBits"]:[];break;default:throw new dr('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(e.alg){case"Ed25519":case"EdDSA":t={name:"Ed25519"},n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},n=e.d?["deriveBits"]:[];break;default:throw new dr('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new dr('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:n}}const Sh=async e=>{if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:t,keyUsages:n}=Ch(e),r={...e};return delete r.alg,delete r.use,crypto.subtle.importKey("jwk",r,t,e.ext??!e.d,e.key_ops??n)},xh=(e,t,n,r,o)=>{if(o.crit!==void 0&&(r==null?void 0:r.crit)===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!r||r.crit===void 0)return new Set;if(!Array.isArray(r.crit)||r.crit.length===0||r.crit.some(s=>typeof s!="string"||s.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let i;n!==void 0?i=new Map([...Object.entries(n),...t.entries()]):i=t;for(const s of r.crit){if(!i.has(s))throw new dr(`Extension Header Parameter "${s}" is not recognized`);if(o[s]===void 0)throw new e(`Extension Header Parameter "${s}" is missing`);if(i.get(s)&&r[s]===void 0)throw new e(`Extension Header Parameter "${s}" MUST be integrity protected`)}return new Set(r.crit)},Oh=(e,t)=>{if(t!==void 0&&(!Array.isArray(t)||t.some(n=>typeof n!="string")))throw new TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)};function da(e){return bo(e)&&typeof e.kty=="string"}function Eh(e){return e.kty!=="oct"&&typeof e.d=="string"}function _h(e){return e.kty!=="oct"&&typeof e.d>"u"}function Nh(e){return e.kty==="oct"&&typeof e.k=="string"}let Mr;const xc=async(e,t,n,r=!1)=>{Mr||(Mr=new WeakMap);let o=Mr.get(e);if(o!=null&&o[n])return o[n];const i=await Sh({...t,alg:n});return r&&Object.freeze(e),o?o[n]=i:Mr.set(e,{[n]:i}),i},Th=(e,t)=>{var s;Mr||(Mr=new WeakMap);let n=Mr.get(e);if(n!=null&&n[t])return n[t];const r=e.type==="public",o=!!r;let i;if(e.asymmetricKeyType==="x25519"){switch(t){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw new TypeError("given KeyObject instance cannot be used for this algorithm")}i=e.toCryptoKey(e.asymmetricKeyType,o,r?[]:["deriveBits"])}if(e.asymmetricKeyType==="ed25519"){if(t!=="EdDSA"&&t!=="Ed25519")throw new TypeError("given KeyObject instance cannot be used for this algorithm");i=e.toCryptoKey(e.asymmetricKeyType,o,[r?"verify":"sign"])}if(e.asymmetricKeyType==="rsa"){let a;switch(t){case"RSA-OAEP":a="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":a="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":a="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":a="SHA-512";break;default:throw new TypeError("given KeyObject instance cannot be used for this algorithm")}if(t.startsWith("RSA-OAEP"))return e.toCryptoKey({name:"RSA-OAEP",hash:a},o,r?["encrypt"]:["decrypt"]);i=e.toCryptoKey({name:t.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:a},o,[r?"verify":"sign"])}if(e.asymmetricKeyType==="ec"){const c=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get((s=e.asymmetricKeyDetails)==null?void 0:s.namedCurve);if(!c)throw new TypeError("given KeyObject instance cannot be used for this algorithm");t==="ES256"&&c==="P-256"&&(i=e.toCryptoKey({name:"ECDSA",namedCurve:c},o,[r?"verify":"sign"])),t==="ES384"&&c==="P-384"&&(i=e.toCryptoKey({name:"ECDSA",namedCurve:c},o,[r?"verify":"sign"])),t==="ES512"&&c==="P-521"&&(i=e.toCryptoKey({name:"ECDSA",namedCurve:c},o,[r?"verify":"sign"])),t.startsWith("ECDH-ES")&&(i=e.toCryptoKey({name:"ECDH",namedCurve:c},o,r?[]:["deriveBits"]))}if(!i)throw new TypeError("given KeyObject instance cannot be used for this algorithm");return n?n[t]=i:Mr.set(e,{[t]:i}),i},Ah=async(e,t)=>{if(e instanceof Uint8Array||il(e))return e;if(ol(e)){if(e.type==="secret")return e.export();if("toCryptoKey"in e&&typeof e.toCryptoKey=="function")try{return Th(e,t)}catch(r){if(r instanceof TypeError)throw r}let n=e.export({format:"jwk"});return xc(e,n,t)}if(da(e))return e.k?fo(e.k):xc(e,e,t,!0);throw new Error("unreachable")},Fr=e=>e==null?void 0:e[Symbol.toStringTag],js=(e,t,n)=>{var r,o;if(t.use!==void 0){let i;switch(n){case"sign":case"verify":i="sig";break;case"encrypt":case"decrypt":i="enc";break}if(t.use!==i)throw new TypeError(`Invalid key for this operation, its "use" must be "${i}" when present`)}if(t.alg!==void 0&&t.alg!==e)throw new TypeError(`Invalid key for this operation, its "alg" must be "${e}" when present`);if(Array.isArray(t.key_ops)){let i;switch(!0){case n==="verify":case e==="dir":case e.includes("CBC-HS"):i=n;break;case e.startsWith("PBES2"):i="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):!e.includes("GCM")&&e.endsWith("KW")?i="unwrapKey":i=n;break;case n==="encrypt":i="wrapKey";break;case n==="decrypt":i=e.startsWith("RSA")?"unwrapKey":"deriveBits";break}if(i&&((o=(r=t.key_ops)==null?void 0:r.includes)==null?void 0:o.call(r,i))===!1)throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${i}" when present`)}return!0},Rh=(e,t,n)=>{if(!(t instanceof Uint8Array)){if(da(t)){if(Nh(t)&&js(e,t,n))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!sl(t))throw new TypeError(rl(e,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if(t.type!=="secret")throw new TypeError(`${Fr(t)} instances for symmetric algorithms must be of type "secret"`)}},Ph=(e,t,n)=>{if(da(t))switch(n){case"decrypt":case"sign":if(Eh(t)&&js(e,t,n))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"encrypt":case"verify":if(_h(t)&&js(e,t,n))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!sl(t))throw new TypeError(rl(e,t,"CryptoKey","KeyObject","JSON Web Key"));if(t.type==="secret")throw new TypeError(`${Fr(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.type==="public")switch(n){case"sign":throw new TypeError(`${Fr(t)} instances for asymmetric algorithm signing must be of type "private"`);case"decrypt":throw new TypeError(`${Fr(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if(t.type==="private")switch(n){case"verify":throw new TypeError(`${Fr(t)} instances for asymmetric algorithm verifying must be of type "public"`);case"encrypt":throw new TypeError(`${Fr(t)} instances for asymmetric algorithm encryption must be of type "public"`)}},Fh=(e,t,n)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(e)||/^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(e)?Rh(e,t,n):Ph(e,t,n)},Dh=(e,t)=>{const n=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:n,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:n,name:"RSA-PSS",saltLength:parseInt(e.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:n,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:n,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};default:throw new dr(`alg ${e} is not supported either by JOSE or your javascript runtime`)}},Mh=async(e,t,n)=>{if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError(vh(t,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[n])}return yh(t,e,n),t},kh=async(e,t,n,r)=>{const o=await Mh(e,t,"verify");Ih(e,o);const i=Dh(e,o.algorithm);try{return await crypto.subtle.verify(i,o,n,r)}catch{return!1}};async function Lh(e,t,n){if(!bo(e))throw new Xe("Flattened JWS must be an object");if(e.protected===void 0&&e.header===void 0)throw new Xe('Flattened JWS must have either of the "protected" or "header" members');if(e.protected!==void 0&&typeof e.protected!="string")throw new Xe("JWS Protected Header incorrect type");if(e.payload===void 0)throw new Xe("JWS Payload missing");if(typeof e.signature!="string")throw new Xe("JWS Signature missing or incorrect type");if(e.header!==void 0&&!bo(e.header))throw new Xe("JWS Unprotected Header incorrect type");let r={};if(e.protected)try{const h=fo(e.protected);r=JSON.parse(Oi.decode(h))}catch{throw new Xe("JWS Protected Header is invalid")}if(!wh(r,e.header))throw new Xe("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const o={...r,...e.header},i=xh(Xe,new Map([["b64",!0]]),n==null?void 0:n.crit,r,o);let s=!0;if(i.has("b64")&&(s=r.b64,typeof s!="boolean"))throw new Xe('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:a}=o;if(typeof a!="string"||!a)throw new Xe('JWS "alg" (Algorithm) Header Parameter missing or invalid');const c=n&&Oh("algorithms",n.algorithms);if(c&&!c.has(a))throw new el('"alg" (Algorithm) Header Parameter value not allowed');if(s){if(typeof e.payload!="string")throw new Xe("JWS Payload must be a string")}else if(typeof e.payload!="string"&&!(e.payload instanceof Uint8Array))throw new Xe("JWS Payload must be a string or an Uint8Array instance");let f=!1;typeof t=="function"&&(t=await t(r,e),f=!0),Fh(a,t,"verify");const d=ph(to.encode(e.protected??""),to.encode("."),typeof e.payload=="string"?to.encode(e.payload):e.payload);let l;try{l=fo(e.signature)}catch{throw new Xe("Failed to base64url decode the signature")}const m=await Ah(t,a);if(!await kh(a,m,l,d))throw new tl;let v;if(s)try{v=fo(e.payload)}catch{throw new Xe("Failed to base64url decode the payload")}else typeof e.payload=="string"?v=to.encode(e.payload):v=e.payload;const w={payload:v};return e.protected!==void 0&&(w.protectedHeader=r),e.header!==void 0&&(w.unprotectedHeader=e.header),f?{...w,key:m}:w}async function jh(e,t,n){if(e instanceof Uint8Array&&(e=Oi.decode(e)),typeof e!="string")throw new Xe("Compact JWS must be a string or Uint8Array");const{0:r,1:o,2:i,length:s}=e.split(".");if(s!==3)throw new Xe("Invalid Compact JWS");const a=await Lh({payload:o,protected:r,signature:i},t,n),c={payload:a.payload,protectedHeader:a.protectedHeader};return typeof t=="function"?{...c,key:a.key}:c}const Kh=e=>Math.floor(e.getTime()/1e3),al=60,cl=al*60,fa=cl*24,$h=fa*7,Uh=fa*365.25,qh=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,Oc=e=>{const t=qh.exec(e);if(!t||t[4]&&t[1])throw new TypeError("Invalid time period format");const n=parseFloat(t[2]),r=t[3].toLowerCase();let o;switch(r){case"sec":case"secs":case"second":case"seconds":case"s":o=Math.round(n);break;case"minute":case"minutes":case"min":case"mins":case"m":o=Math.round(n*al);break;case"hour":case"hours":case"hr":case"hrs":case"h":o=Math.round(n*cl);break;case"day":case"days":case"d":o=Math.round(n*fa);break;case"week":case"weeks":case"w":o=Math.round(n*$h);break;default:o=Math.round(n*Uh);break}return t[1]==="-"||t[4]==="ago"?-o:o},Ec=e=>e.includes("/")?e.toLowerCase():`application/${e.toLowerCase()}`,Vh=(e,t)=>typeof e=="string"?t.includes(e):Array.isArray(e)?t.some(Set.prototype.has.bind(new Set(e))):!1;function Hh(e,t,n={}){let r;try{r=JSON.parse(Oi.decode(t))}catch{}if(!bo(r))throw new la("JWT Claims Set must be a top-level JSON object");const{typ:o}=n;if(o&&(typeof e.typ!="string"||Ec(e.typ)!==Ec(o)))throw new zt('unexpected "typ" JWT header value',r,"typ","check_failed");const{requiredClaims:i=[],issuer:s,subject:a,audience:c,maxTokenAge:f}=n,d=[...i];f!==void 0&&d.push("iat"),c!==void 0&&d.push("aud"),a!==void 0&&d.push("sub"),s!==void 0&&d.push("iss");for(const v of new Set(d.reverse()))if(!(v in r))throw new zt(`missing required "${v}" claim`,r,v,"missing");if(s&&!(Array.isArray(s)?s:[s]).includes(r.iss))throw new zt('unexpected "iss" claim value',r,"iss","check_failed");if(a&&r.sub!==a)throw new zt('unexpected "sub" claim value',r,"sub","check_failed");if(c&&!Vh(r.aud,typeof c=="string"?[c]:c))throw new zt('unexpected "aud" claim value',r,"aud","check_failed");let l;switch(typeof n.clockTolerance){case"string":l=Oc(n.clockTolerance);break;case"number":l=n.clockTolerance;break;case"undefined":l=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:m}=n,g=Kh(m||new Date);if((r.iat!==void 0||f)&&typeof r.iat!="number")throw new zt('"iat" claim must be a number',r,"iat","invalid");if(r.nbf!==void 0){if(typeof r.nbf!="number")throw new zt('"nbf" claim must be a number',r,"nbf","invalid");if(r.nbf>g+l)throw new zt('"nbf" claim timestamp check failed',r,"nbf","check_failed")}if(r.exp!==void 0){if(typeof r.exp!="number")throw new zt('"exp" claim must be a number',r,"exp","invalid");if(r.exp<=g-l)throw new Ls('"exp" claim timestamp check failed',r,"exp","check_failed")}if(f){const v=g-r.iat,w=typeof f=="number"?f:Oc(f);if(v-l>w)throw new Ls('"iat" claim timestamp check failed (too far in the past)',r,"iat","check_failed");if(v<0-l)throw new zt('"iat" claim timestamp check failed (it should be in the past)',r,"iat","check_failed")}return r}async function Bh(e,t,n){var s;const r=await jh(e,t,n);if((s=r.protectedHeader.crit)!=null&&s.includes("b64")&&r.protectedHeader.b64===!1)throw new la("JWTs MUST NOT use unencoded payload");const i={payload:Hh(r.protectedHeader,r.payload,n),protectedHeader:r.protectedHeader};return typeof t=="function"?{...i,key:r.key}:i}const Ks="amp-labs_jwt_",Jh=10*60*1e3,_c=(e,t)=>`${e}:${t}`,Nc=e=>`${Ks}${e}`,ul=b.createContext(null),Wh=async e=>{try{const n=(await Bh(e,new Uint8Array(0),{algorithms:[]})).payload;return n.exp&&typeof n.exp=="number"?n.exp*1e3:null}catch(t){return console.warn("Failed to decode JWT token:",t),null}};function zh({getTokenCallback:e,children:t}){const[n,r]=b.useState(new Map);b.useEffect(()=>{try{const c=new Map,f=Date.now();Object.keys(sessionStorage).forEach(d=>{if(d.startsWith(Ks)){const l=d.replace(Ks,""),m=sessionStorage.getItem(d);if(m)try{const g=JSON.parse(m);g.expiresAt>f?c.set(l,g):sessionStorage.removeItem(d)}catch{sessionStorage.removeItem(d)}}}),c.size>0&&r(c)}catch{console.warn("Failed to load JWT tokens from sessionStorage")}},[]);const o=b.useCallback((c,f)=>{const d=_c(c,f),l=Date.now(),m=n.get(d);if(m&&m.expiresAt>l)return m.token;n.delete(d);const g=Nc(d),v=sessionStorage.getItem(g);if(v)try{const w=JSON.parse(v);if(w.expiresAt>l)return r(h=>new Map(h).set(d,w)),w.token;sessionStorage.removeItem(g)}catch{sessionStorage.removeItem(g)}return null},[n]),i=b.useCallback(async(c,f,d)=>{const l=_c(c,f),g=await Wh(d)||Date.now()+Jh,v={token:d,expiresAt:g};r(w=>new Map(w).set(l,v));try{sessionStorage.setItem(Nc(l),JSON.stringify(v))}catch{console.warn("Failed to store JWT token in sessionStorage")}},[]),s=b.useCallback(async({consumerRef:c,groupRef:f})=>{const d=o(c,f);if(d)return d;if(!e)throw new Error("JWT token callback not provided");try{const l=await e({consumerRef:c,groupRef:f});return await i(c,f,l),l}catch(l){throw console.error("Failed to get JWT token:",l),new Error("Failed to get JWT token")}},[e,o,i]),a={getToken:e?s:void 0};return u.jsx(ul.Provider,{value:a,children:t})}const Gh=()=>{const e=b.useContext(ul);if(!e)throw new Error("useJwtToken must be used within a JwtTokenProvider");return e},pa=b.createContext(null);function Pe(){const e=b.useContext(pa);if(!e)throw new Error(`Cannot call useAmpersandProvider unless your
|
|
2
|
+
component is wrapped with AmpersandProvider`);return e}const Qh=new Wp;function Xh(e){const{options:{apiKey:t,projectId:n,project:r,getToken:o},children:i}=e,s=r||n;if(n&&r)throw new Error("Use AmpersandProvider either with projectId or project but not both.");if(!s)throw new Error("Cannot use AmpersandProvider without a projectId or name.");if(!t&&!o)throw new Error("Cannot use AmpersandProvider without an apiKey or getToken.");if(t&&o)throw new Error("Cannot use AmpersandProvider with both apiKey and getToken.");const a={options:e.options,projectIdOrName:s};return u.jsx(Yp,{client:Qh,children:u.jsx(pa.Provider,{value:a,children:u.jsx(fh,{children:u.jsx(zh,{getTokenCallback:o||null,children:u.jsx(lh,{value:t||null,children:i})})})})})}const Yh="https://api.withampersand.com/v1".replace(/\/+$/,"");class ha{constructor(t={}){this.configuration=t}set config(t){this.configuration=t}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:Yh}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||dl}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 Zh=new ha,Mo=class Mo{constructor(t=Zh){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 nm(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?Mo.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 ll(i,"Response returned an error code")}async createFetchParams(t,n){let r=this.configuration.basePath+t.path;t.query!==void 0&&Object.keys(t.query).length!==0&&(r+="?"+this.configuration.queryParamsStringify(t.query));const o=Object.assign({},this.configuration.headers,t.headers);Object.keys(o).forEach(f=>o[f]===void 0?delete o[f]:{});const i=typeof n=="function"?n:async()=>n,s={method:t.method,headers:o,body:t.body,credentials:this.configuration.credentials},a={...s,...await i({init:s,context:t})},c={...a,body:tm(a.body)||a.body instanceof URLSearchParams||em(a.body)?a.body:JSON.stringify(a.body)};return{url:r,init:c}}clone(){const t=this.constructor,n=new t(this.configuration);return n.middleware=this.middleware.slice(),n}};Mo.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let cn=Mo;function em(e){return typeof Blob<"u"&&e instanceof Blob}function tm(e){return typeof FormData<"u"&&e instanceof FormData}class ll extends Error{constructor(t,n){super(n),this.response=t,this.name="ResponseError"}}class nm extends Error{constructor(t,n){super(n),this.cause=t,this.name="FetchError"}}class ne extends Error{constructor(t,n){super(n),this.field=t,this.name="RequiredError"}}function _(e,t){const n=e[t];return n!=null}function dl(e,t=""){return Object.keys(e).map(n=>fl(n,e[n],t)).filter(n=>n.length>0).join("&")}function fl(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 fl(e,o,n)}return t instanceof Date?`${encodeURIComponent(r)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?dl(t,r):`${encodeURIComponent(r)}=${encodeURIComponent(String(t))}`}function Ve(e,t){return Object.keys(e).reduce((n,r)=>({...n,[r]:t(e[r])}),{})}class Re{constructor(t,n=r=>r){this.raw=t,this.transformer=n}async value(){return this.transformer(await this.raw.json())}}class Qr{constructor(t){this.raw=t}async value(){}}class Tc{constructor(t){this.raw=t}async value(){return await this.raw.text()}}function rm(e){return im(e)}function im(e,t){return e==null?e:{fieldUsed:_(e,"fieldUsed")?e.fieldUsed:void 0,keyFormat:_(e,"keyFormat")?e.keyFormat:void 0}}function om(e){return sm(e)}function sm(e,t){return e==null?e:{name:e.name,valuePrefix:_(e,"valuePrefix")?e.valuePrefix:void 0}}function am(e){return cm(e)}function cm(e,t){return e==null?e:{name:e.name}}function um(e){return lm(e)}function lm(e,t){return e==null?e:{attachmentType:e.attachmentType,query:_(e,"query")?am(e.query):void 0,header:_(e,"header")?om(e.header):void 0,docsURL:_(e,"docsURL")?e.docsURL:void 0}}function dm(e){return fm(e)}function fm(e,t){return e==null?e:{enabled:_(e,"enabled")?e.enabled:void 0,includeFullRecords:_(e,"includeFullRecords")?e.includeFullRecords:void 0}}function pm(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,includeFullRecords:e.includeFullRecords}}function hm(e){return mm(e)}function mm(e,t){return e==null?e:{url:e.url,method:_(e,"method")?e.method:void 0,successStatusCodes:_(e,"successStatusCodes")?e.successStatusCodes:void 0}}const Ac={ApiKey:"apiKey",Basic:"basic"};function gm(e){return ym(e)}function ym(e,t){return e}function vm(e){return wm(e)}function wm(e,t){return e==null?e:{days:_(e,"days")?e.days:void 0,fullHistory:_(e,"fullHistory")?e.fullHistory:void 0}}function bm(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function pl(e){return Im(e)}function Im(e,t){return e==null?e:{defaultPeriod:vm(e.defaultPeriod)}}function Cm(e){if(e!==void 0)return e===null?null:{defaultPeriod:bm(e.defaultPeriod)}}function Sm(e){return xm(e)}function xm(e,t){return e==null?e:{days:_(e,"days")?e.days:void 0,fullHistory:_(e,"fullHistory")?e.fullHistory:void 0}}function Om(e){if(e!==void 0)return e===null?null:{days:e.days,fullHistory:e.fullHistory}}function Em(e){return _m(e)}function _m(e,t){return e==null?e:{defaultPeriod:Sm(e.defaultPeriod)}}function hl(e){if(e!==void 0)return e===null?null:{defaultPeriod:Om(e.defaultPeriod)}}function Nm(e){return Tm(e)}function Tm(e,t){return e==null?e:{enabled:_(e,"enabled")?e.enabled:void 0,useModule:_(e,"useModule")?e.useModule:void 0}}function ml(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,useModule:e.useModule}}function Am(e){return Rm(e)}function Rm(e,t){return e}function Pm(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:hl(e.backfill)}}function Fm(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Ve(e.objects,Pm)}}function Dm(e){return Mm(e)}function Mm(e,t){return e==null?e:{stringValue:_(e,"stringValue")?e.stringValue:void 0,integerValue:_(e,"integerValue")?e.integerValue:void 0,booleanValue:_(e,"booleanValue")?e.booleanValue:void 0}}function km(e){if(e!==void 0)return e===null?null:{stringValue:e.stringValue,integerValue:e.integerValue,booleanValue:e.booleanValue}}const Lm={Always:"always",Never:"never"},jm={Always:"always",Never:"never"};function Km(e){return $m(e)}function $m(e,t){return e==null?e:{default:_(e,"default")?Dm(e.default):void 0,writeOnCreate:_(e,"writeOnCreate")?e.writeOnCreate:void 0,writeOnUpdate:_(e,"writeOnUpdate")?e.writeOnUpdate:void 0}}function gl(e){if(e!==void 0)return e===null?null:{default:km(e.default),writeOnCreate:e.writeOnCreate,writeOnUpdate:e.writeOnUpdate}}function Um(e){let t=!0;return t=t&&"value"in e,t}function qm(e,t){return e==null?e:{value:e.value,applyOnUpdate:_(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function Vm(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function Hm(e){let t=!0;return t=t&&"value"in e,t}function Bm(e,t){return e==null?e:{value:e.value,applyOnUpdate:_(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function Jm(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function Wm(e){let t=!0;return t=t&&"value"in e,t}function zm(e,t){return e==null?e:{value:e.value,applyOnUpdate:_(e,"applyOnUpdate")?e.applyOnUpdate:void 0}}function Gm(e){if(e!==void 0)return e===null?null:{value:e.value,applyOnUpdate:e.applyOnUpdate}}function Qm(e){return Xm(e)}function Xm(e,t){return e==null?e:{...qm(e),...Bm(e),...zm(e)}}function yl(e){if(e!==void 0)return e===null?null:Um(e)?Vm(e):Hm(e)?Jm(e):Wm(e)?Gm(e):{}}function Ym(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,selectedValueDefaults:e.selectedValueDefaults===void 0?void 0:Ve(e.selectedValueDefaults,yl),selectedFieldSettings:e.selectedFieldSettings===void 0?void 0:Ve(e.selectedFieldSettings,gl)}}function Zm(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Ve(e.objects,Ym)}}function eg(e){return tg(e)}function tg(e,t){return e==null?e:{enabled:e.enabled}}function ng(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function rg(e){return ig(e)}function ig(e,t){return e==null?e:{enabled:e.enabled}}function og(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function sg(e){return ag(e)}function ag(e,t){return e==null?e:{enabled:e.enabled,watchFieldsAuto:_(e,"watchFieldsAuto")?e.watchFieldsAuto:void 0,requiredWatchFields:_(e,"requiredWatchFields")?e.requiredWatchFields:void 0}}function cg(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,watchFieldsAuto:e.watchFieldsAuto,requiredWatchFields:e.requiredWatchFields}}function ug(e){return lg(e)}function lg(e,t){return e==null?e:{apiKeyAsBasic:_(e,"apiKeyAsBasic")?e.apiKeyAsBasic:void 0,apiKeyAsBasicOpts:_(e,"apiKeyAsBasicOpts")?rm(e.apiKeyAsBasicOpts):void 0,docsURL:_(e,"docsURL")?e.docsURL:void 0}}function dg(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function fg(e){return pg(e)}function pg(e,t){return e==null?e:{value:e.value}}function hg(e){return mg(e)}function mg(e,t){return e==null?e:{brandingRemoval:_(e,"brandingRemoval")?fg(e.brandingRemoval):void 0}}function no(e){return gg(e)}function gg(e,t){return e==null?e:{id:e.id,name:e.name,appName:e.appName,orgId:_(e,"orgId")?e.orgId:void 0,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0,entitlements:_(e,"entitlements")?hg(e.entitlements):void 0}}function yg(e){return vg(e)}function vg(e,t){return e==null?e:{insert:e.insert,update:e.update,upsert:e.upsert,_delete:e.delete}}function wg(e){return bg(e)}function bg(e,t){return e==null?e:{objectName:e.objectName,schedule:_(e,"schedule")?e.schedule:void 0,destination:_(e,"destination")?e.destination:void 0,selectedFields:e.selectedFields,selectedValueMappings:_(e,"selectedValueMappings")?e.selectedValueMappings:void 0,selectedFieldMappings:e.selectedFieldMappings,selectedFieldsAuto:_(e,"selectedFieldsAuto")?Am(e.selectedFieldsAuto):void 0,backfill:_(e,"backfill")?Em(e.backfill):void 0}}function Ig(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:hl(e.backfill)}}function Cg(e){return Sg(e)}function Sg(e,t){return e==null?e:{objects:Ve(e.objects,wg)}}function xg(e){if(e!==void 0)return e===null?null:{objects:Ve(e.objects,Ig)}}function Og(e){return Eg(e)}function Eg(e,t){return e==null?e:{inheritFieldsAndMappings:e.inheritFieldsAndMappings,objectName:e.objectName,destination:e.destination,createEvent:_(e,"createEvent")?eg(e.createEvent):void 0,updateEvent:_(e,"updateEvent")?sg(e.updateEvent):void 0,deleteEvent:_(e,"deleteEvent")?rg(e.deleteEvent):void 0}}function _g(e){if(e!==void 0)return e===null?null:{inheritFieldsAndMappings:e.inheritFieldsAndMappings,objectName:e.objectName,destination:e.destination,createEvent:ng(e.createEvent),updateEvent:cg(e.updateEvent),deleteEvent:og(e.deleteEvent)}}function Ng(e){return Tg(e)}function Tg(e,t){return e==null?e:{objects:Ve(e.objects,Og)}}function Ag(e){if(e!==void 0)return e===null?null:{objects:Ve(e.objects,_g)}}function Rg(e){return Pg(e)}function Pg(e,t){return e==null?e:{objectName:e.objectName,selectedValueDefaults:_(e,"selectedValueDefaults")?Ve(e.selectedValueDefaults,Qm):void 0,selectedFieldSettings:_(e,"selectedFieldSettings")?Ve(e.selectedFieldSettings,Km):void 0}}function Fg(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,selectedValueDefaults:e.selectedValueDefaults===void 0?void 0:Ve(e.selectedValueDefaults,yl),selectedFieldSettings:e.selectedFieldSettings===void 0?void 0:Ve(e.selectedFieldSettings,gl)}}function Dg(e){return Mg(e)}function Mg(e,t){return e==null?e:{objects:_(e,"objects")?Ve(e.objects,Rg):void 0}}function kg(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:Ve(e.objects,Fg)}}function Lg(e){return jg(e)}function jg(e,t){return e==null?e:{provider:e.provider,module:_(e,"module")?e.module:void 0,read:_(e,"read")?Cg(e.read):void 0,write:_(e,"write")?Dg(e.write):void 0,proxy:_(e,"proxy")?Nm(e.proxy):void 0,subscribe:_(e,"subscribe")?Ng(e.subscribe):void 0}}function Kg(e){if(e!==void 0)return e===null?null:{provider:e.provider,module:e.module,read:xg(e.read),write:kg(e.write),proxy:ml(e.proxy),subscribe:Ag(e.subscribe)}}function $g(e){return Ug(e)}function Ug(e,t){return e==null?e:{id:e.id,revisionId:e.revisionId,createTime:new Date(e.createTime),createdBy:e.createdBy,content:Lg(e.content)}}function qg(e){return Vg(e)}function Vg(e,t){return e==null?e:{consumerRef:e.consumerRef,consumerName:e.consumerName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0}}function vl(e){return Hg(e)}function Hg(e,t){return e==null?e:{groupRef:e.groupRef,groupName:e.groupName,projectId:e.projectId,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0}}function Bg(e){return Jg(e)}function Jg(e,t){return e==null?e:{token:e.token,issuedAt:_(e,"issuedAt")?new Date(e.issuedAt):void 0,expiresAt:_(e,"expiresAt")?new Date(e.expiresAt):void 0}}function Wg(e){return zg(e)}function zg(e,t){return e==null?e:{token:e.token,issuedAt:_(e,"issuedAt")?new Date(e.issuedAt):void 0,expiresAt:_(e,"expiresAt")?new Date(e.expiresAt):void 0}}function Gg(e){return Qg(e)}function Qg(e,t){return e==null?e:{accessToken:_(e,"accessToken")?Bg(e.accessToken):void 0,refreshToken:_(e,"refreshToken")?Wg(e.refreshToken):void 0,scopes:_(e,"scopes")?e.scopes:void 0}}function po(e){return Xg(e)}function Xg(e,t){return e==null?e:{id:e.id,projectId:e.projectId,externalRef:_(e,"externalRef")?e.externalRef:void 0,provider:e.provider,clientId:e.clientId,scopes:_(e,"scopes")?e.scopes:void 0,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0}}function Yg(e){return Zg(e)}function Zg(e,t){return e==null?e:{value:e.value,source:e.source,displayName:_(e,"displayName")?e.displayName:void 0}}function ma(e){if(e!==void 0)return e===null?null:{value:e.value,source:e.source,displayName:e.displayName}}function bi(e){return ey(e)}function ey(e,t){return e==null?e:{id:e.id,projectId:e.projectId,provider:e.provider,providerApp:_(e,"providerApp")?po(e.providerApp):void 0,group:vl(e.group),consumer:qg(e.consumer),providerWorkspaceRef:_(e,"providerWorkspaceRef")?e.providerWorkspaceRef:void 0,providerConsumerRef:_(e,"providerConsumerRef")?e.providerConsumerRef:void 0,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0,authScheme:e.authScheme,status:e.status,oauth2AuthorizationCode:_(e,"oauth2AuthorizationCode")?Gg(e.oauth2AuthorizationCode):void 0,apiKey:_(e,"apiKey")?e.apiKey:void 0,providerMetadata:_(e,"providerMetadata")?Ve(e.providerMetadata,Yg):void 0}}function wl(e){if(e!==void 0)return e===null?null:{username:e.username,password:e.password}}function bl(e){if(e!==void 0)return e===null?null:{clientId:e.clientId,clientSecret:e.clientSecret,scopes:e.scopes}}function Il(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 ty(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 ny(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:ty(e.accessToken),refreshToken:ny(e.refreshToken),scopes:e.scopes}}function ry(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:Ve(e.providerMetadata,ma),groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,customAuth:e.customAuth,basicAuth:wl(e.basicAuth),oauth2ClientCredentials:bl(e.oauth2ClientCredentials),oauth2PasswordCredentials:Il(e.oauth2PasswordCredentials),oauth2AuthorizationCode:Cl(e.oauth2AuthorizationCode)}}function iy(e){return oy(e)}function oy(e,t){return e==null?e:{enabled:_(e,"enabled")?e.enabled:void 0}}function sy(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function ay(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:Kg(e.content)}}function cy(e){if(e!==void 0)return e===null?null:{groupRef:e.groupRef,connectionId:e.connectionId,config:ay(e.config)}}function uy(e){return ly(e)}function ly(e,t){return e==null?e:{enabled:_(e,"enabled")?e.enabled:void 0,useModule:_(e,"useModule")?e.useModule:void 0}}function dy(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,useModule:e.useModule}}function fy(e){return py(e)}function py(e,t){return e==null?e:{mode:_(e,"mode")?e.mode:void 0,pageSize:_(e,"pageSize")?e.pageSize:void 0}}function hy(e){if(e!==void 0)return e===null?null:{mode:e.mode,pageSize:e.pageSize}}function my(e){let t=!0;return t=t&&"fieldName"in e,t}function gy(e,t){return e==null?e:{fieldName:e.fieldName,mapToName:_(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:_(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function yy(e){if(e!==void 0)return e===null?null:{fieldName:e.fieldName,mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName}}function vy(e){let t=!0;return t=t&&"mapToName"in e,t}function Sl(e,t){return e==null?e:{mapToName:e.mapToName,mapToDisplayName:_(e,"mapToDisplayName")?e.mapToDisplayName:void 0,_default:_(e,"default")?e.default:void 0,prompt:_(e,"prompt")?e.prompt:void 0}}function wy(e){if(e!==void 0)return e===null?null:{mapToName:e.mapToName,mapToDisplayName:e.mapToDisplayName,default:e._default,prompt:e.prompt}}function Rc(e){return by(e)}function by(e,t){return e==null?e:{...gy(e),...Sl(e)}}function Pc(e){if(e!==void 0)return e===null?null:my(e)?yy(e):vy(e)?wy(e):{}}function xl(e){return Iy(e)}function Iy(e,t){return e}function Cy(e){return Sy(e)}function Sy(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,schedule:e.schedule,mapToName:_(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:_(e,"mapToDisplayName")?e.mapToDisplayName:void 0,requiredFields:_(e,"requiredFields")?e.requiredFields.map(Rc):void 0,optionalFields:_(e,"optionalFields")?e.optionalFields.map(Rc):void 0,optionalFieldsAuto:_(e,"optionalFieldsAuto")?xl(e.optionalFieldsAuto):void 0,backfill:_(e,"backfill")?pl(e.backfill):void 0,delivery:_(e,"delivery")?fy(e.delivery):void 0,enabled:_(e,"enabled")?e.enabled:void 0}}function xy(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(Pc),optionalFields:e.optionalFields===void 0?void 0:e.optionalFields.map(Pc),optionalFieldsAuto:e.optionalFieldsAuto,backfill:Cm(e.backfill),delivery:hy(e.delivery),enabled:e.enabled}}function Oy(e){return Ey(e)}function Ey(e,t){return e==null?e:{objects:_(e,"objects")?e.objects.map(Cy):void 0}}function _y(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(xy)}}function Ny(e){return Ty(e)}function Ty(e,t){return e==null?e:{enabled:_(e,"enabled")?e.enabled:void 0}}function Ay(e){if(e!==void 0)return e===null?null:{enabled:e.enabled}}function Ry(e){return Py(e)}function Py(e,t){return e==null?e:{enabled:_(e,"enabled")?e.enabled:void 0,watchFieldsAuto:_(e,"watchFieldsAuto")?e.watchFieldsAuto:void 0,requiredWatchFields:_(e,"requiredWatchFields")?e.requiredWatchFields:void 0}}function Fy(e){if(e!==void 0)return e===null?null:{enabled:e.enabled,watchFieldsAuto:e.watchFieldsAuto,requiredWatchFields:e.requiredWatchFields}}function Dy(e){return My(e)}function My(e,t){return e==null?e:{objectName:e.objectName,destination:e.destination,inheritFieldsAndMapping:_(e,"inheritFieldsAndMapping")?e.inheritFieldsAndMapping:void 0,createEvent:_(e,"createEvent")?iy(e.createEvent):void 0,updateEvent:_(e,"updateEvent")?Ry(e.updateEvent):void 0,deleteEvent:_(e,"deleteEvent")?Ny(e.deleteEvent):void 0,associationChangeEvent:_(e,"associationChangeEvent")?dm(e.associationChangeEvent):void 0,otherEvents:_(e,"otherEvents")?e.otherEvents:void 0}}function ky(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,destination:e.destination,inheritFieldsAndMapping:e.inheritFieldsAndMapping,createEvent:sy(e.createEvent),updateEvent:Fy(e.updateEvent),deleteEvent:Ay(e.deleteEvent),associationChangeEvent:pm(e.associationChangeEvent),otherEvents:e.otherEvents}}function Ly(e){return jy(e)}function jy(e,t){return e==null?e:{objects:_(e,"objects")?e.objects.map(Dy):void 0}}function Ky(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(ky)}}function Ol(e){return $y(e)}function $y(e,t){return e==null?e:{allowAnyFields:_(e,"allowAnyFields")?e.allowAnyFields:void 0}}function Uy(e){if(e!==void 0)return e===null?null:{allowAnyFields:e.allowAnyFields}}function qy(e){return Vy(e)}function Vy(e,t){return e==null?e:{objectName:e.objectName,inheritMapping:_(e,"inheritMapping")?e.inheritMapping:void 0,valueDefaults:_(e,"valueDefaults")?Ol(e.valueDefaults):void 0}}function Hy(e){if(e!==void 0)return e===null?null:{objectName:e.objectName,inheritMapping:e.inheritMapping,valueDefaults:Uy(e.valueDefaults)}}function By(e){return Jy(e)}function Jy(e,t){return e==null?e:{objects:_(e,"objects")?e.objects.map(qy):void 0}}function Wy(e){if(e!==void 0)return e===null?null:{objects:e.objects===void 0?void 0:e.objects.map(Hy)}}function zy(e){return Gy(e)}function Gy(e,t){return e==null?e:{name:e.name,provider:e.provider,displayName:_(e,"displayName")?e.displayName:void 0,module:_(e,"module")?e.module:void 0,read:_(e,"read")?Oy(e.read):void 0,write:_(e,"write")?By(e.write):void 0,proxy:_(e,"proxy")?uy(e.proxy):void 0,subscribe:_(e,"subscribe")?Ly(e.subscribe):void 0}}function Qy(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,displayName:e.displayName,module:e.module,read:_y(e.read),write:Wy(e.write),proxy:dy(e.proxy),subscribe:Ky(e.subscribe)}}function Xy(e){if(e!==void 0)return e===null?null:{specVersion:e.specVersion,content:Qy(e.content)}}function Yy(e){if(e!==void 0)return e===null?null:{name:e.name,provider:e.provider,latestRevision:Xy(e.latestRevision)}}function Zy(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name,orgId:e.orgId}}function ev(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 tv(e){if(e!==void 0)return e===null?null:{sourceZipUrl:e.sourceZipUrl,sourceYaml:e.sourceYaml}}function nv(e){return rv(e)}function rv(e,t){return e==null?e:{name:e.name,valueTemplate:e.valueTemplate}}function iv(e){return ov(e)}function ov(e,t){return e==null?e:{name:e.name,displayName:e.displayName,prompt:_(e,"prompt")?e.prompt:void 0,docsURL:_(e,"docsURL")?e.docsURL:void 0}}function sv(e){return av(e)}function av(e,t){return e==null?e:{name:e.name,valueTemplate:e.valueTemplate}}function cv(e){return uv(e)}function uv(e,t){return e==null?e:{headers:_(e,"headers")?e.headers.map(nv):void 0,queryParams:_(e,"queryParams")?e.queryParams.map(sv):void 0,inputs:_(e,"inputs")?e.inputs.map(iv):void 0}}function lv(e){return dv(e)}function dv(e,t){return e==null?e:{value:e.value,displayValue:e.displayValue}}function fv(e){return pv(e)}function pv(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,valueType:_(e,"valueType")?e.valueType:void 0,providerType:_(e,"providerType")?e.providerType:void 0,readOnly:_(e,"readOnly")?e.readOnly:void 0,values:_(e,"values")?e.values.map(lv):void 0}}function hv(e){if(e!==void 0)return e===null?null:{providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:Ve(e.providerMetadata,ma),groupName:e.groupName,groupRef:e.groupRef,consumerName:e.consumerName,consumerRef:e.consumerRef,provider:e.provider,apiKey:e.apiKey,customAuth:e.customAuth,basicAuth:wl(e.basicAuth),oauth2ClientCredentials:bl(e.oauth2ClientCredentials),oauth2PasswordCredentials:Il(e.oauth2PasswordCredentials),oauth2AuthorizationCode:Cl(e.oauth2AuthorizationCode)}}function mv(e){return gv(e)}function gv(e,t){return e==null?e:{enabled:_(e,"enabled")?e.enabled:void 0,useModule:_(e,"useModule")?e.useModule:void 0}}function yv(e,t){return e==null?e:{fieldName:e.fieldName,displayName:e.displayName,mapToName:_(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:_(e,"mapToDisplayName")?e.mapToDisplayName:void 0}}function is(e){return vv(e)}function vv(e,t){return e==null?e:{...yv(e),...Sl(e)}}function wv(e){return bv(e)}function bv(e,t){return e==null?e:{error:_(e,"error")?e.error:void 0,objectName:e.objectName,displayName:e.displayName,mapToName:_(e,"mapToName")?e.mapToName:void 0,mapToDisplayName:_(e,"mapToDisplayName")?e.mapToDisplayName:void 0,destination:e.destination,schedule:e.schedule,requiredFields:_(e,"requiredFields")?e.requiredFields.map(is):void 0,optionalFields:_(e,"optionalFields")?e.optionalFields.map(is):void 0,optionalFieldsAuto:_(e,"optionalFieldsAuto")?xl(e.optionalFieldsAuto):void 0,allFieldsMetadata:_(e,"allFieldsMetadata")?Ve(e.allFieldsMetadata,fv):void 0,allFields:_(e,"allFields")?e.allFields.map(is):void 0,backfill:_(e,"backfill")?pl(e.backfill):void 0}}function Iv(e){return Cv(e)}function Cv(e,t){return e==null?e:{objects:_(e,"objects")?e.objects.map(wv):void 0}}function Sv(e){return xv(e)}function xv(e,t){return e==null?e:{objectName:e.objectName,displayName:e.displayName,valueDefaults:_(e,"valueDefaults")?Ol(e.valueDefaults):void 0}}function Ov(e){return Ev(e)}function Ev(e,t){return e==null?e:{objects:_(e,"objects")?e.objects.map(Sv):void 0}}function _v(e){return Nv(e)}function Nv(e,t){return e==null?e:{name:e.name,displayName:_(e,"displayName")?e.displayName:void 0,module:_(e,"module")?e.module:void 0,provider:e.provider,read:_(e,"read")?Iv(e.read):void 0,write:_(e,"write")?Ov(e.write):void 0,proxy:_(e,"proxy")?mv(e.proxy):void 0}}function Tv(e){return Av(e)}function Av(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:_v(e.content)}}function yi(e){return Rv(e)}function Rv(e,t){return e==null?e:{id:e.id,projectId:e.projectId,integrationId:e.integrationId,group:_(e,"group")?vl(e.group):void 0,healthStatus:e.healthStatus,connection:bi(e.connection),createTime:new Date(e.createTime),createdBy:e.createdBy,updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0,config:$g(e.config)}}function Pv(e){return Fv(e)}function Fv(e,t){return e==null?e:{id:e.id,specVersion:e.specVersion,createTime:new Date(e.createTime),content:zy(e.content)}}function os(e){return Dv(e)}function Dv(e,t){return e==null?e:{id:e.id,projectId:e.projectId,name:e.name,provider:e.provider,createTime:new Date(e.createTime),updateTime:_(e,"updateTime")?new Date(e.updateTime):void 0,latestRevision:Pv(e.latestRevision)}}function Mv(e){return kv(e)}function kv(e,t){return e==null?e:{iconURL:_(e,"iconURL")?e.iconURL:void 0,logoURL:_(e,"logoURL")?e.logoURL:void 0}}function Lv(e){return jv(e)}function jv(e,t){return e==null?e:{iconURL:_(e,"iconURL")?e.iconURL:void 0,logoURL:_(e,"logoURL")?e.logoURL:void 0}}function Kv(e){return $v(e)}function $v(e,t){return e==null?e:{regular:_(e,"regular")?Lv(e.regular):void 0,darkMode:_(e,"darkMode")?Mv(e.darkMode):void 0}}function Uv(e){return qv(e)}function qv(e,t){return e==null?e:{name:e.name,displayName:_(e,"displayName")?e.displayName:void 0,defaultValue:_(e,"defaultValue")?e.defaultValue:void 0,docsURL:_(e,"docsURL")?e.docsURL:void 0,moduleDependencies:_(e,"moduleDependencies")?e.moduleDependencies:void 0}}function Vv(e){return Hv(e)}function Hv(e,t){return e==null?e:{name:e.name,moduleDependencies:_(e,"moduleDependencies")?e.moduleDependencies:void 0}}function Bv(e){return Jv(e)}function Jv(e,t){return e==null?e:{create:_(e,"create")?e.create:void 0,update:_(e,"update")?e.update:void 0,_delete:_(e,"delete")?e.delete:void 0,passThrough:_(e,"passThrough")?e.passThrough:void 0}}function El(e){return Wv(e)}function Wv(e,t){return e==null?e:{bulkWrite:yg(e.bulkWrite),proxy:e.proxy,read:e.read,subscribe:e.subscribe,write:e.write,subscribeSupport:_(e,"subscribeSupport")?Bv(e.subscribeSupport):void 0}}function zv(e){return Gv(e)}function Gv(e,t){return e==null?e:{displayName:e.displayName,baseURL:e.baseURL,support:El(e.support)}}function Qv(e){return Xv(e)}function Xv(e,t){return e==null?e:{name:e.name,displayName:e.displayName,path:e.path,capture:_(e,"capture")?e.capture:void 0}}function Yv(e){return Zv(e)}function Zv(e,t){return e==null?e:{workspaceRefField:_(e,"workspaceRefField")?e.workspaceRefField:void 0,consumerRefField:_(e,"consumerRefField")?e.consumerRefField:void 0,scopesField:_(e,"scopesField")?e.scopesField:void 0,otherFields:_(e,"otherFields")?e.otherFields.map(Qv):void 0}}const ss={AuthorizationCode:"authorizationCode",AuthorizationCodePkce:"authorizationCodePKCE",ClientCredentials:"clientCredentials"};function ew(e){return tw(e)}function tw(e,t){return e==null?e:{grantType:e.grantType,authURL:_(e,"authURL")?e.authURL:void 0,tokenURL:e.tokenURL,explicitScopesRequired:e.explicitScopesRequired,explicitWorkspaceRequired:e.explicitWorkspaceRequired,audience:_(e,"audience")?e.audience:void 0,tokenMetadataFields:Yv(e.tokenMetadataFields),docsURL:_(e,"docsURL")?e.docsURL:void 0,authURLParams:_(e,"authURLParams")?e.authURLParams:void 0}}function nw(e){if(e!==void 0)return e===null?null:{projectId:e.projectId,provider:e.provider,groupRef:e.groupRef,groupName:e.groupName,consumerRef:e.consumerRef,consumerName:e.consumerName,providerWorkspaceRef:e.providerWorkspaceRef,providerMetadata:e.providerMetadata===void 0?void 0:Ve(e.providerMetadata,ma),providerAppId:e.providerAppId,enableCSRFProtection:e.enableCSRFProtection}}function rw(e){return iw(e)}function iw(e,t){return e==null?e:{input:_(e,"input")?e.input.map(Uv):void 0,postAuthentication:_(e,"postAuthentication")?e.postAuthentication.map(Vv):void 0}}function ow(e){return sw(e)}function sw(e,t){return e==null?e:{subscriptionScope:e.subscriptionScope,targetURLScope:e.targetURLScope,registrationTiming:e.registrationTiming}}function Fc(e){return aw(e)}function aw(e,t){return e==null?e:{name:e.name,authType:gm(e.authType),baseURL:e.baseURL,defaultModule:e.defaultModule,oauth2Opts:_(e,"oauth2Opts")?ew(e.oauth2Opts):void 0,apiKeyOpts:_(e,"apiKeyOpts")?um(e.apiKeyOpts):void 0,basicOpts:_(e,"basicOpts")?ug(e.basicOpts):void 0,customOpts:_(e,"customOpts")?cv(e.customOpts):void 0,support:El(e.support),providerOpts:e.providerOpts,authHealthCheck:_(e,"authHealthCheck")?hm(e.authHealthCheck):void 0,displayName:_(e,"displayName")?e.displayName:void 0,postAuthInfoNeeded:_(e,"postAuthInfoNeeded")?e.postAuthInfoNeeded:void 0,media:_(e,"media")?Kv(e.media):void 0,labels:_(e,"labels")?e.labels:void 0,subscribeOpts:_(e,"subscribeOpts")?ow(e.subscribeOpts):void 0,modules:_(e,"modules")?Ve(e.modules,zv):void 0,metadata:_(e,"metadata")?rw(e.metadata):void 0}}function cw(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,connection:ry(e.connection)}}function uw(e){if(e!==void 0)return e===null?null:{provider:e.provider,module:e.module,read:Fm(e.read),write:Zm(e.write),proxy:ml(e.proxy)}}function lw(e){if(e!==void 0)return e===null?null:{revisionId:e.revisionId,createdBy:e.createdBy,content:uw(e.content)}}function dw(e){if(e!==void 0)return e===null?null:{connectionId:e.connectionId,config:lw(e.config)}}function fw(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,installation:dw(e.installation)}}function pw(e){if(e!==void 0)return e===null?null:{appName:e.appName,name:e.name}}function hw(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,project:pw(e.project)}}function mw(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 gw(e){if(e!==void 0)return e===null?null:{updateMask:e.updateMask,providerApp:mw(e.providerApp)}}class yw extends cn{async deleteConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new ne("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling deleteConnection.");const r={},o={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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 Qr(i)}async deleteConnection(t,n){await this.deleteConnectionRaw(t,n)}async generateConnectionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling generateConnection.");const r={},o={};if(o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}const i=await this.request({path:"/projects/{projectIdOrName}/connections:generate".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:r,body:hv(t.generateConnectionParams)},n);return new Re(i,s=>bi(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 ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new ne("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={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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 Re(i,s=>bi(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 ne("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={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}const i=await this.request({path:"/projects/{projectIdOrName}/connections".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Re(i,s=>s.map(bi))}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 ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateConnection.");if(t.connectionId===null||t.connectionId===void 0)throw new ne("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling updateConnection.");if(t.updateConnectionRequest===null||t.updateConnectionRequest===void 0)throw new ne("updateConnectionRequest","Required parameter requestParameters.updateConnectionRequest was null or undefined when calling updateConnection.");const r={},o={};if(o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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:cw(t.updateConnectionRequest)},n);return new Re(i,s=>bi(s))}async updateConnection(t,n){return await(await this.updateConnectionRaw(t,n)).value()}}class vw extends cn{async createInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ne("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createInstallation.");if(t.installation===null||t.installation===void 0)throw new ne("installation","Required parameter requestParameters.installation was null or undefined when calling createInstallation.");const r={},o={};if(o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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:cy(t.installation)},n);return new Re(i,s=>yi(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 ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ne("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteInstallation.");if(t.installationId===null||t.installationId===void 0)throw new ne("installationId","Required parameter requestParameters.installationId was null or undefined when calling deleteInstallation.");const r={},o={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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 Qr(i)}async deleteInstallation(t,n){await this.deleteInstallationRaw(t,n)}async getInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ne("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getInstallation.");if(t.installationId===null||t.installationId===void 0)throw new ne("installationId","Required parameter requestParameters.installationId was null or undefined when calling getInstallation.");const r={},o={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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 Re(i,s=>yi(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 ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallations.");if(t.integrationId===null||t.integrationId===void 0)throw new ne("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling listInstallations.");const r={};t.groupRef!==void 0&&(r.groupRef=t.groupRef);const o={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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 Re(i,s=>s.map(yi))}async listInstallations(t,n){return await(await this.listInstallationsRaw(t,n)).value()}async listInstallationsForProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listInstallationsForProject.");const r={};t.groupRef!==void 0&&(r.groupRef=t.groupRef);const o={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}const i=await this.request({path:"/projects/{projectIdOrName}/installations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Re(i,s=>s.map(yi))}async listInstallationsForProject(t,n){return await(await this.listInstallationsForProjectRaw(t,n)).value()}async updateInstallationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateInstallation.");if(t.integrationId===null||t.integrationId===void 0)throw new ne("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling updateInstallation.");if(t.installationId===null||t.installationId===void 0)throw new ne("installationId","Required parameter requestParameters.installationId was null or undefined when calling updateInstallation.");if(t.installationUpdate===null||t.installationUpdate===void 0)throw new ne("installationUpdate","Required parameter requestParameters.installationUpdate was null or undefined when calling updateInstallation.");const r={},o={};if(o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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:fw(t.installationUpdate)},n);return new Re(i,s=>yi(s))}async updateInstallation(t,n){return await(await this.updateInstallationRaw(t,n)).value()}}class ww extends cn{async batchUpsertIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling batchUpsertIntegrations.");if(t.batchUpsertIntegrationsRequest===null||t.batchUpsertIntegrationsRequest===void 0)throw new ne("batchUpsertIntegrationsRequest","Required parameter requestParameters.batchUpsertIntegrationsRequest was null or undefined when calling batchUpsertIntegrations.");const r={},o={};if(o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}const i=await this.request({path:"/projects/{projectIdOrName}/integrations:batch".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PUT",headers:o,query:r,body:dg(t.batchUpsertIntegrationsRequest)},n);return new Re(i,s=>s.map(os))}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 ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createIntegration.");if(t.integration===null||t.integration===void 0)throw new ne("integration","Required parameter requestParameters.integration was null or undefined when calling createIntegration.");const r={},o={};if(o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}const i=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:r,body:Yy(t.integration)},n);return new Qr(i)}async createIntegration(t,n){await this.createIntegrationRaw(t,n)}async deleteIntegrationRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteIntegration.");if(t.integrationId===null||t.integrationId===void 0)throw new ne("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling deleteIntegration.");const r={},o={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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 Qr(i)}async deleteIntegration(t,n){await this.deleteIntegrationRaw(t,n)}async getIntegrationRaw(t,n){if(t.integrationIdOrName===null||t.integrationIdOrName===void 0)throw new ne("integrationIdOrName","Required parameter requestParameters.integrationIdOrName was null or undefined when calling getIntegration.");if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getIntegration.");const r={},o={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}const i=await this.request({path:"/projects/{projectIdOrName}/integrations/{integrationIdOrName}".replace("{integrationIdOrName}",encodeURIComponent(String(t.integrationIdOrName))).replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Re(i,s=>os(s))}async getIntegration(t,n){return await(await this.getIntegrationRaw(t,n)).value()}async listIntegrationsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listIntegrations.");const r={},o={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}const i=await this.request({path:"/projects/{projectIdOrName}/integrations".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Re(i,s=>s.map(os))}async listIntegrations(t,n){return await(await this.listIntegrationsRaw(t,n)).value()}}class bw extends cn{async oauthConnectRaw(t,n){if(t.connectOAuthParams===null||t.connectOAuthParams===void 0)throw new ne("connectOAuthParams","Required parameter requestParameters.connectOAuthParams was null or undefined when calling oauthConnect.");const r={},o={};if(o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}const i=await this.request({path:"/oauth-connect",method:"POST",headers:o,query:r,body:nw(t.connectOAuthParams)},n);return this.isJsonMime(i.headers.get("content-type"))?new Re(i):new Tc(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 ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling oauthUpdate.");if(t.connectionId===null||t.connectionId===void 0)throw new ne("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling oauthUpdate.");const r={},o={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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 Re(i):new Tc(i)}async oauthUpdate(t,n){return await(await this.oauthUpdateRaw(t,n)).value()}}class Iw extends cn{async createProjectRaw(t,n){if(t.project===null||t.project===void 0)throw new ne("project","Required parameter requestParameters.project was null or undefined when calling createProject.");const r={},o={};if(o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}const i=await this.request({path:"/projects",method:"POST",headers:o,query:r,body:Zy(t.project)},n);return new Re(i,s=>no(s))}async createProject(t,n){return await(await this.createProjectRaw(t,n)).value()}async getProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getProject.");const r={};t.includeEntitlements!==void 0&&(r.includeEntitlements=t.includeEntitlements);const o={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}const i=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"GET",headers:o,query:r},n);return new Re(i,s=>no(s))}async getProject(t,n){return await(await this.getProjectRaw(t,n)).value()}async listProjectsRaw(t){const n={},r={};if(this.configuration&&this.configuration.apiKey&&(r["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const i=this.configuration.accessToken,s=await i("Bearer",[]);s&&(r.Authorization=`Bearer ${s}`)}const o=await this.request({path:"/projects",method:"GET",headers:r,query:n},t);return new Re(o,i=>i.map(no))}async listProjects(t){return await(await this.listProjectsRaw(t)).value()}async updateProjectRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProject.");if(t.projectUpdate===null||t.projectUpdate===void 0)throw new ne("projectUpdate","Required parameter requestParameters.projectUpdate was null or undefined when calling updateProject.");const r={},o={};if(o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}const i=await this.request({path:"/projects/{projectIdOrName}".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"PATCH",headers:o,query:r,body:hw(t.projectUpdate)},n);return new Re(i,s=>no(s))}async updateProject(t,n){return await(await this.updateProjectRaw(t,n)).value()}}class Cw extends cn{async getProviderRaw(t,n){if(t.provider===null||t.provider===void 0)throw new ne("provider","Required parameter requestParameters.provider was null or undefined when calling getProvider.");const r={},o={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}const i=await this.request({path:"/providers/{provider}".replace("{provider}",encodeURIComponent(String(t.provider))),method:"GET",headers:o,query:r},n);return new Re(i,s=>Fc(s))}async getProvider(t,n){return await(await this.getProviderRaw(t,n)).value()}async listProvidersRaw(t){const n={},r={};if(this.configuration&&this.configuration.apiKey&&(r["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const i=this.configuration.accessToken,s=await i("Bearer",[]);s&&(r.Authorization=`Bearer ${s}`)}const o=await this.request({path:"/providers",method:"GET",headers:r,query:n},t);return new Re(o,i=>Ve(i,Fc))}async listProviders(t){return await(await this.listProvidersRaw(t)).value()}}class Sw extends cn{async createProviderAppRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createProviderApp.");if(t.providerApp===null||t.providerApp===void 0)throw new ne("providerApp","Required parameter requestParameters.providerApp was null or undefined when calling createProviderApp.");const r={},o={};if(o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}const i=await this.request({path:"/projects/{projectIdOrName}/provider-apps".replace("{projectIdOrName}",encodeURIComponent(String(t.projectIdOrName))),method:"POST",headers:o,query:r,body:ev(t.providerApp)},n);return new Re(i,s=>po(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 ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling deleteProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new ne("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling deleteProviderApp.");const r={},o={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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 Qr(i)}async deleteProviderApp(t,n){await this.deleteProviderAppRaw(t,n)}async listProviderAppsRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling listProviderApps.");const r={},o={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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 Re(i,s=>s.map(po))}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 ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling updateProviderApp.");if(t.providerAppId===null||t.providerAppId===void 0)throw new ne("providerAppId","Required parameter requestParameters.providerAppId was null or undefined when calling updateProviderApp.");if(t.providerAppUpdate===null||t.providerAppUpdate===void 0)throw new ne("providerAppUpdate","Required parameter requestParameters.providerAppUpdate was null or undefined when calling updateProviderApp.");const r={},o={};if(o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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:gw(t.providerAppUpdate)},n);return new Re(i,s=>po(s))}async updateProviderApp(t,n){return await(await this.updateProviderAppRaw(t,n)).value()}}class xw extends cn{async createRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling createRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new ne("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling createRevision.");if(t.revision===null||t.revision===void 0)throw new ne("revision","Required parameter requestParameters.revision was null or undefined when calling createRevision.");const r={},o={};if(o["Content-Type"]="application/json",this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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:tv(t.revision)},n);return new Qr(i)}async createRevision(t,n){await this.createRevisionRaw(t,n)}async getHydratedRevisionRaw(t,n){if(t.projectIdOrName===null||t.projectIdOrName===void 0)throw new ne("projectIdOrName","Required parameter requestParameters.projectIdOrName was null or undefined when calling getHydratedRevision.");if(t.integrationId===null||t.integrationId===void 0)throw new ne("integrationId","Required parameter requestParameters.integrationId was null or undefined when calling getHydratedRevision.");if(t.revisionId===null||t.revisionId===void 0)throw new ne("revisionId","Required parameter requestParameters.revisionId was null or undefined when calling getHydratedRevision.");if(t.connectionId===null||t.connectionId===void 0)throw new ne("connectionId","Required parameter requestParameters.connectionId was null or undefined when calling getHydratedRevision.");const r={};t.connectionId!==void 0&&(r.connectionId=t.connectionId);const o={};if(this.configuration&&this.configuration.apiKey&&(o["X-Api-Key"]=this.configuration.apiKey("X-Api-Key")),this.configuration&&this.configuration.accessToken){const s=this.configuration.accessToken,a=await s("Bearer",[]);a&&(o.Authorization=`Bearer ${a}`)}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 Re(i,s=>Tv(s))}async getHydratedRevision(t,n){return await(await this.getHydratedRevisionRaw(t,n)).value()}}var _l=Symbol.for("immer-nothing"),Dc=Symbol.for("immer-draftable"),Tt=Symbol.for("immer-state"),Ow=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 Ct(e,...t){if(process.env.NODE_ENV!=="production"){const n=Ow[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 Xr=Object.getPrototypeOf;function Yr(e){return!!e&&!!e[Tt]}function xr(e){var t;return e?Nl(e)||Array.isArray(e)||!!e[Dc]||!!((t=e.constructor)!=null&&t[Dc])||Lo(e)||jo(e):!1}var Ew=Object.prototype.constructor.toString();function Nl(e){if(!e||typeof e!="object")return!1;const t=Xr(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)===Ew}function Io(e,t){ko(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function ko(e){const t=e[Tt];return t?t.type_:Array.isArray(e)?1:Lo(e)?2:jo(e)?3:0}function $s(e,t){return ko(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Tl(e,t,n){const r=ko(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function _w(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Lo(e){return e instanceof Map}function jo(e){return e instanceof Set}function lr(e){return e.copy_||e.base_}function Us(e,t){if(Lo(e))return new Map(e);if(jo(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=Nl(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[Tt];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(Xr(e),r)}else{const r=Xr(e);if(r!==null&&n)return{...e};const o=Object.create(r);return Object.assign(o,e)}}function ga(e,t=!1){return Ko(e)||Yr(e)||!xr(e)||(ko(e)>1&&(e.set=e.add=e.clear=e.delete=Nw),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>ga(r,!0))),e}function Nw(){Ct(2)}function Ko(e){return Object.isFrozen(e)}var Tw={};function Or(e){const t=Tw[e];return t||Ct(0,e),t}var Ei;function Al(){return Ei}function Aw(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Mc(e,t){t&&(Or("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function qs(e){Vs(e),e.drafts_.forEach(Rw),e.drafts_=null}function Vs(e){e===Ei&&(Ei=e.parent_)}function kc(e){return Ei=Aw(Ei,e)}function Rw(e){const t=e[Tt];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Lc(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[Tt].modified_&&(qs(t),Ct(4)),xr(e)&&(e=Co(t,e),t.parent_||So(t,e)),t.patches_&&Or("Patches").generateReplacementPatches_(n[Tt].base_,e,t.patches_,t.inversePatches_)):e=Co(t,n,[]),qs(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==_l?e:void 0}function Co(e,t,n){if(Ko(t))return t;const r=t[Tt];if(!r)return Io(t,(o,i)=>jc(e,r,t,o,i,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return So(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),Io(i,(a,c)=>jc(e,r,o,a,c,n,s)),So(e,o,!1),n&&e.patches_&&Or("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function jc(e,t,n,r,o,i,s){if(process.env.NODE_ENV!=="production"&&o===n&&Ct(5),Yr(o)){const a=i&&t&&t.type_!==3&&!$s(t.assigned_,r)?i.concat(r):void 0,c=Co(e,o,a);if(Tl(n,r,c),Yr(c))e.canAutoFreeze_=!1;else return}else s&&n.add(o);if(xr(o)&&!Ko(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Co(e,o),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&So(e,o)}}function So(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ga(t,n)}function Pw(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:Al(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,i=ya;n&&(o=[r],i=_i);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,a}var ya={get(e,t){if(t===Tt)return e;const n=lr(e);if(!$s(n,t))return Fw(e,n,t);const r=n[t];return e.finalized_||!xr(r)?r:r===as(e.base_,t)?(cs(e),e.copy_[t]=Bs(r,e)):r},has(e,t){return t in lr(e)},ownKeys(e){return Reflect.ownKeys(lr(e))},set(e,t,n){const r=Rl(lr(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const o=as(lr(e),t),i=o==null?void 0:o[Tt];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(_w(n,o)&&(n!==void 0||$s(e.base_,t)))return!0;cs(e),Hs(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 as(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,cs(e),Hs(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=lr(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){Ct(11)},getPrototypeOf(e){return Xr(e.base_)},setPrototypeOf(){Ct(12)}},_i={};Io(ya,(e,t)=>{_i[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});_i.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Ct(13),_i.set.call(this,e,t,void 0)};_i.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Ct(14),ya.set.call(this,e[0],t,n,e[0])};function as(e,t){const n=e[Tt];return(n?lr(n):e)[t]}function Fw(e,t,n){var o;const r=Rl(t,n);return r?"value"in r?r.value:(o=r.get)==null?void 0:o.call(e.draft_):void 0}function Rl(e,t){if(!(t in e))return;let n=Xr(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Xr(n)}}function Hs(e){e.modified_||(e.modified_=!0,e.parent_&&Hs(e.parent_))}function cs(e){e.copy_||(e.copy_=Us(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Dw=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const s=this;return function(c=i,...f){return s.produce(c,d=>n.call(this,d,...f))}}typeof n!="function"&&Ct(6),r!==void 0&&typeof r!="function"&&Ct(7);let o;if(xr(t)){const i=kc(this),s=Bs(t,void 0);let a=!0;try{o=n(s),a=!1}finally{a?qs(i):Vs(i)}return Mc(i,r),Lc(o,i)}else if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===_l&&(o=void 0),this.autoFreeze_&&ga(o,!0),r){const i=[],s=[];Or("Patches").generateReplacementPatches_(t,o,i,s),r(i,s)}return o}else Ct(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,c=>t(c,...a));let r,o;return[this.produce(t,n,(s,a)=>{r=s,o=a}),r,o]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){xr(e)||Ct(8),Yr(e)&&(e=Mw(e));const t=kc(this),n=Bs(e,void 0);return n[Tt].isManual_=!0,Vs(t),n}finishDraft(e,t){const n=e&&e[Tt];(!n||!n.isManual_)&&Ct(9);const{scope_:r}=n;return Mc(r,t),Lc(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));const r=Or("Patches").applyPatches_;return Yr(e)?r(e,t):this.produce(e,o=>r(o,t))}};function Bs(e,t){const n=Lo(e)?Or("MapSet").proxyMap_(e,t):jo(e)?Or("MapSet").proxySet_(e,t):Pw(e,t);return(t?t.scope_:Al()).drafts_.push(n),n}function Mw(e){return Yr(e)||Ct(10,e),Pl(e)}function Pl(e){if(!xr(e)||Ko(e))return e;const t=e[Tt];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Us(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Us(e,!0);return Io(n,(r,o)=>{Tl(n,r,Pl(o))}),t&&(t.finalized_=!1),n}var At=new Dw,It=At.produce;At.produceWithPatches.bind(At);At.setAutoFreeze.bind(At);At.setUseStrictShallowCopy.bind(At);At.applyPatches.bind(At);At.createDraft.bind(At);At.finishDraft.bind(At);const $e=async(e,t)=>{var n;if(e instanceof ll){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(`
|
|
3
3
|
`))||(s==null?void 0:s.detail);a?(console.error("[Error Message]",a),s!=null&&s.remedy&&console.error("[Remedy]",s.remedy)):console.error("Unexpected error response:",s);const c=`${a} ${s!=null&&s.remedy?`
|
|
4
4
|
|
|
5
|
-
[Remedy] ${s.remedy}`:""}`;t&&t(c)}catch(i){console.error("Error parsing error response body:",i)}}else console.error("Unexpected error:",e.message)};function Ko(){const e=it(),{projectIdOrName:t}=Re(),{setError:n,removeError:r}=qt(),o=er({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});return b.useEffect(()=>{o.isError?(De(o.error),n(de.INTEGRATION_LIST,t)):r(de.INTEGRATION_LIST,t)},[o.isError,o.error,t,n,r]),o}const ya=(e,t)=>{var s;const n=it(),{projectIdOrName:r}=Re(),{data:o}=Ko(),i=(s=o==null?void 0:o.find(a=>a.name===e))==null?void 0:s.id;return er({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})},nr=()=>{var o,i;const{setError:e}=qt(),t=it(),{projectIdOrName:n}=Re(),r=er({queryKey:["project",n],queryFn:async()=>(await t()).projectApi.getProject({projectIdOrName:n})});return b.useEffect(()=>{r.isError&&e(de.PROJECT,n)},[r.isError,n,e]),{...r,projectIdOrName:n,appName:(o=r.data)==null?void 0:o.name,projectId:(i=r.data)==null?void 0:i.id}};function Di(){const{integrationNameOrId:e,groupRef:t}=Ar(),n=ya(e,t),{isPending:r,isFetching:o,isError:i,isSuccess:s,error:a,data:c}=n;return{installation:c==null?void 0:c[0],isPending:r,isFetching:o,isError:i,isSuccess:s,error:a}}const ci=e=>{const t=Ko(),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}},va=()=>{const{groupRef:e,integrationNameOrId:t}=Ar(),{provider:n}=ci(t),r=ba({groupRef:e,provider:n}),{isPending:o,isFetching:i,isError:s,isSuccess:a,error:c,data:d}=r;return{connection:d==null?void 0:d[0],error:c,isPending:o,isFetching:i,isError:s,isSuccess:a}},jw=()=>{var m;const e=$e(),t=it(),{connection:n,isPending:r,isFetching:o}=va(),{projectIdOrName:i}=Re(),{integrationNameOrId:s}=Ar(),{data:a}=ci(s),c=n==null?void 0:n.id,d=a==null?void 0:a.id,u=(m=a==null?void 0:a.latestRevision)==null?void 0:m.id,f=r||o;return b.useEffect(()=>{c||e.invalidateQueries({queryKey:["amp","hydratedRevision"]})},[c,e]),er({queryKey:["amp","hydratedRevision",i,d,u,c],queryFn:async()=>{if(!i)throw new Error("projectIdOrName is required");if(!d)throw new Error("integrationId is required");if(!u)throw new Error("revisionId is required");if(!c)throw new Error("connectionId is required");return(await t()).revisionApi.getHydratedRevision({projectIdOrName:i,integrationId:d,revisionId:u,connectionId:c})},retry:3,enabled:!!i&&!!d&&!!u&&!!c&&!f})};function ku(){var d,u;const e=jw(),{isPending:t,isFetching:n,isError:r,isSuccess:o,error:i,data:s}=e,a=s==null?void 0:s.content,c=b.useMemo(()=>({getReadObject:f=>{var g,y;const m=(y=(g=a==null?void 0:a.read)==null?void 0:g.objects)==null?void 0:y.find(v=>v.objectName===f);return m?{object:m,getRequiredFields:()=>m.requiredFields??[],getOptionalFields:()=>m.optionalFields??[]}:(console.error(`Object ${f} not found`),{object:null,getRequiredFields:()=>null,getOptionalFields:()=>null})},getWriteObject:f=>{var g,y;const m=(y=(g=a==null?void 0:a.write)==null?void 0:g.objects)==null?void 0:y.find(v=>v.objectName===f);return m?{object:m}:(console.error(`Object ${f} not found`),{object:null})},getCustomerFieldsForObject:f=>{var g,y;const m=(y=(g=a==null?void 0:a.read)==null?void 0:g.objects)==null?void 0:y.find(v=>v.objectName===f);return m?{allFields:m.allFieldsMetadata??{},getField:v=>{var x;const p=(x=m.allFieldsMetadata)==null?void 0:x[v];return p||(console.error(`Field ${v} not found`),null)}}:(console.error(`Object ${f} not found`),{allFields:null,getField:()=>null})}}),[(d=a==null?void 0:a.read)==null?void 0:d.objects,(u=a==null?void 0:a.write)==null?void 0:u.objects]);return{data:s,...c,isPending:t,isFetching:n,isError:r,isSuccess:o,error:i}}function Kw(e){var m,g,y,v;const[t,n]=b.useState(e),{getReadObject:r,data:o}=ku(),{installation:i}=Di(),s=b.useCallback(()=>t,[t]),a=b.useCallback((p,x)=>{var R,P,J,K;x.provider=x.provider||((R=o==null?void 0:o.content)==null?void 0:R.provider)||"";const h=x.read||{objects:{}},w=h.objects||{},I=w[p]||{},S=r(p),A=(P=S==null?void 0:S.object)==null?void 0:P.schedule,O=(J=S==null?void 0:S.object)==null?void 0:J.destination,N={};return(K=S==null?void 0:S.getRequiredFields())==null||K.forEach(M=>{"fieldName"in M&&(N[M.fieldName]=!0)}),I.objectName=I.objectName||p,I.schedule=I.schedule||A||"",I.destination=I.destination||O||"",I.selectedFields=I.selectedFields||N,w[p]=I,h.objects=w,x.read=h,{read:h,objects:w,obj:I}},[r,(m=o==null?void 0:o.content)==null?void 0:m.provider]),c=b.useCallback(p=>{var x,h;return{object:(h=(x=t.read)==null?void 0:x.objects)==null?void 0:h[p],getSelectedField:w=>{var I,S,A,O;return!!((O=(A=(S=(I=t.read)==null?void 0:I.objects)==null?void 0:S[p])==null?void 0:A.selectedFields)!=null&&O[w])},setSelectedField:({fieldName:w,selected:I})=>{n(S=>It(S,A=>{const{obj:O}=a(p,A);O.selectedFields=O.selectedFields||{},O.selectedFields[w]=I,O.selectedFields[w]===!1&&delete O.selectedFields[w]}))},getFieldMapping:w=>{var I,S,A,O;return(O=(A=(S=(I=t.read)==null?void 0:I.objects)==null?void 0:S[p])==null?void 0:A.selectedFieldMappings)==null?void 0:O[w]},setFieldMapping:({fieldName:w,mapToName:I})=>{n(S=>It(S,A=>{const{obj:O}=a(p,A);O.selectedFieldMappings=O.selectedFieldMappings||{},O.selectedFieldMappings[I]=w}))}}},[(g=t.read)==null?void 0:g.objects,a]),d=b.useCallback(p=>{var S,A;const x=(A=(S=t.write)==null?void 0:S.objects)==null?void 0:A[p],h=O=>{const N=O.write||{},R=N.objects||{},P=R[p]||{objectName:p};return R[p]=P,N.objects=R,O.write=N,{write:N,objects:R,obj:P}},w=(O,N)=>{var R,P;return(P=(R=x==null?void 0:x.selectedFieldSettings)==null?void 0:R[O])==null?void 0:P[N]},I=(O,N,R)=>{n(P=>It(P,J=>{var M;const{obj:K}=h(J);K.selectedFieldSettings={...K.selectedFieldSettings,[O]:{...(M=K.selectedFieldSettings)==null?void 0:M[O],[N]:R}}}))};return{object:x,setEnableWrite:()=>{n(O=>It(O,N=>{const{obj:R}=h(N);R.objectName=p}))},setDisableWrite:()=>{n(O=>It(O,N=>{const{objects:R}=h(N);delete R[p]}))},getWriteObject:()=>{var O,N;return(N=(O=t.write)==null?void 0:O.objects)==null?void 0:N[p]},getSelectedFieldSettings:O=>{var N;return(N=x==null?void 0:x.selectedFieldSettings)==null?void 0:N[O]},setSelectedFieldSettings:({fieldName:O,settings:N})=>{n(R=>It(R,P=>{const{obj:J}=h(P),K=J.selectedFieldSettings||{};J.selectedFieldSettings={...K,[O]:N},N===void 0&&delete J.selectedFieldSettings[O]}))},getDefaultValues:O=>w(O,"default"),setDefaultValues:({fieldName:O,value:N})=>I(O,"default",N),getWriteOnCreateSetting:O=>w(O,"writeOnCreate"),setWriteOnCreateSetting:({fieldName:O,value:N})=>I(O,"writeOnCreate",N),getWriteOnUpdateSetting:O=>w(O,"writeOnUpdate"),setWriteOnUpdateSetting:({fieldName:O,value:N})=>I(O,"writeOnUpdate",N)}},[(y=t.write)==null?void 0:y.objects]),u=b.useCallback(()=>({object:t.proxy,setEnableProxy:()=>{n(p=>It(p,x=>{x.proxy={enabled:!0}}))},setDisableProxy:()=>{n(p=>It(p,x=>{x.proxy={enabled:!1}}))},getProxyEnabled:()=>{var p;return((p=t.proxy)==null?void 0:p.enabled)||!1}}),[t.proxy]),f=b.useCallback(()=>{n(p=>It(p,x=>{var h;Object.assign(x,(h=i==null?void 0:i.config)==null?void 0:h.content)}))},[(v=i==null?void 0:i.config)==null?void 0:v.content]);return b.useEffect(()=>{i&&(console.debug("Installation found",{installation:i}),f())},[i,f]),{draft:t,get:s,reset:f,setDraft:n,readObject:c,writeObject:d,proxy:u}}const Lu=b.createContext(null);function Uw({children:e,initialConfig:t}){const n=Kw(t);return l.jsx(Lu.Provider,{value:n,children:e})}function $w(){const e=b.useContext(Lu);if(!e)throw new Error("useConfigContext must be used within a ConfigProvider / InstallationProvider");return e}const ju=b.createContext({integrationNameOrId:"",consumerRef:"",consumerName:void 0,groupRef:"",groupName:void 0});function Ar(){const e=b.useContext(ju);if(!e)throw new Error("useInstallationProps must be used within an InstallationProvider");return e}function Ku({children:e,integration:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i}){const s=b.useMemo(()=>({integrationNameOrId:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i}),[t,n,r,o,i]);return l.jsx(ju.Provider,{value:s,children:l.jsx(Uw,{initialConfig:{},children:e})})}class Js{constructor(t){this.connectionApi=new ww(t),this.installationApi=new bw(t),this.integrationApi=new Iw(t),this.oAuthApi=new Cw(t),this.projectApi=new xw(t),this.providerApi=new Sw(t),this.providerAppApi=new Ew(t),this.revisionApi=new Ow(t)}}const Uu="2.8.7",qw="v1",no="https://api.withampersand.com";function $u(){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 no;case"mock":return"http://127.0.0.1:4010";case"":return no;default:return e??no}}catch{return no}}const Vw=(e,t)=>`${e}/${t}`;function Hw(){return Vw($u(),qw)}const qu=$u(),Vu=Hw(),Jw=new pa({basePath:Vu,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":Uu}});let Ww=new Js(Jw);const wa=()=>Ww,Bw=e=>({header:"X-Api-Key",value:e}),zw=e=>{try{return{header:"Authorization",value:`Bearer ${e}`}}catch(t){throw console.error("Failed to get JWT token for API authentication:",t),new Error("Failed to authenticate with JWT token")}},Kc=(e,t)=>new pa({basePath:Vu,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":Uu,[e]:t}});function it(){const e=tu(),{getToken:t}=Xh(),{consumerRef:n,groupRef:r}=Ar();return b.useCallback(async()=>{if(e){const i=Bw(e),s=Kc(i.header,i.value);return new Js(s)}if(t){if(!n||!r)throw console.error("Unable to create JWT API service without consumerRef or groupRef.",{consumerRef:n,groupRef:r}),new Error("Unable to create JWT API service without consumerRef or groupRef.");const i=await t({consumerRef:n,groupRef:r}),s=zw(i),a=Kc(s.header,s.value);return new Js(a)}throw console.error("Unable to create API service without API key or JWT token."),new Error("Unable to create API service without API key or JWT token.")},[e,t,n,r])}const ba=({groupRef:e,provider:t})=>{const{projectIdOrName:n}=Re(),r=it();return er({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})};function Gw(){return l.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M20.5796 7.72236L3.63955 36.0024C3.29029 36.6072 3.10549 37.293 3.10353 37.9914C3.10158 38.6898 3.28254 39.3766 3.62841 39.9834C3.97428 40.5902 4.473 41.0959 5.07497 41.4501C5.67693 41.8043 6.36115 41.9947 7.05955 42.0024H40.9396C41.638 41.9947 42.3222 41.8043 42.9241 41.4501C43.5261 41.0959 44.0248 40.5902 44.3707 39.9834C44.7166 39.3766 44.8975 38.6898 44.8956 37.9914C44.8936 37.293 44.7088 36.6072 44.3596 36.0024L27.4196 7.72236C27.063 7.13458 26.561 6.6486 25.9619 6.31133C25.3629 5.97406 24.687 5.79688 23.9996 5.79688C23.3121 5.79688 22.6362 5.97406 22.0372 6.31133C21.4381 6.6486 20.9361 7.13458 20.5796 7.72236Z",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M24 18V26",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M24 34H24.02",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]})}const Qw="_box_1p7c5_1",Uc={box:Qw};function _n({children:e,className:t,style:n}){return l.jsx("div",{className:t?`${Uc.box} ${t}`:Uc.box,style:n,children:e})}const Xw="_container_1wvzr_1",$c={container:Xw};function li({children:e,className:t,style:n}){return l.jsx("div",{className:t?`${$c.container} ${t}`:$c.container,style:n,children:e})}const Yw="_errorBoxContainer_4sdb2_1",Zw="_errorBox_4sdb2_1",eb="_errorText_4sdb2_20",Ws={errorBoxContainer:Yw,errorBox:Zw,errorText:eb};function Hu({message:e}){return l.jsx(_n,{className:Ws.errorBox,children:l.jsx("p",{className:Ws.errorText,children:e})})}function Ju({message:e,children:t}){return l.jsxs(li,{className:Ws.errorBoxContainer,children:[l.jsx(Gw,{}),l.jsx(Hu,{message:e}),t]})}const tb="_loader_6ubm6_1",nb="_rotate_6ubm6_1",rb="_ball1_6ubm6_1",ib="_ball2_6ubm6_1",ob={loader:tb,rotate:nb,ball1:rb,ball2:ib};function sb(){return l.jsx("span",{className:ob.loader})}function Oi(){return l.jsx("div",{style:{display:"flex",width:"100%",height:"100%",justifyContent:"center",marginTop:"20%",marginBottom:"20%"},children:l.jsx(sb,{})})}function Wu({children:e}){return l.jsx(li,{style:{maxWidth:"55rem"},children:l.jsx(_n,{children:e})})}function ui(){return l.jsx(Wu,{children:l.jsx(Oi,{})})}function Ut({message:e,children:t}){return l.jsx(Wu,{children:l.jsx(Ju,{message:e,children:t})})}function ln(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ab(e,t){return(t==null?void 0:t.displayName)??ln(e)}const cb=e=>e.split(`
|
|
6
|
-
`).filter(n=>n.trim()!==""),lb=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(n=>n.name===e)??null,ub=e=>e.replace(/[.:/\\]/g,"\\$&");function db(e){return!e||typeof e!="string"?"id_"+Math.random().toString(36).substr(2,9):e.toLowerCase().replace(/[^a-z0-9_-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"").replace(/^[^a-z]/,"id-").substring(0,50)}const fb=()=>{const[e,t]=b.useState(!1),n=b.useCallback(()=>{t(!0)},[t]),r=b.useCallback(()=>{t(!1)},[t]);return{isIntegrationDeleted:e,setIntegrationDeleted:n,resetIntegrationDeleted:r}},Bu=b.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:()=>{},resetComponent:()=>{}});function Ze(){const e=b.useContext(Bu);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function pb({children:e,integration:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,onInstallSuccess:s,onUpdateSuccess:a,onUninstallSuccess:c,fieldMapping:d,resetComponent:u}){const{data:f}=Ko(),{setError:m,isError:g,removeError:y}=qt(),{isIntegrationDeleted:v,setIntegrationDeleted:p,resetIntegrationDeleted:x}=fb(),h=b.useMemo(()=>lb(t,f||[]),[t,f]),{data:w,isLoading:I,isError:S,error:A}=ya(t,o),O=(w==null?void 0:w[0])||null;b.useEffect(()=>{x()},[t,n,r,o,i,d]),b.useEffect(()=>{h===null&&(f!=null&&f.length)&&console.error(`Integration "${t}" not found in integration list`)},[t,h,f]),b.useEffect(()=>{S?(m(de.INSTALLATION_LIST,(h==null?void 0:h.id)||""),De(A)):y(de.INSTALLATION_LIST,(h==null?void 0:h.id)||"")},[S,h,m,y,A]);const N=$e(),R=b.useCallback(()=>{N.invalidateQueries({queryKey:["amp","installations"]})},[N]),P=b.useCallback(M=>{N.setQueryData(["amp","installations"],[M]),N.invalidateQueries({queryKey:["amp","installations"]})},[N]),J=(h==null?void 0:h.id)||"",K=b.useMemo(()=>({integrationId:(h==null?void 0:h.id)||"",provider:(h==null?void 0:h.provider)||"",integrationObj:h,consumerRef:n,consumerName:r,groupRef:o,groupName:i,installation:O||void 0,setInstallation:P,resetInstallations:R,onInstallSuccess:s,onUpdateSuccess:a,onUninstallSuccess:c,isIntegrationDeleted:v,setIntegrationDeleted:p,fieldMapping:d,resetComponent:u}),[h,n,r,o,i,O,P,R,s,a,c,v,p,d,u]);if(I)return l.jsx(ui,{});if(h===null)return l.jsx(Ut,{message:`Integration "${t}" not found`});if(g(de.INSTALLATION_LIST,J)){const M=`Error retrieving installation information for integration "${(h==null?void 0:h.name)||"unknown"}"`;return l.jsx(Ut,{message:M})}return l.jsx(Bu.Provider,{value:K,children:e})}const zu=b.createContext({connections:null,isConnectionsLoading:!0,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{}}),en=()=>{const e=b.useContext(zu);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function Gu({groupRef:e,provider:t,children:n}){const r=$e(),{setError:o,isError:i}=qt(),{projectIdOrName:s,isLoading:a}=nr(),{integrationId:c,groupRef:d}=Ze(),{provider:u}=ci(c),{data:f,isLoading:m,isError:g,error:y}=ba({groupRef:e||d,provider:u||t}),v=f==null?void 0:f[0],p=b.useCallback(w=>{r.setQueryData(["amp","connections"],()=>w),r.invalidateQueries({queryKey:["amp","connections"]})},[r]),x=b.useCallback(()=>{r.invalidateQueries({queryKey:["amp","connections"]})},[r]);b.useEffect(()=>{g?(o(de.CONNECTION_LIST,s,!0),De(y)):o(de.CONNECTION_LIST,s,!1)},[g,o,s,y]);const h=b.useMemo(()=>({connections:f||null,isConnectionsLoading:m,selectedConnection:v||null,setConnections:p,setSelectedConnection:x}),[f,m,v,p,x]);if(m||a)return l.jsx(ui,{});if(s&&i(de.PROJECT,s))return l.jsx(Ut,{message:`Error loading project ${s}`});if(s&&i(de.CONNECTION_LIST,s))return l.jsx(Ut,{message:"Error retrieving existing connections"});if(!s)throw new Error("Project ID or Project Name not found. ConnectionsProvider must be used within AmpersandProvider");return l.jsx(zu.Provider,{value:h,children:n})}function Qu(){const[e,t]=b.useState(1);return{seed:e,reset:()=>{t(Math.random())}}}var ro=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ia(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xo={exports:{}};xo.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",o=1,i=2,s=9007199254740991,a="[object Arguments]",c="[object Array]",d="[object AsyncFunction]",u="[object Boolean]",f="[object Date]",m="[object Error]",g="[object Function]",y="[object GeneratorFunction]",v="[object Map]",p="[object Number]",x="[object Null]",h="[object Object]",w="[object Promise]",I="[object Proxy]",S="[object RegExp]",A="[object Set]",O="[object String]",N="[object Symbol]",R="[object Undefined]",P="[object WeakMap]",J="[object ArrayBuffer]",K="[object DataView]",M="[object Float32Array]",W="[object Float64Array]",ae="[object Int8Array]",re="[object Int16Array]",ne="[object Int32Array]",ge="[object Uint8Array]",ve="[object Uint8ClampedArray]",F="[object Uint16Array]",U="[object Uint32Array]",H=/[\\^$.*+?()[\]{}|]/g,q=/^\[object .+?Constructor\]$/,$=/^(?:0|[1-9]\d*)$/,L={};L[M]=L[W]=L[ae]=L[re]=L[ne]=L[ge]=L[ve]=L[F]=L[U]=!0,L[a]=L[c]=L[J]=L[u]=L[K]=L[f]=L[m]=L[g]=L[v]=L[p]=L[h]=L[S]=L[A]=L[O]=L[P]=!1;var Z=typeof ro=="object"&&ro&&ro.Object===Object&&ro,te=typeof self=="object"&&self&&self.Object===Object&&self,Y=Z||te||Function("return this")(),Q=t&&!t.nodeType&&t,ee=Q&&!0&&e&&!e.nodeType&&e,le=ee&&ee.exports===Q,k=le&&Z.process,we=function(){try{return k&&k.binding&&k.binding("util")}catch{}}(),B=we&&we.isTypedArray;function We(C,_){for(var D=-1,X=C==null?0:C.length,Ae=0,fe=[];++D<X;){var je=C[D];_(je,D,C)&&(fe[Ae++]=je)}return fe}function Oe(C,_){for(var D=-1,X=_.length,Ae=C.length;++D<X;)C[Ae+D]=_[D];return C}function mt(C,_){for(var D=-1,X=C==null?0:C.length;++D<X;)if(_(C[D],D,C))return!0;return!1}function Be(C,_){for(var D=-1,X=Array(C);++D<C;)X[D]=_(D);return X}function gt(C){return function(_){return C(_)}}function _e(C,_){return C.has(_)}function et(C,_){return C==null?void 0:C[_]}function St(C){var _=-1,D=Array(C.size);return C.forEach(function(X,Ae){D[++_]=[Ae,X]}),D}function Vt(C,_){return function(D){return C(_(D))}}function Pt(C){var _=-1,D=Array(C.size);return C.forEach(function(X){D[++_]=X}),D}var ut=Array.prototype,ot=Function.prototype,Me=Object.prototype,qe=Y["__core-js_shared__"],Ft=ot.toString,tt=Me.hasOwnProperty,Rr=function(){var C=/[^.]+$/.exec(qe&&qe.keys&&qe.keys.IE_PROTO||"");return C?"Symbol(src)_1."+C:""}(),pn=Me.toString,hn=RegExp("^"+Ft.call(tt).replace(H,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),yt=le?Y.Buffer:void 0,Te=Y.Symbol,or=Y.Uint8Array,Tn=Me.propertyIsEnumerable,An=ut.splice,Et=Te?Te.toStringTag:void 0,mn=Object.getOwnPropertySymbols,Rn=yt?yt.isBuffer:void 0,Pn=Vt(Object.keys,Object),gn=Pr(Y,"DataView"),nn=Pr(Y,"Map"),ke=Pr(Y,"Promise"),st=Pr(Y,"Set"),oe=Pr(Y,"WeakMap"),pe=Pr(Object,"create"),dt=ar(gn),yn=ar(nn),z=ar(ke),ce=ar(st),ue=ar(oe),Le=Te?Te.prototype:void 0,He=Le?Le.valueOf:void 0;function Qe(C){var _=-1,D=C==null?0:C.length;for(this.clear();++_<D;){var X=C[_];this.set(X[0],X[1])}}function Dt(){this.__data__=pe?pe(null):{},this.size=0}function nt(C){var _=this.has(C)&&delete this.__data__[C];return this.size-=_?1:0,_}function vt(C){var _=this.__data__;if(pe){var D=_[C];return D===r?void 0:D}return tt.call(_,C)?_[C]:void 0}function Ne(C){var _=this.__data__;return pe?_[C]!==void 0:tt.call(_,C)}function Fn(C,_){var D=this.__data__;return this.size+=this.has(C)?0:1,D[C]=pe&&_===void 0?r:_,this}Qe.prototype.clear=Dt,Qe.prototype.delete=nt,Qe.prototype.get=vt,Qe.prototype.has=Ne,Qe.prototype.set=Fn;function Ht(C){var _=-1,D=C==null?0:C.length;for(this.clear();++_<D;){var X=C[_];this.set(X[0],X[1])}}function Yo(){this.__data__=[],this.size=0}function qi(C){var _=this.__data__,D=Wi(_,C);if(D<0)return!1;var X=_.length-1;return D==X?_.pop():An.call(_,D,1),--this.size,!0}function Vi(C){var _=this.__data__,D=Wi(_,C);return D<0?void 0:_[D][1]}function Hi(C){return Wi(this.__data__,C)>-1}function Ji(C,_){var D=this.__data__,X=Wi(D,C);return X<0?(++this.size,D.push([C,_])):D[X][1]=_,this}Ht.prototype.clear=Yo,Ht.prototype.delete=qi,Ht.prototype.get=Vi,Ht.prototype.has=Hi,Ht.prototype.set=Ji;function rn(C){var _=-1,D=C==null?0:C.length;for(this.clear();++_<D;){var X=C[_];this.set(X[0],X[1])}}function be(){this.size=0,this.__data__={hash:new Qe,map:new(nn||Ht),string:new Qe}}function Jt(C){var _=Bi(this,C).delete(C);return this.size-=_?1:0,_}function pi(C){return Bi(this,C).get(C)}function sr(C){return Bi(this,C).has(C)}function Zo(C,_){var D=Bi(this,C),X=D.size;return D.set(C,_),this.size+=D.size==X?0:1,this}rn.prototype.clear=be,rn.prototype.delete=Jt,rn.prototype.get=pi,rn.prototype.has=sr,rn.prototype.set=Zo;function Dn(C){var _=-1,D=C==null?0:C.length;for(this.__data__=new rn;++_<D;)this.add(C[_])}function rp(C){return this.__data__.set(C,r),this}function ip(C){return this.__data__.has(C)}Dn.prototype.add=Dn.prototype.push=rp,Dn.prototype.has=ip;function Mn(C){var _=this.__data__=new Ht(C);this.size=_.size}function op(){this.__data__=new Ht,this.size=0}function sp(C){var _=this.__data__,D=_.delete(C);return this.size=_.size,D}function ap(C){return this.__data__.get(C)}function cp(C){return this.__data__.has(C)}function lp(C,_){var D=this.__data__;if(D instanceof Ht){var X=D.__data__;if(!nn||X.length<n-1)return X.push([C,_]),this.size=++D.size,this;D=this.__data__=new rn(X)}return D.set(C,_),this.size=D.size,this}Mn.prototype.clear=op,Mn.prototype.delete=sp,Mn.prototype.get=ap,Mn.prototype.has=cp,Mn.prototype.set=lp;function up(C,_){var D=zi(C),X=!D&&Ep(C),Ae=!D&&!X&&es(C),fe=!D&&!X&&!Ae&&dc(C),je=D||X||Ae||fe,Xe=je?Be(C.length,String):[],rt=Xe.length;for(var Pe in C)tt.call(C,Pe)&&!(je&&(Pe=="length"||Ae&&(Pe=="offset"||Pe=="parent")||fe&&(Pe=="buffer"||Pe=="byteLength"||Pe=="byteOffset")||bp(Pe,rt)))&&Xe.push(Pe);return Xe}function Wi(C,_){for(var D=C.length;D--;)if(ac(C[D][0],_))return D;return-1}function dp(C,_,D){var X=_(C);return zi(C)?X:Oe(X,D(C))}function hi(C){return C==null?C===void 0?R:x:Et&&Et in Object(C)?vp(C):Sp(C)}function rc(C){return mi(C)&&hi(C)==a}function ic(C,_,D,X,Ae){return C===_?!0:C==null||_==null||!mi(C)&&!mi(_)?C!==C&&_!==_:fp(C,_,D,X,ic,Ae)}function fp(C,_,D,X,Ae,fe){var je=zi(C),Xe=zi(_),rt=je?c:kn(C),Pe=Xe?c:kn(_);rt=rt==a?h:rt,Pe=Pe==a?h:Pe;var Ot=rt==h,Wt=Pe==h,at=rt==Pe;if(at&&es(C)){if(!es(_))return!1;je=!0,Ot=!1}if(at&&!Ot)return fe||(fe=new Mn),je||dc(C)?oc(C,_,D,X,Ae,fe):gp(C,_,rt,D,X,Ae,fe);if(!(D&o)){var Mt=Ot&&tt.call(C,"__wrapped__"),kt=Wt&&tt.call(_,"__wrapped__");if(Mt||kt){var Ln=Mt?C.value():C,vn=kt?_.value():_;return fe||(fe=new Mn),Ae(Ln,vn,D,X,fe)}}return at?(fe||(fe=new Mn),yp(C,_,D,X,Ae,fe)):!1}function pp(C){if(!uc(C)||Cp(C))return!1;var _=cc(C)?hn:q;return _.test(ar(C))}function hp(C){return mi(C)&&lc(C.length)&&!!L[hi(C)]}function mp(C){if(!xp(C))return Pn(C);var _=[];for(var D in Object(C))tt.call(C,D)&&D!="constructor"&&_.push(D);return _}function oc(C,_,D,X,Ae,fe){var je=D&o,Xe=C.length,rt=_.length;if(Xe!=rt&&!(je&&rt>Xe))return!1;var Pe=fe.get(C);if(Pe&&fe.get(_))return Pe==_;var Ot=-1,Wt=!0,at=D&i?new Dn:void 0;for(fe.set(C,_),fe.set(_,C);++Ot<Xe;){var Mt=C[Ot],kt=_[Ot];if(X)var Ln=je?X(kt,Mt,Ot,_,C,fe):X(Mt,kt,Ot,C,_,fe);if(Ln!==void 0){if(Ln)continue;Wt=!1;break}if(at){if(!mt(_,function(vn,cr){if(!_e(at,cr)&&(Mt===vn||Ae(Mt,vn,D,X,fe)))return at.push(cr)})){Wt=!1;break}}else if(!(Mt===kt||Ae(Mt,kt,D,X,fe))){Wt=!1;break}}return fe.delete(C),fe.delete(_),Wt}function gp(C,_,D,X,Ae,fe,je){switch(D){case K:if(C.byteLength!=_.byteLength||C.byteOffset!=_.byteOffset)return!1;C=C.buffer,_=_.buffer;case J:return!(C.byteLength!=_.byteLength||!fe(new or(C),new or(_)));case u:case f:case p:return ac(+C,+_);case m:return C.name==_.name&&C.message==_.message;case S:case O:return C==_+"";case v:var Xe=St;case A:var rt=X&o;if(Xe||(Xe=Pt),C.size!=_.size&&!rt)return!1;var Pe=je.get(C);if(Pe)return Pe==_;X|=i,je.set(C,_);var Ot=oc(Xe(C),Xe(_),X,Ae,fe,je);return je.delete(C),Ot;case N:if(He)return He.call(C)==He.call(_)}return!1}function yp(C,_,D,X,Ae,fe){var je=D&o,Xe=sc(C),rt=Xe.length,Pe=sc(_),Ot=Pe.length;if(rt!=Ot&&!je)return!1;for(var Wt=rt;Wt--;){var at=Xe[Wt];if(!(je?at in _:tt.call(_,at)))return!1}var Mt=fe.get(C);if(Mt&&fe.get(_))return Mt==_;var kt=!0;fe.set(C,_),fe.set(_,C);for(var Ln=je;++Wt<rt;){at=Xe[Wt];var vn=C[at],cr=_[at];if(X)var fc=je?X(cr,vn,at,_,C,fe):X(vn,cr,at,C,_,fe);if(!(fc===void 0?vn===cr||Ae(vn,cr,D,X,fe):fc)){kt=!1;break}Ln||(Ln=at=="constructor")}if(kt&&!Ln){var Gi=C.constructor,Qi=_.constructor;Gi!=Qi&&"constructor"in C&&"constructor"in _&&!(typeof Gi=="function"&&Gi instanceof Gi&&typeof Qi=="function"&&Qi instanceof Qi)&&(kt=!1)}return fe.delete(C),fe.delete(_),kt}function sc(C){return dp(C,Np,wp)}function Bi(C,_){var D=C.__data__;return Ip(_)?D[typeof _=="string"?"string":"hash"]:D.map}function Pr(C,_){var D=et(C,_);return pp(D)?D:void 0}function vp(C){var _=tt.call(C,Et),D=C[Et];try{C[Et]=void 0;var X=!0}catch{}var Ae=pn.call(C);return X&&(_?C[Et]=D:delete C[Et]),Ae}var wp=mn?function(C){return C==null?[]:(C=Object(C),We(mn(C),function(_){return Tn.call(C,_)}))}:Tp,kn=hi;(gn&&kn(new gn(new ArrayBuffer(1)))!=K||nn&&kn(new nn)!=v||ke&&kn(ke.resolve())!=w||st&&kn(new st)!=A||oe&&kn(new oe)!=P)&&(kn=function(C){var _=hi(C),D=_==h?C.constructor:void 0,X=D?ar(D):"";if(X)switch(X){case dt:return K;case yn:return v;case z:return w;case ce:return A;case ue:return P}return _});function bp(C,_){return _=_??s,!!_&&(typeof C=="number"||$.test(C))&&C>-1&&C%1==0&&C<_}function Ip(C){var _=typeof C;return _=="string"||_=="number"||_=="symbol"||_=="boolean"?C!=="__proto__":C===null}function Cp(C){return!!Rr&&Rr in C}function xp(C){var _=C&&C.constructor,D=typeof _=="function"&&_.prototype||Me;return C===D}function Sp(C){return pn.call(C)}function ar(C){if(C!=null){try{return Ft.call(C)}catch{}try{return C+""}catch{}}return""}function ac(C,_){return C===_||C!==C&&_!==_}var Ep=rc(function(){return arguments}())?rc:function(C){return mi(C)&&tt.call(C,"callee")&&!Tn.call(C,"callee")},zi=Array.isArray;function Op(C){return C!=null&&lc(C.length)&&!cc(C)}var es=Rn||Ap;function _p(C,_){return ic(C,_)}function cc(C){if(!uc(C))return!1;var _=hi(C);return _==g||_==y||_==d||_==I}function lc(C){return typeof C=="number"&&C>-1&&C%1==0&&C<=s}function uc(C){var _=typeof C;return C!=null&&(_=="object"||_=="function")}function mi(C){return C!=null&&typeof C=="object"}var dc=B?gt(B):hp;function Np(C){return Op(C)?up(C):mp(C)}function Tp(){return[]}function Ap(){return!1}e.exports=_p})(xo,xo.exports);var hb=xo.exports;const Xu=Ia(hb),_r="other",So="manage-tab";function En(e){return!e.fieldName}function mb(e,t){var n;return((n=e==null?void 0:e.objects)==null?void 0:n.find(r=>r.objectName===t))||null}function gb(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(n=>!En(n)&&!!n.fieldName))||null}function yb(e){var n;return((n=e==null?void 0:e.requiredFields)==null?void 0:n.filter(r=>En(r)&&!!r.mapToName))||[]}function vb(e){var n;return((n=e==null?void 0:e.optionalFields)==null?void 0:n.filter(r=>En(r)&&!!r.mapToName))||[]}function wb(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(n=>!En(n)&&!!n.fieldName))||null}const Yu=(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 bb(e){return En(e)?e.mapToName:e.fieldName}const Zu=(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)&&ln(s==null?void 0:s.objectName),completed:e?!!Yu(e,s.objectName):!1})}),n},ed=e=>{var n;return{name:_r,completed:e?!!((n=e==null?void 0:e.content)!=null&&n.write):!1}};function Ib(e,t){var i;const n=Zu(e,t),o=!!((i=t==null?void 0:t.content)!=null&&i.write)?ed(e):void 0;return o&&n.push(o),n}function td(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(de.MAPPING,o),r!=null&&r.length&&console.error("required fields not met",r.map(i=>i.mapToDisplayName)),{errorList:o}}function Cb(e,t){return Xu(e,t)}function nd(e,t){return Xu(e,t)}const xb=(e,t,n)=>{var p,x,h,w,I,S,A,O,N;if(!e)return null;const r=mb(e,t),o=r&&gb(r),i=r&&wb(r),s=r&&yb(r),a=r&&vb(r),c=(r==null?void 0:r.allFields)||[],d=(r==null?void 0:r.allFieldsMetadata)||{},u=n==null?void 0:n.content,f=((h=(x=(p=u==null?void 0:u.read)==null?void 0:p.objects)==null?void 0:x[t])==null?void 0:h.selectedFields)||{},m=((S=(I=(w=u==null?void 0:u.read)==null?void 0:w.objects)==null?void 0:I[t])==null?void 0:S.selectedValueMappings)||{},g=((N=(O=(A=u==null?void 0:u.read)==null?void 0:A.objects)==null?void 0:O[t])==null?void 0:N.selectedFieldMappings)||{},y=Object.entries(f).reduce((R,[P,J])=>((i==null?void 0:i.some(M=>!En(M)&&"fieldName"in M&&M.fieldName===P))&&(R[P]=J),R),{}),v={...g};return{allFields:c,allFieldsMetadata:d,requiredFields:o,optionalFields:i,requiredMapFields:s,optionalMapFields:a,selectedOptionalFields:y,selectedFieldMappings:g,selectedValueMappings:m,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,isValueMappingsModified:!1,savedConfig:{optionalFields:y,requiredMapFields:v,selectedValueMappings:m}}},Sb=(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 rd(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:xb(r,t,n),write:Sb(o,n)}}const id=(e,t,n,r)=>{const o=rd(e,n,t);r(n,o)},Eb=(e,t,n)=>{const r=Ib(t,e),o={};r.forEach(({name:i,completed:s})=>{s&&(o[i]=rd(e,i,t))}),n(o)},od=e=>{const{requiredFields:t,selectedOptionalFields:n}=(e==null?void 0:e.read)||{},r=new Set;return t==null||t.forEach(i=>r.add(bb(i))),{...Array.from(r).reduce((i,s)=>({...i,[s]:!0}),{}),...n||{}}},sd=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},ad=e=>{const{selectedValueMappings:t}=(e==null?void 0:e.read)||{};return t};function cd(e,t){return t[e]||void 0}async function ld({createConfig:e,projectIdOrName:t,integrationId:n,groupRef:r,connectionId:o,apiKey:i,setError:s,setInstallation:a,onInstallSuccess:c}){const d={projectIdOrName:t,integrationId:n,installation:{groupRef:r,connectionId:o,config:e}};try{const u=await wa().installationApi.createInstallation(d,{headers:{"X-Api-Key":i,"Content-Type":"application/json"}});a(u),c==null||c(u.id,u.config)}catch(u){De(u,s)}}function Mi(e){var t;return(t=e.content.proxy)==null?void 0:t.enabled}const Ob=(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)},_b=(e,t,n,r)=>{const o=od(e),i=sd(e),s=ad(e),a=Ob(n,t);if(!a)return console.error(`Error when getting object from hydratedRevision for objectName: ${t}`),null;const c={revisionId:n.id,createdBy:`consumer:${r}`,content:{provider:n.content.provider,read:{objects:{[t]:{objectName:t,schedule:a.schedule,destination:a.destination,selectedFields:o,selectedFieldMappings:i,selectedValueMappings:s||{},backfill:a.backfill}}}}};return Mi(n)&&(c.content.proxy={enabled:!0}),c},Nb=(e,t,n,r,o,i,s,a,c,d,u,f)=>{const m=_b(c,i,a,r);return m?ld({createConfig:m,projectIdOrName:e,integrationId:t,groupRef:n,connectionId:o,apiKey:s,setError:d,setInstallation:u,onInstallSuccess:f}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))},ud=e=>{var t;return{...(t=e.write)==null?void 0:t.selectedWriteObjects}},Tb=e=>{const t=e.content.write;return t==null?void 0:t.objects},Ab=(e,t,n)=>{if(!Tb(t))return console.error("Error when getting write objects from hydratedRevision"),null;const o=ud(e),i={revisionId:t.id,createdBy:`consumer:${n}`,content:{provider:t.content.provider,read:{objects:{}},write:{objects:o}}};return Mi(t)&&(i.content.proxy={enabled:!0}),i},Rb=(e,t,n,r,o,i,s,a,c,d,u)=>{const f=Ab(a,s,r);return f?ld({createConfig:f,projectIdOrName:e,integrationId:t,groupRef:n,connectionId:o,apiKey:i,setError:c,setInstallation:d,onInstallSuccess:u}):(console.error("Error when generating createConfig from configureState"),Promise.resolve(null))};var dd={exports:{}};/*!
|
|
5
|
+
[Remedy] ${s.remedy}`:""}`;t&&t(c)}catch(i){console.error("Error parsing error response body:",i)}}else console.error("Unexpected error:",e.message)};function $o(){const e=it(),{projectIdOrName:t}=Pe(),{setError:n,removeError:r}=qt(),o=Zn({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});return b.useEffect(()=>{o.isError?($e(o.error),n(ue.INTEGRATION_LIST,t)):r(ue.INTEGRATION_LIST,t)},[o.isError,o.error,t,n,r]),o}const va=(e,t)=>{var s;const n=it(),{projectIdOrName:r}=Pe(),{data:o}=$o(),i=(s=o==null?void 0:o.find(a=>a.name===e))==null?void 0:s.id;return Zn({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})},tr=()=>{var o,i;const{setError:e}=qt(),t=it(),{projectIdOrName:n}=Pe(),r=Zn({queryKey:["project",n],queryFn:async()=>(await t()).projectApi.getProject({projectIdOrName:n})});return b.useEffect(()=>{r.isError&&e(ue.PROJECT,n)},[r.isError,n,e]),{...r,projectIdOrName:n,appName:(o=r.data)==null?void 0:o.name,projectId:(i=r.data)==null?void 0:i.id}};function ki(){const{integrationNameOrId:e,groupRef:t}=Tr(),n=va(e,t),{isPending:r,isFetching:o,isError:i,isSuccess:s,error:a,data:c}=n;return{installation:c==null?void 0:c[0],isPending:r,isFetching:o,isError:i,isSuccess:s,error:a}}const ci=e=>{const t=$o(),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}},wa=()=>{const{groupRef:e,integrationNameOrId:t}=Tr(),{provider:n}=ci(t),r=Ia({groupRef:e,provider:n}),{isPending:o,isFetching:i,isError:s,isSuccess:a,error:c,data:f}=r;return{connection:f==null?void 0:f[0],error:c,isPending:o,isFetching:i,isError:s,isSuccess:a}},kw=()=>{var m;const e=Ue(),t=it(),{connection:n,isPending:r,isFetching:o}=wa(),{projectIdOrName:i}=Pe(),{integrationNameOrId:s}=Tr(),{data:a}=ci(s),c=n==null?void 0:n.id,f=a==null?void 0:a.id,d=(m=a==null?void 0:a.latestRevision)==null?void 0:m.id,l=r||o;return b.useEffect(()=>{c||e.invalidateQueries({queryKey:["amp","hydratedRevision"]})},[c,e]),Zn({queryKey:["amp","hydratedRevision",i,f,d,c],queryFn:async()=>{if(!i)throw new Error("projectIdOrName is required");if(!f)throw new Error("integrationId is required");if(!d)throw new Error("revisionId is required");if(!c)throw new Error("connectionId is required");return(await t()).revisionApi.getHydratedRevision({projectIdOrName:i,integrationId:f,revisionId:d,connectionId:c})},retry:3,enabled:!!i&&!!f&&!!d&&!!c&&!l})};function Fl(){var f,d;const e=kw(),{isPending:t,isFetching:n,isError:r,isSuccess:o,error:i,data:s}=e,a=s==null?void 0:s.content,c=b.useMemo(()=>({getReadObject:l=>{var g,v;const m=(v=(g=a==null?void 0:a.read)==null?void 0:g.objects)==null?void 0:v.find(w=>w.objectName===l);return m?{object:m,getRequiredFields:()=>m.requiredFields??[],getOptionalFields:()=>m.optionalFields??[]}:(console.error(`Object ${l} not found`),{object:null,getRequiredFields:()=>null,getOptionalFields:()=>null})},getWriteObject:l=>{var g,v;const m=(v=(g=a==null?void 0:a.write)==null?void 0:g.objects)==null?void 0:v.find(w=>w.objectName===l);return m?{object:m}:(console.error(`Object ${l} not found`),{object:null})},getCustomerFieldsForObject:l=>{var g,v;const m=(v=(g=a==null?void 0:a.read)==null?void 0:g.objects)==null?void 0:v.find(w=>w.objectName===l);return m?{allFields:m.allFieldsMetadata??{},getField:w=>{var S;const h=(S=m.allFieldsMetadata)==null?void 0:S[w];return h||(console.error(`Field ${w} not found`),null)}}:(console.error(`Object ${l} not found`),{allFields:null,getField:()=>null})}}),[(f=a==null?void 0:a.read)==null?void 0:f.objects,(d=a==null?void 0:a.write)==null?void 0:d.objects]);return{data:s,...c,isPending:t,isFetching:n,isError:r,isSuccess:o,error:i}}function Lw(e){var m,g,v,w;const[t,n]=b.useState(e),{getReadObject:r,data:o}=Fl(),{installation:i}=ki(),s=b.useCallback(()=>t,[t]),a=b.useCallback((h,S)=>{var E,A;S.provider=S.provider||((E=o==null?void 0:o.content)==null?void 0:E.provider)||"";const p=S.read||{objects:{}},y=p.objects||{},I=y[h]||{},x=r(h),T={};return(A=x==null?void 0:x.getRequiredFields())==null||A.forEach(R=>{"fieldName"in R&&(T[R.fieldName]=!0)}),I.objectName=I.objectName||h,I.selectedFields=I.selectedFields||T,y[h]=I,p.objects=y,S.read=p,{read:p,objects:y,obj:I}},[r,(m=o==null?void 0:o.content)==null?void 0:m.provider]),c=b.useCallback(h=>{var S,p;return{object:(p=(S=t.read)==null?void 0:S.objects)==null?void 0:p[h],getSelectedField:y=>{var I,x,T,E;return!!((E=(T=(x=(I=t.read)==null?void 0:I.objects)==null?void 0:x[h])==null?void 0:T.selectedFields)!=null&&E[y])},setSelectedField:({fieldName:y,selected:I})=>{n(x=>It(x,T=>{const{obj:E}=a(h,T);E.selectedFields=E.selectedFields||{},E.selectedFields[y]=I,E.selectedFields[y]===!1&&delete E.selectedFields[y]}))},getFieldMapping:y=>{var I,x,T,E;return(E=(T=(x=(I=t.read)==null?void 0:I.objects)==null?void 0:x[h])==null?void 0:T.selectedFieldMappings)==null?void 0:E[y]},setFieldMapping:({fieldName:y,mapToName:I})=>{n(x=>It(x,T=>{const{obj:E}=a(h,T);E.selectedFieldMappings=E.selectedFieldMappings||{},E.selectedFieldMappings[I]=y}))}}},[(g=t.read)==null?void 0:g.objects,a]),f=b.useCallback(h=>{var x,T;const S=(T=(x=t.write)==null?void 0:x.objects)==null?void 0:T[h],p=E=>{const A=E.write||{},R=A.objects||{},P=R[h]||{objectName:h};return R[h]=P,A.objects=R,E.write=A,{write:A,objects:R,obj:P}},y=(E,A)=>{var R,P;return(P=(R=S==null?void 0:S.selectedFieldSettings)==null?void 0:R[E])==null?void 0:P[A]},I=(E,A,R)=>{n(P=>It(P,K=>{var V;const{obj:q}=p(K);q.selectedFieldSettings={...q.selectedFieldSettings,[E]:{...(V=q.selectedFieldSettings)==null?void 0:V[E],[A]:R}}}))};return{object:S,setEnableWrite:()=>{n(E=>It(E,A=>{const{obj:R}=p(A);R.objectName=h}))},setDisableWrite:()=>{n(E=>It(E,A=>{const{objects:R}=p(A);delete R[h]}))},getWriteObject:()=>{var E,A;return(A=(E=t.write)==null?void 0:E.objects)==null?void 0:A[h]},getSelectedFieldSettings:E=>{var A;return(A=S==null?void 0:S.selectedFieldSettings)==null?void 0:A[E]},setSelectedFieldSettings:({fieldName:E,settings:A})=>{n(R=>It(R,P=>{const{obj:K}=p(P),q=K.selectedFieldSettings||{};K.selectedFieldSettings={...q,[E]:A},A===void 0&&delete K.selectedFieldSettings[E]}))},getDefaultValues:E=>y(E,"default"),setDefaultValues:({fieldName:E,value:A})=>I(E,"default",A),getWriteOnCreateSetting:E=>y(E,"writeOnCreate"),setWriteOnCreateSetting:({fieldName:E,value:A})=>I(E,"writeOnCreate",A),getWriteOnUpdateSetting:E=>y(E,"writeOnUpdate"),setWriteOnUpdateSetting:({fieldName:E,value:A})=>I(E,"writeOnUpdate",A)}},[(v=t.write)==null?void 0:v.objects]),d=b.useCallback(()=>({object:t.proxy,setEnableProxy:()=>{n(h=>It(h,S=>{S.proxy={enabled:!0}}))},setDisableProxy:()=>{n(h=>It(h,S=>{S.proxy={enabled:!1}}))},getProxyEnabled:()=>{var h;return((h=t.proxy)==null?void 0:h.enabled)||!1}}),[t.proxy]),l=b.useCallback(()=>{n(h=>It(h,S=>{var p;Object.assign(S,(p=i==null?void 0:i.config)==null?void 0:p.content)}))},[(w=i==null?void 0:i.config)==null?void 0:w.content]);return b.useEffect(()=>{i&&(console.debug("Installation found",{installation:i}),l())},[i,l]),{draft:t,get:s,reset:l,setDraft:n,readObject:c,writeObject:f,proxy:d}}const Dl=b.createContext(null);function jw({children:e,initialConfig:t}){const n=Lw(t);return u.jsx(Dl.Provider,{value:n,children:e})}function Kw(){const e=b.useContext(Dl);if(!e)throw new Error("useConfigContext must be used within a ConfigProvider / InstallationProvider");return e}const Ml=b.createContext({integrationNameOrId:"",consumerRef:"",consumerName:void 0,groupRef:"",groupName:void 0});function Tr(){const e=b.useContext(Ml);if(!e)throw new Error("useInstallationProps must be used within an InstallationProvider");return e}function ba({children:e,integration:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i}){const s=b.useMemo(()=>({integrationNameOrId:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i}),[t,n,r,o,i]);return u.jsx(Ml.Provider,{value:s,children:u.jsx(jw,{initialConfig:{},children:e})})}class Js{constructor(t){this.connectionApi=new yw(t),this.installationApi=new vw(t),this.integrationApi=new ww(t),this.oAuthApi=new bw(t),this.projectApi=new Iw(t),this.providerApi=new Cw(t),this.providerAppApi=new Sw(t),this.revisionApi=new xw(t)}}const kl="2.8.9",$w="v1",ro="https://api.withampersand.com";function Ll(){try{const e=process.env.REACT_APP_AMP_SERVER;switch(e){case"local":return"http://localhost:8080";case"dev":return"https://dev-api.withampersand.com";case"staging":return"https://staging-api.withampersand.com";case"prod":return ro;case"mock":return"http://127.0.0.1:4010";case"":return ro;default:return e??ro}}catch{return ro}}const Uw=(e,t)=>`${e}/${t}`;function qw(){return Uw(Ll(),$w)}const jl=Ll(),Kl=qw(),Vw=new ha({basePath:Kl,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":kl}});let Hw=new Js(Vw);const $l=()=>Hw,Bw=e=>({header:"X-Api-Key",value:e}),Jw=e=>{try{return{header:"Authorization",value:`Bearer ${e}`}}catch(t){throw console.error("Failed to get JWT token for API authentication:",t),new Error("Failed to authenticate with JWT token")}},Kc=(e,t)=>new ha({basePath:Kl,headers:{"X-Amp-Client":"react","X-Amp-Client-Version":kl,[e]:t}});function it(){const e=Yu(),{getToken:t}=Gh(),{consumerRef:n,groupRef:r}=Tr();return b.useCallback(async()=>{if(e){const i=Bw(e),s=Kc(i.header,i.value);return new Js(s)}if(t){if(!n||!r)throw console.error("Unable to create JWT API service without consumerRef or groupRef.",{consumerRef:n,groupRef:r}),new Error("Unable to create JWT API service without consumerRef or groupRef.");const i=await t({consumerRef:n,groupRef:r}),s=Jw(i),a=Kc(s.header,s.value);return new Js(a)}throw console.error("Unable to create API service without API key or JWT token."),new Error("Unable to create API service without API key or JWT token.")},[e,t,n,r])}const Ia=({groupRef:e,provider:t})=>{const{projectIdOrName:n}=Pe(),r=it();return Zn({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})};function Ww(){return u.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.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"}),u.jsx("path",{d:"M24 18V26",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M24 34H24.02",stroke:"#7F1D1D",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]})}const zw="_box_1p7c5_1",$c={box:zw};function _n({children:e,className:t,style:n}){return u.jsx("div",{className:t?`${$c.box} ${t}`:$c.box,style:n,children:e})}const Gw="_container_1wvzr_1",Uc={container:Gw};function ui({children:e,className:t,style:n}){return u.jsx("div",{className:t?`${Uc.container} ${t}`:Uc.container,style:n,children:e})}const Qw="_errorBoxContainer_4sdb2_1",Xw="_errorBox_4sdb2_1",Yw="_errorText_4sdb2_20",Ws={errorBoxContainer:Qw,errorBox:Xw,errorText:Yw};function Ul({message:e}){return u.jsx(_n,{className:Ws.errorBox,children:u.jsx("p",{className:Ws.errorText,children:e})})}function ql({message:e,children:t}){return u.jsxs(ui,{className:Ws.errorBoxContainer,children:[u.jsx(Ww,{}),u.jsx(Ul,{message:e}),t]})}const Zw="_loader_6ubm6_1",eb={loader:Zw};function tb(){return u.jsx("span",{className:eb.loader})}function Ni(){return u.jsx("div",{style:{display:"flex",width:"100%",height:"100%",justifyContent:"center",marginTop:"20%",marginBottom:"20%"},children:u.jsx(tb,{})})}function Vl({children:e}){return u.jsx(ui,{style:{maxWidth:"55rem"},children:u.jsx(_n,{children:e})})}function li(){return u.jsx(Vl,{children:u.jsx(Ni,{})})}function $t({message:e,children:t}){return u.jsx(Vl,{children:u.jsx(ql,{message:e,children:t})})}function un(e){return e.charAt(0).toUpperCase()+e.slice(1)}function nb(e,t){return(t==null?void 0:t.displayName)??un(e)}const rb=e=>e.split(`
|
|
6
|
+
`).filter(n=>n.trim()!==""),ib=(e,t)=>(t==null?void 0:t.length)===0||!e?null:t.find(n=>n.name===e)??null,ob=e=>e.replace(/[.:/\\]/g,"\\$&");function sb(e){return!e||typeof e!="string"?"id_"+Math.random().toString(36).substr(2,9):e.toLowerCase().replace(/[^a-z0-9_-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"").replace(/^[^a-z]/,"id-").substring(0,50)}const ab=()=>{const[e,t]=b.useState(!1),n=b.useCallback(()=>{t(!0)},[t]),r=b.useCallback(()=>{t(!1)},[t]);return{isIntegrationDeleted:e,setIntegrationDeleted:n,resetIntegrationDeleted:r}},Hl=b.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:()=>{},resetComponent:()=>{}});function Ze(){const e=b.useContext(Hl);if(!e)throw new Error("useInstallIntegrationProps must be used within an InstallIntegrationProvider");return e}function cb({children:e,integration:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,onInstallSuccess:s,onUpdateSuccess:a,onUninstallSuccess:c,fieldMapping:f,resetComponent:d}){const{data:l}=$o(),{setError:m,isError:g,removeError:v}=qt(),{isIntegrationDeleted:w,setIntegrationDeleted:h,resetIntegrationDeleted:S}=ab(),p=b.useMemo(()=>ib(t,l||[]),[t,l]),{data:y,isLoading:I,isError:x,error:T}=va(t,o),E=(y==null?void 0:y[0])||null;b.useEffect(()=>{S()},[t,n,r,o,i,f]),b.useEffect(()=>{p===null&&(l!=null&&l.length)&&console.error(`Integration "${t}" not found in integration list`)},[t,p,l]),b.useEffect(()=>{x?(m(ue.INSTALLATION_LIST,(p==null?void 0:p.id)||""),$e(T)):v(ue.INSTALLATION_LIST,(p==null?void 0:p.id)||"")},[x,p,m,v,T]);const A=Ue(),R=b.useCallback(()=>{A.invalidateQueries({queryKey:["amp","installations"]})},[A]),P=b.useCallback(V=>{A.setQueryData(["amp","installations"],[V]),A.invalidateQueries({queryKey:["amp","installations"]})},[A]),K=(p==null?void 0:p.id)||"",q=b.useMemo(()=>({integrationId:(p==null?void 0:p.id)||"",provider:(p==null?void 0:p.provider)||"",integrationObj:p,consumerRef:n,consumerName:r,groupRef:o,groupName:i,installation:E||void 0,setInstallation:P,resetInstallations:R,onInstallSuccess:s,onUpdateSuccess:a,onUninstallSuccess:c,isIntegrationDeleted:w,setIntegrationDeleted:h,fieldMapping:f,resetComponent:d}),[p,n,r,o,i,E,P,R,s,a,c,w,h,f,d]);if(I)return u.jsx(li,{});if(p===null)return u.jsx($t,{message:`Integration "${t}" not found`});if(g(ue.INSTALLATION_LIST,K)){const V=`Error retrieving installation information for integration "${(p==null?void 0:p.name)||"unknown"}"`;return u.jsx($t,{message:V})}return u.jsx(Hl.Provider,{value:q,children:e})}const Bl=b.createContext({connections:null,isConnectionsLoading:!0,selectedConnection:null,setConnections:()=>{},setSelectedConnection:()=>{}}),en=()=>{const e=b.useContext(Bl);if(!e)throw new Error("useConnections must be used within a ConnectionsProvider");return e};function Jl({groupRef:e,provider:t,children:n}){const r=Ue(),{setError:o,isError:i}=qt(),{projectIdOrName:s,isLoading:a}=tr(),{integrationId:c,groupRef:f}=Ze(),{provider:d}=ci(c),{data:l,isLoading:m,isError:g,error:v}=Ia({groupRef:e||f,provider:d||t}),w=l==null?void 0:l[0],h=b.useCallback(y=>{r.setQueryData(["amp","connections"],()=>y),r.invalidateQueries({queryKey:["amp","connections"]})},[r]),S=b.useCallback(()=>{r.invalidateQueries({queryKey:["amp","connections"]})},[r]);b.useEffect(()=>{g?(o(ue.CONNECTION_LIST,s,!0),$e(v)):o(ue.CONNECTION_LIST,s,!1)},[g,o,s,v]);const p=b.useMemo(()=>({connections:l||null,isConnectionsLoading:m,selectedConnection:w||null,setConnections:h,setSelectedConnection:S}),[l,m,w,h,S]);if(m||a)return u.jsx(li,{});if(s&&i(ue.PROJECT,s))return u.jsx($t,{message:`Error loading project ${s}`});if(s&&i(ue.CONNECTION_LIST,s))return u.jsx($t,{message:"Error retrieving existing connections"});if(!s)throw new Error("Project ID or Project Name not found. ConnectionsProvider must be used within AmpersandProvider");return u.jsx(Bl.Provider,{value:p,children:n})}const Wl=()=>{const e=it(),t=Ue(),[n,r]=b.useState(null);return{...En({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"),$e(i,r)}}),errorMsg:n}};function ub(e){return typeof e.provider=="string"}function lb(e){if(!ub(e))throw new Error("Config must have a provider field for creation");return e}function zl(){const{projectIdOrName:e}=Pe(),{groupRef:t,integrationNameOrId:n}=Tr(),{data:r}=ci(n),{connection:o}=wa(),{installation:i}=ki(),s=Ue(),{mutate:a,isIdle:c,isPending:f,error:d,errorMsg:l}=Wl();return{createInstallation:({config:g,onSuccess:v,onError:w,onSettled:h})=>{if(i)throw Error("Installation already created. Try updating instead.");if(!r)throw Error("No integration found");const S={projectIdOrName:e,integrationId:r==null?void 0:r.id,installation:{groupRef:t,connectionId:o==null?void 0:o.id,config:{content:lb(g)}}};return a(S,{onSuccess:p=>{v==null||v(p)},onError:p=>{w==null||w(p)},onSettled:()=>{h==null||h(),s.invalidateQueries({queryKey:["amp","installations"]})}})},isIdle:c,isPending:f,error:d,errorMsg:l}}const db=()=>{const e=it(),t=Ue(),[n,r]=b.useState(null);return{...En({mutationKey:["updateInstallation"],mutationFn:async i=>(await e()).installationApi.updateInstallation(i),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","installations"]}),r(null)},onError:i=>{console.error("Error updating installation"),$e(i,r)}}),errorMsg:n}};function fb(){const{projectIdOrName:e}=Pe(),{integrationNameOrId:t}=Tr(),{data:n}=ci(t),{installation:r}=ki(),o=Ue(),{mutate:i,isIdle:s,isPending:a,error:c,errorMsg:f}=db();return{updateInstallation:({config:l,onSuccess:m,onError:g,onSettled:v})=>{var S,p;if(!r)throw Error("Installation not created yet. Try creating the installation first.");if(!n)throw Error("No integration found");const w=[];if((S=l==null?void 0:l.write)!=null&&S.objects&&Object.keys(l.write.objects).length>0&&w.push("config.content.write.objects"),(p=l==null?void 0:l.read)!=null&&p.objects){const y=Object.keys(l.read.objects);w.push(...y.map(I=>`config.content.read.objects.${I}`))}const h={projectIdOrName:e,integrationId:n==null?void 0:n.id,installationId:r.id,installationUpdate:{updateMask:w,installation:{config:{content:l}}}};return i(h,{onSuccess:y=>{m==null||m(y)},onError:y=>{g==null||g(y)},onSettled:()=>{v==null||v(),o.invalidateQueries({queryKey:["amp","installations"]})}})},isIdle:s,isPending:a,error:c,errorMsg:f}}const pb=()=>{const e=it(),t=Ue(),[n,r]=b.useState(null);return{...En({mutationKey:["deleteInstallation"],mutationFn:async i=>(await e()).installationApi.deleteInstallation(i),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","installations"]}),r(null)},onError:i=>{console.error("Error deleting installation"),$e(i,r)}}),errorMsg:n}};function hb(){const{projectIdOrName:e}=Pe(),{integrationNameOrId:t}=Tr(),{data:n}=ci(t),{installation:r}=ki(),o=Ue(),{mutate:i,isIdle:s,isPending:a,error:c,errorMsg:f}=pb();return{deleteInstallation:({onSuccess:l,onError:m,onSettled:g})=>{if(!r)throw Error("Installation not found. Not able to delete installation.");if(!n)throw Error("No integration found");return i({projectIdOrName:e,integrationId:n==null?void 0:n.id,installationId:r.id},{onSuccess:()=>{l==null||l()},onError:v=>{m==null||m(v)},onSettled:()=>{g==null||g(),o.invalidateQueries({queryKey:["amp","installations"]}),o.invalidateQueries({queryKey:["amp","connections"]})}})},isIdle:s,isPending:a,error:c,errorMsg:f}}function Gl(){const[e,t]=b.useState(1);return{seed:e,reset:()=>{t(Math.random())}}}var io=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ca(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xo={exports:{}};xo.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",o=1,i=2,s=9007199254740991,a="[object Arguments]",c="[object Array]",f="[object AsyncFunction]",d="[object Boolean]",l="[object Date]",m="[object Error]",g="[object Function]",v="[object GeneratorFunction]",w="[object Map]",h="[object Number]",S="[object Null]",p="[object Object]",y="[object Promise]",I="[object Proxy]",x="[object RegExp]",T="[object Set]",E="[object String]",A="[object Symbol]",R="[object Undefined]",P="[object WeakMap]",K="[object ArrayBuffer]",q="[object DataView]",V="[object Float32Array]",M="[object Float64Array]",se="[object Int8Array]",oe="[object Int16Array]",ge="[object Int32Array]",me="[object Uint8Array]",Oe="[object Uint8ClampedArray]",F="[object Uint16Array]",$="[object Uint32Array]",J=/[\\^$.*+?()[\]{}|]/g,B=/^\[object .+?Constructor\]$/,U=/^(?:0|[1-9]\d*)$/,k={};k[V]=k[M]=k[se]=k[oe]=k[ge]=k[me]=k[Oe]=k[F]=k[$]=!0,k[a]=k[c]=k[K]=k[d]=k[q]=k[l]=k[m]=k[g]=k[w]=k[h]=k[p]=k[x]=k[T]=k[E]=k[P]=!1;var Q=typeof io=="object"&&io&&io.Object===Object&&io,Z=typeof self=="object"&&self&&self.Object===Object&&self,Y=Q||Z||Function("return this")(),ee=t&&!t.nodeType&&t,te=ee&&!0&&e&&!e.nodeType&&e,le=te&&te.exports===ee,L=le&&Q.process,we=function(){try{return L&&L.binding&&L.binding("util")}catch{}}(),W=we&&we.isTypedArray;function ot(C,N){for(var D=-1,X=C==null?0:C.length,Ae=0,de=[];++D<X;){var je=C[D];N(je,D,C)&&(de[Ae++]=je)}return de}function _e(C,N){for(var D=-1,X=N.length,Ae=C.length;++D<X;)C[Ae+D]=N[D];return C}function mt(C,N){for(var D=-1,X=C==null?0:C.length;++D<X;)if(N(C[D],D,C))return!0;return!1}function Je(C,N){for(var D=-1,X=Array(C);++D<C;)X[D]=N(D);return X}function gt(C){return function(N){return C(N)}}function Ee(C,N){return C.has(N)}function et(C,N){return C==null?void 0:C[N]}function xt(C){var N=-1,D=Array(C.size);return C.forEach(function(X,Ae){D[++N]=[Ae,X]}),D}function Vt(C,N){return function(D){return C(N(D))}}function Pt(C){var N=-1,D=Array(C.size);return C.forEach(function(X){D[++N]=X}),D}var lt=Array.prototype,st=Function.prototype,Me=Object.prototype,qe=Y["__core-js_shared__"],Ft=st.toString,tt=Me.hasOwnProperty,Ar=function(){var C=/[^.]+$/.exec(qe&&qe.keys&&qe.keys.IE_PROTO||"");return C?"Symbol(src)_1."+C:""}(),pn=Me.toString,hn=RegExp("^"+Ft.call(tt).replace(J,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),yt=le?Y.Buffer:void 0,Te=Y.Symbol,or=Y.Uint8Array,Tn=Me.propertyIsEnumerable,An=lt.splice,Ot=Te?Te.toStringTag:void 0,mn=Object.getOwnPropertySymbols,Rn=yt?yt.isBuffer:void 0,Pn=Vt(Object.keys,Object),gn=Rr(Y,"DataView"),nn=Rr(Y,"Map"),ke=Rr(Y,"Promise"),at=Rr(Y,"Set"),re=Rr(Y,"WeakMap"),fe=Rr(Object,"create"),dt=ar(gn),yn=ar(nn),z=ar(ke),ae=ar(at),ce=ar(re),Le=Te?Te.prototype:void 0,He=Le?Le.valueOf:void 0;function Ge(C){var N=-1,D=C==null?0:C.length;for(this.clear();++N<D;){var X=C[N];this.set(X[0],X[1])}}function Dt(){this.__data__=fe?fe(null):{},this.size=0}function nt(C){var N=this.has(C)&&delete this.__data__[C];return this.size-=N?1:0,N}function vt(C){var N=this.__data__;if(fe){var D=N[C];return D===r?void 0:D}return tt.call(N,C)?N[C]:void 0}function Ne(C){var N=this.__data__;return fe?N[C]!==void 0:tt.call(N,C)}function Fn(C,N){var D=this.__data__;return this.size+=this.has(C)?0:1,D[C]=fe&&N===void 0?r:N,this}Ge.prototype.clear=Dt,Ge.prototype.delete=nt,Ge.prototype.get=vt,Ge.prototype.has=Ne,Ge.prototype.set=Fn;function Ht(C){var N=-1,D=C==null?0:C.length;for(this.clear();++N<D;){var X=C[N];this.set(X[0],X[1])}}function Zo(){this.__data__=[],this.size=0}function Hi(C){var N=this.__data__,D=zi(N,C);if(D<0)return!1;var X=N.length-1;return D==X?N.pop():An.call(N,D,1),--this.size,!0}function Bi(C){var N=this.__data__,D=zi(N,C);return D<0?void 0:N[D][1]}function Ji(C){return zi(this.__data__,C)>-1}function Wi(C,N){var D=this.__data__,X=zi(D,C);return X<0?(++this.size,D.push([C,N])):D[X][1]=N,this}Ht.prototype.clear=Zo,Ht.prototype.delete=Hi,Ht.prototype.get=Bi,Ht.prototype.has=Ji,Ht.prototype.set=Wi;function rn(C){var N=-1,D=C==null?0:C.length;for(this.clear();++N<D;){var X=C[N];this.set(X[0],X[1])}}function ve(){this.size=0,this.__data__={hash:new Ge,map:new(nn||Ht),string:new Ge}}function Bt(C){var N=Gi(this,C).delete(C);return this.size-=N?1:0,N}function pi(C){return Gi(this,C).get(C)}function sr(C){return Gi(this,C).has(C)}function es(C,N){var D=Gi(this,C),X=D.size;return D.set(C,N),this.size+=D.size==X?0:1,this}rn.prototype.clear=ve,rn.prototype.delete=Bt,rn.prototype.get=pi,rn.prototype.has=sr,rn.prototype.set=es;function Dn(C){var N=-1,D=C==null?0:C.length;for(this.__data__=new rn;++N<D;)this.add(C[N])}function tp(C){return this.__data__.set(C,r),this}function np(C){return this.__data__.has(C)}Dn.prototype.add=Dn.prototype.push=tp,Dn.prototype.has=np;function Mn(C){var N=this.__data__=new Ht(C);this.size=N.size}function rp(){this.__data__=new Ht,this.size=0}function ip(C){var N=this.__data__,D=N.delete(C);return this.size=N.size,D}function op(C){return this.__data__.get(C)}function sp(C){return this.__data__.has(C)}function ap(C,N){var D=this.__data__;if(D instanceof Ht){var X=D.__data__;if(!nn||X.length<n-1)return X.push([C,N]),this.size=++D.size,this;D=this.__data__=new rn(X)}return D.set(C,N),this.size=D.size,this}Mn.prototype.clear=rp,Mn.prototype.delete=ip,Mn.prototype.get=op,Mn.prototype.has=sp,Mn.prototype.set=ap;function cp(C,N){var D=Qi(C),X=!D&&Sp(C),Ae=!D&&!X&&ts(C),de=!D&&!X&&!Ae&&fc(C),je=D||X||Ae||de,Qe=je?Je(C.length,String):[],rt=Qe.length;for(var Fe in C)tt.call(C,Fe)&&!(je&&(Fe=="length"||Ae&&(Fe=="offset"||Fe=="parent")||de&&(Fe=="buffer"||Fe=="byteLength"||Fe=="byteOffset")||vp(Fe,rt)))&&Qe.push(Fe);return Qe}function zi(C,N){for(var D=C.length;D--;)if(cc(C[D][0],N))return D;return-1}function up(C,N,D){var X=N(C);return Qi(C)?X:_e(X,D(C))}function hi(C){return C==null?C===void 0?R:S:Ot&&Ot in Object(C)?gp(C):Cp(C)}function ic(C){return mi(C)&&hi(C)==a}function oc(C,N,D,X,Ae){return C===N?!0:C==null||N==null||!mi(C)&&!mi(N)?C!==C&&N!==N:lp(C,N,D,X,oc,Ae)}function lp(C,N,D,X,Ae,de){var je=Qi(C),Qe=Qi(N),rt=je?c:kn(C),Fe=Qe?c:kn(N);rt=rt==a?p:rt,Fe=Fe==a?p:Fe;var Et=rt==p,Jt=Fe==p,ct=rt==Fe;if(ct&&ts(C)){if(!ts(N))return!1;je=!0,Et=!1}if(ct&&!Et)return de||(de=new Mn),je||fc(C)?sc(C,N,D,X,Ae,de):hp(C,N,rt,D,X,Ae,de);if(!(D&o)){var Mt=Et&&tt.call(C,"__wrapped__"),kt=Jt&&tt.call(N,"__wrapped__");if(Mt||kt){var Ln=Mt?C.value():C,vn=kt?N.value():N;return de||(de=new Mn),Ae(Ln,vn,D,X,de)}}return ct?(de||(de=new Mn),mp(C,N,D,X,Ae,de)):!1}function dp(C){if(!dc(C)||bp(C))return!1;var N=uc(C)?hn:B;return N.test(ar(C))}function fp(C){return mi(C)&&lc(C.length)&&!!k[hi(C)]}function pp(C){if(!Ip(C))return Pn(C);var N=[];for(var D in Object(C))tt.call(C,D)&&D!="constructor"&&N.push(D);return N}function sc(C,N,D,X,Ae,de){var je=D&o,Qe=C.length,rt=N.length;if(Qe!=rt&&!(je&&rt>Qe))return!1;var Fe=de.get(C);if(Fe&&de.get(N))return Fe==N;var Et=-1,Jt=!0,ct=D&i?new Dn:void 0;for(de.set(C,N),de.set(N,C);++Et<Qe;){var Mt=C[Et],kt=N[Et];if(X)var Ln=je?X(kt,Mt,Et,N,C,de):X(Mt,kt,Et,C,N,de);if(Ln!==void 0){if(Ln)continue;Jt=!1;break}if(ct){if(!mt(N,function(vn,cr){if(!Ee(ct,cr)&&(Mt===vn||Ae(Mt,vn,D,X,de)))return ct.push(cr)})){Jt=!1;break}}else if(!(Mt===kt||Ae(Mt,kt,D,X,de))){Jt=!1;break}}return de.delete(C),de.delete(N),Jt}function hp(C,N,D,X,Ae,de,je){switch(D){case q:if(C.byteLength!=N.byteLength||C.byteOffset!=N.byteOffset)return!1;C=C.buffer,N=N.buffer;case K:return!(C.byteLength!=N.byteLength||!de(new or(C),new or(N)));case d:case l:case h:return cc(+C,+N);case m:return C.name==N.name&&C.message==N.message;case x:case E:return C==N+"";case w:var Qe=xt;case T:var rt=X&o;if(Qe||(Qe=Pt),C.size!=N.size&&!rt)return!1;var Fe=je.get(C);if(Fe)return Fe==N;X|=i,je.set(C,N);var Et=sc(Qe(C),Qe(N),X,Ae,de,je);return je.delete(C),Et;case A:if(He)return He.call(C)==He.call(N)}return!1}function mp(C,N,D,X,Ae,de){var je=D&o,Qe=ac(C),rt=Qe.length,Fe=ac(N),Et=Fe.length;if(rt!=Et&&!je)return!1;for(var Jt=rt;Jt--;){var ct=Qe[Jt];if(!(je?ct in N:tt.call(N,ct)))return!1}var Mt=de.get(C);if(Mt&&de.get(N))return Mt==N;var kt=!0;de.set(C,N),de.set(N,C);for(var Ln=je;++Jt<rt;){ct=Qe[Jt];var vn=C[ct],cr=N[ct];if(X)var pc=je?X(cr,vn,ct,N,C,de):X(vn,cr,ct,C,N,de);if(!(pc===void 0?vn===cr||Ae(vn,cr,D,X,de):pc)){kt=!1;break}Ln||(Ln=ct=="constructor")}if(kt&&!Ln){var Xi=C.constructor,Yi=N.constructor;Xi!=Yi&&"constructor"in C&&"constructor"in N&&!(typeof Xi=="function"&&Xi instanceof Xi&&typeof Yi=="function"&&Yi instanceof Yi)&&(kt=!1)}return de.delete(C),de.delete(N),kt}function ac(C){return up(C,Ep,yp)}function Gi(C,N){var D=C.__data__;return wp(N)?D[typeof N=="string"?"string":"hash"]:D.map}function Rr(C,N){var D=et(C,N);return dp(D)?D:void 0}function gp(C){var N=tt.call(C,Ot),D=C[Ot];try{C[Ot]=void 0;var X=!0}catch{}var Ae=pn.call(C);return X&&(N?C[Ot]=D:delete C[Ot]),Ae}var yp=mn?function(C){return C==null?[]:(C=Object(C),ot(mn(C),function(N){return Tn.call(C,N)}))}:_p,kn=hi;(gn&&kn(new gn(new ArrayBuffer(1)))!=q||nn&&kn(new nn)!=w||ke&&kn(ke.resolve())!=y||at&&kn(new at)!=T||re&&kn(new re)!=P)&&(kn=function(C){var N=hi(C),D=N==p?C.constructor:void 0,X=D?ar(D):"";if(X)switch(X){case dt:return q;case yn:return w;case z:return y;case ae:return T;case ce:return P}return N});function vp(C,N){return N=N??s,!!N&&(typeof C=="number"||U.test(C))&&C>-1&&C%1==0&&C<N}function wp(C){var N=typeof C;return N=="string"||N=="number"||N=="symbol"||N=="boolean"?C!=="__proto__":C===null}function bp(C){return!!Ar&&Ar in C}function Ip(C){var N=C&&C.constructor,D=typeof N=="function"&&N.prototype||Me;return C===D}function Cp(C){return pn.call(C)}function ar(C){if(C!=null){try{return Ft.call(C)}catch{}try{return C+""}catch{}}return""}function cc(C,N){return C===N||C!==C&&N!==N}var Sp=ic(function(){return arguments}())?ic:function(C){return mi(C)&&tt.call(C,"callee")&&!Tn.call(C,"callee")},Qi=Array.isArray;function xp(C){return C!=null&&lc(C.length)&&!uc(C)}var ts=Rn||Np;function Op(C,N){return oc(C,N)}function uc(C){if(!dc(C))return!1;var N=hi(C);return N==g||N==v||N==f||N==I}function lc(C){return typeof C=="number"&&C>-1&&C%1==0&&C<=s}function dc(C){var N=typeof C;return C!=null&&(N=="object"||N=="function")}function mi(C){return C!=null&&typeof C=="object"}var fc=W?gt(W):fp;function Ep(C){return xp(C)?cp(C):pp(C)}function _p(){return[]}function Np(){return!1}e.exports=Op})(xo,xo.exports);var mb=xo.exports;const Ql=Ca(mb),Er="other",Oo="manage-tab";function nr(e){return!e.fieldName}function gb(e,t){var n;return((n=e==null?void 0:e.objects)==null?void 0:n.find(r=>r.objectName===t))||null}function yb(e){var t;return((t=e==null?void 0:e.requiredFields)==null?void 0:t.filter(n=>!nr(n)&&!!n.fieldName))||null}function vb(e){var n;return((n=e==null?void 0:e.requiredFields)==null?void 0:n.filter(r=>nr(r)&&!!r.mapToName))||[]}function wb(e){var n;return((n=e==null?void 0:e.optionalFields)==null?void 0:n.filter(r=>nr(r)&&!!r.mapToName))||[]}function bb(e){var t;return((t=e==null?void 0:e.optionalFields)==null?void 0:t.filter(n=>!nr(n)&&!!n.fieldName))||null}const Xl=(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 Ib(e){return nr(e)?e.mapToName:e.fieldName}const Yl=(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)&&un(s==null?void 0:s.objectName),completed:e?!!Xl(e,s.objectName):!1})}),n},Zl=e=>{var n;return{name:Er,completed:e?!!((n=e==null?void 0:e.content)!=null&&n.write):!1}};function Cb(e,t){var i;const n=Yl(e,t),o=!!((i=t==null?void 0:t.content)!=null&&i.write)?Zl(e):void 0;return o&&n.push(o),n}function ed(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 Sb(e,t){return Ql(e,t)}function td(e,t){return Ql(e,t)}const xb=(e,t,n)=>{var h,S,p,y,I,x,T,E,A;if(!e)return null;const r=gb(e,t),o=r&&yb(r),i=r&&bb(r),s=r&&vb(r),a=r&&wb(r),c=(r==null?void 0:r.allFields)||[],f=(r==null?void 0:r.allFieldsMetadata)||{},d=n==null?void 0:n.content,l=((p=(S=(h=d==null?void 0:d.read)==null?void 0:h.objects)==null?void 0:S[t])==null?void 0:p.selectedFields)||{},m=((x=(I=(y=d==null?void 0:d.read)==null?void 0:y.objects)==null?void 0:I[t])==null?void 0:x.selectedValueMappings)||{},g=((A=(E=(T=d==null?void 0:d.read)==null?void 0:T.objects)==null?void 0:E[t])==null?void 0:A.selectedFieldMappings)||{},v=Object.entries(l).reduce((R,[P,K])=>((i==null?void 0:i.some(V=>!nr(V)&&"fieldName"in V&&V.fieldName===P))&&(R[P]=K),R),{}),w={...g};return{allFields:c,allFieldsMetadata:f,requiredFields:o,optionalFields:i,requiredMapFields:s,optionalMapFields:a,selectedOptionalFields:v,selectedFieldMappings:g,selectedValueMappings:m,isOptionalFieldsModified:!1,isRequiredMapFieldsModified:!1,isValueMappingsModified:!1,savedConfig:{optionalFields:v,requiredMapFields:w,selectedValueMappings:m}}},Ob=(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 nd(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:xb(r,t,n),write:Ob(o,n)}}const rd=(e,t,n,r)=>{const o=nd(e,n,t);r(n,o)},Eb=(e,t,n)=>{const r=Cb(t,e),o={};r.forEach(({name:i,completed:s})=>{s&&(o[i]=nd(e,i,t))}),n(o)},id=e=>{const{requiredFields:t,selectedOptionalFields:n}=(e==null?void 0:e.read)||{},r=new Set;return t==null||t.forEach(i=>r.add(Ib(i))),{...Array.from(r).reduce((i,s)=>({...i,[s]:!0}),{}),...n||{}}},od=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},sd=e=>{const{selectedValueMappings:t}=(e==null?void 0:e.read)||{};return t};function ad(e,t){return t[e]||void 0}function Li(e){var t;return(t=e.content.proxy)==null?void 0:t.enabled}const _b=(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)},Nb=(e,t,n,r)=>{const o=id(e),i=od(e),s=sd(e),a=_b(n,t);if(!a)return console.error(`Error when getting object from hydratedRevision for objectName: ${t}`),null;const c={createdBy:`consumer:${r}`,content:{provider:n.content.provider,read:{objects:{[t]:{objectName:t,selectedFields:o,selectedFieldMappings:i,selectedValueMappings:s||{},backfill:a.backfill}}}}};return Li(n)&&(c.content.proxy={enabled:!0}),c},cd=e=>{var t;return{...(t=e.write)==null?void 0:t.selectedWriteObjects}},Tb=e=>{const t=e.content.write;return t==null?void 0:t.objects},Ab=(e,t,n)=>{if(!Tb(t))return console.error("Error when getting write objects from hydratedRevision"),null;const o=cd(e),i={createdBy:`consumer:${n}`,content:{provider:t.content.provider,read:{objects:{}},write:{objects:o}}};return Li(t)&&(i.content.proxy={enabled:!0}),i};var ud={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})()})(dd);var Pb=dd.exports;const $t=Ia(Pb),Fb="_button_kwfiu_1",Db="_buttonError_kwfiu_28",Mb="_danger_kwfiu_42",kb="_ghost_kwfiu_47",cs={button:Fb,buttonError:Db,danger:Mb,ghost:kb};function Je({className:e,style:t,type:n,children:r,variant:o,...i}){const s=$t(cs.button,{[cs.danger]:o==="danger",[cs.ghost]:o==="ghost",[e||""]:!!e});return l.jsx("button",{type:n,className:s,style:t,...i,children:r})}const Lb={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 ki({children:e,style:t}){return l.jsx(_n,{style:{...Lb,...t},children:e})}const Uo=e=>{const t=it(),{provider:n}=Ze(),r=e||n;return er({queryKey:["amp","providerInfo",r],queryFn:async()=>{if(!r)throw new Error("Provider not found");return(await t()).providerApi.getProvider({provider:r})},enabled:!!r})},lt=e=>{const t=Uo(e),{data:n}=t,{provider:r}=Ze(),o=n&&ab(n==null?void 0:n.name,n);return{...t,providerName:o,selectedProvider:e||r}};function dn({error:e}){return e?l.jsx(ki,{style:{marginTop:"2em"},children:e}):null}const jb="_input_1ymb7_1",Kb="_inputError_1ymb7_27",Ub="_error_1ymb7_43",ls={input:jb,inputError:Kb,error:Ub};function $b({id:e,type:t,className:n,isError:r=!1,...o}){const i=r?$t(ls.inputError,ls.input):ls.input;return l.jsx("input",{id:e,type:t,className:$t(i,n),...o})}function qb(){return l.jsx("svg",{width:"22",height:"22",viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:l.jsxs("g",{opacity:"0.5",children:[l.jsx("path",{d:"M14.2821 11.0004C14.2821 12.8154 12.8154 14.2821 11.0004 14.2821C9.18542 14.2821 7.71875 12.8154 7.71875 11.0004C7.71875 9.18542 9.18542 7.71875 11.0004 7.71875C12.8154 7.71875 14.2821 9.18542 14.2821 11.0004Z",stroke:"currentColor",strokeWidth:"1.375",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M10.9999 18.581C14.2357 18.581 17.2515 16.6743 19.3507 13.3743C20.1757 12.0818 20.1757 9.90932 19.3507 8.61682C17.2515 5.31682 14.2357 3.41016 10.9999 3.41016C7.76402 3.41016 4.74819 5.31682 2.64902 8.61682C1.82402 9.90932 1.82402 12.0818 2.64902 13.3743C4.74819 16.6743 7.76402 18.581 10.9999 18.581Z",stroke:"currentColor",strokeWidth:"1.375",strokeLinecap:"round",strokeLinejoin:"round"})]})})}function Vb(){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",viewBox:"0 0 22 22",fill:"none",children:[l.jsx("path",{d:"M13.3187 8.68036L8.68036 13.3187C8.06528 12.7036 7.71973 11.8694 7.71973 10.9995C7.71973 10.5688 7.80456 10.1423 7.96939 9.7444C8.13421 9.34648 8.3758 8.98491 8.68036 8.68036C8.98491 8.3758 9.34648 8.13421 9.7444 7.96939C10.1423 7.80456 10.5688 7.71973 10.9995 7.71973C11.8694 7.71973 12.7036 8.06528 13.3187 8.68036Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M16.3349 5.28895C14.7307 4.07895 12.8974 3.41895 10.9999 3.41895C7.76402 3.41895 4.74819 5.32561 2.64902 8.62561C1.82402 9.91811 1.82402 12.0906 2.64902 13.3831C3.37319 14.5198 4.21652 15.5006 5.13319 16.2889M7.71819 17.9023C8.76319 18.3423 9.87236 18.5806 10.9999 18.5806C14.2357 18.5806 17.2515 16.6739 19.3507 13.3739C20.1757 12.0814 20.1757 9.90895 19.3507 8.61645C19.0482 8.13978 18.7182 7.69061 18.379 7.26895",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M14.2172 11.6413C14.093 12.2808 13.7806 12.8685 13.32 13.3291C12.8594 13.7897 12.2716 14.1022 11.6322 14.2263M8.68051 13.3188L1.83301 20.1663M20.1663 1.83301L13.3188 8.68051",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Hb({id:e,name:t,placeholder:n="Password",onChange:r,value:o,className:i,isError:s}){const[a,c]=b.useState(!1),d=()=>c(u=>!u);return l.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[l.jsx(xt.Input,{id:e,name:t,type:a?"text":"password",placeholder:n,onChange:r,value:o,className:i,isError:s}),l.jsx(Je,{type:"button","aria-label":a?"Hide password":"Show password",style:{height:"2.5rem",width:"2.5rem",display:"flex",alignItems:"center",justifyContent:"center"},onClick:d,variant:"ghost",children:l.jsx("span",{style:{height:"1.5rem",width:"1.5rem"},children:a?l.jsx(Vb,{}):l.jsx(qb,{})})})]})}const Jb="_textarea_18zl4_1",Wb="_textareaError_18zl4_14",Bb="_error_18zl4_29",us={textarea:Jb,textareaError:Wb,error:Bb};function zb({className:e,isError:t=!1,...n}){const r=t?$t(us.textareaError,us.textarea):us.textarea;return l.jsx("textarea",{className:$t(e,r),...n})}const xt={Input:$b,Textarea:zb,PasswordInput:Hb},Gb=()=>{const{projectIdOrName:e}=Re(),t=it();return er({queryKey:["project",e,"entitlements"],queryFn:async()=>{if(!e)throw new Error("Project ID is required");return(await t()).projectApi.getProject({projectIdOrName:e,includeEntitlements:!0})},enabled:!!e})};function fd(){var n,r;const{data:e}=Gb();return((r=(n=e==null?void 0:e.entitlements)==null?void 0:n.brandingRemoval)==null?void 0:r.value)===!0?null:l.jsxs("footer",{style:{backgroundColor:"light-dark(#EFEFEF, #646266)",padding:"1em",fontSize:"0.8em",color:"gray",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"0 0 4px 4px",gap:"0.4em"},children:[l.jsx("p",{style:{color:"light-dark(gray, #EFEFEF)"},children:"Secured by"}),l.jsx("a",{href:"https://www.withampersand.com/",target:"_blank","aria-label":"Go to Ampersand",rel:"noreferrer noopener",children:l.jsxs("picture",{children:[l.jsx("source",{srcSet:"https://res.cloudinary.com/dycvts6vp/image/upload/v1723671980/ampersand-logo-black.svg",media:"(prefers-color-scheme: light)"}),l.jsx("source",{srcSet:"https://res.cloudinary.com/dycvts6vp/image/upload/v1735853540/ampersand_logo_white.svg",media:"(prefers-color-scheme: dark)"}),l.jsx("img",{style:{height:".8em"},src:"https://res.cloudinary.com/dycvts6vp/image/upload/v1723671980/ampersand-logo-black.svg",alt:"Ampersand"})]})})]})}function rr({children:e}){return l.jsx(li,{children:l.jsxs(_n,{children:[l.jsx("div",{style:{padding:"3rem 2rem"},children:e}),l.jsx(fd,{})]})})}function ir({children:e}){return l.jsx("h1",{style:{fontWeight:600,lineHeight:1.2,fontSize:"1.2em"},children:e})}function Qb({children:e}){return l.jsx("p",{style:{padding:".5em 0"},children:e})}const Xb="_link_oo2kv_1",Yb={link:Xb};function Ca({href:e,className:t,style:n,label:r,children:o,newTab:i=!1}){return l.jsx("a",{className:$t(Yb.link,t),style:n,href:e,"aria-label":r||void 0,target:i?"_blank":"_self",rel:i?"noopener noreferrer":void 0,children:o})}function Eo({url:e,providerDisplayName:t,credentialName:n}){return l.jsxs("p",{style:{color:"var(--amp-colors-text-muted)"},children:[l.jsx(Ca,{href:e,newTab:!0,children:l.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," ","about where to find your ",t," ",n,"."]})}function $o(e,t){const n={},r=[];if(e.forEach(o=>{const i=t[o.name];!i||i.trim()===""?r.push(o.displayName||o.name):n[o.name]={value:i,source:"input"}}),r.length>0)throw new Error(`Please fill in the following required fields: ${r.join(", ")}.`);return n}function Zr(e,t){return e.every(n=>{const r=t[n.name];return r&&r.trim()!==""})}function pd({provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:r,buttonVariant:o,submitButtonType:i}){var x,h;const[s,a]=b.useState({apiKey:""}),c=((x=t.metadata)==null?void 0:x.input)||[],d=w=>{const{name:I,value:S}=w.currentTarget;a(A=>({...A,[I]:S.trim()}))},{apiKey:u}=s,{providerName:f}=lt(e),m=u.length>0,g=Zr(c,s),y=r||!m||!g,v=(h=t.apiKeyOpts)==null?void 0:h.docsURL,p=()=>{const w=$o(c,s);n({apiKey:u,providerMetadata:w})};return l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[v&&l.jsx(Eo,{url:v,providerDisplayName:f||ln(e),credentialName:"API key"}),l.jsx(xt.PasswordInput,{id:"apiKey",name:"apiKey",placeholder:"API Key",onChange:d}),c.map(w=>l.jsxs("div",{children:[w.docsURL&&l.jsx(Eo,{url:w.docsURL,providerDisplayName:f||ln(e),credentialName:w.displayName||w.name}),l.jsx(xt.Input,{id:w.name,name:w.name,type:"text",placeholder:w.displayName||w.name,onChange:d})]},w.name)),l.jsx(Je,{style:{marginTop:"1em",width:"100%"},disabled:y,type:i||"submit",onClick:p,variant:o,children:"Next"})]})}function Zb({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){const{providerName:i}=lt(e);return l.jsxs(rr,{children:[l.jsx(ir,{children:`Set up ${i} integration`}),l.jsx(dn,{error:r}),l.jsx(pd,{provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:o})]})}function eI({...e}){return l.jsx(Zb,{...e})}const tI={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 qo({children:e,style:t}){return l.jsx(_n,{style:{...tI,...t},children:e})}const xa=()=>{const e=it(),t=$e(),[n,r]=b.useState(null);return{...On({mutationKey:["updateConnection"],mutationFn:async i=>(await e()).connectionApi.updateConnection(i),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","connections"]}),r(null)}}),errorMsg:n}},nI="_divider_1kmoj_1",qc={divider:nI};function Vo({className:e,style:t}){return l.jsx("hr",{className:e?`${qc.divider} ${e}`:qc.divider,style:t})}function Rt({string:e}){return l.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"1rem",paddingBottom:".5rem"},children:[l.jsx("h3",{style:{color:"var(--amp-colors-text-muted)",fontSize:"1rem",fontWeight:"400"},children:e}),l.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:l.jsx(Vo,{style:{width:"100%",marginLeft:"1rem"}})})]})}function rI({provider:e}){const{projectIdOrName:t}=Re(),{providerName:n,data:r}=lt(e),{selectedConnection:o,isConnectionsLoading:i}=en(),{mutateAsync:s,isPending:a,error:c}=xa(),[d,u]=b.useState(null),[f,m]=b.useState(!1),g=()=>m(!1),y=()=>{m(!0),u(null)},v=(c==null?void 0:c.message)||d||null,p=async x=>{g(),u(null);try{await s({projectIdOrName:t||"",connectionId:(o==null?void 0:o.id)||"",updateConnectionRequest:{updateMask:["apiKey"],connection:{apiKey:x.apiKey}}},{onError:h=>{console.error("Update connection error:",h),De(h,u)},onSuccess:()=>{y()}})}catch(h){console.error("Update connection caught error:",h),De(h,u)}};return r?l.jsxs(l.Fragment,{children:[l.jsx(Rt,{string:"Update connection"}),l.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[l.jsx("p",{children:`Update ${n} API Key`}),f&&l.jsx(qo,{children:"Connection updated successfully"}),v&&l.jsx(ki,{children:`Error updating connection ${v}`}),l.jsx(pd,{provider:r==null?void 0:r.name,providerInfo:r,handleSubmit:p,isButtonDisabled:a||i,buttonVariant:"ghost",submitButtonType:"button"})]})]}):null}function hd({provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:r,buttonVariant:o}){var p,x;const[i,s]=b.useState({username:"",password:""}),a=((p=t.metadata)==null?void 0:p.input)||[],{username:c,password:d}=i,{providerName:u}=lt(e),f=h=>{const{name:w,value:I}=h.currentTarget;s(S=>({...S,[w]:I.trim()}))},m=Zr(a,i),g=r||!m,y=()=>{const h=$o(a,i);n({user:c,pass:d,providerMetadata:h})},v=(x=t.basicOpts)==null?void 0:x.docsURL;return l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[v&&l.jsx(Eo,{url:v,providerDisplayName:u||ln(e),credentialName:"credentials"}),l.jsx(xt.Input,{id:"username",name:"username",type:"text",placeholder:"Username",onChange:f}),l.jsx(xt.PasswordInput,{id:"password",name:"password",placeholder:"Password",onChange:f}),a.map(h=>l.jsxs("div",{children:[h.docsURL&&l.jsx(Eo,{url:h.docsURL,providerDisplayName:u||ln(e),credentialName:h.displayName||h.name}),l.jsx(xt.Input,{id:h.name,name:h.name,type:"text",placeholder:h.displayName||h.name,onChange:f})]},h.name)),l.jsx(Je,{style:{marginTop:"1em",width:"100%"},disabled:g,type:"button",onClick:y,variant:o,children:"Next"})]})}function iI({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){const{providerName:i}=lt(e);return l.jsxs(rr,{children:[l.jsx(ir,{children:`Set up ${i} integration`}),l.jsx(dn,{error:r}),l.jsx(hd,{provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:o})]})}function oI({...e}){return l.jsx(iI,{...e})}function sI({provider:e}){const{projectIdOrName:t}=Re(),{providerName:n,data:r}=lt(e),{selectedConnection:o,isConnectionsLoading:i}=en(),{mutateAsync:s,isPending:a,error:c}=xa(),[d,u]=b.useState(null),[f,m]=b.useState(!1),g=()=>m(!1),y=()=>{m(!0),u(null)},v=(c==null?void 0:c.message)||d||null,p=async x=>{g(),u(null);try{await s({projectIdOrName:t||"",connectionId:(o==null?void 0:o.id)||"",updateConnectionRequest:{updateMask:["basicAuth"],connection:{basicAuth:{username:x.user,password:x.pass}}}},{onError:h=>{console.error(h),De(h,u)},onSuccess:()=>{y()}})}catch(h){console.error(h),De(h,u)}};return r?l.jsxs(l.Fragment,{children:[l.jsx(Rt,{string:"Update connection"}),l.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[l.jsx("p",{children:`Update ${n} credentials`}),f&&l.jsx(qo,{children:"Connection updated successfully"}),v&&l.jsx(ki,{children:`Error updating connection: ${v}`}),l.jsx(hd,{provider:r==null?void 0:r.name,providerInfo:r,handleSubmit:p,isButtonDisabled:a||i,buttonVariant:"ghost"})]})]}):null}function md({provider:e,handleSubmit:t,isButtonDisabled:n,explicitScopesRequired:r,buttonVariant:o}){var I;const[i,s]=b.useState({clientSecret:"",clientId:"",scopes:""}),[a,c]=b.useState(null),{data:d}=Uo(e),u=((I=d==null?void 0:d.metadata)==null?void 0:I.input)||[],f=S=>{const{name:A,value:O}=S.currentTarget;s(N=>({...N,[A]:O.trim()})),c(null)},{clientSecret:m,clientId:g,scopes:y}=i,v=m.length>0,p=g.length>0,x=Zr(u,i),h=n||!v||!p||!x,w=()=>{const S=$o(u,i),A={clientId:g,clientSecret:m,providerMetadata:S};r&&y.length>0&&(A.scopes=cb(y)),t(A)};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.2rem"},children:[l.jsx(xt.Input,{id:"clientId",name:"clientId",type:"text",placeholder:"Client ID",onChange:f}),l.jsx(xt.PasswordInput,{id:"clientSecret",name:"clientSecret",placeholder:"Client Secret",onChange:f}),r&&l.jsx(xt.Textarea,{name:"scopes",placeholder:"Scopes separated by new line",onChange:f}),u.map(S=>l.jsx(xt.Input,{id:S.name,name:S.name,type:"text",placeholder:S.displayName||S.name,onChange:f},S.name))]}),l.jsx(dn,{error:a}),l.jsx("br",{}),l.jsx(Je,{style:{width:"100%"},disabled:h,type:"button",onClick:w,variant:o,children:"Next"})]})}function aI({provider:e,handleSubmit:t,error:n,isButtonDisabled:r,providerName:o,explicitScopesRequired:i}){return l.jsxs(rr,{children:[l.jsx(ir,{children:`Set up ${o} integration`}),l.jsx(dn,{error:n}),l.jsx("br",{}),l.jsx(md,{provider:e,handleSubmit:t,isButtonDisabled:r,explicitScopesRequired:i})]})}function cI({provider:e}){var h;const{projectIdOrName:t}=Re(),{selectedConnection:n,isConnectionsLoading:r}=en(),{providerName:o,data:i}=lt(e),{mutateAsync:s,isPending:a,error:c}=xa(),[d,u]=b.useState(null),[f,m]=b.useState(!1),g=()=>{m(!1)},y=()=>{m(!0),u(null)},v=(h=i==null?void 0:i.oauth2Opts)==null?void 0:h.explicitScopesRequired,p=(c==null?void 0:c.message)||d||null,x=async w=>{g(),u(null);try{await s({projectIdOrName:t||"",connectionId:(n==null?void 0:n.id)||"",updateConnectionRequest:{updateMask:["oauth2ClientCredentials"],connection:{oauth2ClientCredentials:{clientId:w.clientId,clientSecret:w.clientSecret,scopes:w.scopes}}}}),y()}catch(I){De(I,u)}};return l.jsxs(l.Fragment,{children:[l.jsx(Rt,{string:"Update connection"}),l.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[l.jsx("p",{children:`Re-authenticate to ${o}`}),f&&l.jsx(qo,{children:"Connection updated successfully"}),p&&l.jsx(ki,{children:`Error updating connection ${p}`}),l.jsx(md,{provider:o||"",handleSubmit:x,isButtonDisabled:a||r,explicitScopesRequired:v,buttonVariant:"ghost"})]})]})}const Vc=600,Hc=600,lI="AUTHORIZATION_SUCCEEDED",uI="AUTHORIZATION_FAILED";function dI(e,t,n,r){return b.useCallback(()=>{if(!r)return;const o=window.screenX+(window.outerWidth-Vc)/2,i=window.screenY+(window.outerHeight-Hc)/2.5,s=`width=${Vc},height=${Hc},left=${o},top=${i}`,a=window.open(r,e,s);t(a),window.addEventListener("message",n,!1)},[r,e,t,n])}function fI(e,t,n,r){const o=$e();return b.useCallback(i=>{var s,a;if(i.origin===qu){if(i.data.eventType===lI){const c=(s=i.data.data)==null?void 0:s.connection;c?(e(c),o.setQueriesData({queryKey:["amp","connections"]},()=>[c]),t==null||t.close(),r==null||r(),o.invalidateQueries({queryKey:["amp","connections"]})):console.error("Connection ID not found in event data: ",{event:i})}i.data.eventType===uI&&(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 pI({children:e,oauthUrl:t,windowTitle:n="Connect to Provider",onError:r,error:o,onSuccessConnect:i,isSuccessConnect:s,onWindowClose:a}){const[c,d]=b.useState(null),[u,f]=b.useState(null),m=$e(),g=b.useRef(null),y=fI(d,u,r,i),v=dI(n,f,y,t);b.useEffect(()=>{t&&!u&&!c&&!o&&!s&&(r==null||r(null),v())},[t,u,v,c,o,s,r]);const p=b.useCallback(()=>{m.invalidateQueries({queryKey:["amp","connections"]}),f(null),!c&&!o?console.error("Window closed and no connection was found. Please try again."):c&&(r==null||r(null)),a==null||a()},[c,o,r,a,m]);return b.useEffect(()=>{if(u)return g.current=setInterval(()=>{u!=null&&u.closed&&(g.current&&clearInterval(g.current),g.current=null,p())},500),()=>{g.current&&(clearInterval(g.current),g.current=null),window.removeEventListener("message",y)}},[p,u,y]),l.jsx("div",{children:e})}const hI=()=>{const e=it(),t=$e();return On({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 mI({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return l.jsxs("div",{style:{padding:"1rem 0"},children:[l.jsx("p",{children:`Re-authenticate to ${r}`}),l.jsx(dn,{error:t}),l.jsx(Je,{variant:"ghost",style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function gI({provider:e}){const{selectedConnection:t,isConnectionsLoading:n}=en(),r=t==null?void 0:t.id,o=t==null?void 0:t.projectId,{providerName:i}=lt(e),{mutateAsync:s,isPending:a,error:c}=hI(),[d,u]=b.useState(null),[f,m]=b.useState(!1),[g,y]=b.useState(null),v=()=>{m(!1)},p=()=>{m(!0),u(null),y(null)},x=(c==null?void 0:c.message)||d||null,h=async()=>{v(),u(null);try{const I=await s({projectIdOrName:o||"",connectionId:r||""});y(I)}catch(I){De(I,u)}},w=b.useCallback(I=>{u(I)},[]);return l.jsxs(l.Fragment,{children:[l.jsx(Rt,{string:"Update connection"}),f&&l.jsx(qo,{children:"Connection updated successfully"}),l.jsx(pI,{windowTitle:`Connect to ${i}`,oauthUrl:g||null,onError:w,error:x,isSuccessConnect:f,onSuccessConnect:p,children:l.jsx(mI,{handleSubmit:h,error:x,providerName:i,isButtonDisabled:a||n||f})})]})}function Sa({provider:e}){var r;const{data:t}=Uo(e);if((t==null?void 0:t.authType)===Tc.Basic)return l.jsx(sI,{provider:e});if((t==null?void 0:t.authType)===Tc.ApiKey)return l.jsx(rI,{provider:e});const n=(r=t==null?void 0:t.oauth2Opts)==null?void 0:r.grantType;if(n){if(n===os.AuthorizationCode||n===os.AuthorizationCodePkce)return l.jsx(gI,{provider:e});if(n===os.ClientCredentials)return l.jsx(cI,{provider:e})}return null}const yI=()=>{const e=it(),t=$e(),[n,r]=b.useState(null);return{...On({mutationKey:["deleteConnection"],mutationFn:async i=>(await e()).connectionApi.deleteConnection(i),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","connections"]}),r(null)},onError:i=>{console.error("Error deleting connection"),De(i,r)}}),errorMsg:n}};function gd({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={},onDisconnectSuccess:r,resetComponent:o,onDisconnectError:i}){const{projectIdOrName:s}=Re(),{selectedConnection:a}=en(),{mutate:c,isPending:d}=yI(),u=!s||!a||!a.id||d,f=async()=>{u||(console.warn("deleting connection",{projectIdOrName:s,connectionId:a==null?void 0:a.id}),c({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:y=>{De(y,i)}}))},m=d?"Pending...":e;return l.jsx(Je,{type:"button",onClick:f,disabled:u,variant:t,style:n,children:m})}const yd=b.createContext({hydratedRevision:null,loading:!1,readAction:void 0,writeObjects:[]}),di=()=>{const e=b.useContext(yd);if(!e)throw new Error("useHydratedRevision must be used within a HydratedRevisionProvider");return e},vI=()=>{var d;const e=$e(),t=it(),{selectedConnection:n,isConnectionsLoading:r}=en(),{projectIdOrName:o}=Re(),{integrationId:i,integrationObj:s}=Ze(),a=n==null?void 0:n.id,c=(d=s==null?void 0:s.latestRevision)==null?void 0:d.id;return b.useEffect(()=>{a||e.invalidateQueries({queryKey:["amp","hydratedRevision"]})},[a,e]),er({queryKey:["amp","hydratedRevision",o,i,c,a],queryFn:async()=>{if(!o)throw new Error("projectIdOrName is required");if(!i)throw new Error("integrationId is required");if(!c)throw new Error("revisionId is required");if(!a)throw new Error("connectionId is required");return(await t()).revisionApi.getHydratedRevision({projectIdOrName:o,integrationId:i,revisionId:c,connectionId:a})},retry:3,enabled:!!o&&!!i&&!!c&&!!a&&!r})};function wI({children:e,resetComponent:t}){const{integrationId:n,integrationObj:r}=Ze(),{isError:o,removeError:i,setError:s}=qt(),a=(r==null?void 0:r.name)||n,[c,d]=b.useState(null),[u,f]=b.useState(null),{data:m,isLoading:g,isError:y,error:v}=vI();b.useEffect(()=>{y?(s(de.HYDRATED_REVISION,a),De(v,d)):(i(de.HYDRATED_REVISION,a),d(null),f(null))},[y,a,s,i,v,d]);const p=b.useMemo(()=>{var h,w,I;return{hydratedRevision:m||null,loading:g,readAction:(h=m==null?void 0:m.content)==null?void 0:h.read,writeObjects:((I=(w=m==null?void 0:m.content)==null?void 0:w.write)==null?void 0:I.objects)||[]}},[m,g]);if(g)return l.jsx(ui,{});const x=(r==null?void 0:r.provider)||"provider";if(o(de.HYDRATED_REVISION,a)){const h=(r==null?void 0:r.name)||n||"unknown integration",w=`${c?`: ${c}`:`Error retrieving objects from ${x} or integration details for ${h}`}`;return l.jsx(Ut,{message:w,children:l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",paddingTop:"1rem",width:"100%"},children:[l.jsx(Sa,{provider:x}),l.jsx("p",{children:"If authentication is failing, please try reauthenticating using the section above before deleting and recreating the connection."}),u&&l.jsx(Hu,{message:u}),l.jsx(gd,{buttonText:"Delete Connection",resetComponent:t,buttonVariant:"danger",onDisconnectError:I=>f(I)})]})})}return l.jsx(yd.Provider,{value:p,children:e})}const vd=b.createContext(null);function wd(){const e=b.useContext(vd);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}const bd=b.createContext(()=>{});function bI(){const e=b.useContext(bd);if(!e)throw new Error("useSetNextTabIndex must be used within a NextTabIndexProvider");return{onNextIncompleteTab:e}}const Id=b.createContext(void 0),II={};function Ea(){const e=b.useContext(Id);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function CI({children:e}){const{installation:t}=Ze(),{hydratedRevision:n,loading:r}=di(),[o,i]=b.useState(II),s=t==null?void 0:t.config;b.useEffect(()=>{n!=null&&n.content&&!r&&s&&!(Object.entries(o).length>0)&&Eb(n,s,i)},[n,r,s,o]);const a=b.useCallback((g,y)=>{i(v=>It(v,p=>{p[g]=It(p[g],y)}))},[i]),c=b.useCallback((g,y)=>{i(v=>It(v,p=>{p[g]=y}))},[i]),d=b.useCallback(()=>{i(It(g=>{const y=g.other.write;y&&(y.isWriteModified=!1)}))},[i]),u=b.useCallback(g=>{i(It(y=>{var p;const v=(p=y[g])==null?void 0:p.read;v&&(v.isOptionalFieldsModified=!1,v.isRequiredMapFieldsModified=!1,v.isValueMappingsModified=!1)}))},[i]),f=b.useCallback(g=>{g===_r?d():u(g)},[u,d]),m=b.useMemo(()=>({objectConfigurationsState:o,setObjectConfigurationsState:i,setConfigureState:a,resetConfigureState:c,resetPendingConfigurationState:f}),[o,c,f,a]);return l.jsx(Id.Provider,{value:m,children:e})}const tn=()=>{const{appName:e}=nr(),{objectConfigurationsState:t,setConfigureState:n}=Ea(),{selectedObjectName:r}=wd(),o=cd(r||"",t);return{appName:e,configureState:o,setConfigureState:n,selectedObjectName:r}};function xn(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 me(){return me=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},me.apply(null,arguments)}function Bs(e,t){return Bs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Bs(e,t)}function xI(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Bs(e,t)}var zs={exports:{}},io={exports:{}},Ie={};/** @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})()})(ud);var Rb=ud.exports;const Ut=Ca(Rb),Pb="_button_kwfiu_1",Fb="_danger_kwfiu_42",Db="_ghost_kwfiu_47",us={button:Pb,danger:Fb,ghost:Db};function Be({className:e,style:t,type:n,children:r,variant:o,...i}){const s=Ut(us.button,{[us.danger]:o==="danger",[us.ghost]:o==="ghost",[e||""]:!!e});return u.jsx("button",{type:n,className:s,style:t,...i,children:r})}const Mb={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 ji({children:e,style:t}){return u.jsx(_n,{style:{...Mb,...t},children:e})}const Uo=e=>{const t=it(),{provider:n}=Ze(),r=e||n;return Zn({queryKey:["amp","providerInfo",r],queryFn:async()=>{if(!r)throw new Error("Provider not found");return(await t()).providerApi.getProvider({provider:r})},enabled:!!r})},ut=e=>{const t=Uo(e),{data:n}=t,{provider:r}=Ze(),o=n&&nb(n==null?void 0:n.name,n);return{...t,providerName:o,selectedProvider:e||r}};function dn({error:e}){return e?u.jsx(ji,{style:{marginTop:"2em"},children:e}):null}const kb="_input_1ymb7_1",Lb="_inputError_1ymb7_27",ls={input:kb,inputError:Lb};function ld({id:e,type:t,className:n,isError:r=!1,...o}){const i=r?Ut(ls.inputError,ls.input):ls.input;return u.jsx("input",{id:e,type:t,className:Ut(i,n),...o})}function jb(){return u.jsx("svg",{width:"22",height:"22",viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:u.jsxs("g",{opacity:"0.5",children:[u.jsx("path",{d:"M14.2821 11.0004C14.2821 12.8154 12.8154 14.2821 11.0004 14.2821C9.18542 14.2821 7.71875 12.8154 7.71875 11.0004C7.71875 9.18542 9.18542 7.71875 11.0004 7.71875C12.8154 7.71875 14.2821 9.18542 14.2821 11.0004Z",stroke:"currentColor",strokeWidth:"1.375",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M10.9999 18.581C14.2357 18.581 17.2515 16.6743 19.3507 13.3743C20.1757 12.0818 20.1757 9.90932 19.3507 8.61682C17.2515 5.31682 14.2357 3.41016 10.9999 3.41016C7.76402 3.41016 4.74819 5.31682 2.64902 8.61682C1.82402 9.90932 1.82402 12.0818 2.64902 13.3743C4.74819 16.6743 7.76402 18.581 10.9999 18.581Z",stroke:"currentColor",strokeWidth:"1.375",strokeLinecap:"round",strokeLinejoin:"round"})]})})}function Kb(){return u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",viewBox:"0 0 22 22",fill:"none",children:[u.jsx("path",{d:"M13.3187 8.68036L8.68036 13.3187C8.06528 12.7036 7.71973 11.8694 7.71973 10.9995C7.71973 10.5688 7.80456 10.1423 7.96939 9.7444C8.13421 9.34648 8.3758 8.98491 8.68036 8.68036C8.98491 8.3758 9.34648 8.13421 9.7444 7.96939C10.1423 7.80456 10.5688 7.71973 10.9995 7.71973C11.8694 7.71973 12.7036 8.06528 13.3187 8.68036Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M16.3349 5.28895C14.7307 4.07895 12.8974 3.41895 10.9999 3.41895C7.76402 3.41895 4.74819 5.32561 2.64902 8.62561C1.82402 9.91811 1.82402 12.0906 2.64902 13.3831C3.37319 14.5198 4.21652 15.5006 5.13319 16.2889M7.71819 17.9023C8.76319 18.3423 9.87236 18.5806 10.9999 18.5806C14.2357 18.5806 17.2515 16.6739 19.3507 13.3739C20.1757 12.0814 20.1757 9.90895 19.3507 8.61645C19.0482 8.13978 18.7182 7.69061 18.379 7.26895",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M14.2172 11.6413C14.093 12.2808 13.7806 12.8685 13.32 13.3291C12.8594 13.7897 12.2716 14.1022 11.6322 14.2263M8.68051 13.3188L1.83301 20.1663M20.1663 1.83301L13.3188 8.68051",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}function $b({id:e,name:t,placeholder:n="Password",onChange:r,value:o,className:i,isError:s}){const[a,c]=b.useState(!1),f=()=>c(d=>!d);return u.jsxs("div",{style:{display:"flex",gap:".5rem"},children:[u.jsx(St.Input,{id:e,name:t,type:a?"text":"password",placeholder:n,onChange:r,value:o,className:i,isError:s}),u.jsx(Be,{type:"button","aria-label":a?"Hide password":"Show password",style:{height:"2.5rem",width:"2.5rem",display:"flex",alignItems:"center",justifyContent:"center"},onClick:f,variant:"ghost",children:u.jsx("span",{style:{height:"1.5rem",width:"1.5rem"},children:a?u.jsx(Kb,{}):u.jsx(jb,{})})})]})}const Ub="_textarea_18zl4_1",qb="_textareaError_18zl4_14",ds={textarea:Ub,textareaError:qb};function Vb({className:e,isError:t=!1,...n}){const r=t?Ut(ds.textareaError,ds.textarea):ds.textarea;return u.jsx("textarea",{className:Ut(e,r),...n})}const St={Input:ld,Textarea:Vb,PasswordInput:$b},Hb=()=>{const{projectIdOrName:e}=Pe(),t=it();return Zn({queryKey:["project",e,"entitlements"],queryFn:async()=>{if(!e)throw new Error("Project ID is required");return(await t()).projectApi.getProject({projectIdOrName:e,includeEntitlements:!0})},enabled:!!e})};function dd(){var n,r;const{data:e}=Hb();return((r=(n=e==null?void 0:e.entitlements)==null?void 0:n.brandingRemoval)==null?void 0:r.value)===!0?null:u.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:[u.jsx("p",{style:{color:"light-dark(gray, #EFEFEF)"},children:"Secured by"}),u.jsx("a",{href:"https://www.withampersand.com/",target:"_blank","aria-label":"Go to Ampersand",rel:"noreferrer noopener",children:u.jsx("img",{style:{height:".8em"},src:"https://res.cloudinary.com/dycvts6vp/image/upload/v1723671980/ampersand-logo-black.svg",alt:"Ampersand"})})]})}function rr({children:e}){return u.jsx(ui,{children:u.jsxs(_n,{children:[u.jsx("div",{style:{padding:"3rem 2rem"},children:e}),u.jsx(dd,{})]})})}function ir({children:e}){return u.jsx("h1",{style:{fontWeight:600,lineHeight:1.2,fontSize:"1.2em"},children:e})}function Bb({children:e}){return u.jsx("p",{style:{padding:".5em 0"},children:e})}const Jb="_link_oo2kv_1",Wb={link:Jb};function Sa({href:e,className:t,style:n,label:r,children:o,newTab:i=!1}){return u.jsx("a",{className:Ut(Wb.link,t),style:n,href:e,"aria-label":r||void 0,target:i?"_blank":"_self",rel:i?"noopener noreferrer":void 0,children:o})}function Eo({url:e,providerDisplayName:t,credentialName:n}){return u.jsxs("p",{style:{color:"var(--amp-colors-text-muted)"},children:[u.jsx(Sa,{href:e,newTab:!0,children:u.jsx("span",{style:{textDecoration:"underline"},children:"Learn more"})})," ","about where to find your ",t," ",n,"."]})}function qo(e,t){const n={},r=[];if(e.forEach(o=>{const i=t[o.name];!i||i.trim()===""?r.push(o.displayName||o.name):n[o.name]={value:i,source:"input"}}),r.length>0)throw new Error(`Please fill in the following required fields: ${r.join(", ")}.`);return n}function Zr(e,t){return e.every(n=>{const r=t[n.name];return r&&r.trim()!==""})}function fd({provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:r,buttonVariant:o,submitButtonType:i}){var S,p;const[s,a]=b.useState({apiKey:""}),c=((S=t.metadata)==null?void 0:S.input)||[],f=y=>{const{name:I,value:x}=y.currentTarget;a(T=>({...T,[I]:x.trim()}))},{apiKey:d}=s,{providerName:l}=ut(e),m=d.length>0,g=Zr(c,s),v=r||!m||!g,w=(p=t.apiKeyOpts)==null?void 0:p.docsURL,h=()=>{const y=qo(c,s);n({apiKey:d,providerMetadata:y})};return u.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[w&&u.jsx(Eo,{url:w,providerDisplayName:l||un(e),credentialName:"API key"}),u.jsx(St.PasswordInput,{id:"apiKey",name:"apiKey",placeholder:"API Key",onChange:f}),c.map(y=>u.jsxs("div",{children:[y.docsURL&&u.jsx(Eo,{url:y.docsURL,providerDisplayName:l||un(e),credentialName:y.displayName||y.name}),u.jsx(St.Input,{id:y.name,name:y.name,type:"text",placeholder:y.displayName||y.name,onChange:f})]},y.name)),u.jsx(Be,{style:{marginTop:"1em",width:"100%"},disabled:v,type:i||"submit",onClick:h,variant:o,children:"Next"})]})}function zb({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){const{providerName:i}=ut(e);return u.jsxs(rr,{children:[u.jsx(ir,{children:`Set up ${i} integration`}),u.jsx(dn,{error:r}),u.jsx(fd,{provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:o})]})}function Gb({...e}){return u.jsx(zb,{...e})}const Qb={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 Vo({children:e,style:t}){return u.jsx(_n,{style:{...Qb,...t},children:e})}const xa=()=>{const e=it(),t=Ue(),[n,r]=b.useState(null);return{...En({mutationKey:["updateConnection"],mutationFn:async i=>(await e()).connectionApi.updateConnection(i),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","connections"]}),r(null)}}),errorMsg:n}},Xb="_divider_1kmoj_1",qc={divider:Xb};function Ho({className:e,style:t}){return u.jsx("hr",{className:e?`${qc.divider} ${e}`:qc.divider,style:t})}function Rt({string:e}){return u.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"1rem",paddingBottom:".5rem"},children:[u.jsx("h3",{style:{color:"var(--amp-colors-text-muted)",fontSize:"1rem",fontWeight:"400"},children:e}),u.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:u.jsx(Ho,{style:{width:"100%",marginLeft:"1rem"}})})]})}function Yb({provider:e}){const{projectIdOrName:t}=Pe(),{providerName:n,data:r}=ut(e),{selectedConnection:o,isConnectionsLoading:i}=en(),{mutateAsync:s,isPending:a,error:c}=xa(),[f,d]=b.useState(null),[l,m]=b.useState(!1),g=()=>m(!1),v=()=>{m(!0),d(null)},w=(c==null?void 0:c.message)||f||null,h=async S=>{g(),d(null);try{await s({projectIdOrName:t||"",connectionId:(o==null?void 0:o.id)||"",updateConnectionRequest:{updateMask:["apiKey"],connection:{apiKey:S.apiKey}}},{onError:p=>{console.error("Update connection error:",p),$e(p,d)},onSuccess:()=>{v()}})}catch(p){console.error("Update connection caught error:",p),$e(p,d)}};return r?u.jsxs(u.Fragment,{children:[u.jsx(Rt,{string:"Update connection"}),u.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[u.jsx("p",{children:`Update ${n} API Key`}),l&&u.jsx(Vo,{children:"Connection updated successfully"}),w&&u.jsx(ji,{children:`Error updating connection ${w}`}),u.jsx(fd,{provider:r==null?void 0:r.name,providerInfo:r,handleSubmit:h,isButtonDisabled:a||i,buttonVariant:"ghost",submitButtonType:"button"})]})]}):null}function pd({provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:r,buttonVariant:o}){var h,S;const[i,s]=b.useState({username:"",password:""}),a=((h=t.metadata)==null?void 0:h.input)||[],{username:c,password:f}=i,{providerName:d}=ut(e),l=p=>{const{name:y,value:I}=p.currentTarget;s(x=>({...x,[y]:I.trim()}))},m=Zr(a,i),g=r||!m,v=()=>{const p=qo(a,i);n({user:c,pass:f,providerMetadata:p})},w=(S=t.basicOpts)==null?void 0:S.docsURL;return u.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[w&&u.jsx(Eo,{url:w,providerDisplayName:d||un(e),credentialName:"credentials"}),u.jsx(St.Input,{id:"username",name:"username",type:"text",placeholder:"Username",onChange:l}),u.jsx(St.PasswordInput,{id:"password",name:"password",placeholder:"Password",onChange:l}),a.map(p=>u.jsxs("div",{children:[p.docsURL&&u.jsx(Eo,{url:p.docsURL,providerDisplayName:d||un(e),credentialName:p.displayName||p.name}),u.jsx(St.Input,{id:p.name,name:p.name,type:"text",placeholder:p.displayName||p.name,onChange:l})]},p.name)),u.jsx(Be,{style:{marginTop:"1em",width:"100%"},disabled:g,type:"button",onClick:v,variant:o,children:"Next"})]})}function Zb({provider:e,providerInfo:t,handleSubmit:n,error:r,isButtonDisabled:o}){const{providerName:i}=ut(e);return u.jsxs(rr,{children:[u.jsx(ir,{children:`Set up ${i} integration`}),u.jsx(dn,{error:r}),u.jsx(pd,{provider:e,providerInfo:t,handleSubmit:n,isButtonDisabled:o})]})}function eI({...e}){return u.jsx(Zb,{...e})}function tI({provider:e}){const{projectIdOrName:t}=Pe(),{providerName:n,data:r}=ut(e),{selectedConnection:o,isConnectionsLoading:i}=en(),{mutateAsync:s,isPending:a,error:c}=xa(),[f,d]=b.useState(null),[l,m]=b.useState(!1),g=()=>m(!1),v=()=>{m(!0),d(null)},w=(c==null?void 0:c.message)||f||null,h=async S=>{g(),d(null);try{await s({projectIdOrName:t||"",connectionId:(o==null?void 0:o.id)||"",updateConnectionRequest:{updateMask:["basicAuth"],connection:{basicAuth:{username:S.user,password:S.pass}}}},{onError:p=>{console.error(p),$e(p,d)},onSuccess:()=>{v()}})}catch(p){console.error(p),$e(p,d)}};return r?u.jsxs(u.Fragment,{children:[u.jsx(Rt,{string:"Update connection"}),u.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[u.jsx("p",{children:`Update ${n} credentials`}),l&&u.jsx(Vo,{children:"Connection updated successfully"}),w&&u.jsx(ji,{children:`Error updating connection: ${w}`}),u.jsx(pd,{provider:r==null?void 0:r.name,providerInfo:r,handleSubmit:h,isButtonDisabled:a||i,buttonVariant:"ghost"})]})]}):null}function hd({provider:e,handleSubmit:t,isButtonDisabled:n,explicitScopesRequired:r,buttonVariant:o}){var I;const[i,s]=b.useState({clientSecret:"",clientId:"",scopes:""}),[a,c]=b.useState(null),{data:f}=Uo(e),d=((I=f==null?void 0:f.metadata)==null?void 0:I.input)||[],l=x=>{const{name:T,value:E}=x.currentTarget;s(A=>({...A,[T]:E.trim()})),c(null)},{clientSecret:m,clientId:g,scopes:v}=i,w=m.length>0,h=g.length>0,S=Zr(d,i),p=n||!w||!h||!S,y=()=>{const x=qo(d,i),T={clientId:g,clientSecret:m,providerMetadata:x};r&&v.length>0&&(T.scopes=rb(v)),t(T)};return u.jsxs(u.Fragment,{children:[u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.2rem"},children:[u.jsx(St.Input,{id:"clientId",name:"clientId",type:"text",placeholder:"Client ID",onChange:l}),u.jsx(St.PasswordInput,{id:"clientSecret",name:"clientSecret",placeholder:"Client Secret",onChange:l}),r&&u.jsx(St.Textarea,{name:"scopes",placeholder:"Scopes separated by new line",onChange:l}),d.map(x=>u.jsx(St.Input,{id:x.name,name:x.name,type:"text",placeholder:x.displayName||x.name,onChange:l},x.name))]}),u.jsx(dn,{error:a}),u.jsx("br",{}),u.jsx(Be,{style:{width:"100%"},disabled:p,type:"button",onClick:y,variant:o,children:"Next"})]})}function nI({provider:e,handleSubmit:t,error:n,isButtonDisabled:r,providerName:o,explicitScopesRequired:i}){return u.jsxs(rr,{children:[u.jsx(ir,{children:`Set up ${o} integration`}),u.jsx(dn,{error:n}),u.jsx("br",{}),u.jsx(hd,{provider:e,handleSubmit:t,isButtonDisabled:r,explicitScopesRequired:i})]})}function rI({provider:e}){var p;const{projectIdOrName:t}=Pe(),{selectedConnection:n,isConnectionsLoading:r}=en(),{providerName:o,data:i}=ut(e),{mutateAsync:s,isPending:a,error:c}=xa(),[f,d]=b.useState(null),[l,m]=b.useState(!1),g=()=>{m(!1)},v=()=>{m(!0),d(null)},w=(p=i==null?void 0:i.oauth2Opts)==null?void 0:p.explicitScopesRequired,h=(c==null?void 0:c.message)||f||null,S=async y=>{g(),d(null);try{await s({projectIdOrName:t||"",connectionId:(n==null?void 0:n.id)||"",updateConnectionRequest:{updateMask:["oauth2ClientCredentials"],connection:{oauth2ClientCredentials:{clientId:y.clientId,clientSecret:y.clientSecret,scopes:y.scopes}}}}),v()}catch(I){$e(I,d)}};return u.jsxs(u.Fragment,{children:[u.jsx(Rt,{string:"Update connection"}),u.jsxs("div",{style:{padding:"1rem 0",display:"flex",flexDirection:"column",gap:".5rem"},children:[u.jsx("p",{children:`Re-authenticate to ${o}`}),l&&u.jsx(Vo,{children:"Connection updated successfully"}),h&&u.jsx(ji,{children:`Error updating connection ${h}`}),u.jsx(hd,{provider:o||"",handleSubmit:S,isButtonDisabled:a||r,explicitScopesRequired:w,buttonVariant:"ghost"})]})]})}const Vc=600,Hc=600,iI="AUTHORIZATION_SUCCEEDED",oI="AUTHORIZATION_FAILED";function sI(e,t,n,r){return b.useCallback(()=>{if(!r)return;const o=window.screenX+(window.outerWidth-Vc)/2,i=window.screenY+(window.outerHeight-Hc)/2.5,s=`width=${Vc},height=${Hc},left=${o},top=${i}`,a=window.open(r,e,s);t(a),window.addEventListener("message",n,!1)},[r,e,t,n])}function aI(e,t,n,r){const o=Ue();return b.useCallback(i=>{var s,a;if(i.origin===jl){if(i.data.eventType===iI){const c=(s=i.data.data)==null?void 0:s.connection;c?(e(c),o.setQueriesData({queryKey:["amp","connections"]},()=>[c]),t==null||t.close(),r==null||r(),o.invalidateQueries({queryKey:["amp","connections"]})):console.error("Connection ID not found in event data: ",{event:i})}i.data.eventType===oI&&(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 cI({children:e,oauthUrl:t,windowTitle:n="Connect to Provider",onError:r,error:o,onSuccessConnect:i,isSuccessConnect:s,onWindowClose:a}){const[c,f]=b.useState(null),[d,l]=b.useState(null),m=Ue(),g=b.useRef(null),v=aI(f,d,r,i),w=sI(n,l,v,t);b.useEffect(()=>{t&&!d&&!c&&!o&&!s&&(r==null||r(null),w())},[t,d,w,c,o,s,r]);const h=b.useCallback(()=>{m.invalidateQueries({queryKey:["amp","connections"]}),l(null),!c&&!o?console.error("Window closed and no connection was found. Please try again."):c&&(r==null||r(null)),a==null||a()},[c,o,r,a,m]);return b.useEffect(()=>{if(d)return g.current=setInterval(()=>{d!=null&&d.closed&&(g.current&&clearInterval(g.current),g.current=null,h())},500),()=>{g.current&&(clearInterval(g.current),g.current=null),window.removeEventListener("message",v)}},[h,d,v]),u.jsx("div",{children:e})}const uI=()=>{const e=it(),t=Ue();return En({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 lI({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return u.jsxs("div",{style:{padding:"1rem 0"},children:[u.jsx("p",{children:`Re-authenticate to ${r}`}),u.jsx(dn,{error:t}),u.jsx(Be,{variant:"ghost",style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function dI({provider:e}){const{selectedConnection:t,isConnectionsLoading:n}=en(),r=t==null?void 0:t.id,o=t==null?void 0:t.projectId,{providerName:i}=ut(e),{mutateAsync:s,isPending:a,error:c}=uI(),[f,d]=b.useState(null),[l,m]=b.useState(!1),[g,v]=b.useState(null),w=()=>{m(!1)},h=()=>{m(!0),d(null),v(null)},S=(c==null?void 0:c.message)||f||null,p=async()=>{w(),d(null);try{const I=await s({projectIdOrName:o||"",connectionId:r||""});v(I)}catch(I){$e(I,d)}},y=b.useCallback(I=>{d(I)},[]);return u.jsxs(u.Fragment,{children:[u.jsx(Rt,{string:"Update connection"}),l&&u.jsx(Vo,{children:"Connection updated successfully"}),u.jsx(cI,{windowTitle:`Connect to ${i}`,oauthUrl:g||null,onError:y,error:S,isSuccessConnect:l,onSuccessConnect:h,children:u.jsx(lI,{handleSubmit:p,error:S,providerName:i,isButtonDisabled:a||n||l})})]})}function Oa({provider:e}){var r;const{data:t}=Uo(e);if((t==null?void 0:t.authType)===Ac.Basic)return u.jsx(tI,{provider:e});if((t==null?void 0:t.authType)===Ac.ApiKey)return u.jsx(Yb,{provider:e});const n=(r=t==null?void 0:t.oauth2Opts)==null?void 0:r.grantType;if(n){if(n===ss.AuthorizationCode||n===ss.AuthorizationCodePkce)return u.jsx(dI,{provider:e});if(n===ss.ClientCredentials)return u.jsx(rI,{provider:e})}return null}const fI=()=>{const e=it(),t=Ue(),[n,r]=b.useState(null);return{...En({mutationKey:["deleteConnection"],mutationFn:async i=>(await e()).connectionApi.deleteConnection(i),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","connections"]}),r(null)},onError:i=>{console.error("Error deleting connection"),$e(i,r)}}),errorMsg:n}};function md({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={},onDisconnectSuccess:r,resetComponent:o,onDisconnectError:i}){const{projectIdOrName:s}=Pe(),{selectedConnection:a}=en(),{mutate:c,isPending:f}=fI(),d=!s||!a||!a.id||f,l=async()=>{d||(console.warn("deleting connection",{projectIdOrName:s,connectionId:a==null?void 0:a.id}),c({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=>{$e(v,i)}}))},m=f?"Pending...":e;return u.jsx(Be,{type:"button",onClick:l,disabled:d,variant:t,style:n,children:m})}const gd=b.createContext({hydratedRevision:null,loading:!1,readAction:void 0,writeObjects:[]}),di=()=>{const e=b.useContext(gd);if(!e)throw new Error("useHydratedRevision must be used within a HydratedRevisionProvider");return e},pI=()=>{var f;const e=Ue(),t=it(),{selectedConnection:n,isConnectionsLoading:r}=en(),{projectIdOrName:o}=Pe(),{integrationId:i,integrationObj:s}=Ze(),a=n==null?void 0:n.id,c=(f=s==null?void 0:s.latestRevision)==null?void 0:f.id;return b.useEffect(()=>{a||e.invalidateQueries({queryKey:["amp","hydratedRevision"]})},[a,e]),Zn({queryKey:["amp","hydratedRevision",o,i,c,a],queryFn:async()=>{if(!o)throw new Error("projectIdOrName is required");if(!i)throw new Error("integrationId is required");if(!c)throw new Error("revisionId is required");if(!a)throw new Error("connectionId is required");return(await t()).revisionApi.getHydratedRevision({projectIdOrName:o,integrationId:i,revisionId:c,connectionId:a})},retry:3,enabled:!!o&&!!i&&!!c&&!!a&&!r})};function hI({children:e,resetComponent:t}){const{integrationId:n,integrationObj:r}=Ze(),{isError:o,removeError:i,setError:s}=qt(),a=(r==null?void 0:r.name)||n,[c,f]=b.useState(null),[d,l]=b.useState(null),{data:m,isLoading:g,isError:v,error:w}=pI();b.useEffect(()=>{v?(s(ue.HYDRATED_REVISION,a),$e(w,f)):(i(ue.HYDRATED_REVISION,a),f(null),l(null))},[v,a,s,i,w,f]);const h=b.useMemo(()=>{var p,y,I;return{hydratedRevision:m||null,loading:g,readAction:(p=m==null?void 0:m.content)==null?void 0:p.read,writeObjects:((I=(y=m==null?void 0:m.content)==null?void 0:y.write)==null?void 0:I.objects)||[]}},[m,g]);if(g)return u.jsx(li,{});const S=(r==null?void 0:r.provider)||"provider";if(o(ue.HYDRATED_REVISION,a)){const p=(r==null?void 0:r.name)||n||"unknown integration",y=`${c?`: ${c}`:`Error retrieving objects from ${S} or integration details for ${p}`}`;return u.jsx($t,{message:y,children:u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",paddingTop:"1rem",width:"100%"},children:[u.jsx(Oa,{provider:S}),u.jsx("p",{children:"If authentication is failing, please try reauthenticating using the section above before deleting and recreating the connection."}),d&&u.jsx(Ul,{message:d}),u.jsx(md,{buttonText:"Delete Connection",resetComponent:t,buttonVariant:"danger",onDisconnectError:I=>l(I)})]})})}return u.jsx(gd.Provider,{value:h,children:e})}const yd=b.createContext(null);function vd(){const e=b.useContext(yd);if(e===null)throw new Error("useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider");return{selectedObjectName:e}}const wd=b.createContext(()=>{});function mI(){const e=b.useContext(wd);if(!e)throw new Error("useSetNextTabIndex must be used within a NextTabIndexProvider");return{onNextIncompleteTab:e}}const bd=b.createContext(void 0),gI={};function Ea(){const e=b.useContext(bd);if(!e)throw new Error("useObjectsConfigureState must be used within a ConfigurationProvider");return e}function yI({children:e}){const{installation:t}=Ze(),{hydratedRevision:n,loading:r}=di(),[o,i]=b.useState(gI),s=t==null?void 0:t.config;b.useEffect(()=>{n!=null&&n.content&&!r&&s&&!(Object.entries(o).length>0)&&Eb(n,s,i)},[n,r,s,o]);const a=b.useCallback((g,v)=>{i(w=>It(w,h=>{h[g]=It(h[g],v)}))},[i]),c=b.useCallback((g,v)=>{i(w=>It(w,h=>{h[g]=v}))},[i]),f=b.useCallback(()=>{i(It(g=>{const v=g.other.write;v&&(v.isWriteModified=!1)}))},[i]),d=b.useCallback(g=>{i(It(v=>{var h;const w=(h=v[g])==null?void 0:h.read;w&&(w.isOptionalFieldsModified=!1,w.isRequiredMapFieldsModified=!1,w.isValueMappingsModified=!1)}))},[i]),l=b.useCallback(g=>{g===Er?f():d(g)},[d,f]),m=b.useMemo(()=>({objectConfigurationsState:o,setObjectConfigurationsState:i,setConfigureState:a,resetConfigureState:c,resetPendingConfigurationState:l}),[o,c,l,a]);return u.jsx(bd.Provider,{value:m,children:e})}const tn=()=>{const{appName:e}=tr(),{objectConfigurationsState:t,setConfigureState:n}=Ea(),{selectedObjectName:r}=vd(),o=ad(r||"",t);return{appName:e,configureState:o,setConfigureState:n,selectedObjectName:r}};function xn(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 zs(e,t){return zs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},zs(e,t)}function vI(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,zs(e,t)}var Gs={exports:{}},oo={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 Bc;function wI(){if(Bc)return be;Bc=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,c=e?Symbol.for("react.async_mode"):60111,f=e?Symbol.for("react.concurrent_mode"):60111,d=e?Symbol.for("react.forward_ref"):60112,l=e?Symbol.for("react.suspense"):60113,m=e?Symbol.for("react.suspense_list"):60120,g=e?Symbol.for("react.memo"):60115,v=e?Symbol.for("react.lazy"):60116,w=e?Symbol.for("react.block"):60121,h=e?Symbol.for("react.fundamental"):60117,S=e?Symbol.for("react.responder"):60118,p=e?Symbol.for("react.scope"):60119;function y(x){if(typeof x=="object"&&x!==null){var T=x.$$typeof;switch(T){case t:switch(x=x.type,x){case c:case f:case r:case i:case o:case l:return x;default:switch(x=x&&x.$$typeof,x){case a:case d:case v:case g:case s:return x;default:return T}}case n:return T}}}function I(x){return y(x)===f}return be.AsyncMode=c,be.ConcurrentMode=f,be.ContextConsumer=a,be.ContextProvider=s,be.Element=t,be.ForwardRef=d,be.Fragment=r,be.Lazy=v,be.Memo=g,be.Portal=n,be.Profiler=i,be.StrictMode=o,be.Suspense=l,be.isAsyncMode=function(x){return I(x)||y(x)===c},be.isConcurrentMode=I,be.isContextConsumer=function(x){return y(x)===a},be.isContextProvider=function(x){return y(x)===s},be.isElement=function(x){return typeof x=="object"&&x!==null&&x.$$typeof===t},be.isForwardRef=function(x){return y(x)===d},be.isFragment=function(x){return y(x)===r},be.isLazy=function(x){return y(x)===v},be.isMemo=function(x){return y(x)===g},be.isPortal=function(x){return y(x)===n},be.isProfiler=function(x){return y(x)===i},be.isStrictMode=function(x){return y(x)===o},be.isSuspense=function(x){return y(x)===l},be.isValidElementType=function(x){return typeof x=="string"||typeof x=="function"||x===r||x===f||x===i||x===o||x===l||x===m||typeof x=="object"&&x!==null&&(x.$$typeof===v||x.$$typeof===g||x.$$typeof===s||x.$$typeof===a||x.$$typeof===d||x.$$typeof===h||x.$$typeof===S||x.$$typeof===p||x.$$typeof===w)},be.typeOf=y,be}var Ie={};/** @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 Jc;function bI(){return Jc||(Jc=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,c=e?Symbol.for("react.async_mode"):60111,f=e?Symbol.for("react.concurrent_mode"):60111,d=e?Symbol.for("react.forward_ref"):60112,l=e?Symbol.for("react.suspense"):60113,m=e?Symbol.for("react.suspense_list"):60120,g=e?Symbol.for("react.memo"):60115,v=e?Symbol.for("react.lazy"):60116,w=e?Symbol.for("react.block"):60121,h=e?Symbol.for("react.fundamental"):60117,S=e?Symbol.for("react.responder"):60118,p=e?Symbol.for("react.scope"):60119;function y(L){return typeof L=="string"||typeof L=="function"||L===r||L===f||L===i||L===o||L===l||L===m||typeof L=="object"&&L!==null&&(L.$$typeof===v||L.$$typeof===g||L.$$typeof===s||L.$$typeof===a||L.$$typeof===d||L.$$typeof===h||L.$$typeof===S||L.$$typeof===p||L.$$typeof===w)}function I(L){if(typeof L=="object"&&L!==null){var we=L.$$typeof;switch(we){case t:var W=L.type;switch(W){case c:case f:case r:case i:case o:case l:return W;default:var ot=W&&W.$$typeof;switch(ot){case a:case d:case v:case g:case s:return ot;default:return we}}case n:return we}}}var x=c,T=f,E=a,A=s,R=t,P=d,K=r,q=v,V=g,M=n,se=i,oe=o,ge=l,me=!1;function Oe(L){return me||(me=!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.")),F(L)||I(L)===c}function F(L){return I(L)===f}function $(L){return I(L)===a}function J(L){return I(L)===s}function B(L){return typeof L=="object"&&L!==null&&L.$$typeof===t}function U(L){return I(L)===d}function k(L){return I(L)===r}function Q(L){return I(L)===v}function Z(L){return I(L)===g}function Y(L){return I(L)===n}function ee(L){return I(L)===i}function te(L){return I(L)===o}function le(L){return I(L)===l}Ie.AsyncMode=x,Ie.ConcurrentMode=T,Ie.ContextConsumer=E,Ie.ContextProvider=A,Ie.Element=R,Ie.ForwardRef=P,Ie.Fragment=K,Ie.Lazy=q,Ie.Memo=V,Ie.Portal=M,Ie.Profiler=se,Ie.StrictMode=oe,Ie.Suspense=ge,Ie.isAsyncMode=Oe,Ie.isConcurrentMode=F,Ie.isContextConsumer=$,Ie.isContextProvider=J,Ie.isElement=B,Ie.isForwardRef=U,Ie.isFragment=k,Ie.isLazy=Q,Ie.isMemo=Z,Ie.isPortal=Y,Ie.isProfiler=ee,Ie.isStrictMode=te,Ie.isSuspense=le,Ie.isValidElementType=y,Ie.typeOf=I}()),Ie}var Wc;function Id(){return Wc||(Wc=1,process.env.NODE_ENV==="production"?oo.exports=wI():oo.exports=bI()),oo.exports}/*
|
|
25
25
|
object-assign
|
|
26
26
|
(c) Sindre Sorhus
|
|
27
27
|
@license MIT
|
|
28
|
-
*/var
|
|
29
|
-
Valid keys: `+JSON.stringify(Object.keys(F),null," "));var
|
|
28
|
+
*/var fs,zc;function II(){if(zc)return fs;zc=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 c=Object.getOwnPropertyNames(s).map(function(d){return s[d]});if(c.join("")!=="0123456789")return!1;var f={};return"abcdefghijklmnopqrst".split("").forEach(function(d){f[d]=d}),Object.keys(Object.assign({},f)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return fs=o()?Object.assign:function(i,s){for(var a,c=r(i),f,d=1;d<arguments.length;d++){a=Object(arguments[d]);for(var l in a)t.call(a,l)&&(c[l]=a[l]);if(e){f=e(a);for(var m=0;m<f.length;m++)n.call(a,f[m])&&(c[f[m]]=a[f[m]])}}return c},fs}var ps,Gc;function _a(){if(Gc)return ps;Gc=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ps=e,ps}var hs,Qc;function Cd(){return Qc||(Qc=1,hs=Function.call.bind(Object.prototype.hasOwnProperty)),hs}var ms,Xc;function CI(){if(Xc)return ms;Xc=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var t=_a(),n={},r=Cd();e=function(i){var s="Warning: "+i;typeof console<"u"&&console.error(s);try{throw new Error(s)}catch{}}}function o(i,s,a,c,f){if(process.env.NODE_ENV!=="production"){for(var d in i)if(r(i,d)){var l;try{if(typeof i[d]!="function"){var m=Error((c||"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 m.name="Invariant Violation",m}l=i[d](s,d,c,a,null,t)}catch(v){l=v}if(l&&!(l instanceof Error)&&e((c||"React class")+": type specification of "+a+" `"+d+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof l+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),l instanceof Error&&!(l.message in n)){n[l.message]=!0;var g=f?f():"";e("Failed "+a+" type: "+l.message+(g??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},ms=o,ms}var gs,Yc;function SI(){if(Yc)return gs;Yc=1;var e=Id(),t=II(),n=_a(),r=Cd(),o=CI(),i=function(){};process.env.NODE_ENV!=="production"&&(i=function(a){var c="Warning: "+a;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}});function s(){return null}return gs=function(a,c){var f=typeof Symbol=="function"&&Symbol.iterator,d="@@iterator";function l(F){var $=F&&(f&&F[f]||F[d]);if(typeof $=="function")return $}var m="<<anonymous>>",g={array:S("array"),bigint:S("bigint"),bool:S("boolean"),func:S("function"),number:S("number"),object:S("object"),string:S("string"),symbol:S("symbol"),any:p(),arrayOf:y,element:I(),elementType:x(),instanceOf:T,node:P(),objectOf:A,oneOf:E,oneOfType:R,shape:q,exact:V};function v(F,$){return F===$?F!==0||1/F===1/$:F!==F&&$!==$}function w(F,$){this.message=F,this.data=$&&typeof $=="object"?$:{},this.stack=""}w.prototype=Error.prototype;function h(F){if(process.env.NODE_ENV!=="production")var $={},J=0;function B(k,Q,Z,Y,ee,te,le){if(Y=Y||m,te=te||Z,le!==n){if(c){var L=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 L.name="Invariant Violation",L}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var we=Y+":"+Z;!$[we]&&J<3&&(i("You are manually calling a React.PropTypes validation function for the `"+te+"` prop on `"+Y+"`. 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."),$[we]=!0,J++)}}return Q[Z]==null?k?Q[Z]===null?new w("The "+ee+" `"+te+"` is marked as required "+("in `"+Y+"`, but its value is `null`.")):new w("The "+ee+" `"+te+"` is marked as required in "+("`"+Y+"`, but its value is `undefined`.")):null:F(Q,Z,Y,ee,te)}var U=B.bind(null,!1);return U.isRequired=B.bind(null,!0),U}function S(F){function $(J,B,U,k,Q,Z){var Y=J[B],ee=oe(Y);if(ee!==F){var te=ge(Y);return new w("Invalid "+k+" `"+Q+"` of type "+("`"+te+"` supplied to `"+U+"`, expected ")+("`"+F+"`."),{expectedType:F})}return null}return h($)}function p(){return h(s)}function y(F){function $(J,B,U,k,Q){if(typeof F!="function")return new w("Property `"+Q+"` of component `"+U+"` has invalid PropType notation inside arrayOf.");var Z=J[B];if(!Array.isArray(Z)){var Y=oe(Z);return new w("Invalid "+k+" `"+Q+"` of type "+("`"+Y+"` supplied to `"+U+"`, expected an array."))}for(var ee=0;ee<Z.length;ee++){var te=F(Z,ee,U,k,Q+"["+ee+"]",n);if(te instanceof Error)return te}return null}return h($)}function I(){function F($,J,B,U,k){var Q=$[J];if(!a(Q)){var Z=oe(Q);return new w("Invalid "+U+" `"+k+"` of type "+("`"+Z+"` supplied to `"+B+"`, expected a single ReactElement."))}return null}return h(F)}function x(){function F($,J,B,U,k){var Q=$[J];if(!e.isValidElementType(Q)){var Z=oe(Q);return new w("Invalid "+U+" `"+k+"` of type "+("`"+Z+"` supplied to `"+B+"`, expected a single ReactElement type."))}return null}return h(F)}function T(F){function $(J,B,U,k,Q){if(!(J[B]instanceof F)){var Z=F.name||m,Y=Oe(J[B]);return new w("Invalid "+k+" `"+Q+"` of type "+("`"+Y+"` supplied to `"+U+"`, expected ")+("instance of `"+Z+"`."))}return null}return h($)}function E(F){if(!Array.isArray(F))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 $(J,B,U,k,Q){for(var Z=J[B],Y=0;Y<F.length;Y++)if(v(Z,F[Y]))return null;var ee=JSON.stringify(F,function(le,L){var we=ge(L);return we==="symbol"?String(L):L});return new w("Invalid "+k+" `"+Q+"` of value `"+String(Z)+"` "+("supplied to `"+U+"`, expected one of "+ee+"."))}return h($)}function A(F){function $(J,B,U,k,Q){if(typeof F!="function")return new w("Property `"+Q+"` of component `"+U+"` has invalid PropType notation inside objectOf.");var Z=J[B],Y=oe(Z);if(Y!=="object")return new w("Invalid "+k+" `"+Q+"` of type "+("`"+Y+"` supplied to `"+U+"`, expected an object."));for(var ee in Z)if(r(Z,ee)){var te=F(Z,ee,U,k,Q+"."+ee,n);if(te instanceof Error)return te}return null}return h($)}function R(F){if(!Array.isArray(F))return process.env.NODE_ENV!=="production"&&i("Invalid argument supplied to oneOfType, expected an instance of array."),s;for(var $=0;$<F.length;$++){var J=F[$];if(typeof J!="function")return i("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+me(J)+" at index "+$+"."),s}function B(U,k,Q,Z,Y){for(var ee=[],te=0;te<F.length;te++){var le=F[te],L=le(U,k,Q,Z,Y,n);if(L==null)return null;L.data&&r(L.data,"expectedType")&&ee.push(L.data.expectedType)}var we=ee.length>0?", expected one of type ["+ee.join(", ")+"]":"";return new w("Invalid "+Z+" `"+Y+"` supplied to "+("`"+Q+"`"+we+"."))}return h(B)}function P(){function F($,J,B,U,k){return M($[J])?null:new w("Invalid "+U+" `"+k+"` supplied to "+("`"+B+"`, expected a ReactNode."))}return h(F)}function K(F,$,J,B,U){return new w((F||"React class")+": "+$+" type `"+J+"."+B+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+U+"`.")}function q(F){function $(J,B,U,k,Q){var Z=J[B],Y=oe(Z);if(Y!=="object")return new w("Invalid "+k+" `"+Q+"` of type `"+Y+"` "+("supplied to `"+U+"`, expected `object`."));for(var ee in F){var te=F[ee];if(typeof te!="function")return K(U,k,Q,ee,ge(te));var le=te(Z,ee,U,k,Q+"."+ee,n);if(le)return le}return null}return h($)}function V(F){function $(J,B,U,k,Q){var Z=J[B],Y=oe(Z);if(Y!=="object")return new w("Invalid "+k+" `"+Q+"` of type `"+Y+"` "+("supplied to `"+U+"`, expected `object`."));var ee=t({},J[B],F);for(var te in ee){var le=F[te];if(r(F,te)&&typeof le!="function")return K(U,k,Q,te,ge(le));if(!le)return new w("Invalid "+k+" `"+Q+"` key `"+te+"` supplied to `"+U+"`.\nBad object: "+JSON.stringify(J[B],null," ")+`
|
|
29
|
+
Valid keys: `+JSON.stringify(Object.keys(F),null," "));var L=le(Z,te,U,k,Q+"."+te,n);if(L)return L}return null}return h($)}function M(F){switch(typeof F){case"number":case"string":case"undefined":return!0;case"boolean":return!F;case"object":if(Array.isArray(F))return F.every(M);if(F===null||a(F))return!0;var $=l(F);if($){var J=$.call(F),B;if($!==F.entries){for(;!(B=J.next()).done;)if(!M(B.value))return!1}else for(;!(B=J.next()).done;){var U=B.value;if(U&&!M(U[1]))return!1}}else return!1;return!0;default:return!1}}function se(F,$){return F==="symbol"?!0:$?$["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&$ instanceof Symbol:!1}function oe(F){var $=typeof F;return Array.isArray(F)?"array":F instanceof RegExp?"object":se($,F)?"symbol":$}function ge(F){if(typeof F>"u"||F===null)return""+F;var $=oe(F);if($==="object"){if(F instanceof Date)return"date";if(F instanceof RegExp)return"regexp"}return $}function me(F){var $=ge(F);switch($){case"array":case"object":return"an "+$;case"boolean":case"date":case"regexp":return"a "+$;default:return $}}function Oe(F){return!F.constructor||!F.constructor.name?m:F.constructor.name}return g.checkPropTypes=o,g.resetWarningCache=o.resetWarningCache,g.PropTypes=g,g},gs}var ys,Zc;function xI(){if(Zc)return ys;Zc=1;var e=_a();function t(){}function n(){}return n.resetWarningCache=t,ys=function(){function r(s,a,c,f,d,l){if(l!==e){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}}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},ys}if(process.env.NODE_ENV!=="production"){var OI=Id(),EI=!0;Gs.exports=SI()(OI.isElement,EI)}else Gs.exports=xI()();var _I=Gs.exports;const H=Ca(_I);var Qs={exports:{}},Ce={};/**
|
|
30
30
|
* @license React
|
|
31
31
|
* react-is.production.min.js
|
|
32
32
|
*
|
|
@@ -34,7 +34,7 @@ Valid keys: `+JSON.stringify(Object.keys(F),null," "));var k=le(te,ee,$,L,Z+"."
|
|
|
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 eu;function NI(){if(eu)return Ce;eu=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"),c=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),l=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),v;v=Symbol.for("react.module.reference");function w(h){if(typeof h=="object"&&h!==null){var S=h.$$typeof;switch(S){case e:switch(h=h.type,h){case n:case o:case r:case f:case d:return h;default:switch(h=h&&h.$$typeof,h){case a:case s:case c:case m:case l:case i:return h;default:return S}}case t:return S}}}return Ce.ContextConsumer=s,Ce.ContextProvider=i,Ce.Element=e,Ce.ForwardRef=c,Ce.Fragment=n,Ce.Lazy=m,Ce.Memo=l,Ce.Portal=t,Ce.Profiler=o,Ce.StrictMode=r,Ce.Suspense=f,Ce.SuspenseList=d,Ce.isAsyncMode=function(){return!1},Ce.isConcurrentMode=function(){return!1},Ce.isContextConsumer=function(h){return w(h)===s},Ce.isContextProvider=function(h){return w(h)===i},Ce.isElement=function(h){return typeof h=="object"&&h!==null&&h.$$typeof===e},Ce.isForwardRef=function(h){return w(h)===c},Ce.isFragment=function(h){return w(h)===n},Ce.isLazy=function(h){return w(h)===m},Ce.isMemo=function(h){return w(h)===l},Ce.isPortal=function(h){return w(h)===t},Ce.isProfiler=function(h){return w(h)===o},Ce.isStrictMode=function(h){return w(h)===r},Ce.isSuspense=function(h){return w(h)===f},Ce.isSuspenseList=function(h){return w(h)===d},Ce.isValidElementType=function(h){return typeof h=="string"||typeof h=="function"||h===n||h===o||h===r||h===f||h===d||h===g||typeof h=="object"&&h!==null&&(h.$$typeof===m||h.$$typeof===l||h.$$typeof===i||h.$$typeof===s||h.$$typeof===c||h.$$typeof===v||h.getModuleId!==void 0)},Ce.typeOf=w,Ce}var Se={};/**
|
|
38
38
|
* @license React
|
|
39
39
|
* react-is.development.js
|
|
40
40
|
*
|
|
@@ -42,11 +42,11 @@ Valid keys: `+JSON.stringify(Object.keys(F),null," "));var k=le(te,ee,$,L,Z+"."
|
|
|
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 tl;function DI(){return tl||(tl=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"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),y=!1,v=!1,p=!1,x=!1,h=!1,w;w=Symbol.for("react.module.reference");function I(B){return!!(typeof B=="string"||typeof B=="function"||B===n||B===o||h||B===r||B===d||B===u||x||B===g||y||v||p||typeof B=="object"&&B!==null&&(B.$$typeof===m||B.$$typeof===f||B.$$typeof===i||B.$$typeof===s||B.$$typeof===c||B.$$typeof===w||B.getModuleId!==void 0))}function S(B){if(typeof B=="object"&&B!==null){var We=B.$$typeof;switch(We){case e:var Oe=B.type;switch(Oe){case n:case o:case r:case d:case u:return Oe;default:var mt=Oe&&Oe.$$typeof;switch(mt){case a:case s:case c:case m:case f:case i:return mt;default:return We}}case t:return We}}}var A=s,O=i,N=e,R=c,P=n,J=m,K=f,M=t,W=o,ae=r,re=d,ne=u,ge=!1,ve=!1;function F(B){return ge||(ge=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")),!1}function U(B){return ve||(ve=!0,console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")),!1}function H(B){return S(B)===s}function q(B){return S(B)===i}function $(B){return typeof B=="object"&&B!==null&&B.$$typeof===e}function L(B){return S(B)===c}function Z(B){return S(B)===n}function te(B){return S(B)===m}function Y(B){return S(B)===f}function Q(B){return S(B)===t}function ee(B){return S(B)===o}function le(B){return S(B)===r}function k(B){return S(B)===d}function we(B){return S(B)===u}Se.ContextConsumer=A,Se.ContextProvider=O,Se.Element=N,Se.ForwardRef=R,Se.Fragment=P,Se.Lazy=J,Se.Memo=K,Se.Portal=M,Se.Profiler=W,Se.StrictMode=ae,Se.Suspense=re,Se.SuspenseList=ne,Se.isAsyncMode=F,Se.isConcurrentMode=U,Se.isContextConsumer=H,Se.isContextProvider=q,Se.isElement=$,Se.isForwardRef=L,Se.isFragment=Z,Se.isLazy=te,Se.isMemo=Y,Se.isPortal=Q,Se.isProfiler=ee,Se.isStrictMode=le,Se.isSuspense=k,Se.isSuspenseList=we,Se.isValidElementType=I,Se.typeOf=S}()),Se}process.env.NODE_ENV==="production"?Gs.exports=FI():Gs.exports=DI();var nl=Gs.exports;const rl=e=>typeof e=="object"&&e!=null&&e.nodeType===1,il=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",ys=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return il(n.overflowY,t)||il(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},oo=(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,MI=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},kI=(e,t)=>{var n,r,o,i;if(typeof document>"u")return[];const{scrollMode:s,block:a,inline:c,boundary:d,skipOverflowHiddenElements:u}=t,f=typeof d=="function"?d:re=>re!==d;if(!rl(e))throw new TypeError("Invalid target");const m=document.scrollingElement||document.documentElement,g=[];let y=e;for(;rl(y)&&f(y);){if(y=MI(y),y===m){g.push(y);break}y!=null&&y===document.body&&ys(y)&&!ys(document.documentElement)||y!=null&&ys(y,u)&&g.push(y)}const v=(r=(n=window.visualViewport)==null?void 0:n.width)!=null?r:innerWidth,p=(i=(o=window.visualViewport)==null?void 0:o.height)!=null?i:innerHeight,{scrollX:x,scrollY:h}=window,{height:w,width:I,top:S,right:A,bottom:O,left:N}=e.getBoundingClientRect(),{top:R,right:P,bottom:J,left:K}=(re=>{const ne=window.getComputedStyle(re);return{top:parseFloat(ne.scrollMarginTop)||0,right:parseFloat(ne.scrollMarginRight)||0,bottom:parseFloat(ne.scrollMarginBottom)||0,left:parseFloat(ne.scrollMarginLeft)||0}})(e);let M=a==="start"||a==="nearest"?S-R:a==="end"?O+J:S+w/2-R+J,W=c==="center"?N+I/2-K+P:c==="end"?A+P:N-K;const ae=[];for(let re=0;re<g.length;re++){const ne=g[re],{height:ge,width:ve,top:F,right:U,bottom:H,left:q}=ne.getBoundingClientRect();if(s==="if-needed"&&S>=0&&N>=0&&O<=p&&A<=v&&S>=F&&O<=H&&N>=q&&A<=U)return ae;const $=getComputedStyle(ne),L=parseInt($.borderLeftWidth,10),Z=parseInt($.borderTopWidth,10),te=parseInt($.borderRightWidth,10),Y=parseInt($.borderBottomWidth,10);let Q=0,ee=0;const le="offsetWidth"in ne?ne.offsetWidth-ne.clientWidth-L-te:0,k="offsetHeight"in ne?ne.offsetHeight-ne.clientHeight-Z-Y:0,we="offsetWidth"in ne?ne.offsetWidth===0?0:ve/ne.offsetWidth:0,B="offsetHeight"in ne?ne.offsetHeight===0?0:ge/ne.offsetHeight:0;if(m===ne)Q=a==="start"?M:a==="end"?M-p:a==="nearest"?oo(h,h+p,p,Z,Y,h+M,h+M+w,w):M-p/2,ee=c==="start"?W:c==="center"?W-v/2:c==="end"?W-v:oo(x,x+v,v,L,te,x+W,x+W+I,I),Q=Math.max(0,Q+h),ee=Math.max(0,ee+x);else{Q=a==="start"?M-F-Z:a==="end"?M-H+Y+k:a==="nearest"?oo(F,H,ge,Z,Y+k,M,M+w,w):M-(F+ge/2)+k/2,ee=c==="start"?W-q-L:c==="center"?W-(q+ve/2)+le/2:c==="end"?W-U+te+le:oo(q,U,ve,L,te+le,W,W+I,I);const{scrollLeft:We,scrollTop:Oe}=ne;Q=B===0?0:Math.max(0,Math.min(Oe+Q/B,ne.scrollHeight-ge/B+k)),ee=we===0?0:Math.max(0,Math.min(We+ee/we,ne.scrollWidth-ve/we+le)),M+=Oe-Q,W+=We-ee}ae.push({el:ne,top:Q,left:ee})}return ae};var ei=function(){return ei=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},ei.apply(this,arguments)};var LI=0;function ol(e){return typeof e=="function"?e:_t}function _t(){}function Sd(e,t){if(e){var n=kI(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 sl(e,t,n){var r=e===t||t instanceof n.Node&&e.contains&&e.contains(t);return r}function _a(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 ze(){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 Mr(){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 Ed(){return String(LI++)}function jI(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 al(e,t){return e=Array.isArray(e)?e[0]:e,!e&&t?t:e}function Od(e){return typeof e.type=="string"}function _d(e){return e.props}function KI(e,t){console.error('The property "'+t+'" is required in "'+e+'"')}var UI=["highlightedIndex","inputValue","isOpen","selectedItem","type"];function so(e){e===void 0&&(e={});var t={};return UI.forEach(function(n){e.hasOwnProperty(n)&&(t[n]=e[n])}),t}function Oo(e,t){return!e||!t?e:Object.keys(e).reduce(function(n,r){return n[r]=_o(t,r)?t[r]:e[r],n},{})}function _o(e,t){return e[t]!==void 0}function Qs(e){var t=e.key,n=e.keyCode;return n>=37&&n<=40&&t.indexOf("Arrow")!==0?"Arrow"+t:t}function $I(e){return Object.prototype.toString.call(e)==="[object Object]"}function fr(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 c=ti(a,t<0,n,r,o);return c===-1?e>=i?-1:e:c}function ti(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?ti(t?i-1:0,t,n,r):-1}function No(e,t,n,r){return r===void 0&&(r=!0),n&&t.some(function(o){return o&&(sl(o,e,n)||r&&sl(o,n.document.activeElement,n))})}var Na=_t;process.env.NODE_ENV!=="production"&&(Na=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 qI=_a(function(e){Nd(e).textContent=""},500);function Nd(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 Td(e,t){if(!(!e||!t)){var n=Nd(t);n.textContent=e,qI(t)}}function VI(e){var t=e==null?void 0:e.getElementById("a11y-status-message");t&&t.remove()}var Ad=process.env.NODE_ENV!=="production"?"__autocomplete_unknown__":0,Rd=process.env.NODE_ENV!=="production"?"__autocomplete_mouseup__":1,Pd=process.env.NODE_ENV!=="production"?"__autocomplete_item_mouseenter__":2,po=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_arrow_up__":3,ho=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_arrow_down__":4,Fd=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_escape__":5,Dd=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_enter__":6,Md=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_home__":7,kd=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_end__":8,Ld=process.env.NODE_ENV!=="production"?"__autocomplete_click_item__":9,jd=process.env.NODE_ENV!=="production"?"__autocomplete_blur_input__":10,Kd=process.env.NODE_ENV!=="production"?"__autocomplete_change_input__":11,Ud=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_space_button__":12,Xs=process.env.NODE_ENV!=="production"?"__autocomplete_click_button__":13,$d=process.env.NODE_ENV!=="production"?"__autocomplete_blur_button__":14,qd=process.env.NODE_ENV!=="production"?"__autocomplete_controlled_prop_updated_selected_item__":15,Vd=process.env.NODE_ENV!=="production"?"__autocomplete_touchend__":16,HI=Object.freeze({__proto__:null,blurButton:$d,blurInput:jd,changeInput:Kd,clickButton:Xs,clickItem:Ld,controlledPropUpdatedSelectedItem:qd,itemMouseEnter:Pd,keyDownArrowDown:ho,keyDownArrowUp:po,keyDownEnd:kd,keyDownEnter:Dd,keyDownEscape:Fd,keyDownHome:Md,keyDownSpaceButton:Ud,mouseUp:Rd,touchEnd:Vd,unknown:Ad}),JI=["refKey","ref"],WI=["onClick","onPress","onKeyDown","onKeyUp","onBlur"],BI=["onKeyDown","onBlur","onChange","onInput","onChangeText"],zI=["refKey","ref"],GI=["onMouseMove","onMouseDown","onClick","onPress","index","item"],QI=function(){var e=function(t){function n(o){var i;i=t.call(this,o)||this,i.id=i.props.id||"downshift-"+Ed(),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(h){return i.id+"-item-"+h},i.items=[],i.itemCount=null,i.previousResultCount=0,i.timeoutIds=[],i.internalSetTimeout=function(h,w){var I=setTimeout(function(){i.timeoutIds=i.timeoutIds.filter(function(S){return S!==I}),h()},w);i.timeoutIds.push(I)},i.setItemCount=function(h){i.itemCount=h},i.unsetItemCount=function(){i.itemCount=null},i.isItemDisabled=function(h,w){var I=i.getItemNodeFromIndex(w);return I&&I.hasAttribute("disabled")},i.setHighlightedIndex=function(h,w){h===void 0&&(h=i.props.defaultHighlightedIndex),w===void 0&&(w={}),w=so(w),i.internalSetState(me({highlightedIndex:h},w))},i.clearSelection=function(h){i.internalSetState({selectedItem:null,inputValue:"",highlightedIndex:i.props.defaultHighlightedIndex,isOpen:i.props.defaultIsOpen},h)},i.selectItem=function(h,w,I){w=so(w),i.internalSetState(me({isOpen:i.props.defaultIsOpen,highlightedIndex:i.props.defaultHighlightedIndex,selectedItem:h,inputValue:i.props.itemToString(h)},w),I)},i.selectItemAtIndex=function(h,w,I){var S=i.items[h];S!=null&&i.selectItem(S,w,I)},i.selectHighlightedItem=function(h,w){return i.selectItemAtIndex(i.getState().highlightedIndex,h,w)},i.internalSetState=function(h,w){var I,S,A={},O=typeof h=="function";return!O&&h.hasOwnProperty("inputValue")&&i.props.onInputValueChange(h.inputValue,me({},i.getStateAndHelpers(),h)),i.setState(function(N){var R;N=i.getState(N);var P=O?h(N):h;P=i.props.stateReducer(N,P),I=P.hasOwnProperty("selectedItem");var J={};return I&&P.selectedItem!==N.selectedItem&&(S=P.selectedItem),(R=P).type||(R.type=Ad),Object.keys(P).forEach(function(K){N[K]!==P[K]&&(A[K]=P[K]),K!=="type"&&(P[K],_o(i.props,K)||(J[K]=P[K]))}),O&&P.hasOwnProperty("inputValue")&&i.props.onInputValueChange(P.inputValue,me({},i.getStateAndHelpers(),P)),J},function(){ol(w)();var N=Object.keys(A).length>1;N&&i.props.onStateChange(A,i.getStateAndHelpers()),I&&i.props.onSelect(h.selectedItem,i.getStateAndHelpers()),S!==void 0&&i.props.onChange(S,i.getStateAndHelpers()),i.props.onUserAction(A,i.getStateAndHelpers())})},i.rootRef=function(h){return i._rootNode=h},i.getRootProps=function(h,w){var I,S=h===void 0?{}:h,A=S.refKey,O=A===void 0?"ref":A,N=S.ref,R=xn(S,JI),P=w===void 0?{}:w,J=P.suppressRefError,K=J===void 0?!1:J;i.getRootProps.called=!0,i.getRootProps.refKey=O,i.getRootProps.suppressRefError=K;var M=i.getState(),W=M.isOpen;return me((I={},I[O]=Mr(N,i.rootRef),I.role="combobox",I["aria-expanded"]=W,I["aria-haspopup"]="listbox",I["aria-owns"]=W?i.menuId:void 0,I["aria-labelledby"]=i.labelId,I),R)},i.keyDownHandlers={ArrowDown:function(w){var I=this;if(w.preventDefault(),this.getState().isOpen){var S=w.shiftKey?5:1;this.moveHighlightedIndex(S,{type:ho})}else this.internalSetState({isOpen:!0,type:ho},function(){var A=I.getItemCount();if(A>0){var O=I.getState(),N=O.highlightedIndex,R=fr(N,1,{length:A},I.isItemDisabled,!0);I.setHighlightedIndex(R,{type:ho})}})},ArrowUp:function(w){var I=this;if(w.preventDefault(),this.getState().isOpen){var S=w.shiftKey?-5:-1;this.moveHighlightedIndex(S,{type:po})}else this.internalSetState({isOpen:!0,type:po},function(){var A=I.getItemCount();if(A>0){var O=I.getState(),N=O.highlightedIndex,R=fr(N,-1,{length:A},I.isItemDisabled,!0);I.setHighlightedIndex(R,{type:po})}})},Enter:function(w){if(w.which!==229){var I=this.getState(),S=I.isOpen,A=I.highlightedIndex;if(S&&A!=null){w.preventDefault();var O=this.items[A],N=this.getItemNodeFromIndex(A);if(O==null||N&&N.hasAttribute("disabled"))return;this.selectHighlightedItem({type:Dd})}}},Escape:function(w){w.preventDefault(),this.reset(me({type:Fd},!this.state.isOpen&&{selectedItem:null,inputValue:""}))}},i.buttonKeyDownHandlers=me({},i.keyDownHandlers,{" ":function(w){w.preventDefault(),this.toggleMenu({type:Ud})}}),i.inputKeyDownHandlers=me({},i.keyDownHandlers,{Home:function(w){var I=this.getState(),S=I.isOpen;if(S){w.preventDefault();var A=this.getItemCount();if(!(A<=0||!S)){var O=ti(0,!1,{length:A},this.isItemDisabled);this.setHighlightedIndex(O,{type:Md})}}},End:function(w){var I=this.getState(),S=I.isOpen;if(S){w.preventDefault();var A=this.getItemCount();if(!(A<=0||!S)){var O=ti(A-1,!0,{length:A},this.isItemDisabled);this.setHighlightedIndex(O,{type:kd})}}}}),i.getToggleButtonProps=function(h){var w=h===void 0?{}:h,I=w.onClick;w.onPress;var S=w.onKeyDown,A=w.onKeyUp,O=w.onBlur,N=xn(w,WI),R=i.getState(),P=R.isOpen,J={onClick:ze(I,i.buttonHandleClick),onKeyDown:ze(S,i.buttonHandleKeyDown),onKeyUp:ze(A,i.buttonHandleKeyUp),onBlur:ze(O,i.buttonHandleBlur)},K=N.disabled?{}:J;return me({type:"button",role:"button","aria-label":P?"close menu":"open menu","aria-haspopup":!0,"data-toggle":!0},K,N)},i.buttonHandleKeyUp=function(h){h.preventDefault()},i.buttonHandleKeyDown=function(h){var w=Qs(h);i.buttonKeyDownHandlers[w]&&i.buttonKeyDownHandlers[w].call(i,h)},i.buttonHandleClick=function(h){if(h.preventDefault(),i.props.environment){var w=i.props.environment.document,I=w.body,S=w.activeElement;I&&I===S&&h.target.focus()}process.env.NODE_ENV==="test"?i.toggleMenu({type:Xs}):i.internalSetTimeout(function(){return i.toggleMenu({type:Xs})})},i.buttonHandleBlur=function(h){var w=h.target;i.internalSetTimeout(function(){if(!(i.isMouseDown||!i.props.environment)){var I=i.props.environment.document.activeElement;(I==null||I.id!==i.inputId)&&I!==w&&i.reset({type:$d})}})},i.getLabelProps=function(h){return me({htmlFor:i.inputId,id:i.labelId},h)},i.getInputProps=function(h){var w=h===void 0?{}:h,I=w.onKeyDown,S=w.onBlur,A=w.onChange,O=w.onInput;w.onChangeText;var N=xn(w,BI),R,P={};R="onChange";var J=i.getState(),K=J.inputValue,M=J.isOpen,W=J.highlightedIndex;if(!N.disabled){var ae;P=(ae={},ae[R]=ze(A,O,i.inputHandleChange),ae.onKeyDown=ze(I,i.inputHandleKeyDown),ae.onBlur=ze(S,i.inputHandleBlur),ae)}return me({"aria-autocomplete":"list","aria-activedescendant":M&&typeof W=="number"&&W>=0?i.getItemId(W):void 0,"aria-controls":M?i.menuId:void 0,"aria-labelledby":N&&N["aria-label"]?void 0:i.labelId,autoComplete:"off",value:K,id:i.inputId},P,N)},i.inputHandleKeyDown=function(h){var w=Qs(h);w&&i.inputKeyDownHandlers[w]&&i.inputKeyDownHandlers[w].call(i,h)},i.inputHandleChange=function(h){i.internalSetState({type:Kd,isOpen:!0,inputValue:h.target.value,highlightedIndex:i.props.defaultHighlightedIndex})},i.inputHandleBlur=function(){i.internalSetTimeout(function(){var h;if(!(i.isMouseDown||!i.props.environment)){var w=i.props.environment.document.activeElement,I=(w==null||(h=w.dataset)==null?void 0:h.toggle)&&i._rootNode&&i._rootNode.contains(w);I||i.reset({type:jd})}})},i.menuRef=function(h){i._menuNode=h},i.getMenuProps=function(h,w){var I,S=h===void 0?{}:h,A=S.refKey,O=A===void 0?"ref":A,N=S.ref,R=xn(S,zI),P=w===void 0?{}:w,J=P.suppressRefError,K=J===void 0?!1:J;return i.getMenuProps.called=!0,i.getMenuProps.refKey=O,i.getMenuProps.suppressRefError=K,me((I={},I[O]=Mr(N,i.menuRef),I.role="listbox",I["aria-labelledby"]=R&&R["aria-label"]?void 0:i.labelId,I.id=i.menuId,I),R)},i.getItemProps=function(h){var w,I=h===void 0?{}:h,S=I.onMouseMove,A=I.onMouseDown,O=I.onClick;I.onPress;var N=I.index,R=I.item,P=R===void 0?process.env.NODE_ENV==="production"?void 0:KI("getItemProps","item"):R,J=xn(I,GI);N===void 0?(i.items.push(P),N=i.items.indexOf(P)):i.items[N]=P;var K="onClick",M=O,W=(w={onMouseMove:ze(S,function(){N!==i.getState().highlightedIndex&&(i.setHighlightedIndex(N,{type:Pd}),i.avoidScrolling=!0,i.internalSetTimeout(function(){return i.avoidScrolling=!1},250))}),onMouseDown:ze(A,function(re){re.preventDefault()})},w[K]=ze(M,function(){i.selectItemAtIndex(N,{type:Ld})}),w),ae=J.disabled?{onMouseDown:W.onMouseDown}:W;return me({id:i.getItemId(N),role:"option","aria-selected":i.getState().highlightedIndex===N},ae,J)},i.clearItems=function(){i.items=[]},i.reset=function(h,w){h===void 0&&(h={}),h=so(h),i.internalSetState(function(I){var S=I.selectedItem;return me({isOpen:i.props.defaultIsOpen,highlightedIndex:i.props.defaultHighlightedIndex,inputValue:i.props.itemToString(S)},h)},w)},i.toggleMenu=function(h,w){h===void 0&&(h={}),h=so(h),i.internalSetState(function(I){var S=I.isOpen;return me({isOpen:!S},S&&{highlightedIndex:i.props.defaultHighlightedIndex},h)},function(){var I=i.getState(),S=I.isOpen,A=I.highlightedIndex;S&&i.getItemCount()>0&&typeof A=="number"&&i.setHighlightedIndex(A,h),ol(w)()})},i.openMenu=function(h){i.internalSetState({isOpen:!0},h)},i.closeMenu=function(h){i.internalSetState({isOpen:!1},h)},i.updateStatus=_a(function(){var h;if((h=i.props)!=null&&(h=h.environment)!=null&&h.document){var w=i.getState(),I=i.items[w.highlightedIndex],S=i.getItemCount(),A=i.props.getA11yStatusMessage(me({itemToString:i.props.itemToString,previousResultCount:i.previousResultCount,resultCount:S,highlightedItem:I},w));i.previousResultCount=S,Td(A,i.props.environment.document)}},200);var s=i.props,a=s.defaultHighlightedIndex,c=s.initialHighlightedIndex,d=c===void 0?a:c,u=s.defaultIsOpen,f=s.initialIsOpen,m=f===void 0?u:f,g=s.initialInputValue,y=g===void 0?"":g,v=s.initialSelectedItem,p=v===void 0?null:v,x=i.getState({highlightedIndex:d,isOpen:m,inputValue:y,selectedItem:p});return x.selectedItem!=null&&i.props.initialInputValue===void 0&&(x.inputValue=i.props.itemToString(x.selectedItem)),i.state=x,i}xI(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),Oo(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(),c=this.getState(),d=c.highlightedIndex;if(a>0){var u=fr(d,i,{length:a},this.isItemDisabled,!0);this.setHighlightedIndex(u,s)}},r.getStateAndHelpers=function(){var i=this.getState(),s=i.highlightedIndex,a=i.inputValue,c=i.selectedItem,d=i.isOpen,u=this.props.itemToString,f=this.id,m=this.getRootProps,g=this.getToggleButtonProps,y=this.getLabelProps,v=this.getMenuProps,p=this.getInputProps,x=this.getItemProps,h=this.openMenu,w=this.closeMenu,I=this.toggleMenu,S=this.selectItem,A=this.selectItemAtIndex,O=this.selectHighlightedItem,N=this.setHighlightedIndex,R=this.clearSelection,P=this.clearItems,J=this.reset,K=this.setItemCount,M=this.unsetItemCount,W=this.internalSetState;return{getRootProps:m,getToggleButtonProps:g,getLabelProps:y,getMenuProps:v,getInputProps:p,getItemProps:x,reset:J,openMenu:h,closeMenu:w,toggleMenu:I,selectItem:S,selectItemAtIndex:A,selectHighlightedItem:O,setHighlightedIndex:N,clearSelection:R,clearItems:P,setItemCount:K,unsetItemCount:M,setState:W,itemToString:u,id:f,highlightedIndex:s,inputValue:a,isOpen:d,selectedItem:c}},r.componentDidMount=function(){var i=this;if(process.env.NODE_ENV!=="production"&&this.getMenuProps.called&&!this.getMenuProps.suppressRefError&&cl(this._menuNode,this.getMenuProps),!this.props.environment)this.cleanup=function(){i.internalClearTimeouts()};else{var s=function(){i.isMouseDown=!0},a=function(g){i.isMouseDown=!1;var y=No(g.target,[i._rootNode,i._menuNode],i.props.environment);!y&&i.getState().isOpen&&i.reset({type:Rd},function(){return i.props.onOuterClick(i.getStateAndHelpers())})},c=function(){i.isTouchMove=!1},d=function(){i.isTouchMove=!0},u=function(g){var y=No(g.target,[i._rootNode,i._menuNode],i.props.environment,!1);!i.isTouchMove&&!y&&i.getState().isOpen&&i.reset({type:Vd},function(){return i.props.onOuterClick(i.getStateAndHelpers())})},f=this.props.environment;f.addEventListener("mousedown",s),f.addEventListener("mouseup",a),f.addEventListener("touchstart",c),f.addEventListener("touchmove",d),f.addEventListener("touchend",u),this.cleanup=function(){i.internalClearTimeouts(),i.updateStatus.cancel(),f.removeEventListener("mousedown",s),f.removeEventListener("mouseup",a),f.removeEventListener("touchstart",c),f.removeEventListener("touchmove",d),f.removeEventListener("touchend",u)}}},r.shouldScroll=function(i,s){var a=this.props.highlightedIndex===void 0?this.getState():this.props,c=a.highlightedIndex,d=s.highlightedIndex===void 0?i:s,u=d.highlightedIndex,f=c&&this.getState().isOpen&&!i.isOpen,m=c!==u;return f||m},r.componentDidUpdate=function(i,s){process.env.NODE_ENV!=="production"&&(Na(this.state,i,this.props),this.getMenuProps.called&&!this.getMenuProps.suppressRefError&&cl(this._menuNode,this.getMenuProps)),_o(this.props,"selectedItem")&&this.props.selectedItemChanged(i.selectedItem,this.props.selectedItem)&&this.internalSetState({type:qd,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=al(this.props.children,_t);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=al(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&&XI(s,this.getRootProps),s;if(Od(s))return b.cloneElement(s,this.getRootProps(_d(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}(b.Component);return e.defaultProps={defaultHighlightedIndex:null,defaultIsOpen:!1,getA11yStatusMessage:jI,itemToString:function(n){return n==null?"":(process.env.NODE_ENV!=="production"&&$I(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:_t,onInputValueChange:_t,onUserAction:_t,onChange:_t,onSelect:_t,onOuterClick:_t,selectedItemChanged:function(n,r){return n!==r},environment:typeof window>"u"?void 0:window,stateReducer:function(n,r){return r},suppressRefError:!1,scrollIntoView:Sd},e.stateChangeTypes=HI,e}();process.env.NODE_ENV!=="production"&&(QI.propTypes={children:V.func,defaultHighlightedIndex:V.number,defaultIsOpen:V.bool,initialHighlightedIndex:V.number,initialSelectedItem:V.any,initialInputValue:V.string,initialIsOpen:V.bool,getA11yStatusMessage:V.func,itemToString:V.func,onChange:V.func,onSelect:V.func,onStateChange:V.func,onInputValueChange:V.func,onUserAction:V.func,onOuterClick:V.func,selectedItemChanged:V.func,stateReducer:V.func,itemCount:V.number,id:V.string,environment:V.shape({addEventListener:V.func.isRequired,removeEventListener:V.func.isRequired,document:V.shape({createElement:V.func.isRequired,getElementById:V.func.isRequired,activeElement:V.any.isRequired,body:V.any.isRequired}).isRequired,Node:V.func.isRequired}),suppressRefError:V.bool,scrollIntoView:V.func,selectedItem:V.any,isOpen:V.bool,inputValue:V.string,highlightedIndex:V.number,labelId:V.string,inputId:V.string,menuId:V.string,getItemId:V.func});function cl(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 XI(e,t){var n=t.refKey,r=n!=="ref",o=!Od(e);o&&!r&&!nl.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+'"'),!nl.isForwardRef(e)&&!_d(e)[n]&&console.error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.')}var Hd={highlightedIndex:-1,isOpen:!1,selectedItem:null,inputValue:""};function YI(e,t,n){var r=e.props,o=e.type,i={};Object.keys(t).forEach(function(s){ZI(s,e,t,n),n[s]!==t[s]&&(i[s]=n[s])}),r.onStateChange&&Object.keys(i).length&&r.onStateChange(me({type:o},i))}function ZI(e,t,n,r){var o=t.props,i=t.type,s="on"+Ta(e)+"Change";o[s]&&r[e]!==void 0&&r[e]!==n[e]&&o[s](me({type:i},r))}function eC(e,t){return t.changes}var ll=_a(function(e,t){Td(e,t)},200),tC=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?b.useLayoutEffect:b.useEffect,nC="useId"in b?function(t){var n=t.id,r=t.labelId,o=t.menuId,i=t.getItemId,s=t.toggleButtonId,a=t.inputId,c="downshift-"+b.useId();n||(n=c);var d=b.useRef({labelId:r||n+"-label",menuId:o||n+"-menu",getItemId:i||function(u){return n+"-item-"+u},toggleButtonId:s||n+"-toggle-button",inputId:a||n+"-input"});return d.current}:function(t){var n=t.id,r=n===void 0?"downshift-"+Ed():n,o=t.labelId,i=t.menuId,s=t.getItemId,a=t.toggleButtonId,c=t.inputId,d=b.useRef({labelId:o||r+"-label",menuId:i||r+"-menu",getItemId:s||function(u){return r+"-item-"+u},toggleButtonId:a||r+"-toggle-button",inputId:c||r+"-input"});return d.current};function rC(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 Ta(e){return""+e.slice(0,1).toUpperCase()+e.slice(1)}function Jd(e){var t=b.useRef(e);return t.current=e,t}function iC(e,t,n,r){var o=b.useRef(),i=b.useRef(),s=b.useCallback(function(g,y){i.current=y,g=Oo(g,y.props);var v=e(g,y),p=y.props.stateReducer(g,me({},y,{changes:v}));return p},[e]),a=b.useReducer(s,t,n),c=a[0],d=a[1],u=Jd(t),f=b.useCallback(function(g){return d(me({props:u.current},g))},[u]),m=i.current;return b.useEffect(function(){var g=Oo(o.current,m==null?void 0:m.props),y=m&&o.current&&!r(g,c);y&&YI(m,g,c),o.current=c},[c,m,r]),[c,f]}var wi={itemToString:function(t){return t?String(t):""},itemToKey:function(t){return t},stateReducer:eC,scrollIntoView:Sd,environment:typeof window>"u"?void 0:window};function Qn(e,t,n){n===void 0&&(n=Hd);var r=e["default"+Ta(t)];return r!==void 0?r:n[t]}function bi(e,t,n){n===void 0&&(n=Hd);var r=e[t];if(r!==void 0)return r;var o=e["initial"+Ta(t)];return o!==void 0?o:Qn(e,t,n)}function oC(e){var t=bi(e,"selectedItem"),n=bi(e,"isOpen"),r=uC(e),o=bi(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 Ii(e,t,n){var r=e.items,o=e.initialHighlightedIndex,i=e.defaultHighlightedIndex,s=e.isItemDisabled,a=e.itemToKey,c=t.selectedItem,d=t.highlightedIndex;return r.length===0?-1:o!==void 0&&d===o&&!s(r[o],o)?o:i!==void 0&&!s(r[i],i)?i:c?r.findIndex(function(u){return a(c)===a(u)}):n<0&&!s(r[r.length-1],r.length-1)?r.length-1:n>0&&!s(r[0],0)?0:-1}function sC(e,t,n){var r=b.useRef({isMouseDown:!1,isTouchMove:!1,isTouchEnd:!1});return b.useEffect(function(){if(!e)return _t;var o=n.map(function(u){return u.current});function i(){r.current.isTouchEnd=!1,r.current.isMouseDown=!0}function s(u){r.current.isMouseDown=!1,No(u.target,o,e)||t()}function a(){r.current.isTouchEnd=!1,r.current.isTouchMove=!1}function c(){r.current.isTouchMove=!0}function d(u){r.current.isTouchEnd=!0,!r.current.isTouchMove&&!No(u.target,o,e,!1)&&t()}return e.addEventListener("mousedown",i),e.addEventListener("mouseup",s),e.addEventListener("touchstart",a),e.addEventListener("touchmove",c),e.addEventListener("touchend",d),function(){e.removeEventListener("mousedown",i),e.removeEventListener("mouseup",s),e.removeEventListener("touchstart",a),e.removeEventListener("touchmove",c),e.removeEventListener("touchend",d)}},[n,e,t]),r.current}var Wd=function(){return _t};process.env.NODE_ENV!=="production"&&(Wd=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o=b.useRef(n.reduce(function(s,a){return s[a]={},s},{}));b.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 c=a.suppressRefError,d=a.refKey,u=a.elementRef;c||u!=null&&u.current||console.error('downshift: The ref prop "'+d+'" from '+s+" was not applied correctly on your element.")})},[]);var i=b.useCallback(function(s,a,c,d){o.current[s]={suppressRefError:a,refKey:c,elementRef:d}},[]);return i});function aC(e,t,n,r){r===void 0&&(r={});var o=r.document,i=Ho();b.useEffect(function(){if(!(!e||i||!o)){var s=e(t);ll(s,o)}},n),b.useEffect(function(){return function(){ll.cancel(),VI(o)}},[o])}function cC(e){var t=e.highlightedIndex,n=e.isOpen,r=e.itemRefs,o=e.getItemNodeFromIndex,i=e.menuElement,s=e.scrollIntoView,a=b.useRef(!0);return tC(function(){t<0||!n||!Object.keys(r.current).length||(a.current===!1?a.current=!0:s(o(t),i))},[t]),a}var Bd=_t;process.env.NODE_ENV!=="production"&&(Bd=function(t){var n=t.props,r=t.state,o=b.useRef(n),i=Ho();b.useEffect(function(){i||(Na(r,o.current,n),o.current=n)},[r,n,i])});function ul(e,t,n){var r;n===void 0&&(n=!0);var o=((r=e.items)==null?void 0:r.length)&&t>=0;return me({isOpen:!1,highlightedIndex:-1},o&&me({selectedItem:e.items[t],isOpen:Qn(e,"isOpen"),highlightedIndex:Qn(e,"highlightedIndex")},n&&{inputValue:e.itemToString(e.items[t])}))}function lC(e,t){return e.isOpen===t.isOpen&&e.inputValue===t.inputValue&&e.highlightedIndex===t.highlightedIndex&&e.selectedItem===t.selectedItem}function Ho(){var e=b.useRef(!0);return b.useEffect(function(){return e.current=!1,function(){e.current=!0}},[]),e.current}function Ys(e){var t=Qn(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}function uC(e){var t=bi(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}var mo={environment:V.shape({addEventListener:V.func.isRequired,removeEventListener:V.func.isRequired,document:V.shape({createElement:V.func.isRequired,getElementById:V.func.isRequired,activeElement:V.any.isRequired,body:V.any.isRequired}).isRequired,Node:V.func.isRequired}),itemToString:V.func,itemToKey:V.func,stateReducer:V.func},zd=me({},mo,{getA11yStatusMessage:V.func,highlightedIndex:V.number,defaultHighlightedIndex:V.number,initialHighlightedIndex:V.number,isOpen:V.bool,defaultIsOpen:V.bool,initialIsOpen:V.bool,selectedItem:V.any,initialSelectedItem:V.any,defaultSelectedItem:V.any,id:V.string,labelId:V.string,menuId:V.string,getItemId:V.func,toggleButtonId:V.string,onSelectedItemChange:V.func,onHighlightedIndexChange:V.func,onStateChange:V.func,onIsOpenChange:V.func,scrollIntoView:V.func});function dC(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:Ii(o,e,0)};break;case n.FunctionOpenMenu:i={isOpen:!0,highlightedIndex:Ii(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:Ys(o),isOpen:Qn(o,"isOpen"),selectedItem:Qn(o,"selectedItem"),inputValue:Qn(o,"inputValue")};break;default:throw new Error("Reducer called without proper action type.")}return me({},e,i)}ei(ei({},zd),{items:V.array.isRequired,isItemDisabled:V.func});ei(ei({},wi),{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 Aa=process.env.NODE_ENV!=="production"?"__input_keydown_arrow_down__":0,Ra=process.env.NODE_ENV!=="production"?"__input_keydown_arrow_up__":1,Pa=process.env.NODE_ENV!=="production"?"__input_keydown_escape__":2,Fa=process.env.NODE_ENV!=="production"?"__input_keydown_home__":3,Da=process.env.NODE_ENV!=="production"?"__input_keydown_end__":4,Ma=process.env.NODE_ENV!=="production"?"__input_keydown_page_up__":5,ka=process.env.NODE_ENV!=="production"?"__input_keydown_page_down__":6,La=process.env.NODE_ENV!=="production"?"__input_keydown_enter__":7,ja=process.env.NODE_ENV!=="production"?"__input_change__":8,To=process.env.NODE_ENV!=="production"?"__input_blur__":9,Ka=process.env.NODE_ENV!=="production"?"__input_click__":10,Gd=process.env.NODE_ENV!=="production"?"__menu_mouse_leave__":11,Qd=process.env.NODE_ENV!=="production"?"__item_mouse_move__":12,Ua=process.env.NODE_ENV!=="production"?"__item_click__":13,Xd=process.env.NODE_ENV!=="production"?"__togglebutton_click__":14,Yd=process.env.NODE_ENV!=="production"?"__function_toggle_menu__":15,Zd=process.env.NODE_ENV!=="production"?"__function_open_menu__":16,ef=process.env.NODE_ENV!=="production"?"__function_close_menu__":17,tf=process.env.NODE_ENV!=="production"?"__function_set_highlighted_index__":18,$a=process.env.NODE_ENV!=="production"?"__function_select_item__":19,nf=process.env.NODE_ENV!=="production"?"__function_set_input_value__":20,rf=process.env.NODE_ENV!=="production"?"__function_reset__":21,qa=process.env.NODE_ENV!=="production"?"__controlled_prop_updated_selected_item__":22,of=Object.freeze({__proto__:null,ControlledPropUpdatedSelectedItem:qa,FunctionCloseMenu:ef,FunctionOpenMenu:Zd,FunctionReset:rf,FunctionSelectItem:$a,FunctionSetHighlightedIndex:tf,FunctionSetInputValue:nf,FunctionToggleMenu:Yd,InputBlur:To,InputChange:ja,InputClick:Ka,InputKeyDownArrowDown:Aa,InputKeyDownArrowUp:Ra,InputKeyDownEnd:Da,InputKeyDownEnter:La,InputKeyDownEscape:Pa,InputKeyDownHome:Fa,InputKeyDownPageDown:ka,InputKeyDownPageUp:Ma,ItemClick:Ua,ItemMouseMove:Qd,MenuMouseLeave:Gd,ToggleButtonClick:Xd});function fC(e){var t=oC(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)),me({},t,{inputValue:r})}var pC=me({},zd,{items:V.array.isRequired,isItemDisabled:V.func,inputValue:V.string,defaultInputValue:V.string,initialInputValue:V.string,inputId:V.string,onInputValueChange:V.func});function hC(e,t,n,r){var o=b.useRef(),i=iC(e,t,n,r),s=i[0],a=i[1],c=Ho();return b.useEffect(function(){if(_o(t,"selectedItem")){if(!c){var d=t.itemToKey(t.selectedItem)!==t.itemToKey(o.current);d&&a({type:qa,inputValue:t.itemToString(t.selectedItem)})}o.current=s.selectedItem===o.current?t.selectedItem:s.selectedItem}},[s.selectedItem,t.selectedItem]),[Oo(s,t),a]}var sf=_t;process.env.NODE_ENV!=="production"&&(sf=function(t,n){V.checkPropTypes(pC,t,"prop",n.name)});var mC=me({},wi,{isItemDisabled:function(){return!1}});function gC(e,t){var n,r=t.type,o=t.props,i=t.altKey,s;switch(r){case Ua:s={isOpen:Qn(o,"isOpen"),highlightedIndex:Ys(o),selectedItem:o.items[t.index],inputValue:o.itemToString(o.items[t.index])};break;case Aa:e.isOpen?s={highlightedIndex:fr(e.highlightedIndex,1,o.items,o.isItemDisabled,!0)}:s={highlightedIndex:i&&e.selectedItem==null?-1:Ii(o,e,1),isOpen:o.items.length>=0};break;case Ra:e.isOpen?i?s=ul(o,e.highlightedIndex):s={highlightedIndex:fr(e.highlightedIndex,-1,o.items,o.isItemDisabled,!0)}:s={highlightedIndex:Ii(o,e,-1),isOpen:o.items.length>=0};break;case La:s=ul(o,e.highlightedIndex);break;case Pa:s=me({isOpen:!1,highlightedIndex:-1},!e.isOpen&&{selectedItem:null,inputValue:""});break;case Ma:s={highlightedIndex:fr(e.highlightedIndex,-10,o.items,o.isItemDisabled,!0)};break;case ka:s={highlightedIndex:fr(e.highlightedIndex,10,o.items,o.isItemDisabled,!0)};break;case Fa:s={highlightedIndex:ti(0,!1,o.items,o.isItemDisabled)};break;case Da:s={highlightedIndex:ti(o.items.length-1,!0,o.items,o.isItemDisabled)};break;case To:s=me({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 ja:s={isOpen:!0,highlightedIndex:Ys(o),inputValue:t.inputValue};break;case Ka:s={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:Ii(o,e,0)};break;case $a:s={selectedItem:t.selectedItem,inputValue:o.itemToString(t.selectedItem)};break;case qa:s={inputValue:t.inputValue};break;default:return dC(e,t,of)}return me({},e,s)}var yC=["onMouseLeave","refKey","ref"],vC=["item","index","refKey","ref","onMouseMove","onMouseDown","onClick","onPress","disabled"],wC=["onClick","onPress","refKey","ref"],bC=["onKeyDown","onChange","onInput","onBlur","onChangeText","onClick","refKey","ref"];Va.stateChangeTypes=of;function Va(e){e===void 0&&(e={}),sf(e,Va);var t=me({},mC,e),n=t.items,r=t.scrollIntoView,o=t.environment,i=t.getA11yStatusMessage,s=hC(gC,t,fC,lC),a=s[0],c=s[1],d=a.isOpen,u=a.highlightedIndex,f=a.selectedItem,m=a.inputValue,g=b.useRef(null),y=b.useRef({}),v=b.useRef(null),p=b.useRef(null),x=Ho(),h=nC(t),w=b.useRef(),I=Jd({state:a,props:t}),S=b.useCallback(function(H){return y.current[h.getItemId(H)]},[h]);aC(i,a,[d,u,f,m],o);var A=cC({menuElement:g.current,highlightedIndex:u,isOpen:d,itemRefs:y,scrollIntoView:r,getItemNodeFromIndex:S});Bd({props:t,state:a}),b.useEffect(function(){var H=bi(t,"isOpen");H&&v.current&&v.current.focus()},[]),b.useEffect(function(){x||(w.current=n.length)});var O=sC(o,b.useCallback(function(){I.current.state.isOpen&&c({type:To,selectItem:!1})},[c,I]),b.useMemo(function(){return[g,p,v]},[g.current,p.current,v.current])),N=Wd("getInputProps","getMenuProps");b.useEffect(function(){d||(y.current={})},[d]),b.useEffect(function(){var H;!d||!(o!=null&&o.document)||!(v!=null&&(H=v.current)!=null&&H.focus)||o.document.activeElement!==v.current&&v.current.focus()},[d,o]);var R=b.useMemo(function(){return{ArrowDown:function(q){q.preventDefault(),c({type:Aa,altKey:q.altKey})},ArrowUp:function(q){q.preventDefault(),c({type:Ra,altKey:q.altKey})},Home:function(q){I.current.state.isOpen&&(q.preventDefault(),c({type:Fa}))},End:function(q){I.current.state.isOpen&&(q.preventDefault(),c({type:Da}))},Escape:function(q){var $=I.current.state;($.isOpen||$.inputValue||$.selectedItem||$.highlightedIndex>-1)&&(q.preventDefault(),c({type:Pa}))},Enter:function(q){var $=I.current.state;!$.isOpen||q.which===229||(q.preventDefault(),c({type:La}))},PageUp:function(q){I.current.state.isOpen&&(q.preventDefault(),c({type:Ma}))},PageDown:function(q){I.current.state.isOpen&&(q.preventDefault(),c({type:ka}))}}},[c,I]),P=b.useCallback(function(H){return me({id:h.labelId,htmlFor:h.inputId},H)},[h]),J=b.useCallback(function(H,q){var $,L=H===void 0?{}:H,Z=L.onMouseLeave,te=L.refKey,Y=te===void 0?"ref":te,Q=L.ref,ee=xn(L,yC),le=q===void 0?{}:q,k=le.suppressRefError,we=k===void 0?!1:k;return N("getMenuProps",we,Y,g),me(($={},$[Y]=Mr(Q,function(B){g.current=B}),$.id=h.menuId,$.role="listbox",$["aria-labelledby"]=ee&&ee["aria-label"]?void 0:""+h.labelId,$.onMouseLeave=ze(Z,function(){c({type:Gd})}),$),ee)},[c,N,h]),K=b.useCallback(function(H){var q,$,L=H===void 0?{}:H,Z=L.item,te=L.index,Y=L.refKey,Q=Y===void 0?"ref":Y,ee=L.ref,le=L.onMouseMove,k=L.onMouseDown,we=L.onClick;L.onPress;var B=L.disabled,We=xn(L,vC);B!==void 0&&console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.');var Oe=I.current,mt=Oe.props,Be=Oe.state,gt=rC(Z,te,mt.items,"Pass either item or index to getItemProps!"),_e=gt[0],et=gt[1],St=mt.isItemDisabled(_e,et),Vt="onClick",Pt=we,ut=function(){O.isTouchEnd||et===Be.highlightedIndex||(A.current=!1,c({type:Qd,index:et,disabled:St}))},ot=function(){c({type:Ua,index:et})},Me=function(Ft){return Ft.preventDefault()};return me((q={},q[Q]=Mr(ee,function(qe){qe&&(y.current[h.getItemId(et)]=qe)}),q["aria-disabled"]=St,q["aria-selected"]=et===Be.highlightedIndex,q.id=h.getItemId(et),q.role="option",q),!St&&($={},$[Vt]=ze(Pt,ot),$),{onMouseMove:ze(le,ut),onMouseDown:ze(k,Me)},We)},[c,h,I,O,A]),M=b.useCallback(function(H){var q,$=H===void 0?{}:H,L=$.onClick;$.onPress;var Z=$.refKey,te=Z===void 0?"ref":Z,Y=$.ref,Q=xn($,wC),ee=I.current.state,le=function(){c({type:Xd})};return me((q={},q[te]=Mr(Y,function(k){p.current=k}),q["aria-controls"]=h.menuId,q["aria-expanded"]=ee.isOpen,q.id=h.toggleButtonId,q.tabIndex=-1,q),!Q.disabled&&me({},{onClick:ze(L,le)}),Q)},[c,I,h]),W=b.useCallback(function(H,q){var $,L=H===void 0?{}:H,Z=L.onKeyDown,te=L.onChange,Y=L.onInput,Q=L.onBlur;L.onChangeText;var ee=L.onClick,le=L.refKey,k=le===void 0?"ref":le,we=L.ref,B=xn(L,bC),We=q===void 0?{}:q,Oe=We.suppressRefError,mt=Oe===void 0?!1:Oe;N("getInputProps",mt,k,v);var Be=I.current.state,gt=function(Me){var qe=Qs(Me);qe&&R[qe]&&R[qe](Me)},_e=function(Me){c({type:ja,inputValue:Me.target.value})},et=function(Me){if(o!=null&&o.document&&Be.isOpen&&!O.isMouseDown){var qe=Me.relatedTarget===null&&o.document.activeElement!==o.document.body;c({type:To,selectItem:!qe})}},St=function(){c({type:Ka})},Vt="onChange",Pt={};if(!B.disabled){var ut;Pt=(ut={},ut[Vt]=ze(te,Y,_e),ut.onKeyDown=ze(Z,gt),ut.onBlur=ze(Q,et),ut.onClick=ze(ee,St),ut)}return me(($={},$[k]=Mr(we,function(ot){v.current=ot}),$["aria-activedescendant"]=Be.isOpen&&Be.highlightedIndex>-1?h.getItemId(Be.highlightedIndex):"",$["aria-autocomplete"]="list",$["aria-controls"]=h.menuId,$["aria-expanded"]=Be.isOpen,$["aria-labelledby"]=B&&B["aria-label"]?void 0:h.labelId,$.autoComplete="off",$.id=h.inputId,$.role="combobox",$.value=Be.inputValue,$),Pt,B)},[c,h,o,R,I,O,N]),ae=b.useCallback(function(){c({type:Yd})},[c]),re=b.useCallback(function(){c({type:ef})},[c]),ne=b.useCallback(function(){c({type:Zd})},[c]),ge=b.useCallback(function(H){c({type:tf,highlightedIndex:H})},[c]),ve=b.useCallback(function(H){c({type:$a,selectedItem:H})},[c]),F=b.useCallback(function(H){c({type:nf,inputValue:H})},[c]),U=b.useCallback(function(){c({type:rf})},[c]);return{getItemProps:K,getLabelProps:P,getMenuProps:J,getInputProps:W,getToggleButtonProps:M,toggleMenu:ae,openMenu:ne,closeMenu:re,setHighlightedIndex:ge,setInputValue:F,selectItem:ve,reset:U,highlightedIndex:u,isOpen:d,selectedItem:f,inputValue:m}}mo.stateReducer,mo.itemToKey,mo.environment,V.array,V.array,V.array,V.func,V.number,V.number,V.number,V.func,V.func,V.string,V.string;wi.itemToKey,wi.stateReducer,wi.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 IC="_comboboxContainer_1lcc8_1",CC="_label_1lcc8_8",xC="_inputContainer_1lcc8_12",SC="_input_1lcc8_12",EC="_toggleButton_1lcc8_33",OC="_menu_1lcc8_39",_C="_menuBottom_1lcc8_55",NC="_menuTop_1lcc8_61",TC="_menuItem_1lcc8_66",AC="_highlighted_1lcc8_73",RC="_selected_1lcc8_77",PC="_hidden_1lcc8_81",Bt={comboboxContainer:IC,label:CC,inputContainer:xC,input:SC,toggleButton:EC,menu:OC,menuBottom:_C,menuTop:NC,menuItem:TC,highlighted:AC,selected:RC,hidden:PC};function FC(e){const t=e.toLowerCase();return function(r){return!e||r.label.toLowerCase().includes(t)||r.value.toLowerCase().includes(t)}}function af({items:e,selectedValue:t,onSelectedItemChange:n,placeholder:r,disabled:o,style:i,menuPosition:s="bottom"}){const[a,c]=b.useState(e),d=b.useRef(null);b.useEffect(()=>c(e),[e]);const u=b.useCallback(O=>{(O==null?void 0:O.length)>0?c(e.filter(FC(O))):c(e)},[e]),{isOpen:f,getToggleButtonProps:m,getMenuProps:g,getInputProps:y,highlightedIndex:v,getItemProps:p,setInputValue:x,selectedItem:h}=Va({items:a,selectedItem:t?e.find(O=>O.value===t):null,itemToString:O=>(O==null?void 0:O.label)||"",onInputValueChange:({inputValue:O})=>u(O),onSelectedItemChange:({selectedItem:O})=>{var N;n(O),(N=d.current)==null||N.blur()}}),w=()=>{x(""),c(e)},I=()=>w(),S=b.useMemo(()=>{var O;return(O=e.find(N=>N.value===t))==null?void 0:O.label},[e,t]),A=()=>{t&&S&&t!==(h==null?void 0:h.value)&&x(S||"")};return l.jsxs("div",{style:{position:"relative",...i},children:[l.jsx("div",{className:Bt.comboboxContainer,children:l.jsxs("div",{className:Bt.inputContainer,children:[l.jsx("input",{style:{border:"none"},disabled:o,placeholder:r,className:Bt.input,...y({onFocus:I,onBlur:A,ref:d})}),l.jsx("button",{style:{border:"none"},disabled:o,"aria-label":"toggle menu",className:Bt.toggleButton,type:"button",...m(),children:f?l.jsx(l.Fragment,{children:"↑"}):l.jsx(l.Fragment,{children:"↓"})})]})}),l.jsx("ul",{className:`${Bt.menu} ${f&&e.length?"":Bt.hidden} ${s==="top"?Bt.menuTop:Bt.menuBottom}`,...g(),children:f&&a.map((O,N)=>l.jsx("li",{className:`${Bt.menuItem} ${v===N?Bt.highlighted:""} ${t===(O==null?void 0:O.value)?Bt.selected:""}`,...p({item:O,index:N}),children:l.jsx("span",{children:O.label})},O.id))})]})}const ni=Math.min,Cr=Math.max,Ao=Math.round,ao=Math.floor,Yn=e=>({x:e,y:e}),DC={left:"right",right:"left",bottom:"top",top:"bottom"},MC={start:"end",end:"start"};function Zs(e,t,n){return Cr(e,ni(t,n))}function Li(e,t){return typeof e=="function"?e(t):e}function Nr(e){return e.split("-")[0]}function ji(e){return e.split("-")[1]}function cf(e){return e==="x"?"y":"x"}function Ha(e){return e==="y"?"height":"width"}function ri(e){return["top","bottom"].includes(Nr(e))?"y":"x"}function Ja(e){return cf(ri(e))}function kC(e,t,n){n===void 0&&(n=!1);const r=ji(e),o=Ja(e),i=Ha(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Ro(s)),[s,Ro(s)]}function LC(e){const t=Ro(e);return[ea(e),t,ea(t)]}function ea(e){return e.replace(/start|end/g,t=>MC[t])}function jC(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 KC(e,t,n,r){const o=ji(e);let i=jC(Nr(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(ea)))),i}function Ro(e){return e.replace(/left|right|bottom|top/g,t=>DC[t])}function UC(e){return{top:0,right:0,bottom:0,left:0,...e}}function lf(e){return typeof e!="number"?UC(e):{top:e,right:e,bottom:e,left:e}}function Po(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 dl(e,t,n){let{reference:r,floating:o}=e;const i=ri(t),s=Ja(t),a=Ha(s),c=Nr(t),d=i==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let g;switch(c){case"top":g={x:u,y:r.y-o.height};break;case"bottom":g={x:u,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:f};break;case"left":g={x:r.x-o.width,y:f};break;default:g={x:r.x,y:r.y}}switch(ji(t)){case"start":g[s]-=m*(n&&d?-1:1);break;case"end":g[s]+=m*(n&&d?-1:1);break}return g}const $C=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,a=i.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(t));let d=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:f}=dl(d,r,c),m=r,g={},y=0;for(let v=0;v<a.length;v++){const{name:p,fn:x}=a[v],{x:h,y:w,data:I,reset:S}=await x({x:u,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:g,rects:d,platform:s,elements:{reference:e,floating:t}});u=h??u,f=w??f,g={...g,[p]:{...g[p],...I}},S&&y<=50&&(y++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(d=S.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:u,y:f}=dl(d,m,c)),v=-1)}return{x:u,y:f,placement:m,strategy:o,middlewareData:g}};async function uf(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:a,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:m=!1,padding:g=0}=Li(t,e),y=lf(g),p=a[m?f==="floating"?"reference":"floating":f],x=Po(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(p)))==null||n?p:p.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:d,rootBoundary:u,strategy:c})),h=f==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),I=await(i.isElement==null?void 0:i.isElement(w))?await(i.getScale==null?void 0:i.getScale(w))||{x:1,y:1}:{x:1,y:1},S=Po(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:h,offsetParent:w,strategy:c}):h);return{top:(x.top-S.top+y.top)/I.y,bottom:(S.bottom-x.bottom+y.bottom)/I.y,left:(x.left-S.left+y.left)/I.x,right:(S.right-x.right+y.right)/I.x}}const qC=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:c}=t,{element:d,padding:u=0}=Li(e,t)||{};if(d==null)return{};const f=lf(u),m={x:n,y:r},g=Ja(o),y=Ha(g),v=await s.getDimensions(d),p=g==="y",x=p?"top":"left",h=p?"bottom":"right",w=p?"clientHeight":"clientWidth",I=i.reference[y]+i.reference[g]-m[g]-i.floating[y],S=m[g]-i.reference[g],A=await(s.getOffsetParent==null?void 0:s.getOffsetParent(d));let O=A?A[w]:0;(!O||!await(s.isElement==null?void 0:s.isElement(A)))&&(O=a.floating[w]||i.floating[y]);const N=I/2-S/2,R=O/2-v[y]/2-1,P=ni(f[x],R),J=ni(f[h],R),K=P,M=O-v[y]-J,W=O/2-v[y]/2+N,ae=Zs(K,W,M),re=!c.arrow&&ji(o)!=null&&W!==ae&&i.reference[y]/2-(W<K?P:J)-v[y]/2<0,ne=re?W<K?W-K:W-M:0;return{[g]:m[g]+ne,data:{[g]:ae,centerOffset:W-ae-ne,...re&&{alignmentOffset:ne}},reset:re}}}),VC=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:c,elements:d}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:v=!0,...p}=Li(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const x=Nr(o),h=ri(a),w=Nr(a)===a,I=await(c.isRTL==null?void 0:c.isRTL(d.floating)),S=m||(w||!v?[Ro(a)]:LC(a)),A=y!=="none";!m&&A&&S.push(...KC(a,v,y,I));const O=[a,...S],N=await uf(t,p),R=[];let P=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&R.push(N[x]),f){const W=kC(o,s,I);R.push(N[W[0]],N[W[1]])}if(P=[...P,{placement:o,overflows:R}],!R.every(W=>W<=0)){var J,K;const W=(((J=i.flip)==null?void 0:J.index)||0)+1,ae=O[W];if(ae)return{data:{index:W,overflows:P},reset:{placement:ae}};let re=(K=P.filter(ne=>ne.overflows[0]<=0).sort((ne,ge)=>ne.overflows[1]-ge.overflows[1])[0])==null?void 0:K.placement;if(!re)switch(g){case"bestFit":{var M;const ne=(M=P.filter(ge=>{if(A){const ve=ri(ge.placement);return ve===h||ve==="y"}return!0}).map(ge=>[ge.placement,ge.overflows.filter(ve=>ve>0).reduce((ve,F)=>ve+F,0)]).sort((ge,ve)=>ge[1]-ve[1])[0])==null?void 0:M[0];ne&&(re=ne);break}case"initialPlacement":re=a;break}if(o!==re)return{reset:{placement:re}}}return{}}}};async function HC(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Nr(n),a=ji(n),c=ri(n)==="y",d=["left","top"].includes(s)?-1:1,u=i&&c?-1:1,f=Li(t,e);let{mainAxis:m,crossAxis:g,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof y=="number"&&(g=a==="end"?y*-1:y),c?{x:g*u,y:m*d}:{x:m*d,y:g*u}}const JC=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,c=await HC(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:i+c.y,data:{...c,placement:s}}}}},WC=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:p=>{let{x,y:h}=p;return{x,y:h}}},...c}=Li(e,t),d={x:n,y:r},u=await uf(t,c),f=ri(Nr(o)),m=cf(f);let g=d[m],y=d[f];if(i){const p=m==="y"?"top":"left",x=m==="y"?"bottom":"right",h=g+u[p],w=g-u[x];g=Zs(h,g,w)}if(s){const p=f==="y"?"top":"left",x=f==="y"?"bottom":"right",h=y+u[p],w=y-u[x];y=Zs(h,y,w)}const v=a.fn({...t,[m]:g,[f]:y});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[m]:i,[f]:s}}}}}};function Jo(){return typeof window<"u"}function fi(e){return df(e)?(e.nodeName||"").toLowerCase():"#document"}function Nt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function fn(e){var t;return(t=(df(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function df(e){return Jo()?e instanceof Node||e instanceof Nt(e).Node:!1}function Yt(e){return Jo()?e instanceof Element||e instanceof Nt(e).Element:!1}function un(e){return Jo()?e instanceof HTMLElement||e instanceof Nt(e).HTMLElement:!1}function fl(e){return!Jo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Nt(e).ShadowRoot}function Ki(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 BC(e){return["table","td","th"].includes(fi(e))}function Wo(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function Wa(e){const t=Ba(),n=Yt(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 zC(e){let t=Zn(e);for(;un(t)&&!ii(t);){if(Wa(t))return t;if(Wo(t))return null;t=Zn(t)}return null}function Ba(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function ii(e){return["html","body","#document"].includes(fi(e))}function Zt(e){return Nt(e).getComputedStyle(e)}function Bo(e){return Yt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Zn(e){if(fi(e)==="html")return e;const t=e.assignedSlot||e.parentNode||fl(e)&&e.host||fn(e);return fl(t)?t.host:t}function ff(e){const t=Zn(e);return ii(t)?e.ownerDocument?e.ownerDocument.body:e.body:un(t)&&Ki(t)?t:ff(t)}function _i(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ff(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=Nt(o);if(i){const a=ta(s);return t.concat(s,s.visualViewport||[],Ki(o)?o:[],a&&n?_i(a):[])}return t.concat(o,_i(o,[],n))}function ta(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function pf(e){const t=Zt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=un(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=Ao(n)!==i||Ao(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function za(e){return Yt(e)?e:e.contextElement}function Lr(e){const t=za(e);if(!un(t))return Yn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=pf(t);let s=(i?Ao(n.width):n.width)/r,a=(i?Ao(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const GC=Yn(0);function hf(e){const t=Nt(e);return!Ba()||!t.visualViewport?GC:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function QC(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Nt(e)?!1:t}function Tr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=za(e);let s=Yn(1);t&&(r?Yt(r)&&(s=Lr(r)):s=Lr(e));const a=QC(i,n,r)?hf(i):Yn(0);let c=(o.left+a.x)/s.x,d=(o.top+a.y)/s.y,u=o.width/s.x,f=o.height/s.y;if(i){const m=Nt(i),g=r&&Yt(r)?Nt(r):r;let y=m,v=ta(y);for(;v&&r&&g!==y;){const p=Lr(v),x=v.getBoundingClientRect(),h=Zt(v),w=x.left+(v.clientLeft+parseFloat(h.paddingLeft))*p.x,I=x.top+(v.clientTop+parseFloat(h.paddingTop))*p.y;c*=p.x,d*=p.y,u*=p.x,f*=p.y,c+=w,d+=I,y=Nt(v),v=ta(y)}}return Po({width:u,height:f,x:c,y:d})}function XC(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=fn(r),a=t?Wo(t.floating):!1;if(r===s||a&&i)return n;let c={scrollLeft:0,scrollTop:0},d=Yn(1);const u=Yn(0),f=un(r);if((f||!f&&!i)&&((fi(r)!=="body"||Ki(s))&&(c=Bo(r)),un(r))){const m=Tr(r);d=Lr(r),u.x=m.x+r.clientLeft,u.y=m.y+r.clientTop}return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+u.x,y:n.y*d.y-c.scrollTop*d.y+u.y}}function YC(e){return Array.from(e.getClientRects())}function na(e,t){const n=Bo(e).scrollLeft;return t?t.left+n:Tr(fn(e)).left+n}function ZC(e){const t=fn(e),n=Bo(e),r=e.ownerDocument.body,o=Cr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Cr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+na(e);const a=-n.scrollTop;return Zt(r).direction==="rtl"&&(s+=Cr(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function e0(e,t){const n=Nt(e),r=fn(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,a=0,c=0;if(o){i=o.width,s=o.height;const d=Ba();(!d||d&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:i,height:s,x:a,y:c}}function t0(e,t){const n=Tr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=un(e)?Lr(e):Yn(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,c=o*i.x,d=r*i.y;return{width:s,height:a,x:c,y:d}}function pl(e,t,n){let r;if(t==="viewport")r=e0(e,n);else if(t==="document")r=ZC(fn(e));else if(Yt(t))r=t0(t,n);else{const o=hf(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return Po(r)}function mf(e,t){const n=Zn(e);return n===t||!Yt(n)||ii(n)?!1:Zt(n).position==="fixed"||mf(n,t)}function n0(e,t){const n=t.get(e);if(n)return n;let r=_i(e,[],!1).filter(a=>Yt(a)&&fi(a)!=="body"),o=null;const i=Zt(e).position==="fixed";let s=i?Zn(e):e;for(;Yt(s)&&!ii(s);){const a=Zt(s),c=Wa(s);!c&&a.position==="fixed"&&(o=null),(i?!c&&!o:!c&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Ki(s)&&!c&&mf(e,s))?r=r.filter(u=>u!==s):o=a,s=Zn(s)}return t.set(e,r),r}function r0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?Wo(t)?[]:n0(t,this._c):[].concat(n),r],a=s[0],c=s.reduce((d,u)=>{const f=pl(t,u,o);return d.top=Cr(f.top,d.top),d.right=ni(f.right,d.right),d.bottom=ni(f.bottom,d.bottom),d.left=Cr(f.left,d.left),d},pl(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function i0(e){const{width:t,height:n}=pf(e);return{width:t,height:n}}function o0(e,t,n){const r=un(t),o=fn(t),i=n==="fixed",s=Tr(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const c=Yn(0);if(r||!r&&!i)if((fi(t)!=="body"||Ki(o))&&(a=Bo(t)),r){const g=Tr(t,!0,i,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else o&&(c.x=na(o));let d=0,u=0;if(o&&!r&&!i){const g=o.getBoundingClientRect();u=g.top+a.scrollTop,d=g.left+a.scrollLeft-na(o,g)}const f=s.left+a.scrollLeft-c.x-d,m=s.top+a.scrollTop-c.y-u;return{x:f,y:m,width:s.width,height:s.height}}function vs(e){return Zt(e).position==="static"}function hl(e,t){if(!un(e)||Zt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return fn(e)===n&&(n=n.ownerDocument.body),n}function gf(e,t){const n=Nt(e);if(Wo(e))return n;if(!un(e)){let o=Zn(e);for(;o&&!ii(o);){if(Yt(o)&&!vs(o))return o;o=Zn(o)}return n}let r=hl(e,t);for(;r&&BC(r)&&vs(r);)r=hl(r,t);return r&&ii(r)&&vs(r)&&!Wa(r)?n:r||zC(e)||n}const s0=async function(e){const t=this.getOffsetParent||gf,n=this.getDimensions,r=await n(e.floating);return{reference:o0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function a0(e){return Zt(e).direction==="rtl"}const c0={convertOffsetParentRelativeRectToViewportRelativeRect:XC,getDocumentElement:fn,getClippingRect:r0,getOffsetParent:gf,getElementRects:s0,getClientRects:YC,getDimensions:i0,getScale:Lr,isElement:Yt,isRTL:a0};function l0(e,t){let n=null,r;const o=fn(e);function i(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function s(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),i();const{left:d,top:u,width:f,height:m}=e.getBoundingClientRect();if(a||t(),!f||!m)return;const g=ao(u),y=ao(o.clientWidth-(d+f)),v=ao(o.clientHeight-(u+m)),p=ao(d),h={rootMargin:-g+"px "+-y+"px "+-v+"px "+-p+"px",threshold:Cr(0,ni(1,c))||1};let w=!0;function I(S){const A=S[0].intersectionRatio;if(A!==c){if(!w)return s();A?s(!1,A):r=setTimeout(()=>{s(!1,1e-7)},1e3)}w=!1}try{n=new IntersectionObserver(I,{...h,root:o.ownerDocument})}catch{n=new IntersectionObserver(I,h)}n.observe(e)}return s(!0),i}function u0(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:c=!1}=r,d=za(e),u=o||i?[...d?_i(d):[],..._i(t)]:[];u.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),i&&x.addEventListener("resize",n)});const f=d&&a?l0(d,n):null;let m=-1,g=null;s&&(g=new ResizeObserver(x=>{let[h]=x;h&&h.target===d&&g&&(g.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var w;(w=g)==null||w.observe(t)})),n()}),d&&!c&&g.observe(d),g.observe(t));let y,v=c?Tr(e):null;c&&p();function p(){const x=Tr(e);v&&(x.x!==v.x||x.y!==v.y||x.width!==v.width||x.height!==v.height)&&n(),v=x,y=requestAnimationFrame(p)}return n(),()=>{var x;u.forEach(h=>{o&&h.removeEventListener("scroll",n),i&&h.removeEventListener("resize",n)}),f==null||f(),(x=g)==null||x.disconnect(),g=null,c&&cancelAnimationFrame(y)}}const d0=JC,f0=WC,p0=VC,h0=qC,ml=(e,t,n)=>{const r=new Map,o={platform:c0,...n},i={...o.platform,_c:r};return $C(e,t,{...o,platform:i})};/*
|
|
45
|
+
*/var tu;function TI(){return tu||(tu=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"),c=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),l=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),v=!1,w=!1,h=!1,S=!1,p=!1,y;y=Symbol.for("react.module.reference");function I(W){return!!(typeof W=="string"||typeof W=="function"||W===n||W===o||p||W===r||W===f||W===d||S||W===g||v||w||h||typeof W=="object"&&W!==null&&(W.$$typeof===m||W.$$typeof===l||W.$$typeof===i||W.$$typeof===s||W.$$typeof===c||W.$$typeof===y||W.getModuleId!==void 0))}function x(W){if(typeof W=="object"&&W!==null){var ot=W.$$typeof;switch(ot){case e:var _e=W.type;switch(_e){case n:case o:case r:case f:case d:return _e;default:var mt=_e&&_e.$$typeof;switch(mt){case a:case s:case c:case m:case l:case i:return mt;default:return ot}}case t:return ot}}}var T=s,E=i,A=e,R=c,P=n,K=m,q=l,V=t,M=o,se=r,oe=f,ge=d,me=!1,Oe=!1;function F(W){return me||(me=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")),!1}function $(W){return Oe||(Oe=!0,console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")),!1}function J(W){return x(W)===s}function B(W){return x(W)===i}function U(W){return typeof W=="object"&&W!==null&&W.$$typeof===e}function k(W){return x(W)===c}function Q(W){return x(W)===n}function Z(W){return x(W)===m}function Y(W){return x(W)===l}function ee(W){return x(W)===t}function te(W){return x(W)===o}function le(W){return x(W)===r}function L(W){return x(W)===f}function we(W){return x(W)===d}Se.ContextConsumer=T,Se.ContextProvider=E,Se.Element=A,Se.ForwardRef=R,Se.Fragment=P,Se.Lazy=K,Se.Memo=q,Se.Portal=V,Se.Profiler=M,Se.StrictMode=se,Se.Suspense=oe,Se.SuspenseList=ge,Se.isAsyncMode=F,Se.isConcurrentMode=$,Se.isContextConsumer=J,Se.isContextProvider=B,Se.isElement=U,Se.isForwardRef=k,Se.isFragment=Q,Se.isLazy=Z,Se.isMemo=Y,Se.isPortal=ee,Se.isProfiler=te,Se.isStrictMode=le,Se.isSuspense=L,Se.isSuspenseList=we,Se.isValidElementType=I,Se.typeOf=x}()),Se}process.env.NODE_ENV==="production"?Qs.exports=NI():Qs.exports=TI();var nu=Qs.exports;const ru=e=>typeof e=="object"&&e!=null&&e.nodeType===1,iu=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",vs=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return iu(n.overflowY,t)||iu(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},so=(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,AI=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},RI=(e,t)=>{var n,r,o,i;if(typeof document>"u")return[];const{inline:s,boundary:a,skipOverflowHiddenElements:c}=t,f=typeof a=="function"?a:V=>V!==a;if(!ru(e))throw new TypeError("Invalid target");const d=document.scrollingElement||document.documentElement,l=[];let m=e;for(;ru(m)&&f(m);){if(m=AI(m),m===d){l.push(m);break}m!=null&&m===document.body&&vs(m)&&!vs(document.documentElement)||m!=null&&vs(m,c)&&l.push(m)}const g=(r=(n=window.visualViewport)==null?void 0:n.width)!=null?r:innerWidth,v=(i=(o=window.visualViewport)==null?void 0:o.height)!=null?i:innerHeight,{scrollX:w,scrollY:h}=window,{height:S,width:p,top:y,right:I,bottom:x,left:T}=e.getBoundingClientRect(),{top:E,right:A,left:R}=(V=>{const M=window.getComputedStyle(V);return{top:parseFloat(M.scrollMarginTop)||0,right:parseFloat(M.scrollMarginRight)||0,bottom:parseFloat(M.scrollMarginBottom)||0,left:parseFloat(M.scrollMarginLeft)||0}})(e);let P=y-E,K=s==="center"?T+p/2-R+A:s==="end"?I+A:T-R;const q=[];for(let V=0;V<l.length;V++){const M=l[V],{height:se,width:oe,top:ge,right:me,bottom:Oe,left:F}=M.getBoundingClientRect();if(y>=0&&T>=0&&x<=v&&I<=g&&y>=ge&&x<=Oe&&T>=F&&I<=me)return q;const $=getComputedStyle(M),J=parseInt($.borderLeftWidth,10),B=parseInt($.borderTopWidth,10),U=parseInt($.borderRightWidth,10),k=parseInt($.borderBottomWidth,10);let Q=0,Z=0;const Y="offsetWidth"in M?M.offsetWidth-M.clientWidth-J-U:0,ee="offsetHeight"in M?M.offsetHeight-M.clientHeight-B-k:0,te="offsetWidth"in M?M.offsetWidth===0?0:oe/M.offsetWidth:0,le="offsetHeight"in M?M.offsetHeight===0?0:se/M.offsetHeight:0;if(d===M)Q=so(h,h+v,v,B,k,h+P,h+P+S,S),Z=s==="start"?K:s==="center"?K-g/2:s==="end"?K-g:so(w,w+g,g,J,U,w+K,w+K+p,p),Q=Math.max(0,Q+h),Z=Math.max(0,Z+w);else{Q=so(ge,Oe,se,B,k+ee,P,P+S,S),Z=s==="start"?K-F-J:s==="center"?K-(F+oe/2)+Y/2:s==="end"?K-me+U+Y:so(F,me,oe,J,U+Y,K,K+p,p);const{scrollLeft:L,scrollTop:we}=M;Q=le===0?0:Math.max(0,Math.min(we+Q/le,M.scrollHeight-se/le+ee)),Z=te===0?0:Math.max(0,Math.min(L+Z/te,M.scrollWidth-oe/te+Y)),P+=we-Q,K+=L-Z}q.push({el:M,top:Q,left:Z})}return q};var ei=function(){return ei=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},ei.apply(this,arguments)};var PI=0;function ou(e){return typeof e=="function"?e:_t}function _t(){}function Sd(e,t){if(e){var n=RI(e,{boundary:t});n.forEach(function(r){var o=r.el,i=r.top,s=r.left;o.scrollTop=i,o.scrollLeft=s})}}function su(e,t,n){var r=e===t||t instanceof n.Node&&e.contains&&e.contains(t);return r}function Na(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 We(){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 Dr(){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 xd(){return String(PI++)}function FI(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 au(e,t){return e=Array.isArray(e)?e[0]:e,!e&&t?t:e}function Od(e){return typeof e.type=="string"}function Ed(e){return e.props}function DI(e,t){console.error('The property "'+t+'" is required in "'+e+'"')}var MI=["highlightedIndex","inputValue","isOpen","selectedItem","type"];function ao(e){e===void 0&&(e={});var t={};return MI.forEach(function(n){e.hasOwnProperty(n)&&(t[n]=e[n])}),t}function _o(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 Xs(e){var t=e.key,n=e.keyCode;return n>=37&&n<=40&&t.indexOf("Arrow")!==0?"Arrow"+t:t}function kI(e){return Object.prototype.toString.call(e)==="[object Object]"}function fr(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 c=ti(a,t<0,n,r,o);return c===-1?e>=i?-1:e:c}function ti(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?ti(t?i-1:0,t,n,r):-1}function To(e,t,n,r){return r===void 0&&(r=!0),n&&t.some(function(o){return o&&(su(o,e,n)||r&&su(o,n.document.activeElement,n))})}var Ta=_t;process.env.NODE_ENV!=="production"&&(Ta=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 LI=Na(function(e){_d(e).textContent=""},500);function _d(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 Nd(e,t){if(!(!e||!t)){var n=_d(t);n.textContent=e,LI(t)}}function jI(e){var t=e==null?void 0:e.getElementById("a11y-status-message");t&&t.remove()}var Td=process.env.NODE_ENV!=="production"?"__autocomplete_unknown__":0,Ad=process.env.NODE_ENV!=="production"?"__autocomplete_mouseup__":1,Rd=process.env.NODE_ENV!=="production"?"__autocomplete_item_mouseenter__":2,ho=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_arrow_up__":3,mo=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_arrow_down__":4,Pd=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_escape__":5,Fd=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_enter__":6,Dd=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_home__":7,Md=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_end__":8,kd=process.env.NODE_ENV!=="production"?"__autocomplete_click_item__":9,Ld=process.env.NODE_ENV!=="production"?"__autocomplete_blur_input__":10,jd=process.env.NODE_ENV!=="production"?"__autocomplete_change_input__":11,Kd=process.env.NODE_ENV!=="production"?"__autocomplete_keydown_space_button__":12,Ys=process.env.NODE_ENV!=="production"?"__autocomplete_click_button__":13,$d=process.env.NODE_ENV!=="production"?"__autocomplete_blur_button__":14,Ud=process.env.NODE_ENV!=="production"?"__autocomplete_controlled_prop_updated_selected_item__":15,qd=process.env.NODE_ENV!=="production"?"__autocomplete_touchend__":16,KI=Object.freeze({__proto__:null,blurButton:$d,blurInput:Ld,changeInput:jd,clickButton:Ys,clickItem:kd,controlledPropUpdatedSelectedItem:Ud,itemMouseEnter:Rd,keyDownArrowDown:mo,keyDownArrowUp:ho,keyDownEnd:Md,keyDownEnter:Fd,keyDownEscape:Pd,keyDownHome:Dd,keyDownSpaceButton:Kd,mouseUp:Ad,touchEnd:qd,unknown:Td}),$I=["refKey","ref"],UI=["onClick","onPress","onKeyDown","onKeyUp","onBlur"],qI=["onKeyDown","onBlur","onChange","onInput","onChangeText"],VI=["refKey","ref"],HI=["onMouseMove","onMouseDown","onClick","onPress","index","item"],BI=function(){var e=function(t){function n(o){var i;i=t.call(this,o)||this,i.id=i.props.id||"downshift-"+xd(),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(p){return i.id+"-item-"+p},i.items=[],i.itemCount=null,i.previousResultCount=0,i.timeoutIds=[],i.internalSetTimeout=function(p,y){var I=setTimeout(function(){i.timeoutIds=i.timeoutIds.filter(function(x){return x!==I}),p()},y);i.timeoutIds.push(I)},i.setItemCount=function(p){i.itemCount=p},i.unsetItemCount=function(){i.itemCount=null},i.isItemDisabled=function(p,y){var I=i.getItemNodeFromIndex(y);return I&&I.hasAttribute("disabled")},i.setHighlightedIndex=function(p,y){p===void 0&&(p=i.props.defaultHighlightedIndex),y===void 0&&(y={}),y=ao(y),i.internalSetState(he({highlightedIndex:p},y))},i.clearSelection=function(p){i.internalSetState({selectedItem:null,inputValue:"",highlightedIndex:i.props.defaultHighlightedIndex,isOpen:i.props.defaultIsOpen},p)},i.selectItem=function(p,y,I){y=ao(y),i.internalSetState(he({isOpen:i.props.defaultIsOpen,highlightedIndex:i.props.defaultHighlightedIndex,selectedItem:p,inputValue:i.props.itemToString(p)},y),I)},i.selectItemAtIndex=function(p,y,I){var x=i.items[p];x!=null&&i.selectItem(x,y,I)},i.selectHighlightedItem=function(p,y){return i.selectItemAtIndex(i.getState().highlightedIndex,p,y)},i.internalSetState=function(p,y){var I,x,T={},E=typeof p=="function";return!E&&p.hasOwnProperty("inputValue")&&i.props.onInputValueChange(p.inputValue,he({},i.getStateAndHelpers(),p)),i.setState(function(A){var R;A=i.getState(A);var P=E?p(A):p;P=i.props.stateReducer(A,P),I=P.hasOwnProperty("selectedItem");var K={};return I&&P.selectedItem!==A.selectedItem&&(x=P.selectedItem),(R=P).type||(R.type=Td),Object.keys(P).forEach(function(q){A[q]!==P[q]&&(T[q]=P[q]),q!=="type"&&(P[q],No(i.props,q)||(K[q]=P[q]))}),E&&P.hasOwnProperty("inputValue")&&i.props.onInputValueChange(P.inputValue,he({},i.getStateAndHelpers(),P)),K},function(){ou(y)();var A=Object.keys(T).length>1;A&&i.props.onStateChange(T,i.getStateAndHelpers()),I&&i.props.onSelect(p.selectedItem,i.getStateAndHelpers()),x!==void 0&&i.props.onChange(x,i.getStateAndHelpers()),i.props.onUserAction(T,i.getStateAndHelpers())})},i.rootRef=function(p){return i._rootNode=p},i.getRootProps=function(p,y){var I,x=p===void 0?{}:p,T=x.refKey,E=T===void 0?"ref":T,A=x.ref,R=xn(x,$I),P=y===void 0?{}:y,K=P.suppressRefError,q=K===void 0?!1:K;i.getRootProps.called=!0,i.getRootProps.refKey=E,i.getRootProps.suppressRefError=q;var V=i.getState(),M=V.isOpen;return he((I={},I[E]=Dr(A,i.rootRef),I.role="combobox",I["aria-expanded"]=M,I["aria-haspopup"]="listbox",I["aria-owns"]=M?i.menuId:void 0,I["aria-labelledby"]=i.labelId,I),R)},i.keyDownHandlers={ArrowDown:function(y){var I=this;if(y.preventDefault(),this.getState().isOpen){var x=y.shiftKey?5:1;this.moveHighlightedIndex(x,{type:mo})}else this.internalSetState({isOpen:!0,type:mo},function(){var T=I.getItemCount();if(T>0){var E=I.getState(),A=E.highlightedIndex,R=fr(A,1,{length:T},I.isItemDisabled,!0);I.setHighlightedIndex(R,{type:mo})}})},ArrowUp:function(y){var I=this;if(y.preventDefault(),this.getState().isOpen){var x=y.shiftKey?-5:-1;this.moveHighlightedIndex(x,{type:ho})}else this.internalSetState({isOpen:!0,type:ho},function(){var T=I.getItemCount();if(T>0){var E=I.getState(),A=E.highlightedIndex,R=fr(A,-1,{length:T},I.isItemDisabled,!0);I.setHighlightedIndex(R,{type:ho})}})},Enter:function(y){if(y.which!==229){var I=this.getState(),x=I.isOpen,T=I.highlightedIndex;if(x&&T!=null){y.preventDefault();var E=this.items[T],A=this.getItemNodeFromIndex(T);if(E==null||A&&A.hasAttribute("disabled"))return;this.selectHighlightedItem({type:Fd})}}},Escape:function(y){y.preventDefault(),this.reset(he({type:Pd},!this.state.isOpen&&{selectedItem:null,inputValue:""}))}},i.buttonKeyDownHandlers=he({},i.keyDownHandlers,{" ":function(y){y.preventDefault(),this.toggleMenu({type:Kd})}}),i.inputKeyDownHandlers=he({},i.keyDownHandlers,{Home:function(y){var I=this.getState(),x=I.isOpen;if(x){y.preventDefault();var T=this.getItemCount();if(!(T<=0||!x)){var E=ti(0,!1,{length:T},this.isItemDisabled);this.setHighlightedIndex(E,{type:Dd})}}},End:function(y){var I=this.getState(),x=I.isOpen;if(x){y.preventDefault();var T=this.getItemCount();if(!(T<=0||!x)){var E=ti(T-1,!0,{length:T},this.isItemDisabled);this.setHighlightedIndex(E,{type:Md})}}}}),i.getToggleButtonProps=function(p){var y=p===void 0?{}:p,I=y.onClick;y.onPress;var x=y.onKeyDown,T=y.onKeyUp,E=y.onBlur,A=xn(y,UI),R=i.getState(),P=R.isOpen,K={onClick:We(I,i.buttonHandleClick),onKeyDown:We(x,i.buttonHandleKeyDown),onKeyUp:We(T,i.buttonHandleKeyUp),onBlur:We(E,i.buttonHandleBlur)},q=A.disabled?{}:K;return he({type:"button",role:"button","aria-label":P?"close menu":"open menu","aria-haspopup":!0,"data-toggle":!0},q,A)},i.buttonHandleKeyUp=function(p){p.preventDefault()},i.buttonHandleKeyDown=function(p){var y=Xs(p);i.buttonKeyDownHandlers[y]&&i.buttonKeyDownHandlers[y].call(i,p)},i.buttonHandleClick=function(p){if(p.preventDefault(),i.props.environment){var y=i.props.environment.document,I=y.body,x=y.activeElement;I&&I===x&&p.target.focus()}process.env.NODE_ENV==="test"?i.toggleMenu({type:Ys}):i.internalSetTimeout(function(){return i.toggleMenu({type:Ys})})},i.buttonHandleBlur=function(p){var y=p.target;i.internalSetTimeout(function(){if(!(i.isMouseDown||!i.props.environment)){var I=i.props.environment.document.activeElement;(I==null||I.id!==i.inputId)&&I!==y&&i.reset({type:$d})}})},i.getLabelProps=function(p){return he({htmlFor:i.inputId,id:i.labelId},p)},i.getInputProps=function(p){var y=p===void 0?{}:p,I=y.onKeyDown,x=y.onBlur,T=y.onChange,E=y.onInput;y.onChangeText;var A=xn(y,qI),R,P={};R="onChange";var K=i.getState(),q=K.inputValue,V=K.isOpen,M=K.highlightedIndex;if(!A.disabled){var se;P=(se={},se[R]=We(T,E,i.inputHandleChange),se.onKeyDown=We(I,i.inputHandleKeyDown),se.onBlur=We(x,i.inputHandleBlur),se)}return he({"aria-autocomplete":"list","aria-activedescendant":V&&typeof M=="number"&&M>=0?i.getItemId(M):void 0,"aria-controls":V?i.menuId:void 0,"aria-labelledby":A&&A["aria-label"]?void 0:i.labelId,autoComplete:"off",value:q,id:i.inputId},P,A)},i.inputHandleKeyDown=function(p){var y=Xs(p);y&&i.inputKeyDownHandlers[y]&&i.inputKeyDownHandlers[y].call(i,p)},i.inputHandleChange=function(p){i.internalSetState({type:jd,isOpen:!0,inputValue:p.target.value,highlightedIndex:i.props.defaultHighlightedIndex})},i.inputHandleBlur=function(){i.internalSetTimeout(function(){var p;if(!(i.isMouseDown||!i.props.environment)){var y=i.props.environment.document.activeElement,I=(y==null||(p=y.dataset)==null?void 0:p.toggle)&&i._rootNode&&i._rootNode.contains(y);I||i.reset({type:Ld})}})},i.menuRef=function(p){i._menuNode=p},i.getMenuProps=function(p,y){var I,x=p===void 0?{}:p,T=x.refKey,E=T===void 0?"ref":T,A=x.ref,R=xn(x,VI),P=y===void 0?{}:y,K=P.suppressRefError,q=K===void 0?!1:K;return i.getMenuProps.called=!0,i.getMenuProps.refKey=E,i.getMenuProps.suppressRefError=q,he((I={},I[E]=Dr(A,i.menuRef),I.role="listbox",I["aria-labelledby"]=R&&R["aria-label"]?void 0:i.labelId,I.id=i.menuId,I),R)},i.getItemProps=function(p){var y,I=p===void 0?{}:p,x=I.onMouseMove,T=I.onMouseDown,E=I.onClick;I.onPress;var A=I.index,R=I.item,P=R===void 0?process.env.NODE_ENV==="production"?void 0:DI("getItemProps","item"):R,K=xn(I,HI);A===void 0?(i.items.push(P),A=i.items.indexOf(P)):i.items[A]=P;var q="onClick",V=E,M=(y={onMouseMove:We(x,function(){A!==i.getState().highlightedIndex&&(i.setHighlightedIndex(A,{type:Rd}),i.avoidScrolling=!0,i.internalSetTimeout(function(){return i.avoidScrolling=!1},250))}),onMouseDown:We(T,function(oe){oe.preventDefault()})},y[q]=We(V,function(){i.selectItemAtIndex(A,{type:kd})}),y),se=K.disabled?{onMouseDown:M.onMouseDown}:M;return he({id:i.getItemId(A),role:"option","aria-selected":i.getState().highlightedIndex===A},se,K)},i.clearItems=function(){i.items=[]},i.reset=function(p,y){p===void 0&&(p={}),p=ao(p),i.internalSetState(function(I){var x=I.selectedItem;return he({isOpen:i.props.defaultIsOpen,highlightedIndex:i.props.defaultHighlightedIndex,inputValue:i.props.itemToString(x)},p)},y)},i.toggleMenu=function(p,y){p===void 0&&(p={}),p=ao(p),i.internalSetState(function(I){var x=I.isOpen;return he({isOpen:!x},x&&{highlightedIndex:i.props.defaultHighlightedIndex},p)},function(){var I=i.getState(),x=I.isOpen,T=I.highlightedIndex;x&&i.getItemCount()>0&&typeof T=="number"&&i.setHighlightedIndex(T,p),ou(y)()})},i.openMenu=function(p){i.internalSetState({isOpen:!0},p)},i.closeMenu=function(p){i.internalSetState({isOpen:!1},p)},i.updateStatus=Na(function(){var p;if((p=i.props)!=null&&(p=p.environment)!=null&&p.document){var y=i.getState(),I=i.items[y.highlightedIndex],x=i.getItemCount(),T=i.props.getA11yStatusMessage(he({itemToString:i.props.itemToString,previousResultCount:i.previousResultCount,resultCount:x,highlightedItem:I},y));i.previousResultCount=x,Nd(T,i.props.environment.document)}},200);var s=i.props,a=s.defaultHighlightedIndex,c=s.initialHighlightedIndex,f=c===void 0?a:c,d=s.defaultIsOpen,l=s.initialIsOpen,m=l===void 0?d:l,g=s.initialInputValue,v=g===void 0?"":g,w=s.initialSelectedItem,h=w===void 0?null:w,S=i.getState({highlightedIndex:f,isOpen:m,inputValue:v,selectedItem:h});return S.selectedItem!=null&&i.props.initialInputValue===void 0&&(S.inputValue=i.props.itemToString(S.selectedItem)),i.state=S,i}vI(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),_o(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(),c=this.getState(),f=c.highlightedIndex;if(a>0){var d=fr(f,i,{length:a},this.isItemDisabled,!0);this.setHighlightedIndex(d,s)}},r.getStateAndHelpers=function(){var i=this.getState(),s=i.highlightedIndex,a=i.inputValue,c=i.selectedItem,f=i.isOpen,d=this.props.itemToString,l=this.id,m=this.getRootProps,g=this.getToggleButtonProps,v=this.getLabelProps,w=this.getMenuProps,h=this.getInputProps,S=this.getItemProps,p=this.openMenu,y=this.closeMenu,I=this.toggleMenu,x=this.selectItem,T=this.selectItemAtIndex,E=this.selectHighlightedItem,A=this.setHighlightedIndex,R=this.clearSelection,P=this.clearItems,K=this.reset,q=this.setItemCount,V=this.unsetItemCount,M=this.internalSetState;return{getRootProps:m,getToggleButtonProps:g,getLabelProps:v,getMenuProps:w,getInputProps:h,getItemProps:S,reset:K,openMenu:p,closeMenu:y,toggleMenu:I,selectItem:x,selectItemAtIndex:T,selectHighlightedItem:E,setHighlightedIndex:A,clearSelection:R,clearItems:P,setItemCount:q,unsetItemCount:V,setState:M,itemToString:d,id:l,highlightedIndex:s,inputValue:a,isOpen:f,selectedItem:c}},r.componentDidMount=function(){var i=this;if(process.env.NODE_ENV!=="production"&&this.getMenuProps.called&&!this.getMenuProps.suppressRefError&&cu(this._menuNode,this.getMenuProps),!this.props.environment)this.cleanup=function(){i.internalClearTimeouts()};else{var s=function(){i.isMouseDown=!0},a=function(g){i.isMouseDown=!1;var v=To(g.target,[i._rootNode,i._menuNode],i.props.environment);!v&&i.getState().isOpen&&i.reset({type:Ad},function(){return i.props.onOuterClick(i.getStateAndHelpers())})},c=function(){i.isTouchMove=!1},f=function(){i.isTouchMove=!0},d=function(g){var v=To(g.target,[i._rootNode,i._menuNode],i.props.environment,!1);!i.isTouchMove&&!v&&i.getState().isOpen&&i.reset({type:qd},function(){return i.props.onOuterClick(i.getStateAndHelpers())})},l=this.props.environment;l.addEventListener("mousedown",s),l.addEventListener("mouseup",a),l.addEventListener("touchstart",c),l.addEventListener("touchmove",f),l.addEventListener("touchend",d),this.cleanup=function(){i.internalClearTimeouts(),i.updateStatus.cancel(),l.removeEventListener("mousedown",s),l.removeEventListener("mouseup",a),l.removeEventListener("touchstart",c),l.removeEventListener("touchmove",f),l.removeEventListener("touchend",d)}}},r.shouldScroll=function(i,s){var a=this.props.highlightedIndex===void 0?this.getState():this.props,c=a.highlightedIndex,f=s.highlightedIndex===void 0?i:s,d=f.highlightedIndex,l=c&&this.getState().isOpen&&!i.isOpen,m=c!==d;return l||m},r.componentDidUpdate=function(i,s){process.env.NODE_ENV!=="production"&&(Ta(this.state,i,this.props),this.getMenuProps.called&&!this.getMenuProps.suppressRefError&&cu(this._menuNode,this.getMenuProps)),No(this.props,"selectedItem")&&this.props.selectedItemChanged(i.selectedItem,this.props.selectedItem)&&this.internalSetState({type:Ud,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=au(this.props.children,_t);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=au(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&&JI(s,this.getRootProps),s;if(Od(s))return b.cloneElement(s,this.getRootProps(Ed(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}(b.Component);return e.defaultProps={defaultHighlightedIndex:null,defaultIsOpen:!1,getA11yStatusMessage:FI,itemToString:function(n){return n==null?"":(process.env.NODE_ENV!=="production"&&kI(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:_t,onInputValueChange:_t,onUserAction:_t,onChange:_t,onSelect:_t,onOuterClick:_t,selectedItemChanged:function(n,r){return n!==r},environment:typeof window>"u"?void 0:window,stateReducer:function(n,r){return r},suppressRefError:!1,scrollIntoView:Sd},e.stateChangeTypes=KI,e}();process.env.NODE_ENV!=="production"&&(BI.propTypes={children:H.func,defaultHighlightedIndex:H.number,defaultIsOpen:H.bool,initialHighlightedIndex:H.number,initialSelectedItem:H.any,initialInputValue:H.string,initialIsOpen:H.bool,getA11yStatusMessage:H.func,itemToString:H.func,onChange:H.func,onSelect:H.func,onStateChange:H.func,onInputValueChange:H.func,onUserAction:H.func,onOuterClick:H.func,selectedItemChanged:H.func,stateReducer:H.func,itemCount:H.number,id:H.string,environment:H.shape({addEventListener:H.func.isRequired,removeEventListener:H.func.isRequired,document:H.shape({createElement:H.func.isRequired,getElementById:H.func.isRequired,activeElement:H.any.isRequired,body:H.any.isRequired}).isRequired,Node:H.func.isRequired}),suppressRefError:H.bool,scrollIntoView:H.func,selectedItem:H.any,isOpen:H.bool,inputValue:H.string,highlightedIndex:H.number,labelId:H.string,inputId:H.string,menuId:H.string,getItemId:H.func});function cu(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 JI(e,t){var n=t.refKey,r=n!=="ref",o=!Od(e);o&&!r&&!nu.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+'"'),!nu.isForwardRef(e)&&!Ed(e)[n]&&console.error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.')}var Vd={highlightedIndex:-1,isOpen:!1,selectedItem:null,inputValue:""};function WI(e,t,n){var r=e.props,o=e.type,i={};Object.keys(t).forEach(function(s){zI(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 zI(e,t,n,r){var o=t.props,i=t.type,s="on"+Aa(e)+"Change";o[s]&&r[e]!==void 0&&r[e]!==n[e]&&o[s](he({type:i},r))}function GI(e,t){return t.changes}var uu=Na(function(e,t){Nd(e,t)},200),QI=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?b.useLayoutEffect:b.useEffect,XI="useId"in b?function(t){var n=t.id,r=t.labelId,o=t.menuId,i=t.getItemId,s=t.toggleButtonId,a=t.inputId,c="downshift-"+b.useId();n||(n=c);var f=b.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 f.current}:function(t){var n=t.id,r=n===void 0?"downshift-"+xd():n,o=t.labelId,i=t.menuId,s=t.getItemId,a=t.toggleButtonId,c=t.inputId,f=b.useRef({labelId:o||r+"-label",menuId:i||r+"-menu",getItemId:s||function(d){return r+"-item-"+d},toggleButtonId:a||r+"-toggle-button",inputId:c||r+"-input"});return f.current};function YI(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 Aa(e){return""+e.slice(0,1).toUpperCase()+e.slice(1)}function Hd(e){var t=b.useRef(e);return t.current=e,t}function ZI(e,t,n,r){var o=b.useRef(),i=b.useRef(),s=b.useCallback(function(g,v){i.current=v,g=_o(g,v.props);var w=e(g,v),h=v.props.stateReducer(g,he({},v,{changes:w}));return h},[e]),a=b.useReducer(s,t,n),c=a[0],f=a[1],d=Hd(t),l=b.useCallback(function(g){return f(he({props:d.current},g))},[d]),m=i.current;return b.useEffect(function(){var g=_o(o.current,m==null?void 0:m.props),v=m&&o.current&&!r(g,c);v&&WI(m,g,c),o.current=c},[c,m,r]),[c,l]}var Ii={itemToString:function(t){return t?String(t):""},itemToKey:function(t){return t},stateReducer:GI,scrollIntoView:Sd,environment:typeof window>"u"?void 0:window};function Gn(e,t,n){n===void 0&&(n=Vd);var r=e["default"+Aa(t)];return r!==void 0?r:n[t]}function Ci(e,t,n){n===void 0&&(n=Vd);var r=e[t];if(r!==void 0)return r;var o=e["initial"+Aa(t)];return o!==void 0?o:Gn(e,t,n)}function eC(e){var t=Ci(e,"selectedItem"),n=Ci(e,"isOpen"),r=oC(e),o=Ci(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 Si(e,t,n){var r=e.items,o=e.initialHighlightedIndex,i=e.defaultHighlightedIndex,s=e.isItemDisabled,a=e.itemToKey,c=t.selectedItem,f=t.highlightedIndex;return r.length===0?-1:o!==void 0&&f===o&&!s(r[o],o)?o:i!==void 0&&!s(r[i],i)?i:c?r.findIndex(function(d){return a(c)===a(d)}):n<0&&!s(r[r.length-1],r.length-1)?r.length-1:n>0&&!s(r[0],0)?0:-1}function tC(e,t,n){var r=b.useRef({isMouseDown:!1,isTouchMove:!1,isTouchEnd:!1});return b.useEffect(function(){if(!e)return _t;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,To(d.target,o,e)||t()}function a(){r.current.isTouchEnd=!1,r.current.isTouchMove=!1}function c(){r.current.isTouchMove=!0}function f(d){r.current.isTouchEnd=!0,!r.current.isTouchMove&&!To(d.target,o,e,!1)&&t()}return e.addEventListener("mousedown",i),e.addEventListener("mouseup",s),e.addEventListener("touchstart",a),e.addEventListener("touchmove",c),e.addEventListener("touchend",f),function(){e.removeEventListener("mousedown",i),e.removeEventListener("mouseup",s),e.removeEventListener("touchstart",a),e.removeEventListener("touchmove",c),e.removeEventListener("touchend",f)}},[n,e,t]),r.current}var Bd=function(){return _t};process.env.NODE_ENV!=="production"&&(Bd=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o=b.useRef(n.reduce(function(s,a){return s[a]={},s},{}));b.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 c=a.suppressRefError,f=a.refKey,d=a.elementRef;c||d!=null&&d.current||console.error('downshift: The ref prop "'+f+'" from '+s+" was not applied correctly on your element.")})},[]);var i=b.useCallback(function(s,a,c,f){o.current[s]={suppressRefError:a,refKey:c,elementRef:f}},[]);return i});function nC(e,t,n,r){r===void 0&&(r={});var o=r.document,i=Bo();b.useEffect(function(){if(!(!e||i||!o)){var s=e(t);uu(s,o)}},n),b.useEffect(function(){return function(){uu.cancel(),jI(o)}},[o])}function rC(e){var t=e.highlightedIndex,n=e.isOpen,r=e.itemRefs,o=e.getItemNodeFromIndex,i=e.menuElement,s=e.scrollIntoView,a=b.useRef(!0);return QI(function(){t<0||!n||!Object.keys(r.current).length||(a.current===!1?a.current=!0:s(o(t),i))},[t]),a}var Jd=_t;process.env.NODE_ENV!=="production"&&(Jd=function(t){var n=t.props,r=t.state,o=b.useRef(n),i=Bo();b.useEffect(function(){i||(Ta(r,o.current,n),o.current=n)},[r,n,i])});function lu(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:Gn(e,"isOpen"),highlightedIndex:Gn(e,"highlightedIndex")},n&&{inputValue:e.itemToString(e.items[t])}))}function iC(e,t){return e.isOpen===t.isOpen&&e.inputValue===t.inputValue&&e.highlightedIndex===t.highlightedIndex&&e.selectedItem===t.selectedItem}function Bo(){var e=b.useRef(!0);return b.useEffect(function(){return e.current=!1,function(){e.current=!0}},[]),e.current}function Zs(e){var t=Gn(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}function oC(e){var t=Ci(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}var go={environment:H.shape({addEventListener:H.func.isRequired,removeEventListener:H.func.isRequired,document:H.shape({createElement:H.func.isRequired,getElementById:H.func.isRequired,activeElement:H.any.isRequired,body:H.any.isRequired}).isRequired,Node:H.func.isRequired}),itemToString:H.func,itemToKey:H.func,stateReducer:H.func},Wd=he({},go,{getA11yStatusMessage:H.func,highlightedIndex:H.number,defaultHighlightedIndex:H.number,initialHighlightedIndex:H.number,isOpen:H.bool,defaultIsOpen:H.bool,initialIsOpen:H.bool,selectedItem:H.any,initialSelectedItem:H.any,defaultSelectedItem:H.any,id:H.string,labelId:H.string,menuId:H.string,getItemId:H.func,toggleButtonId:H.string,onSelectedItemChange:H.func,onHighlightedIndexChange:H.func,onStateChange:H.func,onIsOpenChange:H.func,scrollIntoView:H.func});function sC(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:Si(o,e,0)};break;case n.FunctionOpenMenu:i={isOpen:!0,highlightedIndex:Si(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:Zs(o),isOpen:Gn(o,"isOpen"),selectedItem:Gn(o,"selectedItem"),inputValue:Gn(o,"inputValue")};break;default:throw new Error("Reducer called without proper action type.")}return he({},e,i)}ei(ei({},Wd),{items:H.array.isRequired,isItemDisabled:H.func});ei(ei({},Ii),{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 Ra=process.env.NODE_ENV!=="production"?"__input_keydown_arrow_down__":0,Pa=process.env.NODE_ENV!=="production"?"__input_keydown_arrow_up__":1,Fa=process.env.NODE_ENV!=="production"?"__input_keydown_escape__":2,Da=process.env.NODE_ENV!=="production"?"__input_keydown_home__":3,Ma=process.env.NODE_ENV!=="production"?"__input_keydown_end__":4,ka=process.env.NODE_ENV!=="production"?"__input_keydown_page_up__":5,La=process.env.NODE_ENV!=="production"?"__input_keydown_page_down__":6,ja=process.env.NODE_ENV!=="production"?"__input_keydown_enter__":7,Ka=process.env.NODE_ENV!=="production"?"__input_change__":8,Ao=process.env.NODE_ENV!=="production"?"__input_blur__":9,$a=process.env.NODE_ENV!=="production"?"__input_click__":10,zd=process.env.NODE_ENV!=="production"?"__menu_mouse_leave__":11,Gd=process.env.NODE_ENV!=="production"?"__item_mouse_move__":12,Ua=process.env.NODE_ENV!=="production"?"__item_click__":13,Qd=process.env.NODE_ENV!=="production"?"__togglebutton_click__":14,Xd=process.env.NODE_ENV!=="production"?"__function_toggle_menu__":15,Yd=process.env.NODE_ENV!=="production"?"__function_open_menu__":16,Zd=process.env.NODE_ENV!=="production"?"__function_close_menu__":17,ef=process.env.NODE_ENV!=="production"?"__function_set_highlighted_index__":18,qa=process.env.NODE_ENV!=="production"?"__function_select_item__":19,tf=process.env.NODE_ENV!=="production"?"__function_set_input_value__":20,nf=process.env.NODE_ENV!=="production"?"__function_reset__":21,Va=process.env.NODE_ENV!=="production"?"__controlled_prop_updated_selected_item__":22,rf=Object.freeze({__proto__:null,ControlledPropUpdatedSelectedItem:Va,FunctionCloseMenu:Zd,FunctionOpenMenu:Yd,FunctionReset:nf,FunctionSelectItem:qa,FunctionSetHighlightedIndex:ef,FunctionSetInputValue:tf,FunctionToggleMenu:Xd,InputBlur:Ao,InputChange:Ka,InputClick:$a,InputKeyDownArrowDown:Ra,InputKeyDownArrowUp:Pa,InputKeyDownEnd:Ma,InputKeyDownEnter:ja,InputKeyDownEscape:Fa,InputKeyDownHome:Da,InputKeyDownPageDown:La,InputKeyDownPageUp:ka,ItemClick:Ua,ItemMouseMove:Gd,MenuMouseLeave:zd,ToggleButtonClick:Qd});function aC(e){var t=eC(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 cC=he({},Wd,{items:H.array.isRequired,isItemDisabled:H.func,inputValue:H.string,defaultInputValue:H.string,initialInputValue:H.string,inputId:H.string,onInputValueChange:H.func});function uC(e,t,n,r){var o=b.useRef(),i=ZI(e,t,n,r),s=i[0],a=i[1],c=Bo();return b.useEffect(function(){if(No(t,"selectedItem")){if(!c){var f=t.itemToKey(t.selectedItem)!==t.itemToKey(o.current);f&&a({type:Va,inputValue:t.itemToString(t.selectedItem)})}o.current=s.selectedItem===o.current?t.selectedItem:s.selectedItem}},[s.selectedItem,t.selectedItem]),[_o(s,t),a]}var of=_t;process.env.NODE_ENV!=="production"&&(of=function(t,n){H.checkPropTypes(cC,t,"prop",n.name)});var lC=he({},Ii,{isItemDisabled:function(){return!1}});function dC(e,t){var n,r=t.type,o=t.props,i=t.altKey,s;switch(r){case Ua:s={isOpen:Gn(o,"isOpen"),highlightedIndex:Zs(o),selectedItem:o.items[t.index],inputValue:o.itemToString(o.items[t.index])};break;case Ra:e.isOpen?s={highlightedIndex:fr(e.highlightedIndex,1,o.items,o.isItemDisabled,!0)}:s={highlightedIndex:i&&e.selectedItem==null?-1:Si(o,e,1),isOpen:o.items.length>=0};break;case Pa:e.isOpen?i?s=lu(o,e.highlightedIndex):s={highlightedIndex:fr(e.highlightedIndex,-1,o.items,o.isItemDisabled,!0)}:s={highlightedIndex:Si(o,e,-1),isOpen:o.items.length>=0};break;case ja:s=lu(o,e.highlightedIndex);break;case Fa:s=he({isOpen:!1,highlightedIndex:-1},!e.isOpen&&{selectedItem:null,inputValue:""});break;case ka:s={highlightedIndex:fr(e.highlightedIndex,-10,o.items,o.isItemDisabled,!0)};break;case La:s={highlightedIndex:fr(e.highlightedIndex,10,o.items,o.isItemDisabled,!0)};break;case Da:s={highlightedIndex:ti(0,!1,o.items,o.isItemDisabled)};break;case Ma:s={highlightedIndex:ti(o.items.length-1,!0,o.items,o.isItemDisabled)};break;case Ao: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 Ka:s={isOpen:!0,highlightedIndex:Zs(o),inputValue:t.inputValue};break;case $a:s={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:Si(o,e,0)};break;case qa:s={selectedItem:t.selectedItem,inputValue:o.itemToString(t.selectedItem)};break;case Va:s={inputValue:t.inputValue};break;default:return sC(e,t,rf)}return he({},e,s)}var fC=["onMouseLeave","refKey","ref"],pC=["item","index","refKey","ref","onMouseMove","onMouseDown","onClick","onPress","disabled"],hC=["onClick","onPress","refKey","ref"],mC=["onKeyDown","onChange","onInput","onBlur","onChangeText","onClick","refKey","ref"];Ha.stateChangeTypes=rf;function Ha(e){e===void 0&&(e={}),of(e,Ha);var t=he({},lC,e),n=t.items,r=t.scrollIntoView,o=t.environment,i=t.getA11yStatusMessage,s=uC(dC,t,aC,iC),a=s[0],c=s[1],f=a.isOpen,d=a.highlightedIndex,l=a.selectedItem,m=a.inputValue,g=b.useRef(null),v=b.useRef({}),w=b.useRef(null),h=b.useRef(null),S=Bo(),p=XI(t),y=b.useRef(),I=Hd({state:a,props:t}),x=b.useCallback(function(J){return v.current[p.getItemId(J)]},[p]);nC(i,a,[f,d,l,m],o);var T=rC({menuElement:g.current,highlightedIndex:d,isOpen:f,itemRefs:v,scrollIntoView:r,getItemNodeFromIndex:x});Jd({props:t,state:a}),b.useEffect(function(){var J=Ci(t,"isOpen");J&&w.current&&w.current.focus()},[]),b.useEffect(function(){S||(y.current=n.length)});var E=tC(o,b.useCallback(function(){I.current.state.isOpen&&c({type:Ao,selectItem:!1})},[c,I]),b.useMemo(function(){return[g,h,w]},[g.current,h.current,w.current])),A=Bd("getInputProps","getMenuProps");b.useEffect(function(){f||(v.current={})},[f]),b.useEffect(function(){var J;!f||!(o!=null&&o.document)||!(w!=null&&(J=w.current)!=null&&J.focus)||o.document.activeElement!==w.current&&w.current.focus()},[f,o]);var R=b.useMemo(function(){return{ArrowDown:function(B){B.preventDefault(),c({type:Ra,altKey:B.altKey})},ArrowUp:function(B){B.preventDefault(),c({type:Pa,altKey:B.altKey})},Home:function(B){I.current.state.isOpen&&(B.preventDefault(),c({type:Da}))},End:function(B){I.current.state.isOpen&&(B.preventDefault(),c({type:Ma}))},Escape:function(B){var U=I.current.state;(U.isOpen||U.inputValue||U.selectedItem||U.highlightedIndex>-1)&&(B.preventDefault(),c({type:Fa}))},Enter:function(B){var U=I.current.state;!U.isOpen||B.which===229||(B.preventDefault(),c({type:ja}))},PageUp:function(B){I.current.state.isOpen&&(B.preventDefault(),c({type:ka}))},PageDown:function(B){I.current.state.isOpen&&(B.preventDefault(),c({type:La}))}}},[c,I]),P=b.useCallback(function(J){return he({id:p.labelId,htmlFor:p.inputId},J)},[p]),K=b.useCallback(function(J,B){var U,k=J===void 0?{}:J,Q=k.onMouseLeave,Z=k.refKey,Y=Z===void 0?"ref":Z,ee=k.ref,te=xn(k,fC),le=B===void 0?{}:B,L=le.suppressRefError,we=L===void 0?!1:L;return A("getMenuProps",we,Y,g),he((U={},U[Y]=Dr(ee,function(W){g.current=W}),U.id=p.menuId,U.role="listbox",U["aria-labelledby"]=te&&te["aria-label"]?void 0:""+p.labelId,U.onMouseLeave=We(Q,function(){c({type:zd})}),U),te)},[c,A,p]),q=b.useCallback(function(J){var B,U,k=J===void 0?{}:J,Q=k.item,Z=k.index,Y=k.refKey,ee=Y===void 0?"ref":Y,te=k.ref,le=k.onMouseMove,L=k.onMouseDown,we=k.onClick;k.onPress;var W=k.disabled,ot=xn(k,pC);W!==void 0&&console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.');var _e=I.current,mt=_e.props,Je=_e.state,gt=YI(Q,Z,mt.items,"Pass either item or index to getItemProps!"),Ee=gt[0],et=gt[1],xt=mt.isItemDisabled(Ee,et),Vt="onClick",Pt=we,lt=function(){E.isTouchEnd||et===Je.highlightedIndex||(T.current=!1,c({type:Gd,index:et,disabled:xt}))},st=function(){c({type:Ua,index:et})},Me=function(Ft){return Ft.preventDefault()};return he((B={},B[ee]=Dr(te,function(qe){qe&&(v.current[p.getItemId(et)]=qe)}),B["aria-disabled"]=xt,B["aria-selected"]=et===Je.highlightedIndex,B.id=p.getItemId(et),B.role="option",B),!xt&&(U={},U[Vt]=We(Pt,st),U),{onMouseMove:We(le,lt),onMouseDown:We(L,Me)},ot)},[c,p,I,E,T]),V=b.useCallback(function(J){var B,U=J===void 0?{}:J,k=U.onClick;U.onPress;var Q=U.refKey,Z=Q===void 0?"ref":Q,Y=U.ref,ee=xn(U,hC),te=I.current.state,le=function(){c({type:Qd})};return he((B={},B[Z]=Dr(Y,function(L){h.current=L}),B["aria-controls"]=p.menuId,B["aria-expanded"]=te.isOpen,B.id=p.toggleButtonId,B.tabIndex=-1,B),!ee.disabled&&he({},{onClick:We(k,le)}),ee)},[c,I,p]),M=b.useCallback(function(J,B){var U,k=J===void 0?{}:J,Q=k.onKeyDown,Z=k.onChange,Y=k.onInput,ee=k.onBlur;k.onChangeText;var te=k.onClick,le=k.refKey,L=le===void 0?"ref":le,we=k.ref,W=xn(k,mC),ot=B===void 0?{}:B,_e=ot.suppressRefError,mt=_e===void 0?!1:_e;A("getInputProps",mt,L,w);var Je=I.current.state,gt=function(Me){var qe=Xs(Me);qe&&R[qe]&&R[qe](Me)},Ee=function(Me){c({type:Ka,inputValue:Me.target.value})},et=function(Me){if(o!=null&&o.document&&Je.isOpen&&!E.isMouseDown){var qe=Me.relatedTarget===null&&o.document.activeElement!==o.document.body;c({type:Ao,selectItem:!qe})}},xt=function(){c({type:$a})},Vt="onChange",Pt={};if(!W.disabled){var lt;Pt=(lt={},lt[Vt]=We(Z,Y,Ee),lt.onKeyDown=We(Q,gt),lt.onBlur=We(ee,et),lt.onClick=We(te,xt),lt)}return he((U={},U[L]=Dr(we,function(st){w.current=st}),U["aria-activedescendant"]=Je.isOpen&&Je.highlightedIndex>-1?p.getItemId(Je.highlightedIndex):"",U["aria-autocomplete"]="list",U["aria-controls"]=p.menuId,U["aria-expanded"]=Je.isOpen,U["aria-labelledby"]=W&&W["aria-label"]?void 0:p.labelId,U.autoComplete="off",U.id=p.inputId,U.role="combobox",U.value=Je.inputValue,U),Pt,W)},[c,p,o,R,I,E,A]),se=b.useCallback(function(){c({type:Xd})},[c]),oe=b.useCallback(function(){c({type:Zd})},[c]),ge=b.useCallback(function(){c({type:Yd})},[c]),me=b.useCallback(function(J){c({type:ef,highlightedIndex:J})},[c]),Oe=b.useCallback(function(J){c({type:qa,selectedItem:J})},[c]),F=b.useCallback(function(J){c({type:tf,inputValue:J})},[c]),$=b.useCallback(function(){c({type:nf})},[c]);return{getItemProps:q,getLabelProps:P,getMenuProps:K,getInputProps:M,getToggleButtonProps:V,toggleMenu:se,openMenu:ge,closeMenu:oe,setHighlightedIndex:me,setInputValue:F,selectItem:Oe,reset:$,highlightedIndex:d,isOpen:f,selectedItem:l,inputValue:m}}go.stateReducer,go.itemToKey,go.environment,H.array,H.array,H.array,H.func,H.number,H.number,H.number,H.func,H.func,H.string,H.string;Ii.itemToKey,Ii.stateReducer,Ii.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 gC="_comboboxContainer_1lcc8_1",yC="_inputContainer_1lcc8_12",vC="_input_1lcc8_12",wC="_toggleButton_1lcc8_33",bC="_menu_1lcc8_39",IC="_menuBottom_1lcc8_55",CC="_menuTop_1lcc8_61",SC="_menuItem_1lcc8_66",xC="_highlighted_1lcc8_73",OC="_selected_1lcc8_77",EC="_hidden_1lcc8_81",Wt={comboboxContainer:gC,inputContainer:yC,input:vC,toggleButton:wC,menu:bC,menuBottom:IC,menuTop:CC,menuItem:SC,highlighted:xC,selected:OC,hidden:EC};function _C(e){const t=e.toLowerCase();return function(r){return!e||r.label.toLowerCase().includes(t)||r.value.toLowerCase().includes(t)}}function sf({items:e,selectedValue:t,onSelectedItemChange:n,placeholder:r,disabled:o,style:i,menuPosition:s="bottom"}){const[a,c]=b.useState(e),f=b.useRef(null);b.useEffect(()=>c(e),[e]);const d=b.useCallback(E=>{(E==null?void 0:E.length)>0?c(e.filter(_C(E))):c(e)},[e]),{isOpen:l,getToggleButtonProps:m,getMenuProps:g,getInputProps:v,highlightedIndex:w,getItemProps:h,setInputValue:S,selectedItem:p}=Ha({items:a,selectedItem:t?e.find(E=>E.value===t):null,itemToString:E=>(E==null?void 0:E.label)||"",onInputValueChange:({inputValue:E})=>d(E),onSelectedItemChange:({selectedItem:E})=>{var A;n(E),(A=f.current)==null||A.blur()}}),y=()=>{S(""),c(e)},I=()=>y(),x=b.useMemo(()=>{var E;return(E=e.find(A=>A.value===t))==null?void 0:E.label},[e,t]),T=()=>{t&&x&&t!==(p==null?void 0:p.value)&&S(x||"")};return u.jsxs("div",{style:{position:"relative",...i},children:[u.jsx("div",{className:Wt.comboboxContainer,children:u.jsxs("div",{className:Wt.inputContainer,children:[u.jsx("input",{style:{border:"none"},disabled:o,placeholder:r,className:Wt.input,...v({onFocus:I,onBlur:T,ref:f})}),u.jsx("button",{style:{border:"none"},disabled:o,"aria-label":"toggle menu",className:Wt.toggleButton,type:"button",...m(),children:l?u.jsx(u.Fragment,{children:"↑"}):u.jsx(u.Fragment,{children:"↓"})})]})}),u.jsx("ul",{className:`${Wt.menu} ${l&&e.length?"":Wt.hidden} ${s==="top"?Wt.menuTop:Wt.menuBottom}`,...g(),children:l&&a.map((E,A)=>u.jsx("li",{className:`${Wt.menuItem} ${w===A?Wt.highlighted:""} ${t===(E==null?void 0:E.value)?Wt.selected:""}`,...h({item:E,index:A}),children:u.jsx("span",{children:E.label})},E.id))})]})}const ni=Math.min,Ir=Math.max,Ro=Math.round,co=Math.floor,Xn=e=>({x:e,y:e}),NC={left:"right",right:"left",bottom:"top",top:"bottom"},TC={start:"end",end:"start"};function ea(e,t,n){return Ir(e,ni(t,n))}function Ki(e,t){return typeof e=="function"?e(t):e}function _r(e){return e.split("-")[0]}function $i(e){return e.split("-")[1]}function af(e){return e==="x"?"y":"x"}function Ba(e){return e==="y"?"height":"width"}function ri(e){return["top","bottom"].includes(_r(e))?"y":"x"}function Ja(e){return af(ri(e))}function AC(e,t,n){n===void 0&&(n=!1);const r=$i(e),o=Ja(e),i=Ba(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Po(s)),[s,Po(s)]}function RC(e){const t=Po(e);return[ta(e),t,ta(t)]}function ta(e){return e.replace(/start|end/g,t=>TC[t])}function PC(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 FC(e,t,n,r){const o=$i(e);let i=PC(_r(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(ta)))),i}function Po(e){return e.replace(/left|right|bottom|top/g,t=>NC[t])}function DC(e){return{top:0,right:0,bottom:0,left:0,...e}}function cf(e){return typeof e!="number"?DC(e):{top:e,right:e,bottom:e,left:e}}function Fo(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 du(e,t,n){let{reference:r,floating:o}=e;const i=ri(t),s=Ja(t),a=Ba(s),c=_r(t),f=i==="y",d=r.x+r.width/2-o.width/2,l=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let g;switch(c){case"top":g={x:d,y:r.y-o.height};break;case"bottom":g={x:d,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:l};break;case"left":g={x:r.x-o.width,y:l};break;default:g={x:r.x,y:r.y}}switch($i(t)){case"start":g[s]-=m*(n&&f?-1:1);break;case"end":g[s]+=m*(n&&f?-1:1);break}return g}const MC=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,a=i.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(t));let f=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:l}=du(f,r,c),m=r,g={},v=0;for(let w=0;w<a.length;w++){const{name:h,fn:S}=a[w],{x:p,y,data:I,reset:x}=await S({x:d,y:l,initialPlacement:r,placement:m,strategy:o,middlewareData:g,rects:f,platform:s,elements:{reference:e,floating:t}});d=p??d,l=y??l,g={...g,[h]:{...g[h],...I}},x&&v<=50&&(v++,typeof x=="object"&&(x.placement&&(m=x.placement),x.rects&&(f=x.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):x.rects),{x:d,y:l}=du(f,m,c)),w=-1)}return{x:d,y:l,placement:m,strategy:o,middlewareData:g}};async function uf(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:a,strategy:c}=e,{boundary:f="clippingAncestors",rootBoundary:d="viewport",elementContext:l="floating",altBoundary:m=!1,padding:g=0}=Ki(t,e),v=cf(g),h=a[m?l==="floating"?"reference":"floating":l],S=Fo(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:f,rootBoundary:d,strategy:c})),p=l==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,y=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),I=await(i.isElement==null?void 0:i.isElement(y))?await(i.getScale==null?void 0:i.getScale(y))||{x:1,y:1}:{x:1,y:1},x=Fo(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:p,offsetParent:y,strategy:c}):p);return{top:(S.top-x.top+v.top)/I.y,bottom:(x.bottom-S.bottom+v.bottom)/I.y,left:(S.left-x.left+v.left)/I.x,right:(x.right-S.right+v.right)/I.x}}const kC=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:c}=t,{element:f,padding:d=0}=Ki(e,t)||{};if(f==null)return{};const l=cf(d),m={x:n,y:r},g=Ja(o),v=Ba(g),w=await s.getDimensions(f),h=g==="y",S=h?"top":"left",p=h?"bottom":"right",y=h?"clientHeight":"clientWidth",I=i.reference[v]+i.reference[g]-m[g]-i.floating[v],x=m[g]-i.reference[g],T=await(s.getOffsetParent==null?void 0:s.getOffsetParent(f));let E=T?T[y]:0;(!E||!await(s.isElement==null?void 0:s.isElement(T)))&&(E=a.floating[y]||i.floating[v]);const A=I/2-x/2,R=E/2-w[v]/2-1,P=ni(l[S],R),K=ni(l[p],R),q=P,V=E-w[v]-K,M=E/2-w[v]/2+A,se=ea(q,M,V),oe=!c.arrow&&$i(o)!=null&&M!==se&&i.reference[v]/2-(M<q?P:K)-w[v]/2<0,ge=oe?M<q?M-q:M-V:0;return{[g]:m[g]+ge,data:{[g]:se,centerOffset:M-se-ge,...oe&&{alignmentOffset:ge}},reset:oe}}}),LC=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:c,elements:f}=t,{mainAxis:d=!0,crossAxis:l=!0,fallbackPlacements:m,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:w=!0,...h}=Ki(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const S=_r(o),p=ri(a),y=_r(a)===a,I=await(c.isRTL==null?void 0:c.isRTL(f.floating)),x=m||(y||!w?[Po(a)]:RC(a)),T=v!=="none";!m&&T&&x.push(...FC(a,w,v,I));const E=[a,...x],A=await uf(t,h),R=[];let P=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&R.push(A[S]),l){const M=AC(o,s,I);R.push(A[M[0]],A[M[1]])}if(P=[...P,{placement:o,overflows:R}],!R.every(M=>M<=0)){var K,q;const M=(((K=i.flip)==null?void 0:K.index)||0)+1,se=E[M];if(se)return{data:{index:M,overflows:P},reset:{placement:se}};let oe=(q=P.filter(ge=>ge.overflows[0]<=0).sort((ge,me)=>ge.overflows[1]-me.overflows[1])[0])==null?void 0:q.placement;if(!oe)switch(g){case"bestFit":{var V;const ge=(V=P.filter(me=>{if(T){const Oe=ri(me.placement);return Oe===p||Oe==="y"}return!0}).map(me=>[me.placement,me.overflows.filter(Oe=>Oe>0).reduce((Oe,F)=>Oe+F,0)]).sort((me,Oe)=>me[1]-Oe[1])[0])==null?void 0:V[0];ge&&(oe=ge);break}case"initialPlacement":oe=a;break}if(o!==oe)return{reset:{placement:oe}}}return{}}}};async function jC(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=_r(n),a=$i(n),c=ri(n)==="y",f=["left","top"].includes(s)?-1:1,d=i&&c?-1:1,l=Ki(t,e);let{mainAxis:m,crossAxis:g,alignmentAxis:v}=typeof l=="number"?{mainAxis:l,crossAxis:0,alignmentAxis:null}:{mainAxis:l.mainAxis||0,crossAxis:l.crossAxis||0,alignmentAxis:l.alignmentAxis};return a&&typeof v=="number"&&(g=a==="end"?v*-1:v),c?{x:g*d,y:m*f}:{x:m*f,y:g*d}}const KC=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,c=await jC(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:i+c.y,data:{...c,placement:s}}}}},$C=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:S,y:p}=h;return{x:S,y:p}}},...c}=Ki(e,t),f={x:n,y:r},d=await uf(t,c),l=ri(_r(o)),m=af(l);let g=f[m],v=f[l];if(i){const h=m==="y"?"top":"left",S=m==="y"?"bottom":"right",p=g+d[h],y=g-d[S];g=ea(p,g,y)}if(s){const h=l==="y"?"top":"left",S=l==="y"?"bottom":"right",p=v+d[h],y=v-d[S];v=ea(p,v,y)}const w=a.fn({...t,[m]:g,[l]:v});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[m]:i,[l]:s}}}}}};function Jo(){return typeof window<"u"}function fi(e){return lf(e)?(e.nodeName||"").toLowerCase():"#document"}function Nt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function fn(e){var t;return(t=(lf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function lf(e){return Jo()?e instanceof Node||e instanceof Nt(e).Node:!1}function Yt(e){return Jo()?e instanceof Element||e instanceof Nt(e).Element:!1}function ln(e){return Jo()?e instanceof HTMLElement||e instanceof Nt(e).HTMLElement:!1}function fu(e){return!Jo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Nt(e).ShadowRoot}function Ui(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 UC(e){return["table","td","th"].includes(fi(e))}function Wo(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function Wa(e){const t=za(),n=Yt(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 qC(e){let t=Yn(e);for(;ln(t)&&!ii(t);){if(Wa(t))return t;if(Wo(t))return null;t=Yn(t)}return null}function za(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function ii(e){return["html","body","#document"].includes(fi(e))}function Zt(e){return Nt(e).getComputedStyle(e)}function zo(e){return Yt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Yn(e){if(fi(e)==="html")return e;const t=e.assignedSlot||e.parentNode||fu(e)&&e.host||fn(e);return fu(t)?t.host:t}function df(e){const t=Yn(e);return ii(t)?e.ownerDocument?e.ownerDocument.body:e.body:ln(t)&&Ui(t)?t:df(t)}function Ti(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=df(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=Nt(o);if(i){const a=na(s);return t.concat(s,s.visualViewport||[],Ui(o)?o:[],a&&n?Ti(a):[])}return t.concat(o,Ti(o,[],n))}function na(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ff(e){const t=Zt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=ln(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=Ro(n)!==i||Ro(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function Ga(e){return Yt(e)?e:e.contextElement}function kr(e){const t=Ga(e);if(!ln(t))return Xn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=ff(t);let s=(i?Ro(n.width):n.width)/r,a=(i?Ro(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const VC=Xn(0);function pf(e){const t=Nt(e);return!za()||!t.visualViewport?VC:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function HC(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Nt(e)?!1:t}function Nr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Ga(e);let s=Xn(1);t&&(r?Yt(r)&&(s=kr(r)):s=kr(e));const a=HC(i,n,r)?pf(i):Xn(0);let c=(o.left+a.x)/s.x,f=(o.top+a.y)/s.y,d=o.width/s.x,l=o.height/s.y;if(i){const m=Nt(i),g=r&&Yt(r)?Nt(r):r;let v=m,w=na(v);for(;w&&r&&g!==v;){const h=kr(w),S=w.getBoundingClientRect(),p=Zt(w),y=S.left+(w.clientLeft+parseFloat(p.paddingLeft))*h.x,I=S.top+(w.clientTop+parseFloat(p.paddingTop))*h.y;c*=h.x,f*=h.y,d*=h.x,l*=h.y,c+=y,f+=I,v=Nt(w),w=na(v)}}return Fo({width:d,height:l,x:c,y:f})}function BC(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=fn(r),a=t?Wo(t.floating):!1;if(r===s||a&&i)return n;let c={scrollLeft:0,scrollTop:0},f=Xn(1);const d=Xn(0),l=ln(r);if((l||!l&&!i)&&((fi(r)!=="body"||Ui(s))&&(c=zo(r)),ln(r))){const m=Nr(r);f=kr(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-c.scrollLeft*f.x+d.x,y:n.y*f.y-c.scrollTop*f.y+d.y}}function JC(e){return Array.from(e.getClientRects())}function ra(e,t){const n=zo(e).scrollLeft;return t?t.left+n:Nr(fn(e)).left+n}function WC(e){const t=fn(e),n=zo(e),r=e.ownerDocument.body,o=Ir(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Ir(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+ra(e);const a=-n.scrollTop;return Zt(r).direction==="rtl"&&(s+=Ir(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function zC(e,t){const n=Nt(e),r=fn(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,a=0,c=0;if(o){i=o.width,s=o.height;const f=za();(!f||f&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:i,height:s,x:a,y:c}}function GC(e,t){const n=Nr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=ln(e)?kr(e):Xn(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,c=o*i.x,f=r*i.y;return{width:s,height:a,x:c,y:f}}function pu(e,t,n){let r;if(t==="viewport")r=zC(e,n);else if(t==="document")r=WC(fn(e));else if(Yt(t))r=GC(t,n);else{const o=pf(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return Fo(r)}function hf(e,t){const n=Yn(e);return n===t||!Yt(n)||ii(n)?!1:Zt(n).position==="fixed"||hf(n,t)}function QC(e,t){const n=t.get(e);if(n)return n;let r=Ti(e,[],!1).filter(a=>Yt(a)&&fi(a)!=="body"),o=null;const i=Zt(e).position==="fixed";let s=i?Yn(e):e;for(;Yt(s)&&!ii(s);){const a=Zt(s),c=Wa(s);!c&&a.position==="fixed"&&(o=null),(i?!c&&!o:!c&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Ui(s)&&!c&&hf(e,s))?r=r.filter(d=>d!==s):o=a,s=Yn(s)}return t.set(e,r),r}function XC(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?Wo(t)?[]:QC(t,this._c):[].concat(n),r],a=s[0],c=s.reduce((f,d)=>{const l=pu(t,d,o);return f.top=Ir(l.top,f.top),f.right=ni(l.right,f.right),f.bottom=ni(l.bottom,f.bottom),f.left=Ir(l.left,f.left),f},pu(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function YC(e){const{width:t,height:n}=ff(e);return{width:t,height:n}}function ZC(e,t,n){const r=ln(t),o=fn(t),i=n==="fixed",s=Nr(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const c=Xn(0);if(r||!r&&!i)if((fi(t)!=="body"||Ui(o))&&(a=zo(t)),r){const g=Nr(t,!0,i,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else o&&(c.x=ra(o));let f=0,d=0;if(o&&!r&&!i){const g=o.getBoundingClientRect();d=g.top+a.scrollTop,f=g.left+a.scrollLeft-ra(o,g)}const l=s.left+a.scrollLeft-c.x-f,m=s.top+a.scrollTop-c.y-d;return{x:l,y:m,width:s.width,height:s.height}}function ws(e){return Zt(e).position==="static"}function hu(e,t){if(!ln(e)||Zt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return fn(e)===n&&(n=n.ownerDocument.body),n}function mf(e,t){const n=Nt(e);if(Wo(e))return n;if(!ln(e)){let o=Yn(e);for(;o&&!ii(o);){if(Yt(o)&&!ws(o))return o;o=Yn(o)}return n}let r=hu(e,t);for(;r&&UC(r)&&ws(r);)r=hu(r,t);return r&&ii(r)&&ws(r)&&!Wa(r)?n:r||qC(e)||n}const eS=async function(e){const t=this.getOffsetParent||mf,n=this.getDimensions,r=await n(e.floating);return{reference:ZC(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function tS(e){return Zt(e).direction==="rtl"}const nS={convertOffsetParentRelativeRectToViewportRelativeRect:BC,getDocumentElement:fn,getClippingRect:XC,getOffsetParent:mf,getElementRects:eS,getClientRects:JC,getDimensions:YC,getScale:kr,isElement:Yt,isRTL:tS};function rS(e,t){let n=null,r;const o=fn(e);function i(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function s(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),i();const{left:f,top:d,width:l,height:m}=e.getBoundingClientRect();if(a||t(),!l||!m)return;const g=co(d),v=co(o.clientWidth-(f+l)),w=co(o.clientHeight-(d+m)),h=co(f),p={rootMargin:-g+"px "+-v+"px "+-w+"px "+-h+"px",threshold:Ir(0,ni(1,c))||1};let y=!0;function I(x){const T=x[0].intersectionRatio;if(T!==c){if(!y)return s();T?s(!1,T):r=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{n=new IntersectionObserver(I,{...p,root:o.ownerDocument})}catch{n=new IntersectionObserver(I,p)}n.observe(e)}return s(!0),i}function iS(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:c=!1}=r,f=Ga(e),d=o||i?[...f?Ti(f):[],...Ti(t)]:[];d.forEach(S=>{o&&S.addEventListener("scroll",n,{passive:!0}),i&&S.addEventListener("resize",n)});const l=f&&a?rS(f,n):null;let m=-1,g=null;s&&(g=new ResizeObserver(S=>{let[p]=S;p&&p.target===f&&g&&(g.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var y;(y=g)==null||y.observe(t)})),n()}),f&&!c&&g.observe(f),g.observe(t));let v,w=c?Nr(e):null;c&&h();function h(){const S=Nr(e);w&&(S.x!==w.x||S.y!==w.y||S.width!==w.width||S.height!==w.height)&&n(),w=S,v=requestAnimationFrame(h)}return n(),()=>{var S;d.forEach(p=>{o&&p.removeEventListener("scroll",n),i&&p.removeEventListener("resize",n)}),l==null||l(),(S=g)==null||S.disconnect(),g=null,c&&cancelAnimationFrame(v)}}const oS=KC,sS=$C,aS=LC,cS=kC,mu=(e,t,n)=>{const r=new Map,o={platform:nS,...n},i={...o.platform,_c:r};return MC(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 m0="react-tooltip-core-styles",g0="react-tooltip-base-styles",gl={core:!1,base:!1};function yl({css:e,id:t=g0,type:n="base",ref:r}){var o,i;if(!e||typeof document>"u"||gl[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=m0),r||(r={});const{insertAt:s}=r;if(document.getElementById(t))return;const a=document.head||document.getElementsByTagName("head")[0],c=document.createElement("style");c.id=t,c.type="text/css",s==="top"&&a.firstChild?a.insertBefore(c,a.firstChild):a.appendChild(c),c.styleSheet?c.styleSheet.cssText=e:c.appendChild(document.createTextNode(e)),gl[n]=!0}const vl=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:r="top",offset:o=10,strategy:i="absolute",middlewares:s=[d0(Number(o)),p0({fallbackAxisSideDirection:"start"}),f0({padding:5})],border:a,arrowSize:c=8})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};if(t===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};const d=s;return n?(d.push(h0({element:n,padding:5})),ml(e,t,{placement:r,strategy:i,middleware:d}).then(({x:u,y:f,placement:m,middlewareData:g})=>{var y,v;const p={left:`${u}px`,top:`${f}px`,border:a},{x,y:h}=(y=g.arrow)!==null&&y!==void 0?y:{x:0,y:0},w=(v={top:"bottom",right:"left",bottom:"top",left:"right"}[m.split("-")[0]])!==null&&v!==void 0?v:"bottom",I=a&&{borderBottom:a,borderRight:a};let S=0;if(a){const A=`${a}`.match(/(\d+)px/);S=A!=null&&A[1]?Number(A[1]):1}return{tooltipStyles:p,tooltipArrowStyles:{left:x!=null?`${x}px`:"",top:h!=null?`${h}px`:"",right:"",bottom:"",...I,[w]:`-${c/2+S}px`},place:m}})):ml(e,t,{placement:"bottom",strategy:i,middleware:d}).then(({x:u,y:f,placement:m})=>({tooltipStyles:{left:`${u}px`,top:`${f}px`},tooltipArrowStyles:{},place:m}))},wl=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),bl=(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},Il=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",ra=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((o,i)=>ra(o,t[i]));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!Il(e)||!Il(t))return e===t;const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(o=>ra(e[o],t[o]))},y0=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"})},Cl=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(y0(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},v0=typeof window<"u"?b.useLayoutEffect:b.useEffect,Lt=e=>{e.current&&(clearTimeout(e.current),e.current=null)},w0="DEFAULT_TOOLTIP_ID",b0={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},I0=b.createContext({getTooltipData:()=>b0});function yf(e=w0){return b.useContext(I0).getTooltipData(e)}var Fr={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"},ws={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 C0=({forwardRef:e,id:t,className:n,classNameArrow:r,variant:o="dark",anchorId:i,anchorSelect:s,place:a="top",offset:c=10,events:d=["hover"],openOnClick:u=!1,positionStrategy:f="absolute",middlewares:m,wrapper:g,delayShow:y=0,delayHide:v=0,float:p=!1,hidden:x=!1,noArrow:h=!1,clickable:w=!1,closeOnEsc:I=!1,closeOnScroll:S=!1,closeOnResize:A=!1,openEvents:O,closeEvents:N,globalCloseEvents:R,imperativeModeOnly:P,style:J,position:K,afterShow:M,afterHide:W,disableTooltip:ae,content:re,contentWrapperRef:ne,isOpen:ge,defaultIsOpen:ve=!1,setIsOpen:F,activeAnchor:U,setActiveAnchor:H,border:q,opacity:$,arrowColor:L,arrowSize:Z=8,role:te="tooltip"})=>{var Y;const Q=b.useRef(null),ee=b.useRef(null),le=b.useRef(null),k=b.useRef(null),we=b.useRef(null),[B,We]=b.useState({tooltipStyles:{},tooltipArrowStyles:{},place:a}),[Oe,mt]=b.useState(!1),[Be,gt]=b.useState(!1),[_e,et]=b.useState(null),St=b.useRef(!1),Vt=b.useRef(null),{anchorRefs:Pt,setActiveAnchor:ut}=yf(t),ot=b.useRef(!1),[Me,qe]=b.useState([]),Ft=b.useRef(!1),tt=u||d.includes("click"),Rr=tt||(O==null?void 0:O.click)||(O==null?void 0:O.dblclick)||(O==null?void 0:O.mousedown),pn=O?{...O}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!O&&tt&&Object.assign(pn,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const hn=N?{...N}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!N&&tt&&Object.assign(hn,{mouseleave:!1,blur:!1,mouseout:!1});const yt=R?{...R}:{escape:I||!1,scroll:S||!1,resize:A||!1,clickOutsideAnchor:Rr||!1};P&&(Object.assign(pn,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(hn,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(yt,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),v0(()=>(Ft.current=!0,()=>{Ft.current=!1}),[]);const Te=z=>{Ft.current&&(z&>(!0),setTimeout(()=>{Ft.current&&(F==null||F(z),ge===void 0&&mt(z))},10))};b.useEffect(()=>{if(ge===void 0)return()=>null;ge&>(!0);const z=setTimeout(()=>{mt(ge)},10);return()=>{clearTimeout(z)}},[ge]),b.useEffect(()=>{if(Oe!==St.current)if(Lt(we),St.current=Oe,Oe)M==null||M();else{const z=(ce=>{const ue=ce.match(/^([\d.]+)(ms|s)$/);if(!ue)return 0;const[,Le,He]=ue;return Number(Le)*(He==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));we.current=setTimeout(()=>{gt(!1),et(null),W==null||W()},z+25)}},[Oe]);const or=z=>{We(ce=>ra(ce,z)?ce:z)},Tn=(z=y)=>{Lt(le),Be?Te(!0):le.current=setTimeout(()=>{Te(!0)},z)},An=(z=v)=>{Lt(k),k.current=setTimeout(()=>{ot.current||Te(!1)},z)},Et=z=>{var ce;if(!z)return;const ue=(ce=z.currentTarget)!==null&&ce!==void 0?ce:z.target;if(!(ue!=null&&ue.isConnected))return H(null),void ut({current:null});y?Tn():Te(!0),H(ue),ut({current:ue}),Lt(k)},mn=()=>{w?An(v||100):v?An():Te(!1),Lt(le)},Rn=({x:z,y:ce})=>{var ue;const Le={getBoundingClientRect:()=>({x:z,y:ce,width:0,height:0,top:ce,left:z,right:z,bottom:ce})};vl({place:(ue=_e==null?void 0:_e.place)!==null&&ue!==void 0?ue:a,offset:c,elementReference:Le,tooltipReference:Q.current,tooltipArrowReference:ee.current,strategy:f,middlewares:m,border:q,arrowSize:Z}).then(He=>{or(He)})},Pn=z=>{if(!z)return;const ce=z,ue={x:ce.clientX,y:ce.clientY};Rn(ue),Vt.current=ue},gn=z=>{var ce;if(!Oe)return;const ue=z.target;ue.isConnected&&(!((ce=Q.current)===null||ce===void 0)&&ce.contains(ue)||[document.querySelector(`[id='${i}']`),...Me].some(Le=>Le==null?void 0:Le.contains(ue))||(Te(!1),Lt(le)))},nn=bl(Et,50),ke=bl(mn,50),st=z=>{ke.cancel(),nn(z)},oe=()=>{nn.cancel(),ke()},pe=b.useCallback(()=>{var z,ce;const ue=(z=_e==null?void 0:_e.position)!==null&&z!==void 0?z:K;ue?Rn(ue):p?Vt.current&&Rn(Vt.current):U!=null&&U.isConnected&&vl({place:(ce=_e==null?void 0:_e.place)!==null&&ce!==void 0?ce:a,offset:c,elementReference:U,tooltipReference:Q.current,tooltipArrowReference:ee.current,strategy:f,middlewares:m,border:q,arrowSize:Z}).then(Le=>{Ft.current&&or(Le)})},[Oe,U,re,J,a,_e==null?void 0:_e.place,c,f,K,_e==null?void 0:_e.position,p,Z]);b.useEffect(()=>{var z,ce;const ue=new Set(Pt);Me.forEach(be=>{ae!=null&&ae(be)||ue.add({current:be})});const Le=document.querySelector(`[id='${i}']`);Le&&!(ae!=null&&ae(Le))&&ue.add({current:Le});const He=()=>{Te(!1)},Qe=Cl(U),Dt=Cl(Q.current);yt.scroll&&(window.addEventListener("scroll",He),Qe==null||Qe.addEventListener("scroll",He),Dt==null||Dt.addEventListener("scroll",He));let nt=null;yt.resize?window.addEventListener("resize",He):U&&Q.current&&(nt=u0(U,Q.current,pe,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const vt=be=>{be.key==="Escape"&&Te(!1)};yt.escape&&window.addEventListener("keydown",vt),yt.clickOutsideAnchor&&window.addEventListener("click",gn);const Ne=[],Fn=be=>!!(be!=null&&be.target&&(U!=null&&U.contains(be.target))),Ht=be=>{Oe&&Fn(be)||Et(be)},Yo=be=>{Oe&&Fn(be)&&mn()},qi=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],Vi=["click","dblclick","mousedown","mouseup"];Object.entries(pn).forEach(([be,Jt])=>{Jt&&(qi.includes(be)?Ne.push({event:be,listener:st}):Vi.includes(be)&&Ne.push({event:be,listener:Ht}))}),Object.entries(hn).forEach(([be,Jt])=>{Jt&&(qi.includes(be)?Ne.push({event:be,listener:oe}):Vi.includes(be)&&Ne.push({event:be,listener:Yo}))}),p&&Ne.push({event:"pointermove",listener:Pn});const Hi=()=>{ot.current=!0},Ji=()=>{ot.current=!1,mn()},rn=w&&(hn.mouseout||hn.mouseleave);return rn&&((z=Q.current)===null||z===void 0||z.addEventListener("mouseover",Hi),(ce=Q.current)===null||ce===void 0||ce.addEventListener("mouseout",Ji)),Ne.forEach(({event:be,listener:Jt})=>{ue.forEach(pi=>{var sr;(sr=pi.current)===null||sr===void 0||sr.addEventListener(be,Jt)})}),()=>{var be,Jt;yt.scroll&&(window.removeEventListener("scroll",He),Qe==null||Qe.removeEventListener("scroll",He),Dt==null||Dt.removeEventListener("scroll",He)),yt.resize?window.removeEventListener("resize",He):nt==null||nt(),yt.clickOutsideAnchor&&window.removeEventListener("click",gn),yt.escape&&window.removeEventListener("keydown",vt),rn&&((be=Q.current)===null||be===void 0||be.removeEventListener("mouseover",Hi),(Jt=Q.current)===null||Jt===void 0||Jt.removeEventListener("mouseout",Ji)),Ne.forEach(({event:pi,listener:sr})=>{ue.forEach(Zo=>{var Dn;(Dn=Zo.current)===null||Dn===void 0||Dn.removeEventListener(pi,sr)})})}},[U,pe,Be,Pt,Me,O,N,R,tt,y,v]),b.useEffect(()=>{var z,ce;let ue=(ce=(z=_e==null?void 0:_e.anchorSelect)!==null&&z!==void 0?z:s)!==null&&ce!==void 0?ce:"";!ue&&t&&(ue=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const Le=new MutationObserver(He=>{const Qe=[],Dt=[];He.forEach(nt=>{if(nt.type==="attributes"&&nt.attributeName==="data-tooltip-id"&&(nt.target.getAttribute("data-tooltip-id")===t?Qe.push(nt.target):nt.oldValue===t&&Dt.push(nt.target)),nt.type==="childList"){if(U){const vt=[...nt.removedNodes].filter(Ne=>Ne.nodeType===1);if(ue)try{Dt.push(...vt.filter(Ne=>Ne.matches(ue))),Dt.push(...vt.flatMap(Ne=>[...Ne.querySelectorAll(ue)]))}catch{}vt.some(Ne=>{var Fn;return!!(!((Fn=Ne==null?void 0:Ne.contains)===null||Fn===void 0)&&Fn.call(Ne,U))&&(gt(!1),Te(!1),H(null),Lt(le),Lt(k),!0)})}if(ue)try{const vt=[...nt.addedNodes].filter(Ne=>Ne.nodeType===1);Qe.push(...vt.filter(Ne=>Ne.matches(ue))),Qe.push(...vt.flatMap(Ne=>[...Ne.querySelectorAll(ue)]))}catch{}}}),(Qe.length||Dt.length)&&qe(nt=>[...nt.filter(vt=>!Dt.includes(vt)),...Qe])});return Le.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{Le.disconnect()}},[t,s,_e==null?void 0:_e.anchorSelect,U]),b.useEffect(()=>{pe()},[pe]),b.useEffect(()=>{if(!(ne!=null&&ne.current))return()=>null;const z=new ResizeObserver(()=>{setTimeout(()=>pe())});return z.observe(ne.current),()=>{z.disconnect()}},[re,ne==null?void 0:ne.current]),b.useEffect(()=>{var z;const ce=document.querySelector(`[id='${i}']`),ue=[...Me,ce];U&&ue.includes(U)||H((z=Me[0])!==null&&z!==void 0?z:ce)},[i,Me,U]),b.useEffect(()=>(ve&&Te(!0),()=>{Lt(le),Lt(k)}),[]),b.useEffect(()=>{var z;let ce=(z=_e==null?void 0:_e.anchorSelect)!==null&&z!==void 0?z:s;if(!ce&&t&&(ce=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),ce)try{const ue=Array.from(document.querySelectorAll(ce));qe(ue)}catch{qe([])}},[t,s,_e==null?void 0:_e.anchorSelect]),b.useEffect(()=>{le.current&&(Lt(le),Tn(y))},[y]);const dt=(Y=_e==null?void 0:_e.content)!==null&&Y!==void 0?Y:re,yn=Oe&&Object.keys(B.tooltipStyles).length>0;return b.useImperativeHandle(e,()=>({open:z=>{if(z!=null&&z.anchorSelect)try{document.querySelector(z.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${z.anchorSelect}" is not a valid CSS selector`)}et(z??null),z!=null&&z.delay?Tn(z.delay):Te(!0)},close:z=>{z!=null&&z.delay?An(z.delay):Te(!1)},activeAnchor:U,place:B.place,isOpen:!!(Be&&!x&&dt&&yn)})),Be&&!x&&dt?b.createElement(g,{id:t,role:te,className:$t("react-tooltip",Fr.tooltip,ws.tooltip,ws[o],n,`react-tooltip__place-${B.place}`,Fr[yn?"show":"closing"],yn?"react-tooltip__show":"react-tooltip__closing",f==="fixed"&&Fr.fixed,w&&Fr.clickable),onTransitionEnd:z=>{Lt(we),Oe||z.propertyName!=="opacity"||(gt(!1),et(null),W==null||W())},style:{...J,...B.tooltipStyles,opacity:$!==void 0&&yn?$:void 0},ref:Q},dt,b.createElement(g,{className:$t("react-tooltip-arrow",Fr.arrow,ws.arrow,r,h&&Fr.noArrow),style:{...B.tooltipArrowStyles,background:L?`linear-gradient(to right bottom, transparent 50%, ${L} 50%)`:void 0,"--rt-arrow-size":`${Z}px`},ref:ee})):null},x0=({content:e})=>b.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),S0=b.forwardRef(({id:e,anchorId:t,anchorSelect:n,content:r,html:o,render:i,className:s,classNameArrow:a,variant:c="dark",place:d="top",offset:u=10,wrapper:f="div",children:m=null,events:g=["hover"],openOnClick:y=!1,positionStrategy:v="absolute",middlewares:p,delayShow:x=0,delayHide:h=0,float:w=!1,hidden:I=!1,noArrow:S=!1,clickable:A=!1,closeOnEsc:O=!1,closeOnScroll:N=!1,closeOnResize:R=!1,openEvents:P,closeEvents:J,globalCloseEvents:K,imperativeModeOnly:M=!1,style:W,position:ae,isOpen:re,defaultIsOpen:ne=!1,disableStyleInjection:ge=!1,border:ve,opacity:F,arrowColor:U,arrowSize:H,setIsOpen:q,afterShow:$,afterHide:L,disableTooltip:Z,role:te="tooltip"},Y)=>{const[Q,ee]=b.useState(r),[le,k]=b.useState(o),[we,B]=b.useState(d),[We,Oe]=b.useState(c),[mt,Be]=b.useState(u),[gt,_e]=b.useState(x),[et,St]=b.useState(h),[Vt,Pt]=b.useState(w),[ut,ot]=b.useState(I),[Me,qe]=b.useState(f),[Ft,tt]=b.useState(g),[Rr,pn]=b.useState(v),[hn,yt]=b.useState(null),[Te,or]=b.useState(null),Tn=b.useRef(ge),{anchorRefs:An,activeAnchor:Et}=yf(e),mn=ke=>ke==null?void 0:ke.getAttributeNames().reduce((st,oe)=>{var pe;return oe.startsWith("data-tooltip-")&&(st[oe.replace(/^data-tooltip-/,"")]=(pe=ke==null?void 0:ke.getAttribute(oe))!==null&&pe!==void 0?pe:null),st},{}),Rn=ke=>{const st={place:oe=>{var pe;B((pe=oe)!==null&&pe!==void 0?pe:d)},content:oe=>{ee(oe??r)},html:oe=>{k(oe??o)},variant:oe=>{var pe;Oe((pe=oe)!==null&&pe!==void 0?pe:c)},offset:oe=>{Be(oe===null?u:Number(oe))},wrapper:oe=>{var pe;qe((pe=oe)!==null&&pe!==void 0?pe:f)},events:oe=>{const pe=oe==null?void 0:oe.split(" ");tt(pe??g)},"position-strategy":oe=>{var pe;pn((pe=oe)!==null&&pe!==void 0?pe:v)},"delay-show":oe=>{_e(oe===null?x:Number(oe))},"delay-hide":oe=>{St(oe===null?h:Number(oe))},float:oe=>{Pt(oe===null?w:oe==="true")},hidden:oe=>{ot(oe===null?I:oe==="true")},"class-name":oe=>{yt(oe)}};Object.values(st).forEach(oe=>oe(null)),Object.entries(ke).forEach(([oe,pe])=>{var dt;(dt=st[oe])===null||dt===void 0||dt.call(st,pe)})};b.useEffect(()=>{ee(r)},[r]),b.useEffect(()=>{k(o)},[o]),b.useEffect(()=>{B(d)},[d]),b.useEffect(()=>{Oe(c)},[c]),b.useEffect(()=>{Be(u)},[u]),b.useEffect(()=>{_e(x)},[x]),b.useEffect(()=>{St(h)},[h]),b.useEffect(()=>{Pt(w)},[w]),b.useEffect(()=>{ot(I)},[I]),b.useEffect(()=>{pn(v)},[v]),b.useEffect(()=>{Tn.current!==ge&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")},[ge]),b.useEffect(()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:ge==="core",disableBase:ge}}))},[]),b.useEffect(()=>{var ke;const st=new Set(An);let oe=n;if(!oe&&e&&(oe=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),oe)try{document.querySelectorAll(oe).forEach(ce=>{st.add({current:ce})})}catch{console.warn(`[react-tooltip] "${oe}" is not a valid CSS selector`)}const pe=document.querySelector(`[id='${t}']`);if(pe&&st.add({current:pe}),!st.size)return()=>null;const dt=(ke=Te??pe)!==null&&ke!==void 0?ke:Et.current,yn=new MutationObserver(ce=>{ce.forEach(ue=>{var Le;if(!dt||ue.type!=="attributes"||!(!((Le=ue.attributeName)===null||Le===void 0)&&Le.startsWith("data-tooltip-")))return;const He=mn(dt);Rn(He)})}),z={attributes:!0,childList:!1,subtree:!1};if(dt){const ce=mn(dt);Rn(ce),yn.observe(dt,z)}return()=>{yn.disconnect()}},[An,Et,Te,t,n]),b.useEffect(()=>{W!=null&&W.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),ve&&!wl("border",`${ve}`)&&console.warn(`[react-tooltip] "${ve}" is not a valid \`border\`.`),W!=null&&W.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),F&&!wl("opacity",`${F}`)&&console.warn(`[react-tooltip] "${F}" is not a valid \`opacity\`.`)},[]);let Pn=m;const gn=b.useRef(null);if(i){const ke=i({content:(Te==null?void 0:Te.getAttribute("data-tooltip-content"))||Q||null,activeAnchor:Te});Pn=ke?b.createElement("div",{ref:gn,className:"react-tooltip-content-wrapper"},ke):null}else Q&&(Pn=Q);le&&(Pn=b.createElement(x0,{content:le}));const nn={forwardRef:Y,id:e,anchorId:t,anchorSelect:n,className:$t(s,hn),classNameArrow:a,content:Pn,contentWrapperRef:gn,place:we,variant:We,offset:mt,wrapper:Me,events:Ft,openOnClick:y,positionStrategy:Rr,middlewares:p,delayShow:gt,delayHide:et,float:Vt,hidden:ut,noArrow:S,clickable:A,closeOnEsc:O,closeOnScroll:N,closeOnResize:R,openEvents:P,closeEvents:J,globalCloseEvents:K,imperativeModeOnly:M,style:W,position:ae,isOpen:re,defaultIsOpen:ne,border:ve,opacity:F,arrowColor:U,arrowSize:H,setIsOpen:q,afterShow:$,afterHide:L,disableTooltip:Z,activeAnchor:Te,setActiveAnchor:ke=>or(ke),role:te};return b.createElement(C0,{...nn})});typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",e=>{e.detail.disableCore||yl({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;--rt-arrow-size:8px}.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;z-index:-1}.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||yl({css:`
|
|
51
|
-
.styles-module_tooltip__mnnfp{padding:8px 16px;border-radius:3px;font-size:90%;width:max-content}.styles-module_arrow__K0L3T{width:var(--rt-arrow-size);height:var(--rt-arrow-size)}[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 E0(){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:[l.jsxs("g",{clipPath:"url(#clip0_2896_16290)",children:[l.jsx("path",{d:"M8.00032 11.167L8.00032 7.83366M8.00032 1.83366C4.33366 1.83366 1.33366 4.83366 1.33366 8.50033C1.33366 12.167 4.33366 15.167 8.00033 15.167C11.667 15.167 14.667 12.167 14.667 8.50033C14.667 4.83366 11.667 1.83366 8.00032 1.83366Z",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M8.00293 5.83301L7.99768 5.83301",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})]}),l.jsx("defs",{children:l.jsx("clipPath",{id:"clip0_2896_16290",children:l.jsx("rect",{width:"16",height:"16",fill:"white",transform:"translate(16 16.5) rotate(180)"})})})]})}function vf({id:e,tooltipText:t}){return l.jsxs(l.Fragment,{children:[l.jsx("span",{"data-tooltip-id":e,style:{maxWidth:"20rem"},children:E0()}),l.jsx(S0,{id:e,place:"top",content:t,style:{maxWidth:"30rem"}})]})}function O0(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=!nd(o,n);e.read.isRequiredMapFieldsModified=s}}function Ni(e,t,n){t(e,r=>O0(r,n))}const _0="Each field must be mapped to a unique value";function Ga({field:e,onSelectChange:t,allFields:n}){var h;const{configureState:r,selectedObjectName:o,setConfigureState:i}=tn(),[s,a]=b.useState(!0),{isError:c,removeError:d,getError:u}=qt(),f=(h=r==null?void 0:r.read)==null?void 0:h.selectedFieldMappings,m=f==null?void 0:f[e.mapToName];b.useEffect(()=>{e._default&&!m&&o&&r&&Ni(o,i,[{field:e.mapToName,value:e._default}]),a(!1)},[e,i,o,m,r]);const g=b.useMemo(()=>n.map(w=>({id:w.fieldName,label:w.displayName,value:w.fieldName})),[n]),y=l.jsx(af,{disabled:s,items:g,selectedValue:m||null,onSelectedItemChange:w=>{t({target:{name:e.mapToName,value:w==null?void 0:w.value}})},placeholder:"Please select one",style:{width:"100%"}}),v=b.useCallback(()=>{o&&(Ni(o,i,[{field:e.mapToName,value:null}]),c(de.MAPPING,o)&&d(de.MAPPING,o))},[e.mapToName,o,i,c,d]),{hasDuplicationError:p,errorMessage:x}=b.useMemo(()=>{const w=u(de.MAPPING,o),I=Array.isArray(w)&&w.length>0&&w.includes(e.mapToName);return{hasDuplicationError:I,errorMessage:I?_0:""}},[o,u,e.mapToName]);return l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[l.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem",marginBottom:".25rem"},children:[l.jsx("span",{style:{fontWeight:500},children:e.mapToDisplayName??e.mapToName}),l.jsx("span",{children:(e==null?void 0:e.prompt)&&l.jsx(vf,{id:`tooltip-id-${e==null?void 0:e.prompt}`,tooltipText:e==null?void 0:e.prompt})})]}),l.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[y,l.jsx(Je,{type:"button",variant:"ghost",onClick:v,children:"Clear"})]})]},e.mapToName),p&&l.jsxs("span",{style:{color:"red",fontSize:"14px",marginTop:"4px"},children:[" ",x," "]},e.mapToName)]})}const N0="_formControl_9qd8d_1",T0="_formLabel_9qd8d_5",A0="_formLabelRequired_9qd8d_11",R0="_formInput_9qd8d_16",P0="_formInputInvalid_9qd8d_20",F0="_formError_9qd8d_24",D0="_disabled_9qd8d_30",lr={formControl:N0,formLabel:T0,formLabelRequired:A0,formInput:R0,formInputInvalid:P0,formError:F0,disabled:D0};function zo({id:e,label:t,isRequired:n=!1,isDisabled:r=!1,isInvalid:o=!1,errorMessage:i,children:s}){return l.jsxs("div",{className:$t(lr.formControl,{[lr.disabled]:r}),children:[t&&l.jsx("label",{htmlFor:e,className:$t(lr.formLabel,{[lr.formLabelRequired]:n}),children:t}),l.jsx("div",{id:e,className:$t(lr.formInput,{[lr.formInputInvalid]:o}),children:s}),o&&i&&l.jsx("div",{className:lr.formError,role:"alert",children:i})]})}function wf({selectedFieldMappings:e,selectedObjectName:t,fieldName:n,fieldValue:r,setError:o}){if(!e||!t)return!1;if(Object.values(e).some(s=>s===r&&s!==n)){console.error("Each field must be mapped to a unique value",e);const s=Object.keys(e).filter(c=>e[c]===r),a=[n,...s];return o(de.MAPPING,t,a),!0}return!1}function M0({dynamicFieldMappings:e,onSelectChange:t,allFields:n}){return e.length?l.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:e.map(r=>l.jsx(zo,{id:r.mapToName,children:l.jsx(Ga,{allFields:n,field:r,onSelectChange:t})},r.mapToName))}):null}function k0(){var y,v;const{selectedObjectName:e,configureState:t,setConfigureState:n}=tn(),{isError:r,removeError:o,setError:i}=qt(),s=((y=t==null?void 0:t.read)==null?void 0:y.allFields)||[],{fieldMapping:a}=Ze(),c=(v=t==null?void 0:t.read)==null?void 0:v.selectedFieldMappings,d=p=>{const{value:x,name:h}=p.target;!x||wf({selectedFieldMappings:c,selectedObjectName:e,fieldName:h,fieldValue:x,setError:i})||(e&&Ni(e,n,[{field:h,value:x}]),r(de.MAPPING,h)&&o(de.MAPPING,h),e&&r(de.MAPPING,e)&&o(de.MAPPING,e))},u=b.useMemo(()=>!e||!a?[]:Object.values(a[e]||{}).flat().filter(p=>!p.fieldName),[a,e]),f=b.useMemo(()=>{var h;return(((h=t==null?void 0:t.read)==null?void 0:h.optionalMapFields)||[]).filter(w=>!u.some(I=>I.mapToName===w.mapToName))},[t,u]),m=u.length>0;return f.length>0||m?l.jsxs(l.Fragment,{children:[l.jsx(Rt,{string:"Map the following optional fields"}),l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:[f==null?void 0:f.map(p=>l.jsx(zo,{id:p.mapToName,children:l.jsx(Ga,{allFields:s,field:p,onSelectChange:d})},p.mapToName)),m&&l.jsx(M0,{dynamicFieldMappings:u,onSelectChange:d,allFields:s})]})]}):null}function L0(){var d;const{selectedObjectName:e,configureState:t,setConfigureState:n}=tn(),{isError:r,removeError:o,setError:i}=qt(),s=(d=t==null?void 0:t.read)==null?void 0:d.selectedFieldMappings,a=u=>{const{value:f,name:m}=u.target;!f||wf({selectedFieldMappings:s,selectedObjectName:e,fieldName:m,fieldValue:f,setError:i})||(e&&Ni(e,n,[{field:m,value:f}]),r(de.MAPPING,m)&&o(de.MAPPING,m),e&&r(de.MAPPING,e)&&o(de.MAPPING,e))},c=b.useMemo(()=>{var u;return((u=t==null?void 0:t.read)==null?void 0:u.requiredMapFields)||[]},[t]);return c!=null&&c.length?l.jsxs(l.Fragment,{children:[l.jsx(Rt,{string:"Map the following fields"}),l.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:c.map(u=>{var f;return l.jsx(zo,{id:u.mapToName,isInvalid:r(de.MAPPING,u.mapToName),errorMessage:"* required",children:l.jsx(Ga,{allFields:((f=t==null?void 0:t.read)==null?void 0:f.allFields)||[],field:u,onSelectChange:a})},u.mapToName)})})]}):null}const j0=(e,t)=>e.filter(n=>!t.has(n));function K0(){var m,g,y;const{selectedObjectName:e,configureState:t,setConfigureState:n}=tn(),{fieldMapping:r}=Ze(),o=((m=t==null?void 0:t.read)==null?void 0:m.selectedFieldMappings)||{},i=Object.keys(o),s=((g=t==null?void 0:t.read)==null?void 0:g.requiredMapFields)||[],a=((y=t==null?void 0:t.read)==null?void 0:y.optionalMapFields)||[],c=e&&r?Object.values(r[e]||{}).flat().filter(v=>!v.fieldName):[],d=s.concat(c,a).map(v=>v.mapToName),u=new Set(d),f=j0(i,u);b.useEffect(()=>{e&&f.length&&Ni(e,n,f.map(v=>({field:v,value:null})))},[e,n,f])}const U0={backgroundColor:"var(--amp-colors-bg-highlight)",borderColor:"var(--amp-colors-bg-highlight)",padding:".5rem 1rem"};function $0({children:e,style:t}){return l.jsx(_n,{style:{...U0,...t},children:e})}function q0(){var d,u,f;const{data:e}=nr(),{hydratedRevision:t}=di(),{selectedObjectName:n}=tn(),{providerName:r}=lt(),o=e==null?void 0:e.appName,i=(f=(u=(d=t==null?void 0:t.content)==null?void 0:d.read)==null?void 0:u.objects)==null?void 0:f.find(m=>m.objectName===n),s=(i==null?void 0:i.displayName)||n&&ln(n),a=i==null?void 0:i.mapToName,c=(i==null?void 0:i.mapToDisplayName)||a&&ln(a);return c&&o&&r?l.jsx($0,{style:{marginTop:"1rem"},children:l.jsxs("p",{style:{margin:"1rem 0"},children:[l.jsx("b",{children:c})," in ",o," is mapped to"," ",l.jsx("b",{children:s})," in ",r,"."]})}):null}function xl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function bf(...e){return t=>{let n=!1;const r=e.map(o=>{const i=xl(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():xl(e[o],null)}}}}function oi(...e){return j.useCallback(bf(...e),e)}function Go(e,t=[]){let n=[];function r(i,s){const a=j.createContext(s),c=n.length;n=[...n,s];const d=f=>{var x;const{scope:m,children:g,...y}=f,v=((x=m==null?void 0:m[e])==null?void 0:x[c])||a,p=j.useMemo(()=>y,Object.values(y));return l.jsx(v.Provider,{value:p,children:g})};d.displayName=i+"Provider";function u(f,m){var v;const g=((v=m==null?void 0:m[e])==null?void 0:v[c])||a,y=j.useContext(g);if(y)return y;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[d,u]}const o=()=>{const i=n.map(s=>j.createContext(s));return function(a){const c=(a==null?void 0:a[e])||i;return j.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,V0(o,...t)]}function V0(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:c,scopeName:d})=>{const f=c(i)[`__scope${d}`];return{...a,...f}},{});return j.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Xt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}var Ti=globalThis!=null&&globalThis.document?j.useLayoutEffect:()=>{},H0=j[" useInsertionEffect ".trim().toString()]||Ti;function Qa({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,s]=J0({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const u=j.useRef(e!==void 0);j.useEffect(()=>{const f=u.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const d=j.useCallback(u=>{var f;if(a){const m=W0(u)?u(e):u;m!==e&&((f=s.current)==null||f.call(s,m))}else i(u)},[a,e,i,s]);return[c,d]}function J0({defaultProp:e,onChange:t}){const[n,r]=j.useState(e),o=j.useRef(n),i=j.useRef(t);return H0(()=>{i.current=t},[t]),j.useEffect(()=>{var s;o.current!==n&&((s=i.current)==null||s.call(i,n),o.current=n)},[n,o]),[n,r,i]}function W0(e){return typeof e=="function"}function B0(e){const t=j.useRef({value:e,previous:e});return j.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function z0(e){const[t,n]=j.useState(void 0);return Ti(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const c=i.borderBoxSize,d=Array.isArray(c)?c[0]:c;s=d.inlineSize,a=d.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 G0(e,t){return j.useReducer((n,r)=>t[n][r]??n,e)}var Xa=e=>{const{present:t,children:n}=e,r=Q0(t),o=typeof n=="function"?n({present:r.isPresent}):j.Children.only(n),i=oi(r.ref,X0(o));return typeof n=="function"||r.isPresent?j.cloneElement(o,{ref:i}):null};Xa.displayName="Presence";function Q0(e){const[t,n]=j.useState(),r=j.useRef(null),o=j.useRef(e),i=j.useRef("none"),s=e?"mounted":"unmounted",[a,c]=G0(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return j.useEffect(()=>{const d=co(r.current);i.current=a==="mounted"?d:"none"},[a]),Ti(()=>{const d=r.current,u=o.current;if(u!==e){const m=i.current,g=co(d);e?c("MOUNT"):g==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(u&&m!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),Ti(()=>{if(t){let d;const u=t.ownerDocument.defaultView??window,f=g=>{const v=co(r.current).includes(g.animationName);if(g.target===t&&v&&(c("ANIMATION_END"),!o.current)){const p=t.style.animationFillMode;t.style.animationFillMode="forwards",d=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=p)})}},m=g=>{g.target===t&&(i.current=co(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{u.clearTimeout(d),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:j.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function co(e){return(e==null?void 0:e.animationName)||"none"}function X0(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function ia(e){const t=Y0(e),n=j.forwardRef((r,o)=>{const{children:i,...s}=r,a=j.Children.toArray(i),c=a.find(ex);if(c){const d=c.props.children,u=a.map(f=>f===c?j.Children.count(d)>1?j.Children.only(null):j.isValidElement(d)?d.props.children:null:f);return l.jsx(t,{...s,ref:o,children:j.isValidElement(d)?j.cloneElement(d,void 0,u):null})}return l.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function Y0(e){const t=j.forwardRef((n,r)=>{const{children:o,...i}=n;if(j.isValidElement(o)){const s=nx(o),a=tx(i,o.props);return o.type!==j.Fragment&&(a.ref=r?bf(r,s):s),j.cloneElement(o,a)}return j.Children.count(o)>1?j.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Z0=Symbol("radix.slottable");function ex(e){return j.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Z0}function tx(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function nx(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 rx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Nn=rx.reduce((e,t)=>{const n=ia(`Primitive.${t}`),r=j.forwardRef((o,i)=>{const{asChild:s,...a}=o,c=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Qo="Checkbox",[ix,SE]=Go(Qo),[ox,Ya]=ix(Qo);function sx(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:o,disabled:i,form:s,name:a,onCheckedChange:c,required:d,value:u="on",internal_do_not_use_render:f}=e,[m,g]=Qa({prop:n,defaultProp:o??!1,onChange:c,caller:Qo}),[y,v]=j.useState(null),[p,x]=j.useState(null),h=j.useRef(!1),w=y?!!s||!!y.closest("form"):!0,I={checked:m,disabled:i,setChecked:g,control:y,setControl:v,name:a,form:s,value:u,hasConsumerStoppedPropagationRef:h,required:d,defaultChecked:Xn(o)?!1:o,isFormControl:w,bubbleInput:p,setBubbleInput:x};return l.jsx(ox,{scope:t,...I,children:ax(f)?f(I):r})}var If="CheckboxTrigger",Cf=j.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},o)=>{const{control:i,value:s,disabled:a,checked:c,required:d,setControl:u,setChecked:f,hasConsumerStoppedPropagationRef:m,isFormControl:g,bubbleInput:y}=Ya(If,e),v=oi(o,u),p=j.useRef(c);return j.useEffect(()=>{const x=i==null?void 0:i.form;if(x){const h=()=>f(p.current);return x.addEventListener("reset",h),()=>x.removeEventListener("reset",h)}},[i,f]),l.jsx(Nn.button,{type:"button",role:"checkbox","aria-checked":Xn(c)?"mixed":c,"aria-required":d,"data-state":Of(c),"data-disabled":a?"":void 0,disabled:a,value:s,...r,ref:v,onKeyDown:Xt(t,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Xt(n,x=>{f(h=>Xn(h)?!0:!h),y&&g&&(m.current=x.isPropagationStopped(),m.current||x.stopPropagation())})})});Cf.displayName=If;var Za=j.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:c,onCheckedChange:d,form:u,...f}=e;return l.jsx(sx,{__scopeCheckbox:n,checked:o,defaultChecked:i,disabled:a,required:s,onCheckedChange:d,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:m})=>l.jsxs(l.Fragment,{children:[l.jsx(Cf,{...f,ref:t,__scopeCheckbox:n}),m&&l.jsx(Ef,{__scopeCheckbox:n})]})})});Za.displayName=Qo;var xf="CheckboxIndicator",ec=j.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=Ya(xf,n);return l.jsx(Xa,{present:r||Xn(i.checked)||i.checked===!0,children:l.jsx(Nn.span,{"data-state":Of(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});ec.displayName=xf;var Sf="CheckboxBubbleInput",Ef=j.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:o,checked:i,defaultChecked:s,required:a,disabled:c,name:d,value:u,form:f,bubbleInput:m,setBubbleInput:g}=Ya(Sf,e),y=oi(n,g),v=B0(i),p=z0(r);j.useEffect(()=>{const h=m;if(!h)return;const w=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(w,"checked").set,A=!o.current;if(v!==i&&S){const O=new Event("click",{bubbles:A});h.indeterminate=Xn(i),S.call(h,Xn(i)?!1:i),h.dispatchEvent(O)}},[m,v,i,o]);const x=j.useRef(Xn(i)?!1:i);return l.jsx(Nn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??x.current,required:a,disabled:c,name:d,value:u,form:f,...t,tabIndex:-1,ref:y,style:{...t.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Ef.displayName=Sf;function ax(e){return typeof e=="function"}function Xn(e){return e==="indeterminate"}function Of(e){return Xn(e)?"indeterminate":e?"checked":"unchecked"}function _f(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 cx=["color"],Nf=b.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=_f(e,cx);return b.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}),b.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"}))}),lx=["color"],ux=b.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=_f(e,lx);return b.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}),b.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 dx="_checkboxGroupContainer_hqfeu_1",fx="_stack_hqfeu_6",px="_selectAllContainer_hqfeu_10",hx="_fieldContainer_hqfeu_17",mx="_checkbox_hqfeu_1",si={checkboxGroupContainer:dx,stack:fx,selectAllContainer:px,fieldContainer:hx,checkbox:mx};function gx({id:e,isChecked:t,label:n,onCheckedChange:r}){return l.jsxs("div",{className:si.fieldContainer,children:[l.jsx(Za,{className:si.checkbox,id:e,onCheckedChange:r,checked:t,children:l.jsx(ec,{children:l.jsx(Nf,{})})}),l.jsx("label",{htmlFor:e,style:{overflowWrap:"anywhere"},children:n})]})}function yx({id:e,isChecked:t,label:n,onCheckedChange:r,isIndeterminate:o}){return l.jsxs("div",{className:si.selectAllContainer,children:[l.jsx(Za,{className:si.checkbox,id:e,onCheckedChange:r,checked:o?"indeterminate":t,children:l.jsxs(ec,{children:[o&&l.jsx(ux,{}),t===!0&&l.jsx(Nf,{})]})}),l.jsx("label",{htmlFor:e,children:n})]})}function vx({children:e}){return l.jsx("div",{className:si.checkboxGroupContainer,children:e})}function wx({children:e}){return l.jsx("div",{className:si.stack,children:e})}const bx="_paginationContainer_i9j9p_1",Ix="_pageInfo_i9j9p_7",Sl={paginationContainer:bx,pageInfo:Ix};function Tf({items:e,onItemChange:t,onSelectAllChange:n,isAllChecked:r=!1,isIndeterminate:o=!1,itemsPerPage:i=8,showSelectAll:s=!0}){const[a,c]=b.useState(1),d=Math.ceil(e.length/i),u=(a-1)*i,f=u+i,m=e.slice(u,f);return l.jsxs(vx,{children:[d>1&&l.jsxs("div",{className:Sl.paginationContainer,children:[l.jsx(Je,{type:"button",onClick:()=>c(g=>Math.max(1,g-1)),disabled:a===1,variant:"ghost",children:"<"}),l.jsxs("span",{className:Sl.pageInfo,children:[a," of ",d]}),l.jsx(Je,{type:"button",onClick:()=>c(g=>Math.min(d,g+1)),disabled:a===d,variant:"ghost",children:">"})]}),s&&e.length>=2&&l.jsx(yx,{id:"select-all-fields",isChecked:r,label:`Select all ${e.length} fields`,onCheckedChange:n,isIndeterminate:o}),l.jsx(wx,{children:m.map(g=>l.jsx(gx,{id:g.id,isChecked:g.isChecked,label:g.label,onCheckedChange:y=>t(g.id,y===!0)},g.id))})]})}function Cx(e,t,n){var o,i;const r=((o=e==null?void 0:e.read)==null?void 0:o.selectedOptionalFields)||{};if(r[t]=n,n||delete r[t],(i=e.read)!=null&&i.savedConfig.optionalFields){const s=e.read.savedConfig.optionalFields,c=!nd(s,r);e.read.isOptionalFieldsModified=c}else console.warn("read.savedConfig.optionalFields is undefined")}function El(e,t,n,r){t(e,o=>Cx(o,n,r))}function xx(){var m,g;const{appName:e,configureState:t,setConfigureState:n,selectedObjectName:r}=tn(),o=(m=t==null?void 0:t.read)==null?void 0:m.selectedOptionalFields,i=(g=t==null?void 0:t.read)==null?void 0:g.optionalFields,s=(y,v)=>{r&&t&&El(r,n,y,v)},a=y=>{r&&i&&i.forEach(v=>{En(v)||El(r,n,v.fieldName,y)})},c=b.useMemo(()=>(i==null?void 0:i.filter(y=>!En(y)&&"fieldName"in y&&"displayName"in y).map(y=>({id:y.fieldName,label:y.displayName,isChecked:!!(o!=null&&o[y.fieldName])})).sort((y,v)=>y.label.localeCompare(v.label)))||[],[i,o]),d=!!(i&&i.length>0),u=c.every(y=>(o==null?void 0:o[y.id])===!0),f=!u&&Object.keys(o||{}).length>0;return d&&l.jsxs(l.Fragment,{children:[l.jsx(Rt,{string:`${e} reads the following optional fields`}),l.jsx(Tf,{items:c,onItemChange:s,onSelectAllChange:a,isAllChecked:u,isIndeterminate:f,showSelectAll:c.length>=2},`${r}-${i==null?void 0:i.length}`)]})}function Sx(){return l.jsx(xx,{})}const Ex={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 Ox({children:e,style:t,...n}){return l.jsx("span",{style:{...Ex,...t},...n,children:e})}function _x(){var n,r,o;const{configureState:e}=tn(),{appName:t}=nr();return l.jsxs(l.Fragment,{children:[l.jsx(Rt,{string:`${t} reads the following fields`}),l.jsx("div",{style:{display:"flex",gap:".5rem",marginBottom:".5rem",flexWrap:"wrap"},children:(r=(n=e==null?void 0:e.read)==null?void 0:n.requiredFields)!=null&&r.length?(o=e.read)==null?void 0:o.requiredFields.map(i=>En(i)?null:l.jsx(Ox,{children:i.displayName},i.fieldName)):"There are no required fields."})]})}function Nx(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 Af(e,t,n,r,o){t(e,i=>Nx(i,e,n,r,o))}function Tx(e,t,n){t(e,r=>{r.read&&(r.read.isValueMappingsModified=n)})}function Ax({string:e,fieldName:t}){return l.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"1rem",paddingBottom:".5rem"},children:[l.jsxs("h3",{style:{color:"var(--amp-colors-text-muted)",fontSize:"1rem",fontWeight:"400"},children:[e,l.jsx("b",{children:t})]}),l.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:l.jsx(Vo,{style:{width:"100%",marginLeft:"1rem"}})})]})}function Rx({mappedValue:e,onSelectChange:t,fieldName:n,allValueOptions:r,hasError:o}){var S;const{configureState:i,selectedObjectName:s,setConfigureState:a}=tn(),[c,d]=b.useState(!0),{getError:u,setError:f,resetBoundary:m,isError:g,removeError:y}=qt(),v=b.useMemo(()=>{var A,O;return((O=(A=i==null?void 0:i.read)==null?void 0:A.selectedValueMappings)==null?void 0:O[n])||{}},[(S=i==null?void 0:i.read)==null?void 0:S.selectedValueMappings,n]),p=b.useMemo(()=>v==null?void 0:v[e.mappedValue],[v,e.mappedValue]);b.useEffect(()=>{d(!1)},[e,a,s,p,i]);const x=b.useMemo(()=>r.map(A=>({id:A.value,label:A.displayValue,value:A.value})),[r]),h=b.useCallback(A=>{if(A){if(Object.values(v).some(O=>O===A.value&&O!==p)){const O=[...Object.entries(v).filter(([N,R])=>R===A.value&&R!==p).map(([N])=>N),e.mappedValue];f(de.VALUE_MAPPING,n,O);return}u(de.VALUE_MAPPING,n)&&m(de.VALUE_MAPPING),t({target:{name:e.mappedValue,value:A.value,fieldName:n}})}},[t,v,p,n,e.mappedValue,m,f,u]),w=b.useMemo(()=>l.jsx(af,{disabled:c,items:x,selectedValue:p||null,onSelectedItemChange:h,placeholder:"Please select one",style:{border:o?"2px solid red":void 0,borderRadius:"8px",width:"100%"}},p),[p,c,x,h,o]),I=b.useCallback(()=>{s&&(Af(s,a,e.mappedValue,"",n),g(de.VALUE_MAPPING,n)&&y(de.VALUE_MAPPING,n))},[s,a,e.mappedValue,n,g,y]);return l.jsxs("div",{style:{display:"flex",flexDirection:"column",marginBottom:".25rem"},children:[l.jsx("div",{style:{display:"flex",flexDirection:"row",gap:".25rem",marginBottom:".25rem"},children:l.jsx("span",{style:{fontWeight:500},children:e.mappedDisplayValue})}),l.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[w,l.jsx(Je,{type:"button",variant:"ghost",onClick:I,children:"Clear"})]})]},e.mappedValue)}function Px(){var g,y,v;const{fieldMapping:e}=Ze(),{selectedObjectName:t,configureState:n,setConfigureState:r}=tn(),{isError:o,removeError:i,getError:s}=qt(),a=(g=n==null?void 0:n.read)==null?void 0:g.selectedFieldMappings,c=(y=n==null?void 0:n.read)==null?void 0:y.selectedValueMappings,d=(v=n==null?void 0:n.read)==null?void 0:v.isValueMappingsModified,u=b.useRef(!1),f=b.useMemo(()=>{const p=t&&e?Object.values(e[t]||{}).flat().filter(x=>x.mappedValues).map(x=>({...x})):[];if(a)for(let x=0;x<p.length;x+=1){const{mapToName:h}=p[x];a!=null&&a[h]&&(p[x].fieldName=a[h])}return p},[t,e,a]),m=b.useCallback(p=>{const{value:x,name:h,fieldName:w}=p.target;x&&(t&&Af(t,r,h,x,w),o(de.VALUE_MAPPING,h)&&i(de.VALUE_MAPPING,h))},[t,r,o,i]);return b.useEffect(()=>{var p;if(t&&c){const x=((p=e==null?void 0:e[t])==null?void 0:p.filter(w=>w.fieldName&&w.mappedValues.length>0))||[];x.every(w=>{const I=c[w.fieldName]||{};return Object.keys(I).length===Object.keys(w.mappedValues).length})&&x.length>0?!d&&!u.current&&(Tx(t,r,!0),u.current=!0):u.current=!1}},[c,f,t,r,e,d]),f!=null&&f.length?l.jsx(l.Fragment,{children:f.map(p=>{var A,O,N;if(!p.fieldName)return null;const x=(O=(A=n==null?void 0:n.read)==null?void 0:A.allFieldsMetadata)==null?void 0:O[p.fieldName],h=x==null?void 0:x.valueType;if(!["singleSelect","multiSelect"].includes(h))return console.error("fieldName is not a singleSelect or multiSelect",p),null;const w=x==null?void 0:x.values;if(!w)return null;const I=Object.keys(w).length,S=Object.keys((p==null?void 0:p.mappedValues)||[]).length;return I!==S?(console.error("field values and the values to be mapped are not of the same length",p,w),null):l.jsxs(l.Fragment,{children:[l.jsx(Ax,{string:"Map the values for ",fieldName:p.mapToDisplayName||p.mapToName||p.fieldName}),l.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:l.jsx(zo,{id:p.mapToName||p.fieldName,children:(N=p==null?void 0:p.mappedValues)==null?void 0:N.map(R=>{var M,W,ae;const P=s(de.VALUE_MAPPING,p.fieldName),J=Array.isArray(P)&&P.includes(R.mappedValue),K=((ae=(W=(M=n==null?void 0:n.read)==null?void 0:M.allFieldsMetadata)==null?void 0:W[p.fieldName])==null?void 0:ae.values)||[];return l.jsxs(l.Fragment,{children:[l.jsx(Rx,{allValueOptions:K,mappedValue:R,onSelectChange:m,fieldName:(p==null?void 0:p.fieldName)||"",hasError:J},`${R.mappedValue}-${p.fieldName}`),J&&l.jsx("span",{style:{color:"red",fontSize:"14px",marginTop:"4px"},children:`Each ${p.mapToName||p.fieldName} must be mapped to a unique value`},R.mappedValue)]})})},p.mapToName||p.fieldName)})]})})}):null}const Fx=!1;function Dx(){return K0(),l.jsxs(l.Fragment,{children:[l.jsx(q0,{}),l.jsx(_x,{}),l.jsx(L0,{}),l.jsx(k0,{}),l.jsx(Px,{}),l.jsx(Sx,{}),Fx]})}function Mx(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,d=!Cb(a,s);e.write.isWriteModified=d}}}function Ol(e,t,n,r){t(e,o=>{Mx(o,n,r)})}function kx(){var m,g,y,v;const{appName:e,selectedObjectName:t,configureState:n,setConfigureState:r}=tn(),o=(m=n==null?void 0:n.write)==null?void 0:m.selectedWriteObjects,i=(g=n==null?void 0:n.write)==null?void 0:g.writeObjects,s=(p,x)=>{t&&n&&Ol(t,r,p,x)},a=p=>{var x,h;t&&n&&((h=(x=n==null?void 0:n.write)==null?void 0:x.writeObjects)==null||h.forEach(w=>{Ol(t,r,w.objectName,p)}))},c=!!i,d=Object.keys(o||{}).length===((v=(y=n==null?void 0:n.write)==null?void 0:y.writeObjects)==null?void 0:v.length),u=!d&&Object.keys(o||{}).length>0,f=(i==null?void 0:i.map(p=>({id:p.objectName,label:p.displayName,isChecked:!!(o!=null&&o[p.objectName])})))||[];return c&&l.jsxs(l.Fragment,{children:[l.jsx(Rt,{string:`Allow ${e} to write to these objects`}),l.jsx(Tf,{items:f,onItemChange:s,onSelectAllChange:a,isAllChecked:d,isIndeterminate:u,showSelectAll:i.length>=2})]})}function Lx(){return l.jsx(l.Fragment,{children:l.jsx(kx,{})})}function Rf({resetComponent:e,onDisconnectSuccess:t}){return l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[l.jsx(Rt,{string:"Remove connection"}),l.jsx("p",{children:"Click to disconnect your connection from the provider."}),l.jsx(gd,{resetComponent:e,onDisconnectSuccess:t,buttonText:"Remove connection",buttonVariant:"danger",buttonStyle:{fontSize:"13px",width:"100%"}})]})}const jx="_authenticationRow_1g2ms_1",Kx="_field_1g2ms_8",Ux="_value_1g2ms_12",bs={authenticationRow:jx,field:Kx,value:Ux};function _l({label:e,value:t}){return l.jsxs("div",{className:bs.authenticationRow,children:[l.jsx("div",{className:bs.field,children:e}),l.jsx("div",{className:bs.value,children:t})]})}function $x(){const{selectedConnection:e}=en(),{providerName:t}=lt(),r=(e==null?void 0:e.provider)==="salesforce"?"subdomain":"workspace",o=`${t} ${r}`;return l.jsxs(l.Fragment,{children:[l.jsx(Rt,{string:"Connection details"}),l.jsxs("div",{style:{paddingBottom:"1rem"},children:[l.jsx(_l,{label:o,value:e==null?void 0:e.providerWorkspaceRef}),l.jsx(_l,{label:"Status",value:ln((e==null?void 0:e.status)||"")})]})]})}const qx=()=>{const e=it(),t=$e();return On({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."),De(n)}})};function Pf({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={}}){const{projectIdOrName:r}=Re(),{integrationId:o,installation:i,setIntegrationDeleted:s,onUninstallSuccess:a}=Ze(),[c,d]=b.useState(!1),u=!r||!o||!(i!=null&&i.id)||c,f=qx(),m=async()=>{u||(d(!0),console.warn("uninstalling installation",{projectIdOrName: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:()=>d(!1)}))},g=c?"Uninstalling...":e,y=l.jsx(Je,{type:"button",onClick:m,disabled:u,variant:t,style:n,children:g});return i!=null&&i.id?y:null}function Vx(){const{installation:e}=Ze(),{providerName:t}=lt();return e?l.jsxs(l.Fragment,{children:[l.jsx(Rt,{string:"Uninstall entire integration"}),l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",padding:"1rem 0"},children:[e!=null&&e.id?l.jsxs("p",{style:{color:"var(--amp-colors-text-muted)"},children:["By clicking below, you will uninstall the entire ",t," ","integration. You will lose any configuration you've set up."]}):l.jsx("p",{children:"You've successfully uninstalled the integration."}),l.jsx(Pf,{buttonText:"Yes, uninstall",buttonVariant:"danger"})]})]}):null}function Hx(){const{installation:e,resetComponent:t}=Ze();return l.jsxs(l.Fragment,{children:[l.jsx($x,{}),l.jsx(Sa,{}),e&&l.jsx(Vx,{}),!e&&l.jsx(Rf,{resetComponent:t})]})}function Ff({onSave:e,onReset:t,isLoading:n,isCreateMode:r=!1,errorMsg:o}){var A,O,N,R;const{installation:i}=Ze(),{hydratedRevision:s,loading:a}=di(),{configureState:c,selectedObjectName:d}=tn(),u=i==null?void 0:i.config,f=u&&d&&!!Yu(u,d)||!1,m=((A=c==null?void 0:c.read)==null?void 0:A.isOptionalFieldsModified)||((O=c==null?void 0:c.read)==null?void 0:O.isRequiredMapFieldsModified)||((N=c==null?void 0:c.read)==null?void 0:N.isValueMappingsModified),g=(R=c==null?void 0:c.write)==null?void 0:R.isWriteModified,x=a||n||!c||!d||!(m||g||r||d!==_r&&!f),h=d===_r,w=d===So,I=l.jsx(Je,{type:"submit",disabled:x,children:r?"Install":"Save"}),S=l.jsx(Je,{type:"button",onClick:t,disabled:x,variant:"ghost",children:"Reset"});return n?l.jsx(Oi,{}):l.jsxs("form",{style:{width:"34rem"},onSubmit:e,children:[l.jsx("div",{style:{display:"flex",flexDirection:"row-reverse",gap:".8rem",marginBottom:"20px",height:"3rem"},children:!w&&l.jsxs(l.Fragment,{children:[I,S]})}),l.jsxs(_n,{style:{padding:"1rem 2rem",minHeight:"300px",backgroundColor:"var(--amp-colors-bg-primary)",borderColor:"var(--amp-colors-border)"},children:[o&&l.jsx(ki,{children:typeof o=="string"?o:"Installation Failed."}),a&&l.jsx(Oi,{}),s&&!h&&!w&&l.jsx(Dx,{}),s&&h&&!w&&l.jsx(Lx,{}),!a&&w&&l.jsx(Hx,{})]})]})}const Df=()=>{const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,onInstallSuccess:o,onUpdateSuccess:i}=Ze(),{hydratedRevision:s,loading:a}=di(),{selectedObjectName:c}=wd(),{selectedConnection:d}=en(),u=tu(),{projectIdOrName:f}=Re(),{resetBoundary:m,setErrors:g,setError:y,getError:v}=qt(),{resetConfigureState:p,objectConfigurationsState:x,resetPendingConfigurationState:h}=Ea(),w=cd(c||"",x),{onNextIncompleteTab:I}=bI(),S=b.useCallback(()=>{m(de.INSTALLATION_MUTATION)},[m]),A=b.useCallback(N=>N?R=>{y(de.INSTALLATION_MUTATION,N,R)}:R=>{console.error("objectName is required to set installation error: ",R)},[y]),O=b.useCallback(N=>N?v(de.INSTALLATION_MUTATION,N):"",[v]);return{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:s,loading:a,selectedObjectName:c,selectedConnection:d,apiKey:u,projectIdOrName:f,resetBoundary:m,setErrors:g,setMutateInstallationError:A,getMutateInstallationError:O,resetMutateInstallationErrorState:S,resetConfigureState:p,objectConfigurationsState:x,resetPendingConfigurationState:h,configureState:w,onInstallSuccess:o,onUpdateSuccess:i,onNextIncompleteTab:I}},Jx=void 0;function Wx(){const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:o,loading:i,selectedObjectName:s,selectedConnection:a,apiKey:c,projectIdOrName:d,resetBoundary:u,setErrors:f,setMutateInstallationError:m,getMutateInstallationError:g,resetMutateInstallationErrorState:y,resetConfigureState:v,objectConfigurationsState:p,resetPendingConfigurationState:x,configureState:h,onInstallSuccess:w,onNextIncompleteTab:I}=Df(),[S,A]=b.useState(!1),O=s===_r,N=g(s),R=b.useCallback(()=>{u(de.MAPPING),o!=null&&o.content&&!i&&s&&id(o,Jx,s,v)},[u,o,i,s,v]);b.useEffect(()=>{!h&&(o!=null&&o.content)&&!i&&R()},[h,p,o,i,R]);const P=()=>{y();const{requiredMapFields:M,selectedFieldMappings:W}=(h==null?void 0:h.read)||{},{errorList:ae}=td(M,W,f);ae.length>0||(s&&(a!=null&&a.id)&&c&&d&&e&&t&&n&&o?(A(!0),Nb(d,e,t,n,a.id,s,c,o,h,m(s),r,w).finally(()=>{A(!1),x(s),I()})):console.error("CreateInstallallation - onSaveReadCreate: missing required props"))},J=()=>{y(),s&&(a!=null&&a.id)&&c&&d&&e&&t&&n&&o?(A(!0),Rb(d,e,t,n,a.id,c,o,h,m(s),r,w).finally(()=>{A(!1),x(s),I()})):console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},K=M=>{M.preventDefault(),O?J():P()};return l.jsx(Ff,{errorMsg:N,isCreateMode:!0,isLoading:S,onSave:K,onReset:R})}function Bx({updateConfig:e,projectIdOrName:t,integrationId:n,installationId:r,apiKey:o,selectedObjectName:i,setInstallation:s,onUpdateSuccess:a,setError:c}){const d={projectIdOrName:t,installationId:r,integrationId:n,installationUpdate:{updateMask:[`config.content.read.objects.${ub(i)}`],installation:{config:e}}};return wa().installationApi.updateInstallation(d,{headers:{"X-Api-Key":o,"Content-Type":"application/json"}}).then(u=>{s(u),a==null||a(u.id,u.config)}).catch(u=>{De(u,c)})}const zx=(e,t,n,r,o,i)=>{const s=od(e),a=sd(e),c=ad(e),d={content:{read:{objects:{[t]:{objectName:t,schedule:r,destination:(n==null?void 0:n.destination)||"",selectedFields:s,selectedFieldMappings:a,selectedValueMappings:c||{},backfill:i}}}}};return Mi(o)&&(d.content||(d.content={}),d.content.proxy={enabled:!0}),d},Gx=(e,t,n,r,o,i,s,a,c,d,u)=>{const f=zx(i,r||"",a,a.schedule,c,a.backfill);return f?Bx({updateConfig:f,projectIdOrName:e,integrationId:t,installationId:n,apiKey:o,selectedObjectName:r,setError:d,setInstallation:s,onUpdateSuccess:u}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Qx=(e,t)=>{const r={content:{write:{objects:ud(e)}}};return Mi(t)&&(r.content||(r.content={}),r.content.proxy={enabled:!0}),r},Xx=(e,t,n,r,o,i,s,a,c)=>{const d=Qx(o,i);if(!d)return console.error("Error when generating write updateConfig from configureState"),Promise.resolve(null);const u={projectIdOrName:e,installationId:n,integrationId:t,installationUpdate:{updateMask:["config.content.write.objects"],installation:{config:d}}};return wa().installationApi.updateInstallation(u,{headers:{"X-Api-Key":r,"Content-Type":"application/json"}}).then(f=>{a(f),c==null||c(f.id,f.config)}).catch(f=>{De(f,s)})};function Yx({installation:e,integrationObj:t}){const{setInstallation:n,hydratedRevision:r,loading:o,selectedObjectName:i,apiKey:s,projectIdOrName:a,resetBoundary:c,setErrors:d,setMutateInstallationError:u,getMutateInstallationError:f,resetConfigureState:m,resetPendingConfigurationState:g,configureState:y,onUpdateSuccess:v,onNextIncompleteTab:p}=Df(),[x,h]=b.useState(!1),w=i===_r,I=f(i),{config:S}=e,A=b.useCallback(()=>{c(de.MAPPING),r!=null&&r.content&&!o&&i&&id(r,S,i,m)},[c,r,o,i,S,m]);b.useEffect(()=>{y||A()},[y,A]);const O=b.useMemo(()=>{var K,M,W;return(W=(M=(K=r==null?void 0:r.content)==null?void 0:K.read)==null?void 0:M.objects)==null?void 0:W.find(ae=>(ae==null?void 0:ae.objectName)===i)},[r,i]),N=()=>{const{requiredMapFields:J,selectedFieldMappings:K}=(y==null?void 0:y.read)||{},{errorList:M}=td(J,K,d);M.length>0||(r&&e&&i&&s&&a&&O?(h(!0),Gx(a,t.id,e.id,i,s,y,n,O,r,u(i),v).finally(()=>{h(!1),g(i),p()})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},R=()=>{e&&i&&s&&a&&r?(h(!0),Xx(a,t.id,e.id,s,y,r,u(i),n,v).finally(()=>{h(!1),g(i),p()})):console.error("UpdateInstallation - onSaveUpdate missing required props")},P=J=>{J.preventDefault(),w?R():N()};return l.jsx(Ff,{errorMsg:I,onSave:P,onReset:A,isLoading:x})}function Zx(){const{integrationObj:e,installation:t}=Ze();return e?t&&e?l.jsx(Yx,{installation:t,integrationObj:e}):l.jsx(Wx,{}):l.jsx(Ju,{message:"We can't load the integration"})}const Mf=()=>{const e=it(),t=$e(),[n,r]=b.useState(null);return{...On({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"),De(i,r)}}),errorMsg:n}};function eS(){return l.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"#BBF7D0"}),l.jsx("path",{d:"M34.6666 18.6667L20 32.0001L13.3333 25.9395",stroke:"#16A34A",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}function tc({text:e,children:t}){return l.jsx(li,{children:l.jsxs(_n,{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"3rem",gap:"3rem"},children:[l.jsx(eS,{}),l.jsx("p",{children:e}),t]})})}function tS({provider:e}){const{providerName:t}=lt(e),n=`You have successfully installed your ${t} integration.`;return l.jsx(tc,{text:n,children:l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:l.jsx(Pf,{buttonText:"Uninstall",buttonVariant:"outline",buttonStyle:{fontSize:"13px"}})})})}const nS=e=>{const{read:t,write:n}=(e==null?void 0:e.content)??{};return!t&&!n};function rS({children:e}){var S;const t=b.useRef(!1),{projectIdOrName:n}=Re(),{hydratedRevision:r,loading:o}=di(),{integrationObj:i,installation:s,groupRef:a,consumerRef:c,onInstallSuccess:d,isIntegrationDeleted:u}=Ze(),{mutate:f,isIdle:m,isPending:g,error:y,errorMsg:v}=Mf(),{selectedConnection:p,isConnectionsLoading:x}=en(),h=o||g||x,w=(S=r==null?void 0:r.content)==null?void 0:S.provider,I=nS(r);return b.useEffect(()=>{var A;if(!h&&!x&&r&&I&&!s&&p&&(i!=null&&i.id)&&!u&&w){const O={projectIdOrName:n,integrationId:i==null?void 0:i.id,installation:{groupRef:a,connectionId:p==null?void 0:p.id,config:{content:{provider:w}}}};Mi(r)===!0&&(O.installation.config.content.proxy=(A=r==null?void 0:r.content)==null?void 0:A.proxy),m&&!t.current&&(f(O,{onSuccess:N=>{d==null||d(N==null?void 0:N.id,N.config)}}),t.current=!0)}},[r,I,s,p,n,i==null?void 0:i.id,a,c,h,d,u,x,w,f,m]),I&&w&&s?l.jsx(tS,{provider:w}):y?l.jsx(Ut,{message:v??"Create installation failed"}):i?h?l.jsx(ui,{}):l.jsx("div",{children:e}):l.jsx(Ut,{message:"We can't load the integration"})}function Ui(){const e=it(),t=$e();return On({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"),De(n)}})}function iS({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a}){const{projectIdOrName:c}=Re(),d=Ui(),u=b.useCallback(f=>{var v;const{apiKey:m,providerMetadata:g}=f,y={projectIdOrName:c,generateConnectionParams:{providerWorkspaceRef:(v=g==null?void 0:g.workspace)==null?void 0:v.value,groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,apiKey:m,...g&&{providerMetadata:g}}};d.mutate(y)},[c,i,o,r,n,e,d]);return a===null?l.jsx(eI,{provider:e,providerInfo:t,handleSubmit:u,error:null}):s}function oS({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a}){const{projectIdOrName:c}=Re(),d=Ui(),u=b.useCallback(f=>{var p;const{user:m,pass:g,providerMetadata:y}=f,v={projectIdOrName:c,generateConnectionParams:{providerWorkspaceRef:(p=y==null?void 0:y.workspace)==null?void 0:p.value,groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,basicAuth:{username:m,password:g},...y&&{providerMetadata:y}}};d.mutate(v)},[c,i,o,r,n,e,d]);return a===null?l.jsx(oI,{provider:e,providerInfo:t,handleSubmit:u,error:null}):s}function Nl({url:e,prompt:t,inputName:n}){return l.jsx("p",{style:{color:"var(--amp-colors-text-muted)",display:"flex",justifyContent:"space-between"},children:l.jsxs("span",{children:[e?l.jsx(Ca,{href:e,newTab:!0,children:l.jsx("span",{style:{textDecoration:"underline"},children:n})}):l.jsx("span",{children:n})," ",t&&l.jsx(vf,{id:`docs-helper-text-${db(n||(t==null?void 0:t.slice(0,50)))}`,tooltipText:t})]})})}function sS({providerInfo:e,handleSubmit:t,isButtonDisabled:n,buttonVariant:r}){var m,g;const[o,i]=b.useState({}),s=((m=e.metadata)==null?void 0:m.input)||[],a=y=>{const{name:v,value:p}=y.currentTarget;i(x=>({...x,[v]:p.trim()}))},c=Zr(s,o),d=n||!c,u=((g=e.customOpts)==null?void 0:g.inputs)||[],f=()=>{const y=$o(s,o),v=Object.fromEntries(u.map(p=>[p.name,o[p.name]]));t({customAuth:v,providerMetadata:y})};return l.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[u.map(y=>l.jsxs("div",{children:[l.jsx(Nl,{url:y.docsURL,prompt:y.prompt,inputName:y.displayName}),l.jsx(xt.PasswordInput,{id:y.name,name:y.name,onChange:a,placeholder:""})]},y.name)),s.map(y=>l.jsxs("div",{children:[y.docsURL&&l.jsx(Nl,{url:y.docsURL,prompt:y.displayName||y.name,inputName:y.displayName||ln(y.name.toLowerCase())}),l.jsx(xt.Input,{id:y.name,name:y.name,type:"text",placeholder:"",onChange:a})]},y.name)),l.jsx(Je,{style:{marginTop:"1em",width:"100%"},disabled:d,type:"submit",onClick:f,variant:r,children:"Next"})]})}function aS({providerInfo:e,handleSubmit:t,error:n,isButtonDisabled:r}){return l.jsxs(rr,{children:[l.jsx(ir,{children:`Set up ${e.displayName} integration`}),l.jsx(dn,{error:n}),l.jsx(sS,{providerInfo:e,handleSubmit:t,isButtonDisabled:r})]})}function cS({providerInfo:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,selectedConnection:s}){const{projectIdOrName:a}=Re(),c=Ui(),[d,u]=b.useState(null),f=b.useCallback(m=>{var p;const{customAuth:g,providerMetadata:y}=m;u(null);const v={projectIdOrName:a,generateConnectionParams:{providerWorkspaceRef:(p=y==null?void 0:y.workspace)==null?void 0:p.value,groupName:o,groupRef:r,consumerName:n,consumerRef:t,provider:e.name,customAuth:g,...y&&{providerMetadata:y}}};c.mutate(v,{onError:x=>{De(x,u)},onSuccess:()=>{u(null)}})},[a,o,r,n,t,e.name,c]);return s===null?l.jsx(aS,{providerInfo:e,handleSubmit:f,error:d}):i}function lS({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r,children:o,title:i}){if(!i&&!r)throw new Error("Either title or providerName is required");return l.jsxs(rr,{children:[l.jsx(ir,{children:i||`Set up ${r} integration`}),l.jsx(dn,{error:t}),o,l.jsx(Je,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function uS({...e}){return l.jsx(lS,{...e})}function dS({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,selectedConnection:s,providerName:a}){const{projectIdOrName:c}=Re(),d=Ui(),u=b.useCallback(()=>{const f={projectIdOrName:c,generateConnectionParams:{groupName:o,groupRef:r,consumerName:n,consumerRef:t,provider:e}};d.mutate(f)},[c,o,r,n,t,e,d]);return s===null?l.jsx(uS,{handleSubmit:u,error:null,providerName:a}):i}const fS=()=>{const e=it(),t=$e();return On({mutationKey:["createOauthConnection"],mutationFn:async n=>(await e()).oAuthApi.oauthConnect(n),onSuccess:()=>{t.invalidateQueries({queryKey:["connections"]})}})};function pS({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return l.jsxs(rr,{children:[l.jsx(ir,{children:`Set up ${r} integration`}),l.jsx(Qb,{children:`Click Next to sign into the ${r} account you'd like to sync.`}),l.jsx(dn,{error:t}),l.jsx(Je,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:n?"Loading...":"Next"})]})}const hS="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function mS({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r}){return l.jsxs(rr,{children:[l.jsx(ir,{children:"Enter your Salesforce subdomain"}),l.jsx(Ca,{href:hS,newTab:!0,children:"What is my Salesforce subdomain?"}),l.jsx(dn,{error:n}),l.jsxs("div",{style:{display:"flex",marginTop:"1em",alignItems:"center"},children:[l.jsx(xt.Input,{id:"salesforce-subdomain",type:"text",placeholder:"my-domain",onChange:o=>t(o.currentTarget.value)}),l.jsx("p",{style:{lineHeight:"2.2em",marginLeft:"0.4em"},children:".my.salesforce.com"})]}),l.jsx(Je,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}function gS({handleSubmit:e,setFormData:t,error:n,isButtonDisabled:r,providerName:o,metadataFields:i}){return l.jsxs(rr,{children:[l.jsxs(ir,{children:["Enter your ",o," workspace"]}),l.jsx(dn,{error:n}),l.jsx("br",{}),i.map(s=>l.jsx(xt.Input,{id:s.name,name:s.name,type:"text",placeholder:s.displayName||s.name,onChange:a=>t(s.name,a.currentTarget.value)},s.name)),l.jsx("br",{}),l.jsx(Je,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}const Tl=600,Al=600,Rl="salesforce";function yS({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,providerName:i}){var J;const{projectId:s}=nr(),a=$e(),c=b.useRef(null),[d,u]=b.useState(null),[f,m]=b.useState(""),[g,y]=b.useState({}),[v,p]=b.useState({}),{data:x}=Uo(e),h=((J=x==null?void 0:x.metadata)==null?void 0:J.input)||[],{mutateAsync:w,isPending:I}=fS(),{isFetching:S,refetch:A}=ba({groupRef:r,provider:e});b.useEffect(()=>{const K=M=>{var W,ae,re;M.origin===qu&&(((W=M.data)==null?void 0:W.eventType)==="AUTHORIZATION_SUCCEEDED"?(u(null),console.debug("New connection:",M.data.data.connection),a.invalidateQueries({queryKey:["amp","connections"]})):((ae=M.data)==null?void 0:ae.eventType)==="AUTHORIZATION_FAILED"&&(console.error("OAuth failed:",M.data.data.error),a.invalidateQueries({queryKey:["amp","connections"]}),u(M.data.data.error||"An error occurred. Please try again.")),(re=c.current)==null||re.close())};return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[a]);const O=K=>{m(K),y(M=>({...M,workspace:K})),p(M=>({...M,workspace:{value:K,source:"input"}}))},N=(K,M)=>{y(W=>({...W,[K]:M})),p(W=>({...W,[K]:{value:M,source:"input"}}))},R=async()=>{var K;u(null);try{const{data:M}=await A();if(M&&M.length>0){console.debug("connections found");return}}catch{console.debug("error with fetching connections")}if(h.length>0&&!Zr(h,g)){u("Please fill in all required fields");return}try{const M=await w({connectOAuthParams:{provider:e,consumerRef:t,groupRef:r,projectId:s||"",consumerName:n,groupName:o,providerWorkspaceRef:e===Rl?f:(K=v==null?void 0:v.workspace)==null?void 0:K.value,providerMetadata:v}});if(M){const W=window.screenX+(window.outerWidth-Tl)/2,ae=window.screenY+(window.outerHeight-Al)/2.5,re=`width=${Tl},height=${Al},left=${W},top=${ae}`;c.current=window.open(M,"OAuthPopup",re)}}catch(M){console.error(M),u(M instanceof Error?M.message:String(M)||"An error occurred. Please try again.")}},P=e===Rl?l.jsx(mS,{handleSubmit:R,setWorkspace:O,error:d,isButtonDisabled:f.length===0||I||S}):h.length>0?l.jsx(gS,{handleSubmit:R,setFormData:N,error:d,isButtonDisabled:!Zr(h,g)||I||S,providerName:i,metadataFields:h}):l.jsx(pS,{handleSubmit:R,error:d,providerName:i,isButtonDisabled:I||S});return l.jsx("div",{children:P})}function vS({provider:e,providerName:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,explicitScopesRequired:s,selectedConnection:a}){const{projectIdOrName:c}=Re(),d=Ui(),[u,f]=b.useState(null),m=b.useCallback(g=>{var v,p;f(null);const y={projectIdOrName:c,generateConnectionParams:{groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,providerWorkspaceRef:(p=(v=g.providerMetadata)==null?void 0:v.workspace)==null?void 0:p.value,oauth2ClientCredentials:{clientId:g.clientId,clientSecret:g.clientSecret,scopes:g.scopes},...g.providerMetadata&&{providerMetadata:g.providerMetadata}}};d.mutate(y,{onError:()=>f("Error loading provider info")})},[c,i,o,r,n,e,d]);return a===null?l.jsx(aI,{provider:e,providerName:t,handleSubmit:m,error:u,explicitScopesRequired:s}):l.jsx(Oi,{})}function wS({...e}){return l.jsx(vS,{...e})}const bS="authorizationCode",IS="authorizationCodePKCE",CS="clientCredentials";function xS({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,selectedConnection:s,setSelectedConnection:a}){const{providerName:c}=lt(e);if(t.oauth2Opts===void 0)return l.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:d,explicitScopesRequired:u}=t.oauth2Opts,f={provider:e,consumerRef:n,consumerName:r,groupRef:o,groupName:i,providerName:c};return d===bS||d===IS?l.jsx(yS,{...f}):d===CS?l.jsx(wS,{...f,explicitScopesRequired:u,selectedConnection:s,setSelectedConnection:a}):d==="password"?l.jsx("em",{children:"Password flow not supported yet"}):l.jsxs("em",{children:["Unsupported grant type: ",d]})}function SS(e){const{selectedConnection:t}=en();b.useEffect(()=>{e&&t&&e(t)},[e,t])}function ES({onSuccess:e}){SS(e)}function kf({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,onSuccess:s,onDisconnectSuccess:a,resetComponent:c}){const{data:d,isLoading:u,isError:f,error:m,providerName:g,selectedProvider:y}=lt(e),{provider:v,isIntegrationDeleted:p}=Ze(),{selectedConnection:x,setSelectedConnection:h}=en();ES({onSuccess:s});const w=$e(),I=d;b.useEffect(()=>{f&&(console.error("Error loading provider info."),De(m))},[f,m]);const S=b.useCallback(()=>{w.clear(),c()},[c,w]);if(!e&&!v)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");if(p)return l.jsx(tc,{text:"Integration successfully uninstalled.",children:l.jsx(Je,{type:"button",onClick:S,style:{width:"100%"},children:"Reinstall Integration"})});if(x)return i;if(u)return l.jsx(ui,{});if(I==null)return l.jsx(Ut,{message:"Provider info was not found."});const A={provider:y,consumerRef:t,consumerName:n,groupRef:r,groupName:o,selectedConnection:x,setSelectedConnection:h,providerName:g,providerInfo:I,onDisconnectSuccess:a};return I.authType==="none"?l.jsx(dS,{...A,children:i}):I.authType==="basic"?l.jsx(oS,{...A,children:i}):I.authType==="apiKey"?l.jsx(iS,{...A,children:i}):I.authType==="custom"?l.jsx(cS,{...A,children:i}):l.jsx(xS,{...A})}function OS(e){const t=e+"CollectionProvider",[n,r]=Go(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=v=>{const{scope:p,children:x}=v,h=b.useRef(null),w=b.useRef(new Map).current;return l.jsx(o,{scope:p,itemMap:w,collectionRef:h,children:x})};s.displayName=t;const a=e+"CollectionSlot",c=ia(a),d=b.forwardRef((v,p)=>{const{scope:x,children:h}=v,w=i(a,x),I=oi(p,w.collectionRef);return l.jsx(c,{ref:I,children:h})});d.displayName=a;const u=e+"CollectionItemSlot",f="data-radix-collection-item",m=ia(u),g=b.forwardRef((v,p)=>{const{scope:x,children:h,...w}=v,I=b.useRef(null),S=oi(p,I),A=i(u,x);return b.useEffect(()=>(A.itemMap.set(I,{ref:I,...w}),()=>void A.itemMap.delete(I))),l.jsx(m,{[f]:"",ref:S,children:h})});g.displayName=u;function y(v){const p=i(e+"CollectionConsumer",v);return b.useCallback(()=>{const h=p.collectionRef.current;if(!h)return[];const w=Array.from(h.querySelectorAll(`[${f}]`));return Array.from(p.itemMap.values()).sort((A,O)=>w.indexOf(A.ref.current)-w.indexOf(O.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:s,Slot:d,ItemSlot:g},y,r]}var _S=j[" useId ".trim().toString()]||(()=>{}),NS=0;function Lf(e){const[t,n]=j.useState(_S());return Ti(()=>{e||n(r=>r??String(NS++))},[e]),e||(t?`radix-${t}`:"")}function TS(e){const t=j.useRef(e);return j.useEffect(()=>{t.current=e}),j.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}var AS=j.createContext(void 0);function jf(e){const t=j.useContext(AS);return e||t||"ltr"}var Is="rovingFocusGroup.onEntryFocus",RS={bubbles:!1,cancelable:!0},$i="RovingFocusGroup",[oa,Kf,PS]=OS($i),[FS,Uf]=Go($i,[PS]),[DS,MS]=FS($i),$f=j.forwardRef((e,t)=>l.jsx(oa.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(oa.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(kS,{...e,ref:t})})}));$f.displayName=$i;var kS=j.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:u=!1,...f}=e,m=j.useRef(null),g=oi(t,m),y=jf(i),[v,p]=Qa({prop:s,defaultProp:a??null,onChange:c,caller:$i}),[x,h]=j.useState(!1),w=TS(d),I=Kf(n),S=j.useRef(!1),[A,O]=j.useState(0);return j.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(Is,w),()=>N.removeEventListener(Is,w)},[w]),l.jsx(DS,{scope:n,orientation:r,dir:y,loop:o,currentTabStopId:v,onItemFocus:j.useCallback(N=>p(N),[p]),onItemShiftTab:j.useCallback(()=>h(!0),[]),onFocusableItemAdd:j.useCallback(()=>O(N=>N+1),[]),onFocusableItemRemove:j.useCallback(()=>O(N=>N-1),[]),children:l.jsx(Nn.div,{tabIndex:x||A===0?-1:0,"data-orientation":r,...f,ref:g,style:{outline:"none",...e.style},onMouseDown:Xt(e.onMouseDown,()=>{S.current=!0}),onFocus:Xt(e.onFocus,N=>{const R=!S.current;if(N.target===N.currentTarget&&R&&!x){const P=new CustomEvent(Is,RS);if(N.currentTarget.dispatchEvent(P),!P.defaultPrevented){const J=I().filter(re=>re.focusable),K=J.find(re=>re.active),M=J.find(re=>re.id===v),ae=[K,M,...J].filter(Boolean).map(re=>re.ref.current);Hf(ae,u)}}S.current=!1}),onBlur:Xt(e.onBlur,()=>h(!1))})})}),qf="RovingFocusGroupItem",Vf=j.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:s,...a}=e,c=Lf(),d=i||c,u=MS(qf,n),f=u.currentTabStopId===d,m=Kf(n),{onFocusableItemAdd:g,onFocusableItemRemove:y,currentTabStopId:v}=u;return j.useEffect(()=>{if(r)return g(),()=>y()},[r,g,y]),l.jsx(oa.ItemSlot,{scope:n,id:d,focusable:r,active:o,children:l.jsx(Nn.span,{tabIndex:f?0:-1,"data-orientation":u.orientation,...a,ref:t,onMouseDown:Xt(e.onMouseDown,p=>{r?u.onItemFocus(d):p.preventDefault()}),onFocus:Xt(e.onFocus,()=>u.onItemFocus(d)),onKeyDown:Xt(e.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){u.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const x=KS(p,u.orientation,u.dir);if(x!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let w=m().filter(I=>I.focusable).map(I=>I.ref.current);if(x==="last")w.reverse();else if(x==="prev"||x==="next"){x==="prev"&&w.reverse();const I=w.indexOf(p.currentTarget);w=u.loop?US(w,I+1):w.slice(I+1)}setTimeout(()=>Hf(w))}}),children:typeof s=="function"?s({isCurrentTabStop:f,hasTabStop:v!=null}):s})})});Vf.displayName=qf;var LS={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function jS(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function KS(e,t,n){const r=jS(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return LS[r]}function Hf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function US(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var $S=$f,qS=Vf,Xo="Tabs",[VS,EE]=Go(Xo,[Uf]),Jf=Uf(),[HS,nc]=VS(Xo),Wf=j.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:c="automatic",...d}=e,u=jf(a),[f,m]=Qa({prop:r,onChange:o,defaultProp:i??"",caller:Xo});return l.jsx(HS,{scope:n,baseId:Lf(),value:f,onValueChange:m,orientation:s,dir:u,activationMode:c,children:l.jsx(Nn.div,{dir:u,"data-orientation":s,...d,ref:t})})});Wf.displayName=Xo;var Bf="TabsList",zf=j.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=nc(Bf,n),s=Jf(n);return l.jsx($S,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:r,children:l.jsx(Nn.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});zf.displayName=Bf;var Gf="TabsTrigger",Qf=j.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=nc(Gf,n),a=Jf(n),c=Yf(s.baseId,r),d=Zf(s.baseId,r),u=r===s.value;return l.jsx(qS,{asChild:!0,...a,focusable:!o,active:u,children:l.jsx(Nn.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":d,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...i,ref:t,onMouseDown:Xt(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(r):f.preventDefault()}),onKeyDown:Xt(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(r)}),onFocus:Xt(e.onFocus,()=>{const f=s.activationMode!=="manual";!u&&!o&&f&&s.onValueChange(r)})})})});Qf.displayName=Gf;var Xf="TabsContent",JS=j.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=nc(Xf,n),c=Yf(a.baseId,r),d=Zf(a.baseId,r),u=r===a.value,f=j.useRef(u);return j.useEffect(()=>{const m=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(m)},[]),l.jsx(Xa,{present:o||u,children:({present:m})=>l.jsx(Nn.div,{"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:d,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:m&&i})})});JS.displayName=Xf;function Yf(e,t){return`${e}-trigger-${t}`}function Zf(e,t){return`${e}-content-${t}`}var WS=Wf,BS=zf,ep=Qf;const zS=l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[l.jsx("circle",{cx:"9",cy:"9",r:"9",fill:"#BBF7D0"}),l.jsx("path",{d:"M13 7L7.5 12L5 9.72727",stroke:"#16A34A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function GS(e,t){return t?b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},b.createElement("circle",{cx:"9",cy:"9",r:"5",fill:"#FBD38D"})):e?zS:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:l.jsx("circle",{cx:"9",cy:"9",r:"5",fill:"#BFDBFE"})})}function QS(){return l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M8 11C9.65685 11 11 9.65685 11 8C11 6.34315 9.65685 5 8 5C6.34315 5 5 6.34315 5 8C5 9.65685 6.34315 11 8 11Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M12.3378 5.04365C12.4882 5.25907 12.62 5.48699 12.7315 5.7249L14.3503 6.6249C14.5524 7.5302 14.5545 8.4687 14.3565 9.3749L12.7315 10.2749C12.62 10.5128 12.4882 10.7407 12.3378 10.9562L12.369 12.8124C11.683 13.4375 10.871 13.9085 9.98776 14.1937L8.39401 13.2374C8.13185 13.2562 7.86868 13.2562 7.60651 13.2374L6.01901 14.1874C5.13295 13.9075 4.31832 13.4383 3.63151 12.8124L3.66276 10.9624C3.51356 10.744 3.38189 10.5141 3.26901 10.2749L1.65026 9.3749C1.44814 8.46961 1.446 7.53111 1.64401 6.6249L3.26901 5.7249C3.38056 5.48699 3.5123 5.25907 3.66276 5.04365L3.63151 3.1874C4.31754 2.56226 5.1295 2.09128 6.01276 1.80615L7.60651 2.7624C7.86868 2.74365 8.13185 2.74365 8.39401 2.7624L9.98151 1.8124C10.8676 2.09234 11.6822 2.5615 12.369 3.1874L12.3378 5.04365Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const XS="_tabsRoot_ktpr0_1",YS="_tabsList_ktpr0_6",ZS="_tabTrigger_ktpr0_12",eE="_danger_ktpr0_29",Fo={tabsRoot:XS,tabsList:YS,tabTrigger:ZS,danger:eE};function tE(){return l.jsxs(l.Fragment,{children:[l.jsx(Vo,{style:{margin:"1rem 0"}}),l.jsx(ep,{value:So,className:Fo.tabTrigger,children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[l.jsx(QS,{}),l.jsx("span",{children:"Manage"})]})})]})}function tp({objectName:e,completed:t,pending:n,displayName:r}){return l.jsx(ep,{value:e,className:Fo.tabTrigger,children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[GS(t,n),l.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[l.jsx("span",{children:r||e}),n&&l.jsx("span",{style:{fontSize:".8rem",fontStyle:"italic"},children:"pending"})]})]})})}function nE({completed:e,pending:t,displayName:n}){return l.jsxs(l.Fragment,{children:[l.jsx(Vo,{style:{margin:"1rem 0"}}),l.jsx(tp,{objectName:_r,completed:e,pending:t,displayName:n},"other-write")]})}function rE({value:e,readNavObjects:t,onValueChange:n,objectConfigurationsState:r,writeNavObject:o}){var i,s;return l.jsx(WS,{value:e,className:Fo.tabsRoot,onValueChange:n,children:l.jsxs(BS,{className:Fo.tabsList,children:[t.map(a=>{var c,d,u,f,m,g;return l.jsx(tp,{objectName:a.name,displayName:a.displayName,completed:a.completed,pending:((d=(c=r==null?void 0:r[a.name])==null?void 0:c.read)==null?void 0:d.isOptionalFieldsModified)||((f=(u=r==null?void 0:r[a.name])==null?void 0:u.read)==null?void 0:f.isRequiredMapFieldsModified)||((g=(m=r==null?void 0:r[a.name])==null?void 0:m.read)==null?void 0:g.isValueMappingsModified)||!1},a.name)}),o&&l.jsx(nE,{completed:o.completed,pending:((s=(i=r==null?void 0:r.other)==null?void 0:i.write)==null?void 0:s.isWriteModified)||!1,displayName:"Write"}),l.jsx(tE,{})]})})}function iE(e,t){return t===So?{name:So,completed:!1}:e.find(n=>n.name===t)}function oE({children:e}){var x;const{data:t}=nr(),{installation:n}=Ze(),{providerName:r}=lt(),{hydratedRevision:o}=di(),{objectConfigurationsState:i}=Ea(),[s,a]=b.useState(""),c=(t==null?void 0:t.appName)||"",d=n==null?void 0:n.config,u=o&&Zu(d,o),f=u!==null,m=!!((x=o==null?void 0:o.content)!=null&&x.write),g=m?ed(d):void 0,y=b.useMemo(()=>{const h=[...u||[]];return g&&m&&h.push(g),h},[u,g,m]),v=iE(y,s),p=b.useCallback(()=>{const h=y.find(w=>v!==w&&!w.completed);h&&a(h.name)},[y,v]);return b.useEffect(()=>{!s&&y.length>0&&a(y[0].name)},[y,s,p]),l.jsx(bd.Provider,{value:p,children:l.jsx(vd.Provider,{value:v==null?void 0:v.name,children:l.jsxs(li,{style:{maxWidth:"55rem"},children:[l.jsxs(_n,{style:{display:"flex",gap:"1rem",padding:"3rem",paddingBottom:"6rem",backgroundColor:"var(--amp-colors-bg-primary)"},children:[l.jsxs("div",{style:{width:"20rem"},children:[l.jsxs("h1",{style:{fontSize:"small",fontWeight:"400"},children:[r," integration"]}),l.jsx("h3",{style:{marginBottom:"20px",fontSize:"large",fontWeight:"500"},children:c}),f&&l.jsx(rE,{value:s,readNavObjects:u,onValueChange:h=>a(h),objectConfigurationsState:i,writeNavObject:g})]}),e]}),l.jsx(fd,{})]})})})}function sE({...e}){return l.jsx(oE,{...e})}const aE="_resetContainer_lkwv9_4",np={resetContainer:aE};function cE({integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c}){var x;const{projectIdOrName:d,isLoading:u}=nr(),{isLoading:f}=Ko(),{isError:m,errorState:g}=qt(),{seed:y,reset:v}=Qu(),{options:p}=Re();return p.getToken?(console.error("JWT authentication is not supported in InstallIntegration. Please use API key authentication instead."),l.jsx(Ut,{message:"JWT authentication is not supported in InstallIntegration. Please use API key authentication instead."})):u||f?l.jsx(ui,{}):m(de.PROJECT,d)?l.jsx(Ut,{message:`Error loading project ${d}`}):m(de.INTEGRATION_LIST,d)?l.jsx(Ut,{message:"Error retrieving integrations for the project, double check the API key"}):(x=g[de.INTEGRATION_LIST])!=null&&x.apiError?l.jsx(Ut,{message:"Something went wrong, couldn't find integration information"}):l.jsx("div",{className:np.resetContainer,children:l.jsx(pb,{integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c,resetComponent:v,children:l.jsx(Gu,{children:l.jsx(kf,{consumerRef:t,consumerName:n,groupRef:r,groupName:o,resetComponent:v,children:l.jsx(wI,{resetComponent:v,children:l.jsx(rS,{children:l.jsx(CI,{children:l.jsx(sE,{children:l.jsx(Zx,{})})})})})})})},y)})}function lE(e){return typeof e.provider=="string"}function uE(e){if(!lE(e))throw new Error("Config must have a provider field for creation");return e}function dE(){const{projectIdOrName:e}=Re(),{groupRef:t,integrationNameOrId:n}=Ar(),{data:r}=ci(n),{connection:o}=va(),{installation:i}=Di(),s=$e(),{mutate:a,isIdle:c,isPending:d,error:u,errorMsg:f}=Mf();return{createInstallation:({config:g,onSuccess:y,onError:v,onSettled:p})=>{if(i)throw Error("Installation already created. Try updating instead.");if(!r)throw Error("No integration found");const x={projectIdOrName:e,integrationId:r==null?void 0:r.id,installation:{groupRef:t,connectionId:o==null?void 0:o.id,config:{content:uE(g)}}};return a(x,{onSuccess:h=>{y==null||y(h)},onError:h=>{v==null||v(h)},onSettled:()=>{p==null||p(),s.invalidateQueries({queryKey:["amp","installations"]})}})},isIdle:c,isPending:d,error:u,errorMsg:f}}const fE=()=>{const e=it(),t=$e(),[n,r]=b.useState(null);return{...On({mutationKey:["updateInstallation"],mutationFn:async i=>(await e()).installationApi.updateInstallation(i),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","installations"]}),r(null)},onError:i=>{console.error("Error updating installation"),De(i,r)}}),errorMsg:n}};function pE(){const{projectIdOrName:e}=Re(),{integrationNameOrId:t}=Ar(),{data:n}=ci(t),{installation:r}=Di(),o=$e(),{mutate:i,isIdle:s,isPending:a,error:c,errorMsg:d}=fE();return{updateInstallation:({config:f,onSuccess:m,onError:g,onSettled:y})=>{var x,h;if(!r)throw Error("Installation not created yet. Try creating the installation first.");if(!n)throw Error("No integration found");const v=[];if((x=f==null?void 0:f.write)!=null&&x.objects&&Object.keys(f.write.objects).length>0&&v.push("config.content.write.objects"),(h=f==null?void 0:f.read)!=null&&h.objects){const w=Object.keys(f.read.objects);v.push(...w.map(I=>`config.content.read.objects.${I}`))}const p={projectIdOrName:e,integrationId:n==null?void 0:n.id,installationId:r.id,installationUpdate:{updateMask:v,installation:{config:{content:f}}}};return i(p,{onSuccess:w=>{m==null||m(w)},onError:w=>{g==null||g(w)},onSettled:()=>{y==null||y(),o.invalidateQueries({queryKey:["amp","installations"]})}})},isIdle:s,isPending:a,error:c,errorMsg:d}}const hE=()=>{const e=it(),t=$e(),[n,r]=b.useState(null);return{...On({mutationKey:["deleteInstallation"],mutationFn:async i=>(await e()).installationApi.deleteInstallation(i),onSuccess:()=>{t.invalidateQueries({queryKey:["amp","installations"]}),r(null)},onError:i=>{console.error("Error deleting installation"),De(i,r)}}),errorMsg:n}};function mE(){const{projectIdOrName:e}=Re(),{integrationNameOrId:t}=Ar(),{data:n}=ci(t),{installation:r}=Di(),o=$e(),{mutate:i,isIdle:s,isPending:a,error:c,errorMsg:d}=hE();return{deleteInstallation:({onSuccess:f,onError:m,onSettled:g})=>{if(!r)throw Error("Installation not found. Not able to delete installation.");if(!n)throw Error("No integration found");return i({projectIdOrName:e,integrationId:n==null?void 0:n.id,installationId:r.id},{onSuccess:()=>{f==null||f()},onError:y=>{m==null||m(y)},onSettled:()=>{g==null||g(),o.invalidateQueries({queryKey:["amp","installations"]}),o.invalidateQueries({queryKey:["amp","connections"]})}})},isIdle:s,isPending:a,error:c,errorMsg:d}}function gE(){return l.jsxs(li,{style:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[l.jsx(Oi,{}),l.jsx("p",{children:"Redirecting"})]})}function yE({redirectURL:e,children:t}){return b.useEffect(()=>{e&&window.location.replace(e)},[e]),e?l.jsx(gE,{}):t}function vE({resetComponent:e,onDisconnectSuccess:t,provider:n}){const[r,o]=b.useState(!1);return l.jsxs(l.Fragment,{children:[r===!1&&l.jsxs(l.Fragment,{children:[l.jsx(Rt,{string:"Manage connection"}),l.jsxs("div",{style:{padding:"1rem 0",width:"100%",display:"flex",flexDirection:"column",gap:"1rem"},children:[l.jsx("p",{children:"Click to reauthenticate or refresh your connection."}),l.jsx(Je,{type:"button",onClick:()=>o(!0),variant:"ghost",style:{fontSize:"13px"},children:"Update connection"})]})]}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(Sa,{provider:n}),l.jsx(Rf,{resetComponent:e,onDisconnectSuccess:t})]})]})}function wE({provider:e,onDisconnectSuccess:t,resetComponent:n}){const{appName:r}=nr(),{providerName:o}=lt(e),i=`You have successfully connected your ${o} account to ${r}.`;return l.jsx(tc,{text:i,children:l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",width:"100%"},children:l.jsx(vE,{resetComponent:n,onDisconnectSuccess:t,provider:e})})})}function bE({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,redirectUrl:i,onSuccess:s,onDisconnectSuccess:a,onConnectSuccess:c}){const{seed:d,reset:u}=Qu(),f=b.useCallback(m=>{s?s(m.id):c&&c(m)},[s,c]);return l.jsx("div",{className:np.resetContainer,children:l.jsx(Ku,{integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:l.jsx(Gu,{groupRef:r,provider:e,children:l.jsx(kf,{resetComponent:u,provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onSuccess:f,onDisconnectSuccess:a,children:l.jsx(yE,{redirectURL:i,children:l.jsx(wE,{resetComponent:u,provider:e,onDisconnectSuccess:a})})})})})},d)}const IE=(e,t)=>{const{data:n,isLoading:r,isError:o,error:i}=ya(e,t),s=((n==null?void 0:n.length)||0)>0,a=!!n&&!r,c=n==null?void 0:n[0],d=c==null?void 0:c.config;return b.useEffect(()=>{o&&De(i)},[o,i]),{isLoaded:a,isIntegrationInstalled:s,isLoading:r,config:d}};exports.AmpersandContext=fa;exports.AmpersandProvider=Zh;exports.ConnectProvider=bE;exports.FieldSettingWriteOnCreateEnum=Km;exports.FieldSettingWriteOnUpdateEnum=Um;exports.InstallIntegration=cE;exports.InstallationProvider=Ku;exports.useAmpersandProviderProps=Re;exports.useConfig=$w;exports.useConnection=va;exports.useCreateInstallation=dE;exports.useDeleteInstallation=mE;exports.useInstallation=Di;exports.useIsIntegrationInstalled=IE;exports.useManifest=ku;exports.useUpdateInstallation=pE;
|
|
50
|
+
*/const uS="react-tooltip-core-styles",lS="react-tooltip-base-styles",gu={core:!1,base:!1};function yu({css:e,id:t=lS,type:n="base",ref:r}){var o,i;if(!e||typeof document>"u"||gu[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=uS),r||(r={});const{insertAt:s}=r;if(document.getElementById(t))return;const a=document.head||document.getElementsByTagName("head")[0],c=document.createElement("style");c.id=t,c.type="text/css",s==="top"&&a.firstChild?a.insertBefore(c,a.firstChild):a.appendChild(c),c.styleSheet?c.styleSheet.cssText=e:c.appendChild(document.createTextNode(e)),gu[n]=!0}const vu=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:r="top",offset:o=10,strategy:i="absolute",middlewares:s=[oS(Number(o)),aS({fallbackAxisSideDirection:"start"}),sS({padding:5})],border:a,arrowSize:c=8})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};if(t===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};const f=s;return n?(f.push(cS({element:n,padding:5})),mu(e,t,{placement:r,strategy:i,middleware:f}).then(({x:d,y:l,placement:m,middlewareData:g})=>{var v,w;const h={left:`${d}px`,top:`${l}px`,border:a},{x:S,y:p}=(v=g.arrow)!==null&&v!==void 0?v:{x:0,y:0},y=(w={top:"bottom",right:"left",bottom:"top",left:"right"}[m.split("-")[0]])!==null&&w!==void 0?w:"bottom",I=a&&{borderBottom:a,borderRight:a};let x=0;if(a){const T=`${a}`.match(/(\d+)px/);x=T!=null&&T[1]?Number(T[1]):1}return{tooltipStyles:h,tooltipArrowStyles:{left:S!=null?`${S}px`:"",top:p!=null?`${p}px`:"",right:"",bottom:"",...I,[y]:`-${c/2+x}px`},place:m}})):mu(e,t,{placement:"bottom",strategy:i,middleware:f}).then(({x:d,y:l,placement:m})=>({tooltipStyles:{left:`${d}px`,top:`${l}px`},tooltipArrowStyles:{},place:m}))},wu=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),bu=(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},Iu=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",ia=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((o,i)=>ia(o,t[i]));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!Iu(e)||!Iu(t))return e===t;const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(o=>ia(e[o],t[o]))},dS=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"})},Cu=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(dS(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},fS=typeof window<"u"?b.useLayoutEffect:b.useEffect,Lt=e=>{e.current&&(clearTimeout(e.current),e.current=null)},pS="DEFAULT_TOOLTIP_ID",hS={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},mS=b.createContext({getTooltipData:()=>hS});function gf(e=pS){return b.useContext(mS).getTooltipData(e)}var Pr={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"},bs={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 gS=({forwardRef:e,id:t,className:n,classNameArrow:r,variant:o="dark",anchorId:i,anchorSelect:s,place:a="top",offset:c=10,events:f=["hover"],openOnClick:d=!1,positionStrategy:l="absolute",middlewares:m,wrapper:g,delayShow:v=0,delayHide:w=0,float:h=!1,hidden:S=!1,noArrow:p=!1,clickable:y=!1,closeOnEsc:I=!1,closeOnScroll:x=!1,closeOnResize:T=!1,openEvents:E,closeEvents:A,globalCloseEvents:R,imperativeModeOnly:P,style:K,position:q,afterShow:V,afterHide:M,disableTooltip:se,content:oe,contentWrapperRef:ge,isOpen:me,defaultIsOpen:Oe=!1,setIsOpen:F,activeAnchor:$,setActiveAnchor:J,border:B,opacity:U,arrowColor:k,arrowSize:Q=8,role:Z="tooltip"})=>{var Y;const ee=b.useRef(null),te=b.useRef(null),le=b.useRef(null),L=b.useRef(null),we=b.useRef(null),[W,ot]=b.useState({tooltipStyles:{},tooltipArrowStyles:{},place:a}),[_e,mt]=b.useState(!1),[Je,gt]=b.useState(!1),[Ee,et]=b.useState(null),xt=b.useRef(!1),Vt=b.useRef(null),{anchorRefs:Pt,setActiveAnchor:lt}=gf(t),st=b.useRef(!1),[Me,qe]=b.useState([]),Ft=b.useRef(!1),tt=d||f.includes("click"),Ar=tt||(E==null?void 0:E.click)||(E==null?void 0:E.dblclick)||(E==null?void 0:E.mousedown),pn=E?{...E}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!E&&tt&&Object.assign(pn,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const hn=A?{...A}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!A&&tt&&Object.assign(hn,{mouseleave:!1,blur:!1,mouseout:!1});const yt=R?{...R}:{escape:I||!1,scroll:x||!1,resize:T||!1,clickOutsideAnchor:Ar||!1};P&&(Object.assign(pn,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(hn,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(yt,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),fS(()=>(Ft.current=!0,()=>{Ft.current=!1}),[]);const Te=z=>{Ft.current&&(z&>(!0),setTimeout(()=>{Ft.current&&(F==null||F(z),me===void 0&&mt(z))},10))};b.useEffect(()=>{if(me===void 0)return()=>null;me&>(!0);const z=setTimeout(()=>{mt(me)},10);return()=>{clearTimeout(z)}},[me]),b.useEffect(()=>{if(_e!==xt.current)if(Lt(we),xt.current=_e,_e)V==null||V();else{const z=(ae=>{const ce=ae.match(/^([\d.]+)(ms|s)$/);if(!ce)return 0;const[,Le,He]=ce;return Number(Le)*(He==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));we.current=setTimeout(()=>{gt(!1),et(null),M==null||M()},z+25)}},[_e]);const or=z=>{ot(ae=>ia(ae,z)?ae:z)},Tn=(z=v)=>{Lt(le),Je?Te(!0):le.current=setTimeout(()=>{Te(!0)},z)},An=(z=w)=>{Lt(L),L.current=setTimeout(()=>{st.current||Te(!1)},z)},Ot=z=>{var ae;if(!z)return;const ce=(ae=z.currentTarget)!==null&&ae!==void 0?ae:z.target;if(!(ce!=null&&ce.isConnected))return J(null),void lt({current:null});v?Tn():Te(!0),J(ce),lt({current:ce}),Lt(L)},mn=()=>{y?An(w||100):w?An():Te(!1),Lt(le)},Rn=({x:z,y:ae})=>{var ce;const Le={getBoundingClientRect:()=>({x:z,y:ae,width:0,height:0,top:ae,left:z,right:z,bottom:ae})};vu({place:(ce=Ee==null?void 0:Ee.place)!==null&&ce!==void 0?ce:a,offset:c,elementReference:Le,tooltipReference:ee.current,tooltipArrowReference:te.current,strategy:l,middlewares:m,border:B,arrowSize:Q}).then(He=>{or(He)})},Pn=z=>{if(!z)return;const ae=z,ce={x:ae.clientX,y:ae.clientY};Rn(ce),Vt.current=ce},gn=z=>{var ae;if(!_e)return;const ce=z.target;ce.isConnected&&(!((ae=ee.current)===null||ae===void 0)&&ae.contains(ce)||[document.querySelector(`[id='${i}']`),...Me].some(Le=>Le==null?void 0:Le.contains(ce))||(Te(!1),Lt(le)))},nn=bu(Ot,50),ke=bu(mn,50),at=z=>{ke.cancel(),nn(z)},re=()=>{nn.cancel(),ke()},fe=b.useCallback(()=>{var z,ae;const ce=(z=Ee==null?void 0:Ee.position)!==null&&z!==void 0?z:q;ce?Rn(ce):h?Vt.current&&Rn(Vt.current):$!=null&&$.isConnected&&vu({place:(ae=Ee==null?void 0:Ee.place)!==null&&ae!==void 0?ae:a,offset:c,elementReference:$,tooltipReference:ee.current,tooltipArrowReference:te.current,strategy:l,middlewares:m,border:B,arrowSize:Q}).then(Le=>{Ft.current&&or(Le)})},[_e,$,oe,K,a,Ee==null?void 0:Ee.place,c,l,q,Ee==null?void 0:Ee.position,h,Q]);b.useEffect(()=>{var z,ae;const ce=new Set(Pt);Me.forEach(ve=>{se!=null&&se(ve)||ce.add({current:ve})});const Le=document.querySelector(`[id='${i}']`);Le&&!(se!=null&&se(Le))&&ce.add({current:Le});const He=()=>{Te(!1)},Ge=Cu($),Dt=Cu(ee.current);yt.scroll&&(window.addEventListener("scroll",He),Ge==null||Ge.addEventListener("scroll",He),Dt==null||Dt.addEventListener("scroll",He));let nt=null;yt.resize?window.addEventListener("resize",He):$&&ee.current&&(nt=iS($,ee.current,fe,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const vt=ve=>{ve.key==="Escape"&&Te(!1)};yt.escape&&window.addEventListener("keydown",vt),yt.clickOutsideAnchor&&window.addEventListener("click",gn);const Ne=[],Fn=ve=>!!(ve!=null&&ve.target&&($!=null&&$.contains(ve.target))),Ht=ve=>{_e&&Fn(ve)||Ot(ve)},Zo=ve=>{_e&&Fn(ve)&&mn()},Hi=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],Bi=["click","dblclick","mousedown","mouseup"];Object.entries(pn).forEach(([ve,Bt])=>{Bt&&(Hi.includes(ve)?Ne.push({event:ve,listener:at}):Bi.includes(ve)&&Ne.push({event:ve,listener:Ht}))}),Object.entries(hn).forEach(([ve,Bt])=>{Bt&&(Hi.includes(ve)?Ne.push({event:ve,listener:re}):Bi.includes(ve)&&Ne.push({event:ve,listener:Zo}))}),h&&Ne.push({event:"pointermove",listener:Pn});const Ji=()=>{st.current=!0},Wi=()=>{st.current=!1,mn()},rn=y&&(hn.mouseout||hn.mouseleave);return rn&&((z=ee.current)===null||z===void 0||z.addEventListener("mouseover",Ji),(ae=ee.current)===null||ae===void 0||ae.addEventListener("mouseout",Wi)),Ne.forEach(({event:ve,listener:Bt})=>{ce.forEach(pi=>{var sr;(sr=pi.current)===null||sr===void 0||sr.addEventListener(ve,Bt)})}),()=>{var ve,Bt;yt.scroll&&(window.removeEventListener("scroll",He),Ge==null||Ge.removeEventListener("scroll",He),Dt==null||Dt.removeEventListener("scroll",He)),yt.resize?window.removeEventListener("resize",He):nt==null||nt(),yt.clickOutsideAnchor&&window.removeEventListener("click",gn),yt.escape&&window.removeEventListener("keydown",vt),rn&&((ve=ee.current)===null||ve===void 0||ve.removeEventListener("mouseover",Ji),(Bt=ee.current)===null||Bt===void 0||Bt.removeEventListener("mouseout",Wi)),Ne.forEach(({event:pi,listener:sr})=>{ce.forEach(es=>{var Dn;(Dn=es.current)===null||Dn===void 0||Dn.removeEventListener(pi,sr)})})}},[$,fe,Je,Pt,Me,E,A,R,tt,v,w]),b.useEffect(()=>{var z,ae;let ce=(ae=(z=Ee==null?void 0:Ee.anchorSelect)!==null&&z!==void 0?z:s)!==null&&ae!==void 0?ae:"";!ce&&t&&(ce=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const Le=new MutationObserver(He=>{const Ge=[],Dt=[];He.forEach(nt=>{if(nt.type==="attributes"&&nt.attributeName==="data-tooltip-id"&&(nt.target.getAttribute("data-tooltip-id")===t?Ge.push(nt.target):nt.oldValue===t&&Dt.push(nt.target)),nt.type==="childList"){if($){const vt=[...nt.removedNodes].filter(Ne=>Ne.nodeType===1);if(ce)try{Dt.push(...vt.filter(Ne=>Ne.matches(ce))),Dt.push(...vt.flatMap(Ne=>[...Ne.querySelectorAll(ce)]))}catch{}vt.some(Ne=>{var Fn;return!!(!((Fn=Ne==null?void 0:Ne.contains)===null||Fn===void 0)&&Fn.call(Ne,$))&&(gt(!1),Te(!1),J(null),Lt(le),Lt(L),!0)})}if(ce)try{const vt=[...nt.addedNodes].filter(Ne=>Ne.nodeType===1);Ge.push(...vt.filter(Ne=>Ne.matches(ce))),Ge.push(...vt.flatMap(Ne=>[...Ne.querySelectorAll(ce)]))}catch{}}}),(Ge.length||Dt.length)&&qe(nt=>[...nt.filter(vt=>!Dt.includes(vt)),...Ge])});return Le.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{Le.disconnect()}},[t,s,Ee==null?void 0:Ee.anchorSelect,$]),b.useEffect(()=>{fe()},[fe]),b.useEffect(()=>{if(!(ge!=null&&ge.current))return()=>null;const z=new ResizeObserver(()=>{setTimeout(()=>fe())});return z.observe(ge.current),()=>{z.disconnect()}},[oe,ge==null?void 0:ge.current]),b.useEffect(()=>{var z;const ae=document.querySelector(`[id='${i}']`),ce=[...Me,ae];$&&ce.includes($)||J((z=Me[0])!==null&&z!==void 0?z:ae)},[i,Me,$]),b.useEffect(()=>(Oe&&Te(!0),()=>{Lt(le),Lt(L)}),[]),b.useEffect(()=>{var z;let ae=(z=Ee==null?void 0:Ee.anchorSelect)!==null&&z!==void 0?z:s;if(!ae&&t&&(ae=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),ae)try{const ce=Array.from(document.querySelectorAll(ae));qe(ce)}catch{qe([])}},[t,s,Ee==null?void 0:Ee.anchorSelect]),b.useEffect(()=>{le.current&&(Lt(le),Tn(v))},[v]);const dt=(Y=Ee==null?void 0:Ee.content)!==null&&Y!==void 0?Y:oe,yn=_e&&Object.keys(W.tooltipStyles).length>0;return b.useImperativeHandle(e,()=>({open:z=>{if(z!=null&&z.anchorSelect)try{document.querySelector(z.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${z.anchorSelect}" is not a valid CSS selector`)}et(z??null),z!=null&&z.delay?Tn(z.delay):Te(!0)},close:z=>{z!=null&&z.delay?An(z.delay):Te(!1)},activeAnchor:$,place:W.place,isOpen:!!(Je&&!S&&dt&&yn)})),Je&&!S&&dt?b.createElement(g,{id:t,role:Z,className:Ut("react-tooltip",Pr.tooltip,bs.tooltip,bs[o],n,`react-tooltip__place-${W.place}`,Pr[yn?"show":"closing"],yn?"react-tooltip__show":"react-tooltip__closing",l==="fixed"&&Pr.fixed,y&&Pr.clickable),onTransitionEnd:z=>{Lt(we),_e||z.propertyName!=="opacity"||(gt(!1),et(null),M==null||M())},style:{...K,...W.tooltipStyles,opacity:U!==void 0&&yn?U:void 0},ref:ee},dt,b.createElement(g,{className:Ut("react-tooltip-arrow",Pr.arrow,bs.arrow,r,p&&Pr.noArrow),style:{...W.tooltipArrowStyles,background:k?`linear-gradient(to right bottom, transparent 50%, ${k} 50%)`:void 0,"--rt-arrow-size":`${Q}px`},ref:te})):null},yS=({content:e})=>b.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),vS=b.forwardRef(({id:e,anchorId:t,anchorSelect:n,content:r,html:o,render:i,className:s,classNameArrow:a,variant:c="dark",place:f="top",offset:d=10,wrapper:l="div",children:m=null,events:g=["hover"],openOnClick:v=!1,positionStrategy:w="absolute",middlewares:h,delayShow:S=0,delayHide:p=0,float:y=!1,hidden:I=!1,noArrow:x=!1,clickable:T=!1,closeOnEsc:E=!1,closeOnScroll:A=!1,closeOnResize:R=!1,openEvents:P,closeEvents:K,globalCloseEvents:q,imperativeModeOnly:V=!1,style:M,position:se,isOpen:oe,defaultIsOpen:ge=!1,disableStyleInjection:me=!1,border:Oe,opacity:F,arrowColor:$,arrowSize:J,setIsOpen:B,afterShow:U,afterHide:k,disableTooltip:Q,role:Z="tooltip"},Y)=>{const[ee,te]=b.useState(r),[le,L]=b.useState(o),[we,W]=b.useState(f),[ot,_e]=b.useState(c),[mt,Je]=b.useState(d),[gt,Ee]=b.useState(S),[et,xt]=b.useState(p),[Vt,Pt]=b.useState(y),[lt,st]=b.useState(I),[Me,qe]=b.useState(l),[Ft,tt]=b.useState(g),[Ar,pn]=b.useState(w),[hn,yt]=b.useState(null),[Te,or]=b.useState(null),Tn=b.useRef(me),{anchorRefs:An,activeAnchor:Ot}=gf(e),mn=ke=>ke==null?void 0:ke.getAttributeNames().reduce((at,re)=>{var fe;return re.startsWith("data-tooltip-")&&(at[re.replace(/^data-tooltip-/,"")]=(fe=ke==null?void 0:ke.getAttribute(re))!==null&&fe!==void 0?fe:null),at},{}),Rn=ke=>{const at={place:re=>{var fe;W((fe=re)!==null&&fe!==void 0?fe:f)},content:re=>{te(re??r)},html:re=>{L(re??o)},variant:re=>{var fe;_e((fe=re)!==null&&fe!==void 0?fe:c)},offset:re=>{Je(re===null?d:Number(re))},wrapper:re=>{var fe;qe((fe=re)!==null&&fe!==void 0?fe:l)},events:re=>{const fe=re==null?void 0:re.split(" ");tt(fe??g)},"position-strategy":re=>{var fe;pn((fe=re)!==null&&fe!==void 0?fe:w)},"delay-show":re=>{Ee(re===null?S:Number(re))},"delay-hide":re=>{xt(re===null?p:Number(re))},float:re=>{Pt(re===null?y:re==="true")},hidden:re=>{st(re===null?I:re==="true")},"class-name":re=>{yt(re)}};Object.values(at).forEach(re=>re(null)),Object.entries(ke).forEach(([re,fe])=>{var dt;(dt=at[re])===null||dt===void 0||dt.call(at,fe)})};b.useEffect(()=>{te(r)},[r]),b.useEffect(()=>{L(o)},[o]),b.useEffect(()=>{W(f)},[f]),b.useEffect(()=>{_e(c)},[c]),b.useEffect(()=>{Je(d)},[d]),b.useEffect(()=>{Ee(S)},[S]),b.useEffect(()=>{xt(p)},[p]),b.useEffect(()=>{Pt(y)},[y]),b.useEffect(()=>{st(I)},[I]),b.useEffect(()=>{pn(w)},[w]),b.useEffect(()=>{Tn.current!==me&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")},[me]),b.useEffect(()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:me==="core",disableBase:me}}))},[]),b.useEffect(()=>{var ke;const at=new Set(An);let re=n;if(!re&&e&&(re=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),re)try{document.querySelectorAll(re).forEach(ae=>{at.add({current:ae})})}catch{console.warn(`[react-tooltip] "${re}" is not a valid CSS selector`)}const fe=document.querySelector(`[id='${t}']`);if(fe&&at.add({current:fe}),!at.size)return()=>null;const dt=(ke=Te??fe)!==null&&ke!==void 0?ke:Ot.current,yn=new MutationObserver(ae=>{ae.forEach(ce=>{var Le;if(!dt||ce.type!=="attributes"||!(!((Le=ce.attributeName)===null||Le===void 0)&&Le.startsWith("data-tooltip-")))return;const He=mn(dt);Rn(He)})}),z={attributes:!0,childList:!1,subtree:!1};if(dt){const ae=mn(dt);Rn(ae),yn.observe(dt,z)}return()=>{yn.disconnect()}},[An,Ot,Te,t,n]),b.useEffect(()=>{M!=null&&M.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),Oe&&!wu("border",`${Oe}`)&&console.warn(`[react-tooltip] "${Oe}" is not a valid \`border\`.`),M!=null&&M.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),F&&!wu("opacity",`${F}`)&&console.warn(`[react-tooltip] "${F}" is not a valid \`opacity\`.`)},[]);let Pn=m;const gn=b.useRef(null);if(i){const ke=i({content:(Te==null?void 0:Te.getAttribute("data-tooltip-content"))||ee||null,activeAnchor:Te});Pn=ke?b.createElement("div",{ref:gn,className:"react-tooltip-content-wrapper"},ke):null}else ee&&(Pn=ee);le&&(Pn=b.createElement(yS,{content:le}));const nn={forwardRef:Y,id:e,anchorId:t,anchorSelect:n,className:Ut(s,hn),classNameArrow:a,content:Pn,contentWrapperRef:gn,place:we,variant:ot,offset:mt,wrapper:Me,events:Ft,openOnClick:v,positionStrategy:Ar,middlewares:h,delayShow:gt,delayHide:et,float:Vt,hidden:lt,noArrow:x,clickable:T,closeOnEsc:E,closeOnScroll:A,closeOnResize:R,openEvents:P,closeEvents:K,globalCloseEvents:q,imperativeModeOnly:V,style:M,position:se,isOpen:oe,defaultIsOpen:ge,border:Oe,opacity:F,arrowColor:$,arrowSize:J,setIsOpen:B,afterShow:U,afterHide:k,disableTooltip:Q,activeAnchor:Te,setActiveAnchor:ke=>or(ke),role:Z};return b.createElement(gS,{...nn})});typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",e=>{e.detail.disableCore||yu({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;--rt-arrow-size:8px}.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;z-index:-1}.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||yu({css:`
|
|
51
|
+
.styles-module_tooltip__mnnfp{padding:8px 16px;border-radius:3px;font-size:90%;width:max-content}.styles-module_arrow__K0L3T{width:var(--rt-arrow-size);height:var(--rt-arrow-size)}[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 wS(){return u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:[u.jsxs("g",{clipPath:"url(#clip0_2896_16290)",children:[u.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"}),u.jsx("path",{d:"M8.00293 5.83301L7.99768 5.83301",stroke:"#6B7280",strokeLinecap:"round",strokeLinejoin:"round"})]}),u.jsx("defs",{children:u.jsx("clipPath",{id:"clip0_2896_16290",children:u.jsx("rect",{width:"16",height:"16",fill:"white",transform:"translate(16 16.5) rotate(180)"})})})]})}function yf({id:e,tooltipText:t}){return u.jsxs(u.Fragment,{children:[u.jsx("span",{"data-tooltip-id":e,style:{maxWidth:"20rem"},children:wS()}),u.jsx(vS,{id:e,place:"top",content:t,style:{maxWidth:"30rem"}})]})}function bS(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=!td(o,n);e.read.isRequiredMapFieldsModified=s}}function Ai(e,t,n){t(e,r=>bS(r,n))}const IS="Each field must be mapped to a unique value";function Qa({field:e,onSelectChange:t,allFields:n}){var p;const{configureState:r,selectedObjectName:o,setConfigureState:i}=tn(),[s,a]=b.useState(!0),{isError:c,removeError:f,getError:d}=qt(),l=(p=r==null?void 0:r.read)==null?void 0:p.selectedFieldMappings,m=l==null?void 0:l[e.mapToName];b.useEffect(()=>{e._default&&!m&&o&&r&&Ai(o,i,[{field:e.mapToName,value:e._default}]),a(!1)},[e,i,o,m,r]);const g=b.useMemo(()=>n.map(y=>({id:y.fieldName,label:y.displayName,value:y.fieldName})),[n]),v=u.jsx(sf,{disabled:s,items:g,selectedValue:m||null,onSelectedItemChange:y=>{t({target:{name:e.mapToName,value:y==null?void 0:y.value}})},placeholder:"Please select one",style:{width:"100%"}}),w=b.useCallback(()=>{o&&(Ai(o,i,[{field:e.mapToName,value:null}]),c(ue.MAPPING,o)&&f(ue.MAPPING,o))},[e.mapToName,o,i,c,f]),{hasDuplicationError:h,errorMessage:S}=b.useMemo(()=>{const y=d(ue.MAPPING,o),I=Array.isArray(y)&&y.length>0&&y.includes(e.mapToName);return{hasDuplicationError:I,errorMessage:I?IS:""}},[o,d,e.mapToName]);return u.jsxs(u.Fragment,{children:[u.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[u.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem",marginBottom:".25rem"},children:[u.jsx("span",{style:{fontWeight:500},children:e.mapToDisplayName??e.mapToName}),u.jsx("span",{children:(e==null?void 0:e.prompt)&&u.jsx(yf,{id:`tooltip-id-${e==null?void 0:e.prompt}`,tooltipText:e==null?void 0:e.prompt})})]}),u.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[v,u.jsx(Be,{type:"button",variant:"ghost",onClick:w,children:"Clear"})]})]},e.mapToName),h&&u.jsxs("span",{style:{color:"red",fontSize:"14px",marginTop:"4px"},children:[" ",S," "]},e.mapToName)]})}const CS="_formControl_9qd8d_1",SS="_formLabel_9qd8d_5",xS="_formLabelRequired_9qd8d_11",OS="_formInput_9qd8d_16",ES="_formInputInvalid_9qd8d_20",_S="_formError_9qd8d_24",NS="_disabled_9qd8d_30",ur={formControl:CS,formLabel:SS,formLabelRequired:xS,formInput:OS,formInputInvalid:ES,formError:_S,disabled:NS};function Go({id:e,label:t,isRequired:n=!1,isDisabled:r=!1,isInvalid:o=!1,errorMessage:i,children:s}){return u.jsxs("div",{className:Ut(ur.formControl,{[ur.disabled]:r}),children:[t&&u.jsx("label",{htmlFor:e,className:Ut(ur.formLabel,{[ur.formLabelRequired]:n}),children:t}),u.jsx("div",{id:e,className:Ut(ur.formInput,{[ur.formInputInvalid]:o}),children:s}),o&&i&&u.jsx("div",{className:ur.formError,role:"alert",children:i})]})}function vf({selectedFieldMappings:e,selectedObjectName:t,fieldName:n,fieldValue:r,setError:o}){if(!e||!t)return!1;if(Object.values(e).some(s=>s===r&&s!==n)){console.error("Each field must be mapped to a unique value",e);const s=Object.keys(e).filter(c=>e[c]===r),a=[n,...s];return o(ue.MAPPING,t,a),!0}return!1}function TS({dynamicFieldMappings:e,onSelectChange:t,allFields:n}){return e.length?u.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:e.map(r=>u.jsx(Go,{id:r.mapToName,children:u.jsx(Qa,{allFields:n,field:r,onSelectChange:t})},r.mapToName))}):null}function AS(){var v,w;const{selectedObjectName:e,configureState:t,setConfigureState:n}=tn(),{isError:r,removeError:o,setError:i}=qt(),s=((v=t==null?void 0:t.read)==null?void 0:v.allFields)||[],{fieldMapping:a}=Ze(),c=(w=t==null?void 0:t.read)==null?void 0:w.selectedFieldMappings,f=h=>{const{value:S,name:p}=h.target;!S||vf({selectedFieldMappings:c,selectedObjectName:e,fieldName:p,fieldValue:S,setError:i})||(e&&Ai(e,n,[{field:p,value:S}]),r(ue.MAPPING,p)&&o(ue.MAPPING,p),e&&r(ue.MAPPING,e)&&o(ue.MAPPING,e))},d=b.useMemo(()=>!e||!a?[]:Object.values(a[e]||{}).flat().filter(h=>!h.fieldName),[a,e]),l=b.useMemo(()=>{var p;return(((p=t==null?void 0:t.read)==null?void 0:p.optionalMapFields)||[]).filter(y=>!d.some(I=>I.mapToName===y.mapToName))},[t,d]),m=d.length>0;return l.length>0||m?u.jsxs(u.Fragment,{children:[u.jsx(Rt,{string:"Map the following optional fields"}),u.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:[l==null?void 0:l.map(h=>u.jsx(Go,{id:h.mapToName,children:u.jsx(Qa,{allFields:s,field:h,onSelectChange:f})},h.mapToName)),m&&u.jsx(TS,{dynamicFieldMappings:d,onSelectChange:f,allFields:s})]})]}):null}function RS(){var f;const{selectedObjectName:e,configureState:t,setConfigureState:n}=tn(),{isError:r,removeError:o,setError:i}=qt(),s=(f=t==null?void 0:t.read)==null?void 0:f.selectedFieldMappings,a=d=>{const{value:l,name:m}=d.target;!l||vf({selectedFieldMappings:s,selectedObjectName:e,fieldName:m,fieldValue:l,setError:i})||(e&&Ai(e,n,[{field:m,value:l}]),r(ue.MAPPING,m)&&o(ue.MAPPING,m),e&&r(ue.MAPPING,e)&&o(ue.MAPPING,e))},c=b.useMemo(()=>{var d;return((d=t==null?void 0:t.read)==null?void 0:d.requiredMapFields)||[]},[t]);return c!=null&&c.length?u.jsxs(u.Fragment,{children:[u.jsx(Rt,{string:"Map the following fields"}),u.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:c.map(d=>{var l;return u.jsx(Go,{id:d.mapToName,isInvalid:r(ue.MAPPING,d.mapToName),errorMessage:"* required",children:u.jsx(Qa,{allFields:((l=t==null?void 0:t.read)==null?void 0:l.allFields)||[],field:d,onSelectChange:a})},d.mapToName)})})]}):null}const PS=(e,t)=>e.filter(n=>!t.has(n));function FS(){var m,g,v;const{selectedObjectName:e,configureState:t,setConfigureState:n}=tn(),{fieldMapping:r}=Ze(),o=((m=t==null?void 0:t.read)==null?void 0:m.selectedFieldMappings)||{},i=Object.keys(o),s=((g=t==null?void 0:t.read)==null?void 0:g.requiredMapFields)||[],a=((v=t==null?void 0:t.read)==null?void 0:v.optionalMapFields)||[],c=e&&r?Object.values(r[e]||{}).flat().filter(w=>!w.fieldName):[],f=s.concat(c,a).map(w=>w.mapToName),d=new Set(f),l=PS(i,d);b.useEffect(()=>{e&&l.length&&Ai(e,n,l.map(w=>({field:w,value:null})))},[e,n,l])}const DS={backgroundColor:"var(--amp-colors-bg-highlight)",borderColor:"var(--amp-colors-bg-highlight)",padding:".5rem 1rem"};function MS({children:e,style:t}){return u.jsx(_n,{style:{...DS,...t},children:e})}function kS(){var f,d,l;const{data:e}=tr(),{hydratedRevision:t}=di(),{selectedObjectName:n}=tn(),{providerName:r}=ut(),o=e==null?void 0:e.appName,i=(l=(d=(f=t==null?void 0:t.content)==null?void 0:f.read)==null?void 0:d.objects)==null?void 0:l.find(m=>m.objectName===n),s=(i==null?void 0:i.displayName)||n&&un(n),a=i==null?void 0:i.mapToName,c=(i==null?void 0:i.mapToDisplayName)||a&&un(a);return c&&o&&r?u.jsx(MS,{style:{marginTop:"1rem"},children:u.jsxs("p",{style:{margin:"1rem 0"},children:[u.jsx("b",{children:c})," in ",o," is mapped to"," ",u.jsx("b",{children:s})," in ",r,"."]})}):null}function Su(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function wf(...e){return t=>{let n=!1;const r=e.map(o=>{const i=Su(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():Su(e[o],null)}}}}function oi(...e){return j.useCallback(wf(...e),e)}function Qo(e,t=[]){let n=[];function r(i,s){const a=j.createContext(s),c=n.length;n=[...n,s];const f=l=>{var S;const{scope:m,children:g,...v}=l,w=((S=m==null?void 0:m[e])==null?void 0:S[c])||a,h=j.useMemo(()=>v,Object.values(v));return u.jsx(w.Provider,{value:h,children:g})};f.displayName=i+"Provider";function d(l,m){var w;const g=((w=m==null?void 0:m[e])==null?void 0:w[c])||a,v=j.useContext(g);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${l}\` must be used within \`${i}\``)}return[f,d]}const o=()=>{const i=n.map(s=>j.createContext(s));return function(a){const c=(a==null?void 0:a[e])||i;return j.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,LS(o,...t)]}function LS(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:c,scopeName:f})=>{const l=c(i)[`__scope${f}`];return{...a,...l}},{});return j.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Xt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}var Ri=globalThis!=null&&globalThis.document?j.useLayoutEffect:()=>{},jS=j[" useInsertionEffect ".trim().toString()]||Ri;function Xa({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,s]=KS({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const d=j.useRef(e!==void 0);j.useEffect(()=>{const l=d.current;l!==a&&console.warn(`${r} is changing from ${l?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const f=j.useCallback(d=>{var l;if(a){const m=$S(d)?d(e):d;m!==e&&((l=s.current)==null||l.call(s,m))}else i(d)},[a,e,i,s]);return[c,f]}function KS({defaultProp:e,onChange:t}){const[n,r]=j.useState(e),o=j.useRef(n),i=j.useRef(t);return jS(()=>{i.current=t},[t]),j.useEffect(()=>{var s;o.current!==n&&((s=i.current)==null||s.call(i,n),o.current=n)},[n,o]),[n,r,i]}function $S(e){return typeof e=="function"}function US(e){const t=j.useRef({value:e,previous:e});return j.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function qS(e){const[t,n]=j.useState(void 0);return Ri(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const c=i.borderBoxSize,f=Array.isArray(c)?c[0]:c;s=f.inlineSize,a=f.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}function VS(e,t){return j.useReducer((n,r)=>t[n][r]??n,e)}var Ya=e=>{const{present:t,children:n}=e,r=HS(t),o=typeof n=="function"?n({present:r.isPresent}):j.Children.only(n),i=oi(r.ref,BS(o));return typeof n=="function"||r.isPresent?j.cloneElement(o,{ref:i}):null};Ya.displayName="Presence";function HS(e){const[t,n]=j.useState(),r=j.useRef(null),o=j.useRef(e),i=j.useRef("none"),s=e?"mounted":"unmounted",[a,c]=VS(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return j.useEffect(()=>{const f=uo(r.current);i.current=a==="mounted"?f:"none"},[a]),Ri(()=>{const f=r.current,d=o.current;if(d!==e){const m=i.current,g=uo(f);e?c("MOUNT"):g==="none"||(f==null?void 0:f.display)==="none"?c("UNMOUNT"):c(d&&m!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),Ri(()=>{if(t){let f;const d=t.ownerDocument.defaultView??window,l=g=>{const w=uo(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&w&&(c("ANIMATION_END"),!o.current)){const h=t.style.animationFillMode;t.style.animationFillMode="forwards",f=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=h)})}},m=g=>{g.target===t&&(i.current=uo(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",l),t.addEventListener("animationend",l),()=>{d.clearTimeout(f),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",l),t.removeEventListener("animationend",l)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:j.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function uo(e){return(e==null?void 0:e.animationName)||"none"}function BS(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function oa(e){const t=JS(e),n=j.forwardRef((r,o)=>{const{children:i,...s}=r,a=j.Children.toArray(i),c=a.find(zS);if(c){const f=c.props.children,d=a.map(l=>l===c?j.Children.count(f)>1?j.Children.only(null):j.isValidElement(f)?f.props.children:null:l);return u.jsx(t,{...s,ref:o,children:j.isValidElement(f)?j.cloneElement(f,void 0,d):null})}return u.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function JS(e){const t=j.forwardRef((n,r)=>{const{children:o,...i}=n;if(j.isValidElement(o)){const s=QS(o),a=GS(i,o.props);return o.type!==j.Fragment&&(a.ref=r?wf(r,s):s),j.cloneElement(o,a)}return j.Children.count(o)>1?j.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var WS=Symbol("radix.slottable");function zS(e){return j.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===WS}function GS(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function QS(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 XS=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Nn=XS.reduce((e,t)=>{const n=oa(`Primitive.${t}`),r=j.forwardRef((o,i)=>{const{asChild:s,...a}=o,c=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(c,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Xo="Checkbox",[YS,gO]=Qo(Xo),[ZS,Za]=YS(Xo);function ex(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:o,disabled:i,form:s,name:a,onCheckedChange:c,required:f,value:d="on",internal_do_not_use_render:l}=e,[m,g]=Xa({prop:n,defaultProp:o??!1,onChange:c,caller:Xo}),[v,w]=j.useState(null),[h,S]=j.useState(null),p=j.useRef(!1),y=v?!!s||!!v.closest("form"):!0,I={checked:m,disabled:i,setChecked:g,control:v,setControl:w,name:a,form:s,value:d,hasConsumerStoppedPropagationRef:p,required:f,defaultChecked:Qn(o)?!1:o,isFormControl:y,bubbleInput:h,setBubbleInput:S};return u.jsx(ZS,{scope:t,...I,children:tx(l)?l(I):r})}var bf="CheckboxTrigger",If=j.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},o)=>{const{control:i,value:s,disabled:a,checked:c,required:f,setControl:d,setChecked:l,hasConsumerStoppedPropagationRef:m,isFormControl:g,bubbleInput:v}=Za(bf,e),w=oi(o,d),h=j.useRef(c);return j.useEffect(()=>{const S=i==null?void 0:i.form;if(S){const p=()=>l(h.current);return S.addEventListener("reset",p),()=>S.removeEventListener("reset",p)}},[i,l]),u.jsx(Nn.button,{type:"button",role:"checkbox","aria-checked":Qn(c)?"mixed":c,"aria-required":f,"data-state":Of(c),"data-disabled":a?"":void 0,disabled:a,value:s,...r,ref:w,onKeyDown:Xt(t,S=>{S.key==="Enter"&&S.preventDefault()}),onClick:Xt(n,S=>{l(p=>Qn(p)?!0:!p),v&&g&&(m.current=S.isPropagationStopped(),m.current||S.stopPropagation())})})});If.displayName=bf;var ec=j.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:c,onCheckedChange:f,form:d,...l}=e;return u.jsx(ex,{__scopeCheckbox:n,checked:o,defaultChecked:i,disabled:a,required:s,onCheckedChange:f,name:r,form:d,value:c,internal_do_not_use_render:({isFormControl:m})=>u.jsxs(u.Fragment,{children:[u.jsx(If,{...l,ref:t,__scopeCheckbox:n}),m&&u.jsx(xf,{__scopeCheckbox:n})]})})});ec.displayName=Xo;var Cf="CheckboxIndicator",tc=j.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=Za(Cf,n);return u.jsx(Ya,{present:r||Qn(i.checked)||i.checked===!0,children:u.jsx(Nn.span,{"data-state":Of(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});tc.displayName=Cf;var Sf="CheckboxBubbleInput",xf=j.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:o,checked:i,defaultChecked:s,required:a,disabled:c,name:f,value:d,form:l,bubbleInput:m,setBubbleInput:g}=Za(Sf,e),v=oi(n,g),w=US(i),h=qS(r);j.useEffect(()=>{const p=m;if(!p)return;const y=window.HTMLInputElement.prototype,x=Object.getOwnPropertyDescriptor(y,"checked").set,T=!o.current;if(w!==i&&x){const E=new Event("click",{bubbles:T});p.indeterminate=Qn(i),x.call(p,Qn(i)?!1:i),p.dispatchEvent(E)}},[m,w,i,o]);const S=j.useRef(Qn(i)?!1:i);return u.jsx(Nn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??S.current,required:a,disabled:c,name:f,value:d,form:l,...t,tabIndex:-1,ref:v,style:{...t.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});xf.displayName=Sf;function tx(e){return typeof e=="function"}function Qn(e){return e==="indeterminate"}function Of(e){return Qn(e)?"indeterminate":e?"checked":"unchecked"}function Ef(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 nx=["color"],_f=b.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=Ef(e,nx);return b.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}),b.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"}))}),rx=["color"],ix=b.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=Ef(e,rx);return b.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}),b.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 ox="_checkboxGroupContainer_hqfeu_1",sx="_stack_hqfeu_6",ax="_selectAllContainer_hqfeu_10",cx="_fieldContainer_hqfeu_17",ux="_checkbox_hqfeu_1",si={checkboxGroupContainer:ox,stack:sx,selectAllContainer:ax,fieldContainer:cx,checkbox:ux};function lx({id:e,isChecked:t,label:n,onCheckedChange:r}){return u.jsxs("div",{className:si.fieldContainer,children:[u.jsx(ec,{className:si.checkbox,id:e,onCheckedChange:r,checked:t,children:u.jsx(tc,{children:u.jsx(_f,{})})}),u.jsx("label",{htmlFor:e,style:{overflowWrap:"anywhere"},children:n})]})}function dx({id:e,isChecked:t,label:n,onCheckedChange:r,isIndeterminate:o}){return u.jsxs("div",{className:si.selectAllContainer,children:[u.jsx(ec,{className:si.checkbox,id:e,onCheckedChange:r,checked:o?"indeterminate":t,children:u.jsxs(tc,{children:[o&&u.jsx(ix,{}),t===!0&&u.jsx(_f,{})]})}),u.jsx("label",{htmlFor:e,children:n})]})}function fx({children:e}){return u.jsx("div",{className:si.checkboxGroupContainer,children:e})}function px({children:e}){return u.jsx("div",{className:si.stack,children:e})}const hx="_paginationContainer_1p51x_1",mx="_pageInfo_1p51x_7",gx="_searchContainer_1p51x_13",yx="_searchInput_1p51x_17",vx="_noResults_1p51x_21",vi={paginationContainer:hx,pageInfo:mx,searchContainer:gx,searchInput:yx,noResults:vx};function Nf({items:e,onItemChange:t,itemsPerPage:n=8,showSelectAll:r=!0,showSearch:o=!0,searchPlaceholder:i="Search fields..."}){const[s,a]=b.useState(1),[c,f]=b.useState(""),d=e.filter(y=>y.label.toLowerCase().includes(c.toLowerCase())),l=Math.ceil(d.length/n),m=(s-1)*n,g=m+n,v=d.slice(m,g),w=y=>{f(y),a(1)},h=y=>{d.forEach(I=>{t(I.id,y)})},S=d.length>0&&d.every(y=>y.isChecked),p=d.some(y=>y.isChecked);return u.jsxs(fx,{children:[o&&u.jsx("div",{className:vi.searchContainer,children:u.jsx(ld,{id:"field-search",type:"text",placeholder:i,value:c,onChange:y=>w(y.target.value),className:vi.searchInput})}),r&&e.length>=2&&u.jsx(dx,{id:"select-all-fields",isChecked:S,label:`Select all ${d.length} ${c?"matching ":""}fields`,onCheckedChange:h,isIndeterminate:p&&!S}),u.jsx(px,{children:v.map(y=>u.jsx(lx,{id:y.id,isChecked:y.isChecked,label:y.label,onCheckedChange:I=>t(y.id,I===!0)},y.id))}),l>1&&u.jsxs("div",{className:vi.paginationContainer,children:[u.jsx(Be,{type:"button",onClick:()=>a(y=>Math.max(1,y-1)),disabled:s===1,variant:"ghost",children:"<"}),u.jsxs("span",{className:vi.pageInfo,children:[s," of ",l]}),u.jsx(Be,{type:"button",onClick:()=>a(y=>Math.min(l,y+1)),disabled:s===l,variant:"ghost",children:">"})]}),d.length===0&&c&&u.jsxs("div",{className:vi.noResults,children:['No fields found matching "',c,'"']})]})}function wx(e,t,n){var o,i;const r=((o=e==null?void 0:e.read)==null?void 0:o.selectedOptionalFields)||{};if(r[t]=n,n||delete r[t],(i=e.read)!=null&&i.savedConfig.optionalFields){const s=e.read.savedConfig.optionalFields,c=!td(s,r);e.read.isOptionalFieldsModified=c}else console.warn("read.savedConfig.optionalFields is undefined")}function bx(e,t,n,r){t(e,o=>wx(o,n,r))}function Ix(){var f,d;const{appName:e,configureState:t,setConfigureState:n,selectedObjectName:r}=tn(),o=(f=t==null?void 0:t.read)==null?void 0:f.selectedOptionalFields,i=(d=t==null?void 0:t.read)==null?void 0:d.optionalFields,s=(l,m)=>{r&&t&&bx(r,n,l,m)},a=b.useMemo(()=>(i==null?void 0:i.filter(l=>!nr(l)&&"fieldName"in l&&"displayName"in l).map(l=>({id:l.fieldName,label:l.displayName,isChecked:!!(o!=null&&o[l.fieldName])})).sort((l,m)=>l.label.localeCompare(m.label)))||[],[i,o]);return!!(i&&i.length>0)&&u.jsxs(u.Fragment,{children:[u.jsx(Rt,{string:`${e} reads the following optional fields`}),u.jsx(Nf,{items:a,onItemChange:s,showSelectAll:a.length>=2},`${r}-${i==null?void 0:i.length}`)]})}function Cx(){return u.jsx(Ix,{})}const Sx={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 xx({children:e,style:t,...n}){return u.jsx("span",{style:{...Sx,...t},...n,children:e})}function Ox(){var n,r,o;const{configureState:e}=tn(),{appName:t}=tr();return u.jsxs(u.Fragment,{children:[u.jsx(Rt,{string:`${t} reads the following fields`}),u.jsx("div",{style:{display:"flex",gap:".5rem",marginBottom:".5rem",flexWrap:"wrap"},children:(r=(n=e==null?void 0:e.read)==null?void 0:n.requiredFields)!=null&&r.length?(o=e.read)==null?void 0:o.requiredFields.map(i=>nr(i)?null:u.jsx(xx,{children:i.displayName},i.fieldName)):"There are no required fields."})]})}function Ex(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 Tf(e,t,n,r,o){t(e,i=>Ex(i,e,n,r,o))}function _x(e,t,n){t(e,r=>{r.read&&(r.read.isValueMappingsModified=n)})}function Nx({string:e,fieldName:t}){return u.jsxs("div",{style:{display:"flex",position:"relative",paddingTop:"1rem",paddingBottom:".5rem"},children:[u.jsxs("h3",{style:{color:"var(--amp-colors-text-muted)",fontSize:"1rem",fontWeight:"400"},children:[e,u.jsx("b",{children:t})]}),u.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center"},children:u.jsx(Ho,{style:{width:"100%",marginLeft:"1rem"}})})]})}function Tx({mappedValue:e,onSelectChange:t,fieldName:n,allValueOptions:r,hasError:o}){var x;const{configureState:i,selectedObjectName:s,setConfigureState:a}=tn(),[c,f]=b.useState(!0),{getError:d,setError:l,resetBoundary:m,isError:g,removeError:v}=qt(),w=b.useMemo(()=>{var T,E;return((E=(T=i==null?void 0:i.read)==null?void 0:T.selectedValueMappings)==null?void 0:E[n])||{}},[(x=i==null?void 0:i.read)==null?void 0:x.selectedValueMappings,n]),h=b.useMemo(()=>w==null?void 0:w[e.mappedValue],[w,e.mappedValue]);b.useEffect(()=>{f(!1)},[e,a,s,h,i]);const S=b.useMemo(()=>r.map(T=>({id:T.value,label:T.displayValue,value:T.value})),[r]),p=b.useCallback(T=>{if(T){if(Object.values(w).some(E=>E===T.value&&E!==h)){const E=[...Object.entries(w).filter(([A,R])=>R===T.value&&R!==h).map(([A])=>A),e.mappedValue];l(ue.VALUE_MAPPING,n,E);return}d(ue.VALUE_MAPPING,n)&&m(ue.VALUE_MAPPING),t({target:{name:e.mappedValue,value:T.value,fieldName:n}})}},[t,w,h,n,e.mappedValue,m,l,d]),y=b.useMemo(()=>u.jsx(sf,{disabled:c,items:S,selectedValue:h||null,onSelectedItemChange:p,placeholder:"Please select one",style:{border:o?"2px solid red":void 0,borderRadius:"8px",width:"100%"}},h),[h,c,S,p,o]),I=b.useCallback(()=>{s&&(Tf(s,a,e.mappedValue,"",n),g(ue.VALUE_MAPPING,n)&&v(ue.VALUE_MAPPING,n))},[s,a,e.mappedValue,n,g,v]);return u.jsxs("div",{style:{display:"flex",flexDirection:"column",marginBottom:".25rem"},children:[u.jsx("div",{style:{display:"flex",flexDirection:"row",gap:".25rem",marginBottom:".25rem"},children:u.jsx("span",{style:{fontWeight:500},children:e.mappedDisplayValue})}),u.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:".25rem"},children:[y,u.jsx(Be,{type:"button",variant:"ghost",onClick:I,children:"Clear"})]})]},e.mappedValue)}function Ax(){var g,v,w;const{fieldMapping:e}=Ze(),{selectedObjectName:t,configureState:n,setConfigureState:r}=tn(),{isError:o,removeError:i,getError:s}=qt(),a=(g=n==null?void 0:n.read)==null?void 0:g.selectedFieldMappings,c=(v=n==null?void 0:n.read)==null?void 0:v.selectedValueMappings,f=(w=n==null?void 0:n.read)==null?void 0:w.isValueMappingsModified,d=b.useRef(!1),l=b.useMemo(()=>{const h=t&&e?Object.values(e[t]||{}).flat().filter(S=>S.mappedValues).map(S=>({...S})):[];if(a)for(let S=0;S<h.length;S+=1){const{mapToName:p}=h[S];a!=null&&a[p]&&(h[S].fieldName=a[p])}return h},[t,e,a]),m=b.useCallback(h=>{const{value:S,name:p,fieldName:y}=h.target;S&&(t&&Tf(t,r,p,S,y),o(ue.VALUE_MAPPING,p)&&i(ue.VALUE_MAPPING,p))},[t,r,o,i]);return b.useEffect(()=>{var h;if(t&&c){const S=((h=e==null?void 0:e[t])==null?void 0:h.filter(y=>y.fieldName&&y.mappedValues.length>0))||[];S.every(y=>{const I=c[y.fieldName]||{};return Object.keys(I).length===Object.keys(y.mappedValues).length})&&S.length>0?!f&&!d.current&&(_x(t,r,!0),d.current=!0):d.current=!1}},[c,l,t,r,e,f]),l!=null&&l.length?u.jsx(u.Fragment,{children:l.map(h=>{var T,E,A;if(!h.fieldName)return null;const S=(E=(T=n==null?void 0:n.read)==null?void 0:T.allFieldsMetadata)==null?void 0:E[h.fieldName],p=S==null?void 0:S.valueType;if(!["singleSelect","multiSelect"].includes(p))return console.error("fieldName is not a singleSelect or multiSelect",h),null;const y=S==null?void 0:S.values;if(!y)return null;const I=Object.keys(y).length,x=Object.keys((h==null?void 0:h.mappedValues)||[]).length;return I!==x?(console.error("field values and the values to be mapped are not of the same length",h,y),null):u.jsxs(u.Fragment,{children:[u.jsx(Nx,{string:"Map the values for ",fieldName:h.mapToDisplayName||h.mapToName||h.fieldName}),u.jsx("div",{style:{display:"flex",gap:"1rem",flexDirection:"column"},children:u.jsx(Go,{id:h.mapToName||h.fieldName,children:(A=h==null?void 0:h.mappedValues)==null?void 0:A.map(R=>{var V,M,se;const P=s(ue.VALUE_MAPPING,h.fieldName),K=Array.isArray(P)&&P.includes(R.mappedValue),q=((se=(M=(V=n==null?void 0:n.read)==null?void 0:V.allFieldsMetadata)==null?void 0:M[h.fieldName])==null?void 0:se.values)||[];return u.jsxs(u.Fragment,{children:[u.jsx(Tx,{allValueOptions:q,mappedValue:R,onSelectChange:m,fieldName:(h==null?void 0:h.fieldName)||"",hasError:K},`${R.mappedValue}-${h.fieldName}`),K&&u.jsx("span",{style:{color:"red",fontSize:"14px",marginTop:"4px"},children:`Each ${h.mapToName||h.fieldName} must be mapped to a unique value`},R.mappedValue)]})})},h.mapToName||h.fieldName)})]})})}):null}const Rx=!1;function Px(){return FS(),u.jsxs(u.Fragment,{children:[u.jsx(kS,{}),u.jsx(Ox,{}),u.jsx(RS,{}),u.jsx(AS,{}),u.jsx(Ax,{}),u.jsx(Cx,{}),Rx]})}function Fx(e,t,n){var r,o,i;if(((r=e==null?void 0:e.write)==null?void 0:r.selectedWriteObjects)===null&&(e.write.selectedWriteObjects={}),e!=null&&e.write){const s=e.write.selectedWriteObjects;if(n&&(s[t]={objectName:t}),n||delete s[t],(i=(o=e==null?void 0:e.write)==null?void 0:o.savedConfig)!=null&&i.selectedWriteObjects){const a=e.write.savedConfig.selectedWriteObjects,f=!Sb(a,s);e.write.isWriteModified=f}}}function Dx(e,t,n,r){t(e,o=>{Fx(o,n,r)})}function Mx(){var f,d;const{appName:e,selectedObjectName:t,configureState:n,setConfigureState:r}=tn(),o=(f=n==null?void 0:n.write)==null?void 0:f.selectedWriteObjects,i=(d=n==null?void 0:n.write)==null?void 0:d.writeObjects,s=(l,m)=>{t&&n&&Dx(t,r,l,m)},a=!!i,c=(i==null?void 0:i.map(l=>({id:l.objectName,label:l.displayName,isChecked:!!(o!=null&&o[l.objectName])})))||[];return a&&u.jsxs(u.Fragment,{children:[u.jsx(Rt,{string:`Allow ${e} to write to these objects`}),u.jsx(Nf,{items:c,onItemChange:s,showSelectAll:i.length>=2})]})}function kx(){return u.jsx(u.Fragment,{children:u.jsx(Mx,{})})}function Af({resetComponent:e,onDisconnectSuccess:t}){return u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[u.jsx(Rt,{string:"Remove connection"}),u.jsx("p",{children:"Click to disconnect your connection from the provider."}),u.jsx(md,{resetComponent:e,onDisconnectSuccess:t,buttonText:"Remove connection",buttonVariant:"danger",buttonStyle:{fontSize:"13px",width:"100%"}})]})}const Lx="_authenticationRow_1g2ms_1",jx="_field_1g2ms_8",Kx="_value_1g2ms_12",Is={authenticationRow:Lx,field:jx,value:Kx};function xu({label:e,value:t}){return u.jsxs("div",{className:Is.authenticationRow,children:[u.jsx("div",{className:Is.field,children:e}),u.jsx("div",{className:Is.value,children:t})]})}function $x(){const{selectedConnection:e}=en(),{providerName:t}=ut(),r=(e==null?void 0:e.provider)==="salesforce"?"subdomain":"workspace",o=`${t} ${r}`;return u.jsxs(u.Fragment,{children:[u.jsx(Rt,{string:"Connection details"}),u.jsxs("div",{style:{paddingBottom:"1rem"},children:[u.jsx(xu,{label:o,value:e==null?void 0:e.providerWorkspaceRef}),u.jsx(xu,{label:"Status",value:un((e==null?void 0:e.status)||"")})]})]})}const Ux=()=>{const e=it(),t=Ue();return En({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."),$e(n)}})};function Rf({buttonText:e,buttonVariant:t="secondary",buttonStyle:n={}}){const{projectIdOrName:r}=Pe(),{integrationId:o,installation:i,setIntegrationDeleted:s,onUninstallSuccess:a}=Ze(),[c,f]=b.useState(!1),d=!r||!o||!(i!=null&&i.id)||c,l=Ux(),m=async()=>{d||(f(!0),console.warn("uninstalling installation",{projectIdOrName:r,integrationId:o,installationId:i.id}),l.mutate({projectIdOrName:r,integrationId:o,installationId:i.id},{onSuccess:()=>{console.warn("successfully uninstalled installation:",i.id),a==null||a(i==null?void 0:i.id),s()},onSettled:()=>f(!1)}))},g=c?"Uninstalling...":e,v=u.jsx(Be,{type:"button",onClick:m,disabled:d,variant:t,style:n,children:g});return i!=null&&i.id?v:null}function qx(){const{installation:e}=Ze(),{providerName:t}=ut();return e?u.jsxs(u.Fragment,{children:[u.jsx(Rt,{string:"Uninstall entire integration"}),u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",padding:"1rem 0"},children:[e!=null&&e.id?u.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."]}):u.jsx("p",{children:"You've successfully uninstalled the integration."}),u.jsx(Rf,{buttonText:"Yes, uninstall",buttonVariant:"danger"})]})]}):null}function Vx(){const{installation:e,resetComponent:t}=Ze();return u.jsxs(u.Fragment,{children:[u.jsx($x,{}),u.jsx(Oa,{}),e&&u.jsx(qx,{}),!e&&u.jsx(Af,{resetComponent:t})]})}function Pf({onSave:e,onReset:t,isLoading:n,isCreateMode:r=!1,errorMsg:o}){var T,E,A,R;const{installation:i}=Ze(),{hydratedRevision:s,loading:a}=di(),{configureState:c,selectedObjectName:f}=tn(),d=i==null?void 0:i.config,l=d&&f&&!!Xl(d,f)||!1,m=((T=c==null?void 0:c.read)==null?void 0:T.isOptionalFieldsModified)||((E=c==null?void 0:c.read)==null?void 0:E.isRequiredMapFieldsModified)||((A=c==null?void 0:c.read)==null?void 0:A.isValueMappingsModified),g=(R=c==null?void 0:c.write)==null?void 0:R.isWriteModified,S=a||n||!c||!f||!(m||g||r||f!==Er&&!l),p=f===Er,y=f===Oo,I=u.jsx(Be,{type:"submit",disabled:S,children:r?"Install":"Save"}),x=u.jsx(Be,{type:"button",onClick:t,disabled:S,variant:"ghost",children:"Reset"});return n?u.jsx(Ni,{}):u.jsxs("form",{style:{width:"34rem"},onSubmit:e,children:[u.jsx("div",{style:{display:"flex",flexDirection:"row-reverse",gap:".8rem",marginBottom:"20px",height:"3rem"},children:!y&&u.jsxs(u.Fragment,{children:[I,x]})}),u.jsxs(_n,{style:{padding:"1rem 2rem",minHeight:"300px",backgroundColor:"var(--amp-colors-bg-primary)",borderColor:"var(--amp-colors-border)"},children:[o&&u.jsx(ji,{children:typeof o=="string"?o:"Installation Failed."}),a&&u.jsx(Ni,{}),s&&!p&&!y&&u.jsx(Px,{}),s&&p&&!y&&u.jsx(kx,{}),!a&&y&&u.jsx(Vx,{})]})]})}const Ff=()=>{const{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,onInstallSuccess:o,onUpdateSuccess:i}=Ze(),{hydratedRevision:s,loading:a}=di(),{selectedObjectName:c}=vd(),{selectedConnection:f}=en(),d=Yu(),{projectIdOrName:l}=Pe(),{resetBoundary:m,setErrors:g,setError:v,getError:w}=qt(),{resetConfigureState:h,objectConfigurationsState:S,resetPendingConfigurationState:p}=Ea(),y=ad(c||"",S),{onNextIncompleteTab:I}=mI(),x=b.useCallback(()=>{m(ue.INSTALLATION_MUTATION)},[m]),T=b.useCallback(A=>A?R=>{v(ue.INSTALLATION_MUTATION,A,R)}:R=>{console.error("objectName is required to set installation error: ",R)},[v]),E=b.useCallback(A=>A?w(ue.INSTALLATION_MUTATION,A):"",[w]);return{integrationId:e,groupRef:t,consumerRef:n,setInstallation:r,hydratedRevision:s,loading:a,selectedObjectName:c,selectedConnection:f,apiKey:d,projectIdOrName:l,resetBoundary:m,setErrors:g,setMutateInstallationError:T,getMutateInstallationError:E,resetMutateInstallationErrorState:x,resetConfigureState:h,objectConfigurationsState:S,resetPendingConfigurationState:p,configureState:y,onInstallSuccess:o,onUpdateSuccess:i,onNextIncompleteTab:I}},Hx=void 0;function Bx(){const{consumerRef:e,setInstallation:t,hydratedRevision:n,loading:r,selectedObjectName:o,selectedConnection:i,resetBoundary:s,setErrors:a,setMutateInstallationError:c,getMutateInstallationError:f,resetMutateInstallationErrorState:d,resetConfigureState:l,objectConfigurationsState:m,resetPendingConfigurationState:g,configureState:v,onInstallSuccess:w,onNextIncompleteTab:h}=Ff(),[S,p]=b.useState(!1),{createInstallation:y}=zl(),I=o===Er,x=f(o),T=b.useCallback(()=>{s(ue.MAPPING),n!=null&&n.content&&!r&&o&&rd(n,Hx,o,l)},[s,n,r,o,l]);b.useEffect(()=>{!v&&(n!=null&&n.content)&&!r&&T()},[v,m,n,r,T]);const E=()=>{d();const{requiredMapFields:P,selectedFieldMappings:K}=(v==null?void 0:v.read)||{},{errorList:q}=ed(P,K,a);if(!(q.length>0))if(o&&(i!=null&&i.id)&&e&&n){p(!0);const V=Nb(v,o,n,e);if(!V){console.error("Error when generating createConfig from configureState"),p(!1);return}y({config:V.content,onSuccess:M=>{t(M),w==null||w(M.id,M.config),p(!1),g(o),h()},onError:M=>{c(o)(M.message),p(!1)}})}else console.error("CreateInstallallation - onSaveReadCreate: missing required props")},A=()=>{if(d(),o&&(i!=null&&i.id)&&e&&n){p(!0);const P=Ab(v,n,e);if(!P){console.error("Error when generating createConfig from configureState"),p(!1);return}y({config:P.content,onSuccess:K=>{t(K),w==null||w(K.id,K.config),p(!1),g(o),h()},onError:K=>{c(o)(K.message),p(!1)}})}else console.error("CreateInstallallation - onSaveWriteCreate: missing required props")},R=P=>{P.preventDefault(),I?A():E()};return u.jsx(Pf,{errorMsg:x,isCreateMode:!0,isLoading:S,onSave:R,onReset:T})}function Jx({updateConfig:e,projectIdOrName:t,integrationId:n,installationId:r,apiKey:o,selectedObjectName:i,setInstallation:s,onUpdateSuccess:a,setError:c}){const f={projectIdOrName:t,installationId:r,integrationId:n,installationUpdate:{updateMask:[`config.content.read.objects.${ob(i)}`],installation:{config:e}}};return $l().installationApi.updateInstallation(f,{headers:{"X-Api-Key":o,"Content-Type":"application/json"}}).then(d=>{s(d),a==null||a(d.id,d.config)}).catch(d=>{$e(d,c)})}const Wx=(e,t,n,r)=>{const o=id(e),i=od(e),s=sd(e),a={content:{read:{objects:{[t]:{objectName:t,selectedFields:o,selectedFieldMappings:i,selectedValueMappings:s||{},backfill:r}}}}};return Li(n)&&(a.content||(a.content={}),a.content.proxy={enabled:!0}),a},zx=(e,t,n,r,o,i,s,a,c,f,d)=>{const l=Wx(i,r||"",c,a.backfill);return l?Jx({updateConfig:l,projectIdOrName:e,integrationId:t,installationId:n,apiKey:o,selectedObjectName:r,setError:f,setInstallation:s,onUpdateSuccess:d}):(console.error("Error when generating updateConfig from configureState"),Promise.resolve(null))},Gx=(e,t)=>{const r={content:{write:{objects:cd(e)}}};return Li(t)&&(r.content||(r.content={}),r.content.proxy={enabled:!0}),r},Qx=(e,t,n,r,o,i,s,a,c)=>{const f=Gx(o,i);if(!f)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:f}}};return $l().installationApi.updateInstallation(d,{headers:{"X-Api-Key":r,"Content-Type":"application/json"}}).then(l=>{a(l),c==null||c(l.id,l.config)}).catch(l=>{$e(l,s)})};function Xx({installation:e,integrationObj:t}){const{setInstallation:n,hydratedRevision:r,loading:o,selectedObjectName:i,apiKey:s,projectIdOrName:a,resetBoundary:c,setErrors:f,setMutateInstallationError:d,getMutateInstallationError:l,resetConfigureState:m,resetPendingConfigurationState:g,configureState:v,onUpdateSuccess:w,onNextIncompleteTab:h}=Ff(),[S,p]=b.useState(!1),y=i===Er,I=l(i),{config:x}=e,T=b.useCallback(()=>{c(ue.MAPPING),r!=null&&r.content&&!o&&i&&rd(r,x,i,m)},[c,r,o,i,x,m]);b.useEffect(()=>{v||T()},[v,T]);const E=b.useMemo(()=>{var q,V,M;return(M=(V=(q=r==null?void 0:r.content)==null?void 0:q.read)==null?void 0:V.objects)==null?void 0:M.find(se=>(se==null?void 0:se.objectName)===i)},[r,i]),A=()=>{const{requiredMapFields:K,selectedFieldMappings:q}=(v==null?void 0:v.read)||{},{errorList:V}=ed(K,q,f);V.length>0||(r&&e&&i&&s&&a&&E?(p(!0),zx(a,t.id,e.id,i,s,v,n,E,r,d(i),w).finally(()=>{p(!1),g(i),h()})):console.error("UpdateInstallation - onSaveUpdate missing required props"))},R=()=>{e&&i&&s&&a&&r?(p(!0),Qx(a,t.id,e.id,s,v,r,d(i),n,w).finally(()=>{p(!1),g(i),h()})):console.error("UpdateInstallation - onSaveUpdate missing required props")},P=K=>{K.preventDefault(),y?R():A()};return u.jsx(Pf,{errorMsg:I,onSave:P,onReset:T,isLoading:S})}function Yx(){const{integrationObj:e,installation:t}=Ze();return e?t&&e?u.jsx(Xx,{installation:t,integrationObj:e}):u.jsx(Bx,{}):u.jsx(ql,{message:"We can't load the integration"})}function Zx(){return u.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"#BBF7D0"}),u.jsx("path",{d:"M34.6666 18.6667L20 32.0001L13.3333 25.9395",stroke:"#16A34A",strokeWidth:"5.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}function nc({text:e,children:t}){return u.jsx(ui,{children:u.jsxs(_n,{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"3rem",gap:"3rem"},children:[u.jsx(Zx,{}),u.jsx("p",{children:e}),t]})})}function e0({provider:e}){const{providerName:t}=ut(e),n=`You have successfully installed your ${t} integration.`;return u.jsx(nc,{text:n,children:u.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:u.jsx(Rf,{buttonText:"Uninstall",buttonVariant:"outline",buttonStyle:{fontSize:"13px"}})})})}const t0=e=>{const{read:t,write:n}=(e==null?void 0:e.content)??{};return!t&&!n};function n0({children:e}){var x;const t=b.useRef(!1),{projectIdOrName:n}=Pe(),{hydratedRevision:r,loading:o}=di(),{integrationObj:i,installation:s,groupRef:a,consumerRef:c,onInstallSuccess:f,isIntegrationDeleted:d}=Ze(),{mutate:l,isIdle:m,isPending:g,error:v,errorMsg:w}=Wl(),{selectedConnection:h,isConnectionsLoading:S}=en(),p=o||g||S,y=(x=r==null?void 0:r.content)==null?void 0:x.provider,I=t0(r);return b.useEffect(()=>{var T;if(!p&&!S&&r&&I&&!s&&h&&(i!=null&&i.id)&&!d&&y){const E={projectIdOrName:n,integrationId:i==null?void 0:i.id,installation:{groupRef:a,connectionId:h==null?void 0:h.id,config:{content:{provider:y}}}};Li(r)===!0&&(E.installation.config.content.proxy=(T=r==null?void 0:r.content)==null?void 0:T.proxy),m&&!t.current&&(l(E,{onSuccess:A=>{f==null||f(A==null?void 0:A.id,A.config)}}),t.current=!0)}},[r,I,s,h,n,i==null?void 0:i.id,a,c,p,f,d,S,y,l,m]),I&&y&&s?u.jsx(e0,{provider:y}):v?u.jsx($t,{message:w??"Create installation failed"}):i?p?u.jsx(li,{}):u.jsx("div",{children:e}):u.jsx($t,{message:"We can't load the integration"})}function qi(){const e=it(),t=Ue();return En({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"),$e(n)}})}function r0({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a}){const{projectIdOrName:c}=Pe(),f=qi(),d=b.useCallback(l=>{var w;const{apiKey:m,providerMetadata:g}=l,v={projectIdOrName:c,generateConnectionParams:{providerWorkspaceRef:(w=g==null?void 0:g.workspace)==null?void 0:w.value,groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,apiKey:m,...g&&{providerMetadata:g}}};f.mutate(v)},[c,i,o,r,n,e,f]);return a===null?u.jsx(Gb,{provider:e,providerInfo:t,handleSubmit:d,error:null}):s}function i0({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,children:s,selectedConnection:a}){const{projectIdOrName:c}=Pe(),f=qi(),d=b.useCallback(l=>{var h;const{user:m,pass:g,providerMetadata:v}=l,w={projectIdOrName:c,generateConnectionParams:{providerWorkspaceRef:(h=v==null?void 0:v.workspace)==null?void 0:h.value,groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,basicAuth:{username:m,password:g},...v&&{providerMetadata:v}}};f.mutate(w)},[c,i,o,r,n,e,f]);return a===null?u.jsx(eI,{provider:e,providerInfo:t,handleSubmit:d,error:null}):s}function Ou({url:e,prompt:t,inputName:n}){return u.jsx("p",{style:{color:"var(--amp-colors-text-muted)",display:"flex",justifyContent:"space-between"},children:u.jsxs("span",{children:[e?u.jsx(Sa,{href:e,newTab:!0,children:u.jsx("span",{style:{textDecoration:"underline"},children:n})}):u.jsx("span",{children:n})," ",t&&u.jsx(yf,{id:`docs-helper-text-${sb(n||(t==null?void 0:t.slice(0,50)))}`,tooltipText:t})]})})}function o0({providerInfo:e,handleSubmit:t,isButtonDisabled:n,buttonVariant:r}){var m,g;const[o,i]=b.useState({}),s=((m=e.metadata)==null?void 0:m.input)||[],a=v=>{const{name:w,value:h}=v.currentTarget;i(S=>({...S,[w]:h.trim()}))},c=Zr(s,o),f=n||!c,d=((g=e.customOpts)==null?void 0:g.inputs)||[],l=()=>{const v=qo(s,o),w=Object.fromEntries(d.map(h=>[h.name,o[h.name]]));t({customAuth:w,providerMetadata:v})};return u.jsxs("div",{style:{display:"flex",gap:"1rem",flexDirection:"column",marginTop:"1rem"},children:[d.map(v=>u.jsxs("div",{children:[u.jsx(Ou,{url:v.docsURL,prompt:v.prompt,inputName:v.displayName}),u.jsx(St.PasswordInput,{id:v.name,name:v.name,onChange:a,placeholder:""})]},v.name)),s.map(v=>u.jsxs("div",{children:[v.docsURL&&u.jsx(Ou,{url:v.docsURL,prompt:v.displayName||v.name,inputName:v.displayName||un(v.name.toLowerCase())}),u.jsx(St.Input,{id:v.name,name:v.name,type:"text",placeholder:"",onChange:a})]},v.name)),u.jsx(Be,{style:{marginTop:"1em",width:"100%"},disabled:f,type:"submit",onClick:l,variant:r,children:"Next"})]})}function s0({providerInfo:e,handleSubmit:t,error:n,isButtonDisabled:r}){return u.jsxs(rr,{children:[u.jsx(ir,{children:`Set up ${e.displayName} integration`}),u.jsx(dn,{error:n}),u.jsx(o0,{providerInfo:e,handleSubmit:t,isButtonDisabled:r})]})}function a0({providerInfo:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,selectedConnection:s}){const{projectIdOrName:a}=Pe(),c=qi(),[f,d]=b.useState(null),l=b.useCallback(m=>{var h;const{customAuth:g,providerMetadata:v}=m;d(null);const w={projectIdOrName:a,generateConnectionParams:{providerWorkspaceRef:(h=v==null?void 0:v.workspace)==null?void 0:h.value,groupName:o,groupRef:r,consumerName:n,consumerRef:t,provider:e.name,customAuth:g,...v&&{providerMetadata:v}}};c.mutate(w,{onError:S=>{$e(S,d)},onSuccess:()=>{d(null)}})},[a,o,r,n,t,e.name,c]);return s===null?u.jsx(s0,{providerInfo:e,handleSubmit:l,error:f}):i}function c0({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 u.jsxs(rr,{children:[u.jsx(ir,{children:i||`Set up ${r} integration`}),u.jsx(dn,{error:t}),o,u.jsx(Be,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:"Next"})]})}function u0({...e}){return u.jsx(c0,{...e})}function l0({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,selectedConnection:s,providerName:a}){const{projectIdOrName:c}=Pe(),f=qi(),d=b.useCallback(()=>{const l={projectIdOrName:c,generateConnectionParams:{groupName:o,groupRef:r,consumerName:n,consumerRef:t,provider:e}};f.mutate(l)},[c,o,r,n,t,e,f]);return s===null?u.jsx(u0,{handleSubmit:d,error:null,providerName:a}):i}const d0=()=>{const e=it(),t=Ue();return En({mutationKey:["createOauthConnection"],mutationFn:async n=>(await e()).oAuthApi.oauthConnect(n),onSuccess:()=>{t.invalidateQueries({queryKey:["connections"]})}})};function f0({handleSubmit:e,error:t,isButtonDisabled:n,providerName:r}){return u.jsxs(rr,{children:[u.jsx(ir,{children:`Set up ${r} integration`}),u.jsx(Bb,{children:`Click Next to sign into the ${r} account you'd like to sync.`}),u.jsx(dn,{error:t}),u.jsx(Be,{style:{marginTop:"1em",width:"100%"},disabled:n,type:"submit",onClick:e,children:n?"Loading...":"Next"})]})}const p0="https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5";function h0({handleSubmit:e,setWorkspace:t,error:n,isButtonDisabled:r}){return u.jsxs(rr,{children:[u.jsx(ir,{children:"Enter your Salesforce subdomain"}),u.jsx(Sa,{href:p0,newTab:!0,children:"What is my Salesforce subdomain?"}),u.jsx(dn,{error:n}),u.jsxs("div",{style:{display:"flex",marginTop:"1em",alignItems:"center"},children:[u.jsx(St.Input,{id:"salesforce-subdomain",type:"text",placeholder:"my-domain",onChange:o=>t(o.currentTarget.value)}),u.jsx("p",{style:{lineHeight:"2.2em",marginLeft:"0.4em"},children:".my.salesforce.com"})]}),u.jsx(Be,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}function m0({handleSubmit:e,setFormData:t,error:n,isButtonDisabled:r,providerName:o,metadataFields:i}){return u.jsxs(rr,{children:[u.jsxs(ir,{children:["Enter your ",o," workspace"]}),u.jsx(dn,{error:n}),u.jsx("br",{}),i.map(s=>u.jsx(St.Input,{id:s.name,name:s.name,type:"text",placeholder:s.displayName||s.name,onChange:a=>t(s.name,a.currentTarget.value)},s.name)),u.jsx("br",{}),u.jsx(Be,{style:{marginTop:"1em",width:"100%"},disabled:r,type:"submit",onClick:e,children:"Next"})]})}const Eu=600,_u=600,Nu="salesforce";function g0({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,providerName:i}){var K;const{projectId:s}=tr(),a=Ue(),c=b.useRef(null),[f,d]=b.useState(null),[l,m]=b.useState(""),[g,v]=b.useState({}),[w,h]=b.useState({}),{data:S}=Uo(e),p=((K=S==null?void 0:S.metadata)==null?void 0:K.input)||[],{mutateAsync:y,isPending:I}=d0(),{isFetching:x,refetch:T}=Ia({groupRef:r,provider:e});b.useEffect(()=>{const q=V=>{var M,se,oe;V.origin===jl&&(((M=V.data)==null?void 0:M.eventType)==="AUTHORIZATION_SUCCEEDED"?(d(null),console.debug("New connection:",V.data.data.connection),a.invalidateQueries({queryKey:["amp","connections"]})):((se=V.data)==null?void 0:se.eventType)==="AUTHORIZATION_FAILED"&&(console.error("OAuth failed:",V.data.data.error),a.invalidateQueries({queryKey:["amp","connections"]}),d(V.data.data.error||"An error occurred. Please try again.")),(oe=c.current)==null||oe.close())};return window.addEventListener("message",q),()=>window.removeEventListener("message",q)},[a]);const E=q=>{m(q),v(V=>({...V,workspace:q})),h(V=>({...V,workspace:{value:q,source:"input"}}))},A=(q,V)=>{v(M=>({...M,[q]:V})),h(M=>({...M,[q]:{value:V,source:"input"}}))},R=async()=>{var q;d(null);try{const{data:V}=await T();if(V&&V.length>0){console.debug("connections found");return}}catch{console.debug("error with fetching connections")}if(p.length>0&&!Zr(p,g)){d("Please fill in all required fields");return}try{const V=await y({connectOAuthParams:{provider:e,consumerRef:t,groupRef:r,projectId:s||"",consumerName:n,groupName:o,providerWorkspaceRef:e===Nu?l:(q=w==null?void 0:w.workspace)==null?void 0:q.value,providerMetadata:w}});if(V){const M=window.screenX+(window.outerWidth-Eu)/2,se=window.screenY+(window.outerHeight-_u)/2.5,oe=`width=${Eu},height=${_u},left=${M},top=${se}`;c.current=window.open(V,"OAuthPopup",oe)}}catch(V){console.error(V),d(V instanceof Error?V.message:String(V)||"An error occurred. Please try again.")}},P=e===Nu?u.jsx(h0,{handleSubmit:R,setWorkspace:E,error:f,isButtonDisabled:l.length===0||I||x}):p.length>0?u.jsx(m0,{handleSubmit:R,setFormData:A,error:f,isButtonDisabled:!Zr(p,g)||I||x,providerName:i,metadataFields:p}):u.jsx(f0,{handleSubmit:R,error:f,providerName:i,isButtonDisabled:I||x});return u.jsx("div",{children:P})}function y0({provider:e,providerName:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,explicitScopesRequired:s,selectedConnection:a}){const{projectIdOrName:c}=Pe(),f=qi(),[d,l]=b.useState(null),m=b.useCallback(g=>{var w,h;l(null);const v={projectIdOrName:c,generateConnectionParams:{groupName:i,groupRef:o,consumerName:r,consumerRef:n,provider:e,providerWorkspaceRef:(h=(w=g.providerMetadata)==null?void 0:w.workspace)==null?void 0:h.value,oauth2ClientCredentials:{clientId:g.clientId,clientSecret:g.clientSecret,scopes:g.scopes},...g.providerMetadata&&{providerMetadata:g.providerMetadata}}};f.mutate(v,{onError:()=>l("Error loading provider info")})},[c,i,o,r,n,e,f]);return a===null?u.jsx(nI,{provider:e,providerName:t,handleSubmit:m,error:d,explicitScopesRequired:s}):u.jsx(Ni,{})}function v0({...e}){return u.jsx(y0,{...e})}const w0="authorizationCode",b0="authorizationCodePKCE",I0="clientCredentials";function C0({provider:e,providerInfo:t,consumerRef:n,consumerName:r,groupRef:o,groupName:i,selectedConnection:s,setSelectedConnection:a}){const{providerName:c}=ut(e);if(t.oauth2Opts===void 0)return u.jsx("em",{children:"Provider is missing OAuth2 options"});const{grantType:f,explicitScopesRequired:d}=t.oauth2Opts,l={provider:e,consumerRef:n,consumerName:r,groupRef:o,groupName:i,providerName:c};return f===w0||f===b0?u.jsx(g0,{...l}):f===I0?u.jsx(v0,{...l,explicitScopesRequired:d,selectedConnection:s,setSelectedConnection:a}):f==="password"?u.jsx("em",{children:"Password flow not supported yet"}):u.jsxs("em",{children:["Unsupported grant type: ",f]})}function S0(e){const{selectedConnection:t}=en();b.useEffect(()=>{e&&t&&e(t)},[e,t])}function x0({onSuccess:e}){S0(e)}function Df({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:i,onSuccess:s,onDisconnectSuccess:a,resetComponent:c}){const{data:f,isLoading:d,isError:l,error:m,providerName:g,selectedProvider:v}=ut(e),{provider:w,isIntegrationDeleted:h}=Ze(),{selectedConnection:S,setSelectedConnection:p}=en();x0({onSuccess:s});const y=Ue(),I=f;b.useEffect(()=>{l&&(console.error("Error loading provider info."),$e(m))},[l,m]);const x=b.useCallback(()=>{y.clear(),c()},[c,y]);if(!e&&!w)throw new Error("ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider");if(h)return u.jsx(nc,{text:"Integration successfully uninstalled.",children:u.jsx(Be,{type:"button",onClick:x,style:{width:"100%"},children:"Reinstall Integration"})});if(S)return i;if(d)return u.jsx(li,{});if(I==null)return u.jsx($t,{message:"Provider info was not found."});const T={provider:v,consumerRef:t,consumerName:n,groupRef:r,groupName:o,selectedConnection:S,setSelectedConnection:p,providerName:g,providerInfo:I,onDisconnectSuccess:a};return I.authType==="none"?u.jsx(l0,{...T,children:i}):I.authType==="basic"?u.jsx(i0,{...T,children:i}):I.authType==="apiKey"?u.jsx(r0,{...T,children:i}):I.authType==="custom"?u.jsx(a0,{...T,children:i}):u.jsx(C0,{...T})}function O0(e){const t=e+"CollectionProvider",[n,r]=Qo(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=w=>{const{scope:h,children:S}=w,p=b.useRef(null),y=b.useRef(new Map).current;return u.jsx(o,{scope:h,itemMap:y,collectionRef:p,children:S})};s.displayName=t;const a=e+"CollectionSlot",c=oa(a),f=b.forwardRef((w,h)=>{const{scope:S,children:p}=w,y=i(a,S),I=oi(h,y.collectionRef);return u.jsx(c,{ref:I,children:p})});f.displayName=a;const d=e+"CollectionItemSlot",l="data-radix-collection-item",m=oa(d),g=b.forwardRef((w,h)=>{const{scope:S,children:p,...y}=w,I=b.useRef(null),x=oi(h,I),T=i(d,S);return b.useEffect(()=>(T.itemMap.set(I,{ref:I,...y}),()=>void T.itemMap.delete(I))),u.jsx(m,{[l]:"",ref:x,children:p})});g.displayName=d;function v(w){const h=i(e+"CollectionConsumer",w);return b.useCallback(()=>{const p=h.collectionRef.current;if(!p)return[];const y=Array.from(p.querySelectorAll(`[${l}]`));return Array.from(h.itemMap.values()).sort((T,E)=>y.indexOf(T.ref.current)-y.indexOf(E.ref.current))},[h.collectionRef,h.itemMap])}return[{Provider:s,Slot:f,ItemSlot:g},v,r]}var E0=j[" useId ".trim().toString()]||(()=>{}),_0=0;function Mf(e){const[t,n]=j.useState(E0());return Ri(()=>{n(r=>r??String(_0++))},[e]),e||(t?`radix-${t}`:"")}function N0(e){const t=j.useRef(e);return j.useEffect(()=>{t.current=e}),j.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}var T0=j.createContext(void 0);function kf(e){const t=j.useContext(T0);return e||t||"ltr"}var Cs="rovingFocusGroup.onEntryFocus",A0={bubbles:!1,cancelable:!0},Vi="RovingFocusGroup",[sa,Lf,R0]=O0(Vi),[P0,jf]=Qo(Vi,[R0]),[F0,D0]=P0(Vi),Kf=j.forwardRef((e,t)=>u.jsx(sa.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(sa.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(M0,{...e,ref:t})})}));Kf.displayName=Vi;var M0=j.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:f,preventScrollOnEntryFocus:d=!1,...l}=e,m=j.useRef(null),g=oi(t,m),v=kf(i),[w,h]=Xa({prop:s,defaultProp:a??null,onChange:c,caller:Vi}),[S,p]=j.useState(!1),y=N0(f),I=Lf(n),x=j.useRef(!1),[T,E]=j.useState(0);return j.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(Cs,y),()=>A.removeEventListener(Cs,y)},[y]),u.jsx(F0,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:w,onItemFocus:j.useCallback(A=>h(A),[h]),onItemShiftTab:j.useCallback(()=>p(!0),[]),onFocusableItemAdd:j.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:j.useCallback(()=>E(A=>A-1),[]),children:u.jsx(Nn.div,{tabIndex:S||T===0?-1:0,"data-orientation":r,...l,ref:g,style:{outline:"none",...e.style},onMouseDown:Xt(e.onMouseDown,()=>{x.current=!0}),onFocus:Xt(e.onFocus,A=>{const R=!x.current;if(A.target===A.currentTarget&&R&&!S){const P=new CustomEvent(Cs,A0);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const K=I().filter(oe=>oe.focusable),q=K.find(oe=>oe.active),V=K.find(oe=>oe.id===w),se=[q,V,...K].filter(Boolean).map(oe=>oe.ref.current);qf(se,d)}}x.current=!1}),onBlur:Xt(e.onBlur,()=>p(!1))})})}),$f="RovingFocusGroupItem",Uf=j.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:s,...a}=e,c=Mf(),f=i||c,d=D0($f,n),l=d.currentTabStopId===f,m=Lf(n),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:w}=d;return j.useEffect(()=>{if(r)return g(),()=>v()},[r,g,v]),u.jsx(sa.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:u.jsx(Nn.span,{tabIndex:l?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:Xt(e.onMouseDown,h=>{r?d.onItemFocus(f):h.preventDefault()}),onFocus:Xt(e.onFocus,()=>d.onItemFocus(f)),onKeyDown:Xt(e.onKeyDown,h=>{if(h.key==="Tab"&&h.shiftKey){d.onItemShiftTab();return}if(h.target!==h.currentTarget)return;const S=j0(h,d.orientation,d.dir);if(S!==void 0){if(h.metaKey||h.ctrlKey||h.altKey||h.shiftKey)return;h.preventDefault();let y=m().filter(I=>I.focusable).map(I=>I.ref.current);if(S==="last")y.reverse();else if(S==="prev"||S==="next"){S==="prev"&&y.reverse();const I=y.indexOf(h.currentTarget);y=d.loop?K0(y,I+1):y.slice(I+1)}setTimeout(()=>qf(y))}}),children:typeof s=="function"?s({isCurrentTabStop:l,hasTabStop:w!=null}):s})})});Uf.displayName=$f;var k0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function L0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function j0(e,t,n){const r=L0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return k0[r]}function qf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function K0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var $0=Kf,U0=Uf,Yo="Tabs",[q0,yO]=Qo(Yo,[jf]),Vf=jf(),[V0,rc]=q0(Yo),Hf=j.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:c="automatic",...f}=e,d=kf(a),[l,m]=Xa({prop:r,onChange:o,defaultProp:i??"",caller:Yo});return u.jsx(V0,{scope:n,baseId:Mf(),value:l,onValueChange:m,orientation:s,dir:d,activationMode:c,children:u.jsx(Nn.div,{dir:d,"data-orientation":s,...f,ref:t})})});Hf.displayName=Yo;var Bf="TabsList",Jf=j.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=rc(Bf,n),s=Vf(n);return u.jsx($0,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:r,children:u.jsx(Nn.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});Jf.displayName=Bf;var Wf="TabsTrigger",zf=j.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=rc(Wf,n),a=Vf(n),c=Qf(s.baseId,r),f=Xf(s.baseId,r),d=r===s.value;return u.jsx(U0,{asChild:!0,...a,focusable:!o,active:d,children:u.jsx(Nn.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":f,"data-state":d?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...i,ref:t,onMouseDown:Xt(e.onMouseDown,l=>{!o&&l.button===0&&l.ctrlKey===!1?s.onValueChange(r):l.preventDefault()}),onKeyDown:Xt(e.onKeyDown,l=>{[" ","Enter"].includes(l.key)&&s.onValueChange(r)}),onFocus:Xt(e.onFocus,()=>{const l=s.activationMode!=="manual";!d&&!o&&l&&s.onValueChange(r)})})})});zf.displayName=Wf;var Gf="TabsContent",H0=j.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=rc(Gf,n),c=Qf(a.baseId,r),f=Xf(a.baseId,r),d=r===a.value,l=j.useRef(d);return j.useEffect(()=>{const m=requestAnimationFrame(()=>l.current=!1);return()=>cancelAnimationFrame(m)},[]),u.jsx(Ya,{present:o||d,children:({present:m})=>u.jsx(Nn.div,{"data-state":d?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:f,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:l.current?"0s":void 0},children:m&&i})})});H0.displayName=Gf;function Qf(e,t){return`${e}-trigger-${t}`}function Xf(e,t){return`${e}-content-${t}`}var B0=Hf,J0=Jf,Yf=zf;const W0=u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[u.jsx("circle",{cx:"9",cy:"9",r:"9",fill:"#BBF7D0"}),u.jsx("path",{d:"M13 7L7.5 12L5 9.72727",stroke:"#16A34A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function z0(e,t){return t?b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none"},b.createElement("circle",{cx:"9",cy:"9",r:"5",fill:"#FBD38D"})):e?W0:u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:u.jsx("circle",{cx:"9",cy:"9",r:"5",fill:"#BFDBFE"})})}function G0(){return u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.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"}),u.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 Q0="_tabsRoot_ktpr0_1",X0="_tabsList_ktpr0_6",Y0="_tabTrigger_ktpr0_12",Do={tabsRoot:Q0,tabsList:X0,tabTrigger:Y0};function Z0(){return u.jsxs(u.Fragment,{children:[u.jsx(Ho,{style:{margin:"1rem 0"}}),u.jsx(Yf,{value:Oo,className:Do.tabTrigger,children:u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[u.jsx(G0,{}),u.jsx("span",{children:"Manage"})]})})]})}function Zf({objectName:e,completed:t,pending:n,displayName:r}){return u.jsx(Yf,{value:e,className:Do.tabTrigger,children:u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem",marginRight:".5rem"},children:[z0(t,n),u.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[u.jsx("span",{children:r||e}),n&&u.jsx("span",{style:{fontSize:".8rem",fontStyle:"italic"},children:"pending"})]})]})})}function eO({completed:e,pending:t,displayName:n}){return u.jsxs(u.Fragment,{children:[u.jsx(Ho,{style:{margin:"1rem 0"}}),u.jsx(Zf,{objectName:Er,completed:e,pending:t,displayName:n},"other-write")]})}function tO({value:e,readNavObjects:t,onValueChange:n,objectConfigurationsState:r,writeNavObject:o}){var i,s;return u.jsx(B0,{value:e,className:Do.tabsRoot,onValueChange:n,children:u.jsxs(J0,{className:Do.tabsList,children:[t.map(a=>{var c,f,d,l,m,g;return u.jsx(Zf,{objectName:a.name,displayName:a.displayName,completed:a.completed,pending:((f=(c=r==null?void 0:r[a.name])==null?void 0:c.read)==null?void 0:f.isOptionalFieldsModified)||((l=(d=r==null?void 0:r[a.name])==null?void 0:d.read)==null?void 0:l.isRequiredMapFieldsModified)||((g=(m=r==null?void 0:r[a.name])==null?void 0:m.read)==null?void 0:g.isValueMappingsModified)||!1},a.name)}),o&&u.jsx(eO,{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"}),u.jsx(Z0,{})]})})}function nO(e,t){return t===Oo?{name:Oo,completed:!1}:e.find(n=>n.name===t)}function rO({children:e}){var S;const{data:t}=tr(),{installation:n}=Ze(),{providerName:r}=ut(),{hydratedRevision:o}=di(),{objectConfigurationsState:i}=Ea(),[s,a]=b.useState(""),c=(t==null?void 0:t.appName)||"",f=n==null?void 0:n.config,d=o&&Yl(f,o),l=d!==null,m=!!((S=o==null?void 0:o.content)!=null&&S.write),g=m?Zl(f):void 0,v=b.useMemo(()=>{const p=[...d||[]];return g&&m&&p.push(g),p},[d,g,m]),w=nO(v,s),h=b.useCallback(()=>{const p=v.find(y=>w!==y&&!y.completed);p&&a(p.name)},[v,w]);return b.useEffect(()=>{!s&&v.length>0&&a(v[0].name)},[v,s,h]),u.jsx(wd.Provider,{value:h,children:u.jsx(yd.Provider,{value:w==null?void 0:w.name,children:u.jsxs(ui,{style:{maxWidth:"55rem"},children:[u.jsxs(_n,{style:{display:"flex",gap:"1rem",padding:"3rem",paddingBottom:"6rem",backgroundColor:"var(--amp-colors-bg-primary)"},children:[u.jsxs("div",{style:{width:"20rem"},children:[u.jsxs("h1",{style:{fontSize:"small",fontWeight:"400"},children:[r," integration"]}),u.jsx("h3",{style:{marginBottom:"20px",fontSize:"large",fontWeight:"500"},children:c}),l&&u.jsx(tO,{value:s,readNavObjects:d,onValueChange:p=>a(p),objectConfigurationsState:i,writeNavObject:g})]}),e]}),u.jsx(dd,{})]})})})}function iO({...e}){return u.jsx(rO,{...e})}const oO="_resetContainer_lkwv9_4",ep={resetContainer:oO},sO=({integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c})=>{var S;const{projectIdOrName:f,isLoading:d}=tr(),{isLoading:l}=$o(),{isError:m,errorState:g}=qt(),{seed:v,reset:w}=Gl(),{options:h}=Pe();return h.getToken?(console.error("JWT authentication is not supported in InstallIntegration. Please use API key authentication instead."),u.jsx($t,{message:"JWT authentication is not supported in InstallIntegration. Please use API key authentication instead."})):d||l?u.jsx(li,{}):m(ue.PROJECT,f)?u.jsx($t,{message:`Error loading project ${f}`}):m(ue.INTEGRATION_LIST,f)?u.jsx($t,{message:"Error retrieving integrations for the project, double check the API key"}):(S=g[ue.INTEGRATION_LIST])!=null&&S.apiError?u.jsx($t,{message:"Something went wrong, couldn't find integration information"}):u.jsx("div",{className:ep.resetContainer,children:u.jsx(cb,{integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c,resetComponent:w,children:u.jsx(Jl,{children:u.jsx(Df,{consumerRef:t,consumerName:n,groupRef:r,groupName:o,resetComponent:w,children:u.jsx(hI,{resetComponent:w,children:u.jsx(n0,{children:u.jsx(yI,{children:u.jsx(iO,{children:u.jsx(Yx,{})})})})})})})},v)})};function aO({integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c}){const f={integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onInstallSuccess:i,onUpdateSuccess:s,onUninstallSuccess:a,fieldMapping:c};return u.jsx(ba,{integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:u.jsx(sO,{...f})})}function cO(){return u.jsxs(ui,{style:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[u.jsx(Ni,{}),u.jsx("p",{children:"Redirecting"})]})}function uO({redirectURL:e,children:t}){return b.useEffect(()=>{e&&window.location.replace(e)},[e]),e?u.jsx(cO,{}):t}function lO({resetComponent:e,onDisconnectSuccess:t,provider:n}){const[r,o]=b.useState(!1);return u.jsxs(u.Fragment,{children:[r===!1&&u.jsxs(u.Fragment,{children:[u.jsx(Rt,{string:"Manage connection"}),u.jsxs("div",{style:{padding:"1rem 0",width:"100%",display:"flex",flexDirection:"column",gap:"1rem"},children:[u.jsx("p",{children:"Click to reauthenticate or refresh your connection."}),u.jsx(Be,{type:"button",onClick:()=>o(!0),variant:"ghost",style:{fontSize:"13px"},children:"Update connection"})]})]}),r===!0&&u.jsxs(u.Fragment,{children:[u.jsx(Oa,{provider:n}),u.jsx(Af,{resetComponent:e,onDisconnectSuccess:t})]})]})}function dO({provider:e,onDisconnectSuccess:t,resetComponent:n}){const{appName:r}=tr(),{providerName:o}=ut(e),i=`You have successfully connected your ${o} account to ${r}.`;return u.jsx(nc,{text:i,children:u.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",width:"100%"},children:u.jsx(lO,{resetComponent:n,onDisconnectSuccess:t,provider:e})})})}function fO({provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,redirectUrl:i,onSuccess:s,onDisconnectSuccess:a,onConnectSuccess:c}){const{seed:f,reset:d}=Gl(),l=b.useCallback(m=>{s?s(m.id):c&&c(m)},[s,c]);return u.jsx("div",{className:ep.resetContainer,children:u.jsx(ba,{integration:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,children:u.jsx(Jl,{groupRef:r,provider:e,children:u.jsx(Df,{resetComponent:d,provider:e,consumerRef:t,consumerName:n,groupRef:r,groupName:o,onSuccess:l,onDisconnectSuccess:a,children:u.jsx(uO,{redirectURL:i,children:u.jsx(dO,{resetComponent:d,provider:e,onDisconnectSuccess:a})})})})})},f)}const pO=(e,t)=>{const{data:n,isLoading:r,isError:o,error:i}=va(e,t),s=((n==null?void 0:n.length)||0)>0,a=!!n&&!r,c=n==null?void 0:n[0],f=c==null?void 0:c.config;return b.useEffect(()=>{o&&$e(i)},[o,i]),{isLoaded:a,isIntegrationInstalled:s,isLoading:r,config:f}};exports.AmpersandContext=pa;exports.AmpersandProvider=Xh;exports.ConnectProvider=fO;exports.FieldSettingWriteOnCreateEnum=Lm;exports.FieldSettingWriteOnUpdateEnum=jm;exports.InstallIntegration=aO;exports.InstallationProvider=ba;exports.useAmpersandProviderProps=Pe;exports.useConfig=Kw;exports.useConnection=wa;exports.useCreateInstallation=zl;exports.useDeleteInstallation=hb;exports.useInstallation=ki;exports.useIsIntegrationInstalled=pO;exports.useManifest=Fl;exports.useUpdateInstallation=fb;
|
|
52
52
|
//# sourceMappingURL=amp-react.cjs.js.map
|