@villagehq/extension-sdk
Version:
Village Chrome Extension SDK for Partner Integrations
5 lines • 59.1 kB
JavaScript
(function(H,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],T):(H=typeof globalThis<"u"?globalThis:H||self,T(H.VillageExtension={},H.axios))})(this,function(H,T){"use strict";const Ve=T.create({baseURL:"https://app.posthog.com"});Ve.interceptors.request.use(e=>(e.data={...e.data,api_key:"phc_cWZiUS6cHGvUDyCMDRK8Cvoayv5m6x6YOT02RW91vOX"},e));const Le="isPathsEverywhereActive",oe="village.paths-everywhere.is-active";function We(e){const t={VITE_VILLAGE_API_URL:"https://api.village.do/",VITE_VILLAGE_FRONTEND_URL:"https://village.do/",VITE_POSTHOG_KEY:"phc_cWZiUS6cHGvUDyCMDRK8Cvoayv5m6x6YOT02RW91vOX",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}[e];if(!t)throw console.error(`Missing required environment variable: ${e}`),new Error(`Env var ${e} is not defined`);return t}const M=We("VITE_VILLAGE_API_URL"),Se=We("VITE_VILLAGE_FRONTEND_URL");function Et(e){for(var t="",n=0;n<e.length;n++){var o=e.charCodeAt(n),i=o+1;t+=String.fromCharCode(i)}return t}const ce=e=>Object.keys(e).length===0,bt=()=>Math.random().toString(36).substring(2,9)+new Date().getTime();function de(e){if(!e)return"";const{rootUrl:t,artifacts:n}=e;if(!t||!n||!n.length)return"";const o=n[n.length-1];return`${t}${o.fileIdentifyingUrlPathSegment}`}function kt(e,...t){return t.reduce((n,o)=>n&&n[o],e)}const xt=e=>{var t={};const{miniProfile:n}=e.profile;t.linkedin_id=e.entityUrn||"",t.firstname=e.profile.firstName||"",t.lastname=e.profile.lastName||"",t.profile_url="https://www.linkedin.com/in/"+n.publicIdentifier,t.avatar_url=n.picture&&de(n.picture["com.linkedin.common.VectorImage"]),t.country=e.profile.geoCountryName||"",t.location=e.profile.geoLocationName||"",t.number_of_connections="",t.about=e.profile.summary||"",t.headline=e.profile.headline||"",t.industryName=e.profile.industryName||"",t.job_history=[];var o=e.positionGroupView;if(o&&o.elements&&o.elements.length>0)for(var i=o.elements,r=0;r<i.length;r++){var s=i[r].positions;for(const _ of s){var c={};c.position=_.title,c.company_name=_.companyName;var d=_.timePeriod||{};typeof d.startDate<"u"&&(c.date_from=d.startDate),typeof d.endDate<"u"&&(c.date_to=d.endDate);var g="",l="",u=i[r].miniCompany||{},y=u.logo,h=u.universalName;y&&typeof y["com.linkedin.common.VectorImage"]<"u"&&(g=de(y["com.linkedin.common.VectorImage"])),h&&(l="https://www.linkedin.com/company/"+h),c.logo_url=g,c.linkedin_url=l,t.job_history.push(c)}}t.education_history=[];var p=e.educationView;if(p&&p.elements&&p.elements.length>0)for(var v=p.elements,E=0;E<v.length;E++){var w={};w.major_program_certificate=v[E].degreeName||"",w.field_of_study=v[E].fieldOfStudy||"",w.school_name=v[E].schoolName||"";var d=v[E].timePeriod||{};typeof d.startDate<"u"&&(w.date_from=d.startDate),typeof d.endDate<"u"&&(w.date_to=d.endDate);var g="",l="",b=v[E].school||{},y=b.logo||{},L=b.entityUrn||"";y&&typeof y["com.linkedin.common.VectorImage"]<"u"&&(g=de(y["com.linkedin.common.VectorImage"])),L=L.replace("urn:li:fs_miniSchool:",""),L&&(l="https://www.linkedin.com/school/"+L),w.logo_url=g,w.linkedin_url=l,t.education_history.push(w)}return t},Lt=e=>{const{connectedMemberResolutionResult:t,entityUrn:n,createdAt:o}=e,i=kt(t,"profilePicture","displayImageReference","vectorImage");return{avatar_url:de(i),full_name:`${t.firstName} ${t.lastName}`,profile_id:t.publicIdentifier,linkedin_id:n.replace("urn:li:fsd_connection:",""),created_at:new Date(o)}};function P(e){return new Promise(t=>{chrome.storage.sync.get([e],n=>{t(n[e])})})}function R(e,t){return new Promise(n=>{chrome.storage.sync.set({[e]:t},()=>{n()})})}function He(e){return new Promise((t,n)=>{var o={};Q().then(i=>{T.get("https://www.linkedin.com/voyager/api/identity/profiles/"+e+"/profileContactInfo",{headers:{"csrf-token":i},withCredentials:!0}).then(({data:r})=>{r&&r.emailAddress&&(o.emailAddress=r.emailAddress),r&&r.websites&&(o.websites=r.websites),r&&r.twitterHandles&&(o.twitterHandles=r.twitterHandles),r&&r.phoneNumbers&&(o.phoneNumbers=r.phoneNumbers),t(o)}).catch(()=>{t(o)})})})}function Ce(e){return new Promise((t,n)=>{var o={};Q().then(i=>{T.get("https://www.linkedin.com/voyager/api/identity/profiles/"+e+"/profileView",{headers:{"csrf-token":i,accept:"*"},withCredentials:!0}).then(({data:r})=>{r&&r.entityUrn&&(o=r),t(o)}).catch(()=>{t(o)})})})}function St(e){var n,o,i;const t=e==null?void 0:e.data;try{return!t||!((i=(o=(n=t==null?void 0:t.searchDashClustersByAll)==null?void 0:n.elements)==null?void 0:o[0])!=null&&i.items)?[]:t.searchDashClustersByAll.elements[0].items.filter(r=>{var s;return(s=r==null?void 0:r.item)==null?void 0:s.entityResult}).map(r=>{var l,u,y,h,p,v,E;const s=r.item.entityResult,c=s.navigationUrl||"",d=((y=(u=(l=c.split("/in/"))==null?void 0:l[1])==null?void 0:u.split("?"))==null?void 0:y[0])||"",g=new URL(c);return{name:((h=s.title)==null?void 0:h.text)||"",slug:d,headline:((p=s.primarySubtitle)==null?void 0:p.text)||"",location:((v=s.secondarySubtitle)==null?void 0:v.text)||"",profileUrl:g.origin+g.pathname,distance:((E=s.entityCustomTrackingInfo)==null?void 0:E.memberDistance)||""}})}catch(r){return console.error("Error parsing mutual connections:",r),[]}}function Ct(e){return new Promise((t,n)=>{Ce(e).then(o=>{if(!o.entityUrn)throw new Error("Could not get profile details");const i=o.entityUrn.replace("urn:li:fs_profileView:","");return Q().then(async r=>{const s=[],g=l=>new Promise(u=>setTimeout(u,l));for(let l=0;l<5;l++){const y=`https://www.linkedin.com/voyager/api/graphql?variables=(start:${l*50},count:50,origin:MEMBER_PROFILE_CANNED_SEARCH,query:(flagshipSearchIntent:SEARCH_SRP,queryParameters:List((key:connectionOf,value:List(${i})),(key:network,value:List(F)),(key:resultType,value:List(PEOPLE))),includeFiltersInResponse:false))&queryId=voyagerSearchDashClusters.92cc53470cef3c578ab1d34676d5320c`;try{const h=await T.get(y,{headers:{"csrf-token":r,accept:"*/*"},withCredentials:!0}),p=St(h.data);if(!p||p.length===0)break;if(s.push(...p),l<5-1){const v=Math.floor(Math.random()*501)+500;await g(v)}}catch{}}return s})}).then(o=>{t(o)}).catch(o=>{console.error("Error fetching mutual connections:",o),n(o)})})}function Q(){return new Promise((e,t)=>{chrome.cookies.get({url:"https://www.linkedin.com",name:"JSESSIONID"},function(o){e((o||{}).value.replace(/"/g,""))})})}function It(e){var be,yt,wt;const t="sdk_debug_mode";var o=[];const i=async(a,f,m={},x=!1)=>{const S={ts:new Date().toISOString(),lvl:a,msg:f,ctx:m};try{((await chrome.storage.local.get([t]))[t]||x)&&(console[a]||console.log)(`[village-extension-sdk] ${f}`,m&&Object.keys(m).length>0?m:""),o.push(S),o.length>500&&(o=o.slice(o.length-500))}catch(C){console.error("[village-extension-sdk] Failed to write SDK log:",C,S)}},r=async()=>{try{console.log(`--- Village Extension SDK Logs (Last ${o.length}) ---`),console.table(o)}catch(a){console.error("[village-extension-sdk] Failed to retrieve logs:",a)}},s=async()=>{try{await chrome.storage.local.set({[t]:!0}),i("warn","Village Extension SDK Debug Mode ENABLED. Verbose logs will now appear in the console."),console.log("[village-extension-sdk] Debug mode enabled.")}catch(a){console.error("[village-extension-sdk] Failed to enable debug mode:",a)}},c=async()=>{try{await chrome.storage.local.set({[t]:!1}),i("warn","Village Extension SDK Debug Mode DISABLED."),console.log("[village-extension-sdk] Debug mode disabled.")}catch(a){console.error("[village-extension-sdk] Failed to disable debug mode:",a)}},d=()=>{try{o=[],i("warn","Village Extension SDK logs cleared."),console.log("[village-extension-sdk] Logs cleared.")}catch(a){console.error("[village-extension-sdk] Failed to clear logs:",a)}};self.villageExtension={getLogs:r,enableDebug:s,disableDebug:c,clearLogs:d},(()=>{const a={runtime:chrome==null?void 0:chrome.runtime,storage:chrome==null?void 0:chrome.storage,alarms:chrome==null?void 0:chrome.alarms,webRequest:chrome==null?void 0:chrome.webRequest,webNavigation:chrome==null?void 0:chrome.webNavigation,cookies:chrome==null?void 0:chrome.cookies,tabs:chrome==null?void 0:chrome.tabs,permissions:chrome==null?void 0:chrome.permissions};let f=!0;for(const[m,x]of Object.entries(a))x||(i("error",`Critical Chrome API missing for Village Extension SDK: chrome.${m}. Check manifest.json or browser compatibility.`,{},!0),f=!1);return f&&i("info","All critical Chrome APIs for Village Extension SDK seem present."),f})(),i("info","ServiceWorker initializing...",{CONFIG:e,manifestVersion:(wt=(yt=(be=chrome==null?void 0:chrome.runtime)==null?void 0:be.getManifest)==null?void 0:yt.call(be))==null?void 0:wt.version}),i("info","Checking permissions...");const l=["cookies","storage","webRequest","alarms","webNavigation"];chrome&&chrome.permissions?chrome.permissions.contains({permissions:l},a=>{a?i("info","All required permissions for Village Extension SDK granted."):(i("warn",`Missing required permissions for Village Extension SDK. Ensure these are granted: ${l.join(", ")}`),console.error(`[village-extension-sdk] Missing required permissions. Ensure these are granted: ${l.join(", ")}`))}):i("warn","Cannot check permissions for Village Extension SDK (chrome.permissions API not available).");async function u(){const[a,f,m,x]=await Promise.allSettled([P("linkedin_login"),P("linkedin_loggedin_email"),P("frontend_login"),P("user_logged_obj")]).then(A=>A.map(X=>X.status==="fulfilled"?X.value:null)),S=chrome.runtime.getManifest().version;return{linkedin_login:a,linkedin_loggedin_email:f,frontend_login:m,user_logged_obj:x,version:S}}async function y({url:a}){var f;try{const m=await b(),x=await u();if(!m)return{message:"Login on Village to find the best possible paths",redirect:!0};const{data:S}=await T.post(`${M}paths-check`,{url:a},{headers:{"x-access-token":m}});return{...S,token:m,userReference:(f=x==null?void 0:x.user_logged_obj)==null?void 0:f.id}}catch{}}async function h(){if(!await v())return{};const f=await Q();let m=await P("linkedin_loggedin_email");if(m)return{email:m};try{const{data:x}=await T.get("https://www.linkedin.com/voyager/api/identity/profiles/me/profileContactInfo",{headers:{"csrf-token":f},withCredentials:!0});if(x&&x.emailAddress){let S=x.emailAddress;return S.indexOf("phishing")>=0&&(S=decodeURIComponent(S).replace(/(.*?)https:.*?=(.*)/,"$1$2")),await R("linkedin_loggedin_email",S),{email:S}}}catch{return{}}return{}}async function p({message:a,data:f}){try{const m=await P("user_logged_obj");return await T.post(M+"extension/logger",{message:a,data:f,user:!m||ce(m)?null:m}),"ok"}catch{return"error"}}function v(){return new Promise((a,f)=>{chrome.cookies.get({url:"https://www.linkedin.com/",name:"li_at"},async function(m){m!=null?(await R("linkedin_login",!0),a(!0)):(await R("linkedin_login",!1),Vn(),a(!1))})})}function E({token:a}){return new Promise((f,m)=>{chrome.cookies.set({url:`${Se}`,name:"village.token",value:a},()=>f(!0))})}var w=null;function b(){return new Promise((a,f)=>{chrome.cookies.get({url:`${Se}`,name:"village.token"},async function(m){const x=m!==null;w!==x&&(await R("frontend_login",x),w=x),a(x?m.value:!1)})})}chrome.runtime.onMessageExternal.addListener(function(a,f,m){setTimeout(()=>i("info","Received external message",{type:a==null?void 0:a.message,hasCallback:!!m,senderId:f==null?void 0:f.id,senderUrl:f==null?void 0:f.url}),0);const x=["getExtensionStatus","livelinessCheck","fillUpEmail","GET_MUTUAL_CONNECTIONS"];return a&&a.message&&x.includes(a.message)?((async()=>{try{if(a.message==="getExtensionStatus"){const C=await u();m(C),a.shouldTriggerReset&&k()}else if(a.message==="livelinessCheck"){const C=await Bn();m(C)}else if(a.message==="fillUpEmail")chrome.tabs.create({url:"https://mail.google.com",active:!0},C=>{const A=setInterval(()=>{chrome.tabs.sendMessage(C.id,{type:"fillUpEmail",email:a.email},function(X){if(!chrome.runtime.lastError&&X)return clearInterval(A)})},500)});else if(a.message==="GET_MUTUAL_CONNECTIONS"){const{profileSlug:C}=a;if(!C){m({error:!0,message:"Profile slug is required"});return}try{const A=await Ct(C);m(A)}catch(A){m({error:!0,message:A==null?void 0:A.message})}}}catch(C){try{m({error:!0,message:(C==null?void 0:C.message)||"Unknown error"})}catch{}}})().catch(C=>{}),!0):!1});async function L(){const a=await u(),f={is_loggedin_on_linkedin:a.linkedin_login,linkedin_email:a.linkedin_loggedin_email},m=await b();f.is_loggedin_on_frontend=!!m;const x=await P(Le);f.is_paths_everywhere_settings_enabled=!!x;const S=await P(oe);f.is_paths_everywhere_floating_enabled=S!=="DISABLED",pt({eventName:"Extension daily report",properties:f,force:!0})}async function _(a){p({message:"✅ STARTED saveLinkedinConnectionsIds",data:null});try{const f=await b();if(await v()==!0){const x=await Q();let S=!0,C=a||0;for(;S;){p({message:"⏱ TIMEOUT...",data:null}),p({message:`ℹ️ START FROM: ${C}`,data:null});try{const{data:A}=await T.get("https://www.linkedin.com/voyager/api/relationships/dash/connections?decorationId=com.linkedin.voyager.dash.deco.web.mynetwork.ConnectionListWithProfile-15&count=500&q=search&sortType=RECENTLY_ADDED&start="+C,{headers:{"csrf-token":x},withCredentials:!0});p({message:"🗣 RESPONSE DATA",data:A});const{elements:X}=A,U=X.filter(xe=>xe.connectedMemberResolutionResult).map(xe=>Lt(xe)),ke=X.length<500;await T.post(M+"extension/saveids",{connections:U,isFinished:ke,startFrom:ke?C:C+500},{headers:{"x-access-token":f}}),p({message:`📥 SAVING ${U.length} IDs`,data:null}),ke?(p({message:"✅ isFinished -> Number of IDs < 500",data:null}),S=!1,await R("fetched_connections",!0)):(p({message:"🔁 Continue looping -> Number of IDs = 500",data:null}),C+=500)}catch(A){p({message:"🚫 FAILED saveLinkedinConnectionsIds (while fetching from Linkedin)",data:A.response&&A.response.data?A.response.data:A.response})}}}else p({message:"🚫 NOT LOGGED ON LINKEDIN",data:null})}catch(f){p({message:"🚫 FAILED saveLinkedinConnectionsIds",data:f})}}async function k(){const a=await P("user_logged_obj");if(a&&!ce(a)&&(a!=null&&a.name))if(await v()==!0){const{email:m}=await h(),x=await b();if(!x)return p({message:"🚫 FAILED getUserIntegration -> Not logged in on App",data:null});try{const{data:S}=await T.post(M+"extension/integration",{linkedinEmail:m,extensionId:chrome.runtime.id},{headers:{"x-access-token":x}});await R("user_integration",S),le(S)}catch(S){return S&&S.response&&S.response.status&&Number(S.response.status)===400&&Wn(),p({message:"🚫 FAILED getUserIntegration",data:S}),S}}else p({message:"🚫 FAILED getUserIntegration -> Not logged in on Linkedin",data:null});else I()}async function N(){if(!await v())return p({message:"🚫 [extensionLogin]: Not logged in on Linkedin"});const{email:f}=await h(),{data:m}=await T.get(`${M}lilo?e=${encodeURIComponent(Et(f))}`);m.t&&(await E({token:m.t}),I())}async function I(){const a=await b();if(!a)return N(),p({message:"⚠️ [extensionLogin] -> Not logged in on App 👉 attempting Loging in the user via Linkedin",data:null});try{const{data:f}=await T.get(M+"user",{headers:{"x-access-token":a}});await R("user_logged_obj",f),k()}catch(f){return p({message:"⚠️ [extensionLogin] -> Error on try/catch block",data:f}),f}}var O=!1;async function le(a){if(!O){O=!0;try{const f=a.sync_data||!1;(!f||!f.user_profile)&&await Gn(),(!f.connection_ids||!f.connection_ids.is_finished)&&await _(f.connection_ids&&f.connection_ids.start_from?f.connection_ids.start_from:void 0)}catch(f){p({message:"🚫 FAILED handleUserIntegration",data:f})}O=!1}}async function Bn(){const a={getProfileUserDetails:!1,getContactInfo:!1,getLinkedinLoggedinUserInfo:!1,getProfileConnections:!1};try{await Ce("me"),a.getProfileUserDetails=!0}catch{a.getProfileUserDetails=!1}try{await He("me"),a.getContactInfo=!0}catch{a.getContactInfo=!1}try{await h(),a.getLinkedinLoggedinUserInfo=!0}catch{a.getLinkedinLoggedinUserInfo=!1}try{const f=await Q();await T.get("https://www.linkedin.com/voyager/api/relationships/dash/connections?decorationId=com.linkedin.voyager.dash.deco.web.mynetwork.ConnectionListWithProfile-15&count=500&q=search&sortType=RECENTLY_ADDED&start=0",{headers:{"csrf-token":f},withCredentials:!0}),a.getProfileConnections=!0}catch{a.getProfileConnections=!1}return a}async function Gn(){p({message:"✅ STARTED getAndSendUsersProfileData",data:null});try{const m=await He("me"),x=await Ce("me");var a=xt(x);a.contact_info=m,a.public_identifier=x.profile.miniProfile.publicIdentifier}catch(m){p({message:`🚫 FAILED parsing user profile data - error: ${m.message}`,data:m})}const f=await b();if(!f)return p({message:"🚫 FAILED getAndSendUsersProfileData -> Not logged in on App",data:null});try{const m=await T.post(M+"extension/saveuserprofile",{userProfileData:a},{headers:{"x-access-token":f}});await R("saved_profile",!0);return}catch(m){throw p({message:"🚫 FAILED getAndSendUsersProfileData",data:m}),new Error("Failed to save user profile data")}}async function Vn(){const a=await b();if(!a)return p({message:"🚫 FAILED notifyUserLinkedinLogin -> Not logged in on App",data:null});try{await T.get(M+"notify-linkedin",{headers:{"x-access-token":a}})}catch(f){return p({message:"🚫 FAILED notifyUserLinkedinLogin",data:f}),f}}async function Wn(){const a=await P("user_logged_obj");if(a&&!ce(a))try{await T.get(`${M}notify-app/${a.id}`)}catch(f){return p({message:"🚫 FAILED notifyUserAppLogin",data:f}),f}else p({message:"🚫 FAILED notifyUserAppLogin",data:"Empty user_logged_obj"})}async function pt({eventName:a,properties:f,force:m}){const x=await P("user_logged_obj");try{if(!x||ce(x)&&!m)return;const S=x.id||bt(),C={event:a,properties:{...f,distinct_id:S}},[A]=await Promise.allSettled([Ve.post("/capture",C)])}catch{}}async function mt(a,f){var m,x,S,C,A;if(f){if(!await b())return;new URL(f);const U=await P("user_logged_obj");if(!!!(U!=null&&U.last_cache_date)||!((C=(S=(x=(m=U==null?void 0:U.app)==null?void 0:m.config)==null?void 0:x.features)==null?void 0:S.pathsEverywhere)==null?void 0:C.enabled)||f.includes((A=U==null?void 0:U.app)==null?void 0:A.domain_name)||f.includes("village.do"))return;P(Le).then(Ge=>{const vt=typeof Ge>"u";if(vt&&R(Le,!0),Ge||vt)try{chrome.tabs.sendMessage(a,{type:"pathsEverywhere"},Hn=>{chrome.runtime.lastError})}catch{}}).catch(Ge=>{})}}chrome.runtime.onMessage.addListener((a,f,m)=>(console.log("[EXT] Received message:",a),["village:bind:extension","saveUISettings","getUserIntegration","getSettings","checkPaths","tracking"].includes(a.command)?(console.log(`[EXT] Handling known command: ${a.command}`),(async()=>{try{switch(console.log("[EXT] getUserIntegration switch ",a.command),a.command){case"village:bind:extension":await R("village:bind:extension",a.data),m({success:!0});break;case"saveUISettings":await R("user_logged_obj",a.data),m({success:!0});break;case"getUserIntegration":await k(),m({success:!0});break;case"getSettings":const C=await u();m({uiSettings:C});break;case"checkPaths":const A=await y({url:a.url});m(A);break;case"tracking":await pt({eventName:a.eventName,properties:a.properties}),m({success:!0});break}}catch(C){console.error("[EXT] Error handling command:",C),m({error:C.message})}})().catch(C=>{console.error("[EXT] Async operation error:",C)}),console.log("[EXT] Unknown command received, ignoring:",a.command),!0):!1)),i("info","Setting up alarms...");try{chrome&&chrome.alarms&&(i("info","Attempting to clear/create getUserIntegration alarm."),chrome.alarms.clear("getUserIntegration",a=>{chrome.runtime.lastError?i("error","Error clearing getUserIntegration alarm",{error:chrome.runtime.lastError.message}):(i("info",`getUserIntegration alarm cleared (existed: ${a})`),chrome.alarms.create("getUserIntegration",{delayInMinutes:60,periodInMinutes:60}),i("info","Created getUserIntegration alarm (60 min period)."))}),i("info","Attempting to clear/create dailyReport alarm."),chrome.alarms.clear("dailyReport",a=>{chrome.runtime.lastError?i("error","Error clearing dailyReport alarm",{error:chrome.runtime.lastError.message}):(i("info",`dailyReport alarm cleared (existed: ${a})`),chrome.alarms.create("dailyReport",{delayInMinutes:5,periodInMinutes:1440}),i("info","Created dailyReport alarm (24 hour period)."))}))}catch(a){i("error","Unexpected error during alarm setup",{error:a==null?void 0:a.message,stack:a==null?void 0:a.stack})}i("info","Alarm setup phase complete."),i("info","Attaching webRequest listeners...");try{chrome.webRequest.onBeforeSendHeaders.addListener(async function(a){return a.url.indexOf("signin")>0||a.url.indexOf("login-submit")>0?(await R("linkedin_login",!0),await new Promise(f=>setTimeout(f,7500)),k()):a.url.indexOf("/logout")>0&&await R("linkedin_login",!1),{requestHeaders:a.requestHeaders}},{urls:["*://*.linkedin.com/*/*"]},["requestHeaders"])}catch(a){i("error","Failed to attach LinkedIn webRequest listener",{error:a==null?void 0:a.message},!0)}try{chrome.webRequest.onBeforeSendHeaders.addListener(async function(a){return a.url.indexOf("/callback")>0?(await R("frontend_login",!0),await new Promise(f=>setTimeout(f,7500)),k()):a.url.indexOf("/logout")>0&&await R("frontend_login",!1),{requestHeaders:a.requestHeaders}},{urls:[`${M}*`,`${M}*/*/*`]},["requestHeaders"])}catch(a){i("error","Failed to attach Frontend webRequest listener",{error:a==null?void 0:a.message},!0)}chrome.alarms.onAlarm.addListener(function(a){i("info",`Alarm triggered: ${a.name}`),a.name=="getUserIntegration"&&k().catch(f=>{}),a.name==="dailyReport"&&L().catch(f=>{})}),chrome.runtime.onInstalled.addListener(a=>{I().catch(f=>{})}),chrome.runtime.onStartup.addListener(()=>{I().catch(a=>{})}),chrome.tabs.onUpdated.addListener((a,f)=>{mt(a,f.url).catch(m=>{})}),chrome.webNavigation.onCompleted.addListener(a=>{const{tabId:f,url:m}=a;mt(f,m).catch(x=>{})})}const _t=["top","right","bottom","left"],ue=Math.min,Y=Math.max,fe=Math.round,ge=Math.floor,B=e=>({x:e,y:e});function je(e,t,n){return Y(e,ue(t,n))}function Ie(e,t){return typeof e=="function"?e(t):e}function _e(e){return e.split("-")[0]}function At(e){return e.split("-")[1]}function ze(e){return e==="x"?"y":"x"}function Tt(e){return e==="y"?"height":"width"}function Ae(e){return["top","bottom"].includes(_e(e))?"y":"x"}function Ot(e){return ze(Ae(e))}function Pt(e){return{top:0,right:0,bottom:0,left:0,...e}}function Rt(e){return typeof e!="number"?Pt(e):{top:e,right:e,bottom:e,left:e}}function he(e){const{x:t,y:n,width:o,height:i}=e;return{width:o,height:i,top:n,left:t,right:t+o,bottom:n+i,x:t,y:n}}function Ke(e,t,n){let{reference:o,floating:i}=e;const r=Ae(t),s=Ot(t),c=Tt(s),d=_e(t),g=r==="y",l=o.x+o.width/2-i.width/2,u=o.y+o.height/2-i.height/2,y=o[c]/2-i[c]/2;let h;switch(d){case"top":h={x:l,y:o.y-i.height};break;case"bottom":h={x:l,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:u};break;case"left":h={x:o.x-i.width,y:u};break;default:h={x:o.x,y:o.y}}switch(At(t)){case"start":h[s]-=y*(n&&g?-1:1);break;case"end":h[s]+=y*(n&&g?-1:1);break}return h}const Dt=async(e,t,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:s}=n,c=r.filter(Boolean),d=await(s.isRTL==null?void 0:s.isRTL(t));let g=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:l,y:u}=Ke(g,o,d),y=o,h={},p=0;for(let v=0;v<c.length;v++){const{name:E,fn:w}=c[v],{x:b,y:L,data:_,reset:k}=await w({x:l,y:u,initialPlacement:o,placement:y,strategy:i,middlewareData:h,rects:g,platform:s,elements:{reference:e,floating:t}});l=b??l,u=L??u,h={...h,[E]:{...h[E],..._}},k&&p<=50&&(p++,typeof k=="object"&&(k.placement&&(y=k.placement),k.rects&&(g=k.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:i}):k.rects),{x:l,y:u}=Ke(g,y,d)),v=-1)}return{x:l,y:u,placement:y,strategy:i,middlewareData:h}};async function Te(e,t){var n;t===void 0&&(t={});const{x:o,y:i,platform:r,rects:s,elements:c,strategy:d}=e,{boundary:g="clippingAncestors",rootBoundary:l="viewport",elementContext:u="floating",altBoundary:y=!1,padding:h=0}=Ie(t,e),p=Rt(h),E=c[y?u==="floating"?"reference":"floating":u],w=he(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(E)))==null||n?E:E.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:g,rootBoundary:l,strategy:d})),b=u==="floating"?{x:o,y:i,width:s.floating.width,height:s.floating.height}:s.reference,L=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c.floating)),_=await(r.isElement==null?void 0:r.isElement(L))?await(r.getScale==null?void 0:r.getScale(L))||{x:1,y:1}:{x:1,y:1},k=he(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:b,offsetParent:L,strategy:d}):b);return{top:(w.top-k.top+p.top)/_.y,bottom:(k.bottom-w.bottom+p.bottom)/_.y,left:(w.left-k.left+p.left)/_.x,right:(k.right-w.right+p.right)/_.x}}function qe(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Xe(e){return _t.some(t=>e[t]>=0)}const Nt=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:o="referenceHidden",...i}=Ie(e,t);switch(o){case"referenceHidden":{const r=await Te(t,{...i,elementContext:"reference"}),s=qe(r,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:Xe(s)}}}case"escaped":{const r=await Te(t,{...i,altBoundary:!0}),s=qe(r,n.floating);return{data:{escapedOffsets:s,escaped:Xe(s)}}}default:return{}}}}},Ut=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:i}=t,{mainAxis:r=!0,crossAxis:s=!1,limiter:c={fn:E=>{let{x:w,y:b}=E;return{x:w,y:b}}},...d}=Ie(e,t),g={x:n,y:o},l=await Te(t,d),u=Ae(_e(i)),y=ze(u);let h=g[y],p=g[u];if(r){const E=y==="y"?"top":"left",w=y==="y"?"bottom":"right",b=h+l[E],L=h-l[w];h=je(b,h,L)}if(s){const E=u==="y"?"top":"left",w=u==="y"?"bottom":"right",b=p+l[E],L=p-l[w];p=je(b,p,L)}const v=c.fn({...t,[y]:h,[u]:p});return{...v,data:{x:v.x-n,y:v.y-o,enabled:{[y]:r,[u]:s}}}}}};function pe(){return typeof window<"u"}function ee(e){return Ye(e)?(e.nodeName||"").toLowerCase():"#document"}function D(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function G(e){var t;return(t=(Ye(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ye(e){return pe()?e instanceof Node||e instanceof D(e).Node:!1}function F(e){return pe()?e instanceof Element||e instanceof D(e).Element:!1}function V(e){return pe()?e instanceof HTMLElement||e instanceof D(e).HTMLElement:!1}function Ze(e){return!pe()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof D(e).ShadowRoot}function ie(e){const{overflow:t,overflowX:n,overflowY:o,display:i}=$(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!["inline","contents"].includes(i)}function Mt(e){return["table","td","th"].includes(ee(e))}function me(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function Oe(e){const t=Pe(),n=F(e)?$(e):e;return["transform","translate","scale","rotate","perspective"].some(o=>n[o]?n[o]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(o=>(n.willChange||"").includes(o))||["paint","layout","strict","content"].some(o=>(n.contain||"").includes(o))}function Ft(e){let t=j(e);for(;V(t)&&!te(t);){if(Oe(t))return t;if(me(t))return null;t=j(t)}return null}function Pe(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function te(e){return["html","body","#document"].includes(ee(e))}function $(e){return D(e).getComputedStyle(e)}function ye(e){return F(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function j(e){if(ee(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ze(e)&&e.host||G(e);return Ze(t)?t.host:t}function Je(e){const t=j(e);return te(t)?e.ownerDocument?e.ownerDocument.body:e.body:V(t)&&ie(t)?t:Je(t)}function re(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=Je(e),r=i===((o=e.ownerDocument)==null?void 0:o.body),s=D(i);if(r){const c=Re(s);return t.concat(s,s.visualViewport||[],ie(i)?i:[],c&&n?re(c):[])}return t.concat(i,re(i,[],n))}function Re(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Qe(e){const t=$(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const i=V(e),r=i?e.offsetWidth:n,s=i?e.offsetHeight:o,c=fe(n)!==r||fe(o)!==s;return c&&(n=r,o=s),{width:n,height:o,$:c}}function De(e){return F(e)?e:e.contextElement}function ne(e){const t=De(e);if(!V(t))return B(1);const n=t.getBoundingClientRect(),{width:o,height:i,$:r}=Qe(t);let s=(r?fe(n.width):n.width)/o,c=(r?fe(n.height):n.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}const $t=B(0);function et(e){const t=D(e);return!Pe()||!t.visualViewport?$t:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Bt(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==D(e)?!1:t}function Z(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),r=De(e);let s=B(1);t&&(o?F(o)&&(s=ne(o)):s=ne(e));const c=Bt(r,n,o)?et(r):B(0);let d=(i.left+c.x)/s.x,g=(i.top+c.y)/s.y,l=i.width/s.x,u=i.height/s.y;if(r){const y=D(r),h=o&&F(o)?D(o):o;let p=y,v=Re(p);for(;v&&o&&h!==p;){const E=ne(v),w=v.getBoundingClientRect(),b=$(v),L=w.left+(v.clientLeft+parseFloat(b.paddingLeft))*E.x,_=w.top+(v.clientTop+parseFloat(b.paddingTop))*E.y;d*=E.x,g*=E.y,l*=E.x,u*=E.y,d+=L,g+=_,p=D(v),v=Re(p)}}return he({width:l,height:u,x:d,y:g})}function Ne(e,t){const n=ye(e).scrollLeft;return t?t.left+n:Z(G(e)).left+n}function tt(e,t,n){n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=o.left+t.scrollLeft-(n?0:Ne(e,o)),r=o.top+t.scrollTop;return{x:i,y:r}}function Gt(e){let{elements:t,rect:n,offsetParent:o,strategy:i}=e;const r=i==="fixed",s=G(o),c=t?me(t.floating):!1;if(o===s||c&&r)return n;let d={scrollLeft:0,scrollTop:0},g=B(1);const l=B(0),u=V(o);if((u||!u&&!r)&&((ee(o)!=="body"||ie(s))&&(d=ye(o)),V(o))){const h=Z(o);g=ne(o),l.x=h.x+o.clientLeft,l.y=h.y+o.clientTop}const y=s&&!u&&!r?tt(s,d,!0):B(0);return{width:n.width*g.x,height:n.height*g.y,x:n.x*g.x-d.scrollLeft*g.x+l.x+y.x,y:n.y*g.y-d.scrollTop*g.y+l.y+y.y}}function Vt(e){return Array.from(e.getClientRects())}function Wt(e){const t=G(e),n=ye(e),o=e.ownerDocument.body,i=Y(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=Y(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let s=-n.scrollLeft+Ne(e);const c=-n.scrollTop;return $(o).direction==="rtl"&&(s+=Y(t.clientWidth,o.clientWidth)-i),{width:i,height:r,x:s,y:c}}function Ht(e,t){const n=D(e),o=G(e),i=n.visualViewport;let r=o.clientWidth,s=o.clientHeight,c=0,d=0;if(i){r=i.width,s=i.height;const g=Pe();(!g||g&&t==="fixed")&&(c=i.offsetLeft,d=i.offsetTop)}return{width:r,height:s,x:c,y:d}}function jt(e,t){const n=Z(e,!0,t==="fixed"),o=n.top+e.clientTop,i=n.left+e.clientLeft,r=V(e)?ne(e):B(1),s=e.clientWidth*r.x,c=e.clientHeight*r.y,d=i*r.x,g=o*r.y;return{width:s,height:c,x:d,y:g}}function nt(e,t,n){let o;if(t==="viewport")o=Ht(e,n);else if(t==="document")o=Wt(G(e));else if(F(t))o=jt(t,n);else{const i=et(e);o={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return he(o)}function ot(e,t){const n=j(e);return n===t||!F(n)||te(n)?!1:$(n).position==="fixed"||ot(n,t)}function zt(e,t){const n=t.get(e);if(n)return n;let o=re(e,[],!1).filter(c=>F(c)&&ee(c)!=="body"),i=null;const r=$(e).position==="fixed";let s=r?j(e):e;for(;F(s)&&!te(s);){const c=$(s),d=Oe(s);!d&&c.position==="fixed"&&(i=null),(r?!d&&!i:!d&&c.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||ie(s)&&!d&&ot(e,s))?o=o.filter(l=>l!==s):i=c,s=j(s)}return t.set(e,o),o}function Kt(e){let{element:t,boundary:n,rootBoundary:o,strategy:i}=e;const s=[...n==="clippingAncestors"?me(t)?[]:zt(t,this._c):[].concat(n),o],c=s[0],d=s.reduce((g,l)=>{const u=nt(t,l,i);return g.top=Y(u.top,g.top),g.right=ue(u.right,g.right),g.bottom=ue(u.bottom,g.bottom),g.left=Y(u.left,g.left),g},nt(t,c,i));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function qt(e){const{width:t,height:n}=Qe(e);return{width:t,height:n}}function Xt(e,t,n){const o=V(t),i=G(t),r=n==="fixed",s=Z(e,!0,r,t);let c={scrollLeft:0,scrollTop:0};const d=B(0);if(o||!o&&!r)if((ee(t)!=="body"||ie(i))&&(c=ye(t)),o){const y=Z(t,!0,r,t);d.x=y.x+t.clientLeft,d.y=y.y+t.clientTop}else i&&(d.x=Ne(i));const g=i&&!o&&!r?tt(i,c):B(0),l=s.left+c.scrollLeft-d.x-g.x,u=s.top+c.scrollTop-d.y-g.y;return{x:l,y:u,width:s.width,height:s.height}}function Ue(e){return $(e).position==="static"}function it(e,t){if(!V(e)||$(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return G(e)===n&&(n=n.ownerDocument.body),n}function rt(e,t){const n=D(e);if(me(e))return n;if(!V(e)){let i=j(e);for(;i&&!te(i);){if(F(i)&&!Ue(i))return i;i=j(i)}return n}let o=it(e,t);for(;o&&Mt(o)&&Ue(o);)o=it(o,t);return o&&te(o)&&Ue(o)&&!Oe(o)?n:o||Ft(e)||n}const Yt=async function(e){const t=this.getOffsetParent||rt,n=this.getDimensions,o=await n(e.floating);return{reference:Xt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Zt(e){return $(e).direction==="rtl"}const Jt={convertOffsetParentRelativeRectToViewportRelativeRect:Gt,getDocumentElement:G,getClippingRect:Kt,getOffsetParent:rt,getElementRects:Yt,getClientRects:Vt,getDimensions:qt,getScale:ne,isElement:F,isRTL:Zt};function st(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Qt(e,t){let n=null,o;const i=G(e);function r(){var c;clearTimeout(o),(c=n)==null||c.disconnect(),n=null}function s(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),r();const g=e.getBoundingClientRect(),{left:l,top:u,width:y,height:h}=g;if(c||t(),!y||!h)return;const p=ge(u),v=ge(i.clientWidth-(l+y)),E=ge(i.clientHeight-(u+h)),w=ge(l),L={rootMargin:-p+"px "+-v+"px "+-E+"px "+-w+"px",threshold:Y(0,ue(1,d))||1};let _=!0;function k(N){const I=N[0].intersectionRatio;if(I!==d){if(!_)return s();I?s(!1,I):o=setTimeout(()=>{s(!1,1e-7)},1e3)}I===1&&!st(g,e.getBoundingClientRect())&&s(),_=!1}try{n=new IntersectionObserver(k,{...L,root:i.ownerDocument})}catch{n=new IntersectionObserver(k,L)}n.observe(e)}return s(!0),r}function en(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=o,g=De(e),l=i||r?[...g?re(g):[],...re(t)]:[];l.forEach(w=>{i&&w.addEventListener("scroll",n,{passive:!0}),r&&w.addEventListener("resize",n)});const u=g&&c?Qt(g,n):null;let y=-1,h=null;s&&(h=new ResizeObserver(w=>{let[b]=w;b&&b.target===g&&h&&(h.unobserve(t),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var L;(L=h)==null||L.observe(t)})),n()}),g&&!d&&h.observe(g),h.observe(t));let p,v=d?Z(e):null;d&&E();function E(){const w=Z(e);v&&!st(v,w)&&n(),v=w,p=requestAnimationFrame(E)}return n(),()=>{var w;l.forEach(b=>{i&&b.removeEventListener("scroll",n),r&&b.removeEventListener("resize",n)}),u==null||u(),(w=h)==null||w.disconnect(),h=null,d&&cancelAnimationFrame(p)}}const at=Ut,tn=Nt,we=(e,t,n)=>{const o=new Map,i={platform:Jt,...n},r={...i.platform,_c:o};return Dt(e,t,{...i,platform:r})},J={wrapper:{right:0,left:"auto",position:"fixed",zIndex:2147483647,alignItems:"center",justifyContent:"center",backgroundColor:"#f0f0f0",boxShadow:"0 0 10px rgba(0, 0, 0, 0.2)",borderTopLeftRadius:"10px",borderBottomLeftRadius:"10px",transition:"top 0.3s ease-in-out",display:"none"},icon:{width:"40px",height:"40px",cursor:"pointer",pointerEvents:"auto",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},positionerWrapper:{pointerEvents:"auto",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",transition:"all 0.3s ease-in-out"},positionerButton:{border:"none",padding:0,width:"0px",height:"20px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.3s ease-in-out",cursor:"grab"},iconImage:{width:"24px",height:"24px"},iconBadge:{position:"absolute",background:"#48bb74",color:"white",borderRadius:"999999px",width:"22px",height:"22px",zIndex:2147483646,fontSize:"12px",fontWeight:"bold",display:"flex",justifyContent:"center",alignItems:"center",bottom:"-8px",left:"-8px"}},se={icon:(e="none")=>({display:e,height:"fit-content"}),iconAbsolute:{position:"absolute",zIndex:2147483647,top:0,left:0},outerSpan:{borderRadius:"50%",width:"24px",height:"24px",marginLeft:"0.25rem",display:"flex",alignItems:"center",justifyContent:"center"},innerSpan:{display:"inline-block",borderRadius:"50%",width:"14px",height:"14px",borderColor:"#fff",borderStyle:"solid",borderWidth:"3px"},strong:{backgroundColor:"#48bb74"},weak:{backgroundColor:"#ffa500"},noRelationship:{backgroundColor:"#ffa3a3"},noRelationshipInnerSpan:{borderWidth:"5px",width:"9px",height:"9px"}},W={tooltip:{position:"absolute",top:0,left:0,width:"max-content",zIndex:2147483647,padding:"10px",borderRadius:"5px",transform:"translateX(-50%)",display:"none",backgroundColor:"#fff",border:"solid 1px #e5e5e5",boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.2)"},tooltipWrapper:{display:"flex",flexDirection:"column",gap:"0.75rem",padding:"0.5rem"},tooltipLink:{fontSize:"12px"},tooltipParagraph:{fontSize:"12px",margin:0,color:"#748095"},component:{display:"flex",flexDirection:"column",gap:"0.5rem"},loader:{display:"flex",alignItems:"center",gap:"4px"},loaderSpan:{display:"flex",alignItems:"center"}};class nn{constructor(t){this.currentTab=t}execute({link:t,iconToHover:n}){this.shouldUsePortalStrategy()?this.attachUsingPortal({link:t,iconToHover:n}):this.attachInsideElement({link:t,iconToHover:n})}shouldUsePortalStrategy(){return["docs.google.com","mail.google.com","airtable.com","notion.so","notion.site"].some(n=>this.currentTab.includes(n))}attachUsingPortal({link:t,iconToHover:n}){Object.assign(n.style,se.iconAbsolute),document.body.appendChild(n),en(t,n,()=>we(t,n,{placement:"right",middleware:[tn()]}).then(({x:o,y:i,middlewareData:r})=>{Object.assign(n.style,{left:`${o}px`,top:`${i}px`}),r.hide&&Object.assign(n.style,{visibility:r.hide.referenceHidden?"hidden":"visible"})}))}attachInsideElement({link:t,iconToHover:n}){t.appendChild(n)}}const on='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M6 15l6 -6l6 6" /></svg>',rn='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M6 9l6 6l6 -6" /></svg>',sn='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 3a9 9 0 1 0 9 9" /></svg>',an='<svg stroke="currentColor" fill="currentColor" stroke-width="16" viewBox="0 0 512 512" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M377.4 32c-38.9 0-70.6 31.7-70.6 70.7 0 17.1 6.2 33.7 17.5 46.6 10 11.5 23.5 19.4 38.2 22.5v43.1L256 270.3l-106.4-55.4v-43.1c32.2-6.9 55.7-35.6 55.7-69.1 0-39-31.7-70.7-70.6-70.7S64 63.7 64 102.7c0 17.1 6.2 33.7 17.5 46.6 10 11.5 23.5 19.4 38.2 22.5v57.4c0 2.7 1.5 5.1 3.9 6.3l117.5 60.8v43.9c-32.2 6.9-55.7 35.6-55.7 69.1 0 39 31.7 70.7 70.6 70.7s70.6-31.7 70.6-70.7c0-17.1-6.2-33.7-17.5-46.6-10-11.5-23.5-19.4-38.2-22.5v-43.9l117.5-60.8c2.4-1.2 3.9-3.6 3.9-6.3v-57.4c32.2-6.9 55.7-35.6 55.7-69.1 0-39-31.7-70.7-70.6-70.7zM93.8 102.7c0-22.5 18.3-40.8 40.8-40.8s40.8 18.3 40.8 40.8c0 22.5-18.3 40.8-40.8 40.8s-40.8-18.3-40.8-40.8zm203 306.6c0 22.5-18.3 40.8-40.8 40.8s-40.8-18.3-40.8-40.8c0-22.5 18.3-40.8 40.8-40.8s40.8 18.3 40.8 40.8zm80.6-265.7c-22.5 0-40.8-18.3-40.8-40.8 0-22.5 18.3-40.8 40.8-40.8 22.5 0 40.8 18.3 40.8 40.8 0 22.4-18.3 40.8-40.8 40.8z"></path></svg>';function ln(e){return e>=10?"excellent":e>=7?"veryGood":e>=4?"good":e>=1?"okay":e>=.5?"highLikelihood":e>=.1?"lowLikelihood":e>0?"lessCold":"cold"}const cn={excellent:"Excellent",veryGood:"Very Good",good:"Good",okay:"Okay",highLikelihood:"Maybe",lowLikelihood:"Maybe",lessCold:"Not sure",cold:"Not Sure"},dn={excellent:"background: #CCF6C9; color: #2E533E;",veryGood:"background: #CCF6C9; color: #2E533E;",good:"background: #EAFEE9; color: #315540;",okay:"background: #EAFEE9; color: #315540;",highLikelihood:"background: #FEFCBF; color: #B7791F;",lowLikelihood:"background: #FEFCBF; color: #B7791F;",lessCold:"background: #ECECEC; color: #000000CC;",cold:"background: #ECECEC; color: #000000CC;"};function un({avatars:e,score:t,total:n,entity:o="person"}){const i=ln(t),s=[...new Set(e)].slice(0,2).map((g,l)=>{const u=l===0;return`<img src="${g}" style="width: 40px; height: 40px; border-radius: 9999px; z-index: ${u?"3":"2"}; transform: translateX(-${u?"3":"10"}px)" />`}).join(""),c=`<div class='paths-with-strength' style="display: flex; align-items: center; cursor: pointer;">
<div style="${dn[i]} text-transform: uppercase; font-size: 12px; font-weight: 600; white-space: nowrap; padding: 8px 12px; border-radius: 9999px;">${cn[i]}</div>
${s}
<span style="color: #718096; font-size: 14px; font-weight: 600; white-space: nowrap; text-decoration: underline;">${n} ${fn(n,o)} →</span>
</div>`,d=document.createElement("div");return d.innerHTML=c,d}function fn(e,t){return t==="company"?e===1?"person":"people":`path${e>1?"s":""}`}function gn({color:e}){const t=document.createElement("div");return t.innerHTML=`<button style="border: none; height: 40px; background: ${e}; color: white; padding: 0 16px; border-radius: 9999px; font-size: 14px; font-weight: 600; cursor: pointer;"><div style="display: flex; align-items: center; justify-content: center; width: 100%; gap: 4px;">${an}<span style="color: white; font-size: 14px;">View Paths</span></div></button>`,t}function ve({eventName:e,properties:t}){Me({command:"tracking",eventName:e,properties:t})}const Me=e=>new Promise((t,n)=>{chrome.runtime.sendMessage(e,function(o){return chrome.runtime.lastError&&n(new Error(chrome.runtime.lastError.message)),t(o||"no reply")})}),hn=({token:e,partnerKey:t,url:n,userReference:o,eventProperties:i})=>{const r=new URLSearchParams;e&&r.append("token",e),n&&r.append("url",encodeURIComponent(n)),t&&r.append("partnerKey",t),o&&r.append("userReference",o);const s=document.createElement("iframe");s.id="village-iframe",s.src=`${Se}/widget?${r.toString()}`,s.setAttribute("style","display: block; position: fixed; width: 100%; height: 100%; top: 0; left: 0; z-index: 2147483647;"),ve({eventName:"Paths Viewed",properties:{$current_url:window.location.href,...i}}),document.addEventListener("keyup",c=>{c.key==="Escape"&&s.remove()}),window.addEventListener("message",function(c){var d;(((d=c.data)==null?void 0:d.type)==="VILLAGE_REMOVE_IFRAME"||c.data==="remove-iframe")&&s.remove()}),document.body.appendChild(s)},Fe=({wrapper:e,element:t,appendOnWrapper:n})=>{n?e.appendChild(t):e.parentElement.insertBefore(t,e)},pn=()=>{const e=document.createElement("div"),t=document.createElement("p");Object.assign(t.style,W.tooltipParagraph),Object.assign(t.style,W.loader),t.innerHTML=`<span>${sn}</span> Loading paths...`;const n=t.querySelector("span");return n&&Object.assign(n.style,W.loaderSpan),e.appendChild(t),{element:e}},lt=async({url:e,page:t,isPathsEverywhere:n})=>{var o,i,r,s,c,d,g,l;try{const[u,y]=await Promise.allSettled([Me({command:"checkPaths",url:e}),P("user_logged_obj")]).then(I=>I.map(O=>O.status==="fulfilled"?O.value:null)),h=y==null?void 0:y.app,p=(i=(o=h==null?void 0:h.config)==null?void 0:o.branding)==null?void 0:i.color,v=(c=(s=(r=h==null?void 0:h.config)==null?void 0:r.features)==null?void 0:s.pathsEverywhere)==null?void 0:c.logo;if(!(u!=null&&u.relationship)||!((l=(g=(d=u==null?void 0:u.relationship)==null?void 0:d.paths)==null?void 0:g.avatars)!=null&&l.length))return!1;const E=u.relationship,w="people"in E?"company":"person",b=yn({entity:w}),L=un({avatars:E.paths.avatars,score:E.warmth_score,total:E.paths.count,entity:w});n&&Object.assign(L.style,W.component);const _=L.getElementsByTagName("img");for(let I=0;I<_.length;I++)_[I].onerror=function(){const O=this.src;this.src=`https://ui-avatars.com/api/?length=1&font-size=0.5&size=256&bold=true&background=2dbed8&color=ffffff&name=${wn(vn(O))}`,this.onerror=null};const k=document.createElement("div");k.setAttribute("data-village-wrapper","true"),k.setAttribute("style","position: relative; width: 100%; height: 100%;"),n&&Object.assign(k.style,W.tooltipWrapper);const N=I=>{hn({token:u.token,partnerKey:"pk_zT4HzZn7oV8x7dg7YuCjBEG40AM4Dhzu",userReference:u==null?void 0:u.userReference,url:e,eventProperties:{url:e,context:mn(n)}}),I.stopPropagation(),I.preventDefault()};if(n){const I=L.querySelector("div.paths-with-strength");I.onclick=N;const O=document.createElement("img");if(O.src=v,O.style.height="30px",O.style.width="fit-content",O.style.borderRadius="5px",k.appendChild(O),b){const le=document.createElement("p");le.innerHTML=b,Object.assign(le.style,W.tooltipParagraph),L.insertBefore(le,L.firstChild)}}if(k.appendChild(L),n){const I=gn({color:p});I.onclick=N,k.appendChild(I);const O=document.createElement("p");O.textContent="P.S. To hide this icon from showing, click on the icon on the right edge of this page",O.style.fontSize="10px",O.style.color="#999",k.appendChild(O)}else{const I=document.createElement("div");I.setAttribute("style","height: 100%; width: 100%; z-index: 9999; position: absolute; top: 0; left:0; cursor: pointer;"),I.onclick=N,k.appendChild(I)}return{element:k}}catch(u){return console.log("erro"),console.log(u),!1}};function mn(e){return e?"Paths Everywhere":"Paths Anywhere"}function yn({entity:e}){return e==="company"?"<strong>Awesome! 🎉</strong> We've found some people who can connect you</strong>":"<strong>Awesome! 🎉</strong> We've found you a reliable connection</strong>"}const wn=e=>`onerror="this.onerror=null;this.src='${`https://ui-avatars.com/api/?length=1&font-size=0.7&size=256&bold=true&background=2dbed8&color=ffffff&name=${encodeURIComponent(e||"U")}`}';"`,vn=e=>{const t=e.split("https://village.sfo3.cdn.digitaloceanspaces.com/l-");return t&&t.length>1?t[1].slice(0,-4):""};function ct(){const e=document.createElement("div");return e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.zIndex="2147483647",document.body.appendChild(e),e}function dt(){const e=document.createElement("span");e.style.position="absolute",e.style.zIndex="2";const t=e.attachShadow({mode:"open"});return{shadowHost:e,shadowRoot:t}}function En(){new MutationObserver((t,n)=>{for(const o of t)if(o.type==="childList"&&o.addedNodes.length){const i=o.addedNodes[0];i&&typeof i.hasAttribute=="function"&&i.hasAttribute("data-tippy-root")&&(o.addedNodes[0].style.zIndex="2147483646")}}).observe(document.body,{childList:!0})}function bn(e){const t=setInterval(()=>{if(document.body)return e(),clearInterval(t)},50)}function $e({status:e}){const t=e==="ENABLED"?"inline-block":"none";document.querySelectorAll("[data-village-path-icon='strong'], [data-village-path-icon='weak'], [data-village-path-icon='noRelationship']").forEach(n=>{n.style.display=t})}async function kn({relationship:e,url:t}){const n=await P(oe)||"ENABLED";let o=!1;const i=e?e.warmth_score:0;let r="noRelationship";i>=1?r="strong":i>0&&(r="weak");const s=document.createElement("span"),c=n==="ENABLED"?"inline-block":"none";Object.assign(s.style,se.icon(c)),s.setAttribute("data-village-path-icon",r);const d=document.createElement("span");Object.assign(d.style,se.outerSpan),Object.assign(d.style,se[r]),s.appendChild(d);const g=document.createElement("span");Object.assign(g.style,se.innerSpan),d.appendChild(g);const l=document.createElement("div");Object.assign(l.style,W.tooltip);let u=!1;const y=async()=>{if(u=!0,o)we(s,l,{middleware:[at()]}).then(({x:p,y:v})=>{const E=l.offsetWidth,w=p+E/2;Object.assign(l.style,{left:`${w}px`,top:`${v}px`})}),l.style.display="block";else{o=!0;const p=ct(),{shadowHost:v,shadowRoot:E}=dt();if(p.appendChild(v),E.appendChild(l),we(s,l,{middleware:[at()]}).then(({x:w,y:b})=>{const L=l.offsetWidth,_=w+L/2;Object.assign(l.style,{left:`${_}px`,top:`${b}px`})}),l.style.display="block",r==="noRelationship"){const w=document.createElement("div"),b=document.createElement("p");Object.assign(b.style,W.tooltipParagraph),b.textContent="We haven't found any reliable paths based on available data.",w.appendChild(b),l.appendChild(w)}else{ve({eventName:"Paths Previewed",properties:{$current_url:window.location.href,context:"Paths Everywhere",url:t}});const{element:w}=pn();Fe({element:w,wrapper:l,appendOnWrapper:!0});const{element:b}=await lt({url:t,page:{entity:"",path:"",styles:""},isPathsEverywhere:!0});w.remove(),Fe({element:b,wrapper:l,appendOnWrapper:!0})}}},h=()=>{u||(l.style.display="none")};return s.addEventListener("mouseenter",y),l.addEventListener("mouseenter",y),s.addEventListener("mouseleave",()=>{u=!1,setTimeout(h,500)}),l.addEventListener("mouseleave",()=>{u=!1,h()}),{iconToHover:s}}var z,ut=!1,ae=50;const xn={ENABLED:"Shown",DISABLED:"Hidden"};function Ln(e){const t=z==="ENABLED"?"DISABLED":"ENABLED";z=t,t==="ENABLED"?e.style.filter="none":e.style.filter="grayscale(100%)",$e({status:t}),R(oe,t),ve({eventName:`Paths Everywhere ${xn[t]}`,properties:{$current_url:window.location.href}})}const ft="ENABLED";async function Sn(){if(ut)return;ut=!0;const[e,t]=await Promise.allSettled([P(oe),P("user_logged_obj")]).then(k=>k.map(N=>N.status==="fulfilled"?N.value:null)),n=t==null?void 0:t.app;e||R(oe,ft),z=e||ft;const o=ct();o.style.width="100%",o.style.height="100%",o.style.pointerEvents="none";const{shadowHost:i,shadowRoot:r}=dt();o.appendChild(i);const s=document.createElement("div");Object.assign(s.style,W.tooltip);const c=document.createElem