1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DQWhnii7.js","assets/app-DNkPr59T.js","assets/app-CiFEs0iJ.css","assets/useConfirmModal-CgPC1Rc1.js","assets/Modal-BthdXXf7.js","assets/context-BXlvO0jn.js","assets/TrapFocus-DCAGR4me.js","assets/CSSTransition-CauivwVE.js","assets/InlineGrid-CJm4niPX.js","assets/XSmallIcon.svg-BTp9v8hn.js","assets/Banner-B9RXQssz.js","assets/InfoIcon.svg-fy3JYkaJ.js","assets/CheckIcon.svg-CyuHZZo9.js","assets/DescriptionList-ChqGTn-e.js","assets/ProgressBar-COqs5vu1.js","assets/index-DD4TlwUb.js"])))=>i.map(i=>d[i]); 2import{R as ie,j as e,r as o,ax as se,T as O,l as $,s as Lt,k as Tt,e as te,a9 as Dt,v as Se,G as Ce,d as Ft,aa as Z,x as Et,P as ge,A as fe,bf as re,ag as Ot,O as we,az as Ie,aJ as _t,d2 as Nt,f as K,D as Le,I as Te,ah as Ye,i as ae,B as ye,H as Ke,q as le,aL as qe,p as $t,a3 as Ve}from"./app-DNkPr59T.js";import{A as De,a as Rt}from"./audienceContext-Cn4wpBfb.js";import{u as Bt}from"./useCacheFetchApi-D9dBXSsl.js";import{p as Vt}from"./processCustomerName-BCHU-L5m.js";import{a as Ut,c as zt}from"./hasField-DbheP7Uf.js";import{t as Xe,f as Wt,b as Qe}from"./timezoneService-B6V1SB3z.js";import{H as Gt}from"./HtmlParser-DM_xvAWp.js";import{u as Ht,a as Zt,b as Jt,C as Yt,c as Kt,d as qt,l as Xt}from"./Audiences-CInM44K5.js";import{C as Ue}from"./ContactStatus-C0bNIk2x.js";import{S as Qt}from"./SuppressionReason-BquFJ2kj.js";import{v as et,c as en,o as tn,g as nn,i as on}from"./operations-B3sKw4-T.js";import{u as de}from"./useFetchApiBeta-FTT6KVs9.js";import{g as ee}from"./getUrlSearch-CfZ5g5jG.js";import{u as sn,S as an}from"./useBulkDeleteModal-HtiTH--h.js";import{a as cn}from"./isNewShop-DzBAAjK2.js";import{u as rn}from"./useResponseModal-CZC8Ppvs.js";import{p as Fe}from"./prepareLabel-Bd8yAr9n.js";import{M as ne}from"./Modal-BthdXXf7.js";import{S as ln}from"./SkeletonBodyText-CT7oHyLO.js";import{B as oe}from"./Banner-B9RXQssz.js";import{R as ze}from"./RadioButton-CReOExFq.js";import{ag as dn,ah as un,ai as pn}from"./gaEvents-B90xzGKV.js";import{u as gn}from"./useDeleteContactModal-Dtn5IZZ0.js";import{u as tt}from"./useVideoModal-Bis5l3Yt.js";import{C as We}from"./CopyToClipboard-wGjBFDha.js";import{g as mn}from"./chatSupport-CpL4MtbI.js";import{i as nt}from"./isBFS-vyeUQQMA.js";import{P as hn}from"./PaginationLabel-D1IuMe1Z.js";import{u as Ee}from"./useTogglePopover-CP-1BBb9.js";import{u as fn}from"./use-index-resource-state-JgOstvjx.js";import{I as E}from"./IndexTable-DDSZTT-x.js";import{S as Oe}from"./MenuHorizontalIcon.svg-C1_3qnnr.js";import{S as yn}from"./PersonAddIcon.svg-7YTTFlO3.js";import{S as Sn}from"./ListBulletedIcon.svg-BRpE5qsw.js";import{C as _e}from"./Card-BH_2svwz.js";import{S as Cn}from"./XCircleIcon.svg-CrA6QdXp.js";import{S as Ne}from"./SearchIcon.svg-MPCAqEFx.js";import{D as Ge}from"./Divider-B9y_V4oi.js";import{S as xn}from"./DeleteIcon.svg-DV5XyuWb.js";import{P as jn}from"./pricingModalContext-mLVGkMdF.js";import{T as vn}from"./Tag-BZsRZp3h.js";import{D as bn}from"./DisableProFeatureModal-BCfE2vGI.js";import{A as ot}from"./AdvancedChoiceList-TNXnqGuV.js";import{C as st}from"./ChoiceList-CGmH-Ay1.js";import{P as He}from"./PlanBadge-CcjMNrTJ.js";import{S as An}from"./RefreshIcon.svg-ajGd0nzP.js";import{u as wn,a as Mn}from"./useCreateTagModal-Dybk4BGU.js";import{T as me}from"./utils-BflGAEPb.js";import{u as Pn}from"./useConfirmModal-CgPC1Rc1.js";import{L as kn}from"./LegacyTabs-BG4l6Jha.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";import"./timezones-9vCu4OSO.js";import"./replaceAll-CSL_G7l6.js";import"./eventType-BoLwyzBV.js";import"./contactAttribute-DtFEylwW.js";import"./specialOccasionPresets-D7teY9b5.js";import"./automation-B04g1SCn.js";import"./customer-BA4Syk_b.js";import"./store-BCLvt8ie.js";import"./filters-_IzI-GJX.js";import"./ChevronDownIcon.svg-BJZwvfv0.js";import"./ChevronRightIcon.svg-B9GQTWie.js";import"./Checkbox-B5xRphX-.js";import"./Choice-CkiE5Wb7.js";import"./Select-CSxHa9nl.js";import"./OptionList-CA137oz-.js";import"./options-D-ZULEqM.js";import"./use-deep-effect-BFR-QSr0.js";import"./index-BpqlvwSN.js";import"./CheckIcon.svg-CyuHZZo9.js";import"./FormLayout-DtemmXe4.js";import"./SMSIcon-DX574kaA.js";import"./eventTypes-Bt5HDJz4.js";import"./customEventPresets-Cb6irVWX.js";import"./signUpPresets-CTKmVv7z.js";import"./customerSegmentationPresets-D8HVIn52.js";import"./toOptionList-BxnQBtBE.js";import"./countries-6aOuFpoa.js";import"./customerRfeSegments-B1T4lHsy.js";
2import"./CursorIcon.svg-7Gnvw_-o.js";import"./EmailNewsletterIcon.svg-CHpeJOVa.js";import"./SendIcon.svg-CbZB8RGh.js";import"./CashDollarIcon.svg-6IlKQOx1.js";import"./PhoneIcon.svg-ssoKlvqx.js";import"./CheckIcon.svg-B8_9KBus.js";import"./CollectionIcon.svg-BnRFOwAn.js";import"./MobileIcon.svg-CY3JJvN6.js";import"./context-BXlvO0jn.js";import"./TrapFocus-DCAGR4me.js";import"./CSSTransition-CauivwVE.js";import"./InlineGrid-CJm4niPX.js";import"./InfoIcon.svg-fy3JYkaJ.js";import"./set-root-property-_18RJuEB.js";import"./EmptySearchResult-Doq1kRyB.js";import"./BulkActions-D4SNY82-.js";import"./AfterInitialMount-D3s5YcLb.js";import"./Sticky-CjTUDs2V.js";import"./analyticHelpers-C7jddZLX.js";import"./newsletterCampaignStatus-DsCGqykW.js";import"./stringCompare-Cgg2lX8x.js";import"./useInput-BjD556bP.js";var at=function(n){return ie.createElement("svg",Object.assign({viewBox:"0 0 20 20"},n),ie.createElement("path",{d:"M10 3c-3.866 0-7 3.154-7 7.045 0 3.506 2.544 6.414 5.875 6.955v-4.187h-1.875v-2.186h1.875v-1.666c0-1.895 1.103-2.942 2.79-2.942.808 0 1.653.148 1.653.148v1.86h-.931c-.918 0-1.204.584-1.204 1.182v1.418h2.048l-.327 2.186h-1.72v4.177c3.302-.566 5.816-3.46 5.816-6.945 0-3.89-3.134-7.045-7-7.045Z"}))};at.displayName="LogoFacebookIcon";var ct=function(n){return ie.createElement("svg",Object.assign({viewBox:"0 0 20 20"},n),ie.createElement("path",{fillRule:"evenodd",d:"M10.143 5.787c1.052 0 1.987.357 2.734 1.044l2.045-2.005c-1.24-1.132-2.85-1.826-4.78-1.826a7.146 7.146 0 0 0-6.376 3.863 6.802 6.802 0 0 0 0 6.274v.007a7.152 7.152 0 0 0 6.377 3.856c1.928 0 3.545-.624 4.727-1.693 1.35-1.222 2.13-3.016 2.13-5.148 0-.496-.046-.974-.13-1.432h-6.727v2.711h3.844a3.225 3.225 0 0 1-1.435 2.106c-.636.42-1.448.675-2.41.675-1.856 0-3.434-1.228-4-2.883h-.008l.009-.006a4.119 4.119 0 0 1-.227-1.33c0-.465.084-.91.227-1.33.565-1.655 2.143-2.883 4-2.883Z"}))};ct.displayName="LogoGoogleIcon";var it=function(n){return ie.createElement("svg",Object.assign({viewBox:"0 0 20 20"},n),ie.createElement("path",{fillRule:"evenodd",d:"M6.75 4c-.69 0-1.25.56-1.25 1.25v9.5c0 .69.56 1.25 1.25 1.25h6.5c.69 0 1.25-.56 1.25-1.25v-9a.75.75 0 0 1 1.5 0v9a2.75 2.75 0 0 1-2.75 2.75h-6.5a2.75 2.75 0 0 1-2.75-2.75v-9.5a2.75 2.75 0 0 1 2.75-2.75h3a2.75 2.75 0 0 1 2.75 2.75v6.25a2.5 2.5 0 0 1-5 0v-5.5a.75.75 0 0 1 1.5 0v5.5a1 1 0 1 0 2 0v-6.25c0-.69-.56-1.25-1.25-1.25h-3Z"}))};it.displayName="PageAttachmentIcon";function In(){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.95156 5.17422C4.95156 4.5529 5.45524 4.04922 6.07656 4.04922H8.55156V6.97422C8.55156 7.84407 9.25671 8.54922 10.1266 8.54922H13.0516V9.22422C13.0516 9.59701 13.3538 9.89922 13.7266 9.89922C14.0994 9.89922 14.4016 9.59701 14.4016 9.22422V7.87422C14.4016 7.6952 14.3304 7.52351 14.2039 7.39692L9.70386 2.89692C9.57727 2.77033 9.40558 2.69922 9.22656 2.69922H6.07656C4.70966 2.69922 3.60156 3.80731 3.60156 5.17422V12.8242C3.60156 14.1911 4.70966 15.2992 6.07656 15.2992H9.45156C9.82436 15.2992 10.1266 14.997 10.1266 14.6242C10.1266 14.2514 9.82436 13.9492 9.45156 13.9492H6.07656C5.45524 13.9492 4.95156 13.4455 4.95156 12.8242V5.17422ZM12.097 7.19922L9.90156 5.00381V6.97422C9.90156 7.09848 10.0023 7.19922 10.1266 7.19922H12.097Z",fill:"#4A4A4A"}),e.jsx("path",{d:"M13.5016 12.8788V15.5242C13.5016 15.897 13.1994 16.1992 12.8266 16.1992C12.4538 16.1992 12.1516 15.897 12.1516 15.5242V12.8788L11.5039 13.5265C11.2403 13.7901 10.8129 13.7901 10.5493 13.5265C10.2857 13.2629 10.2857 12.8355 10.5493 12.5719L12.3493 10.7719C12.6129 10.5083 13.0403 10.5083 13.3039 10.7719L15.1039 12.5719C15.3675 12.8355 15.3675 13.2629 15.1039 13.5265C14.8403 13.7901 14.4129 13.7901 14.1493 13.5265L13.5016 12.8788Z",fill:"#4A4A4A"})]})}function Ln(){return e.jsx("svg",{fill:"#000000",width:"18",height:"18",viewBox:"0 0 24 24",role:"img",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M17.98 11.341c.165-.021.332-.021.497 0 .089-.205.104-.558.024-.942-.12-.571-.28-.917-.613-.863-.333.054-.346.468
2-.226 1.039.067.321.186.596.319.766zM15.12 11.793c.239.105.385.174.442.114.037-.038.026-.11-.03-.203-.118-.193-.36-.388-.617-.497a1.677 1.677 0 0 0-1.634.196c-.16.117-.31.28-.29.378.008.032.031.056.087.064.132.015.591-.217 1.12-.25.374-.023.684.094.922.199zm-.48.274c-.31.05-.481.152-.591.247-.094.082-.152.173-.152.237l.024.057.051.02c.07 0 .228-.064.228-.064a1.975 1.975 0 0 1 1-.104c.155.018.23.028.263-.026.01-.015.023-.049-.008-.1-.073-.118-.387-.317-.814-.266zM17.015 13.073c.21.104.442.063.518-.09.076-.155-.034-.364-.245-.467-.21-.104-.442-.063-.518.09-.076.155.034.364.245.467zm1.355-1.186c-.171-.003-.314.185-.317.421-.004.235.131.428.302.431.171.003.314-.185.318-.42.003-.235-.132-.428-.303-.432zM6.866 16.13c-.042-.053-.112-.037-.18-.021a.646.646 0 0 1-.16.022.347.347 0 0 1-.292-.148c-.078-.12-.073-.299.012-.504l.04-.092c.138-.308.368-.825.11-1.317-.194-.37-.511-.602-.892-.65a1.145 1.145 0 0 0-.983.355c-.379.418-.438.988-.364 1.19.027.073.069.094.099.098.065.009.16-.038.22-.2l.017-.052c.026-.085.076-.243.157-.37a.688.688 0 0 1 .953-.2c.266.175.368.5.255.811-.059.161-.154.468-.133.72.043.512.357.717.638.74.274.01.466-.145.514-.258.03-.066.005-.107-.01-.125v.001zM22.691 15.194c-.01-.037-.078-.286-.172-.586l-.19-.51c.375-.563.381-1.066.332-1.35-.054-.353-.2-.654-.496-.964-.295-.312-.9-.63-1.75-.868l-.445-.124c-.002-.018-.023-1.053-.043-1.497-.013-.32-.041-.822-.196-1.315-.185-.669-.507-1.253-.91-1.627 1.11-1.152 1.803-2.422 1.801-3.511-.003-2.095-2.571-2.73-5.736-1.416l-.67.285a666.1 666.1 0 0 0-1.23-1.207C9.376-2.65-1.905 9.912 1.701 12.964l.789.668a3.885 3.885 0 0 0-.22 1.793c.085.84.517 1.644 1.218 2.266.665.59 1.54.965 2.389.964 1.403 3.24 4.61 5.228 8.37 5.34 4.034.12 7.42-1.776 8.84-5.182.093-.24.486-1.317.486-2.267 0-.956-.539-1.352-.882-1.352zm-16.503 2.55a1.94 1.94 0 0 1-.374.027c-1.218-.033-2.534-1.131-2.665-2.435-.145-1.44.59-2.548 1.89-2.81a2.22 2.22 0 0 1 .547-.04c.729.04 1.803.6 2.048 2.191.217 1.408-.128 2.843-1.446 3.068zm-1.36-6.08c-.81.157-1.524.617-1.96 1.252-.261-.218-.747-.64-.833-.804-.697-1.325.76-3.902 1.778-5.357C6.33 3.159 10.268.437 12.093.931c.296.084 1.278 1.224 1.278 1.224s-1.823 1.013-3.514 2.426c-2.278 1.757-3.999 4.311-5.03 7.083zm12.787 5.542a.072.072 0 0 0 .042-.071.067.067 0 0 0-.074-.06s-1.908.283-3.711-.379c.196-.639.718-.408 1.508-.344a11.01 11.01 0 0 0 3.64-.394c.816-.235 1.888-.698 2.722-1.356.28.618.38 1.298.38 1.298s.217-.039.399.073c.171.106.297.326.211.895-.175 1.063-.626 1.926-1.384 2.72a5.698 5.698 0 0 1-1.663 1.244 7.018 7.018 0 0 1-1.085.46c-2.858.935-5.784-.093-6.727-2.3a3.582 3.582 0 0 1-.19-.522c-.401-1.455-.06-3.2 1.007-4.299.065-.07.132-.153.132-.256 0-.087-.055-.178-.102-.243-.373-.542-1.666-1.466-1.406-3.254.186-1.285 1.308-2.189 2.353-2.135l.265.015c.453.027.848.085 1.222.101.624.027 1.185-.064 1.85-.619.224-.187.404-.35.708-.401.032-.005.111-.034.27-.026a.892.892 0 0 1 .456.146c.533.355.608 1.215.636 1.845.016.36.059 1.228.074 1.478.034.57.183.65.486.75.17.057.329.099.562.164.705.199 1.123.4 1.387.659.158.161.23.333.253.497.084.608-.47 1.359-1.938 2.041-1.605.746-3.55.935-4.895.785l-.471-.053c-1.076-.145-1.689 1.247-1.044 2.201.416.615 1.55 1.015 2.683 1.015 2.6 0 4.598-1.111 5.341-2.072l.06-.085c.036-.055.006-.085-.04-.054-.607.416-3.304 2.069-6.19 1.571 0 0-.35-.057-.67-.182-.254-.099-.786-.344-.85-.891 2.328.721 3.793.039 3.793.039zm-3.688-.436l.001.001v-.002zM9.473 6.74c.895-1.036 1.996-1.936 2.982-2.441.034-.017.07.02.052.053-.079.142-.23.447-.277.677a.04.04 0 0 0 .061.042c.614-.419 1.681-.868 2.618-.925.04-.003.06.049.027.074-.154.119-.293.258-.411.413a.04.04 0 0 0 .031.064c.657.005 1.584.235 2.188.575.04.023.012.102-.034.092-.914-.21-2.41-.37-3.964.01-1.387.339-2.446.862-3.218 1.425-.04.029-.086-.023-.055-.06z"})})}function Tn(){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:e.jsx("path",{d:"M7.20178 1.6875C6.20965 1.6875 5.41801 2.85934 5.12866 4.64612L3.26428 5.17456L1.91406 14.7371L10.6888 16.3125L16.0886 15.2435L14.3451 3.99353L12.7697 3.76831L11.5886 2.8125L10.9316 2.99927C10.5178 2.16215 9.93479 1.6875 9.28259 1.6875C9.0023 1.6875 8.60551 1.76928 8.22131 2.15002C7.92109
21.85393 7.57992 1.6875 7.20178 1.6875ZM7.25781 2.8125C7.4072 2.8125 7.73206 3.07884 7.96094 3.84192L6.34375 4.30115C6.59799 3.28666 7.03365 2.8125 7.25781 2.8125ZM9.28259 2.8125C9.3903 2.8125 9.59128 2.97305 9.79456 3.32117L9.01892 3.54199C8.9578 3.36401 8.89167 3.19658 8.82007 3.04211L8.88928 3.09375C9.00178 2.925 9.17009 2.8125 9.28259 2.8125ZM10.8163 4.13965L10.1516 15.0864L3.20715 13.7812L4.27612 6.07544L10.8163 4.13965ZM11.9204 4.4978L12.2643 4.78125L13.3322 4.95044L14.7955 14.3998L11.2788 15.0743L11.9204 4.4978ZM8.15759 6.69397C6.47009 6.69397 5.62634 7.76272 5.62634 8.94397C5.62634 10.3502 6.97656 10.3502 6.97656 11.194C6.97656 11.419 6.80759 11.7004 6.47009 11.7004C5.90759 11.7004 5.28906 11.1379 5.28906 11.1379L4.95178 12.2058C4.95178 12.2058 5.56987 12.9375 6.80737 12.9375C7.81987 12.9375 8.5509 12.15 8.5509 10.9688C8.5509 9.50625 6.8634 9.22544 6.8634 8.60669C6.8634 8.49419 6.91987 8.04419 7.65112 8.04419C8.15737 8.04419 8.5509 8.26831 8.5509 8.26831L9.00134 6.86206C9.00134 6.86206 8.66384 6.69397 8.15759 6.69397Z",fill:"#4A4A4A"})})}const Dn="/assets/sync_notice-DsoWXUCH.gif",Me={skip:"skip",overwrite:"overwrite"};function Fn(t){const[n,a]=o.useState(!1),[y,r]=o.useState(!1),[l,d]=o.useState(!1),[p,c]=o.useState(!1),[g,u]=o.useState(Me.overwrite),[S,D]=o.useState(!1),[P,F]=o.useState(!0),[U,_]=o.useState(0),k=async()=>{r(!0);try{const b=await $("/importContacts/getCount");b.success&&(_(b.customerCount),d(b.isMaximum))}catch(b){console.log(b.message)}finally{r(!1)}},I=o.useCallback((b,A)=>u(A),[]),N=async()=>{c(!0);try{const b=await $("/contacts/syncFromShopify",{body:{whenExistCustomer:g},method:"PUT"});b.success&&(a(!1),D(!0),F(!!b.isDone),Lt.dispatch(Tt({...t,unreadNotification:t.unreadNotification+1,isSyncing:!0,isShopifySync:!0,isShowShopifySyncBanner:!0})))}catch(b){console.log(b.message)}finally{c(!1)}},L=()=>{a(!1),_(0)},T=o.useCallback(()=>{a(!0),k()},[]),H=l?e.jsxs(oe,{tone:"warning",children:["Avada only allows maximum ",e.jsx("b",{children:"200k"})," contacts in your Audiences list. Please","clean contacts to sync or reach us ",e.jsx(te,{onClick:()=>Dt(),variant:"plain",children:"here"})," for support."]}):U===0?e.jsx("p",{children:"'The sync can not be processed.'"}):e.jsxs(se,{gap:"200",children:[e.jsx(ze,{label:"Overwrite existing customers",checked:g===Me.overwrite,id:"overwrite",onChange:I}),e.jsx(ze,{label:"Skip duplicate customers",id:"skip",checked:g===Me.skip,onChange:I})]});return{modal:e.jsxs(e.Fragment,{children:[e.jsx(ne,{open:n,onClose:()=>L(),title:"Sync contacts from Shopify",primaryAction:{content:"Sync contacts",onAction:()=>N(),loading:p,disabled:U===0||y||l},secondaryActions:[{content:"Cancel",onAction:()=>L()}],children:e.jsx(ne.Section,{children:y?e.jsx(ln,{}):e.jsxs(se,{gap:"200",children:[e.jsxs("p",{children:["We found ",e.jsx(O,{variant:"bodyMd",as:"span",fontWeight:"semibold",children:Fe(U,"customer")})," on your Shopify store."]}),H]})})}),e.jsx(ne,{open:S,onClose:()=>D(!1),title:e.jsx(oe,{title:"Success",tone:"success"}),secondaryActions:[{content:"Close",onAction:()=>D(!1)}],children:e.jsx(ne.Section,{children:e.jsx(se,{gap:"200",children:P?e.jsx("p",{children:"Sync successfully!"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"Contacts are syncing. You can close this dialog and track the sync process as below:"}),e.jsx("div",{style:{textAlign:"center"},children:e.jsx("img",{style:{width:"75%",border:"solid 1px #dfdfdf"},src:Dn,alt:"Syncing"})}),e.jsx("span",{children:"We will notify you when sync is completed."})]})})})})]}),openModal:T}}function En(){const[t,n]=o.useState(!1),[a,y]=o.useState(""),r=o.useCallback(p=>{y(p),n(!0)},[]),l=o.useCallback(()=>n(!1),[]);return{modal:e.jsx(ne,{sectioned:!0,open:t,onClose:l,title:"Notice",primaryAction:{content:"OK",onAction:l},children:e.jsx(oe,{tone:"warning",children:a})}),openModal:r}}const On=o.lazy(()=>Ye(()=>import("./index-DQWhnii7.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),_n=o.lazy(()=>Ye(()=>import("./index-DD4TlwUb.js"),__vite__mapDeps([15,1,2,3,4,5,6,7,8,9,13,14]))),Pe=20;function Nn(){const t={type:"ALL",conditions:[]},a=new URLSearchParams(window.location.search).get("tagFilter");return a&&t.conditions.push({conditionType:"contact_attribute",attribute:"tags",operation:"",value:a,dataType:"text"}),t}function rt({shop:t,setToast:n}){const[a,y]=o.useState(""),{popoverActive:r,togglePopoverActive:l,handleClosePopover:d}
2=Ee(),[p,c]=o.useState(""),[g,u]=o.useState([]),[S,D]=o.useState(Nn()),[P,F]=o.useState({page:1,totalCount:0}),U=o.useRef(JSON.parse(JSON.stringify(S))),[_,k]=o.useState(0),{modal:I}=tt({videoLink:"https://www.youtube.com/embed/IKp7HJEeUl8"}),{optionsFilterLoading:N}=o.useContext(De),{data:L,setData:T,loading:H,fetched:q,refetch:b}=de({url:"/contacts",method:"PUT",postData:{conditions:S,search:a},initLoad:!1,presentDataFunc:s=>{typeof s.contactCount=="number"&&F(f=>({...f,totalCount:s.contactCount}));const h=s.contacts.map(f=>({...f,id:f.id||f._id}));return u(f=>[...f,...h]),h}}),{selectedResources:A,allResourcesSelected:R,handleSelectionChange:C}=fn(L),{openModal:W,modal:B}=rn(),{openModal:X,modal:J}=En(),{openModal:m,modal:x}=Fn(t),[V,w]=o.useMemo(()=>[t.isShopifySync||t.isShowShopifySyncBanner,t.isImportContact||t.isShowImportContactBanner],[t]),j=s=>{const h=s.charAt(0).toUpperCase()+s.slice(1);return R?{title:`${h} these all ${A.length}+ contacts`,buttonTitle:`${h} all ${A.length}+ contacts`,content:e.jsxs("div",{children:["You are going to ",s," all ",A.length,"+ contacts ",e.jsx("br",{}),"Please be careful because you cannot undo this action."]})}:A.length>1?{title:`${h} ${A.length} contacts`,buttonTitle:`${h} ${A.length} contacts`,content:e.jsxs("div",{children:["You are going to ",s," ",A.length," contacts ",e.jsx("br",{}),"Please be careful because you cannot undo this action."]})}:{title:`${h} this contact`,buttonTitle:`${h} this contact`,content:e.jsxs(e.Fragment,{children:["You are going to ",s," all ",A.length," contact ",e.jsx("br",{}),"Please be careful because you cannot undo this action."]})}},z=o.useCallback(()=>{k(s=>s+1)},[]),i=o.useCallback(s=>{y(s)},[]),M=(s={})=>{F({page:1,totalCount:0}),u([]),b("/contacts",s)},v=async s=>{try{if(!s)return;d(),c(s);const h=await $(`/contacts/${s}`,{method:"DELETE"});if(h.success){n({content:h.message||"Contact deleted"}),u([]);const f=L.filter(Q=>Q.id!==s);T(f),f.length<10&&M()}else n({content:h.message,error:!0})}catch(h){console.log(h),n({content:h.message,error:!0})}finally{c("")}},Y=async()=>{try{d(),c("bulk-delete");let s={type:"select",selectedIds:A};R&&(s={type:"filter",conditions:S,search:a});const h=await $("/contacts",{body:s,method:"DELETE"});h.success?(M(),n({content:h.message||"Contacts deleted"})):n({content:h.message,error:!0})}catch(s){console.log(s),n({content:s.message,error:!0})}finally{c("")}},G=s=>{F(f=>({...f,page:s}));const h=(s-1)*Pe;if(h<g.length){T(g.slice(h,s*Pe));return}b(`/contacts?${ee({skip:h})}`)},ce=(...s)=>{d(""),C(...s)},xe=async s=>{const h="add";try{c("bulk-segment");const f=await $("/contacts/bulkSegment",{body:{search:a,conditions:S,segmentIds:s,selectedIds:A,allSelected:R,action:h},method:"PUT"});f.success?n({content:f.message||"Success"}):n({content:f.message,error:!0})}catch(f){console.log(f),n({content:f.message,error:!0})}finally{c("")}},je=async(s,h)=>{try{c("bulk-tag");const Q=await $("/contacts/bulkTag",{body:{search:a,conditions:S,selectedTags:h,selectedIds:A,allSelected:R,action:s?"replace":"add"},method:"PUT"});if(Q.success){const pe=A.length>1||R?"Tags added":"Tag added";n({content:Q.message||pe})}else n({content:Q.message,error:!0})}catch(f){console.log(f),n({content:f.message,error:!0})}finally{c("")}},{openModal:ve,modal:ue}=Ht({postConfirmAction:async s=>xe(s),loading:p==="bulk-segment",...j("segment")}),{openModal:pt,modal:gt}=Zt({postConfirmAction:async(s,h)=>je(s,h),loading:p==="bulk-tag",...j("tag")}),{openModal:mt,modal:ht}=Jt({search:a,conditions:S,segmentId:"",selectedIds:A,allSelected:R}),{openModal:ft,modal:yt}=gn({postConfirmAction:v,loading:p}),{openModal:St,modal:Ct}=sn({postConfirmAction:Y,loading:p==="bulk-delete",...j("delete")}),xt=async()=>{try{d(),c("create-contact");const s=await $("/notification/check-status?type=sync-contact");if(!s.success){W(!1,s.error);return}if(!s.data){X("The synchronize is in process...");return}m(),we(pn)}catch(s){console.log(s),n({content:s.message,error:!0})}finally{c("")}};o.useEffect(()=>{if(S.conditions.every(h=>et(h))&&!($n(S,U.current)&&q))return U.current=JSON.parse(JSON.stringify(S)),M(),()=>{}},[_]);const jt=L.map((s,h)=>
2{const{id:f,email:Q,phoneNumber:pe,firstName:Mt,lastName:Pt,orderCount:kt=0,totalSpent:It=0,createdAt:Re}=s,Be=Vt(Mt,Pt);return e.jsxs(E.Row,{id:f,selected:A.includes(f),position:h,onClick:()=>re.push(`/audience/contact/edit/${f}`),children:[e.jsx(E.Cell,{children:e.jsxs(se,{children:[e.jsx("div",{children:e.jsx(Ft,{monochrome:!0,removeUnderline:!0,children:e.jsx(O,{variant:"bodyMd",fontWeight:"semibold",as:"h3",children:Be})})}),Q?e.jsxs(Z,{gap:"200",children:[e.jsx(O,{children:Q}),e.jsx(We,{text:Q})]}):pe?e.jsxs(Z,{gap:"200",children:[e.jsx(O,{children:pe}),e.jsx(We,{text:pe})]}):null]})}),e.jsx(E.Cell,{children:e.jsxs(Z,{gap:"200",children:[Ut(Q)&&e.jsx(Ue,{status:s.status,label:"Email"}),zt(s)&&e.jsx(Ue,{status:s.pushStatus,label:"Push"})]})}),e.jsx(E.Cell,{children:e.jsx(Qt,{...s,hasLabel:!1})}),e.jsx(E.Cell,{children:e.jsx(O,{as:"span",alignment:"end",numeric:!0,children:kt})}),e.jsx(E.Cell,{children:e.jsx(O,{as:"span",alignment:"end",numeric:!0,children:It})}),e.jsx(E.Cell,{children:e.jsx(Et,{content:Gt(Wt(Re,t.timezone)),children:e.jsx("div",{style:{width:"fit-content"},children:Xe(Re)})})}),e.jsx(E.Cell,{children:e.jsx(Z,{align:"end",children:e.jsx(ge,{active:r===f,activator:e.jsx(te,{onClick:Ae=>{Ae.stopPropagation(),l(f)},variant:"tertiary",loading:p===f,icon:Oe}),onClose:d,children:e.jsx("div",{onClick:Ae=>Ae.stopPropagation(),children:e.jsx(fe,{actionRole:"menuitem",items:[{content:"Send email",onAction:()=>re.push(`/contact/send/${f}`)},{content:"Delete",onAction:()=>ft({id:f,name:Be}),destructive:!0}]})})})})})]},f)}),$e=cn(t),be=[{icon:yn,content:e.jsx(O,{as:"h5",fontWeight:"medium",children:"Add single contact"}),helpText:"Enter each contact info manually",buttonTitle:"Add",url:"/audience/contact/create"},{icon:In,content:e.jsx(O,{as:"h5",fontWeight:"medium",children:"Import file"}),helpText:"Import or copy and paste contact list",disabled:$e,onAction:()=>{if($e){mn();return}we(un),re.push("/audience/contact/import")}}];Ot(t)&&be.push({icon:Tn,content:e.jsx(O,{as:"h5",fontWeight:"medium",children:"Sync from Shopify"}),helpText:"Sync all contacts from Shopify to Avada",disabled:!!t.isShopifySync,onAction:xt}),be.push({icon:Ln,content:e.jsx(O,{as:"h5",fontWeight:"medium",children:"Sync from Mailchimp"}),helpText:"Sync all contacts from Mailchimp to Avada",onAction:()=>{we(dn),re.push("/integration/mailchimp")}});const vt=!!S.conditions.length,bt=P.page<Math.ceil(P.totalCount/Pe)&&!H,At=P.page>1&&!H,wt={conditions:S,setConditions:D,runFilter:z};return e.jsx(Yt,{value:wt,children:e.jsx(Ie,{title:"Contacts",fullWidth:!0,subtitle:"Manage all of your marketing contacts in one place. Create targeted segments to deliver more personalized experiences.",additionalMetadata:nt,primaryAction:e.jsx(ge,{active:r==="create-contact",activator:e.jsx(te,{variant:"primary",loading:p==="create-contact",onClick:()=>l("create-contact"),disclosure:!0,children:"Create contact"}),autofocusTarget:"first-node",onClose:d,children:e.jsx(fe,{items:be})}),secondaryActions:[{icon:it,content:"Manage files",url:"/audience/imex"},{icon:Sn,content:"Suppression list",url:"/audience/suppression"}],children:e.jsxs(se,{gap:"400",children:[e.jsx(_t,{children:t.shopifyDomain&&e.jsx(Nt,{position:"audiences"})}),V&&e.jsx(o.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(On,{shop:t,page:"contact-list"})}),w&&e.jsx(o.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(_n,{shop:t,page:"contact-list"})}),e.jsxs(K,{children:[e.jsxs(_e,{padding:"0",children:[e.jsx(K,{padding:"200",children:e.jsxs(Z,{gap:"200",blockAlign:"center",children:[e.jsx("div",{className:"Polaris-Filters__SearchField",onKeyDown:s=>{s.key==="Enter"&&M()},children:e.jsx(Le,{prefix:e.jsx(Te,{source:Ne}),suffix:a&&e.jsx(se,{align:"center",children:e.jsx(te,{onClick:()=>{i(""),M({search:""})},icon:Cn,variant:"tertiary"})}),value:a,onChange:i,placeholder:"Search by email or phone"})}),e.jsx("div",{children:e.jsx(ge,{active:r==="add-filter",activator:e.jsx(te,{onClick:()=>l("add-filter"),disclosure:"down",disabled:N,children:"Add filter"}),onClose:d,children:e.jsx("div",{style:{minWidth:"350px"},children:e.jsx(Kt,{shop:t,closePopover:d})})})})]})}),e.jsx(Ge,{}),vt&&e.jsxs(K,{children:[e.jsx(K,{padding:"200",children:e.jsx(qt,{shop:t})}),e.jsx(Ge,{})]}),e.jsx(E,{resourceName:{singular:"contact",plural:"contacts"},itemCount:L.length,loading:H,selectedItemsCount:R?"All":A.length,onSelectionChange:ce,bulkActions:[{icon:an,content:"Export",onAction:mt},{icon:xn,content:"Delete",destructive:!0,onAction:St}],promotedBulkActions:[{content:"Add segment",onAction:ve},{content:"Add tag",onAction:pt}],paginatedSelectAllActionText:"Select all",hasMoreItems:!0,headings:[{title:"Contacts"},{title:"Channel"},{title:"Suppression"},{title:"Order count",alignment:"end"},{title:"Total spent",alignment:"end"},{title:"Date created"},{title:"Actions",alignment:"end"}],pagination:{hasNext:bt,label:e.jsx(hn,{pageInfo:P}),hasPrevious:At,onPrevious:()=>{G(P.page-1)},onNext:()=>{G(P.page+1)}},children:jt})]}),J,I,gt,yt,B,ue,Ct,x,ht]})]})})})}function $n(t,n){return JSON.stringify(JSON.parse(JSON.stringify(t)))===JSON.stringify(JSON.parse(JSON.stringify(n)))}
2rt.propTypes={shop:ae.object,setToast:ae.func};const Rn=t=>({shop:t.shop.activeShop}),Bn={setToast:Ce},Vn=Se(Rn,Bn)(rt);function Un({segmentCondition:t,markedTag:n}){return!t.conditions.length&&!n?e.jsx(ye,{tone:"info",children:"Add contacts or conditions to this segment"}):t!=null&&t.conditions.length?e.jsx(K,{padding:"0",children:e.jsx(Z,{gap:"200",blockAlign:"center",children:t.conditions.map((y,r)=>e.jsxs(ie.Fragment,{children:[r!==0&&e.jsx(Wn,{type:t.type}),e.jsx(zn,{condition:y})]},r))})}):e.jsx(ye,{tone:"info",children:"No conditions"})}function zn({condition:t}){const{optionsFilterData:n}=o.useContext(De),a=Gn(t),y=Hn(t,n),r=et(t)?"":"invalid-condition";return e.jsx("div",{className:`Avada-ContactConditionItem__Tag ${r}`,children:e.jsx(vn,{children:e.jsx(te,{variant:"monochromePlain",children:e.jsxs("p",{className:"tag-text-content",children:[e.jsx("b",{children:a})," "," "+y]})})})})}function Wn({type:t}){const n={ALL:"and",ANY:"or"};return e.jsx(O,{tone:"subdued",children:n[t]})}function Gn(t){for(const n of Xt)if(n.value===t.conditionType){const a=n.options.find(y=>y.value===t.attribute);if(a)return a.label}return""}function Hn(t,n){var r,l;if(en(t))return((r=tn(t).filter(p=>!p.disabled).find(p=>p.value===t.operation))==null?void 0:r.label)+" "+t.value;const a=t.conditionType+t.attribute,y=nn({type:a,productCollections:n.collections,contactTags:n.tags,popupCampaigns:n.campaigns,newslettersOpen:n.newslettersOpened,newslettersClick:n.newslettersClicked,emailSettings:n.settings}).filter(d=>!d.disabled);if(on(a)){const p=t.value.split(",").filter(Boolean).map(u=>{var S;return(S=y.find(D=>D.value===u))==null?void 0:S.label}).filter(Boolean);let c="";if(p.length>3){const u=p.length-3;c=" and "+u+" more value",u>1&&(c+="s")}return(["","IS_ONE_OF"].includes(t.operation)?" is one of ":" not one of ")+p.slice(0,3).join(",")+c}return(l=y.find(d=>d.value===t.value))==null?void 0:l.label}function Zn({postConfirmAction:t,title:n="Are you sure to delete?",contentRender:a=()=>{},buttonTitle:y="Confirm",closeTitle:r="Cancel",disabled:l=!1,loading:d=!1,destructive:p=!1,closeCallback:c=()=>{},callOnClose:g=!0,callPrimaryClose:u=!0,large:S=!1}){const[D,P]=o.useState(!1),[F,U]=o.useState(null),_=(N=null)=>{P(!0),N&&U(N)},k=()=>P(!1);return{modal:e.jsx(ne,{size:S&&"large",sectioned:!0,open:D,onClose:()=>g?Promise.resolve(c()).then(()=>k()):k(),title:n,primaryAction:{disabled:l,loading:d,destructive:p,content:y,onAction:()=>{Promise.resolve(t(F)).then(()=>{u&&k()})}},secondaryActions:[{disabled:l||d,content:r,onAction:()=>Promise.resolve(c()).then(()=>k())}],children:a(F)}),open:D,closeModal:k,openModal:_}}const Ze={audienceIds:[],contactStatus:"notsub",syncStatus:"not_synced",syncCount:0,lastSyncedAt:new Date};function Jn({setToast:t,shop:n}){var X,J;const[a,y]=o.useState({}),[r,l]=o.useState(!1),[d,p]=o.useState(!1),[c,g]=o.useState(Ze),{loading:u,setLoading:S,data:D,setData:P,fetched:F,refetch:U}=de({}),_=o.useCallback(m=>{y(m),g({...Ze,...m.facebook}),p(!0),F||U("/facebook/audiences")},[F]),{syncStatus:k}=c,I=Ke(),N=(m,x)=>{g(V=>({...V,[m]:x}))},L=async()=>{const m=le.pick(c,["audienceIds","contactStatus"]);try{l(!0);const x=await $("/facebook/save",{body:{id:a.id,facebook:m},method:"POST"});if(!x.success){t({content:x.error,error:!0});return}g(V=>({...V,...m})),t({content:"Updated sync details successfully"})}catch(x){console.log(x),t({error:!0,content:x.message})}finally{l(!1)}},T=async()=>{R&&await L(),p(!1)},H=async()=>{switch(k){case"syncing":return await b();case"not_synced":case"synced":default:return await q()}},q=async()=>{const m={syncStatus:"syncing",lastSyncedAt:new Date,...le.pick(c,["audienceIds","contactStatus"])};try{if(l(!0),!(await $("/facebook/save",{body:{id:a.id,facebook:m,isSync:!0},method:"POST"})).success){t({error:!0,content:"Failed to start sync progress"});return}g(V=>({...V,...m})),t({content:"Sync process started successfully"})}catch(x){console.log(x),t({error:!0,content:"Failed to start sync progress"})}finally{l(!1)}},b=async()=>{const m={syncStatus:"synced",lastSyncedAt:new Date};try{if(l(!0),!(await $("/facebook/save",{body:{id:a.id,facebook:m},method:"POST"})).success){t({error:!0,content:"Failed to stop sync progress"});return}g(V=>({...V,...m})),t({content:"Sync process stopped successfully"})}catch(x){console.log(x),t({error:!0,content:"Failed to stop sync progress"})}finally{l(!1)}},A=async m=>{try{S(!0);const x=await $("/facebook/audience",{body:{name:m},method:"POST"});if(x.error){t({content:x.error,error:!0});return}t({content:"Created audience successfully"}),N("audienceIds",[...c.audienceIds||[],x.created.id]),P(x.data)}catch(x){console.log(x),t({content:"Failed to create audience",error:!0})}finally{S(!1)}};o.useEffect(()=>{if(F){const m=D.map(V=>V.value),x=c.audienceIds.filter(V=>m.includes(V));N("audienceIds",x)}},[F,D]);const R=(X=n.facebookAds)==null?void 0:X.accessToken,C=R?!((J=c.audienceIds)!=null&&J.length):!1,W=(()=>
2{if(!R)return"Connect";switch(k){case"syncing":return"Stop syncing";case"not_synced":case"synced":default:return"Save and Sync now"}})(),B=R?e.jsxs(ne,{sectioned:!0,open:d,onClose:T,title:`Sync "${a.name}" to Facebook Audiences`,primaryAction:{disabled:C,loading:r,content:W,onAction:async()=>{H(),T()}},secondaryActions:[{disabled:C||r,content:"Save",onAction:T}],children:[c.syncCount>0&&e.jsxs(e.Fragment,{children:[e.jsxs(oe,{tone:"info",children:["Synced contacts: ",e.jsx(O,{variant:"bodyMd",as:"span",fontWeight:"semibold",children:le.formatNumber(c.syncCount)}),e.jsx("br",{}),"Last synced on: ",e.jsx(O,{variant:"bodyMd",as:"span",fontWeight:"semibold",children:Qe(c.lastSyncedAt)})]}),e.jsx("br",{})]}),c.error&&e.jsxs(e.Fragment,{children:[e.jsx(oe,{tone:"warning",title:"Failed to sync contacts",children:c.error}),e.jsx("br",{})]}),e.jsx(qe,{id:"",label:"Select Audiences",children:e.jsx(ot,{options:D,value:c.audienceIds||[],onChange:m=>N("audienceIds",m),loading:u,fetched:F,allowMultiple:!0,preferredAlignment:"left",singular:"audience",plural:"audiences",handleCreate:A})}),e.jsx("br",{}),e.jsx(st,{title:"Select Contact Status to sync",choices:[{label:"Only sync contacts that emails are subscribed or not subscribed",value:"notsub"},{label:"Only sync contacts that emails are subscribed",value:"subscribe"},{label:"Sync all contacts",value:"all"}],selected:c.contactStatus||"",onChange:m=>N("contactStatus",m[0])})]}):e.jsx(ne,{sectioned:!0,open:d,onClose:T,title:`Sync "${a.name}" to Facebook Audiences`,primaryAction:{disabled:C,loading:r,content:W,onAction:async()=>{I.push("/integration"),T()}},secondaryActions:[{disabled:C||r,content:"Close",onAction:async()=>{T()}}],children:e.jsx(oe,{tone:"warning",children:"You haven't connected your Facebook Audiences account."})});return{openModal:_,modal:B}}const Je={audienceIds:[],contactStatus:"notsub",syncStatus:"not_synced",syncCount:0,lastSyncedAt:new Date};function Yn({setToast:t,shop:n}){var V;const[a,y]=o.useState({}),[r,l]=o.useState(!1),[d,p]=o.useState(!1),[c,g]=o.useState(Je),{data:u,fetched:S,refetch:D,loading:P}=de("/integration/google"),{loading:F,setLoading:U,data:_,setData:k,fetched:I,refetch:N}=de({}),L=o.useMemo(()=>(u==null?void 0:u.isConnected)&&(u==null?void 0:u.adsAccountId),[u]),T=(w,j)=>{g(z=>({...z,[w]:j}))},H=o.useCallback(w=>{y(w),g({...Je,...w.google}),p(!0),S||D("/integration/google")},[S,L,I,N,D]),q=async()=>{const w=le.pick(c,["audienceIds","contactStatus"]);try{l(!0);const j=await $("/google/save",{body:{id:a.id,google:w},method:"POST"});if(!j.success){t({content:j.message,error:!0});return}g(z=>({...z,...w})),t({content:"Updated sync details successfully"})}catch(j){console.log(j),t({error:!0,content:j.message})}finally{l(!1)}},b=()=>{L&&q(),p(!1)},{syncStatus:A}=c,R=Ke(),C=async w=>{switch(A){case"syncing":return await B(w);case"not_synced":case"synced":default:return await W(w)}},W=async w=>{const j={syncStatus:"syncing",lastSyncedAt:new Date,...le.pick(c,["audienceIds","contactStatus"])};try{if(l(!0),!(await $("/google/save",{body:{id:a.id,google:j,isSync:!0},method:"POST"})).success){t({error:!0,content:"Failed to start sync progress"});return}g(i=>({...i,...j})),w(),t({content:"Sync process started successfully"})}catch(z){console.log(z),t({error:!0,content:"Failed to start sync progress"})}finally{l(!1)}},B=async w=>{const j={syncStatus:"synced",lastSyncedAt:new Date};try{if(l(!0),!(await $("/google/save",{body:{id:a.id,google:j},method:"POST"})).success){t({error:!0,content:"Failed to stop sync progress"});return}g(i=>({...i,...j})),w(),t({content:"Sync process stopped successfully"})}catch(z){console.log(z),t({error:!0,content:"Failed to stop sync progress"})}finally{l(!1)}},X=async w=>{try{U(!0);const j=await $("/google/audience",{body:{name:w},method:"POST"});if(j.error){t({content:j.error,error:!0});return}t({content:"Created audience successfully"}),T("audienceIds",[...c.audienceIds||[],j.created.id]),k(j.data)}catch(j){console.log(j),t({content:"Failed to create audience",error:!0})}finally{U(!1)}};o.useEffect(()=>{!I&&L&&N("/google/audiences")},[L,I,N]),o.useEffect(()=>{if(S){const w=_.map(z=>z.value),j=c.audienceIds.filter(z=>w.includes(z));
2T("audienceIds",j)}},[S,_]);const J=(()=>{if(!L)return"Connect";switch(A){case"syncing":return"Stop syncing";case"not_synced":case"synced":default:return"Save and Sync now"}})(),m=L?!((V=c.audienceIds)!=null&&V.length):!1,x=L?e.jsxs(ne,{sectioned:!0,open:d,onClose:b,title:`Sync "${a.name}" to Google Audiences`,primaryAction:{disabled:m,loading:r,content:J,onAction:async()=>{C(),b()}},secondaryActions:[{disabled:m||r,content:"Save",onAction:b}],children:[c.syncCount>0&&e.jsxs(e.Fragment,{children:[e.jsxs(oe,{tone:"info",children:["Synced contacts: ",e.jsx(O,{variant:"bodyMd",as:"span",fontWeight:"semibold",children:le.formatNumber(c.syncCount)}),e.jsx("br",{}),"Last synced on: ",e.jsx(O,{variant:"bodyMd",as:"span",fontWeight:"semibold",children:Qe(c.lastSyncedAt)})]}),e.jsx("br",{})]}),c.error&&e.jsxs(e.Fragment,{children:[e.jsx(oe,{tone:"warning",title:"Failed to sync contacts",children:c.error}),e.jsx("br",{})]}),e.jsx(qe,{id:"",label:"Select Audiences",children:e.jsx(ot,{options:_,value:c.audienceIds||[],onChange:w=>T("audienceIds",w),loading:F,fetched:I,allowMultiple:!0,preferredAlignment:"left",singular:"audience",plural:"audiences",handleCreate:X})}),e.jsx("br",{}),e.jsx(st,{title:"Select Contact Status to sync",choices:[{label:"Only sync contacts that emails are subscribed or not subscribed",value:"notsub"},{label:"Only sync contacts that emails are subscribed",value:"subscribe"},{label:"Sync all contacts",value:"all"}],selected:c.contactStatus||"",onChange:w=>T("contactStatus",w[0])})]}):e.jsx(ne,{sectioned:!0,open:d,onClose:b,title:`Sync "${a.name}" to Google Audiences`,primaryAction:{disabled:m,loading:r,content:J,onAction:async()=>{R.push("/integration"),b()}},secondaryActions:[{disabled:m||r,content:"Close",onAction:async()=>{b()}}],children:P?e.jsx(Z,{align:"center",children:e.jsx($t,{})}):e.jsx(oe,{tone:"warning",children:"You haven't connected your Google Audiences account."})});return{openModal:H,modal:x}}const ke=20;function lt({shop:t,setToast:n}){const{popoverActive:a,togglePopoverActive:y,handleClosePopover:r}=Ee(),[l,d]=o.useState(""),[p,c]=o.useState(""),[g,u]=o.useState({page:1,totalPage:1}),[S,D]=o.useState(!1),{modal:P}=tt({videoLink:"https://www.youtube.com/embed/IKp7HJEeUl8"}),F=o.useContext(jn),[U,_]=o.useMemo(()=>[!Ve(t,2),!Ve(t,2)&&t.activeSegment>=5],[t]),k={source:"bigquery"},{data:I,setData:N,loading:L,refetch:T}=de({url:`/segmentsList?${ee(k)}`,method:"POST",postData:{search:p},presentDataFunc:i=>(typeof i.totalCount=="number"&&u(v=>({...v,totalPage:Math.ceil(i.totalCount/ke)})),i.segments.map(v=>({...v,id:v.id||v.value||v._id})))}),H=o.useCallback(i=>{c(i)},[]),q=()=>{u({page:1,totalPage:1}),T(`/segmentsList?${ee(k)}`)},b=()=>{const i=(g.page-1)*ke;T(`/segmentsList?${ee({fetchContact:!0,skip:i,...k})}`)},A=i=>{u(v=>({...v,page:i}));const M=(i-1)*ke;T(`/segmentsList?${ee({skip:M,...k})}`)},R=o.useCallback(async()=>{try{if(d("create-segment"),_){D(!0);return}const i=await $("/segments",{body:{name:"New segment",description:"",status:!0,contactCount:0,condition:{type:"ALL",conditions:[]}},method:"POST"});i.success?re.push(`/audience/segment/${i.data.id}`):n({content:i.message})}catch(i){console.log(i),n({error:!0,content:i.message})}finally{d("")}},[t]),C=o.useCallback(async i=>{try{if(!i||!I.find(Y=>Y.id===i))return;r(),d(i);const v=await $(`/segments/${i}`,{method:"DELETE"});if(v.success){const Y=I.filter(G=>G.id!==i);N(Y),n({content:v.message||"Segment deleted"}),Y.length<10&&T(`/segmentsList?${ee(k)}`)}else n({content:v.message,error:!0})}catch(M){console.log(M),n({content:M.message,error:!0})}finally{d("")}},[I]),W=async i=>{try{d(i);const M=I.find(G=>G.id===i);if(!M)return;if(_&&!M.status)return F({plan:"pro"});r();const v={status:!M.status},Y=await $(`/segments/${i}`,{method:"PUT",body:v});if(Y.success){const G=I.map(ce=>ce.id===i?{...ce,status:!M.status}:ce);N(G),n({content:"Segment updated"})}else n({content:Y.message,error:!0})}catch(M){console.log(M),n({content:M.message,error:!0})}finally{d("")}},{modal:B,openModal:X}=Zn({title:"Are you sure to delete this segment?",buttonTitle:"Confirm",loading:l,destructive:!0,postConfirmAction:i=>C(i),contentRender:i=>{const M=I.find(v=>v.id===i)||{};return e.jsx(K,{children:e.jsx(se,{gap:"200",children:e.jsxs(O,{as:"div",children:["Once you confirm the deletion. You cannot undo the task. ",e.jsx("strong",{children:M.name})]})})})}}),{modal:J,openModal:m}=Jn({shop:t,setToast:n}),{modal:x,openModal:V}=Yn({shop:t,setToast:n}),w=I.map((i,M)=>{const{id:v,name:Y,status:G,condition:ce,contactCount:xe=0,markedTag:je,createdAt:ve}=i;return e.jsxs(E.Row,{id:v,position:M,children:[e.jsx(E.Cell,{children:e.jsxs(se,{children:[e.jsx("div",{children:e.jsx(te,{url:`/audience/segment/${v}`,variant:"plain",textAlign:"start",children:e.jsx(O,{variant:"bodyMd",fontWeight:"semibold",as:"h3",children:Y})})}),e.jsxs(O,{variant:"bodyMd",tone:"subdued",as:"p",children:["Created ",Xe(ve)]})]})}),e.jsx(E.Cell,{children:e.jsx(Un,{shop:t,segmentCondition:ce,markedTag:je})}),e.jsx(E.Cell,{children:e.jsx(ye,{tone:G?"success":"warning",children:G?"Active":"Inactive"})}),e.jsx(E.Cell,{children:U&&G===!1?e.jsx(He,{plan:"pro"}):G&&e.jsx("div",{children:Fe(xe,"contact")})}),e.jsx(E.Cell,{children:e.jsx(Z,{align:"end",children:e.jsx(ge,{active:!!v&&a===v,activator:e.jsx(te,{onClick:ue=>{ue.stopPropagation(),y(v)},variant:"tertiary",loading:l===v,icon:Oe}),onClose:r,children:e.jsx("div",{onClick:ue=>ue.stopPropagation(),children:e.jsx(fe,{actionRole:"menuitem",items:[{icon:at,content:"Sync to Facebook",onAction:()=>{m(i)}},{icon:ct,content:"Sync to Google",onAction:()=>{V(i)}},{content:G?"Inactive segment":e.jsxs(Z,{gap:"100",wrap:!1,children:[e.jsx(O,{children:"Active segment"}),_&&e.jsx(He,{plan:"pro"})]}),onAction:()=>W(v)},{content:"Delete",onAction:()=>{X(v)},destructive:!0}]})})})})})]},v)}),j=g.page<g.totalPage&&!L,z=g.page>1&&!L;return e.jsxs(Ie,{title:"Segments",fullWidth:!0,subtitle:"Manage all of your marketing contacts in one place. Create targeted segments to deliver more personalized experiences.",primaryAction:{content:"Create segment",onAction:R,loading:l==="create-segment"},additionalMetadata:nt,children:[e.jsx(K,{children:e.jsxs(_e,{padding:"0",children:[e.jsx(K,{padding:"200",children:e.jsxs(Z,{gap:"200",blockAlign:"center",children:[e.jsx("div",{className:"Polaris-Filters__SearchField",onKeyDown:i=>{i.key==="Enter"&&q()},children:e.jsx(Le,{prefix:e.jsx(Te,{source:Ne}),value:p,onChange:H,placeholder:"Search segment",size:"slim"})}),e.jsx(te,{icon:An,onClick:()=>b()})]})}),e.jsx(E,{resourceName:{singular:"segment",plural:"segments"},itemCount:I.length,loading:L,selectable:!1,headings:[{title:"Segment name"},{title:"Condition"},{title:"Status"},{title:"Contacts"},{title:"Actions",alignment:"end"}],pagination:{hasNext:j,label:`Page ${g.page}`,hasPrevious:z,onPrevious:()=>A(g.page-1),onNext:()=>A(g.page+1)},children:w})]})}),P,B,J,x,e.jsx(bn,{open:S,onClose:()=>D(!1),title:"Upgrade your plan to use this feature",content:"Upgrade SegmentView"})]})}lt.propTypes={shop:ae.object,setToast:ae.func};const Kn=t=>({shop:t.shop.activeShop}),qn={setToast:Ce},Xn=Se(Kn,qn)(lt);function dt({shop:t,setToast:n}){const[a,y]=o.useState(""),[r,l]=o.useState(!1),{popoverActive:d,togglePopoverActive:p,handleClosePopover:c}=Ee(),{handleTabChange:g}=o.useContext(De),{data:u,setData:S,loading:D,pageInfo:P,refetch:F}=de({url:`/fue/tagList?${ee({sortType:"createdAt_desc",typeFilter:me})}`,presentDataFunc:C=>C.items}),U=o.useCallback(C=>{y(C)},[]),_=o.useCallback(()=>{F(`/fue/tagList?${ee({sortType:"createdAt_desc",typeFilter:me,nameFilter:a})}`)},[a]),k=o.useCallback(C=>{C==="next"&&P.hasNext&&F(`/fue/tagList?${ee({sortType:"createdAt_desc",typeFilter:me,after:u[u.length-1].id})}`),C==="pre"&&P.hasPre&&F(`/fue/tagList?${ee({sortType:"createdAt_desc",typeFilter:me,before:u[0].id})}`)},[P,u]),I=o.useCallback(C=>{const W=u.map(B=>B.id===C.id?C:B);S(W)},[u]),N=async({id:C,type:W})=>{try{l(!0),await $(`/fue/tags?id=${C}&type=${W}`,{body:{},method:"DELETE"}),_(),n({content:"Tag deleted!"})}catch(B){n({content:B.message,error:!0})}finally{l(!1)}},{openModal:L,modal:T}=Pn({postConfirmAction:async({id:C,type:W})=>await N({id:C,type:W}),title:"Are you sure you want to delete this tag?",content:"Once you confirm the deletion, you cannot undo it.",callPrimaryClose
2:!0,loading:r}),{modal:H,openModal:q}=wn({callback:_,disabledType:!0,setToast:n}),{modal:b,openModal:A}=Mn({callback:I,setToast:n}),R=u.map((C,W)=>{const{id:B,name:X,tagCount:J}=C;return e.jsxs(E.Row,{id:B,position:W,children:[e.jsx(E.Cell,{children:e.jsx(O,{variant:"bodyMd",fontWeight:"medium",as:"h3",children:X})}),e.jsx(E.Cell,{children:e.jsx(ye,{tone:"info",children:"Contact Tag"})}),e.jsx(E.Cell,{children:e.jsx(O,{children:Fe(J,"contact")})}),e.jsx(E.Cell,{children:e.jsx(Z,{align:"end",children:e.jsx(ge,{active:d===B,activator:e.jsx(te,{onClick:m=>{m.stopPropagation(),p(B)},variant:"tertiary",icon:Oe}),onClose:c,children:e.jsx("div",{onClick:m=>m.stopPropagation(),children:e.jsx(fe,{actionRole:"menuitem",items:[{content:"View",onAction:()=>g(0,{tagFilter:B})},{content:"Edit",onAction:()=>A(C)},{content:"Delete",onAction:()=>L(C),destructive:!0}]})})})})})]},B)});return e.jsxs(Ie,{title:"Tags",fullWidth:!0,primaryAction:{content:"Create tag",onAction:q},children:[e.jsx(K,{children:e.jsxs(_e,{padding:"0",children:[e.jsx(K,{padding:"200",children:e.jsx(Z,{gap:"200",blockAlign:"center",children:e.jsx("div",{className:"Polaris-Filters__SearchField",onKeyDown:C=>{C.key==="Enter"&&_()},children:e.jsx(Le,{prefix:e.jsx(Te,{source:Ne}),value:a,onChange:U,placeholder:"Search tags",size:"slim"})})})}),e.jsx(E,{resourceName:{singular:"tag",plural:"tags"},itemCount:u.length,loading:D,selectable:!1,headings:[{title:"Tag name"},{title:""},{title:"Contacts"},{title:"Actions",alignment:"end"}],pagination:{hasNext:P.hasNext,hasPrevious:P.hasPre,onNext:()=>k("next"),onPrevious:()=>k("pre")},children:R})]})}),b,T,H]})}dt.propTypes={shop:ae.object,setToast:ae.func};const Qn=t=>({shop:t.shop.activeShop}),eo={setToast:Ce},to=Se(Qn,eo)(dt),he=[{id:"contacts",content:"Contacts",pageContent:e.jsx(Vn,{}),accessibilityLabel:"All customers",panelID:"audiences-contacts-page"},{id:"segments",content:"Segments",pageContent:e.jsx(Xn,{}),panelID:"audiences-segments-page"},{id:"tags",content:"Tags",pageContent:e.jsx(to,{}),panelID:"audiences-tags-page"}];function no(){const n=new URLSearchParams(window.location.search).get("page"),a=he.findIndex(y=>y.id===n);return Math.max(a,0)}function oo(t,n={}){const a=new URLSearchParams(window.location.search),{tagFilter:y}=n;a.set("page",t),y?a.set("tagFilter",y):a.delete("tagFilter");const r=`${window.location.pathname}?${a.toString()}`.replace("/embed","");re.push(r)}function ut({shop:t,setToast:n}){const[a,y]=o.useState(no()),{data:r,loading:l,refetch:d}=Bt({url:"/options/dynamicOptionsFilter",defaultData:{}}),p=o.useCallback((g,u={})=>{const S=he[g];oo(S.id,u),y(g)},[]),c={handleTabChange:p,optionsFilterData:r,optionsFilterLoading:l,refetchOptionsFilter:d};return e.jsxs(K,{children:[e.jsx(kn,{tabs:he,selected:a,onSelect:p}),e.jsx(Rt,{value:c,children:he[a].pageContent})]})}ut.propTypes={shop:ae.object,setToast:ae.func};const so=t=>({shop:t.shop.activeShop}),ao={setToast:Ce},ea=Se(so,ao)(ut);export{ea as default};
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.