"use strict";exports.id=99419,exports.ids=[99419],exports.modules={567472:(a,b,c)=>{c.d(b,{Ez:()=>l,Qw:()=>h,Ut:()=>m,cH:()=>n,fW:()=>k,gt:()=>j,x6:()=>i,y3:()=>g});var d=c(693349),e=c(612839);let f=null;async function g(a=!1){if(f&&!a)return f;let b=await (0,e.W3)(e.zq.people),c=await (0,e.W3)(e.zq.company),d=await (0,e.W3)(e.zq.email_thread),h=await (0,e.W3)(e.zq.email_message);return f={people:b,company:c,email_thread:d,email_message:h,calendar_event:await (0,e.W3)(e.zq.calendar_event),interaction:await (0,e.W3)(e.zq.interaction)}}function h(a){return`'${a.replace(/'/g,"''")}'`}function i(a,b){let c=b.replace(/'/g,"''").replace(/"/g,'""');return`${a} LIKE '%"${c}"%'`}function j(a){let b=a.objectId.replace(/'/g,"''"),c=a.aliasedFields.map(({name:b,alias:c})=>{let d=a.fieldMap[b];if(!d)return`NULL AS "${c}"`;let e=d.replace(/'/g,"''");return`MAX(CASE WHEN ef.field_id = '${e}' THEN ef.value END) AS "${c}"`}).join(",\n      "),d=a.whereSql?`AND ${a.whereSql}`:"",e=a.orderBySql?`ORDER BY ${a.orderBySql}`:"",f=void 0!==a.limit?`LIMIT ${Math.max(0,Math.floor(a.limit))}`:"";return`
    SELECT
      e.id AS entry_id,
      e.created_at,
      e.updated_at,
      ${c}
    FROM entries e
    LEFT JOIN entry_fields ef ON ef.entry_id = e.id
    WHERE e.object_id = '${b}'
      ${d}
    GROUP BY e.id, e.created_at, e.updated_at
    ${e}
    ${f}
  `}function k(a,b,c){let d=void 0!==c?`LIMIT ${Math.max(0,Math.floor(c))}`:"";return`
    SELECT * FROM (${a}) sub
    ${b?`ORDER BY ${b}`:""}
    ${d}
  `}async function l(a,b=[]){try{return await (0,d.AI)(a)}catch{return b}}function m(a){let b=a.emailMessageFieldMap,c=b.Thread,d=b["Sent At"];if(!c||!d)return null;let f=b["Sender Type"],g=b["Body Preview"],h=b.From,i=[c,d];f&&i.push(f),g&&i.push(g),h&&i.push(h);let j=i.map(a=>`'${a.replace(/'/g,"''")}'`).join(", "),k=a.candidateThreadIdsCte?`WHERE m.thread_value IN (SELECT entry_id FROM ${a.candidateThreadIdsCte})`:"WHERE m.thread_value IS NOT NULL";return{cte:`
    latest_msg AS (
      SELECT
        thread_value AS thread_id,
        ${f?"ARG_MAX(sender_type_value, sent_at_value)":"NULL"} AS sender_type,
        ${g?"ARG_MAX(preview_value, sent_at_value)":"NULL"} AS snippet,
        ${h?"ARG_MAX(from_value, sent_at_value)":"NULL"} AS from_person_id
      FROM (
        SELECT
          e.id AS msg_id,
          MAX(CASE WHEN ef.field_id = '${c}' THEN ef.value END) AS thread_value,
          MAX(CASE WHEN ef.field_id = '${d}' THEN ef.value END) AS sent_at_value,
          ${f?`MAX(CASE WHEN ef.field_id = '${f}' THEN ef.value END)`:"NULL"} AS sender_type_value,
          ${g?`MAX(CASE WHEN ef.field_id = '${g}' THEN ef.value END)`:"NULL"} AS preview_value,
          ${h?`MAX(CASE WHEN ef.field_id = '${h}' THEN ef.value END)`:"NULL"} AS from_value
        FROM entries e
        JOIN entry_fields ef
          ON ef.entry_id = e.id
         AND ef.field_id IN (${j})
        WHERE e.object_id = '${e.zq.email_message}'
        GROUP BY e.id
      ) m
      ${k}
      GROUP BY thread_value
    )
  `,joinClause:"LEFT JOIN latest_msg ON latest_msg.thread_id = base.entry_id"}}async function n(a,b){let c=new Map;if(0===a.length)return c;let d=b["Full Name"],f=b["Email Address"],g=b["Avatar URL"];if(!d&&!f)return c;let h=a.map(a=>`'${a.replace(/'/g,"''")}'`).join(", "),i=`
    SELECT
      e.id AS person_id,
      ${d?`MAX(CASE WHEN ef.field_id = '${d}' THEN ef.value END)`:"NULL"} AS name,
      ${f?`MAX(CASE WHEN ef.field_id = '${f}' THEN ef.value END)`:"NULL"} AS email,
      ${g?`MAX(CASE WHEN ef.field_id = '${g}' THEN ef.value END)`:"NULL"} AS avatar_url
    FROM entries e
    LEFT JOIN entry_fields ef ON ef.entry_id = e.id
    WHERE e.object_id = '${e.zq.people}'
      AND e.id IN (${h})
    GROUP BY e.id;
  `;for(let a of(await l(i)))c.set(a.person_id,{id:a.person_id,name:a.name,email:a.email,avatar_url:a.avatar_url});return c}},748866:(a,b,c)=>{c.d(b,{S:()=>k,EQ:()=>l,dP:()=>n,OE:()=>h,C0:()=>i,X:()=>m});var d=c(101378);let e=new Set(["gmail.com","googlemail.com","hotmail.com","hotmail.co.uk","hotmail.fr","hotmail.de","hotmail.it","hotmail.es","outlook.com","outlook.co.uk","outlook.de","outlook.fr","outlook.it","outlook.es","outlook.jp","outlook.in","outlook.ie","outlook.com.au","live.com","live.co.uk","live.de","live.fr","live.it","live.com.au","msn.com","passport.com","yahoo.com","yahoo.co.uk","yahoo.co.in","yahoo.co.jp","yahoo.co.id","yahoo.com.au","yahoo.com.br","yahoo.com.mx","yahoo.com.sg","yahoo.de","yahoo.fr","yahoo.es","yahoo.it","yahoo.ca","ymail.com","rocketmail.com","icloud.com","me.com","mac.com","aol.com","aol.co.uk","aol.de","aol.fr","verizon.net","protonmail.com","proton.me","pm.me","tutanota.com","tuta.io","fastmail.com","fastmail.fm","hushmail.com","mailfence.com","disroot.org","riseup.net","posteo.de","posteo.net","ctemplar.com","kolabnow.com","runbox.com","gmx.com","gmx.de","gmx.net","gmx.us","web.de","t-online.de","freenet.de","yandex.com","yandex.ru","ya.ru","mail.ru","list.ru","bk.ru","inbox.ru","rambler.ru","qq.com","163.com","126.com","yeah.net","sina.com","sina.cn","sohu.com","aliyun.com","foxmail.com","naver.com","daum.net","hanmail.net","nate.com","rediffmail.com","sify.com","indiatimes.com","uol.com.br","bol.com.br","terra.com.br","ig.com.br","globo.com","libero.it","alice.it","tin.it","tiscali.it","virgilio.it","wanadoo.fr","orange.fr","free.fr","laposte.net","sfr.fr","neuf.fr","club-internet.fr","telia.com","bredband.net","comhem.se","swipnet.se","online.no","broadpark.no","telenor.no","ziggo.nl","kpnmail.nl","hetnet.nl","planet.nl","home.nl","telenet.be","skynet.be","scarlet.be","mail.com","email.com","inbox.com","usa.com","europe.com","asia.com","post.com","consultant.com","engineer.com","techie.com","writeme.com","iname.com","lawyer.com","doctor.com","myself.com","europemail.com","earthlink.net","att.net","comcast.net","sbcglobal.net","bellsouth.net","cox.net","charter.net","frontier.com","frontiernet.net","embarqmail.com","centurylink.net","windstream.net","juno.com","netzero.net","netscape.net","rogers.com","shaw.ca","telus.net","sympatico.ca","videotron.ca","bigpond.com","bigpond.net.au","optusnet.com.au","iinet.net.au","tpg.com.au","internode.on.net","mailinator.com","guerrillamail.com","guerrillamail.net","guerrillamail.org","10minutemail.com","tempmail.com","temp-mail.org","throwawaymail.com","trashmail.com","yopmail.com","sharklasers.com","spam4.me","maildrop.cc","dispostable.com","getnada.com","burnermail.io","mintemail.com","fakeinbox.com"].map(a=>a.toLowerCase())),f=/<([^>]+)>/,g=/^"([^"]+)"\s*/;function h(a){if("string"!=typeof a)return null;let b=a.trim();if(!b)return null;let c=null,d=null,e=b.match(f);if(e){c=e[1]?.trim().toLowerCase()??null;let a=b.slice(0,e.index).trim();if(a){let b=a.match(g);d=b?b[1].trim():a.replace(/^['"]|['"]$/g,"").trim()}}else c=b.toLowerCase();return c&&j.test(c)?{address:c,name:d&&d.length>0?d:null,raw:b}:null}function i(a){if("string"!=typeof a)return[];let b=a.trim();if(!b)return[];let c=function(a){let b=[],c="",d=!1,e=!1;for(let f of a){if('"'===f&&!e){d=!d,c+=f;continue}if("<"===f&&!d){e=!0,c+=f;continue}if(">"===f&&!d){e=!1,c+=f;continue}if(","===f&&!d&&!e){let a=c.trim();a&&b.push(a),c="";continue}c+=f}let f=c.trim();return f&&b.push(f),b}(b),d=[],e=new Set;for(let a of c){let b=h(a);b&&(e.has(b.address)||(e.add(b.address),d.push(b)))}return d}let j=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function k(a){let b=a.lastIndexOf("@");return b<=0||b===a.length-1?null:a.slice(b+1).trim().toLowerCase()}function l(a,b){let c=k(a);if(!c)return null;let f=function(a){let b=new Set(e);if(a?.remove)for(let c of a.remove){let a=c.trim().toLowerCase();a&&b.delete(a)}if(a?.add)for(let c of a.add){let a=c.trim().toLowerCase();a&&b.add(a)}return b}(b);if(f.has(c))return null;let g=d.Ay.parse(c);if(!g||"error"in g&&g.error)return null;let h=g.domain;return!h||f.has(h)?null:h}function m(a,b){let c=h(a);return c?l(c.address,b):null}function n(a){let b=h(a);if(!b)return null;let c=b.address.lastIndexOf("@");if(c<=0)return b.address;let d=b.address.slice(0,c),e=b.address.slice(c+1),f=d.indexOf("+"),g=f>=0?d.slice(0,f):d;return g?`${g}@${e}`:b.address}}};