1import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{A as t,j as n}from"./react-vendor-BERBVPaj.js";import{Qi as r,la as i,ma as a,na as o}from"./policies-C74xZeOL.js";import{Ds as s,Ls as c,c as l,o as u,oc as d,s as f,sc as p}from"./src-BSmyd9H1.js";import{At as m,Ct as h,Mt as g,Ut as _,en as v,fn as y,jt as ee,ln as te,qt as b}from"./src-Cpb3xFo3.js";import{n as x}from"./UserContext-oy1v7M1h.js";import{a as S}from"./sentry-vendor-B_OyWdrc.js";import{t as ne}from"./Trash-Ct6MPpGl.js";import{t as re}from"./InformationOutlined-D_ZvmAzR.js";import{c as C,i as w,s as T}from"./modal-DTB5z36U.js";import"./useFormatMessage-XJ9Ad3tf.js";import{c as E,l as D,n as ie,t as O,u as ae}from"./index.esm-BPupXMoA.js";import{i as oe,r as se}from"./src-CkpJay5R.js";import{t as k}from"./logger-C4ee1UZI.js";import{t as A}from"./useLocalStorage-B5xAOEYY.js";import{A as ce,M as le,k as ue,n as j}from"./ParagonContext-BunmP-Wy.js";import{r as M,t as N}from"./useFeatureAccess-B2s_8HPP.js";import{t as P}from"./useUserTeams-CqIhlXQn.js";import{t as F}from"./useIsBillingAdmin-DUc9qReM.js";import{t as I}from"./useIsAuthUserPublicDomain-BcUuCaes.js";var L=e(n()),R=500,z=({provider:e,url:t,onConnect:n,onError:r})=>{let{user:i}=x(),[a,o]=A(`_cap_${e}_user_access_token`,null),[s,c]=A(`_cap_${e}_user_email_access_token`,null),[l,u]=(0,L.useState)(!1),d=(0,L.useRef)(null),f=(0,L.useRef)(null),p=(0,L.useCallback)(()=>{d.current&&(clearInterval(d.current),d.current=null),f.current&&(window.removeEventListener(`message`,f.current),f.current=null)},[]);return(0,L.useEffect)(()=>p,[p]),(0,L.useEffect)(()=>{s&&i?.email&&i?.email!==s&&(o(null),c(null))},[s,i?.email,o,c]),{connect:(0,L.useCallback)(()=>{let a=window.open(t,`${e} Connect`,`width=600,height=600`);if(!a)return;p(),u(!0);let s=async e=>{let t=e.data;t.oAuth2Redirect&&(t.error?await r?.():t.accessToken&&i?.email&&(o(t.accessToken),c(i.email),await n?.()),u(!1),p())};f.current=s,window.addEventListener(`message`,s),d.current=setInterval(()=>{a.closed&&(u(!1),p())},R)},[p,n,r,e,o,c,t,i?.email]),accessToken:a,resetAccess:(0,L.useCallback)(()=>{o(null),c(null)},[o,c]),isConnecting:l}},B=`https://zapier.com/oauth/authorize?client_id=JHUfE73EN7tu0eKJRi360CilTsKBmskofL9RIkX7&redirect_uri=https://tldv.io/app/oauth2/callback&response_type=token&scope=zap`,V=[p.enum.draft,p.enum.disabled,p.enum.paused];function H({status:e,isTested:t}){return e===p.enum.enabled||V.includes(e)&&t}function U(e,t){return e===p.enum.paused?t(`GENERIC.PAUSED`):e===p.enum.enabled?t(`GENERIC.ON`):t(`GENERIC.OFF`)}var W=new Map,G=new WeakMap,K=0,de=void 0;function fe(e){return e?G.has(e)?G.get(e):(K+=1,G.set(e,K.toString()),G.get(e)):`0`}function pe(e){return Object.keys(e).sort().filter(t=>e[t]!==void 0).map(t=>`${t}_${t===`root`?fe(e.root):e[t]}`).toString()}function me(e){let t=pe(e),n=W.get(t);if(!n){let r=new Map,i,a=new IntersectionObserver(t=>{t.forEach(t=>{var n;let a=t.isIntersecting&&i.some(e=>t.intersectionRatio>=e);e.trackVisibility&&t.isVisible===void 0&&(t.isVisible=a),(n=r.get(t.target))==null||n.forEach(e=>{e(a,t)})})},e);i=a.thresholds||(Array.isArray(e.threshold)?e.threshold:[e.threshold||0]),n={id:t,observer:a,elements:r},W.set(t,n)}return n}function he(e,t,n={},r=de){if(window.IntersectionObserver===void 0&&r!==void 0){let i=e.getBoundingClientRect();return t(r,{isIntersecting:r,target:e,intersectionRatio:typeof n.threshold==`number`?n.threshold:0,time:0,boundingClientRect:i,intersectionRect:i,rootBounds:i}),()=>{}}let{id:i,observer:a,elements:o}=me(n),s=o.get(e)||[];return o.has(e)||o.set(e,s),s.push(t),a.observe(e),function(){s.splice(s.indexOf(t),1),s.length===0&&(o.delete(e),a.unobserve(e)),o.size===0&&(a.disconnect(),W.delete(i))}}L.Component;function ge({threshold:e,delay:t,trackVisibility:n,rootMargin:r,root:i,triggerOnce:a,skip:o,initialInView:s,fallbackInView:c,onChange:l}={}){let[u,d]=L.useState(null),f=L.useRef(l),[p,m]=L.useState({inView:!!s,entry:void 0});f.current=l,L.useEffect(()=>{if(o||!u)return;let s;return s=he(u,(e,t)=>{m({inView:e,entry:t}),f.current&&f.current(e,t),t.isIntersecting&&a&&s&&(s(),s=void 0)},{root:i,rootMargin:r,threshold:e,trackVisibility:n,delay:t},c),()=>{s&&s()}},[Array.isArray(e)?e.toString():e,u,i,r,a,o,n,c,t]);let h=p.entry?.target,g=L.useRef(void 0);!u&&h&&!a&&!o&&g.current!==h&&(g.current=h,m({inView:!!s,entry:void 0}));let _=[d,p.inView,p.entry];return _.ref=_[0],_.inView=_[1],_.entry=_[2],_}function q(){let{user:e}=x(),t=F(),n=!!e?.seats&&(e?.seats??0)>0,r=e?.seats;return n&&r===1&&t}function J(){let e=P();return(0,L.useMemo)(()=>e.filter(e=>e.role===c.enum.admin),[e])}function _e(){let e=J(),{hasAccess:t}=N(M.teamIntegrations),n=I(),r=q();return e.length>0&&t&&!n&&!r}var Y=t();function ve(){let{show:e}=_(),t=s(),{mutateAsync:n,isPending:r}
1=l(),[i,a]=(0,L.useState)(null),o=(0,L.useCallback)(e=>{a(e)},[]),c=(0,L.useCallback)(()=>{a(null)},[]),u=(0,L.useCallback)(async()=>{if(i)try{await n(i),e({message:t(`PAGES.INTEGRATIONS.WORKFLOWS.DELETE_CONFIRMATION.SUCCESS`),appearance:`info`,position:`top-center`,leftIcon:(0,Y.jsx)(ne,{className:`text-base-100 mr-2`}),fitContentWidth:!0}),a(null)}catch(n){e({position:`top-center`,message:t(`GENERIC.GENERIC_UPS_ERROR`),appearance:`warning`}),S(new ue({cause:n}))}},[i,n,e,t]);return{workflowToDelete:i,isModalOpen:i!==null,openDeleteModal:o,closeDeleteModal:c,confirmDelete:u,isPending:r}}function ye(){let{show:e}=_(),t=s(),{mutateAsync:n,isPending:r}=f();return{duplicate:(0,L.useCallback)(async(r,i)=>{try{let a=await n({workflowId:r,target:i});return e({message:t(`PAGES.INTEGRATIONS.DUPLICATE_WORKFLOW_SUCCESS`),position:`top-center`,leftIcon:(0,Y.jsx)(v,{className:`text-base-100`}),appearance:`success`}),a.id}catch(n){e({message:t(`PAGES.INTEGRATIONS.DUPLICATE_WORKFLOW_ERROR`),position:`top-center`,appearance:`warning`}),S(new ce({cause:n}))}},[n,e,t]),isPending:r}}var be={enabled:`PAGES.INTEGRATIONS.WORKFLOWS.AUTOMATION_ENABLED_TOAST`,disabled:`PAGES.INTEGRATIONS.WORKFLOWS.DEACTIVATE_TOAST`},xe=e=>e===p.enum.enabled?p.enum.disabled:p.enum.enabled;function Se(){let{show:e}=_(),t=s(),{mutateAsync:n,isPending:r}=u(),i=(0,L.useCallback)(async({workflowId:r,status:i,onSuccess:a,sentryExtra:o})=>{try{await n({workflowId:r,status:i}),await a?.(),e({message:t(be[i]),appearance:`success`,position:`top-center`,leftIcon:(0,Y.jsx)(v,{className:`text-base-100`})})}catch(n){e({message:t(`GENERIC.GENERIC_SOMETHING_WENT_WRONG_MINUTES`),appearance:`warning`,position:`top-center`}),S(new le({cause:n}),{extra:{workflowId:r,targetStatus:i,...o}})}},[t,e,n]);return{isPending:r,setWorkflowStatus:i,toggleWorkflowStatus:(0,L.useCallback)(async({workflowId:e,currentStatus:t,onSuccess:n,sentryExtra:r})=>{let a=xe(t);return i({workflowId:e,status:a,onSuccess:n,sentryExtra:{currentStatus:t,nextStatus:a,...r}})},[i])}}var X=r([`individual`,`team`]),Ce=i({type:X,teamId:a().nullable(),includeAdminRecordings:o()});function Z({disabled:e=!1}){let t=D(),n=J();return(0,Y.jsx)(`div`,{className:`mt-2`,children:(0,Y.jsx)(O,{name:`teamId`,control:t.control,render:({field:r})=>(0,Y.jsx)(oe,{name:`team-select`,disabled:e,defaultValue:r.value,value:r.value,onValueChange:e=>{e!==``&&(r.onChange(e),t.setValue(`type`,X.enum.team))},className:`w-full justify-between items-center bg-base-200 p-2 rounded-lg hover:bg-base-250 transition-colors [&>span]:text-[15px] [&>span]:text-base-500`,contentClassName:`max-w-[var(--radix-select-trigger-width)]`,sideOffset:4,children:n.map(e=>(0,Y.jsx)(se,{size:`s`,value:e.id,className:`w-[var(--radix-select-trigger-width)]`,children:e.name},e.id))})})})}var we=y([`flex gap-2`]),Te=y([`mt-1`]),Ee=y([`flex-1 text-left`]),De=y([`text-base-600 font-medium`]),Oe=y([`text-base-500 mt-1`]);function Q({id:e,value:t,label:n,helpText:r,disabled:i=!1,children:a}){let{control:o}=D();return(0,Y.jsxs)(`div`,{className:we,children:[(0,Y.jsx)(O,{name:`type`,control:o,render:({field:n})=>(0,Y.jsx)(h,{className:Te,id:e,value:t,checked:n.value===t,disabled:i,onClick:()=>n.onChange(t)})}),(0,Y.jsxs)(`div`,{className:Ee,children:[(0,Y.jsx)(m,{asChild:!0,className:De,children:(0,Y.jsx)(`label`,{htmlFor:e,children:n})}),(0,Y.jsx)(ee,{asChild:!0,className:Oe,children:(0,Y.jsx)(`p`,{children:r})}),a]})]})}function ke(e,t){let n=e.ownerType===d.enum.team,r=n&&t.some(t=>t.id===e.ownerId);return{type:n?X.enum.team:X.enum.individual,teamId:r?e.ownerId:t[0]?.id??null,includeAdminRecordings:!1}}function Ae(e,t){return e.type===X.enum.team?e.teamId?{ownerType:d.enum.team,ownerId:e.teamId}:null:t?{ownerType:d.enum.user,ownerId:t}:null}function $(e){let{user:t}=x(),n=J(),r=E({defaultValues:ke(e,n)}),[i,a]=ae({control:r.control,name:[`type`,`teamId`]});return{form:r,target:Ae({type:i,teamId:a},t?.id),isTeamSelected:i===X.enum.team,willDisplayTeamSelect:n.length>1}}var je=y([`flex flex-col gap-6 mt-6`]),Me=y([`flex items-center gap-s mt-6 px-m py-s rounded-lg bg-primary-100`]),Ne=y([`shrink-0 text-primary-400`]),Pe=y([`text-primary-400 font-medium leading-4 md:leading-4`]),Fe=y([`justify-end`]);function Ie({source:e,onConfirm:t,onCancel:n,isDuplicating:r}){let i=s(),{form:a,target:o,isTeamSelected:c,willDisplayTeamSelect:l}=$(e),u=()=>{o&&t(o)};return(0,Y.jsxs)(ie,{...a,children:[(0,Y.jsxs)(`div`,{className:je,children:[(0,Y.jsx)(Q,{id:`duplicate-workflow-individual-radio`,value:X.enum.individual,label:i(`PAGES.INTEGRATIONS.DUPL
1ICATE_WORKFLOW_MODAL.INDIVIDUAL_LABEL`),helpText:i(`PAGES.INTEGRATIONS.DUPLICATE_WORKFLOW_MODAL.INDIVIDUAL_HELP_TEXT`),disabled:r}),(0,Y.jsx)(Q,{id:`duplicate-workflow-team-radio`,value:X.enum.team,label:i(`PAGES.INTEGRATIONS.DUPLICATE_WORKFLOW_MODAL.TEAM_LABEL`),helpText:i(`PAGES.INTEGRATIONS.DUPLICATE_WORKFLOW_MODAL.TEAM_HELP_TEXT`),disabled:r,children:l&&(0,Y.jsx)(Z,{disabled:r||!c})})]}),(0,Y.jsxs)(`div`,{className:Me,children:[(0,Y.jsx)(re,{size:`s`,className:Ne}),(0,Y.jsx)(g,{className:Pe,children:i(`PAGES.INTEGRATIONS.DUPLICATE_WORKFLOW_MODAL.DRAFT_NOTICE`)})]}),(0,Y.jsxs)(w,{containerClassName:Fe,children:[(0,Y.jsx)(b,{"data-testid":`duplicate-workflow-confirm-button`,variant:`primary`,onClick:u,label:i(`PAGES.INTEGRATIONS.DUPLICATE_WORKFLOW_MODAL.CONFIRM`),loading:r,disabled:!o}),(0,Y.jsx)(b,{"data-testid":`duplicate-workflow-cancel-button`,variant:`secondary`,onClick:n,label:i(`GENERIC.CANCEL`),disabled:r})]})]})}function Le({open:e,onOpenChange:t,source:n,onConfirm:r,isDuplicating:i}){let a=s();return(0,Y.jsxs)(T,{open:e,onOpenChange:t,children:[(0,Y.jsx)(C,{title:a(`PAGES.INTEGRATIONS.DUPLICATE_WORKFLOW`)}),(0,Y.jsx)(Ie,{source:n,onConfirm:r,onCancel:()=>t(!1),isDuplicating:i})]})}function Re({open:e,onOpenChange:t,onConfirm:n,isDeleting:r}){let i=s();return(0,Y.jsxs)(T,{open:e,onOpenChange:t,children:[(0,Y.jsx)(C,{title:i(`PAGES.INTEGRATIONS.WORKFLOWS.DELETE_CONFIRMATION.TITLE`),body:i(`PAGES.INTEGRATIONS.WORKFLOWS.DELETE_CONFIRMATION.MESSAGE`)}),(0,Y.jsxs)(w,{children:[(0,Y.jsx)(b,{variant:`warning`,onClick:n,label:i(`GENERIC.DELETE`),loading:r}),(0,Y.jsx)(b,{variant:`secondary`,onClick:()=>t(!1),label:i(`GENERIC.CANCEL`),disabled:r})]})]})}function ze({className:e}){let t=s();return(0,Y.jsx)(`div`,{className:te(`flex items-center gap-1 rounded-3xl bg-orange-100 py-2 px-4`,e),children:(0,Y.jsx)(g,{className:`font-semibold text-orange-400`,children:t(`PAGES.INTEGRATIONS.WORKFLOWS.PAUSED_NOTICE.LABEL`)})})}function Be({entityId:e,entityType:t,refetchOnWindowFocus:n=!1}){let{as:r,getParagon:i,connected:a}=j(),[o,s]=(0,L.useState)(!0),c=(0,L.useCallback)(()=>{if(!a||!e)return;s(!0);let n=i().getUser();if(n.authenticated&&n.userId===e){k.log(`paragon`,`Already authenticated as correct entity`,{id:n.userId}),s(!1);return}k.log(`paragon`,`Re-authenticating as`,{type:t,entityId:e}),r(t,e,()=>{s(!1)})},[a,e,t,r,i]);return(0,L.useEffect)(()=>{c()},[c]),(0,L.useEffect)(()=>{if(!n)return;let e=()=>{document.visibilityState===`visible`&&c()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[n,c]),{isConnecting:!a||o}}export{B as _,Z as a,Se as c,_e as d,J as f,H as g,U as h,Le as i,ye as l,ge as m,ze as n,Ce as o,q as p,Re as r,X as s,Be as t,ve as u,z as v}; 2//# sourceMappingURL=useParagonEntityConnection-BpxWC2wS.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.