@hiver/connector-admin 4.22.0-ghlSubAccountMapping-beta.5 → 4.22.0-ghlSubAccountMapping-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/connector-library/components/sub-account-mapping/index.tsx"],"names":[],"mappings":"AAwBA,UAAU,sBAAsB;IAC9B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,sBAAuB,sBAAsB,mDAuJ1E,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/connector-library/components/sub-account-mapping/index.tsx"],"names":[],"mappings":"AAwBA,UAAU,sBAAsB;IAC9B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,sBAAuB,sBAAsB,mDAqJ1E,CAAC"}
@@ -170,11 +170,11 @@ export declare const chipStripSx: {
170
170
  /** Menu surface for the field above — kit defaults are 4px radius, no border. */
171
171
  export declare const tagsMenuProps: {
172
172
  anchorOrigin: {
173
- vertical: "top";
173
+ vertical: "bottom";
174
174
  horizontal: "left";
175
175
  };
176
176
  transformOrigin: {
177
- vertical: "bottom";
177
+ vertical: "top";
178
178
  horizontal: "left";
179
179
  };
180
180
  PaperProps: {
package/index.es.js CHANGED
@@ -35835,13 +35835,13 @@ const UV = F(Ee)`
35835
35835
  }
35836
35836
  }
35837
35837
  }, dG = {
35838
- // Open upward. Dropping down, the menu for the lower rows covered Cancel and
35839
- // Save, the only way out of the modal while it is open (QA R1 P3).
35840
- anchorOrigin: { vertical: "top", horizontal: "left" },
35841
- transformOrigin: { vertical: "bottom", horizontal: "left" },
35838
+ // Always open downward, directly under the field. Anchoring explicitly also
35839
+ // stops MUI's default of laying the menu over the field itself.
35840
+ anchorOrigin: { vertical: "bottom", horizontal: "left" },
35841
+ transformOrigin: { vertical: "top", horizontal: "left" },
35842
35842
  PaperProps: {
35843
35843
  sx: {
35844
- marginTop: "-4px",
35844
+ marginTop: "4px",
35845
35845
  maxHeight: "240px",
35846
35846
  borderRadius: dt.radius.md,
35847
35847
  border: `1px solid ${dt.color.borderSubtle}`,
@@ -36081,9 +36081,7 @@ const UV = F(Ee)`
36081
36081
  Q4(e),
36082
36082
  m4(e)
36083
36083
  ]);
36084
- C || (B.status === "fulfilled" ? o(
36085
- ((E = B.value.data) == null ? void 0 : E.locations) ?? []
36086
- ) : (o([]), console.error(B.reason)), I.status === "fulfilled" ? i(((Q = I.value.data) == null ? void 0 : Q.mapping) ?? {}) : (i({}), console.error(I.reason)), s(!1));
36084
+ C || (B.status === "fulfilled" ? o(((E = B.value.data) == null ? void 0 : E.locations) ?? []) : (o([]), console.error(B.reason)), I.status === "fulfilled" ? i(((Q = I.value.data) == null ? void 0 : Q.mapping) ?? {}) : (i({}), console.error(I.reason)), s(!1));
36087
36085
  })(), () => {
36088
36086
  C = !0;
36089
36087
  };
package/index.umd.js CHANGED
@@ -2017,7 +2017,7 @@ https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof e.getDerivedStat
2017
2017
  height: 18px;
2018
2018
  width: 18px;
2019
2019
  color: var(--connector-admin-accent);
