1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a0f45b-c6f7-7572-8571-a6f0882a58d6")}catch(e){}}();import{r as N,j as s}from"./1_rjLJJT.js";import{e as O,c as $,u as W,cr as q,z as M,t as F,bm as Q,T as g,cW as B,bJ as K,B as S,bt as V,al as X}from"./Cnl0lOne.js";import{b as L,e as Y,d as Z,S as ee,a as se}from"./B35B_vHQ.js";import{S as H}from"./mrGFdEA4.js";import{u as U,c as ae}from"./IR4uT189.js";import{a as le,u as te,I as ne}from"./iM2HpF5v.js";import{f as ie,a as re,b as oe,c as ce,D as de,e as fe,d as ge}from"./CrTs0UAI.js";import{F as he,n as xe,D as ue}from"./YLLfQEvQ.js";const me=({action:a,additionalState:e})=>{const o=U(),[n,d]=N.useState(!1),[l,i]=N.useState(null),r=le();N.useEffect(()=>{(async()=>{if(O.isNative()&&!n)try{await H.initialize({google:{webClientId:O.googleClientId(),iOSClientId:O.isIOS()?O.googleIOSClientId():void 0,iOSServerClientId:O.googleClientId(),mode:a==="auth"?"online":"offline"}}),d(!0)}catch(t){console.error(t),i(t)}})()},[a,n]);const j=N.useCallback(async()=>{if(n)try{const{result:t}=await H.login({provider:"google",options:{scopes:a==="auth"?["profile","email"]:["https://www.googleapis.com/auth/calendar"],forceRefreshToken:a==="calendar"}});if(a==="calendar"&&t.responseType==="offline"){const c=t.serverAuthCode,f={action:"calendar",...r?{redirect:r}:{},...e??{}},h=new URLSearchParams({idToken:c,code:c,state:JSON.stringify(f)});o(`/google-callback?${h.toString()}`,{replace:!0})}else if(a==="auth"&&t.responseType==="online"&&t.idToken){const c=t.idToken,f=new URLSearchParams({idToken:c,state:JSON.stringify({action:"auth-gis",...r?{redirect:r}:{},...e??{}})});o(`/google-callback?${f.toString()}`,{replace:!0})}}catch(t){i(t)}},[a,e,n,o,r]);return[n,j,l]};function je(a){const e=$.c(23),{personId:o,onDeleted:n}=a,[d,l]=N.useState(!1),i=F.useUtils();let r;e[0]!==i?(r={onSuccess:async()=>{await i.getPersonSettings.invalidate()}},e[0]=i,e[1]=r):r=e[1];const{mutateAsync:j,isPending:t}=F.googleCalendar.disableGoogleCalendarSync.useMutation(r);let c;e[2]!==n||e[3]!==o||e[4]!==j?(c=async()=>{await j({personId:o}),n()},e[2]=n,e[3]=o,e[4]=j,e[5]=c):c=e[5];const f=c;let h;e[6]!==t?(h=w=>{t||l(w)},e[6]=t,e[7]=h):h=e[7];const p=h;let C;e[8]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(ie,{asChild:!0,children:s.jsx(S,{variant:"destructive",className:"p-3 rounded-lg border-ink-black-200 text-ink-black",children:s.jsx(xe,{className:"size-6",strokeWidth:1.25})})}),e[8]=C):C=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsxs(re,{children:[s.jsx(oe,{children:"Remove Google calendar?"}),s.jsx(ce,{children:"This will remove all synced blocks from your calendar."})]}),e[9]=m):m=e[9];let x;e[10]!==t?(x=s.jsx(ue,{asChild:!0,children:s.jsx(S,{variant:"secondary",disabled:t,children:"Cancel"})}),e[10]=t,e[11]=x):x=e[11];const v=t?"Removing...":"Remove";let b;e[12]!==f||e[13]!==t||e[14]!==v?(b=s.jsx(S,{variant:"destructive",onClick:f,disabled:t,children:v}),e[12]=f,e[13]=t,e[14]=v,e[15]=b):b=e[15];let u;e[16]!==x||e[17]!==b?(u=s.jsxs(de,{showClose:!1,children:[m,s.jsxs(fe,{children:[x,b]})]}),e[16]=x,e[17]=b,e[18]=u):u=e[18];let y;return e[19]!==p||e[20]!==d||e[21]!==u?(y=s.jsxs(ge,{open:d,onOpenChange:p,children:[C,u]}),e[19]=p,e[20]=d,e[21]=u,e[22]=y):y=e[22],y}function pe(a){const e=$.c(38),{onHidden:o,onEditCheckForConflicts:n,onEditAddToCalendar:d}=a,{personId:l,handle:i}=W(),r=q(),[j,t]=N.useState(!1),c=M();let f;e[0]!==c||e[1]!==i||e[2]!==l?(f=c("setupGoogleCalendar",{personId:l,handle:i}),e[0]=c,e[1]=i,e[2]=l,e[3]=f):f=e[3];const h=`${f}`;let p;e[4]!==l||e[5]!==h?(p={action:"calendar",additionalState:{personId:l,redirect:h}},e[4]=l,e[5]=h,e[6]=p):p=e[6];const C=te(p);let m;e[7]!==c||e[8]!==i||e[9]!==l?(m=c("setupGoogleCalendar",{personId:l,handle:i}),e[7]=c,e[8]=i,e[9]=l,e[10]=m):m=e[10];const x=`${m}`;let v;e[11]!==l||e[12]!==x?(v={action:"calendar",additionalState:{personId:l,redirect:x}},e[11]=l,e[12]=x,e[13]=v):v=e[13];const[b,u]=me(v),y=!!l;let w;e[14]!==y?(w={enabled:y},e[14]=y,e[15]=w):w=e[15];const{data:D,isLoading:J}=F.getPersonSettings.useQuery(l,w),z=D?.hasGoogleCalendarRefreshToken===!0;let R;e[16]!==o?(R=()=>{o(),t(!0)},e[16]=o,e[17]=R):R=e[17];const I=R;if(J)return null;let k;b?k="native":r?k="instagram":k="redirect";const A=!j;let _;e[18]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(Y,{children:s.jsx(Z,{children:"Calendar Sync"})}),e[18]=_):_=e[18];let T;e[19]!==I||e[20]!==z||e[21]!==d||e[22]!==n||e[23]!==D?.googleCalendarDisabled||e[24]!==l?(T=z&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-5 flex flex-col gap-4",children:[D?.googleCalendarDisabled&&s.jsxs("div",{className:"border border-ink-caution bg-ink-caution/20 rounded-xl flex flex-row gap-2 items-center p-3 text-ink-black-800",children:[s.jsx("div",{children:s.jsx(Q,{size:12,className:"text-ink-caution"})}),s.jsx(g,{size:"sm",className:"leading-snug",children:"Weâre unable to sync your Google Calendar. To resolve this issue, please reconnect your calendar."})]}),s.jsx(g,{size:"sm",className:"text-ink-black",children:D?.googleCalendarDisabled?"Calendar":"Connected calendar"}),s.jsxs("div",{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{className:"flex flex-row gap-3 items-center",children:[s.jsx("div",{className:"h-12 w-12 bg-[#f7f7f7] items-center justify-center flex rounded-lg",children:s.jsx(B,{size:32})}),s.jsx(g,{size:"lg",variant:"heading",children:"Google Calendar"})]}),s.jsx(je,{personId:l,onDeleted:I})]})]}),s.jsx(K,{}),s.jsx(L,{className:"flex-1 bg-ink-white",children:!D?.googleCalendarDisabled&&s.jsxs("div",{className:"px-5 py-6 flex flex-col gap-6",children:[s.jsx(g,{size:"sm",className:"text-ink-black",children:"Configure Google Calendar"}),s.jsxs("div",{className:"flex flex-col gap-10",children:[s.jsxs("div",{className:"flex flex-row items-start gap-4",children:[s.jsx(he,{className:"shrink-0 size-6"}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(g,{size:"lg",variant:"heading",children:"Check for c
1onflicts"}),s.jsx(g,{size:"sm",className:"text-ink-black",children:"Select which calendar(s) you want to check for potential conflicts"})]}),s.jsx(S,{variant:"link",onClick:n,children:"edit"})]}),s.jsxs("div",{className:"flex flex-row items-start gap-4",children:[s.jsx(V,{size:24,className:"shrink-0"}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(g,{size:"lg",variant:"heading",children:"Add to calendar"}),s.jsx(g,{size:"sm",className:"text-ink-black",children:"Choose which calendar you want your appointments to be added to"})]}),s.jsx(S,{variant:"link",onClick:d,children:"edit"})]})]})]})})]}),e[19]=I,e[20]=z,e[21]=d,e[22]=n,e[23]=D?.googleCalendarDisabled,e[24]=l,e[25]=T):T=e[25];let G;e[26]!==k||e[27]!==C||e[28]!==z||e[29]!==u?(G=!z&&s.jsx(L,{className:"flex-1",children:s.jsxs("div",{className:"p-5 flex flex-col gap-8",children:[s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsx(g,{size:"2xl",variant:"heading",children:"Select calendar"}),s.jsx(g,{size:"base",className:"text-ink-black",children:"Connect your calendar to automatically block time and avoid conflicts."})]}),s.jsxs("div",{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{className:"flex flex-row gap-3 items-center",children:[s.jsx("div",{className:"h-12 w-12 bg-[#f7f7f7] items-center justify-center flex rounded-lg",children:s.jsx(B,{size:32})}),s.jsx(g,{size:"lg",variant:"heading",children:"Google Calendar"})]}),k==="native"&&s.jsx("button",{onClick:u,children:s.jsx(S,{children:"Connect"})}),k==="instagram"&&s.jsx(ne,{children:s.jsx(S,{className:"h-8 px-4 py-0 rounded-lg text-sm font-medium",children:"Connect"})}),k==="redirect"&&s.jsx("a",{href:C,children:s.jsx(S,{children:"Connect"})})]})]})}),e[26]=k,e[27]=C,e[28]=z,e[29]=u,e[30]=G):G=e[30];let P;e[31]!==T||e[32]!==G?(P=s.jsx(ee,{className:"h-full bg-ink-white pt-0 flex flex-col gap-0",side:"right",showClose:!0,children:s.jsxs("div",{className:"h-full flex flex-col justify-between",children:[_,T,G]})}),e[31]=T,e[32]=G,e[33]=P):P=e[33];let E;return e[34]!==I||e[35]!==A||e[36]!==P?(E=s.jsx(se,{open:A,onOpenChange:I,children:P}),e[34]=I,e[35]=A,e[36]=P,e[37]=E):E=e[37],E}function Ce(){const a=$.c(7),e=U(),[o,n]=ae(),{toast:d}=X();let l,i;a[0]!==o||a[1]!==n||a[2]!==d?(l=()=>{o.get("error")==="true"&&(d({title:"Calendar Not Connected",description:"Connect your Google Calendar to enable syncing. Try again.",variant:"error"}),n(ve))},i=[o,n,d],a[0]=o,a[1]=n,a[2]=d,a[3]=l,a[4]=i):(l=a[3],i=a[4]),N.useEffect(l,i);let r;return a[5]!==e?(r=s.jsx(pe,{onHidden:()=>{e("../",{preventScrollReset:!0})},onEditCheckForConflicts:()=>{e("../calendar-conflicts")},onEditAddToCalendar:()=>{e("../add-to-calendar")}}),a[5]=e,a[6]=r):r=a[6],r}function ve(a){return a.delete("error"),a}const Ie=Object.freeze(Object.defineProperty({__proto__:null,default:Ce},Symbol.toStringTag,{value:"Module"}));export{Ie as c,me as u}; 2 3//# chunkId=01a0f45b-c6f7-7572-8571-a6f0882a58d6
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.