2020
- `,HV=({upgradeGuideContent:e,upgradeGuideLink:t})=>u.jsxs(RV,{children:[u.jsxs(g.Stack,{marginBottom:"20px",children:[u.jsxs(g.Stack,{direction:"row",padding:"8px 0",gap:"4px",alignItems:"center",children:[u.jsx(kV,{}),u.jsx(g.Typography,{variant:"body1_medium",color:"var(--connector-admin-text-primary)",children:hj})]}),u.jsx(g.Typography,{variant:"body2",children:Qj})]}),u.jsx(g.Typography,{variant:"body2_medium",marginBottom:"8px",color:"var(--connector-admin-text-primary)",children:mj}),u.jsx(VV,{variant:"body2",dangerouslySetInnerHTML:{__html:e}}),t?u.jsxs(jV,{target:"_blank",underline:"none",href:t,children:[u.jsx(GV,{}),bj]}):null]}),G0=(e,t)=>{const n=t.authType===yi,r=t.authType===Vp,o=t.authType===Aa,A=t.authType===bi;if(!e||!e.data)return{authUrl:"",authStatus:r?qe.API_KEY_FAILED:n?qe.BASIC_AUTH_FAILED:o?qe.OAUTH1_FAILED:qe.OAUTH_FAILED};const a=e.data;return r?{authUrl:"",id:a.id,authStatus:qe.API_KEY_SUCCESS}:n?{authUrl:"",id:a.id,authStatus:qe.BASIC_AUTH_SUCCESS}:o?{authUrl:"",id:a.id,authStatus:qe.OAUTH1_SUCCESS}:A?{authUrl:"",id:a.id,authStatus:qe.OAUTH_SUCCESS}:a.authorizationUrl?{authUrl:a.authorizationUrl,id:a.id,authStatus:qe.PENDING}:{authUrl:"",id:"",authStatus:qe.OAUTH_FAILED}},WV=async e=>{try{const t=await Ue({url:_S,method:nt.POST,data:e});return G0(t,e.authDetails)}catch(t){return Promise.reject(t)}},zV=async(e,t)=>{try{const n=RS.replace("{{id}}",t),r=await Ue({url:n,method:nt.PATCH,data:e});return G0(r,e.authDetails)}catch(n){return Promise.reject(n)}},YV=({connectorId:e,onSuccess:t})=>{const n=ho(),r=y.useMemo(()=>["authDetails",{connectorId:e}],[e]),{data:o}=Qo({queryKey:r,queryFn:()=>Promise.resolve({authUrl:"",authStatus:qe.IDLE,id:""}),enabled:!1}),A=oA({mutationFn:i=>"connectorId"in i?zV(i.data,i.connectorId):WV(i.data),onSuccess:i=>{n.setQueryData(r,i),t==null||t(i)}});y.useEffect(()=>()=>{n.removeQueries({queryKey:r,exact:!0})},[n,r]);const a=y.useCallback(i=>{n.setQueryData(r,s=>s&&{...s,authStatus:i})},[r,n]);return{mutate:A.mutate,mutateAsync:A.mutateAsync,isLoading:A.isPending,data:o,mutateStatus:a}},so={SUCCESS:"success",PENDING:"pending",FAILED:"failed"},JV=500,XV=1e3,ZV=[{afterMs:3*60*1e3,intervalMs:3e3},{afterMs:60*1e3,intervalMs:2e3}],UV=e=>{var t;return((t=ZV.find(n=>e>=n.afterMs))==null?void 0:t.intervalMs)??XV},yC=e=>["authSuccessStatus",{connectorId:e}],H0=e=>e===so.SUCCESS||e===so.FAILED,qV=async(e,t)=>{var n;try{const r=await Ue({url:Ft(jS,{connectorId:e}),method:nt.GET}),o=(n=r==null?void 0:r.data)==null?void 0:n.status;return!r||!o?{status:t?so.PENDING:so.FAILED}:t&&!H0(o)&&o!==so.PENDING?{status:so.PENDING}:r==null?void 0:r.data}catch(r){return Promise.reject(r)}},KV=({connectorId:e,enabled:t=!1,unknownAsPending:n=!1,backOff:r=!1,startedAt:o=0})=>{const A=ho(),a=y.useMemo(()=>yC(e),[e]),i=Qo({queryKey:a,queryFn:()=>qV(e,n),refetchInterval:s=>{var c;return H0((c=s.state.data)==null?void 0:c.status)?!1:r?UV(o?Date.now()-o:0):JV},enabled:t,refetchOnWindowFocus:!1,refetchIntervalInBackground:!0});return y.useEffect(()=>()=>{A.removeQueries({queryKey:a,exact:!0})},[A,a]),i},$V=1e3,eG=e=>{var n;const t=(n=e.data)==null?void 0:n.status;return t==="success"||t==="failed"||e.data===bl||e.data===IC},W0=({connectorData:e})=>{const{sendTrackingEvent:t,availableFeatures:n}=y.useContext(at),[r,o]=y.useState(!1),A=Se(lA),a=Se(_u),i=y.useRef(null),s=fn(),{id:c=""}=cA(),[l]=ea(),C=l.get("isEdit")==="true",Q=KQ(),h=ul({id:c,isEdit:C,row:e}),I=y.useRef(h);I.current=h;const E=y.useRef(null),d=y.useCallback(($,ge)=>{E.current!==ge&&(E.current=ge,Q($,{...I.current,auth_status:ge}))},[Q]),B=!!(e!=null&&e.showUpgradeButton),p=Fn(n,Fv),f=Fn(n,Mv),m=ho(),[v,w]=y.useState(0),x=y.useRef(null),b=y.useCallback(()=>{var $;try{($=i.current)==null||$.close()}catch{}i.current=null},[]),{data:T,mutateStatus:M,isLoading:_,mutate:R}=YV({connectorId:c,onSuccess:$=>{var ye;if(p&&o(!0),!f)return;const ge=($==null?void 0:$.id)||"";if(ge&&m.removeQueries({queryKey:yC(ge),exact:!0}),!!($!=null&&$.authUrl))try{if(b(),i.current=window.open($.authUrl,"_blank"),!i.current){(ye=x.current)==null||ye.call(x,qe.IDLE),rt({message:fj,type:Nt});return}w(Date.now())}catch(de){pt.log("Error in Authentication",de)}}});x.current=M;const F=(T==null?void 0:T.authStatus)||qe.IDLE,O=(T==null?void 0:T.authUrl)||"",j=KV({connectorId:(T==null?void 0:T.id)||"",enabled:f?v>0&&!!(T!=null&&T.id):r,unknownAsPending:f,backOff:f,startedAt:v}),{status:W}=j.data||{},ne=Qn(),K=y.useRef((T==null?void 0:T.id)||"");K.current=(T==null?void 0:T.id)||"";const U=y.useRef(0),V=y.useRef(!1);V.current=j.isFetching;const Z=y.useCallback(()=>{const $=K.current;if(!$||V.current)return;const ge=Date.now();ge-U.current<$V||(U.current=ge,m.invalidateQueries({queryKey:yC($)}))},[m]),G=y.useRef(W);y.useEffect(()=>{G.current=W},[W]),y.useEffect(()=>()=>{ne(zS())},[ne]),y.useEffect(()=>{if(f)return;let $,ge;const ye=de=>{var Me;if(i.current){if(p){if(de.source!==i.current)return;const X=(Me=de.data)==null?void 0:Me.status;(X==="success"||X==="failed")&&(clearTimeout($),clearInterval(ge),i.current.close(),i.current=null,M(X==="success"?qe.OAUTH_SUCCESS:qe.OAUTH_FAILED));return}de.origin===window.location.origin&&(de.data===IC||de.data===bl)&&(clearTimeout($),i.current.close(),i.current=null,M(de.data===bl?qe.OAUTH_SUCCESS:qe.OAUTH_FAILED))}};try{if(O){i.current=window.open(O,"_blank");const de=5*60*1e3;$=setTimeout(()=>{var Me;(Me=i.current)==null||Me.close(),i.current=null,M(qe.OAUTH_FAILED)},de),ge=setInterval(()=>{var X;if(!((X=i.current)!=null&&X.closed))return;if(clearInterval(ge),!p){i.current=null,M(qe.OAUTH_FAILED);return}const Me=()=>{i.current&&(i.current=null,M(G.current==="success"?qe.OAUTH_SUCCESS:qe.OAUTH_FAILED))};G.current==="success"||G.current==="failed"?Me():setTimeout(Me,1500)},500),window.addEventListener("message",ye)}}catch(de){pt.log("Error in Authentication",de)}return()=>{window.removeEventListener("message",ye),clearTimeout($),clearInterval(ge)}},[O,ne,M,p,f]),y.useEffect(()=>{f||W&&W!=="pending"&&i.current&&p&&(i.current.close(),i.current=null,M(W==="success"?qe.OAUTH_SUCCESS:qe.OAUTH_FAILED))},[W,M,p,f]),y.useEffect(()=>{!f||v===0||W!==so.SUCCESS&&W!==so.FAILED||(b(),w(0),M(W===so.SUCCESS?qe.OAUTH_SUCCESS:qe.OAUTH_FAILED))},[W,b,M,f,v]),y.useEffect(()=>{if(!f||v===0)return;const $=ye=>{eG(ye)&&Z()};window.addEventListener("message",$);const ge=setTimeout(()=>{w(0),M(qe.IDLE),rt({message:Ej,type:Nt})},Cj);return()=>{window.removeEventListener("message",$),clearTimeout(ge)}},[f,v,M,Z]),y.useEffect(()=>{if(!f||v===0)return;const $=()=>{document.visibilityState==="visible"&&Z()};return document.addEventListener("visibilitychange",$),()=>document.removeEventListener("visibilitychange",$)},[f,v,Z]),y.useEffect(()=>{switch((F===qe.OAUTH1_FAILED||F===qe.OAUTH_FAILED||F===qe.API_KEY_FAILED||F===qe.BASIC_AUTH_FAILED)&&s(Fe.BASEPATH),(F===qe.OAUTH1_SUCCESS||F===qe.OAUTH_SUCCESS||F===qe.API_KEY_SUCCESS||F===qe.BASIC_AUTH_SUCCESS)&&T!=null&&T.id&&s(C?Fe.BASEPATH:`${Fe.BASEPATH}${Fe.CONNECTOR_INITIAL_SETUP}/${c}?connectorId=${T.id}`),F){case qe.BASIC_AUTH_SUCCESS:case qe.OAUTH1_SUCCESS:case qe.OAUTH_SUCCESS:{rt({message:B?v0:uj,type:Mn}),t(We.CONNECTOR_AUTH_SUCCESS,{connector_name:e==null?void 0:e.name}),d(lr.AUTHENTICATION_SUCCESS,F);break}case qe.BASIC_AUTH_FAILED:case qe.OAUTH1_FAILED:case qe.OAUTH_FAILED:{rt({message:B?x0:gj,type:Nt}),d(lr.AUTHENTICATION_FAILURE,F);break}case qe.REQUEST_FAILED:{rt({message:qs,type:Nt}),d(lr.AUTHENTICATION_FAILURE,F);break}case qe.API_KEY_SUCCESS:{rt({message:B?v0:Ij,type:Mn}),t(We.CONNECTOR_AUTH_SUCCESS,{connector_name:e==null?void 0:e.name}),d(lr.AUTHENTICATION_SUCCESS,F);break}case qe.API_KEY_FAILED:{rt({message:B?x0:qs,type:Nt}),d(lr.AUTHENTICATION_FAILURE,F);break}}},[F,s,B,c,C,e==null?void 0:e.name,t,d,T==null?void 0:T.id]);const H=A===pe.LOADING||a===pe.LOADING,{name:ae="",type:ue="",advancedFeatures:se={}}=e||{};return u.jsxs(u.Fragment,{children:[u.jsxs(NV,{direction:"row",id:"connectors-auth-page",style:C?{height:"auto"}:void 0,children:[u.jsx("div",{className:"flex flex-col",children:u.jsx(eV,{connectorId:c,isEdit:C,connectorData:e,authStatus:F,isLoading:H,authMutate:R,isAuthPending:_})}),u.jsxs(g.Stack,{gap:"36px",width:"322px",className:"connector-auth-help",children:[e!=null&&e.upgradeGuideContent?u.jsx(HV,{upgradeGuideContent:e.upgradeGuideContent,upgradeGuideLink:e.upgradeGuideLink}):null,u.jsxs(g.Stack,{gap:"12px",children:[u.jsx(g.Typography,{variant:"h2",marginBottom:"8px",children:Gp}),C?null:u.jsx(vc,{isSettingsPage:!0}),u.jsx(V0,{connectorName:e==null?void 0:e.name,supportLinks:e==null?void 0:e.supportLinks})]})]})]}),C&&u.jsx(j0,{advancedFeatures:se,connectorId:c,connectorName:ae,connectorType:ue,featureIds:[Zi],soloSpansFullWidth:!1})]})},tG=e=>S.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.createElement("g",{clipPath:"url(#clip0_1446_4479)"},S.createElement("path",{d:"M11.3333 2H3.33333C2.59333 2 2 2.6 2 3.33333V12.6667C2 13.4 2.59333 14 3.33333 14H12.6667C13.4 14 14 13.4 14 12.6667V4.66667L11.3333 2ZM8 12.6667C6.89333 12.6667 6 11.7733 6 10.6667C6 9.56 6.89333 8.66667 8 8.66667C9.10667 8.66667 10 9.56 10 10.6667C10 11.7733 9.10667 12.6667 8 12.6667ZM10 6H3.33333V3.33333H10V6Z",fill:"white"})),S.createElement("defs",null,S.createElement("clipPath",{id:"clip0_1446_4479"},S.createElement("rect",{width:16,height:16,fill:"white"})))),z0=e=>S.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.86993 0.652446C7.56922 0.248711 8.43078 0.248711 9.13007 0.652446L13.7981 3.34755C14.4974 3.75129 14.9282 4.49742 14.9282 5.30489V10.6951C14.9282 11.5026 14.4974 12.2487 13.7981 12.6524L9.13007 15.3476C8.43078 15.7513 7.56922 15.7513 6.86993 15.3476L2.20187 12.6524C1.50258 12.2487 1.0718 11.5026 1.0718 10.6951V5.30489C1.0718 4.49742 1.50258 3.75129 2.20187 3.34755L6.86993 0.652446Z",fill:"#FFD122"}),S.createElement("g",{filter:"url(#filter0_d_360_39563)"},S.createElement("path",{d:"M5.83154 4.43359V4.43359C6.84296 4.43359 7.66287 5.25351 7.66287 6.26492V11.5179V11.5179C6.65146 11.5179 5.83154 10.698 5.83154 9.68661V4.43359Z",fill:"white"})),S.createElement("g",{filter:"url(#filter1_d_360_39563)"},S.createElement("path",{d:"M8.57812 7.66211V7.66211C9.58954 7.66211 10.4095 8.48202 10.4095 9.49343V11.7103V11.7103C9.39804 11.7103 8.57812 10.8904 8.57812 9.87898V7.66211Z",fill:"white"})),S.createElement("defs",null,S.createElement("filter",{id:"filter0_d_360_39563",x:4.76488,y:3.36693,width:3.96488,height:9.21732,filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB"},S.createElement("feFlood",{floodOpacity:0,result:"BackgroundImageFix"}),S.createElement("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),S.createElement("feOffset",null),S.createElement("feGaussianBlur",{stdDeviation:.533333}),S.createElement("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.114019 0"}),S.createElement("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_360_39563"}),S.createElement("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow_360_39563",result:"shape"})),S.createElement("filter",{id:"filter1_d_360_39563",x:7.51146,y:6.59544,width:3.96488,height:6.18216,filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB"},S.createElement("feFlood",{floodOpacity:0,result:"BackgroundImageFix"}),S.createElement("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),S.createElement("feOffset",null),S.createElement("feGaussianBlur",{stdDeviation:.533333}),S.createElement("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.114019 0"}),S.createElement("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_360_39563"}),S.createElement("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow_360_39563",result:"shape"})))),nG=({connectorId:e,connectorName:t,connectorLogo:n})=>{const{sendTrackingEvent:r}=y.useContext(at),[o,A]=y.useState(null),[a,i]=y.useState([]),[s,c]=y.useState(!1),[l,C]=y.useState(""),[Q,h]=y.useState(!0),[I,E]=y.useState(!1);if(y.useEffect(()=>{(async()=>{var w;h(!0);try{const[x,b]=await Promise.all([IS(e),pS(e)]);A(x.data??null),i(((w=b.data)==null?void 0:w.presets)??[])}catch(x){rt({message:qs,type:Nt}),pt.error(x)}finally{h(!1)}})()},[e]),Q||a.length===0)return null;const d=a.find(v=>v.hiverParam===(o==null?void 0:o.hiverParam))??a[0],B=()=>{var x;r(We.LOOKUP_CONFIG_CLICKED,{connector_name:t,page:"connector_settings"});const v=(o==null?void 0:o.hiverParam)??d.hiverParam,w=a.some(b=>b.hiverParam===v);C(w?v:((x=a[0])==null?void 0:x.hiverParam)??""),c(!0)},p=async()=>{E(!0);try{await BS([{connectorId:e,hiverParam:l}]),A({connectorId:e,hiverParam:l}),r(We.LOOKUP_SAVED,{connector_name:t,hiver_param:l,page:"connector_settings"}),rt({message:qT,type:Mn}),c(!1)}catch{rt({message:KT,type:Nt})}finally{E(!1)}},f=UT.replace("%s",t),m=a.find(v=>v.hiverParam===(l||(o==null?void 0:o.hiverParam)))??a[0];return u.jsxs("div",{className:"border border-gray-5 rounded-lg bg-white p-4 mb-6",children:[u.jsxs("div",{className:"flex items-center justify-between mb-1",children:[u.jsx("span",{className:"text-h2 text-gray-1!",children:YT}),s?u.jsx(g.Button,{variant:"contained",size:"small",startIcon:u.jsx(tG,{}),onClick:p,disabled:I,children:ZT}):u.jsx(g.Button,{variant:"outlined",color:"tertiary",size:"small",onClick:B,children:XT})]}),u.jsx("p",{className:"text-body2 text-gray-3! mb-6",children:JT}),s?u.jsxs("div",{className:"inline-flex items-center border border-gray-6 overflow-hidden p-3 rounded-[8px] w-full",children:[u.jsx(g.Select,{value:l,onChange:v=>{const w=v.target.value;r(We.LOOKUP_FIELD_CLICKED,{hiver_param:w,connector_name:t,page:"connector_settings"}),C(w)},size:"small",variant:"outlined",renderValue:v=>{var x;const w=((x=a.find(b=>b.hiverParam===v))==null?void 0:x.label)??"";return u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(z0,{className:"w-4 h-4 shrink-0"}),w]})},sx:{fontSize:`${g.theme.typography.body1.fontSize}px`,width:"209px",height:"40px",background:"var(--connector-admin-surface-subtle)",borderRadius:"8px",fontWeight:g.theme.typography.fontWeightMedium,"& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--connector-admin-border)"}},children:a.map(v=>u.jsx(g.MenuItem,{value:v.hiverParam,sx:{fontSize:`${g.theme.typography.body1.fontSize}px`},children:v.label},v.hiverParam))}),u.jsx("div",{className:"h-px w-8 bg-gray-6 shrink-0"}),u.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 text-sm text-gray-2 rounded-full border-1 border-gray-6 h-[26px]",children:[n&&u.jsx("img",{src:n,alt:t,className:"w-4 h-4 object-contain shrink-0"}),f]}),u.jsx("div",{className:"h-px w-8 bg-gray-6 shrink-0"}),u.jsx("div",{className:"px-4 py-2.5 text-sm text-gray-2 bg-gray-6a rounded-[8px] h-10 grow",children:m.objectParamLabel})]}):u.jsxs("div",{className:"inline-flex items-center border border-gray-6 overflow-hidden p-3 rounded-[8px] w-full",children:[u.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 text-sm text-gray-2 rounded-[8px] font-medium bg-gray-6a w-[209px] h-10",children:[u.jsx(z0,{className:"w-4 h-4 shrink-0"}),m.label]}),u.jsx("div",{className:"h-px w-8 bg-gray-6 shrink-0"}),u.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 text-sm text-gray-2 rounded-full border-1 border-gray-6 h-[26px]",children:[n&&u.jsx("img",{src:n,alt:t,className:"w-4 h-4 object-contain shrink-0"}),f]}),u.jsx("div",{className:"h-px w-8 bg-gray-6 shrink-0"}),u.jsx("div",{className:"px-4 py-2.5 text-sm text-gray-2 bg-gray-6a rounded-[8px] h-10 grow",children:m.objectParamLabel})]})]})},rG=e=>S.createElement("svg",{width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.createElement("path",{d:"M12.75 15H12.6C11.3399 15 10.7098 15 10.2285 14.7548C9.80516 14.539 9.46095 14.1948 9.24524 13.7715C9 13.2902 9 12.6601 9 11.4V6.6C9 5.33988 9 4.70982 9.24524 4.22852C9.46095 3.80516 9.80516 3.46095 10.2285 3.24524C10.7098 3 11.3399 3 12.6 3H12.75M12.75 15C12.75 15.8284 13.4216 16.5 14.25 16.5C15.0784 16.5 15.75 15.8284 15.75 15C15.75 14.1716 15.0784 13.5 14.25 13.5C13.4216 13.5 12.75 14.1716 12.75 15ZM12.75 3C12.75 3.82843 13.4216 4.5 14.25 4.5C15.0784 4.5 15.75 3.82843 15.75 3C15.75 2.17157 15.0784 1.5 14.25 1.5C13.4216 1.5 12.75 2.17157 12.75 3ZM5.25 9L12.75 9M5.25 9C5.25 9.82843 4.57843 10.5 3.75 10.5C2.92157 10.5 2.25 9.82843 2.25 9C2.25 8.17157 2.92157 7.5 3.75 7.5C4.57843 7.5 5.25 8.17157 5.25 9ZM12.75 9C12.75 9.82843 13.4216 10.5 14.25 10.5C15.0784 10.5 15.75 9.82843 15.75 9C15.75 8.17157 15.0784 7.5 14.25 7.5C13.4216 7.5 12.75 8.17157 12.75 9Z",stroke:"currentColor",strokeWidth:1.33,strokeLinecap:"round",strokeLinejoin:"round"})),oG=e=>S.createElement("svg",{width:20,height:20,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.createElement("g",{id:"Icons/Line/arrow-right"},S.createElement("path",{id:"Icon",d:"M4.16667 10H15.8333M10 15.8333L15.8333 10L10 4.16667",stroke:"currentColor",strokeWidth:1.41667,strokeLinecap:"round",strokeLinejoin:"round"}))),AG=e=>S.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.createElement("g",{id:"Icon"},S.createElement("path",{id:"Icon_2",d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:1.33,strokeLinecap:"round",strokeLinejoin:"round"}))),aG=e=>S.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.createElement("g",{id:"Icon"},S.createElement("path",{id:"Icon_2",d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:1.33,strokeLinecap:"round",strokeLinejoin:"round"}))),Ui="'Inter', sans-serif",At={color:{surface:"var(--connector-admin-surface)",surfaceSubtle:"var(--connector-admin-surface-subtle)",surfaceSoft:"var(--connector-admin-surface-subtle)",borderSubtle:"var(--connector-admin-border)",borderSoft:"var(--connector-admin-border)",borderDefault:"var(--connector-admin-input-border)",textStrong:"var(--connector-admin-text-primary)",textDefault:"var(--connector-admin-text-secondary)",textSoft:"var(--connector-admin-text-tertiary)",textSubtle:"var(--connector-admin-input-placeholder)",tableHeader:"var(--connector-admin-text-tertiary)",tagBg:"var(--connector-admin-surface-hover)"},radius:{sm:"6px",md:"8px",lg:"16px"},shadow:"0px 2px 4px -2px rgba(16, 24, 40, 0.06), 0px 4px 8px -2px rgba(16, 24, 40, 0.1)",font:{titleMd:{fontFamily:Ui,fontSize:"14px",lineHeight:"20px",fontWeight:500},titleLg:{fontFamily:Ui,fontSize:"16px",lineHeight:"24px",fontWeight:500},bodySm:{fontFamily:Ui,fontSize:"13px",lineHeight:"19px",fontWeight:400},labelSm:{fontFamily:Ui,fontSize:"13px",lineHeight:"19px",fontWeight:500},placeholder:{fontFamily:Ui,fontSize:"14px",lineHeight:"20px",fontWeight:400},columnHeader:{fontFamily:"'Open Sans', sans-serif",fontSize:"13px",lineHeight:"16px",fontWeight:600}}},iG={width:"100%",height:"40px",background:"var(--connector-admin-input-background)",borderRadius:At.radius.md,border:`1px solid ${At.color.borderDefault}`,...At.font.bodySm,"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiSelect-select":{padding:"0 12px",height:"40px",display:"flex",alignItems:"center",overflow:"hidden",boxSizing:"border-box"},"& .MuiSelect-icon":{width:"16px",height:"16px",right:"12px",top:"calc(50% - 8px)",pointerEvents:"none"}},sG={display:"flex",alignItems:"center",gap:"6px",flex:"1 1 0%",minWidth:0,overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none","&::-webkit-scrollbar":{height:0},"&:hover":{scrollbarWidth:"thin","&::-webkit-scrollbar":{height:"4px"},"&::-webkit-scrollbar-thumb":{borderRadius:"2px",backgroundColor:"var(--connector-admin-scrollbar)"}}},cG={anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},PaperProps:{sx:{marginTop:"-4px",maxHeight:"240px",borderRadius:At.radius.md,border:`1px solid ${At.color.borderSubtle}`,boxShadow:At.shadow,"& .MuiMenuItem-root":{...At.font.bodySm,color:At.color.textDefault,minHeight:"36px",gap:"8px"}}}},Y0=e=>u.jsx(AG,{...e,width:16,height:16,style:{color:"var(--connector-admin-icon-secondary)"}}),J0=(e,t)=>e.localeCompare(t,void 0,{sensitivity:"base"}),lG=({label:e})=>u.jsx("span",{className:"flex max-h-[22px] max-w-[96px] shrink-0 items-center justify-center gap-1 rounded-md px-1.5 py-0.5",style:{background:At.color.tagBg},children:u.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",style:{...At.font.labelSm,color:At.color.textDefault},title:e,children:e})}),uG=({selected:e,subAccounts:t,atLimit:n,subAccountName:r,onChange:o})=>{const[A,a]=y.useState(!1),i=y.useMemo(()=>[...e].sort((c,l)=>J0(r(c),r(l))),[e,r]),s=e.length===0?u.jsx("span",{className:"min-w-0 flex-1",style:{...At.font.placeholder,color:At.color.textSubtle},children:i5}):u.jsx(g.Box,{sx:sG,children:i.map(c=>u.jsx(lG,{label:r(c)},c))});return A?u.jsx(g.Select,{multiple:!0,displayEmpty:!0,defaultOpen:!0,value:e,onChange:c=>o(c.target.value),onClose:()=>a(!1),IconComponent:Y0,MenuProps:cG,sx:iG,renderValue:()=>s,children:t.map(c=>{const l=e.includes(c.locationId);return u.jsxs(g.MenuItem,{value:c.locationId,disabled:n&&!l,children:[u.jsx(g.Checkbox,{checked:l,size:"small",sx:{padding:0}}),c.name]},c.locationId)})}):u.jsxs("button",{type:"button",onClick:()=>a(!0),className:"flex h-10 w-full cursor-pointer items-center gap-1.5 overflow-hidden rounded-lg px-3 text-left",style:{background:"var(--connector-admin-input-background)",border:`1px solid ${At.color.borderDefault}`},children:[s,u.jsx("span",{className:"flex shrink-0 items-center",children:u.jsx(Y0,{})})]})},gG=({shown:e,setShown:t,inboxes:n,subAccounts:r,mapping:o,isSaving:A,onSave:a})=>{const[i,s]=y.useState(o),c=y.useMemo(()=>[...r].sort((h,I)=>J0(h.name,I.name)),[r]),l=y.useMemo(()=>{const h=new Map(r.map(I=>[I.locationId,I.name]));return I=>h.get(I)??I},[r]),C=y.useMemo(()=>[...new Set([...Object.keys(o),...Object.keys(i)])].some(I=>{const E=[...o[I]??[]].sort().join(","),d=[...i[I]??[]].sort().join(",");return E!==d}),[o,i]),Q=()=>{s(o),t(!1)};return u.jsx(ro,{shown:e,setShown:t,onClose:Q,borderRadius:16,customPaperProps:{width:"640px",border:`1px solid ${At.color.borderSoft}`,boxShadow:At.shadow,overflow:"hidden"},children:u.jsxs("div",{className:"flex w-full flex-col",children:[u.jsxs("div",{className:"flex w-full items-center gap-3 px-5 py-3",style:{background:At.color.surfaceSoft,borderBottom:`1px solid ${At.color.borderSubtle}`},children:[u.jsx("p",{className:"min-w-0 flex-1",style:{...At.font.titleLg,color:At.color.textStrong},children:o5}),u.jsx("button",{type:"button","aria-label":"Close",onClick:Q,className:"flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-1.5",style:{color:"var(--connector-admin-icon-primary)"},children:u.jsx(aG,{width:16,height:16})})]}),u.jsx("div",{className:"flex w-full flex-col gap-6 p-5",children:u.jsxs("div",{className:"flex w-full flex-col overflow-hidden rounded-lg pb-1",style:{border:`1px solid ${At.color.borderSubtle}`},children:[u.jsxs("div",{className:"flex w-full items-center gap-2",style:{background:At.color.surfaceSubtle},children:[u.jsx("div",{className:"flex w-[186px] shrink-0 items-center py-4 pl-6 pr-4",children:u.jsx("span",{className:"whitespace-nowrap",style:{...At.font.columnHeader,color:At.color.tableHeader},children:A5})}),u.jsx("div",{className:"flex min-w-0 flex-1 items-center py-4 pl-10 pr-5",children:u.jsx("span",{className:"whitespace-nowrap",style:{...At.font.columnHeader,color:At.color.tableHeader},children:a5})})]}),u.jsx("div",{className:"max-h-[320px] w-full overflow-y-auto",children:n.map(h=>{const I=i[h.id]??[],E=I.length>=g5;return u.jsxs("div",{className:"flex h-16 w-full items-center gap-2",style:{borderTop:`1px solid ${At.color.borderSubtle}`},children:[u.jsx("div",{className:"flex w-[165px] shrink-0 items-center py-[22px] pl-6 pr-4",children:u.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",style:{...At.font.bodySm,color:At.color.textDefault},title:h.name,children:h.name})}),u.jsx(oG,{width:20,height:20,className:"shrink-0",style:{color:"var(--connector-admin-icon-secondary)"}}),u.jsx("div",{className:"flex min-w-0 flex-1 items-center py-3 pl-8 pr-4",children:u.jsx(uG,{selected:I,subAccounts:c,atLimit:E,subAccountName:l,onChange:d=>s(B=>({...B,[h.id]:d}))})})]},h.id)})})]})}),u.jsxs("div",{className:"flex w-full items-center justify-end gap-3 px-5 py-4",style:{background:At.color.surface,borderTop:`1px solid ${At.color.borderSubtle}`},children:[u.jsx(g.Button,{variant:"outlined",color:"tertiary",size:"small",onClick:Q,disabled:A,children:s5}),u.jsx(g.Button,{variant:"contained",size:"small",onClick:()=>a(i),disabled:!C||A,children:c5})]})]})})},dG=({connectorType:e})=>{const{sendTrackingEvent:t}=y.useContext(at),n=Se(no)??[],[r,o]=y.useState([]),[A,a]=y.useState({}),[i,s]=y.useState(!0),[c,l]=y.useState(!1),[C,Q]=y.useState(!1);y.useEffect(()=>{let E=!1;return(async()=>{var f,m;s(!0);const[B,p]=await Promise.allSettled([QS(e),mS(e)]);E||(B.status==="fulfilled"?o(((f=B.value.data)==null?void 0:f.locations)??[]):(o([]),console.error(B.reason)),p.status==="fulfilled"?a(((m=p.value.data)==null?void 0:m.mapping)??{}):(a({}),console.error(p.reason)),s(!1))})(),()=>{E=!0}},[e]);const h=y.useMemo(()=>Object.values(A).some(E=>E.length>0),[A]),I=async E=>{l(!0);try{const d=n.map(B=>String(B.id)).filter(B=>{const p=[...A[B]??[]].sort().join(","),f=[...E[B]??[]].sort().join(",");return p!==f});await Promise.all(d.map(B=>bS({connectorType:e,smId:B,locationIds:E[B]??[]}))),a(B=>{const p={...B};return d.forEach(f=>{p[f]=E[f]??[]}),p}),t==null||t("sub_account_mapping_saved",{connector_type:e,page:"connector_settings"}),rt({message:l5,type:Mn}),Q(!1)}catch(d){rt({message:u5,type:Nt}),console.error(d)}finally{l(!1)}};return i||r.length===0||n.length===0?null:u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-center gap-3 mb-6 p-3 rounded-lg overflow-hidden",style:{background:At.color.surface,border:`1px solid ${At.color.borderSubtle}`},children:[u.jsxs("div",{className:"flex flex-1 min-w-0 items-center gap-3 overflow-hidden",children:[u.jsx("span",{className:"flex shrink-0 items-center justify-center p-[11px] rounded-lg",style:{background:At.color.surfaceSoft,color:"var(--connector-admin-icon-primary)"},children:u.jsx(rG,{width:18,height:18})}),u.jsxs("div",{className:"flex flex-1 min-w-0 flex-col gap-0.5 break-words",children:[u.jsx("p",{style:{...At.font.titleMd,color:At.color.textStrong},children:e5}),u.jsx("p",{style:{...At.font.bodySm,color:At.color.textSoft},children:t5})]})]}),u.jsx(g.Button,{variant:"outlined",color:"tertiary",size:"small",onClick:()=>Q(!0),children:h?r5:n5})]}),C&&u.jsx(gG,{shown:C,setShown:Q,inboxes:n,subAccounts:r,mapping:A,isSaving:c,onSave:I},`${C}`)]})},CG=({connectorData:e})=>{var h;const{cardList:t=[],name:n="",customCardsList:r=[],advancedFeatures:o={},type:A,logo:a=null}=e||{},[i,s]=y.useState(!1),{availableFeatures:c}=y.useContext(at),l=(h=br())==null?void 0:h.tenantPlatform,C=Fn(c,l==="HIVERWEB"?`hot-${LE}`:LE),{id:Q=""}=cA();return u.jsxs(u.Fragment,{children:[u.jsx(yg,{shown:i,setShown:s,connectorName:n}),u.jsx("h2",{className:"text-h2 text-gray-2!",children:WT}),u.jsx("p",{className:"text-body2 text-gray-3! mb-6 mt-2",children:zT}),C&&u.jsx(nG,{connectorId:Q,connectorName:n,connectorLogo:a}),A&&u.jsx(dG,{connectorType:A}),u.jsx(UQ,{setShowEnabledModal:s,currentConnectorId:Q,formDefaultsEnabled:e==null?void 0:e.formDefaultsEnabled,infoCards:[...t,...r]}),u.jsx(j0,{advancedFeatures:o,connectorId:Q,connectorName:n,connectorType:A,excludeFeatureIds:[Zi]})]})},EG=()=>{const e=Qn(),{sendTrackingEvent:t}=y.useContext(at),n=Se(Qi),r=Se(lA),o=Se(Ag),A=Se(ur),a=Se(HA),{id:i=""}=cA(),[s]=ea(),c=s.get("isEdit")==="true",l=s.get("tabIndex"),[C,Q]=y.useState(()=>{const b=Number(l);return Number.isNaN(b)||b<0?0:b>yc.length-1?yc.length-1:b}),h=(b,T)=>{Q(T)},I=(A==null?void 0:A[i])||null,E=(a==null?void 0:a[i])||null,d=c?I:E,B=!(d!=null&&d.isAuthenticated),p=!!(d!=null&&d.type)&&oa(d.type);Md({event:c?C===1?lr.VISIBILITY_TAB_VIEWED:lr.AUTHENTICATION_TAB_VIEWED:lr.MARKETPLACE_AUTH_PAGE_VIEWED,data:ul({id:i,isEdit:c,row:d}),enabled:!!d&&!p});const f=!!(d!=null&&d.isEnabled),m=B&&!f,v=[n,r].includes(pe.LOADING)||m,w=[{name:ys,route:`${Fe.BASEPATH}${Fe.DASHBOARD}`},{name:(d==null?void 0:d.name)||"",route:`${Fe.BASEPATH}${Fe.API_VIEW}/${i}?isEdit=${String(c)}`},{name:Hk}],x=(b,T)=>{b==null||b.stopPropagation();const M=b.target.checked;if(M&&B){rt({message:TI,type:Nt});return}e(zA({id:T,enabled:M})).unwrap().then(()=>{M?t(We.TOGGLE_ENABLED,{connector_name:d==null?void 0:d.name}):(t(We.TOGGLE_DISABLED,{connector_name:d==null?void 0:d.name}),rt({message:Lu,type:Us}))}).catch(()=>{rt({message:Pu,type:Nt})})};if(y.useEffect(()=>{e(aA()),c?(e(JA(i)),e($s(i))):e(WA(i))},[c,e,i]),p){const b=c?Fe.APP_DETAIL:Fe.TEMPLATE_APP;return u.jsx(fc,{to:`${Fe.BASEPATH}${b}/${i}`,replace:!0})}return u.jsxs("div",{className:"w-full h-full flex flex-col",children:[u.jsxs("div",{className:`flex flex-row justify-between ${c?"mb-2":"mb-9"}`,children:[u.jsx(h0,{options:w}),c?u.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[u.jsx(sj,{connectorDetails:I}),u.jsx(Q0,{active:f,label:u.jsx(g.Typography,{variant:"body2",children:f?"Active":"Inactive"})}),u.jsx(g.Tooltip,{title:m?TI:"",placement:"bottom",children:u.jsx("span",{children:u.jsx(fC,{className:"connector-admin-settings-status-switch",isLoading:(o==null?void 0:o[i])===pe.LOADING,id:`switch_${i}`,checked:f,disabled:v,onClick:b=>b==null?void 0:b.stopPropagation(),onChange:b=>x(b,i)})})})]}):null]}),c?u.jsxs(u.Fragment,{children:[u.jsx("div",{children:u.jsxs(g.Tabs,{className:"connector-admin-settings-tabs",value:C,onChange:h,classes:{flexContainer:"border-b-2 border-gray-5"},children:[u.jsx(g.Tab,{label:yc[0],className:"border-b-0!"}),u.jsx(g.Tab,{label:yc[1],className:"border-b-0!"})]})}),u.jsx("div",{hidden:C!==0,className:"grow overflow-auto py-6",children:u.jsx(W0,{connectorData:d})}),u.jsx("div",{hidden:C!==1,className:"grow overflow-auto py-6",children:u.jsx(CG,{connectorData:d})})]}):u.jsx("div",{className:"grow overflow-auto py-0",children:u.jsx(W0,{connectorData:d})})]})},fG=e=>e.auth.verifyTokenApiStatus,IG=e=>e.auth.authVerificationDone,pG=g.styled(g.Box)`
2020
+ `,HV=({upgradeGuideContent:e,upgradeGuideLink:t})=>u.jsxs(RV,{children:[u.jsxs(g.Stack,{marginBottom:"20px",children:[u.jsxs(g.Stack,{direction:"row",padding:"8px 0",gap:"4px",alignItems:"center",children:[u.jsx(kV,{}),u.jsx(g.Typography,{variant:"body1_medium",color:"var(--connector-admin-text-primary)",children:hj})]}),u.jsx(g.Typography,{variant:"body2",children:Qj})]}),u.jsx(g.Typography,{variant:"body2_medium",marginBottom:"8px",color:"var(--connector-admin-text-primary)",children:mj}),u.jsx(VV,{variant:"body2",dangerouslySetInnerHTML:{__html:e}}),t?u.jsxs(jV,{target:"_blank",underline:"none",href:t,children:[u.jsx(GV,{}),bj]}):null]}),G0=(e,t)=>{const n=t.authType===yi,r=t.authType===Vp,o=t.authType===Aa,A=t.authType===bi;if(!e||!e.data)return{authUrl:"",authStatus:r?qe.API_KEY_FAILED:n?qe.BASIC_AUTH_FAILED:o?qe.OAUTH1_FAILED:qe.OAUTH_FAILED};const a=e.data;return r?{authUrl:"",id:a.id,authStatus:qe.API_KEY_SUCCESS}:n?{authUrl:"",id:a.id,authStatus:qe.BASIC_AUTH_SUCCESS}:o?{authUrl:"",id:a.id,authStatus:qe.OAUTH1_SUCCESS}:A?{authUrl:"",id:a.id,authStatus:qe.OAUTH_SUCCESS}:a.authorizationUrl?{authUrl:a.authorizationUrl,id:a.id,authStatus:qe.PENDING}:{authUrl:"",id:"",authStatus:qe.OAUTH_FAILED}},WV=async e=>{try{const t=await Ue({url:_S,method:nt.POST,data:e});return G0(t,e.authDetails)}catch(t){return Promise.reject(t)}},zV=async(e,t)=>{try{const n=RS.replace("{{id}}",t),r=await Ue({url:n,method:nt.PATCH,data:e});return G0(r,e.authDetails)}catch(n){return Promise.reject(n)}},YV=({connectorId:e,onSuccess:t})=>{const n=ho(),r=y.useMemo(()=>["authDetails",{connectorId:e}],[e]),{data:o}=Qo({queryKey:r,queryFn:()=>Promise.resolve({authUrl:"",authStatus:qe.IDLE,id:""}),enabled:!1}),A=oA({mutationFn:i=>"connectorId"in i?zV(i.data,i.connectorId):WV(i.data),onSuccess:i=>{n.setQueryData(r,i),t==null||t(i)}});y.useEffect(()=>()=>{n.removeQueries({queryKey:r,exact:!0})},[n,r]);const a=y.useCallback(i=>{n.setQueryData(r,s=>s&&{...s,authStatus:i})},[r,n]);return{mutate:A.mutate,mutateAsync:A.mutateAsync,isLoading:A.isPending,data:o,mutateStatus:a}},so={SUCCESS:"success",PENDING:"pending",FAILED:"failed"},JV=500,XV=1e3,ZV=[{afterMs:3*60*1e3,intervalMs:3e3},{afterMs:60*1e3,intervalMs:2e3}],UV=e=>{var t;return((t=ZV.find(n=>e>=n.afterMs))==null?void 0:t.intervalMs)??XV},yC=e=>["authSuccessStatus",{connectorId:e}],H0=e=>e===so.SUCCESS||e===so.FAILED,qV=async(e,t)=>{var n;try{const r=await Ue({url:Ft(jS,{connectorId:e}),method:nt.GET}),o=(n=r==null?void 0:r.data)==null?void 0:n.status;return!r||!o?{status:t?so.PENDING:so.FAILED}:t&&!H0(o)&&o!==so.PENDING?{status:so.PENDING}:r==null?void 0:r.data}catch(r){return Promise.reject(r)}},KV=({connectorId:e,enabled:t=!1,unknownAsPending:n=!1,backOff:r=!1,startedAt:o=0})=>{const A=ho(),a=y.useMemo(()=>yC(e),[e]),i=Qo({queryKey:a,queryFn:()=>qV(e,n),refetchInterval:s=>{var c;return H0((c=s.state.data)==null?void 0:c.status)?!1:r?UV(o?Date.now()-o:0):JV},enabled:t,refetchOnWindowFocus:!1,refetchIntervalInBackground:!0});return y.useEffect(()=>()=>{A.removeQueries({queryKey:a,exact:!0})},[A,a]),i},$V=1e3,eG=e=>{var n;const t=(n=e.data)==null?void 0:n.status;return t==="success"||t==="failed"||e.data===bl||e.data===IC},W0=({connectorData:e})=>{const{sendTrackingEvent:t,availableFeatures:n}=y.useContext(at),[r,o]=y.useState(!1),A=Se(lA),a=Se(_u),i=y.useRef(null),s=fn(),{id:c=""}=cA(),[l]=ea(),C=l.get("isEdit")==="true",Q=KQ(),h=ul({id:c,isEdit:C,row:e}),I=y.useRef(h);I.current=h;const E=y.useRef(null),d=y.useCallback(($,ge)=>{E.current!==ge&&(E.current=ge,Q($,{...I.current,auth_status:ge}))},[Q]),B=!!(e!=null&&e.showUpgradeButton),p=Fn(n,Fv),f=Fn(n,Mv),m=ho(),[v,w]=y.useState(0),x=y.useRef(null),b=y.useCallback(()=>{var $;try{($=i.current)==null||$.close()}catch{}i.current=null},[]),{data:T,mutateStatus:M,isLoading:_,mutate:R}=YV({connectorId:c,onSuccess:$=>{var ye;if(p&&o(!0),!f)return;const ge=($==null?void 0:$.id)||"";if(ge&&m.removeQueries({queryKey:yC(ge),exact:!0}),!!($!=null&&$.authUrl))try{if(b(),i.current=window.open($.authUrl,"_blank"),!i.current){(ye=x.current)==null||ye.call(x,qe.IDLE),rt({message:fj,type:Nt});return}w(Date.now())}catch(de){pt.log("Error in Authentication",de)}}});x.current=M;const F=(T==null?void 0:T.authStatus)||qe.IDLE,O=(T==null?void 0:T.authUrl)||"",j=KV({connectorId:(T==null?void 0:T.id)||"",enabled:f?v>0&&!!(T!=null&&T.id):r,unknownAsPending:f,backOff:f,startedAt:v}),{status:W}=j.data||{},ne=Qn(),K=y.useRef((T==null?void 0:T.id)||"");K.current=(T==null?void 0:T.id)||"";const U=y.useRef(0),V=y.useRef(!1);V.current=j.isFetching;const Z=y.useCallback(()=>{const $=K.current;if(!$||V.current)return;const ge=Date.now();ge-U.current<$V||(U.current=ge,m.invalidateQueries({queryKey:yC($)}))},[m]),G=y.useRef(W);y.useEffect(()=>{G.current=W},[W]),y.useEffect(()=>()=>{ne(zS())},[ne]),y.useEffect(()=>{if(f)return;let $,ge;const ye=de=>{var Me;if(i.current){if(p){if(de.source!==i.current)return;const X=(Me=de.data)==null?void 0:Me.status;(X==="success"||X==="failed")&&(clearTimeout($),clearInterval(ge),i.current.close(),i.current=null,M(X==="success"?qe.OAUTH_SUCCESS:qe.OAUTH_FAILED));return}de.origin===window.location.origin&&(de.data===IC||de.data===bl)&&(clearTimeout($),i.current.close(),i.current=null,M(de.data===bl?qe.OAUTH_SUCCESS:qe.OAUTH_FAILED))}};try{if(O){i.current=window.open(O,"_blank");const de=5*60*1e3;$=setTimeout(()=>{var Me;(Me=i.current)==null||Me.close(),i.current=null,M(qe.OAUTH_FAILED)},de),ge=setInterval(()=>{var X;if(!((X=i.current)!=null&&X.closed))return;if(clearInterval(ge),!p){i.current=null,M(qe.OAUTH_FAILED);return}const Me=()=>{i.current&&(i.current=null,M(G.current==="success"?qe.OAUTH_SUCCESS:qe.OAUTH_FAILED))};G.current==="success"||G.current==="failed"?Me():setTimeout(Me,1500)},500),window.addEventListener("message",ye)}}catch(de){pt.log("Error in Authentication",de)}return()=>{window.removeEventListener("message",ye),clearTimeout($),clearInterval(ge)}},[O,ne,M,p,f]),y.useEffect(()=>{f||W&&W!=="pending"&&i.current&&p&&(i.current.close(),i.current=null,M(W==="success"?qe.OAUTH_SUCCESS:qe.OAUTH_FAILED))},[W,M,p,f]),y.useEffect(()=>{!f||v===0||W!==so.SUCCESS&&W!==so.FAILED||(b(),w(0),M(W===so.SUCCESS?qe.OAUTH_SUCCESS:qe.OAUTH_FAILED))},[W,b,M,f,v]),y.useEffect(()=>{if(!f||v===0)return;const $=ye=>{eG(ye)&&Z()};window.addEventListener("message",$);const ge=setTimeout(()=>{w(0),M(qe.IDLE),rt({message:Ej,type:Nt})},Cj);return()=>{window.removeEventListener("message",$),clearTimeout(ge)}},[f,v,M,Z]),y.useEffect(()=>{if(!f||v===0)return;const $=()=>{document.visibilityState==="visible"&&Z()};return document.addEventListener("visibilitychange",$),()=>document.removeEventListener("visibilitychange",$)},[f,v,Z]),y.useEffect(()=>{switch((F===qe.OAUTH1_FAILED||F===qe.OAUTH_FAILED||F===qe.API_KEY_FAILED||F===qe.BASIC_AUTH_FAILED)&&s(Fe.BASEPATH),(F===qe.OAUTH1_SUCCESS||F===qe.OAUTH_SUCCESS||F===qe.API_KEY_SUCCESS||F===qe.BASIC_AUTH_SUCCESS)&&T!=null&&T.id&&s(C?Fe.BASEPATH:`${Fe.BASEPATH}${Fe.CONNECTOR_INITIAL_SETUP}/${c}?connectorId=${T.id}`),F){case qe.BASIC_AUTH_SUCCESS:case qe.OAUTH1_SUCCESS:case qe.OAUTH_SUCCESS:{rt({message:B?v0:uj,type:Mn}),t(We.CONNECTOR_AUTH_SUCCESS,{connector_name:e==null?void 0:e.name}),d(lr.AUTHENTICATION_SUCCESS,F);break}case qe.BASIC_AUTH_FAILED:case qe.OAUTH1_FAILED:case qe.OAUTH_FAILED:{rt({message:B?x0:gj,type:Nt}),d(lr.AUTHENTICATION_FAILURE,F);break}case qe.REQUEST_FAILED:{rt({message:qs,type:Nt}),d(lr.AUTHENTICATION_FAILURE,F);break}case qe.API_KEY_SUCCESS:{rt({message:B?v0:Ij,type:Mn}),t(We.CONNECTOR_AUTH_SUCCESS,{connector_name:e==null?void 0:e.name}),d(lr.AUTHENTICATION_SUCCESS,F);break}case qe.API_KEY_FAILED:{rt({message:B?x0:qs,type:Nt}),d(lr.AUTHENTICATION_FAILURE,F);break}}},[F,s,B,c,C,e==null?void 0:e.name,t,d,T==null?void 0:T.id]);const H=A===pe.LOADING||a===pe.LOADING,{name:ae="",type:ue="",advancedFeatures:se={}}=e||{};return u.jsxs(u.Fragment,{children:[u.jsxs(NV,{direction:"row",id:"connectors-auth-page",style:C?{height:"auto"}:void 0,children:[u.jsx("div",{className:"flex flex-col",children:u.jsx(eV,{connectorId:c,isEdit:C,connectorData:e,authStatus:F,isLoading:H,authMutate:R,isAuthPending:_})}),u.jsxs(g.Stack,{gap:"36px",width:"322px",className:"connector-auth-help",children:[e!=null&&e.upgradeGuideContent?u.jsx(HV,{upgradeGuideContent:e.upgradeGuideContent,upgradeGuideLink:e.upgradeGuideLink}):null,u.jsxs(g.Stack,{gap:"12px",children:[u.jsx(g.Typography,{variant:"h2",marginBottom:"8px",children:Gp}),C?null:u.jsx(vc,{isSettingsPage:!0}),u.jsx(V0,{connectorName:e==null?void 0:e.name,supportLinks:e==null?void 0:e.supportLinks})]})]})]}),C&&u.jsx(j0,{advancedFeatures:se,connectorId:c,connectorName:ae,connectorType:ue,featureIds:[Zi],soloSpansFullWidth:!1})]})},tG=e=>S.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.createElement("g",{clipPath:"url(#clip0_1446_4479)"},S.createElement("path",{d:"M11.3333 2H3.33333C2.59333 2 2 2.6 2 3.33333V12.6667C2 13.4 2.59333 14 3.33333 14H12.6667C13.4 14 14 13.4 14 12.6667V4.66667L11.3333 2ZM8 12.6667C6.89333 12.6667 6 11.7733 6 10.6667C6 9.56 6.89333 8.66667 8 8.66667C9.10667 8.66667 10 9.56 10 10.6667C10 11.7733 9.10667 12.6667 8 12.6667ZM10 6H3.33333V3.33333H10V6Z",fill:"white"})),S.createElement("defs",null,S.createElement("clipPath",{id:"clip0_1446_4479"},S.createElement("rect",{width:16,height:16,fill:"white"})))),z0=e=>S.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.86993 0.652446C7.56922 0.248711 8.43078 0.248711 9.13007 0.652446L13.7981 3.34755C14.4974 3.75129 14.9282 4.49742 14.9282 5.30489V10.6951C14.9282 11.5026 14.4974 12.2487 13.7981 12.6524L9.13007 15.3476C8.43078 15.7513 7.56922 15.7513 6.86993 15.3476L2.20187 12.6524C1.50258 12.2487 1.0718 11.5026 1.0718 10.6951V5.30489C1.0718 4.49742 1.50258 3.75129 2.20187 3.34755L6.86993 0.652446Z",fill:"#FFD122"}),S.createElement("g",{filter:"url(#filter0_d_360_39563)"},S.createElement("path",{d:"M5.83154 4.43359V4.43359C6.84296 4.43359 7.66287 5.25351 7.66287 6.26492V11.5179V11.5179C6.65146 11.5179 5.83154 10.698 5.83154 9.68661V4.43359Z",fill:"white"})),S.createElement("g",{filter:"url(#filter1_d_360_39563)"},S.createElement("path",{d:"M8.57812 7.66211V7.66211C9.58954 7.66211 10.4095 8.48202 10.4095 9.49343V11.7103V11.7103C9.39804 11.7103 8.57812 10.8904 8.57812 9.87898V7.66211Z",fill:"white"})),S.createElement("defs",null,S.createElement("filter",{id:"filter0_d_360_39563",x:4.76488,y:3.36693,width:3.96488,height:9.21732,filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB"},S.createElement("feFlood",{floodOpacity:0,result:"BackgroundImageFix"}),S.createElement("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),S.createElement("feOffset",null),S.createElement("feGaussianBlur",{stdDeviation:.533333}),S.createElement("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.114019 0"}),S.createElement("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_360_39563"}),S.createElement("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow_360_39563",result:"shape"})),S.createElement("filter",{id:"filter1_d_360_39563",x:7.51146,y:6.59544,width:3.96488,height:6.18216,filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB"},S.createElement("feFlood",{floodOpacity:0,result:"BackgroundImageFix"}),S.createElement("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),S.createElement("feOffset",null),S.createElement("feGaussianBlur",{stdDeviation:.533333}),S.createElement("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.114019 0"}),S.createElement("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_360_39563"}),S.createElement("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow_360_39563",result:"shape"})))),nG=({connectorId:e,connectorName:t,connectorLogo:n})=>{const{sendTrackingEvent:r}=y.useContext(at),[o,A]=y.useState(null),[a,i]=y.useState([]),[s,c]=y.useState(!1),[l,C]=y.useState(""),[Q,h]=y.useState(!0),[I,E]=y.useState(!1);if(y.useEffect(()=>{(async()=>{var w;h(!0);try{const[x,b]=await Promise.all([IS(e),pS(e)]);A(x.data??null),i(((w=b.data)==null?void 0:w.presets)??[])}catch(x){rt({message:qs,type:Nt}),pt.error(x)}finally{h(!1)}})()},[e]),Q||a.length===0)return null;const d=a.find(v=>v.hiverParam===(o==null?void 0:o.hiverParam))??a[0],B=()=>{var x;r(We.LOOKUP_CONFIG_CLICKED,{connector_name:t,page:"connector_settings"});const v=(o==null?void 0:o.hiverParam)??d.hiverParam,w=a.some(b=>b.hiverParam===v);C(w?v:((x=a[0])==null?void 0:x.hiverParam)??""),c(!0)},p=async()=>{E(!0);try{await BS([{connectorId:e,hiverParam:l}]),A({connectorId:e,hiverParam:l}),r(We.LOOKUP_SAVED,{connector_name:t,hiver_param:l,page:"connector_settings"}),rt({message:qT,type:Mn}),c(!1)}catch{rt({message:KT,type:Nt})}finally{E(!1)}},f=UT.replace("%s",t),m=a.find(v=>v.hiverParam===(l||(o==null?void 0:o.hiverParam)))??a[0];return u.jsxs("div",{className:"border border-gray-5 rounded-lg bg-white p-4 mb-6",children:[u.jsxs("div",{className:"flex items-center justify-between mb-1",children:[u.jsx("span",{className:"text-h2 text-gray-1!",children:YT}),s?u.jsx(g.Button,{variant:"contained",size:"small",startIcon:u.jsx(tG,{}),onClick:p,disabled:I,children:ZT}):u.jsx(g.Button,{variant:"outlined",color:"tertiary",size:"small",onClick:B,children:XT})]}),u.jsx("p",{className:"text-body2 text-gray-3! mb-6",children:JT}),s?u.jsxs("div",{className:"inline-flex items-center border border-gray-6 overflow-hidden p-3 rounded-[8px] w-full",children:[u.jsx(g.Select,{value:l,onChange:v=>{const w=v.target.value;r(We.LOOKUP_FIELD_CLICKED,{hiver_param:w,connector_name:t,page:"connector_settings"}),C(w)},size:"small",variant:"outlined",renderValue:v=>{var x;const w=((x=a.find(b=>b.hiverParam===v))==null?void 0:x.label)??"";return u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(z0,{className:"w-4 h-4 shrink-0"}),w]})},sx:{fontSize:`${g.theme.typography.body1.fontSize}px`,width:"209px",height:"40px",background:"var(--connector-admin-surface-subtle)",borderRadius:"8px",fontWeight:g.theme.typography.fontWeightMedium,"& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--connector-admin-border)"}},children:a.map(v=>u.jsx(g.MenuItem,{value:v.hiverParam,sx:{fontSize:`${g.theme.typography.body1.fontSize}px`},children:v.label},v.hiverParam))}),u.jsx("div",{className:"h-px w-8 bg-gray-6 shrink-0"}),u.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 text-sm text-gray-2 rounded-full border-1 border-gray-6 h-[26px]",children:[n&&u.jsx("img",{src:n,alt:t,className:"w-4 h-4 object-contain shrink-0"}),f]}),u.jsx("div",{className:"h-px w-8 bg-gray-6 shrink-0"}),u.jsx("div",{className:"px-4 py-2.5 text-sm text-gray-2 bg-gray-6a rounded-[8px] h-10 grow",children:m.objectParamLabel})]}):u.jsxs("div",{className:"inline-flex items-center border border-gray-6 overflow-hidden p-3 rounded-[8px] w-full",children:[u.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 text-sm text-gray-2 rounded-[8px] font-medium bg-gray-6a w-[209px] h-10",children:[u.jsx(z0,{className:"w-4 h-4 shrink-0"}),m.label]}),u.jsx("div",{className:"h-px w-8 bg-gray-6 shrink-0"}),u.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 text-sm text-gray-2 rounded-full border-1 border-gray-6 h-[26px]",children:[n&&u.jsx("img",{src:n,alt:t,className:"w-4 h-4 object-contain shrink-0"}),f]}),u.jsx("div",{className:"h-px w-8 bg-gray-6 shrink-0"}),u.jsx("div",{className:"px-4 py-2.5 text-sm text-gray-2 bg-gray-6a rounded-[8px] h-10 grow",children:m.objectParamLabel})]})]})},rG=e=>S.createElement("svg",{width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.createElement("path",{d:"M12.75 15H12.6C11.3399 15 10.7098 15 10.2285 14.7548C9.80516 14.539 9.46095 14.1948 9.24524 13.7715C9 13.2902 9 12.6601 9 11.4V6.6C9 5.33988 9 4.70982 9.24524 4.22852C9.46095 3.80516 9.80516 3.46095 10.2285 3.24524C10.7098 3 11.3399 3 12.6 3H12.75M12.75 15C12.75 15.8284 13.4216 16.5 14.25 16.5C15.0784 16.5 15.75 15.8284 15.75 15C15.75 14.1716 15.0784 13.5 14.25 13.5C13.4216 13.5 12.75 14.1716 12.75 15ZM12.75 3C12.75 3.82843 13.4216 4.5 14.25 4.5C15.0784 4.5 15.75 3.82843 15.75 3C15.75 2.17157 15.0784 1.5 14.25 1.5C13.4216 1.5 12.75 2.17157 12.75 3ZM5.25 9L12.75 9M5.25 9C5.25 9.82843 4.57843 10.5 3.75 10.5C2.92157 10.5 2.25 9.82843 2.25 9C2.25 8.17157 2.92157 7.5 3.75 7.5C4.57843 7.5 5.25 8.17157 5.25 9ZM12.75 9C12.75 9.82843 13.4216 10.5 14.25 10.5C15.0784 10.5 15.75 9.82843 15.75 9C15.75 8.17157 15.0784 7.5 14.25 7.5C13.4216 7.5 12.75 8.17157 12.75 9Z",stroke:"currentColor",strokeWidth:1.33,strokeLinecap:"round",strokeLinejoin:"round"})),oG=e=>S.createElement("svg",{width:20,height:20,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.createElement("g",{id:"Icons/Line/arrow-right"},S.createElement("path",{id:"Icon",d:"M4.16667 10H15.8333M10 15.8333L15.8333 10L10 4.16667",stroke:"currentColor",strokeWidth:1.41667,strokeLinecap:"round",strokeLinejoin:"round"}))),AG=e=>S.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.createElement("g",{id:"Icon"},S.createElement("path",{id:"Icon_2",d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:1.33,strokeLinecap:"round",strokeLinejoin:"round"}))),aG=e=>S.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.createElement("g",{id:"Icon"},S.createElement("path",{id:"Icon_2",d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:1.33,strokeLinecap:"round",strokeLinejoin:"round"}))),Ui="'Inter', sans-serif",At={color:{surface:"var(--connector-admin-surface)",surfaceSubtle:"var(--connector-admin-surface-subtle)",surfaceSoft:"var(--connector-admin-surface-subtle)",borderSubtle:"var(--connector-admin-border)",borderSoft:"var(--connector-admin-border)",borderDefault:"var(--connector-admin-input-border)",textStrong:"var(--connector-admin-text-primary)",textDefault:"var(--connector-admin-text-secondary)",textSoft:"var(--connector-admin-text-tertiary)",textSubtle:"var(--connector-admin-input-placeholder)",tableHeader:"var(--connector-admin-text-tertiary)",tagBg:"var(--connector-admin-surface-hover)"},radius:{sm:"6px",md:"8px",lg:"16px"},shadow:"0px 2px 4px -2px rgba(16, 24, 40, 0.06), 0px 4px 8px -2px rgba(16, 24, 40, 0.1)",font:{titleMd:{fontFamily:Ui,fontSize:"14px",lineHeight:"20px",fontWeight:500},titleLg:{fontFamily:Ui,fontSize:"16px",lineHeight:"24px",fontWeight:500},bodySm:{fontFamily:Ui,fontSize:"13px",lineHeight:"19px",fontWeight:400},labelSm:{fontFamily:Ui,fontSize:"13px",lineHeight:"19px",fontWeight:500},placeholder:{fontFamily:Ui,fontSize:"14px",lineHeight:"20px",fontWeight:400},columnHeader:{fontFamily:"'Open Sans', sans-serif",fontSize:"13px",lineHeight:"16px",fontWeight:600}}},iG={width:"100%",height:"40px",background:"var(--connector-admin-input-background)",borderRadius:At.radius.md,border:`1px solid ${At.color.borderDefault}`,...At.font.bodySm,"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiSelect-select":{padding:"0 12px",height:"40px",display:"flex",alignItems:"center",overflow:"hidden",boxSizing:"border-box"},"& .MuiSelect-icon":{width:"16px",height:"16px",right:"12px",top:"calc(50% - 8px)",pointerEvents:"none"}},sG={display:"flex",alignItems:"center",gap:"6px",flex:"1 1 0%",minWidth:0,overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none","&::-webkit-scrollbar":{height:0},"&:hover":{scrollbarWidth:"thin","&::-webkit-scrollbar":{height:"4px"},"&::-webkit-scrollbar-thumb":{borderRadius:"2px",backgroundColor:"var(--connector-admin-scrollbar)"}}},cG={anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{sx:{marginTop:"4px",maxHeight:"240px",borderRadius:At.radius.md,border:`1px solid ${At.color.borderSubtle}`,boxShadow:At.shadow,"& .MuiMenuItem-root":{...At.font.bodySm,color:At.color.textDefault,minHeight:"36px",gap:"8px"}}}},Y0=e=>u.jsx(AG,{...e,width:16,height:16,style:{color:"var(--connector-admin-icon-secondary)"}}),J0=(e,t)=>e.localeCompare(t,void 0,{sensitivity:"base"}),lG=({label:e})=>u.jsx("span",{className:"flex max-h-[22px] max-w-[96px] shrink-0 items-center justify-center gap-1 rounded-md px-1.5 py-0.5",style:{background:At.color.tagBg},children:u.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",style:{...At.font.labelSm,color:At.color.textDefault},title:e,children:e})}),uG=({selected:e,subAccounts:t,atLimit:n,subAccountName:r,onChange:o})=>{const[A,a]=y.useState(!1),i=y.useMemo(()=>[...e].sort((c,l)=>J0(r(c),r(l))),[e,r]),s=e.length===0?u.jsx("span",{className:"min-w-0 flex-1",style:{...At.font.placeholder,color:At.color.textSubtle},children:i5}):u.jsx(g.Box,{sx:sG,children:i.map(c=>u.jsx(lG,{label:r(c)},c))});return A?u.jsx(g.Select,{multiple:!0,displayEmpty:!0,defaultOpen:!0,value:e,onChange:c=>o(c.target.value),onClose:()=>a(!1),IconComponent:Y0,MenuProps:cG,sx:iG,renderValue:()=>s,children:t.map(c=>{const l=e.includes(c.locationId);return u.jsxs(g.MenuItem,{value:c.locationId,disabled:n&&!l,children:[u.jsx(g.Checkbox,{checked:l,size:"small",sx:{padding:0}}),c.name]},c.locationId)})}):u.jsxs("button",{type:"button",onClick:()=>a(!0),className:"flex h-10 w-full cursor-pointer items-center gap-1.5 overflow-hidden rounded-lg px-3 text-left",style:{background:"var(--connector-admin-input-background)",border:`1px solid ${At.color.borderDefault}`},children:[s,u.jsx("span",{className:"flex shrink-0 items-center",children:u.jsx(Y0,{})})]})},gG=({shown:e,setShown:t,inboxes:n,subAccounts:r,mapping:o,isSaving:A,onSave:a})=>{const[i,s]=y.useState(o),c=y.useMemo(()=>[...r].sort((h,I)=>J0(h.name,I.name)),[r]),l=y.useMemo(()=>{const h=new Map(r.map(I=>[I.locationId,I.name]));return I=>h.get(I)??I},[r]),C=y.useMemo(()=>[...new Set([...Object.keys(o),...Object.keys(i)])].some(I=>{const E=[...o[I]??[]].sort().join(","),d=[...i[I]??[]].sort().join(",");return E!==d}),[o,i]),Q=()=>{s(o),t(!1)};return u.jsx(ro,{shown:e,setShown:t,onClose:Q,borderRadius:16,customPaperProps:{width:"640px",border:`1px solid ${At.color.borderSoft}`,boxShadow:At.shadow,overflow:"hidden"},children:u.jsxs("div",{className:"flex w-full flex-col",children:[u.jsxs("div",{className:"flex w-full items-center gap-3 px-5 py-3",style:{background:At.color.surfaceSoft,borderBottom:`1px solid ${At.color.borderSubtle}`},children:[u.jsx("p",{className:"min-w-0 flex-1",style:{...At.font.titleLg,color:At.color.textStrong},children:o5}),u.jsx("button",{type:"button","aria-label":"Close",onClick:Q,className:"flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-1.5",style:{color:"var(--connector-admin-icon-primary)"},children:u.jsx(aG,{width:16,height:16})})]}),u.jsx("div",{className:"flex w-full flex-col gap-6 p-5",children:u.jsxs("div",{className:"flex w-full flex-col overflow-hidden rounded-lg pb-1",style:{border:`1px solid ${At.color.borderSubtle}`},children:[u.jsxs("div",{className:"flex w-full items-center gap-2",style:{background:At.color.surfaceSubtle},children:[u.jsx("div",{className:"flex w-[186px] shrink-0 items-center py-4 pl-6 pr-4",children:u.jsx("span",{className:"whitespace-nowrap",style:{...At.font.columnHeader,color:At.color.tableHeader},children:A5})}),u.jsx("div",{className:"flex min-w-0 flex-1 items-center py-4 pl-10 pr-5",children:u.jsx("span",{className:"whitespace-nowrap",style:{...At.font.columnHeader,color:At.color.tableHeader},children:a5})})]}),u.jsx("div",{className:"max-h-[320px] w-full overflow-y-auto",children:n.map(h=>{const I=i[h.id]??[],E=I.length>=g5;return u.jsxs("div",{className:"flex h-16 w-full items-center gap-2",style:{borderTop:`1px solid ${At.color.borderSubtle}`},children:[u.jsx("div",{className:"flex w-[165px] shrink-0 items-center py-[22px] pl-6 pr-4",children:u.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",style:{...At.font.bodySm,color:At.color.textDefault},title:h.name,children:h.name})}),u.jsx(oG,{width:20,height:20,className:"shrink-0",style:{color:"var(--connector-admin-icon-secondary)"}}),u.jsx("div",{className:"flex min-w-0 flex-1 items-center py-3 pl-8 pr-4",children:u.jsx(uG,{selected:I,subAccounts:c,atLimit:E,subAccountName:l,onChange:d=>s(B=>({...B,[h.id]:d}))})})]},h.id)})})]})}),u.jsxs("div",{className:"flex w-full items-center justify-end gap-3 px-5 py-4",style:{background:At.color.surface,borderTop:`1px solid ${At.color.borderSubtle}`},children:[u.jsx(g.Button,{variant:"outlined",color:"tertiary",size:"small",onClick:Q,disabled:A,children:s5}),u.jsx(g.Button,{variant:"contained",size:"small",onClick:()=>a(i),disabled:!C||A,children:c5})]})]})})},dG=({connectorType:e})=>{const{sendTrackingEvent:t}=y.useContext(at),n=Se(no)??[],[r,o]=y.useState([]),[A,a]=y.useState({}),[i,s]=y.useState(!0),[c,l]=y.useState(!1),[C,Q]=y.useState(!1);y.useEffect(()=>{let E=!1;return(async()=>{var f,m;s(!0);const[B,p]=await Promise.allSettled([QS(e),mS(e)]);E||(B.status==="fulfilled"?o(((f=B.value.data)==null?void 0:f.locations)??[]):(o([]),console.error(B.reason)),p.status==="fulfilled"?a(((m=p.value.data)==null?void 0:m.mapping)??{}):(a({}),console.error(p.reason)),s(!1))})(),()=>{E=!0}},[e]);const h=y.useMemo(()=>Object.values(A).some(E=>E.length>0),[A]),I=async E=>{l(!0);try{const d=n.map(B=>String(B.id)).filter(B=>{const p=[...A[B]??[]].sort().join(","),f=[...E[B]??[]].sort().join(",");return p!==f});await Promise.all(d.map(B=>bS({connectorType:e,smId:B,locationIds:E[B]??[]}))),a(B=>{const p={...B};return d.forEach(f=>{p[f]=E[f]??[]}),p}),t==null||t("sub_account_mapping_saved",{connector_type:e,page:"connector_settings"}),rt({message:l5,type:Mn}),Q(!1)}catch(d){rt({message:u5,type:Nt}),console.error(d)}finally{l(!1)}};return i||r.length===0||n.length===0?null:u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-center gap-3 mb-6 p-3 rounded-lg overflow-hidden",style:{background:At.color.surface,border:`1px solid ${At.color.borderSubtle}`},children:[u.jsxs("div",{className:"flex flex-1 min-w-0 items-center gap-3 overflow-hidden",children:[u.jsx("span",{className:"flex shrink-0 items-center justify-center p-[11px] rounded-lg",style:{background:At.color.surfaceSoft,color:"var(--connector-admin-icon-primary)"},children:u.jsx(rG,{width:18,height:18})}),u.jsxs("div",{className:"flex flex-1 min-w-0 flex-col gap-0.5 break-words",children:[u.jsx("p",{style:{...At.font.titleMd,color:At.color.textStrong},children:e5}),u.jsx("p",{style:{...At.font.bodySm,color:At.color.textSoft},children:t5})]})]}),u.jsx(g.Button,{variant:"outlined",color:"tertiary",size:"small",onClick:()=>Q(!0),children:h?r5:n5})]}),C&&u.jsx(gG,{shown:C,setShown:Q,inboxes:n,subAccounts:r,mapping:A,isSaving:c,onSave:I},`${C}`)]})},CG=({connectorData:e})=>{var h;const{cardList:t=[],name:n="",customCardsList:r=[],advancedFeatures:o={},type:A,logo:a=null}=e||{},[i,s]=y.useState(!1),{availableFeatures:c}=y.useContext(at),l=(h=br())==null?void 0:h.tenantPlatform,C=Fn(c,l==="HIVERWEB"?`hot-${LE}`:LE),{id:Q=""}=cA();return u.jsxs(u.Fragment,{children:[u.jsx(yg,{shown:i,setShown:s,connectorName:n}),u.jsx("h2",{className:"text-h2 text-gray-2!",children:WT}),u.jsx("p",{className:"text-body2 text-gray-3! mb-6 mt-2",children:zT}),C&&u.jsx(nG,{connectorId:Q,connectorName:n,connectorLogo:a}),A&&u.jsx(dG,{connectorType:A}),u.jsx(UQ,{setShowEnabledModal:s,currentConnectorId:Q,formDefaultsEnabled:e==null?void 0:e.formDefaultsEnabled,infoCards:[...t,...r]}),u.jsx(j0,{advancedFeatures:o,connectorId:Q,connectorName:n,connectorType:A,excludeFeatureIds:[Zi]})]})},EG=()=>{const e=Qn(),{sendTrackingEvent:t}=y.useContext(at),n=Se(Qi),r=Se(lA),o=Se(Ag),A=Se(ur),a=Se(HA),{id:i=""}=cA(),[s]=ea(),c=s.get("isEdit")==="true",l=s.get("tabIndex"),[C,Q]=y.useState(()=>{const b=Number(l);return Number.isNaN(b)||b<0?0:b>yc.length-1?yc.length-1:b}),h=(b,T)=>{Q(T)},I=(A==null?void 0:A[i])||null,E=(a==null?void 0:a[i])||null,d=c?I:E,B=!(d!=null&&d.isAuthenticated),p=!!(d!=null&&d.type)&&oa(d.type);Md({event:c?C===1?lr.VISIBILITY_TAB_VIEWED:lr.AUTHENTICATION_TAB_VIEWED:lr.MARKETPLACE_AUTH_PAGE_VIEWED,data:ul({id:i,isEdit:c,row:d}),enabled:!!d&&!p});const f=!!(d!=null&&d.isEnabled),m=B&&!f,v=[n,r].includes(pe.LOADING)||m,w=[{name:ys,route:`${Fe.BASEPATH}${Fe.DASHBOARD}`},{name:(d==null?void 0:d.name)||"",route:`${Fe.BASEPATH}${Fe.API_VIEW}/${i}?isEdit=${String(c)}`},{name:Hk}],x=(b,T)=>{b==null||b.stopPropagation();const M=b.target.checked;if(M&&B){rt({message:TI,type:Nt});return}e(zA({id:T,enabled:M})).unwrap().then(()=>{M?t(We.TOGGLE_ENABLED,{connector_name:d==null?void 0:d.name}):(t(We.TOGGLE_DISABLED,{connector_name:d==null?void 0:d.name}),rt({message:Lu,type:Us}))}).catch(()=>{rt({message:Pu,type:Nt})})};if(y.useEffect(()=>{e(aA()),c?(e(JA(i)),e($s(i))):e(WA(i))},[c,e,i]),p){const b=c?Fe.APP_DETAIL:Fe.TEMPLATE_APP;return u.jsx(fc,{to:`${Fe.BASEPATH}${b}/${i}`,replace:!0})}return u.jsxs("div",{className:"w-full h-full flex flex-col",children:[u.jsxs("div",{className:`flex flex-row justify-between ${c?"mb-2":"mb-9"}`,children:[u.jsx(h0,{options:w}),c?u.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[u.jsx(sj,{connectorDetails:I}),u.jsx(Q0,{active:f,label:u.jsx(g.Typography,{variant:"body2",children:f?"Active":"Inactive"})}),u.jsx(g.Tooltip,{title:m?TI:"",placement:"bottom",children:u.jsx("span",{children:u.jsx(fC,{className:"connector-admin-settings-status-switch",isLoading:(o==null?void 0:o[i])===pe.LOADING,id:`switch_${i}`,checked:f,disabled:v,onClick:b=>b==null?void 0:b.stopPropagation(),onChange:b=>x(b,i)})})})]}):null]}),c?u.jsxs(u.Fragment,{children:[u.jsx("div",{children:u.jsxs(g.Tabs,{className:"connector-admin-settings-tabs",value:C,onChange:h,classes:{flexContainer:"border-b-2 border-gray-5"},children:[u.jsx(g.Tab,{label:yc[0],className:"border-b-0!"}),u.jsx(g.Tab,{label:yc[1],className:"border-b-0!"})]})}),u.jsx("div",{hidden:C!==0,className:"grow overflow-auto py-6",children:u.jsx(W0,{connectorData:d})}),u.jsx("div",{hidden:C!==1,className:"grow overflow-auto py-6",children:u.jsx(CG,{connectorData:d})})]}):u.jsx("div",{className:"grow overflow-auto py-0",children:u.jsx(W0,{connectorData:d})})]})},fG=e=>e.auth.verifyTokenApiStatus,IG=e=>e.auth.authVerificationDone,pG=g.styled(g.Box)`
2021
2021
  position: fixed;
2022
2022
  z-index: 1000;
2023
2023
  color: var(--connector-admin-text-primary);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiver/connector-admin",
3
- "version": "4.22.0-ghlSubAccountMapping-beta.5",
3
+ "version": "4.22.0-ghlSubAccountMapping-beta.6",
4
4
  "main": "index.es.js",
5
5
  "module": "index.es.js",
6
6
  "types": "index.d.ts",
@@ -1 +1 @@
1
- {"version":3,"file":"sub-account-mapping.d.ts","sourceRoot":"","sources":["../../../../src/testing/mocks/handlers/sub-account-mapping.ts"],"names":[],"mappings":"AAqCA,eAAO,MAAM,QAAQ,6BAsDpB,CAAC"}
1
+ {"version":3,"file":"sub-account-mapping.d.ts","sourceRoot":"","sources":["../../../../src/testing/mocks/handlers/sub-account-mapping.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,QAAQ,6BAsDpB,CAAC"}