PageSourceSearch

https://settlecent.web.app/assets/feature-contacts-Cf91zrS8.js

js settlecent.web.app collected 2026-10-03 12:35:38 UTC 134,107 bytes, 1 lines download raw bytes

1import{s as e,ac as t,M as n,ad as o,N as a,I as i,ae as r,z as d,af as l,c as s,Q as c,u as p,B as u,V as w,ag as g,ah as m,ai as f,aj as y,ak as v,al as h,O as x,am as b,an as C,ao as k,ap as S}from"./core-base-C6U1gwfh.js";import{_ as B}from"./vendor-core-PeJPZ6eL.js";let P=null,M=null;function $(){var e;P=null,null==(e=document.getElementById("contactCardFlipOverlay"))||e.remove()}function I(){var t;const n=(null==(t=e.user)?void 0:t.uid)||"guest";M!==n&&(M=n,$())}function E(t,n){return(e.contacts||[]).some(e=>{if((e.first||"").toLowerCase()!==(t||"").toLowerCase())return!1;return(e.last||"").trim().toLowerCase()===(n||"").trim().toLowerCase()})}function A(a){const i=t(a);if(!i)return{ok:!1,reason:"invalid",message:"Could not read a valid SettleCent contact code. Make sure you scanned the full QR or pasted the entire CC1 code."};if("function"==typeof window.canAddContact&&!window.canAddContact())return"function"==typeof window.showPremiumModal&&window.showPremiumModal("contacts"),{ok:!1,reason:"limit",message:"You have reached the contact limit for your plan. Upgrade to add more contacts."};const r="function"==typeof n&&n(),d=o(i,{allowAvatar:r}),l=(d.last||"").trim(),s=function(e,t){let n=e,o=t||"",a=2;for(;E(n,o)&&(o=t?`${t} (${a})`:`(${a})`,a+=1,!(a>50)););return{first:n,last:o}}(d.first,d.last),c=s.first!==d.first||(s.last||"").trim()!==l,p=(e.contacts||[]).map(e=>e.color),u=d.color||("function"==typeof window.generateUniqueColor?window.generateUniqueColor(p):"#7678ed"),w={id:"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"c_"+Date.now().toString(36)+Math.random().toString(36).slice(2,9),first:s.first,last:s.last,email:d.email,phone:d.phone,venmo:d.venmo,cashapp:d.cashapp,paypal:d.paypal,preferredPayment:d.preferredPayment,color:u,avatarImage:d.avatarImage,overlayImage:d.overlayImage,animationPref:d.animationPref,createdAt:Date.now()};e.contacts||(e.contacts=[]),e.contacts.push(w),"function"==typeof window.invalidateContactsMapCache&&window.invalidateContactsMapCache(),"function"==typeof window.invalidateContactsPopupCache&&window.invalidateContactsPopupCache(),"function"==typeof window.syncSplitParticipantsUi&&"split"===e.view?window.syncSplitParticipantsUi():"function"==typeof window.render&&window.render(!0);const g=`${w.first||""} ${w.last||""}`.trim();return{ok:!0,id:w.id,displayName:g,renamed:c}}function T(t){I();const o=(e.contacts||[]).find(e=>e.id===t);o&&(P===t&&document.getElementById("contactCardFlipOverlay")?$():function(e){var t,o,r;$(),P=e.id;const d="function"==typeof n&&n(),l=a(e,{includeAvatar:d}),s=i(`${e.first||""} ${e.last||""}`.trim()),c=i(l||""),p=document.createElement("div");p.id="contactCardFlipOverlay",p.className="modal-overlay contact-card-flip-overlay",p.style.cssText=window.modalOverlayStyle||"position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.55);padding:16px;",p.innerHTML=`\n    <div class="contact-flip-card" style="perspective:900px;width:min(100%,340px);">\n      <div class="contact-flip-inner" style="position:relative;transform-style:preserve-3d;transition:transform 0.45s ease;transform:rotateY(180deg);min-height:280px;">\n        <div class="contact-flip-face contact-flip-front" style="backface-visibility:hidden;position:absolute;inset:0;border-radius:24px;padding:20px;background:var(--card-bg);border:1.5px solid var(--glass-border);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;">\n          <div style="font-weight:900;font-size:18px;">${s}</div>\n          <div style="font-size:12px;color:var(--text-secondary);text-align:center;">Tap outside to close</div>\n        </div>\n        <div class="contact-flip-face contact-flip-back" style="backface-visibility:hidden;transform:rotateY(180deg);position:relative;border-radius:24px;padding:16px;background:var(--card-bg);border:1.5px solid var(--glass-border);display:flex;flex-direction:column;gap:10px;">\n          <div style="font-weight:900;font-size:16px;">Share / import contact</div>\n          <p style="font-size:11px;color:var(--text-secondary);margin:0;line-height:1.4;">Copy this code or paste someone else's. ${d?"Your avatar is included.":"Upgrade to Gold to share avatars."}</p>\n          <textarea id="contactCardPayloadField" readonly rows="4" style="width:100%;font-size:10px;font-family:monospace;resize:none;border-radius:12px;padding:8px;border:1px solid var(--glass-border);background:var(--input-bg, var(--card-bg));">${c}</textarea>\n          <label style="font-size:11px;font-weight:700;">
1Import code</label>\n          <textarea id="contactCardImportField" rows="3" placeholder="Paste CC1… code" style="width:100%;font-size:10px;font-family:monospace;resize:none;border-radius:12px;padding:8px;border:1px solid var(--glass-border);"></textarea>\n          <div style="display:flex;gap:8px;flex-wrap:wrap;">\n            <button type="button" id="contactCardCopyBtn" style="${window.baseBtn||""} flex:1;">Copy share code</button>\n            <button type="button" id="contactCardImportBtn" style="${window.baseBtn||""} flex:1;">Import</button>\n            <button type="button" id="contactCardCloseBtn" style="${window.baseBtn||""}">Close</button>\n          </div>\n        </div>\n      </div>\n    </div>`,document.body.appendChild(p),p.addEventListener("click",e=>{e.target===p&&$()}),null==(t=p.querySelector("#contactCardCloseBtn"))||t.addEventListener("click",$),null==(o=p.querySelector("#contactCardCopyBtn"))||o.addEventListener("click",async()=>{const e=p.querySelector("#contactCardPayloadField");if(null==e?void 0:e.value)try{await navigator.clipboard.writeText(e.value),"function"==typeof customAlert&&customAlert("Contact code copied.")}catch{e.select(),document.execCommand("copy")}}),null==(r=p.querySelector("#contactCardImportBtn"))||r.addEventListener("click",()=>{var e,t;const n=null==(t=null==(e=p.querySelector("#contactCardImportField"))?void 0:e.value)?void 0:t.trim();if(!n)return;const o=A(n);if(o.ok){const e=o.renamed?`${o.displayName} was added. A contact with that name already existed, so the name was adjusted.`:`${o.displayName} was added to your directory.`;"function"==typeof customAlert&&customAlert(e),$(),"function"==typeof window.contacts&&window.contacts(),"function"==typeof window.render&&window.render()}else"function"==typeof customAlert&&customAlert(o.message)})}(o))}window.resetContactCardFlip=$,window.openContactCardFlip=T,window.importContactFromCardPayload=A;const L=Object.freeze(Object.defineProperty({__proto__:null,attachContactAvatarTap:function(e,t){if(!e||!t)return;if(e.dataset.contactId=t,e.classList.add("contact-avatar-tap"),e.setAttribute("role","button"),e.setAttribute("aria-label","Share or import contact info"),e.tabIndex=0,e.style.cursor="pointer","1"===e.dataset.flipBound)return;e.dataset.flipBound="1";const n=e=>{e.preventDefault(),e.stopPropagation(),T(t)};e.addEventListener("click",n),e.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||n(e)})},bindContactCardFlipScope:I,importContactFromCardPayload:A,openContactCardFlip:T,resetContactCardFlip:$},Symbol.toStringTag,{value:"Module"}));window.generateCustomMessage=function(e,t,n,o){var a,i,r,d,l;const s=(null==(a=window.state)?void 0:a.settings)||{},c="payApp"===e?s.payAppMessageTemplate||"{receipt_name} - {date}":s.textMessageTemplate||"{receipt_name} - {date}";let p=[];if(Array.isArray(t))p=t;else if(t)p=[t];else{const e=(null==(d=null==(i=window.state)?void 0:i.saved)?void 0:d[null==(r=window.state)?void 0:r.viewingCheckIndex])||(null==(l=window.state)?void 0:l.metadata);e&&(p=[e])}if(0===p.length)return c.replace(/{receipt_name}/g,"Receipt").replace(/{date}/g,(new Date).toLocaleDateString()).replace(/{subtotal_items}/g,"").replace(/{responsible_item}/g,"");let u="Receipt";if(1===p.length)u=p[0].name||"Receipt";else if(2===p.length)u=`${p[0].name||"Receipt"} and ${p[1].name||"Receipt"}`;else if(p.length>=3){const e=e=>(e.prices||(e.receipt?e.receipt.map(e=>e.price):[])).reduce((e,t)=>e+(Number(t)||0),0);u=[...p].sort((t,n)=>e(n)-e(t)).slice(0,3).map(e=>e.name||"Receipt").join(", ")}let w="";const g=p[0],m=g.dateHappened||g.dateCreated||g.date||"";if(m){const e=new Date(m);isNaN(e.getTime())||(w=`${e.getMonth()+1}/${e.getDate()}/${String(e.getFullYear()).slice(-2)}`)}if(!w){const e=new Date;w=`${e.getMonth()+1}/${e.getDate()}/${String(e.getFullYear()).slice(-2)}`}const f=e=>{if(void 0!==window.CategorizationEngine&&"function"==typeof window.CategorizationEngine.isSurcharge)return window.CategorizationEngine.isSurcharge(e);const t=(e||"").toLowerCase();return["tax","tip","gratuity","fee","subtotal","discount"].some(e=>t.includes(e))},y=[],v=[];
1p.forEach(e=>{const t=e.items||(e.receipt?e.receipt.map(e=>e.name):[]),o=e.percentages,a=e.contacts||[];t.forEach((e,t)=>{var i,r,d;const l=f(e),s=l&&(e||"").toLowerCase().includes("fee");let c=!1;if(n)if(o){const e=a.indexOf(n);-1!==e&&((null==(i=o[t])?void 0:i[e])||0)>0&&(c=!0)}else(null==(r=window.state)?void 0:r.splits)&&((null==(d=window.state.splits[t])?void 0:d[n])||0)>0&&(c=!0);!c&&n||(l?s&&(v.includes(e)||v.push(e)):y.includes(e)||y.push(e))})}),0===y.length&&0===v.length&&p.forEach(e=>{(e.items||(e.receipt?e.receipt.map(e=>e.name):[])).forEach(e=>{const t=f(e),n=t&&(e||"").toLowerCase().includes("fee");t?n&&(v.includes(e)||v.push(e)):y.includes(e)||y.push(e)})});const h=y.length>0?y.join(", "):v.length>0?v.join(", "):"";let x=-1,b="";return p.forEach(e=>{const t=e.items||(e.receipt?e.receipt.map(e=>e.name):[]),o=e.percentages,a=e.contacts||[];t.forEach((e,t)=>{var i,r,d;if(f(e))return;let l=0;if(n)if(o){const e=a.indexOf(n);-1!==e&&(l=(null==(i=o[t])?void 0:i[e])||0)}else(null==(r=window.state)?void 0:r.splits)&&(l=(null==(d=window.state.splits[t])?void 0:d[n])||0);l>x&&(x=l,b=e)})}),!b&&y.length>0&&(b=y[0]),c.replace(/{receipt_name}/g,u).replace(/{date}/g,w).replace(/{subtotal_items}/g,h).replace(/{responsible_item}/g,b)};const D=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));const z=["#7678ed","#4dd0e1","#3b82f6","#6366f1","#ba68c8","#9C27B0","#E91E63","#F44336","#FF5722","#FF9800","#f59e0b","#FFC107","#FFEB3B","#CDDC39","#8BC34A","#22c55e","#4CAF50","#009688","#00BCD4","#03A9F4","#2196F3","#3F51B5","#673AB7","#795548","#607D8B","#90a4ae","#9E9E9E","#34495E"];let O=!1,F=!1,_=null,H="",j=1,N=5,U={show:!1,group:"all",oweStatus:"all",sortBy:"alphaAsc"};const G="border: 1.5px solid var(--glass-border); border-radius: 24px; padding: 10px 16px; font-weight: 900; letter-spacing: -1px; cursor: pointer; background: var(--card-bg); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05); font-size: 16px; transition: transform 0.1s;",R=`border: 1.5px solid var(--glass-border); border-radius: 24px; padding: 10px 16px; font-weight: 900; letter-spacing: -1px; cursor: pointer; background: ${"function"==typeof getThemeColor?getThemeColor("negative_accent"):"var(--error-text)"}; color: ${"function"==typeof getAutoTextColor?getAutoTextColor("#fff","function"==typeof getThemeColor?getThemeColor("negative_accent"):"#000"):"#fff"}; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05); font-size: 16px;`,q=`border: 1.5px solid var(--glass-border); border-radius: 24px; padding: 10px 20px; font-weight: 900; letter-spacing: -1px; cursor: pointer; background: ${"function"==typeof getThemeColor?getThemeColor("info"):"var(--me-color)"}; color: ${"function"==typeof getAutoTextColor?getAutoTextColor("#fff","function"==typeof getThemeColor?getThemeColor("info"):"#000"):"#fff"}; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05); font-size: 16px;`,V="border: 1.5px solid var(--glass-border); border-radius: 24px; padding: 10px 12px; font-size: 16px; font-weight: 500; outline: none; width: 100%; box-sizing: border-box; background: rgba(255, 255, 255, 0.15); color: var(--text-primary);";window.loadContactsPage=function(){Q(),j=1};let Y={version:-1,result:null};function Z(){if(Y.version===e.version&&Y.result)return Y.result;const t={};(e.saved||[]).forEach(e=>{if(!e)return;const n=e.perSplit&&Object.keys(e.perSplit).length>0?e.perSplit:e.perAmount&&Object.keys(e.perAmount).length>0?e.perAmount:"function"==typeof computeUserBreakdown?computeUserBreakdown(e).totals:{},o="function"==typeof window.getCheckSettlements&&e.id?window.getCheckSettlements(e.id):"function"==typeof intuitiveSettle?intuitiveSettle(n,e.paidByTotals||{},e.transactions||[],e.contacts):[];if(Array.isArray(e.contacts))for(let a=0;a<e.contacts.length;a++){const n=e.contacts[a];t[n]||(t[n]={netBalance:0,checkCount:0}),t[n].checkCount++}for(let a=0;a<o.length;a++){const e=o[a];t[e.from]||(t[e.from]={netBalance:0,checkCount:0}),t[e.to]||(t[e.to]={netBalance:0,checkCount:0}),t[e.from].netBalance-=e.amount,t[e.to].netBalance+=e.amount}});for(const e in t)t[e].netBalance=Math.round(100*t[e].netBalance)/100;
1return Y={version:e.version,result:t},t}function K(){Y={version:-1,result:null}}function J(){U.show=!U.show,window.render()}function W(e,t){U[e]=t,j=1,window.render()}function Q(){H="",U.group="all",U.oweStatus="all",U.sortBy="alphaAsc",j=1,window.render()}function X(){var e,t;null==(e=document.getElementById("contactModalOverlay"))||e.remove(),null==(t=document.getElementById("standaloneContactModalOverlay"))||t.remove()}function ee(){const t=window._contactModalReturnContext;X(),O=!1,window.isContactModalOpen=!1,_=null,F=!1,window._isModalOpening=!1,window._contactModalReturnContext=null,window.modalBaseState=null,"contactsPopup"===t&&e.contactsPopupOpen&&"function"==typeof window.restoreManageContactsPopup?window.restoreManageContactsPopup():(document.body.classList.remove("modal-open"),"function"==typeof window.syncModalOpenBodyClass&&window.syncModalOpenBodyClass())}function te(t={}){if((e.groups||[]).length,X(),!O)return null;const n=t.id||"contactModalOverlay",o=ce();let a="function"==typeof window.mountHtmlModalOverlay?window.mountHtmlModalOverlay(o,{id:n,zIndex:t.zIndex}):null;return a||(a=function(e,t,n){const o="function"==typeof window.getModalHost?window.getModalHost():document.body,a=document.createElement("div");a.innerHTML=(e||"").trim();const i=Array.from(a.children).filter(e=>e instanceof HTMLElement),r=i.find(e=>e.classList.contains("modal-overlay"))||i.find(e=>!e.matches("style, script, link, meta"));return r?(i.forEach(e=>{e!==r&&"style"===e.tagName.toLowerCase()&&r.insertBefore(e,r.firstChild)}),r.id=t,r.dataset.scModalBody="1",null!=n&&(r.style.zIndex=String(n)),o.appendChild(r),r):null}(o,n,t.zIndex)),a?(document.body.classList.add("modal-open"),se(),requestAnimationFrame(()=>{var e;const t=a.querySelector(".contact-modal-container");t&&"function"==typeof window.bindModalViewportFit&&(null==(e=window._contactModalViewportUnbind)||e.call(window),window._contactModalViewportUnbind=window.bindModalViewportFit(a,t,{reservedTop:16,reservedBottom:24,ignoreKeyboard:!0}))}),a):(console.error("Contact modal failed to mount; releasing UI lock"),ee(),null)}function ne(e,t={}){if(window._contactModalReturnContext=t.returnContext||null,window._isModalOpening)return null;window._isModalOpening=!0;try{_=e,F=!1,O=!0,window.isContactModalOpen=!0;const n=te({id:"standaloneContactModalOverlay",zIndex:t.zIndex??35e3});return n?(setTimeout(()=>{window.modalBaseState=window.captureModalState(),window._isModalOpening=!1},150),n):null}catch(n){return console.error("Failed to mount standalone contact modal",n),window._isModalOpening=!1,window._contactModalReturnContext=null,"function"==typeof window.restoreManage
1ContactsPopup&&window.restoreManageContactsPopup(),null}}function oe(t){var n;if(!window._isModalOpening){window._isModalOpening=!0,window._contactModalReturnContext=null,"function"==typeof window.ensureMeContactIntegrity&&window.ensureMeContactIntegrity(),(null==(n=e.settings)?void 0:n.meId)&&(e.contacts||[]).some(t=>t&&t.id===e.settings.meId&&!t.isDeleted)&&(window.isAddYourselfSpecial=!1);try{if(document.body.classList.add("modal-open"),_=t,F=!1,O=!0,window.isContactModalOpen=!0,"contacts"===e.view&&document.querySelector("#app .page-container")){if(!te({id:"contactModalOverlay"}))return;return void setTimeout(()=>{window.modalBaseState=window.captureModalState(),window._isModalOpening=!1},150)}"function"==typeof window.render&&window.render(),setTimeout(()=>{if(!O)return;(document.getElementById("contactModalOverlay")||document.getElementById("standaloneContactModalOverlay")||te({id:"contactModalOverlay"}))&&(window.modalBaseState=window.captureModalState(),window._isModalOpening=!1)},150)}catch(o){console.error("Failed to open contact modal",o),ee()}}}async function ae(t=!1){var n,o,a;if(!t&&window.isContactModalDirty()&&!(await customConfirm("You have unsaved contact changes. Are you sure you want to discard them?")))return!1;null==(n=document.getElementById("contactAppearanceOverlay"))||n.remove(),null==(o=window._contactAppearanceViewportUnbind)||o.call(window),window._contactAppearanceViewportUnbind=null,null==(a=window._contactModalViewportUnbind)||a.call(window),window._contactModalViewportUnbind=null;const i=window._contactModalReturnContext;return window._contactModalReturnContext=null,X(),O=!1,window.isContactModalOpen=!1,F=!1,_=null,window.isAddYourselfSpecial=!1,window._isModalOpening=!1,window.modalBaseState=null,"contactsPopup"===i?(e.contactsPopupOpen?(document.body.classList.add("modal-open"),"function"==typeof window.restoreManage
1ContactsPopup&&window.restoreManageContactsPopup()):document.body.classList.remove("modal-open"),!0):(document.body.classList.remove("modal-open"),window.render(),!0)}function ie(t,n=null){if(!t)return"#7678ed";let o=t.toUpperCase();const a=e=>{if(!e)return!1;const t=e.replace("#","").toUpperCase();return"000000"===t||"FFFFFF"===t||"000"===t||"FFF"===t},i=[...(e.contacts||[]).filter(e=>e&&e.id&&e.id!==n).map(e=>e.color),...(e.groups||[]).filter(e=>e&&e.id).map(e=>e.color)].map(e=>(e||"").toUpperCase());return a(o)||i.includes(o)?he(i):o}function re(t,n,o=null){const a=`${(t||"").trim()} ${(n||"").trim()}`.trim().toLowerCase();return!!a&&(e.contacts||[]).some(e=>{if(!e||!e.id||e.id===o)return!1;return`${(e.first||"").trim()} ${(e.last||"").trim()}`.trim().toLowerCase()===a})}function de(){const e=document.getElementById("fn"),t=document.getElementById("ln"),n=document.getElementById("e"),o=document.getElementById("p"),a=document.getElementById("paymentHandle"),i=document.getElementById("prefPayment");if(!e||!t)return null;const r=e.value,d=t.value,l=r.trim(),s=d.trim(),c=n?n.value.trim():"",p=o?o.value.trim():"",u=i?i.value.trim():"",w=a?a.value.trim():"";if(!l)return"First name is required.";if(l.length>18)return"First name cannot exceed 18 characters.";if(s.length>18)return"Last name cannot exceed 18 characters.";if(/[0-9]/.test(r)||/[0-9]/.test(d))return"No numbers allowed in names.";const g=/^[A-Za-zÀ-ÖØ-öø-ÿ' -]*$/;if(!g.test(r.trim()))return"First name contains invalid characters.";if(!g.test(d.trim()))return"Last name contains invalid characters.";if(re(l,s,_))return"A contact with this name already exists.";if(c&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c))return"Please enter a valid email address.";if(p){if(/[a-zA-Z]/.test(p))return"Phone number contains invalid characters.";if(p.replace(/\D/g,"").length<10)return"Please enter a valid phone number (10 digits).";if(!ve(p))return"Please enter a valid phone number (10 digits)."}if(u){const e=document.getElementById("paymentHandleContainer");if(e&&"none"!==e.style.display){if(!w)return"Please enter a payment handle.";if(w.length>30)return"Payment handle cannot exceed 30 characters.";if(/\s/.test(w))return"Payment handle cannot contain spaces."}}return null}function le(){"undefined"==typeof document||window._contactToggleDelegationBound||(window._contactToggleDelegationBound=!0,document.body.addEventListener("click",e=>{const t=e.target.closest(".pay-toggle, .pay-toggle-popup");if(t){const e=t.dataset.val;if(!e)return;return void(t.classList.contains("pay-toggle-popup")?"function"==typeof window.togglePaymentPopup&&window.togglePaymentPopup(e):"function"==typeof window.togglePayment&&window.togglePayment(e))}const n=e.target.closest(".contact-detail-toggle, .contact-detail-toggle-popup");if(n){const e=n.dataset.val;if(!e)return;n.classList.contains("contact-detail-toggle-popup")?"function"==typeof window.toggleContactDetailPopup&&window.toggleContactDetailPopup(e):"function"==typeof window.toggleContactDetail&&window.toggleContactDetail(e)}}))}function se(){const t=null!==_;!t||(window.getMemoizedContactsMap?window.getMemoizedContactsMap(e.contacts)[_]:(e.contacts||[]).find(e=>e.id===_));const n=document.getElementById("fn"),o=document.getElementById("ln"),a=document.getElementById("e"),i=document.getElementById("p"),r=document.getElementById("paymentHandle"),d=document.getElementById("contactAppearanceEditBtn"),l=document.getElementById("closeContactModalBtn"),s=document.getElementById("contactSaveBtn"),c=document.getElementById("contactDeleteBtn");!n||null===_&&""===n.value.trim()||(n.dataset.touched="true");[n,o,a,i,r].forEach(e=>{if(e){const t=()=>{n&&(n.dataset.touched="true"),window.updateContactSaveBtnState()};e.addEventListener("input",t),e.addEventListener("blur",t),e.addEventListener("focusout",t)}}),d&&d.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),pe()}),l&&l.addEventListener("click",()=>ae()),s&&s.addEventListener("click",()=>t?we():ue()),c&&c.addEventListener("click",()=>ge(_)),le(),r&&r.addEventListener("input",e=>window.updateHiddenHandle(e.target.value));const p=document.getElementById("contactGroupPillsContainer"),u=document.getElementById("groupModalFilterTabs");function w(){var e,t;if(!p)return;const n=(null==(t=null==(e=null==u?void 0:u.querySelector(".group-tab-btn.active"))?void 0:e.dataset)?void 0:t.filter)||"all",o=document.getElementById("groupModalSearchInput"),a=o?o.value.trim().toLowerCase():"",i=p.querySelectorAll(".contact-group-pill");let r=i.length,d=0;
1i.forEach(e=>{const t=e.querySelector(".contact-group-cb"),o=!!t&&t.checked;o&&d++;const i=e.dataset.groupName||"";let r=!0;"selected"===n&&(r=o),"unselected"===n&&(r=!o);let l=!0;a&&(l=i.includes(a)),e.style.display=r&&l?"flex":"none"});let l=r-d;const s=null==u?void 0:u.querySelector('[data-filter="all"]'),c=null==u?void 0:u.querySelector('[data-filter="selected"]'),w=null==u?void 0:u.querySelector('[data-filter="unselected"]');s&&(s.textContent=`All (${r})`),c&&(c.textContent=`Selected (${d})`),w&&(w.textContent=`Unselected (${l})`);const g=document.getElementById("contactGroupMemberCountBadge");g&&(g.textContent=`${d} Selected`)}u&&!u.dataset.scBound&&(u.dataset.scBound="1",u.addEventListener("click",e=>{const t=e.target.closest(".group-tab-btn");t&&(u.querySelectorAll(".group-tab-btn").forEach(e=>{e.classList.remove("active"),e.style.background="rgba(255, 255, 255, 0.08)",e.style.color="var(--text-secondary)",e.style.border="1px solid var(--glass-border)"}),t.classList.add("active"),t.style.background="var(--text-primary)",t.style.color="var(--card-bg)",t.style.border="1.5px solid var(--text-primary)",w())})),p&&!p.dataset.scBound&&(p.dataset.scBound="1",p.addEventListener("click",e=>{const t=e.target.closest(".contact-group-pill");if(!t)return;const n=t.querySelector(".contact-group-cb");if(!n)return;n.checked=!n.checked;const o=n.checked,a=t.dataset.groupColor||"var(--text-secondary)";t.classList.toggle("active",o),o?(t.style.background=`color-mix(in srgb, ${a} 25%, var(--card-bg))`,t.style.border=`2px solid ${a}`,t.style.boxShadow=`0 0 12px color-mix(in srgb, ${a} 35%, transparent)`,t.style.opacity="1"):(t.style.background="rgba(255, 255, 255, 0.06)",t.style.border="1.5px solid var(--glass-border)",t.style.boxShadow="none",t.style.opacity="0.7");const i=t.querySelector(".group-pill-status-icon");i&&(o?(i.style.background=a,i.style.color="function"==typeof getAutoTextColor?getAutoTextColor("#fff",a):"#fff",i.innerHTML="function"==typeof window.customEmojiHtml?window.customEmojiHtml("check",{width:"11px",height:"11px"}):"✓"):(i.style.background="rgba(255,255,255,0.15)",i.style.color="var(--text-secondary)",i.innerHTML="+")),w(),"function"==typeof window.updateContactSaveBtnState&&window.updateContactSaveBtnState()}));const g=document.getElementById("groupModalSearchInput");g&&!g.dataset.scBound&&(g.dataset.scBound="1",g.addEventListener("input",()=>{w()})),window.updateContactSaveBtnState()}function ce(t){var n;const o=null!==_,a=o&&(window.getMemoizedContactsMap?window.getMemoizedContactsMap(e.contacts)[_]:(e.contacts||[]).find(e=>e.id===_))||{};let r=o?'<svg class="nav-icon dash-icon-svg" style="width: 1em; height: 1em; vertical-align: middle; margin-bottom: 0px;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg> Edit Contact':"New Contact";o||"contactsPopup"!==window._contactModalReturnContext||(r="New Contact");const d=[...(e.contacts||[]).filter(e=>e&&e.id&&e.id!==_).map(e=>e.color),...(e.groups||[]).filter(e=>e&&e.id).map(e=>e.color)],l=a.color||he(d);let s=a.first||"",c=a.last||"";if(((null==(n=e.settings)?void 0:n.meId)?window.getMemoizedContactsMap?window.getMemoizedContactsMap(e.contacts)[e.settings.meId]:(e.contacts||[]).find(t=>t.id===e.settings.meId):null)&&(window.isAddYourselfSpecial=!1),!o&&window.isAddYourselfSpecial&&(r="Add Yourself",!s&&e.user&&!e.user.isGuest&&(s=e.user.firstName||"",c=e.user.lastName||"",!s&&e.user.username&&!e.user.username.includes("@")))){const t=e.user.username.trim().split(" ");s=t[0]||"",c=t.slice(1).join(" ")||""}const p=window.modalOverlayStyle||"position:fixed; inset:0; background:rgba(0,0,0,0.52); display:flex; align-items:center; justify-content:center; z-index:30000; padding:16px; box-sizing:border-box; backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px);",u="function"==typeof window.getTxModalShellStyle?window.getTxModalShellStyle("560px",l):(window.modalContainerStyle||"position:relative; background:var(--card-bg); border-radius:24px; width:100%; display:flex; flex-direction:column; overflow:hidden; min-height:0;")+" max-width:560px; padding:0; overflow:hidden;",g=window.modalHeaderStyle||"display:flex; justify-content:space-between; align-items:center; padding:20px 20px 16px; border-bottom:1.5px solid var(--glass-border); background:transparent; flex-shrink:0;";a.preferredPayment;const m=a.email||"",f=a.phone||"",y=!!m,v=!!f,h=a.avatarImage&&"None"!==a.avatarImage?(a.avatarImage||"").replace(/['"()]/g,""):null,b=h?`background: ${l}; background-image: url('${w(h)||`avatars/${h}`}'); background-size: cover; background-position: center;`:`background: ${l};`;
1return`\n    <div class="modal-overlay sc-modal-viewport-fit" data-sc-modal-body="1" data-no-keyboard-resize="true" style="${p}">\n      <div class="contact-modal-container sc-modal-panel" style="${u}">\n        <div id="contactAppearanceHiddenFields" style="position:absolute;width:0;height:0;overflow:hidden;opacity:0;pointer-events:none;" aria-hidden="true">\n          <input autocomplete="off" type="color" id="c" value="${l}">\n          <input autocomplete="off" type="hidden" id="hiddenOverlayImage" value="${a.overlayImage||"None"}">\n          <input type="hidden" id="hiddenAnimationPref" value="${a.animationPref??"-1"}">\n          <input type="hidden" id="hiddenAvatarImage" value="${a.avatarImage||"None"}">\n        </div>\n\n        <div style="${g} padding: 16px 20px; gap: 12px;">\n          <div style="display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1;">\n            <div style="position: relative; flex-shrink: 0;">\n              <div id="contactModalProfilePreview" style="position: relative; width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--glass-border); box-sizing: border-box; overflow: visible; box-shadow: var(--glass-shadow), 0 4px 12px rgba(0,0,0,0.1); ${b}">\n              </div>\n              <button type="button" id="contactAppearanceEditBtn" class="sc-appearance-edit-btn" aria-label="Edit avatar and appearance" title="Edit avatar, color, and bar style">\n                <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg>\n              </button>\n            </div>\n            <h3 style="margin: 0; font-size: 20px; font-weight: 900; color: var(--text-primary); text-transform: uppercase; letter-spacing: -0.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;">${r}</h3>\n          </div>\n          <button id="closeContactModalBtn" aria-label="Close" style="${window.baseBtn} padding: 2px 8px; width: 36px; height: 36px; min-height: 36px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;"><svg class="nav-icon dash-icon-svg" style="width: 1.2em; height: 1.2em; vertical-align: middle; margin-bottom: 0px;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></button>\n        </div>\n\n        <div id="contactModalContent" class="contact-modal-scroll" style="flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 14px;">\n\n          <div id="contactFormErrorBanner" style="display: none; background: rgba(244, 67, 54, 0.12); border: 1.5px solid var(--negative-accent, #f44336); color: var(--negative-accent, #f44336); border-radius: 16px; padding: 10px 14px; font-size: 13px; font-weight: 800; align-items: center; gap: 8px; box-shadow: var(--glass-shadow);">\n            <span id="contactFormErrorIcon" style="display: inline-flex; align-items: center; flex-shrink: 0;"></span>\n            <span id="contactFormErrorText"></span>\n          </div>\n\n          <section>\n            <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px;">\n              <div><label style="${window.labelStyle||""}">FIRST NAME</label><input autocomplete="off" id="fn" value="${i(s||a.first||"")}" maxlength="18" style="${V}" placeholder="Required"></div>\n              <div><label style="${window.labelStyle||""}">LAST NAME</label><input autocomplete="off" id="ln" value="${i(c||a.last||"")}" maxlength="18" style="${V}" placeholder="Optional"></div>\n            </div>\n          </section>\n\n          <section>\n            <strong style="display: block; margin-bottom: 10px; font-size: 15px; font-weight: 900; text-transform: uppercase; color: var(--text-primary); border-bottom: 1.5px solid var(--glass-border); padding-bottom: 4px;">Payment & Contact</strong>\n            <div style="display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap;">\n              ${["venmo","cashapp","paypal"].map(e=>{const t=a.preferredPayment===e,n="cashapp"===e?"CASH APP":e.toUpperCase();return`\n                  <div class="pay-toggle" data-val="${e}" role="button" tabindex="0" style="flex: 1; text-align: center; padding: 10px 4px; border-radius: 20px; border: ${t?"3px solid #00FFFF":"1.5px solid var(--glass-border)"}; background: var(--card-bg); cursor: pointer; font-weight: 900; font-size: 14px; transition: all 0.2s; min-width: 80px;">\n                    ${n}\n                  </div>\n                `}).join("")}\n            </div>\n\n            <div style="display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap;">\n              ${["email","phone"].map(e=>{const t="email"===e&&y||"phone"===e&&v,n=e.toUpperCase();return`\n                  <div class="contact-detail-toggle" data-val="${e}" role="button" tabindex="0" style="flex: 1; text-align: center; padding: 10px 4px; border-radius: 20px; border: ${t?"3px solid #00FFFF":"1.5px solid var(--glass-border)"}; background: var(--card-bg); cursor: pointer; font-weight: 900; font-size: 14px; transition: all 0.2s; min-width: 80px;">\n                    ${n}\n                  </div>\n                `}).join("")}\n            </div>\n\n            <input type="hidden" id="prefPayment" value="${a.preferredPayment||""}">\n            <input type="hidden" id="h_venmo" value="${i(a.venmo||"")}">\n            <input type="hidden" id="h_cashapp" value="${i(a.cashapp||"")}">\n            <input type="hidden" id="h_paypal" value="${i(a.paypal||"")}">\n\n            <div id="paymentHandleContainer" style="margin-top: 8px; display: ${a.preferredPayment?"block":"none"};">\n              <label id="handleLabel" style="${window.labelStyle||""}">${C=a.preferredPayment,{venmo:"VENMO HANDLE",cashapp:"CASH APP ID",paypal:"PAYPAL HANDLE"}[C]||"PAYMENT HANDLE"}</label>\n              <div class="qr-input-wrapper">
1\n                <span class="qr-symbol-inline">${x({size:18,type:"monochrome"})}</span>\n                <input autocomplete="off" id="paymentHandle" value="${i(a[a.preferredPayment]||"")}" style="${V}" placeholder="Enter Username">\n              </div>\n            </div>\n\n            <div id="emailHandleContainer" style="margin-top: 8px; display: ${y?"block":"none"};">\n              <label style="${window.labelStyle||""}">EMAIL HANDLE</label>\n              <input autocomplete="off" id="e" value="${i(m)}" maxlength="100" style="${V}" placeholder="[email protected]">\n            </div>\n\n            <div id="phoneHandleContainer" style="margin-top: 8px; display: ${v?"block":"none"};">\n              <label style="${window.labelStyle||""}">PHONE HANDLE</label>\n              <input autocomplete="off" id="p" value="${i(f)}" maxlength="20" style="${V}" placeholder="555-555-5555">\n            </div>\n          </section>\n\n          <section>\n            <div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1.5px solid var(--glass-border); padding-bottom: 4px; margin-bottom: 10px;">\n              <strong style="font-size: 15px; font-weight: 900; text-transform: uppercase; color: var(--text-primary);">Group Memberships</strong>\n              ${(e.groups||[]).filter(e=>e&&e.id).length>0?`\n                <span id="contactGroupMemberCountBadge" style="font-size: 11px; font-weight: 800; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; background: rgba(255, 255, 255, 0.1); padding: 2px 8px; border-radius: 12px; border: 1px solid var(--glass-border);">\n                  ${o&&a.id?(e.groups||[]).filter(e=>e&&e.members&&e.members.includes(a.id)).length:0} Selected\n                </span>\n              `:""}\n            </div>\n\n            ${(e.groups||[]).filter(e=>e&&e.id).length>0?`\n              <div style="display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px;">\n                <div id="groupModalFilterTabs" style="display: flex; gap: 6px; flex-wrap: wrap;">\n                  <button type="button" class="group-tab-btn active" data-filter="all" style="${window.baseBtn} padding: 4px 10px; font-size: 11px; font-weight: 900; border-radius: 14px; background: var(--text-primary); color: var(--card-bg); border: 1.5px solid var(--text-primary); transition: all 0.2s;">\n                    All (${(e.groups||[]).filter(e=>e&&e.id).length})\n                  </button>\n                  <button type="button" class="group-tab-btn" data-filter="selected" style="${window.baseBtn} padding: 4px 10px; font-size: 11px; font-weight: 900; border-radius: 14px; background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); border: 1px solid var(--glass-border); transition: all 0.2s;">\n                    Selected (${o&&a.id?(e.groups||[]).filter(e=>e&&e.members&&e.members.includes(a.id)).length:0})\n                  </button>\n                  <button type="button" class="group-tab-btn" data-filter="unselected" style="${window.baseBtn} padding: 4px 10px; font-size: 11px; font-weight: 900; border-radius: 14px; background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); border: 1px solid var(--glass-border); transition: all 0.2s;">\n                    Unselected (${(e.groups||[]).filter(e=>e&&e.id).length-(o&&a.id?(e.groups||[]).filter(e=>e&&e.members&&e.members.includes(a.id)).length:0)})\n                  </button>\n                </div>\n\n                ${(e.groups||[]).filter(e=>e&&e.id).length>=4?`\n                  <input autocomplete="off" id="groupModalSearchInput" type="text" placeholder="Filter groups by name..." style="${V} height: 32px; font-size: 12px; padding: 4px 10px; border-radius: 16px;">\n                `:""}\n              </div>\n            `:""}\n\n            <div id="contactGroupPillsContainer" style="max-height: 200px; overflow-y: auto; padding: 4px 2px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px;">\n              ${(e.groups||[]).filter(e=>e&&e.id).length>0?(e.groups||[]).filter(e=>e&&e.id).map(t=>{var n;const r=o&&t.members&&t.members.includes(a.id),d=t.color||"var(--text-secondary)",l=t.avatarImage&&"None"!==t.avatarImage?(t.avatarImage||"").replace(/['"()]/g,""):null,s=l&&!(null==(n=e.user)?void 0:n.isGuest)?`background: ${d}; background-image: url('${w(l)||`avatars/${l}`}'); background-size: cover; background-position: center;`:`background: ${d};`,c=(t.members||[]).length,p=`background: color-mix(in srgb, ${i(d)} 25%, var(--card-bg)); border: 2px solid ${i(d)}; box-shadow: 0 0 12px color-mix(in srgb, ${i(d)} 35%, transparent); opacity: 1;`;return`\n                  <div class="contact-group-pill ${r?"active":""}"\n                       data-group-id="${i(t.id)}"\n                       data-group-name="${i(t.name).toLowerCase()}"\n                       data-group-color="${i(d)}"\n                       style="display: flex; align-items: center; justify-content: space-between; gap: 6px; cursor: pointer; padding: 6px 10px; border-radius: 20px; transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1); user-select: none; width: 100%; box-sizing: border-box; ${r?p:"background: rgba(255, 255, 255, 0.06); border: 1.5px solid var(--glass-border); opacity: 0.7;"}">\n                    <input type="checkbox" class="contact-group-cb" data-group-id="${i(t.id)}" ${r?"checked":""} style="display: none !important;">\n\n                    <div style="position: relative; width: 26px;
1 height: 26px; border-radius: 50%; border: 1.5px solid var(--glass-border); box-sizing: border-box; flex-shrink: 0; overflow: visible; ${s}"></div>\n\n                    <div style="display: flex; flex-direction: column; min-width: 0; flex: 1;">\n                      <span style="font-size: 12px; font-weight: 800; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">${i(t.name)}</span>\n                      <span style="font-size: 10px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap;">${c} Member${1!==c?"s":""}</span>\n                    </div>\n\n                    <div class="group-pill-status-icon" style="width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 900; flex-shrink: 0; background: ${r?i(d):"rgba(255,255,255,0.15)"}; color: ${r?"function"==typeof getAutoTextColor?getAutoTextColor("#fff",d):"#fff":"var(--text-secondary)"};">\n                      ${r?"function"==typeof window.customEmojiHtml?window.customEmojiHtml("check",{width:"11px",height:"11px"}):"✓":"+"}\n                    </div>\n                  </div>\n                `}).join(""):'<div style="font-size: 14px; color: var(--text-secondary); font-style: italic; text-align: center; padding: 12px; grid-column: 1 / -1;">No groups created yet.</div>'}\n            </div>\n          </section>\n\n        </div>\n\n        <div style="display:flex; gap:12px; padding:16px 20px; border-top:1.5px solid var(--glass-border); background:transparent; flex-shrink:0;">\n          ${o?`<button id="contactDeleteBtn" style="${window.baseBtn} ${window.getGlassyTintedButtonStyle(getThemeColor("negative_accent"))} height: 48px; padding: 0 16px;" title="Delete Contact"><svg class="nav-icon dash-icon-svg" style="width: 1.4em; height: 1.4em;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg></button>`:""}\n          <button id="contactSaveBtn" style="${window.baseBtn} ${window.getGlassyTintedButtonStyle(getThemeColor("accent"))} flex: 1; height: 48px; font-size: 18px; color: var(--text-primary); font-weight: 900; letter-spacing: -1px; display: flex; align-items: center; justify-content: center; ${o||s?"":"opacity: 0.5; pointer-events: none;"}" ${o||s?"":"disabled"}>\n            ${o?`UPDATE CONTACT ${window.customEmojiHtml("check",{width:"0.85em",height:"0.85em"})}`:"ADD CONTACT +"}\n          </button>\n        </div>\n\n      </div>\n    </div>\n  `;var C}function pe(){y({resolveColor:e=>ie(e,_),requireRegisteredUser:!0,onCloseMainPreview:()=>{var e;return null==(e=window.refreshContactModalPreview)?void 0:e.call(window)}})}function ue(){var t;if("function"==typeof window.canAddContact&&!window.canAddContact())return void("function"==typeof window.showPremiumModal&&window.showPremiumModal("contacts"));const n=me();if(!n)return;"undefined"!=typeof Logger&&Logger.log("Add New Contact",{contact:n}),e.contacts.push(n),"function"==typeof r&&r(),"function"==typeof window.invalidateContactsPopupCache&&window.invalidateContactsPopupCache(),"function"==typeof window.refreshContactsPopupLight&&window.refreshContactsPopupLight();const o=document.querySelectorAll(".contact-group-cb:checked"),a=window.getMemoizedGroupsMap?window.getMemoizedGroupsMap(e.groups):(e.groups||[]).reduce((e,t)=>(e[t.id]=t,e),{});if(o.forEach(e=>{const t=e.dataset.groupId,o=a[t];o&&(C(o,"remove"),o.members||(o.members=[]),o.members.includes(n.id)||o.members.push(n.id),C(o,"add"))}),"undefined"!=typeof ActionLogger&&ActionLogger.log("CREATE_CONTACT",n),"contactsPopup"===window._contactModalReturnContext)return"function"==typeof window.addCreatedContactToCheck&&window.addCreatedContactToCheck(n),"function"==typeof window.invalidateContactsPopupCache&&window.invalidateContactsPopupCache(),fe(),null==(t=window.clearDirty)||t.call(window,"contacts"),"function"==typeof d&&d(),void ae(!0);window.isAddYourselfSpecial?(e.settings=e.settings||{},e.settings.meId=n.id,e.settings.defaultPayerId="me",e.settings.remainderTo="default",e.user&&(e.user.firstName=(null==n?void 0:n.first)||"",e.user.lastName=(null==n?void 0:n.last)||"",e.user.username=`${(null==n?void 0:n.first)||""} ${(null==n?void 0:n.last)||""}`.trim()),e.user&&e.user.uid&&"function"==typeof window.updateUserDisplayName&&window.updateUserDisplayName(e.user.uid,(null==n?void 0:n.first)||"",(null==n?void 0:n.last)||"").catch(()=>{}),"function"==typeof window.clearDirty&&(window.clearDirty("contacts"),window.clearDirty("settings")),"function"==typeof d&&d(!0),ae(!0),"function"==typeof openSettlingPreferencesModal&&setTimeout(()=>
1openSettlingPreferencesModal(!0),300)):("function"==typeof window.ensureMeContactIntegrity&&window.ensureMeContactIntegrity(),window.clearDirty("contacts"),"function"==typeof d&&d(),ae(!0))}function we(){const t=me(_);if(!t)return;const n=e.contacts.findIndex(e=>e.id===_);-1!==n&&(e.contacts[n]=t),"function"==typeof r&&r(),"function"==typeof window.invalidateContactsPopupCache&&window.invalidateContactsPopupCache(),"function"==typeof window.refreshContactsPopupLight&&window.refreshContactsPopupLight();const o=document.querySelectorAll(".contact-group-cb");if(o.length>0){const n=(e.groups||[]).reduce((e,t)=>(e[t.id]=t,e),{});o.forEach(e=>{const o=e.dataset.groupId,a=n[o];if(a){C(a,"remove"),a.members||(a.members=[]);const n=e.checked,o=a.members.includes(t.id);n&&!o?a.members.push(t.id):!n&&o&&(a.members=a.members.filter(e=>e!==t.id)),C(a,"add")}})}"function"==typeof window.ensureMeContactIntegrity&&window.ensureMeContactIntegrity(),window.clearDirty("contacts"),"function"==typeof d&&d(),"function"==typeof window.closeProfile?window.closeProfile():"function"==typeof window.unmountProfilePopup&&window.unmountProfilePopup(),ae(!0)}async function ge(t){var n,o,a,i,l,s;if(!(await customConfirm("Are you sure you want to delete this contact completely?")))return;if(!t)return;const c=e.contacts.findIndex(e=>e.id===t);if(-1===c)return;const p=t,u=e._reverseIndex.contactToChecks.get(p)||new Set,w=e._reverseIndex.contactToGroups.get(p)||new Set;u.forEach(t=>{const n=e._reverseIndex.checkIdMap.get(t);n&&(Array.isArray(n.contacts)&&(n.contacts=n.contacts.filter(e=>e!==p)),n.paidByTotals&&void 0!==n.paidByTotals[p]&&delete n.paidByTotals[p],n.perSplit&&void 0!==n.perSplit[p]&&delete n.perSplit[p],n.perAmount&&void 0!==n.perAmount[p]&&delete n.perAmount[p],Array.isArray(n.transactions)&&(n.transactions=n.transactions.filter(e=>e.from!==p&&e.to!==p)),n.adjustments&&void 0!==n.adjustments[p]&&delete n.adjustments[p])}
1),w.forEach(t=>{const n=e._reverseIndex.groupIdMap.get(t);n&&Array.isArray(n.members)&&(n.members=n.members.filter(e=>e!==p))}),e.contacts.splice(c,1),window.clearDirty("contacts"),"function"==typeof window.removeSavedFilterContact&&window.removeSavedFilterContact(p),null==(a=null==(o=null==(n=e.ui)?void 0:n.tx)?void 0:o.contacts)||a.delete(p),null==(s=null==(l=null==(i=e.ui)?void 0:i.pendingTx)?void 0:l.contacts)||s.delete(p),"function"==typeof r&&r(),"function"==typeof window.invalidateContactsPopupCache&&window.invalidateContactsPopupCache(),"function"==typeof window.refreshContactsPopupLight&&window.refreshContactsPopupLight(),e.settings&&(e.settings.meId===p&&(e.settings.meId="","function"==typeof window.ensureMeContactIntegrity&&window.ensureMeContactIntegrity()),e.settings.defaultPayerId===p&&(e.settings.defaultPayerId=""),e.settings.remainderTo===p&&(e.settings.remainderTo="")),e._reverseIndex.contactToChecks.delete(p),e._reverseIndex.contactToGroups.delete(p),"function"==typeof d&&d(),"function"==typeof window.closeProfile?window.closeProfile():"function"==typeof window.unmountProfilePopup&&window.unmountProfilePopup(),ae(!0)}function me(t=null){var n,o;const a=document.getElementById("fn");a&&(a.dataset.touched="true");if(de())return updateContactSaveBtnState(),null;const i=document.getElementById("ln"),r=document.getElementById("e"),d=document.getElementById("p"),s=document.getElementById("h_venmo"),c=document.getElementById("h_cashapp"),p=document.getElementById("h_paypal"),u=document.getElementById("prefPayment"),w=document.getElementById("c"),g=document.getElementById("hiddenOverlayImage"),m=document.getElementById("hiddenAnimationPref"),f=document.getElementById("hiddenAvatarImage");if(!(a&&i&&r&&d&&w))return null;
1const y=/[^A-Za-zÀ-ÖØ-öø-ÿ' -]/g;let v=l(a.value,50).replace(y,"").trim(),h=l(i.value,50).replace(y,"").trim();if(!v)return null;if(v=ye(v),h=h?ye(h):"",re(v,h,t))return null;let x=l(r.value,100).toLowerCase();if(x&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x))return null;let b=l(d.value,20);if(b&&(b=ve(b),!b))return null;let C=ie(w.value,t);const k=g?g.value:"None",S=m?m.value:"-1",B=f?f.value:"None",P=t?window.getMemoizedContactsMap?window.getMemoizedContactsMap(e.contacts)[t]:e.contacts.find(e=>e.id===t):null,M=(null==P?void 0:P.createdAt)||Date.now();let $=(null==P?void 0:P.uid)||"";!$&&(null==(n=e.user)?void 0:n.uid)&&(window.isAddYourselfSpecial||t===(null==(o=e.settings)?void 0:o.meId))&&($=e.user.uid);const I={id:t||crypto.randomUUID(),first:v,last:h,email:x,phone:b,venmo:s?l(s.value,30):"",cashapp:c?l(c.value,30):"",paypal:p?l(p.value,30):"",preferredPayment:u?l(u.value,20):"",color:C,overlayImage:k,animationPref:S,avatarImage:B,createdAt:M};return $&&(I.uid=$),I}function fe(){var t;if(!e.contacts)return;const n=null==(t=e.settings)?void 0:t.meId;e.contacts.sort((e,t)=>{if(n){if(e.id===n&&t.id!==n)return-1;if(t.id===n&&e.id!==n)return 1}const o=((null==e?void 0:e.first)||"").localeCompare((null==t?void 0:t.first)||"",void 0,{sensitivity:"base"});return 0!==o?o:((null==e?void 0:e.last)||"").localeCompare((null==t?void 0:t.last)||"",void 0,{sensitivity:"base"})}),"function"==typeof window.clearDirty&&window.clearDirty("contacts")}function ye(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function ve(e){const t=e.replace(/\D/g,"");let n=t;return 11===t.length&&t.startsWith("1")&&(n=t.slice(1)),10!==n.length?null:`${n.slice(0,3)}-${n.slice(3,6)}-${n.slice(6)}`}function he(t){const n=new Set(t.map(e=>(e||"").toUpperCase().replace("#",""))),o=new Set(["000000","FFFFFF"]),a=[],i="function"==typeof getThemeColor?getThemeColor:"function"==typeof window.getThemeColor?window.getThemeColor:null;if(i&&void 0!==e&&e.theme){const e=i("accent");e&&a.push(e);const t=i("info");t&&a.push(t);const n=i("special");n&&a.push(n)}const r=[...a,...z];for(const e of r){const t=e.replace("#","").toUpperCase();if(!n.has(t)&&!o.has(t))return e}let d,l;do{let e=0;if("undefined"!=typeof crypto&&crypto.getRandomValues){const t=new Uint32Array(1);crypto.getRandomValues(t),e=t[0]/4294967296}else e=Math.random();d="#"+Math.floor(16777215*e).toString(16).padStart(6,"0").toUpperCase(),l=d.replace("#","")}while(n.has(l)||o.has(l));return d}async function xe(t){if(!t)return;let n=(t.first||"").trim(),o=(t.last||"").trim();const a=/[^A-Za-zÀ-ÖØ-öø-ÿ' -]/g;n=ye(l(n,50).replace(a,"").trim()),o=ye(l(o,50).replace(a,"").trim());const i=l(t.email||"",100).toLowerCase(),r=ve(l(t.phone||"")||"")||"",s={first:n,last:o,email:i,phone:r,isInvalid:!n,isDuplicate:re(n,o)};if(s.isInvalid||s.isDuplicate||i&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i))return void Me(s,0,null,0,null);const c=he([...(e.contacts||[]).filter(e=>e&&e.id).map(e=>e.color),...(e.groups||[]).map(e=>e.color)].map(e=>(e||"").toUpperCase())),p={id:crypto.randomUUID(),first:n,last:o,email:i,phone:r,venmo:"",cashapp:"",paypal:"",preferredPayment:"",color:c,createdAt:Date.now()};window.commandManager?await window.commandManager.execute(new $e([p])):(e.contacts.push(p),fe(),"function"==typeof window.invalidateContactsMapCache&&window.invalidateContactsMapCache(),"function"==typeof window.invalidateContactsPopupCache&&window.invalidateContactsPopupCache(),"function"==typeof window.refreshContactsPopupLight&&window.refreshContactsPopupLight()),e.contactsPopupOpen&&"function"==typeof window.addCreatedContactToCheck&&(window.addCreatedContactToCheck(p),"function"==typeof window.refreshContactsPopupLight&&window.refreshContactsPopupLight()),"undefined"!=typeof ActionLogger&&ActionLogger.log("CREATE_CONTACT",p),"function"==typeof d&&d(),"function"==typeof window.saveState&&window.saveState(),"function"==typeof window.render&&window.render(),"function"==typeof showContactImportResult&&showContactImportResult({success:!0,title:"Contact imported",message:`${n} ${o}`.trim()+" was imported directly from your mobile device."})}function be(t){e.contactsPopupOpen&&"function"==typeof window.setManageContactsPopupHidden&&window.setManageContactsPopupHidden(!0);const n=s("div",{id:"singleDeviceContactPickerOverlay",className:"modal-overlay 
1sc-modal-viewport-fit",style:(window.modalOverlayStyle||"")+" z-index: 35000;"}),o="function"==typeof getThemeColor?getThemeColor("accent"):"#7678ed",a="function"==typeof window.getTxModalShellStyle?window.getTxModalShellStyle("440px",o):`${window.modalContainerStyle||""} max-width: 440px; padding: 0; overflow: hidden; display: flex; flex-direction: column;`,i=s("div",{className:"sc-tx-dialog sc-modal-panel",style:a}),r=s("div",{style:(window.txModalHeaderStyle||"")+" flex-shrink: 0; padding: 20px 20px 12px; margin-bottom: 0;"}),d=s("h3",{style:window.txModalTitleStyle||"margin:0;"},"Select Contact"),l=s("button",{type:"button","aria-label":"Close",style:"function"==typeof window.getTxModalCloseBtnStyle?window.getTxModalCloseBtnStyle():window.baseBtn||""});c(l),l.addEventListener("click",()=>{n.remove(),e.contactsPopupOpen&&"function"==typeof window.restoreManageContactsPopup&&window.restoreManageContactsPopup()}),r.append(d,l);const p=s("div",{className:"sc-tx-dialog__body",style:"flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 12px;"}),w=s("input",{type:"text",autocomplete:"off",placeholder:"Search mobile device contacts...",style:window.inputStyle||"border: 1.5px solid var(--glass-border); border-radius: 20px; padding: 10px 14px; font-size: 15px; font-weight: 600; outline: none; width: 100%; box-sizing: border-box; background: var(--glass-button-bg); color: var(--text-primary);"});p.appendChild(w);const g=s("div",{style:"display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto;"}),m=(e="")=>{g.innerHTML="";const a=e.toLowerCase().trim(),i=(t||[]).filter(e=>{if(!a)return!0;return`${e.first||""} ${e.last||""}`.toLowerCase().includes(a)||e.email&&e.email.toLowerCase().includes(a)||e.phone&&e.phone.includes(a)});if(0===i.length){const e=s("div",{style:"text-align: center; padding: 20px; color: var(--text-secondary); font-size: 14px; font-weight: 600;"},"No contacts found.");return void g.appendChild(e)}i.forEach(e=>{const t=`${e.first||""} ${e.last||""}`.trim()||"Unknown",a=s("div",{style:"display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 18px; border: 1.5px solid var(--glass-border); background: var(--glass-button-bg); cursor: pointer; transition: all 0.2s ease;"}),i=s("div",{style:"display: flex; align-items: center; gap: 10px; min-width: 0;"}),r=`${(e.first||"C")[0]||""}${(e.last||"")[0]||""}`.toUpperCase(),d=s("div",{style:"width: 36px; height: 36px; border-radius: 50%; background: "+o+"; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex-shrink: 0;"},r),l=s("div",{style:"display: flex; flex-direction: column; min-width: 0;"}),c=s("span",{style:"font-weight: 800; font-size: 14px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"},t),p=s("span",{style:"font-size: 11px; font-weight: 600; color: var(--text-secondary);"},e.phone||e.email||"No details");l.append(c,p),i.append(d,l);const u=s("span",{style:"function"==typeof window.getGlassyTintedButtonStyle?window.getGlassyTintedButtonStyle(o)+" font-size: 12px; padding: 4px 10px; border-radius: 12px;":""},"Import");a.append(i,u),a.addEventListener("click",()=>{n.remove(),xe(e)}),g.appendChild(a)})};w.addEventListener("input",e=>m(e.target.value)),m(),p.appendChild(g),i.append(r,p),n.appendChild(i),n.dataset.scModalBody="1";("function"==typeof u?u():document.body).appendChild(n),"function"==typeof window.bindModalViewportFit&&window.bindModalViewportFit(n,i,{reservedTop:16,reservedBottom:24})}function Ce(){Me({first:"",last:"",email:"",phone:""},-1,null,0,null)}async function ke(t={}){var n,o;const a=!0===(null==t?void 0:t.single);if(null==(o=null==(n=window.Capacitor)?void 0:n.isNativePlatform)?void 0:o.call(n)){const t="function"==typeof checkAndRequestPermission?checkAndRequestPermission:window.checkAndRequestPermission;if(!(!t||await t("contacts")))return;try{const{Contacts:t}=await B(async()=>{const{Contacts:e}=await import("./vendor-core-PeJPZ6eL.js").then(e=>e.B);return{Contacts:e}},[]),n=await t.getContacts({projection:{name:!0,phones:!0,emails:!0}}),o=(null==n?void 0:n.contacts)||[],i=(new Set((e.contacts||[]).filter(e=>e&&e.id).map(e=>`${(e.first||"").trim()} ${(e.last||"").trim()}`.trim().toLowerCase())),[]);
1return o.forEach(e=>{var t,n,o,a,r,d;let l=((null==(t=e.name)?void 0:t.given)||e.givenName||"").trim(),s=((null==(n=e.name)?void 0:n.family)||e.familyName||"").trim();if(!l&&!s&&((null==(o=e.name)?void 0:o.display)||e.displayName)){const t=((null==(a=e.name)?void 0:a.display)||e.displayName).trim().split(/\s+/);l=t[0]||"",s=t.slice(1).join(" ")||""}const c=/[^A-Za-zÀ-ÖØ-öø-ÿ' -]/g,p=ye(l.replace(c,"").trim()),u=ye(s.replace(c,"").trim());if(!p)return;const w=Array.isArray(e.emails)&&e.emails.length>0?"string"==typeof e.emails[0]?e.emails[0]:(null==(r=e.emails[0])?void 0:r.address)||"":"",g=Array.isArray(e.phones)&&e.phones.length>0?"string"==typeof e.phones[0]?e.phones[0]:(null==(d=e.phones[0])?void 0:d.number)||"":"";i.push({first:p,last:u,email:w?w.toLowerCase().trim():"",phone:g&&ve(g)||""})}),0===i.length?void Se():a?void be(i):void(await Be(i.map(e=>({...e,selected:!0,isInvalid:!1,isDuplicate:re(e.first,e.last)}))))}catch(i){return console.error("Native contact retrieval failed:",i),void Se()}}if(!("undefined"!=typeof navigator&&"contacts"in navigator&&"select"in navigator.contacts))return a?void Ce():void Se();try{const t=["name","email","tel"],n=await navigator.contacts.select(t,{multiple:!a});if(!(null==n?void 0:n.length))return;if(a){const e=n[0],t=e.name&&e.name.length>0?e.name[0].trim().split(/\s+/):[],o=t[0]||"",a=t.slice(1).join(" ")||"",i=/[^A-Za-zÀ-ÖØ-öø-ÿ' -]/g,r=ye(o.replace(i,"").trim()),d=ye(a.replace(i,"").trim());return void(await xe({first:r,last:d,email:e.email&&e.email.length>0?e.email[0].toLowerCase():"",phone:e.tel&&e.tel.length>0&&ve(e.tel[0])||""}))}const o=[];if(n.forEach(e=>{const t=e.name&&e.name.length>0?e.name[0].trim().split(/\s+/):[],n=t[0]||"",a=t.slice(1).join(" ")||"",i=/[^A-Za-zÀ-ÖØ-öø-ÿ' -]/g,r=ye(n.replace(i,"").trim()),d=ye(a.replace(i,"").trim());r&&o.push({first:r,last:d,email:e.email&&e.email.length>0?e.email[0].toLowerCase():"",phone:e.tel&&e.tel.length>0&&ve(e.tel[0])||"",selected:!0,isInvalid:!1,isDuplicate:re(r,d)})}),0===o.length)return"function"==typeof customAlert&&customAlert("No valid contacts were selected."),void(e.contactsPopupOpen&&"function"==typeof window.restoreManage
1ContactsPopup&&window.restoreManageContactsPopup());await Be(o)}catch(i){console.error("Device contact picker failed:",i),a?Ce():Se()}}function Se(t={}){e.contactsPopupOpen&&"function"==typeof window.setManageContactsPopupHidden&&window.setManageContactsPopupHidden(!0);const n=s("div",{id:t.id||"importModalOverlay",className:"modal-overlay sc-modal-viewport-fit",style:window.modalOverlayStyle}),o=s("div",{style:window.modalContainerStyle}),a=s("div",{style:window.modalHeaderStyle}),i=s("h3",{style:window.modalTitleStyle},"Bulk Import Contacts"),r=s("button",{style:window.modalCloseBtnStyle,"aria-label":"Close"});c(r),r.addEventListener("click",()=>{n.remove(),e.contactsPopupOpen&&"function"==typeof window.restoreManageContactsPopup&&window.restoreManageContactsPopup()}),a.appendChild(i),a.appendChild(r);const d=s("div",{style:"flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px;"}),p=s("p",{style:"margin: 0; font-size: 14px; color: var(--text-secondary); line-height: 1.4;"},'Paste a list of contacts below. Supported formats: "Name, Email, Phone" or "Name <email>". One contact per line.'),w=s("textarea",{placeholder:"John Doe, [email protected], 123-456-7890\nJane Smith <[email protected]>",style:window.baseInput+" min-height: 200px; font-family: monospace; resize: vertical; border-radius: 16px;"});d.appendChild(p),d.appendChild(w);const g=s("div",{style:"padding: 16px; border-top: 1px solid rgba(255, 255, 255, 0.25); background: var(--glass-button-bg); backdrop-filter: var(--glass-blur); display: flex; gap: 12px;"}),m=s("button",{style:window.baseBtn+" flex: 1; background: var(--card-bg);"},"Cancel");m.addEventListener("click",()=>n.remove());const f="function"==typeof getThemeColor?getThemeColor("info"):"#3b82f6",y="function"==typeof getAutoTextColor?getAutoTextColor("var(--accent-text)",f):"var(--accent-text)",v=s("button",{style:window.baseBtn+" flex: 1; background: "+f+"; color: "+y+";"},"Analyze List");v.addEventListener("click",()=>{const t=w.value.trim();if(!t)return customAlert("Please enter some contact data first.");const o=function(t){const n=t.split(/\r?\n/).filter(e=>e.trim().length>0),o=[],a=/[^A-Za-zÀ-ÖØ-öø-ÿ' -]/g,i=new Set((e.contacts||[]).filter(e=>e&&e.id).map(e=>`${(e.first||"").trim()} ${(e.last||"").trim()}`.trim().toLowerCase()));return n.forEach(e=>{let t=null,n=null,r=l(e,200);const d=e.match(/<([^>]+)>/);d&&(t=d[1].trim().toLowerCase(),r=e.replace(d[0],"").trim());let s=r.split(/[,;\t]/).map(e=>e.trim());s.length>1&&(r=s[0],s.slice(1).forEach(e=>{if(!t&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))t=e.toLowerCase();else if(!n){const t=ve(e);t&&(n=t)}}));let c=r.split(/\s+/).filter(e=>e.length>0),p=c[0]||"",u=c.slice(1).join(" ")||"";const w=p.replace(a,"").trim(),g=u.replace(a,"").trim(),m=`${w} ${g}`.trim().toLowerCase(),f=i.has(m);!f&&m&&i.add(m);const y=!w;o.push({first:ye(w),last:ye(g),email:t?l(t,100):"",phone:n?l(n,20):"",isDuplicate:f,isInvalid:y,originalLine:l(e,200)})}),o}(t);!function(e,t){const n=t.querySelector('div[style*="max-width: 480px"]'),o=n.querySelector('div[style*="flex: 1"]'),a=n.querySelector('div[style*="padding: 16px; border-top"]'),i=n.querySelector("h3");i&&(i.textContent="Review Contacts ("+e.length+")");o.textContent="",a.textContent="";const r=s("div",{style:"display: flex; flex-direction: column; gap: 12px;"});e.forEach((e,t)=>{const n=s("div",{style:`padding: 12px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.3); background: ${e.isInvalid?"var(--error-bg)":e.isDuplicate?"var(--warning-bg)":"var(--card-bg)"}; display: flex; align-items: center; gap: 12px;`}),o=s("input",{type:"checkbox",style:"width: 20px; height: 20px; cursor: pointer;"});o.checked=!e.isDuplicate&&!e.isInvalid,e.selected=o.checked,o.addEventListener("change",()=>e.selected=o.checked);const a=s("div",{style:"flex: 1; display: flex; flex-direction: column; gap: 4px;"}),i=s("div",{style:"display: flex; gap: 8px;"}),d=s("input",{value:e.first,style:window.baseInput+" height: 28px; padding: 4px 8px; font-size: 14px;",placeholder:"First Name"}),l=s("input",{value:e.last,style:window.baseInput+" height: 28px; padding: 4px 8px; font-size: 14px;",placeholder:"Last Name"}
1),c=/[^A-Za-zÀ-ÖØ-öø-ÿ' -]/g,p=()=>{e.first=d.value.replace(c,"").trim(),e.last=l.value.replace(c,"").trim(),e.isInvalid=!e.first||!e.last,n.style.background=e.isInvalid?"var(--error-bg)":e.isDuplicate?"var(--warning-bg)":"var(--card-bg)"};d.addEventListener("input",p),l.addEventListener("input",p),i.appendChild(d),i.appendChild(l);const u=s("div",{style:"font-size: 12px; color: var(--text-secondary); display: flex; gap: 8px;"});if(e.email&&u.appendChild(s("span",{},e.email)),e.phone&&u.appendChild(s("span",{},e.phone)),a.appendChild(i),a.appendChild(u),e.isDuplicate||e.isInvalid){const t=s("span",{style:`font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 8px; text-transform: uppercase; background: ${e.isInvalid?"var(--error-color)":"var(--warning-color)"}; color: ${"function"==typeof getAutoTextColor?getAutoTextColor("var(--accent-text)",e.isInvalid?"var(--error-color)":"var(--warning-color)"):"var(--accent-text)"};`},e.isInvalid?"Invalid Name":"Duplicate");a.appendChild(t)}n.appendChild(o),n.appendChild(a),r.appendChild(n)}),o.appendChild(r);const d=s("button",{style:window.baseBtn+" flex: 1; background: var(--card-bg); font-size: 13px; padding: 8px;"},"Select All");d.addEventListener("click",()=>{o.querySelectorAll('input[type="checkbox"]').forEach(e=>e.checked=!0),e.forEach(e=>e.selected=!0)});const l=s("button",{style:window.baseBtn+" flex: 1; background: var(--card-bg); font-size: 13px; padding: 8px;"},"Deselect All");l.addEventListener("click",()=>{o.querySelectorAll('input[type="checkbox"]').forEach(e=>e.checked=!1),e.forEach(e=>e.selected=!1)});const c=s("button",{style:window.baseBtn+" flex: 1; background: var(--card-bg);"},"Back");c.addEventListener("click",()=>Se());const p=getThemeColor("info"),u="function"==typeof getAutoTextColor?getAutoTextColor("var(--accent-text)",p):"var(--accent-text)",w=s("button",{style:window.baseBtn+" flex: 2; background: "+p+"; color: "+u+";"},"Import Selected");w.addEventListener("click",()=>{const n=e.filter(e=>e.selected);return 0===n.length?customAlert("Please select at least one contact to import."):n.some(e=>e.isInvalid)?customAlert("Some selected contacts have invalid names. Please fix them before importing."):void Be(n,t)});const g=s("div",{style:"display: flex; gap: 8px; width: 100%; margin-bottom: 8px;"});g.appendChild(d),g.appendChild(l);const m=s("div",{style:"display: flex; gap: 8px; width: 100%;"});m.appendChild(c),m.appendChild(w);const f=s("div",{style:"display: flex; flex-direction: column; width: 100%;"});f.appendChild(g),f.appendChild(m),a.appendChild(f)}(o,n)}),g.appendChild(m),g.appendChild(v),o.appendChild(a),o.appendChild(d),o.appendChild(g),n.appendChild(o),n.dataset.scModalBody="1",u().appendChild(n),"function"==typeof window.bindModalViewportFit&&window.bindModalViewportFit(n,o,{reservedTop:16,reservedBottom:24}),w.focus()}async function Be(t,n=null){const o=[],a=[],i=new Set((e.contacts||[]).filter(e=>e&&e.id).map(e=>`${(e.first||"").trim()} ${(e.last||"").trim()}`.trim().toLowerCase())),r=[...(e.contacts||[]).filter(e=>e&&e.id).map(e=>e.color),...(e.groups||[]).map(e=>e.color)];t.forEach(e=>{const t=/[^A-Za-zÀ-ÖØ-öø-ÿ' -]/g,n=ye(l(e.first||"",50).replace(t,"").trim()),d=ye(l(e.last||"",50).replace(t,"").trim()),s=l(e.email||"",100).toLowerCase(),c=ve(l(e.phone||"")||"");if(!n)return void a.push({...e,reason:"First name required"});const p=`${n} ${d}`.trim().toLowerCase();if(i.has(p))return void a.push({...e,reason:"Duplicate name"});if(s&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s))return void a.push({...e,reason:"Invalid email"});const u=he(r.map(e=>(e||"").toUpperCase())),w={id:crypto.randomUUID(),first:n,last:d,email:s,phone:c||"",venmo:"",cashapp:"",paypal:"",preferredPayment:"",color:u,createdAt:Date.now()};o.push(w),i.add(p),r.push(u)}),o.length>0&&(window.commandManager?await window.commandManager.execute(new $e(o)):(e.contacts.push(...o),fe(),"function"==typeof window.invalidateContactsMapCache&&window.invalidateContactsMapCache(),"function"==typeof window.invalidateContactsPopupCache&&window.invalidateContactsPopupCache(),"function"==typeof window.refreshContactsPopupLight&&window.refreshContactsPopupLight()),"undefined"!=typeof ActionLogger&&o.forEach(e
1=>ActionLogger.log("CREATE_CONTACT",e))),n&&n.remove(),Pe(o.length,a),"function"==typeof d&&d(),"function"==typeof window.render&&window.render()}function Pe(e,t){const n=s("div",{id:"importModalOverlay",className:"modal-overlay",style:window.modalOverlayStyle}),o=s("div",{style:window.modalContainerStyle+" max-width: 480px;"}),a=s("div",{style:window.modalHeaderStyle}),r=s("h3",{style:window.modalTitleStyle},"Import Results"),d=s("button",{style:window.modalCloseBtnStyle,"aria-label":"Close"});c(d),d.addEventListener("click",()=>n.remove()),a.appendChild(r),a.appendChild(d);const l=s("div",{style:"flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px;"}),w=s("div",{style:"background: var(--glass-button-bg); padding: 16px; border-radius: 20px; border: 1.5px solid var(--glass-border);"}),g=s("div",{style:"font-weight: bold; font-size: 18px; margin-bottom: 8px;"},"Import Summary"),m=s("div",{style:"color: var(--success-text); font-weight: bold; display:flex; align-items:center; gap:6px;"});m.appendChild(p("check",{width:"1em",height:"1em"})),m.appendChild(document.createTextNode(` Success: ${e}`));const f=s("div",{style:`color: ${t.length>0?"var(--error-text)":"var(--text-secondary)"}; font-weight: bold; display:flex; align-items:center; gap:6px;`});if(f.appendChild(p("error",{width:"1em",height:"1em"})),f.appendChild(document.createTextNode(` Failed: ${t.length}`)),w.appendChild(g),w.appendChild(m),w.appendChild(f),l.appendChild(w),t.length>0){const o=s("div",{style:"display: flex; flex-direction: column; gap: 10px;"}),a=s("div",{style:"font-weight: bold; font-size: 14px; text-transform: uppercase; color: var(--text-secondary);"},"Contacts requiring correction:");o.appendChild(a),t.forEach((a,r)=>{const d=s("div",{style:"padding: 12px; border-radius: 16px; border: 1.5px solid var(--error-color); background: var(--error-bg); display: flex; justify-content: space-between; align-items: center;"}),l=s("div",{style:"flex: 1;"}),c=s("div",{style:"font-weight: bold; font-size: 15px;"},`${i(a.first)} ${i(a.last)}`),p=s("div",{style:"font-size: 12px; color: var(--error-text);"},i(a.reason));l.appendChild(c),l.appendChild(p);const u=s("button",{style:window.baseBtn+" padding: 6px 12px; font-size: 13px;"},"Edit");u.addEventListener("click",()=>Me(a,r,t,e,n)),d.appendChild(l),d.appendChild(u),o.appendChild(d)}),l.appendChild(o)}const y=s("div",{style:"padding: 16px; border-top: 1.5px solid var(--glass-border); background: var(--glass-button-bg); backdrop-filter: var(--glass-blur); display: flex; justify-content: center;"}),v="function"==typeof getThemeColor?getThemeColor("accent"):"#7678ed",h="function"==typeof window.getGlassyTintedStyle?window.getGlassyTintedStyle(v):"",x=s("button",{style:`${window.baseBtn||""} min-width: 120px; ${h} color: var(--text-primary);`},"Done");x.addEventListener("click",()=>n.remove()),y.appendChild(x),o.appendChild(a),o.appendChild(l),o.appendChild(y),n.appendChild(o),n.dataset.scModalBody="1",u().appendChild(n)}function Me(t,n,o,a,i,r={}){e.contactsPopupOpen&&"function"==typeof window.setManageContactsPopupHidden&&window.setManageContactsPopupHidden(!0);const w=s("div",{id:r.id||"importModalOverlay",className:"modal-overlay sc-modal-viewport-fit",style:(window.modalOverlayStyle||"")+" z-index: 40000;"}),g=()=>{w.remove(),e.contactsPopupOpen&&"function"==typeof window.restoreManage
1ContactsPopup&&window.restoreManageContactsPopup()},m="function"==typeof getThemeColor?getThemeColor("accent"):"#7678ed",f="function"==typeof window.getTxModalShellStyle?window.getTxModalShellStyle("440px",m):`${window.modalContainerStyle||""} max-width: 440px; padding: 0; overflow: hidden; display: flex; flex-direction: column;`,y=s("div",{className:"sc-tx-dialog sc-modal-panel",style:f}),v=s("div",{style:(window.txModalHeaderStyle||"")+" flex-shrink: 0; padding: 20px 20px 12px; margin-bottom: 0;"}),h=s("h3",{style:window.txModalTitleStyle||"margin:0;"},"Correct Contact"),x=s("button",{type:"button","aria-label":"Close",style:"function"==typeof window.getTxModalCloseBtnStyle?window.getTxModalCloseBtnStyle():window.baseBtn||""});c(x),x.addEventListener("click",g),v.append(h,x);const b=s("div",{className:"sc-tx-dialog__body","data-modal-scroll":"",style:(window.txModalBodyStyle||"")+" flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 14px; text-align: left;"}),C=s("div",{style:`display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 20px; background: color-mix(in srgb, var(--card-bg), ${m} 15%); border: 1.5px solid color-mix(in srgb, transparent, ${m} 30%); box-shadow: var(--glass-shadow);`}),k=s("div",{style:`width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--card-bg), ${m} 30%); border: 1.5px solid color-mix(in srgb, transparent, ${m} 50%); flex-shrink: 0;`});k.appendChild(p("warning",{width:"22px",height:"22px",color:m,strokeWidth:"2.5"}));const S=s("div",{style:"font-size: 13px; font-weight: 700; color: var(--text-primary); line-height: 1.35;"},"Adjust contact details to complete importing into your directory.");C.append(k,S),b.appendChild(C);const B=(e,t,n,o="")=>{const a=s("div"),i=s("label",{style:window.labelStyle||"display: block; font-weight: 700; font-size: 12px; margin-bottom: 6px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px;"},e),r=s("input",{id:n,value:t,placeholder:o,autocomplete:"off",style:window.inputStyle||"border: 1.5px solid var(--glass-border); border-radius: 20px; padding: 10px 14px; font-size: 15px; font-weight: 600; outline: none; width: 100%; box-sizing: border-box; background: var(--glass-button-bg); color: var(--text-primary); backdrop-filter: blur(5px);"});return a.appendChild(i),a.appendChild(r),a},P=B("FIRST NAME",t.first,"corr_fn","Required"),M=B("LAST NAME",t.last,"corr_ln","Optional"),$=B("EMAIL",t.email,"corr_e","[email protected]"),I=B("PHONE",t.phone,"corr_p","555-555-5555");b.appendChild(P),b.appendChild(M),b.appendChild($),b.appendChild(I);const E=s("div",{style:(window.txModalFooterStyle||"")+" flex-shrink: 0; padding: 14px 20px 20px; margin-top: 0; display: flex; gap: 10px;"}),A=s("button",{type:"button",style:("function"==typeof window.getTxModalSecondaryBtnStyle?window.getTxModalSecondaryBtnStyle():window.baseBtn||"")+" flex: 1; min-height: 48px;"},"Cancel");A.addEventListener("click",g);const T=s("button",{type:"button",style:("function"==typeof window.getTxModalPrimaryBtnStyle?window.getTxModalPrimaryBtnStyle(m):window.baseBtn||"")+" flex: 1.5; min-height: 48px; gap: 6px;"});T.appendChild(document.createTextNode("Save Contact ")),T.appendChild(p("check",{width:"1em",height:"1em"})),T.addEventListener("click",async()=>{const t=b.querySelector("#corr_fn"),r=b.querySelector("#corr_ln"),s=b.querySelector("#corr_e"),c=b.querySelector("#corr_p"),p=/[^A-Za-zÀ-ÖØ-öø-ÿ' -]/g,u=ye(l(t.value,50).replace(p,"").trim()),g=ye(l(r.value,50).replace(p,"").trim()),m=l(s.value,100).toLowerCase(),f=c.value.trim(),y=f?ve(l(f,20)):"";let v=!1;[t,r].forEach(e=>{e.value.trim()||(e.classList.add("shake"),setTimeout(()=>e.classList.remove("shake"),500),v=!0)}),m&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(m)&&(s.classList.add("shake"),setTimeout(()=>s.classList.remove("shake"),500),v=!0),f&&!y&&(c.classList.add("shake"),setTimeout(()=>c.classList.remove("shake"),500),v=!0);const h=new Set((e.contacts||[]).filter(e=>e&&e.id).map(e=>`${(e.first||"").trim()} ${(e.last||"").trim()}`.trim().toLowerCase())),x=`${u} ${g}`.trim().toLowerCase();if(h.has(x)&&(t.classList.add("shake"),r.classList.add("shake"),setTimeout(()=>{t.classList.remove("shake"),r.classList.remove("shake")},500),v=!0),v)return;const C=he([...(e.contacts||[]).filter(e=>e&&e.id).map(e=>e.color),...(e.groups||[]).map(e=>e.color)].map(e=>(e||"").toUpperCase())),k={id:crypto.randomUUID(),first:u,last:g,email:m,phone:y||"",venmo:"",cashapp:"",paypal:"",preferredPayment:"",color:C,createdAt:Date.now()};e.contacts.push(k),fe(),Array.isArray(o)&&n>=0&&o.splice(n,1),w.remove(),i&&i.remove(),Array.isArray(o)&&i?Pe(a+1,o):e.contactsPopupOpen&&"function"==typeof window.addCreatedContactToCheck&&(window.addCreatedContactToCheck(k),"function"==typeof window.refreshContactsPopupLight&&window.refreshContactsPopupLight()),"function"==typeof d&&d(),window.render()}),E.appendChild(A),E.appendChild(T),y.append(v,b,E),w.appendChild(y),w.dataset.scModalBody="1";("function"==typeof u?u():document.body).appendChild(w),"function"==typeof window.bindModalViewportFit&&window.bindModalViewportFit(w,y,{reservedTop:16,reservedBottom:24})}window.getAllContactMetrics=Z,window.invalidateContactMetricsCache=K,window.changeContactPage=function(e){j+=e,window.render()},window.updateContactItemsPerPage=function(e){N=parseInt(e,10),j=1,window.render()},window.toggleVisualOptions=()=>{const e=document.getElementById("extendedVisualOptions"),t=document.getElementById("toggleVisualBtn");if(!e||!t)return;const n="none"===e.style.display;e.style.display=n?"flex":"none";const o=t.querySelector("span"),a=t.querySelector("svg");o&&(o.textContent=n?"Show Less":"Show More Options"),a&&(a.style.transform=n?"rotate(180deg)":"rotate(0deg)"),F=n}
1,window.captureModalState=function(){const e={fields:{},groups:[]},t=document.querySelector(".contact-modal-container");if(!t)return e;t.querySelectorAll('input:not([type="checkbox"]):not([type="color"]), input[type="hidden"], select').forEach(t=>{t.id&&(e.fields[t.id]=t.value)});const n=t.querySelector('input[type="color"]');n&&n.id&&(e.fields[n.id]=n.value.toUpperCase());const o=t.querySelectorAll(".contact-group-cb");return e.groups=Array.from(o).filter(e=>e.checked).map(e=>e.dataset.groupId).sort(),e},window.isContactModalDirty=function(){if(!O||!window.modalBaseState||0===Object.keys(window.modalBaseState.fields).length)return!1;const e=window.captureModalState();for(const t in window.modalBaseState.fields)if(String(e.fields[t])!==String(window.modalBaseState.fields[t]))return!0;if(e.groups.length!==window.modalBaseState.groups.length)return!0;for(let t=0;t<e.groups.length;t++)if(e.groups[t]!==window.modalBaseState.groups[t])return!0;return!1},window.getAppliedColor=ie,window.contactDuplicateExists=re,window.getContactFormError=de,window.updateContactSaveBtnState=function(){const e=document.getElementById("contactSaveBtn"),t=document.getElementById("contactFormErrorBanner"),n=document.getElementById("contactFormErrorText"),o=document.getElementById("contactFormErrorIcon"),a=document.getElementById("fn"),i=de(),r=!a||("true"===a.dataset.touched||""!==a.value.trim()||null!==_);t&&n&&(i&&("First name is required."!==i||r)?(n.textContent=i,o&&!o.innerHTML&&(o.innerHTML="function"==typeof window.customEmojiHtml?window.customEmojiHtml("error",{width:"16px",height:"16px"}):"⚠️"),t.style.display="flex"):(t.style.display="none",n.textContent=""));const d=!i;e&&(e.disabled=!d,e.style.opacity=d?"1":"0.5",e.style.pointerEvents=d?"auto":"none")},window.togglePayment=function(e){const t=document.getElementById("prefPayment");if(!t)return;const n=document.getElementById("paymentHandle"),o=document.getElementById("handleLabel"),a=document.getElementById("paymentHandleContainer"),i=document.querySelectorAll(".pay-toggle"),r=document.getElementById("emailHandleContainer"),d=document.getElementById("phoneHandleContainer"),l=document.querySelectorAll(".contact-detail-toggle");if(t.value===e)t.value="",o&&(o.textContent="PAYMENT HANDLE"),a&&(a.style.display="none");else{r&&(r.style.display="none"),d&&(d.style.display="none"),l.forEach(e=>{e.style.border="1.5px solid var(--glass-border)"}),t.value=e;const i={venmo:"VENMO HANDLE",cashapp:"CASH APP ID",paypal:"PAYPAL HANDLE"};o&&(o.textContent=i[e]||"PAYMENT HANDLE");const s=document.getElementById("h_"+e);n&&s&&(n.value=s.value),a&&(a.style.display="block")}i.forEach(e=>{const n=e.dataset.val===t.value;e.style.border=n?"3px solid #00FFFF":"1.5px solid var(--glass-border)"})},window.toggleContactDetail=function(e){const t=document.getElementById("email"===e?"emailHandleContainer":"phoneHandleContainer"),n=document.getElementById("email"===e?"e":"p"),o=document.querySelector(`.contact-detail-toggle[data-val="${e}"]`);if(!t||!n||!o)return;const a=document.getElementById("prefPayment"),i=document.getElementById("paymentHandleContainer"),r=document.querySelectorAll(".pay-toggle");a&&(a.value=""),i&&(i.style.display="none"),r.forEach(e=>{e.style.border="1.5px solid var(--glass-border)"});const d="email"===e?"phone":"email",l=document.getElementById("email"===d?"emailHandleContainer":"phoneHandleContainer"),s=document.querySelector(`.contact-detail-toggle[data-val="${d}"]`);l&&(l.style.display="none"),s&&(s.style.border="1.5px solid var(--glass-border)");"none"!==t.style.display?(t.style.display="none",n.value="",o.style.border="1.5px solid var(--glass-border)"):(t.style.display="block",o.style.border="3px solid #00FFFF",setTimeout(()=>{try{n.focus()}catch(e){}},50)),"function"==typeof window.updateContactSaveBtnState&&window.updateContactSaveBtnState()},window.refreshContactModalPreview=function(){const e=document.getElementById("contactModalProfilePreview");if(!e)return;const t=document.getElementById("c"),n=document.getElementById("hiddenAvatarImage"),o=t?t.value:"#7678ed",a=n?n.value:"None",i=a&&"None"!==a?a.replace(/['"()]/g,""):null;let r=`background: ${o};`;r+=i?` background-image: url('${w(i)||`avatars/${i}`}'); background-size: cover; background-position: center;`:" background-image: none;",e.style.cssText=`position: relative; width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--glass-border); flex-shrink: 0; box-sizing: border-box; overflow: visible; box-shadow: var(--glass-shadow), 0 4px 12px rgba(0,0,0,0.1); ${r}`,e.innerHTML=""},window.refreshContactAppearanceBarPreview=function(){g()},window.refreshContactAppearanceAvatarSample=function(){m()},window.openContactAppearanceModal=pe,window.updateHiddenHandle=function(e){const t=document.getElementById("prefPayment").value;t&&(document.getElementById("h_"+t).value=e)},window.openOverlaySelectionModal=function(e,t,n,o){var a;null==(a=document.getElementById("overlaySelectionOverlay"))||a.remove();const r=document.getElementById(e),d=r?r.value:"#7678ed",l=t?document.getElementById(t):null,s=l?parseInt(l.value):-1,c=document.getElementById(n),p=c?c.value:"None";let w=["None","Pumpkins.svg","Clovers.svg","Spades.svg","Hearts.svg","Clubs.svg","Diamonds.svg","Snowflakes.svg","Ice_Snowflakes.svg","Flowers.svg","Fireworks.svg","Bats.svg","Bells_Ribbons.svg","Trees_Snowmen.svg","Halloween.svg","Easter.svg"].map(e=>{const t="None"===e,a=e===p,r=t?"None":ye(e.replace(/\.svg$/,"")),l=`\n      <div style="width: 100%; height: 100%; background: ${d}; position: relative; border-radius: 20px; overflow: hidden;">\n        ${s>=0&&"function"==typeof window.generateCustomImage?`\n          <div style="position: absolute; inset: 0;">${window.generateCustomImage(d,s,"100%","100%",!0)}</div>\n        `:""}\n        ${t?"":`\n          <div style="position: absolute; inset: 0; background-image: url('colorOverlays/${e}'); background-size: 100% 100%; background-repeat: no-repeat; opacity: 0.85;"></div>\n        `}\n      </div>\n    `;return`\n      <div onclick="${`document.getElementById('${n}').value = '${e}'; if(document.getElementById('${o}')) document.getElementById('${o}').textContent = '${i(r)}'; if(typeof window.refreshAppearanceBarPreview==='function')window.refreshAppearanceBarPreview(); if(typeof window.refreshContactAppearanceBarPreview==='function')window.refreshContactAppearanceBarPreview(); if(typeof window.refreshContactModalPreview==='function')window.refreshContactModalPreview(); if(typeof window.refreshGroupModalPreview==='function')window.refreshGroupModalPreview(); document.getElementById('overlaySelectionOverlay').remove();`}" style="\n        display: flex; flex-direction: column; align-items: center; justify-content: center;\n        width: 140px; height: 40px; border: 1.5px solid var(--glass-border); border-radius: 24px; background: var(--card-bg);\n        cursor: pointer; position: relative;\n        ${a?"box-shadow: 0 0 15px color-mix(in srgb, var(--text-primary), transparent 40%); border-color: var(--text-primary); border-width: 2.5px;":""}\n      ">\n        ${l}\n      </div>\n    `}).join("");const g=`\n    <div id="overlaySelectionOverlay" class="modal-overlay" data-sc-modal-body="1" onclick="this.remove()" style="position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 60001; padding: 12px; box-sizing: border-box; backdrop-filter: blur(3px);">\n      <div onclick="event.stopPropagation()" style="position: relative; background: var(--glass-button-bg); backdrop-filter: var(--glass-blur); border: 1.5px solid var(--glass-border); border-radius: 24px; width: 100%; max-width: 500px; max-height: 80vh; box-shadow: 0 8px 32px rgba(31, 38, 135, 0.1); display: flex; flex-direction: column; overflow: hidden;">\n        <div style="display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1.5px solid var(--glass-border); background: var(--card-bg); flex-shrink: 0;">\n          <h3 style="margin: 0; font-size: 18px;">Select an Overlay</h3>\n          <button aria-label="Close" onclick="document.getElementById('overlaySelectionOverlay').remove()" style="${window.baseBtn} ${void 0!==window.modalCloseBtnStyle?window.modalCloseBtnStyle:"position:absolute; top:12px; right:12px;"}">${window.closeIconHtml()}</button>\n        </div>\n        <div style="padding: 16px; overflow-y: auto;">\n          <div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); justify-items: center; gap: 12px;">\n            ${w}\n          </div>\n        </div>\n      </div>\n    </div>\n  `;u().insertAdjacentHTML("beforeend",g),"function"==typeof window.mountCustomImages&&window.mountCustomImages()},window.openAnimationSelectionModal=function(e,t,n,o){var a;null==(a=document.getElementById("animationSelectionOverlay"))||a.remove();const r=["Water","Chocolate","Sand","Slime","Syrup","Energy","Fire"],d=[2,8,18],l=[{id:"-1",name:"Solid"}],s=[7,9,10,12,14,17,19,20,21,22,23,24,25,26,27,28,29];for(let i=0;i<30;i++)s.includes(i)||l.push({id:i.toString(),name:d.includes(i)?"Beam":r[i%r.length]});const c=document.getElementById(e),p=c?c.value:"#7678ed",w=t?document.getElementById(t):null,g=w&&"None"!==w.value?w.value:null,m=document.getElementById(n),f=m?m.value:"-1";let y=l.map(e=>{const t=e.id===f,a="-1"===e.id,r=`\n      <div style="width: 100%; height: 100%; background: ${p}; position: relative; border-radius: 20px; overflow: hidden;">\n        ${a||"function"!=typeof window.generateCustomImage?"":`\n          <div style="position: absolute; inset: 0;">${window.generateCustomImage(p,parseInt(e.id),"100%","100%",!0)}</div>\n        `}\n        ${g?`\n          <div style="position: absolute; inset: 0; background-image: url('colorOverlays/${g}'); background-size: 100% 100%; background-repeat: no-repeat; opacity: 0.85;"></div>\n        `:""}\n      </div>\n    `;return`\n      <div onclick="${`document.getElementById('${n}').value = '${e.id}'; if(document.getElementById('${o}')) document.getElementById('${o}').textContent = '${i(e.name)}'; if(typeof window.refreshAppearanceBarPreview==='function')window.refreshAppearanceBarPreview(); if(typeof window.refreshContactAppearanceBarPreview==='function')window.refreshContactAppearanceBarPreview(); if(typeof window.refreshContactModalPreview==='function')window.refreshContactModalPreview(); if(typeof window.refreshGroupModalPreview==='function')window.refreshGroupModalPreview(); document.getElementById('animationSelectionOverlay').remove();`}" style="\n        display: flex; flex-direction: column; align-items: center; justify-content: center;\n        width: 140px; height: 40px; border: 1.5px solid var(--glass-border); border-radius: 24px; background: var(--card-bg);\n        cursor: pointer; position: relative;\n        ${t?"box-shadow: 0 0 15px color-mix(in srgb, var(--text-primary), transparent 40%); border-color: var(--text-primary); border-width: 2.5px;":""}\n      ">\n        ${r}\n      </div>\n    `}).join("");const v=`\n    <div id="animationSelectionOverlay" class="modal-overlay" data-sc-modal-body="1" onclick="this.remove()" style="position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 60001; padding: 12px; box-sizing: border-box; backdrop-filter: blur(3px);">\n      <div onclick="event.stopPropagation()" style="position: relative; background: var(--glass-button-bg); backdrop-filter: var(--glass-blur); border: 1.5px solid var(--glass-border); border-radius: 24px; width: 100%; max-width: 500px; max-height: 80vh; box-shadow: 0 8px 32px rgba(31, 38, 135, 0.1); display: flex; flex-direction: column; overflow: hidden;">\n        <div style="display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1.5px solid var(--glass-border); background: var(--card-bg); flex-shrink: 0;">\n          <h3 style="margin: 0; font-size: 18px;">Select an Animation</h3>\n          <button aria-label="Close" onclick="document.getElementById('animationSelectionOverlay').remove()" style="${window.baseBtn} ${void 0!==window.modalCloseBtnStyle?window.modalCloseBtnStyle:"position:absolute; top:12px; right:12px;"}">${window.closeIconHtml()}</button>\n        </div>\n        <div style="padding: 16px; overflow-y: auto;">\n          <div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); justify-items: center; gap: 12px;">\n            ${y}\n          </div>\n        </div>\n      </div>\n    </div>\n  `;u().insertAdjacentHTML("beforeend",v),"function"==typeof window.mountCustomImages&&window.mountCustomImages()},window.openAvatarSelectionModal=function(e,t,n,o){var a;null==(a=document.getElementById("avatarSelectionOverlay"))||a.remove();const i=document.getElementById(e),r=i?i.value:"var(--text-secondary)",d=t?document.getElementById(t):null;d&&"Default"!==d.value&&d.value;const l=document.getElementById(n),p=l?l.value:"None",g="function"==typeof isPremium&&isPremium(),m=s("div",{id:"avatarSelectionOverlay",className:"modal-overlay",style:"position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 60000; padding: 12px; box-sizing: border-box; backdrop-filter: blur(3px);"}),y=s("div",{className:"modal-container",style:"position: relative; background: var(--glass-button-bg); backdrop-filter: var(--glass-blur); border: 1.5px solid var(--glass-border); border-radius: 24px; width: 100%; max-width: 500px; max-height: 80vh; box-shadow: 0 8px 32px rgba(31, 38, 135, 0.1); display: flex; flex-direction: column; overflow: hidden;"}),v=s("div",{style:"display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1.5px solid var(--glass-border); background: var(--card-bg); flex-shrink: 0;"});v.appendChild(s("h3",{style:"margin: 0; font-size: 18px;"},"Select an Avatar"));const h=s("button",{"aria-label":"Close",style:(window.baseBtn||"")+(void 0!==window.modalCloseBtnStyle?window.modalCloseBtnStyle:"position:absolute; top:12px; right:12px;")});c(h),h.addEventListener("click",()=>m.remove()),v.appendChild(h);const x=s("div",{style:"padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 24px;"}),b=(e,t)=>{const a="None"===e,i=!a&&!g,d=s("div",{className:"avatar-option",style:`display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px; border: 1.5px solid var(--glass-border); border-radius: 24px; background: var(--card-bg); cursor: pointer; position: relative; height: 110px; width: 100%; box-sizing: border-box; ${i?"opacity: 0.5;":""} ${e===p?"box-shadow: 0 0 15px color-mix(in srgb, var(--text-primary), transparent 40%); border-color: var(--text-primary); border-width: 2.5px;":""}`}),l=s("div",{style:`width: 48px; height: 48px; position: relative; border-radius: 50%; border: 1.5px solid var(--glass-border); box-sizing: border-box; background: ${a?"var(--border-color)":r}; ${a?"":"background-image: url('"+(w(e)||"avatars/"+e)+"'); background-size: cover; background-position: center;"}`});return d.appendChild(l),d.appendChild(s("span",{style:"font-weight: bold; font-size: 12px; text-align: center;"},t)),i&&d.appendChild(s("span",{style:"position: absolute; top: 4px; right: 4px; font-size: 16px;"},"gem")),d.addEventListener("click",()=>
1{i?(m.remove(),"function"==typeof showPremiumModal&&showPremiumModal("Premium Avatars")):(document.getElementById(n)&&(document.getElementById(n).value=e),document.getElementById(o)&&(document.getElementById(o).textContent=t),m.remove(),"function"==typeof window.refreshContactModalPreview&&window.refreshContactModalPreview(),"function"==typeof window.refreshGroupModalPreview&&window.refreshGroupModalPreview(),"function"==typeof window.refreshAppearanceBarPreview&&window.refreshAppearanceBarPreview(),"function"==typeof window.refreshContactAppearanceAvatarSample&&window.refreshContactAppearanceAvatarSample(),"function"==typeof window.refreshAppearanceAvatarSample&&window.refreshAppearanceAvatarSample(),"function"==typeof window.refreshContactAppearanceBarPreview&&window.refreshContactAppearanceBarPreview())}),d},C=s("div"),k=s("div",{style:"display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); justify-items: center; gap: 12px;"});k.appendChild(b("None","None")),C.appendChild(k),x.appendChild(C),[{name:"Milkshakes",files:["avatar9.png","avatar5.png","avatar8.png","avatar6.png","avatar4.png"]},{name:"Mains",files:["avatar19.png","avatar1.png","avatar13.png","avatar15.png","avatar16.png","avatar17.png","avatar23.png"]},{name:"Sides & Salads",files:["avatar21.png","avatar22.png","avatar24.png","avatar18.png","avatar25.png"]},{name:"Sweets & Treats",files:["avatar2.png","avatar26.png","avatar3.png","avatar7.png","avatar10.png","avatar11.png","avatar12.png","avatar14.png","avatar20.png"]}].forEach(e=>{const t=s("div");t.appendChild(s("h4",{style:"margin: 0 0 12px 4px; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary);"},e.name));const n=s("div",{style:"display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); justify-items: center; gap: 12px;"});e.files.forEach(e=>{const t=f[e]||e.replace(".png","");n.appendChild(b(e,t))}),t.appendChild(n),x.appendChild(t)}),y.appendChild(v),y.appendChild(x),m.appendChild(y),m.addEventListener("click",e=>{e.target===m&&m.remove()});("function"==typeof u?u():document.body).appendChild(m)},window.openFrameSelectionModal=function(){},window.contacts=function(){var t,n,o,a;"function"==typeof window.ensureMeContactIntegrity&&window.ensureMeContactIntegrity(),le(),null===document.getElementById("contactSearch")&&(H="",U.group="all",U.oweStatus="all",U.sortBy=(null==(t=e.settings)?void 0:t.contactSortStyle)||"alphaAsc",U.show=!1,j=1),checkFreshMount("contactSearch",U),e.contacts||(e.contacts=[]),e.groups&&e.groups.length;const r=Z(),d=(e.contacts||[]).filter(e=>e&&e.id).map(e=>{const t=r[e.id]||{netBalance:0,checkCount:0};return{...e,netBalance:t.netBalance,checkCount:t.checkCount,createdAt:e.createdAt||0}}),l=H?new RegExp(H.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"i"):null;let s=null;if("all"!==U.group){const t=(window.getMemoizedGroupsMap?window.getMemoizedGroupsMap(e.groups):(e.groups||[]).reduce((e,t)=>(e[t.id]=t,e),{}))[U.group];s=t&&t.members?new Set(t.members):new Set}let c=d.filter(e=>{if(s&&!s.has(e.id))return!1;if("owesMe"===U.oweStatus&&e.netBalance>=-.005)return!1;if("iOweThem"===U.oweStatus&&e.netBalance<=.005)return!1;if("settled"===U.oweStatus&&Math.abs(e.netBalance)>.005)return!1;if(l){if(!(l.test(`${(null==e?void 0:e.first)||""} ${(null==e?void 0:e.last)||""}`)||(null==e?void 0:e.email)&&l.test(e.email)||(null==e?void 0:e.phone)&&e.phone.includes(H)))return!1}return!0});const p=c.map(e=>{let t;switch(U.sortBy){case"alphaAsc":case"alphaDesc":t=`${e.first||""}\0${e.last||""}`,"string"!=typeof t&&(t=String(t));break;case"newest":case"oldest":t=e.createdAt||0;break;case"owesMeMost":case"iOweMost":t=e.netBalance;break;case"checksHigh":case"checksLow":t=e.checkCount;break;default:t=0}return{item:e,sortKey:t}}),u=null==(n=e.settings)?void 0:n.meId;p.sort((e,t)=>{if(u){if(e.item.id===u&&t.item.id!==u)return-1;if(t.item.id===u&&e.item.id!==u)return 1}const n=e.sortKey,o=t.sortKey;let a=0;switch(U.sortBy){case"alphaAsc":a=n.localeCompare(o,void 0,{sensitivity:"base"});break;case"alphaDesc":a=o.localeCompare(n,void 0,{sensitivity:"base"});break;case"newest":case"iOweMost":case"checksHigh":a=o-n;break;case"oldest":case"owesMeMost":case"checksLow":a=n-o}return a}),c=p.map(e=>e.item);const w=Math.ceil(c.length/N);j>w&&w>0&&(j=w);const g=(j-1)*N,m=c.slice(g,g+N),f=[{id:"all",htmlContent:'<span style="font-weight:500;">Any Balance</span>'},{id:"owesMe",htmlContent:'<span style="font-weight:500;">They Owe</span>'},{id:"iOweThem",htmlContent:'<span style="font-weight:500;">They Are Owed</span>'},{id:"settled",htmlContent:'<span style="font-weight:500;">Settled</span>'}],y=[{id:"all",hoverColor:"var(--bg-color)",htmlContent:'<span style="font-weight:500;">All Groups</span>'}];if(e.groups){("function"==typeof getSortedGroups?getSortedGroups([...e.groups]):e.groups).forEac
1h(e=>{const t="function"==typeof i?i((null==e?void 0:e.color)||"#ccc"):(null==e?void 0:e.color)||"#ccc";y.push({id:(null==e?void 0:e.id)||"",hoverColor:`${t}22`,htmlContent:`\n          <div style="display: flex; align-items: center; gap: 8px;">\n            <span style="width: 14px; height: 14px; border-radius: 50%; background: ${t}; border: 1px solid  var(--border-color); flex-shrink: 0;"></span>\n            <span style="font-weight:500;">${"function"==typeof i?i((null==e?void 0:e.name)||"Group"):(null==e?void 0:e.name)||"Group"}</span>\n          </div>\n        `})})}const x={searchInputId:"contactSearch",searchTerm:H,searchPlaceholder:h,onClearSearch:()=>{H="",j=1,window.render()},onToggleFilters:()=>J(),onResetFilters:()=>Q(),showFilters:U.show,dropdowns:[{containerId:"filterSortContainer",label:"Sort By",options:[{id:"alphaAsc",htmlContent:'<span style="font-weight:500;">Name (A-Z)</span>'},{id:"alphaDesc",htmlContent:'<span style="font-weight:500;">Name (Z-A)</span>'},{id:"newest",htmlContent:'<span style="font-weight:500;">Recently Created</span>'},{id:"oldest",htmlContent:'<span style="font-weight:500;">Oldest Created</span>'},{id:"owesMeMost",htmlContent:'<span style="font-weight:500;">Owes Most</span>'},{id:"iOweMost",htmlContent:'<span style="font-weight:500;">Owed Most</span>'},{id:"checksHigh",htmlContent:'<span style="font-weight:500;">Most Checks</span>'},{id:"checksLow",htmlContent:'<span style="font-weight:500;">Least Checks</span>'}],activeId:U.sortBy,onSelect:e=>W("sortBy",e)},{containerId:"filterOweContainer",label:"Owe Status",options:f,activeId:U.oweStatus,onSelect:e=>W("oweStatus",e)},{containerId:"filterGroupContainer",label:"Group Filter",options:y,activeId:U.group,onSelect:e=>W("group",e)}]},b=m.length>0?m.map(t=>{var n;const o=(null==(n=e.settings)?void 0:n.meId)===t.id,a=t.color||"#555";let r,d,l;t.netBalance<-.005?(r=getThemeColor("negative_dark"),getThemeColor("negative_bg"),d=`Owes $${Math.abs(t.netBalance).toFixed(2)}`,l="↑"):t.netBalance>.005?(r=getThemeColor("positive_dark"),getThemeColor("positive_bg"),d=`Owed $${Math.abs(t.netBalance).toFixed(2)}`,l="↓"):(r=getThemeColor("positive_accent"),getThemeColor("positive_bg"),d="Settled",l="check");const s=`${i((null==t?void 0:t.first)||"User")} ${i((null==t?void 0:t.last)||"")}`.trim(),c=s.length<=16?s:`${i((null==t?void 0:t.first)||"User")} ${i((null==t?void 0:t.last)?t.last.charAt(0):"U")}.`,p=parseInt(t.animationPref??-1),u=p>=0?` animation: cs-contact-anim-${p} 2s ease-in-out infinite;`:"";return`\n          <div style="\n            position: relative;\n            display: flex;\n            justify-content: space-between;\n            align-items: center;\n            padding: 0;\n            margin-bottom: 12px;\n            overflow: hidden;\n            ${"function"==typeof window.getGlassyTintedStyle?window.getGlassyTintedStyle(a):`border: 2.5px solid ${i(a)}; background: var(--card-bg);`}\n            border-color: ${i(a)};\n            border-width: 2px;\n          "\n          onmouseenter="if(window.matchMedia('(hover:hover)').matches){this.style.transform='translateY(-2px)'; this.style.boxShadow='var(--glass-shadow), 0 8px 25px color-mix(in srgb, transparent, ${escapeJS(a)} 40%)';}"\n          onmouseleave="if(window.matchMedia('(hover:hover)').matches){this.style.transform='none'; this.style.boxShadow='var(--glass-shadow), 0 4px 15px rgba(0, 0, 0, 0.05), 0 0 15px color-mix(in srgb, transparent, ${escapeJS(a)} 20%)';}else{this.style.transform='none';}"\n          >\n            \x3c!-- Color strip on left --\x3e\n            <div style="\n              width: 8px;\n              align-self: stretch;\n              background: ${a};\n              flex-shrink: 0;\n              ${u}\n            "></div>\n\n            \x3c!-- Color overlay tint behind content --\x3e\n            <div style="\n              position: absolute;\n              inset: 0;\n              left: 8px;\n              background: ${a}0d;\n              pointer-events: none;\n            "></div>\n\n            \x3c!-- Avatar --\x3e\n            <div style="padding: 12px 10px 12px 12px; flex-shrink: 0; position: relative; z-index: 1;">\n              <div id="profileContainer-${t.id}" style="width: 48px; height: 48px; flex-shrink: 0;"></div>\n              ${o?`<div style="position:absolute; bottom:8px; right:6px; background:${a}
1; color:${"function"==typeof getAutoTextColor?getAutoTextColor("var(--accent-text)",a):"var(--accent-text)"}; font-size:8px; font-weight:900; padding:1px 4px; border-radius:4px; letter-spacing:0.3px;">ME</div>`:""}\n            </div>\n\n            \x3c!-- Main content --\x3e\n            <div style="flex: 1; min-width: 0; padding: 12px 8px 12px 0; position: relative; z-index: 1;">\n              \x3c!-- Name Bubble --\x3e\n              <div style="margin-bottom: 6px;">\n                ${"function"==typeof renderContactPill?renderContactPill(t,{showIcon:!0,padding:"4px 12px",fontSize:"15px"}):`<div style="display: inline-flex; align-items: center; background: ${a}; color: #fff; padding: 3px 10px; border-radius: 20px; font-weight: 900;">${c}</div>`}\n              </div>\n\n              \x3c!-- Badges row --\x3e\n              <div style="display: flex; gap: 5px; align-items: center; flex-wrap: wrap;">\n                <span style="\n                  display: inline-flex; align-items: center; gap: 3px;\n                  ${window.getGlassyTintedStyle(r)}\n                  padding: 2px 8px; border-radius: 20px;\n                  color: ${r};\n                  font-size: 11px; font-weight: 900;\n                  text-transform: uppercase; letter-spacing: 0.5px;\n                ">${function(e,t){return"Settled"===e?"Settled":`${t} ${e}`}(d,l)}</span>\n              </div>\n            </div>\n\n            \x3c!-- Action buttons --\x3e\n            <div style="display: flex; gap: 8px; padding: 12px; flex-shrink: 0; position: relative; z-index: 1;">\n              <button class="contact-view-profile-btn" data-id="${escapeJS(t.id)}" style="${window.baseBtn}\n                border: 1.5px solid var(--glass-border);\n                border-radius: 24px;\n                padding: 8px 10px;\n                font-weight: bold;\n                cursor: pointer;\n                background: color-mix(in srgb, transparent, ${i(a)} 15%);\n                color: ${i(a)};\n                box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05), 0 0 15px color-mix(in srgb, transparent, ${i(a)} 25%);\n                font-size: 14px;\n                transition: 0.2s;\n                backdrop-filter: blur(8px);\n                -webkit-backdrop-filter: blur(8px);\n                display: flex; align-items: center; justify-content: center;\n              "\n              title="View Profile">\n                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" style="width:16px;height:16px;"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg>\n              </button>\n              <button class="contact-edit-modal-btn" data-id="${escapeJS(t.id)}" style="${window.baseBtn}\n                border: 1.5px solid var(--glass-border);\n                border-radius: 24px;\n                padding: 8px 10px;\n                font-weight: bold;\n                cursor: pointer;\n                background: color-mix(in srgb, transparent, var(--me-color) 15%);\n                color: var(--text-primary);\n                box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05), 0 0 15px color-mix(in srgb, transparent, var(--me-color) 25%);\n                font-size: 14px;\n                transition: 0.2s;\n                backdrop-filter: blur(8px);\n                -webkit-backdrop-filter: blur(8px);\n                display: flex; align-items: center; justify-content: center;\n              "\n              title="Edit Contact">\n                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" style="width:16px;height:16px;"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg>\n              </button>\n            </div>\n          </div>\n        `}).join(""):H||"all"!==U.group||"all"!==U.oweStatus?`\n        <div style="padding: 40px 0; text-align: center;">\n          ${renderFilterSticker("No matching contacts")}
1\n          <button id="resetContactFiltersBtn" aria-label="Reset filters" title="Reset filters" style="${window.baseBtn} ${G} padding: 10px 18px; margin-top: 16px;">\n            <svg class="nav-icon dash-icon-svg" style="width: 1.1em; height: 1.1em; vertical-align: middle;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="23 4 23 10 17 10"></polyline><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"></path></svg> <span class="button-text">Reset Filters</span>\n          </button>\n        </div>\n      `:renderEmptyState("Your directory is empty.","contacts",`<button id="addFirstContactBtn" style="${window.baseBtn} ${window.getGlassyTintedButtonStyle(getThemeColor("accent"))} padding: 12px 32px; color: var(--text-primary); font-weight: 900; display: flex; align-items: center; justify-content: center;">+ Add First Contact</button>`);let C="";w>1&&(C=`\n      <div class="pagination-bar">\n        <button id="contactsPrevPageBtn" style="${window.baseBtn} ${window.getGlassyTintedButtonStyle("var(--glass-button-bg)")} color: ${window.getAutoTextColor("var(--text-primary)","var(--glass-button-bg)")}; padding: 4px 12px; font-weight: 900; cursor: ${1===j?"not-allowed":"pointer"};" ${1===j?"disabled":""}><svg class="nav-icon dash-icon-svg" style="width: 1em; height: 1em; vertical-align: middle; margin-bottom: 0px;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"></polyline></svg> Prev</button>\n        <span class="page-info" style="font-size: 15px; font-weight: bold; color: var(--text-primary);">Page ${j} of ${w||1}</span>\n        <button id="contactsNextPageBtn" style="${window.baseBtn} ${window.getGlassyTintedButtonStyle("var(--glass-button-bg)")} color: ${window.getAutoTextColor("var(--text-primary)","var(--glass-button-bg)")}; padding: 4px 12px; font-weight: 900; cursor: ${j===w||0===w?"not-allowed":"pointer"};" ${j===w||0===w?"disabled":""}>Next <svg class="nav-icon dash-icon-svg" style="width: 1em; height: 1em; vertical-align: middle; margin-bottom: 0px;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg></button>\n      </div>\n    `),window.Capacitor&&window.Capacitor.isNativePlatform&&window.Capacitor.isNativePlatform()||window.innerWidth;let k=`\n    <div class="page-container" style="font-family: 'Inter', sans-serif;">\n      <div style="display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1.5px solid var(--glass-border); padding-bottom: 12px; margin-bottom: 16px;">\n        <div style="display: flex; align-items: center; gap: 10px;">\n          <h2 style="margin: 0; font-size: 26px;">Directory</h2>\n          <span style="${window.getGlassyTintedStyle(getThemeColor("info"))} background: transparent; padding: 2px 10px; border-radius: 24px; font-size: 18px; font-weight: 900; color: var(--text-primary); border-width: 1.5px;">${c.length}</span>\n        </div>\n        <div style="display: flex; gap: 8px; align-items: center;">\n          <button id="importContactUxBtn" class="import-contact-ux-btn" title="Import Contacts" aria-label="Import Contacts" style="${window.baseBtn} ${window.getGlassyTintedButtonStyle("var(--glass-button-bg)")} padding: 10px 18px; font-size: 15px; color: var(--text-primary); font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; min-height: 44px; border-radius: 22px;">\n            ${"function"==typeof v?v("import",{width:"18px",height:"18px"}):'<svg class="nav-icon dash-icon-svg" style="width: 18px; height: 18px;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>'}
1\n            <span class="import-btn-label">Import from Device</span>\n          </button>\n          <button id="addContactBtn" style="${window.baseBtn} ${window.getGlassyTintedButtonStyle(getThemeColor("accent"))} padding: 10px 22px; font-size: 16px; color: var(--text-primary); font-weight: 900; display: flex; align-items: center; justify-content: center; white-space: nowrap; min-height: 44px;">+ Contact</button>\n        </div>\n      </div>\n      ${renderFilterSection(x)}\n      ${(H||"all"!==U.group||"all"!==U.oweStatus)&&c.length>0?`\n        <div style="margin-bottom: 16px;">\n          <div style="display: flex; flex-wrap: wrap; gap: 8px; align-items: center;">\n            <span style="font-size: 13px; font-weight: bold; text-transform: uppercase; color: var(--text-secondary); letter-spacing: 0.5px;">Active:</span>\n            ${H?renderFilterSticker(`Search: ${H}`):""}\n            ${"all"!==U.group?renderFilterSticker(`Group: ${(null==(o=window.getMemoizedGroupsMap?window.getMemoizedGroupsMap(e.groups)[U.group]:(e.groups||[]).find(e=>e.id===U.group))?void 0:o.name)||"Unknown"}`):""}\n            ${"all"!==U.oweStatus?renderFilterSticker(`Status: ${(null==(a=f.find(e=>e.id===U.oweStatus))?void 0:a.id)||"Filtered"}`):""}\n          </div>\n        </div>\n      `:""}\n      <div id="contacts-list-container">\n        ${b}\n      </div>\n      ${C}\n    </div>\n  `;const S=app.innerHTML!==k;S&&(app.innerHTML=k),O?te({id:"contactModalOverlay"}):(X(),S&&function(){const e=document.getElementById("importContactUxBtn");e&&!e.dataset.scBound&&(e.dataset.scBound="1",e.addEventListener("click",()=>ke()));const t=document.getElementById("addContactBtn");t&&!t.dataset.scBound&&(t.dataset.scBound="1",t.addEventListener("click",()=>oe(null)));const n=document.getElementById("addFirstContactBtn");n&&!n.dataset.scBound&&(n.dataset.scBound="1",n.addEventListener("click",()=>oe(null)));const o=document.getElementById("resetContactFiltersBtn");o&&!o.dataset.scBound&&(o.dataset.scBound="1",o.addEventListener("click",Q));const a=document.getElementById("contactsPrevPageBtn");a&&!a.dataset.scBound&&(a.dataset.scBound="1",a.addEventListener("click",()=>changeContactPage(-1)));const i=document.getElementById("contactsNextPageBtn");i&&!i.dataset.scBound&&(i.dataset.scBound="1",i.addEventListener("click",()=>changeContactPage(1)));const r=document.getElementById("contacts-list-container");r&&"1"!==r.dataset.scDelegated&&(r.dataset.scDelegated="1",r.addEventListener("click",e=>{var t;const n=e.target.closest(".contact-avatar-tap");if(null==(t=null==n?void 0:n.dataset)?void 0:t.contactId)return void openProfile(n.dataset.contactId);const o=e.target.closest(".contact-view-profile-btn");if(o)return void openProfile(o.dataset.id);const a=e.target.closest(".contact-edit-modal-btn");a&&oe(a.dataset.id)}))}()),bindFilterSearchInput(x,H,e=>{H=e,j=1,window.render()}),m.forEach(e=>displayProfilePic(e.id)),U.show&&initFilterDropdowns(x.dropdowns)},window.getContactMetrics=function(e){return Z()[e]||{netBalance:0,checkCount:0}},window.toggleAdvancedFilters=J,window.updateFilters=W,window.resetFilters=Q,window.openContactModal=oe,window.openContactModalForManageContacts=function(){if(!e.contactsPopupOpen)return;ne(null,{returnContext:"contactsPopup"})?"function"==typeof window.setManageContactsPopupHidden&&window.setManageContactsPopupHidden(!0):"function"==typeof window.restoreManage
1ContactsPopup&&window.restoreManageContactsPopup()},window.mountStandaloneContactModal=ne,window.mountContactModalOverlay=te,window.abortContactModal=ee,window.unmountContactModalOverlays=X,window.unmountStandaloneContactModalOverlay=function(){X()},window.closeContactModal=ae,window.renderModalHTML=ce,window.bindContactModalEvents=se,window.initAnimationDropdown=function(e){const t=document.getElementById("animationDropdownContainer");if(!t)return;let n=e;"None"!==n&&null!=n||(n="-1"),isNaN(parseInt(n))&&(n="-1");const o=["Water","Chocolate","Sand","Slime","Syrup","Energy","Fire"],a=[2,8,18];let i="Solid";if("-1"!==n){const e=parseInt(n);i=a.includes(e)?"Beam":o[e%o.length]}t.textContent="";const r=s("button",{id:"contactAnimationBtn",style:(window.baseBtn||"")+" width: 100%; height: 32px; padding: 0 12px; border: 1.5px solid var(--glass-border); border-radius: 24px; background: var(--card-bg); color: var(--text-primary); font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"},i);r.addEventListener("click",()=>window.openAnimationSelectionModal("c","hiddenOverlayImage","hiddenAnimationPref","contactAnimationBtn")),t.appendChild(r)},window.initAvatarDropdown=function(e){const t=document.getElementById("avatarDropdownContainer");if(!t)return;const n=b(e);t.textContent="";const o=s("button",{id:"contactAvatarBtn",style:(window.baseBtn||"")+" width: 100%; height: 32px; padding: 0 12px; border: 1.5px solid var(--glass-border); border-radius: 24px; background: var(--card-bg); color: var(--text-primary); font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center;"},n);o.addEventListener("click",()=>window.openAvatarSelectionModal("c",null,"hiddenAvatarImage","contactAvatarBtn")),t.appendChild(o)},window.openAvatarSelectionModal=openAvatarSelectionModal,window.initBorderFrameDropdown=function(){},window.addContact=ue,window.saveEdit=we,window.validateAndBuildContact=me,window.sortContacts=fe,window.capitalize=ye,window.normalizePhone=ve,window.generateUniqueColor=he,window.getContrastColor=function(e){if(!e)return"#fff";const t=e.replace("#","");return(299*parseInt(t.substr(0,2),16)+587*parseInt(t.substr(2,2),16)+114*parseInt(t.substr(4,2),16))/1e3>=128?"#000":"#fff"},window.toggleVisualOptions=toggleVisualOptions,window.PRESET_COLORS=z,Object.defineProperty(window,"isContactModalOpen",{get:()=>O,set:e=>{O=e},configurable:!0}),Object.defineProperty(window,"editingContactId",{get:()=>_,set:e=>{_=e},configurable:!0}),Object.defineProperty(window,"contactSearchTerm",{get:()=>H,set:e=>{H=e},configurable:!0}),Object.defineProperty(window,"contactCurrentPage",{get:()=>j,set:e=>{j=e},configurable:!0}),Object.defineProperty(window,"contactItemsPerPage",{get:()=>N,set:e=>{N=e},configurable:!0}),Object.defineProperty(window,"advancedFilters",{get:()=>U,set:e=>{U=e},configurable:!0}),window.btnStyle=G,window.btnDangerStyle=R,window.btnPrimaryStyle=q,window.deleteContact=ge,window.ActionLogger="undefined"!=typeof ActionLogger?ActionLogger:window.ActionLogger,window.executeSingleContactImport=xe,window.openSingleDeviceContactPickerModal=be,window.openSingleContactImportModal=Ce,window.pickDeviceContactsForImport=ke,window.renderCorrectionUI=Me,window.openImportModal=Se;class $e{constructor(e){this.contacts=e,this.contactIds=e.map(e=>e.id)}async execute(){e.contacts.push(...this.contacts),fe(),"function"==typeof window.invalidateContactsMapCache&&window.invalidateContactsMapCache(),"function"==typeof window.invalidateContactsPopupCache&&window.invalidateContactsPopupCache(),"function"==typeof window.refreshContactsPopupLight&&window.refreshContactsPopupLight(),"contacts"===e.view&&window.render()}async undo(){const t=new Set(this.contactIds);e.contacts=e.contacts.filter(e=>!t.has(e.id)),"function"==typeof window.invalidateContactsMapCache&&window.invalidateContactsMapCache(),"function"==typeof window.invalidateContactsPopupCache&&window.invalidateContactsPopupCache(),"function"==typeof window.refreshContactsPopupLight&&window.refreshContactsPopupLight(),"contacts"===e.view&&window.render()}}"undefined"!=typeof window&&(le(),window.commandManager||"function"!=typeof window.CommandManager||(window.commandManager=new window.CommandManager));const Ie=Object.freeze(Object.defineProperty({__proto__:null,deleteContact:ge,executeSingleContactImport:xe,getContactFormError:de,invalidateContactMetricsCache:K,openSingleContactImportModal:Ce,openSingleDeviceContactPickerModal:be,pickDeviceContactsForImport:ke,renderCorrectionUI:Me},Symbol.toStringTag,{value:"Module"}));let Ee=null,Ae="",Te="";function Le(){Ee=null,Ae=""}function De(){const t=S(e.contacts);return"function"==typeof window.reID?window.reID(t):t}function ze(){let t=(e.contacts||[]).filter(e=>e&&e.id&&!k(e));return"function"==typeof window.reID&&(t=window.reID(t)),t}function Oe(){let t=(e.groups||[]).filter(t=>t&&t.id&&function(t){var n;if(!(null==(n=null==t?void 0:t.members)?void 0:n.length))return!1;const o="function"==typeof window.getMemoizedContactsMap?window.getMemoizedContactsMap(e.contacts):(e.contacts||[]).reduce((e,t)=>
1((null==t?void 0:t.id)&&(e[t.id]=t),e),{});return t.members.some(e=>{const t=o[e];return t&&!k(t)})}(t));return"function"==typeof window.getSortedGroups&&(t=window.getSortedGroups(t)),t}function Fe(t){const n=[...(e.contacts||[]).filter(e=>e&&e.color).map(e=>e.color),...(e.groups||[]).filter(e=>e&&e.color).map(e=>e.color)],o="function"==typeof window.generateUniqueColor?window.generateUniqueColor(n):"#7678ed";return`min-height: 84px; max-height: 140px; overflow-y: auto; padding: 14px; border: 1.5px solid var(--glass-border); border-radius: 24px; ${t>0&&"function"==typeof window.getGlassyTintedStyle?window.getGlassyTintedStyle(o):"background: rgba(0,0,0,0.1); backdrop-filter: var(--glass-blur);"}`}function _e(e=De()){if(!e.length){return`\n      <div style="display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 60px; color: var(--text-secondary); opacity: 0.5; gap: 6px;">\n        <div style="display:flex; justify-content:center; filter: grayscale(1);">${"function"==typeof window.customEmojiHtml?window.customEmojiHtml("users",{width:"28px",height:"28px"}):""}</div>\n        <div style="font-size: 12px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;">Check is empty</div>\n      </div>\n    `}return e.map(e=>{const t="function"==typeof window.closeIconHtml?window.closeIconHtml():"×",n="function"==typeof window.getThemeColor?window.getThemeColor("negative"):"red";if("function"==typeof window.renderContactPill)return`\n        <div style="display: flex; align-items: center; gap: 4px;">\n          ${window.renderContactPill(e,{showIcon:!0,padding:"6px 12px",fontSize:"14px"})}\n          <button style="border:none !important; background:transparent; cursor:pointer; font-size:16px; color:${n}; padding: 0; box-shadow: none !important; outline: none !important; display: flex; align-items: center;" aria-label="Remove Contact" data-action="removeContactFromCheck" data-args='["${i((null==e?void 0:e.id)||"")}"]' data-stop="1">${t}</button>\n        </div>\n      `;const o="function"==typeof window.getGlassyTintedStyle?window.getGlassyTintedStyle(null==e?void 0:e.color):"background:var(--bg-color); border: 1.5px solid var(--glass-border);",a="function"==typeof window.fullName?window.fullName(e):(null==e?void 0:e.first)||"Unknown";return`\n      <div style="display:flex; align-items:center; gap:6px; ${o} border-radius: 20px; padding: 6px 12px; font-size: 14px; font-weight: 800; box-shadow: var(--glass-shadow);">\n        <span style="width:10px; height:10px; border-radius:50%; background:${i((null==e?void 0:e.color)||"var(--border-color)")}; border: 1.5px solid var(--glass-border);"></span>\n        ${i(a)}\n        <button style="${window.baseBtn||""} border:none !important; background:transparent; cursor:pointer; font-size:16px; color:${n}; margin-left: 4px; padding: 0; box-shadow: none !important; outline: none !important; display: flex; align-items: center;" aria-label="Remove Contact" data-action="removeContactFromCheck" data-args='["${i((null==e?void 0:e.id)||"")}"]' data-stop="1">${t}</button>\n      </div>\n    `}).join("")}function He(){return`\n    <div id="contactsPopupUsedPills" style="display:flex; flex-wrap:wrap; gap: 12px; align-content: flex-start; align-items: center;">\n      ${_e(De())}\n    </div>\n  `}function je(){const e=document.getElementById("contactsPopupUsedList");if(!e)return;const t=De();e.style.cssText=Fe(t.length);let n=document.getElementById("contactsPopupUsedPills");n?n.innerHTML=_e(t):e.innerHTML=He()}function Ne(e,t,n,o){const a=document.getElementById(`dd-header-${e}`),i=document.getElementById(`dd-label-${e}`);if(a&&i)if(t)a.setAttribute("aria-disabled","false"),a.title="",a.style.opacity="",a.style.cursor="pointer",a.style.pointerEvents="",a.dataset.scDropdownDisabled="0","1"!==a.dataset.scResetPending&&"1"!==i.dataset.scResetPending&&(i.textContent=n);else{a.setAttribute("aria-disabled","false"),a.title=o,a.style.opacity="0.75",a.style.cursor="default",a.style.pointerEvents="auto",a.dataset.scDropdownDisabled="0",i.textContent=o,"function"==typeof window.updateDropdownHeaderStyle&&window.updateDropdownHeaderStyle(`dd-header-${e}`,null);const t="groupDropdownUI"===e?"existingGroup":"existingContact",n=document.getElementById(t);n&&(n.value="")}}function Ue(e,t){Ne("contactDropdownUI",e.length>0,"Add Contact","No contacts to add"),Ne("groupDropdownUI",t.length>0,"Add Group","No groups to add")}function Ge(e,t){return`${e.map(e=>e.id).join(",")}|${t.map(e=>e.id).join(",")}`}function Re(){e.contactsPopupOpen&&Ze()}function qe(){e.contactsPopupOpen&&(je(),Re())}
1function Ve(){if(!e.contactsPopupOpen)return null;if(!["receipt","split","summary"].includes(e.view))return e.contactsPopupOpen=!1,document.querySelectorAll("#contactsPopup").forEach(e=>e.remove()),"function"==typeof window.forceDismissManageContacts&&window.forceDismissManageContacts(),null;document.querySelectorAll("#contactsPopup").forEach(e=>{e.closest("#app, #page-container, #page-content-wrapper")&&e.remove()});let t=document.getElementById("contactsPopup");if(!t){let e="";try{e=Ye()}catch(n){console.error("Manage Contacts popup failed to build",n),Le()}e&&"function"==typeof window.mountHtmlModalOverlay&&(t=window.mountHtmlModalOverlay(e,{id:"contactsPopup"}))}return t?(t.style.display="flex",t.style.visibility="",t.style.pointerEvents="",t.removeAttribute("aria-hidden"),Ze()):(console.error("Manage Contacts popup failed to mount; releasing UI lock"),e.contactsPopupOpen=!1,document.body.classList.remove("modal-open")),"function"==typeof window.syncModalOpenBodyClass&&window.syncModalOpenBodyClass(),t}function Ye(){const t=`v5-${e.cacheVersion||0}-${e.contactsPopupOpen}-${(e.contacts||[]).length}-${(e.groups||[]).length}-${De().map(e=>null==e?void 0:e.id).filter(Boolean).sort().join(",")}`;if(null!==Ee&&Ae===t)return Ee;const n=Fe(De().length),o=[...(e.contacts||[]).filter(e=>e&&e.color).map(e=>e.color),...(e.groups||[]).filter(e=>e&&e.color).map(e=>e.color)],a="function"==typeof window.generateUniqueColor?window.generateUniqueColor(o):"#7678ed",i=void 0!==window.modalOverlayStyle?window.modalOverlayStyle:"position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:30; justify-content:center; align-items:center; padding: 24px;",r=("function"==typeof window.getTxModalShellStyle?window.getTxModalShellStyle("480px",a):void 0!==window.modalContainerStyle?window.modalContainerStyle:`${window.cardStyle||"background: var(--card-bg); border: 1.5px solid var(--glass-border);"} width: 100%; max-width: 480px; border-radius: 28px; max-height: 90vh; overflow-y: auto; scrollbar-width: thin;`)+" position:relative; display: flex; flex-direction: column; padding: 0; overflow: hidden;",d=window.baseBtn||"cursor:pointer; background:transparent; border:none;",l="function"==typeof window.closeIconHtml?window.closeIconHtml():"&times;",s="function"==typeof window.getThemeColor?window.getThemeColor("accent"):"#7678ed",c="function"==typeof window.getGlassyTintedButtonStyle?window.getGlassyTintedButtonStyle(s):`background:${s};`,p=`\n    <div id="contactsPopup" class="modal-overlay" style="${i} display:${e.contactsPopupOpen?"flex":"none"};">\n      <div style="${r}">\n        \n        <div style="${void 0!==window.modalHeaderStyle?window.modalHeaderStyle:"background: transparent; border-bottom: 1.5px solid var(--glass-border);"} padding: 14px 20px; flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px;">\n          <h2 style="margin:0; font-size: 20px; font-weight: 900; letter-spacing: -0.5px;">Manage Contacts</h2>\n          <button aria-label="Close" data-action="closeContactsPopup" style="${d} ${"function"==typeof window.getTxModalCloseBtnStyle?window.getTxModalCloseBtnStyle():"border-radius: 50%; width: 40px; height: 40px; min-width: 40px; min-height: 40px; padding: 0; position: static; flex-shrink: 0; display: flex; align-items: center; justify-content: center;"}">${l}</button>\n        </div>\n\n        <div style="flex: 1; overflow-y: auto; padding: 24px;">\n          \n          <div style="margin-bottom: 24px;">\n            <span style="${window.labelStyle||"display:block; margin-bottom: 8px; font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.8;"}">Used on this check</span>\n            \n            <div id="contactsPopupUsedList" style="${n}">\n              ${He()}\n            </div>\n          </div>\n\n          <hr style="border: 1px dashed var(--border-color); margin: 12px 0; opacity: 0.3;">\n\n          <div style="margin-bottom: 12px; display:grid; grid-template-columns: 1fr 1fr; justify-content: space-between; gap: 8px;">\n            \n            <div style="display:flex; flex-direction:column; gap: 6px; min-width: 0;">\n              <div id="groupDropdownUI" style="width: 100%; height: 38px; box-sizing: border-box;"></div>\n              <input autocomplete="off" type="hidden" id="existingGroup">\n            </div>\n\n            <div style="display:flex; flex-direction:column; gap: 6px; min-width: 0;">\n              <div id="contactDropdownUI" style="width: 100%; height: 38px; box-sizing: border-box;"></div>\n              <input autocomplete="off" type="hidden" id="existingContact">\n            </div>\n\n          </div>\n\n          <div class="contacts-popup-create-row" style="display: flex; gap: 8px; justify-content: center; align-items: center;">\n            <button type="button" id="contactsPopupImportUxBtn" class="contacts-popup-import-btn" data-action="importDeviceContactsFromPopup" title="Import Contacts" aria-label="Import Contacts" style="${d} ${"function"==typeof window.getGlassyTintedButtonStyle?window.getGlassyTintedButtonStyle("var(--glass-button-bg)"):""} flex: 1; min-height: 44px; padding: 8px 14px; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 22px; color: var(--text-primary); font-weight: 800; font-size: 14px;">\n              ${"function"==typeof v?v("import",{width:"18px",height:"18px"}):'<svg class="nav-icon dash-icon-svg" style="width: 18px; height: 18px;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>'}
1\n              <span>Import from Device</span>\n            </button>\n            <button type="button" id="contactsPopupCreateContactBtn" class="contacts-popup-create-btn" data-action="openCreateContactFromManagePopup" style="${d} ${c} color: var(--text-primary); font-weight: 900; font-size: 14px; letter-spacing: -0.3px; flex: 1; min-height: 44px; border-radius: 22px; display: flex; align-items: center; justify-content: center;">\n              New Contact\n            </button>\n          </div>\n        </div>\n\n      </div>\n    </div>\n  `;return Ee=p,Ae=t,p}function Ze(){if(!e.contactsPopupOpen)return;window._scContactsPopupDdResetTimers&&Object.keys(window._scContactsPopupDdResetTimers).forEach(e=>{window._scContactsPopupDdResetTimers[e]&&(clearTimeout(window._scContactsPopupDdResetTimers[e]),window._scContactsPopupDdResetTimers[e]=null)});const t=ze(),n=Oe(),o=Ge(t,n),a=document.getElementById("dd-header-contactDropdownUI"),r=document.getElementById("dd-header-groupDropdownUI");if(o===Te&&(a&&r))Ue(t,n);else{if(Te=o,"function"==typeof window.customDropdownHelper){const e="color: var(--text-primary);";window.customDropdownHelper("groupDropdownUI",n,e=>{const t=document.getElementById("existingGroup");t&&(t.value=e),"function"==typeof window.addGroupToCheck&&(window._contactsPopupPendingAddKind="group",window.addGroupToCheck()),Ke("groupDropdownUI","Add Group")},"Add Group",null,!0,e,!1,e),window.customDropdownHelper("contactDropdownUI",t,e=>{const t=document.getElementById("existingContact");t&&(t.value=e),"function"==typeof window.addExistingContact&&(window._contactsPopupPendingAddKind="contact",window.addExistingContact()),Ke("contactDropdownUI","Add Contact")},"Add Contact",null,!0,e,!1,e),["groupDropdownUI","contactDropdownUI"].forEach(e=>{const t=document.getElementById(`dd-header-${e}`);t&&"1"!==t.dataset.scResetBound&&(t.dataset.scResetBound="1",t.addEventListener("mousedown",n=>{if("1"===t.dataset.scDropdownDisabled)return n.preventDefault(),void n.stopPropagation();"function"==typeof window.flushContactsPopupHeavySync&&window.flushContactsPopupHeavySync(),function(e){window._scContactsPopupDdResetTimers||(window._scContactsPopupDdResetTimers={});const t=String(e);if(!window._scContactsPopupDdResetTimers[t])return;clearTimeout(window._scContactsPopupDdResetTimers[t]),window._scContactsPopupDdResetTimers[t]=null;const n=document.getElementById(`dd-label-${e}`);n&&(n.style.transition="opacity 0.08s ease",n.style.opacity="0",setTimeout(()=>{const t=ze(),o=Oe(),a="groupDropdownUI"===e?"Add Group":"Add Contact",r="groupDropdownUI"===e?o.length>0:t.length>0;n.innerHTML=i(r?a:"groupDropdownUI"===e?"No groups to add":"No contacts to add"),n.style.opacity=r?"1":"0.65",delete n.dataset.scResetPending;const d=document.getElementById(`dd-header-${e}`);d&&delete d.dataset.scResetPending,r&&"function"==typeof window.updateDropdownHeaderStyle&&window.updateDropdownHeaderStyle(`dd-header-${e}`,null);const l=document.getElementById("groupDropdownUI"===e?"existingGroup":"existingContact");l&&(l.value=""),Ue(t,o)},90))}(e)},{capture:!0}))})}Ue(t,n)}}function Ke(e,t){window._scContactsPopupDdResetTimers||(window._scContactsPopupDdResetTimers={});const n=String(e);clearTimeout(window._scContactsPopupDdResetTimers[n]);const o=document.getElementById(`dd-label-${e}`),a=document.getElementById(`dd-header-${e}`);o&&(o.dataset.scResetPending="1",o.style.transition="opacity 0.32s ease"),a&&(a.dataset.scResetPending="1",a.style.transition="background 0.32s ease, border-color 0.32s ease, box-shadow 0.32s ease, color 0.32s ease"),o&&(o.style.opacity="0.65"),window._scContactsPopupDdResetTimers[n]=setTimeout(()=>{o&&(o.style.opacity="0"),setTimeout(()=>{const n=ze(),r=Oe(),d="groupDropdownUI"===e?r.length>0:n.length>0;o&&(o.innerHTML=i(d?t:"groupDropdownUI"===e?"No groups to add":"No contacts to add"),o.style.opacity=d?"1":"0.65",delete o.dataset.scResetPending),a&&delete a.dataset.scResetPending,d&&"function"==typeof window.updateDropdownHeaderStyle&&window.updateDropdownHeaderStyle(`dd-header-${e}`,null);const l=document.getElementById("groupDropdownUI"===e?"existingGroup":"existingContact");l&&(l.value=""),Ue(n,r)},180)},240)}function Je(t){const n=document.getElementById("contactsPopup");n&&(t?(n.style.visibility="hidden",n.style.pointerEvents="none",n.setAttribute("aria-hidden","true")):(n.style.visibility="",n.style.pointerEvents="",n.removeAttribute("aria-hidden"),e.contactsPopupOpen&&(n.style.display="flex")))}window.invalidateContactsPopupCache=Le,window.refreshContactsPopupContent=function(){Le(),Te="",document.getElementById("contactsPopup"),qe()},window.refreshContactsPopupLight=qe,window.refreshContactsPopupUsedList=je,window.refreshContactsPopupDropdownOptions=Re,window.resetContactsPopupCreateForm=function(){},window.ensureContactsPopupMounted=Ve,window.openCreateContactFromManagePopup=function(){e.contactsPopupOpen&&"function"==typeof window.openContactModalForManage
1Contacts&&window.openContactModalForManageContacts()},window.importDeviceContactsFromPopup=function(){e.contactsPopupOpen&&"function"==typeof window.setManageContactsPopupHidden&&window.setManageContactsPopupHidden(!0),"function"==typeof window.pickDeviceContactsForImport&&window.pickDeviceContactsForImport({single:!0})},window.setManageContactsPopupHidden=Je,window.restoreManageContactsPopup=function(){e.contactsPopupOpen&&(Le(),Te="",Je(!1),document.body.classList.add("modal-open"),Ve(),qe(),requestAnimationFrame(()=>{const e=document.getElementById("contactsPopup"),t=null==e?void 0:e.querySelector(":scope > div");e&&t&&"function"==typeof window.bindModalViewportFit&&(window._contactsPopupViewportUnbind&&window._contactsPopupViewportUnbind(),window._contactsPopupViewportUnbind=window.bindModalViewportFit(e,t,{reservedTop:16,reservedBottom:24}))}))},window.contactsPopupHTML=Ye,window.initContactsPopupDropdowns=Ze,window.sortGroups=(window.sortGroups,window.sortGroups);const We=Object.freeze(Object.defineProperty({__proto__:null,buildUsedOnCheckPillsHTML:_e,contactsPopupHTML:Ye,getAvailableContactsForPopup:ze,getAvailableGroupsForPopup:Oe,getContactsPopupDropdownKey:Ge,initContactsPopupDropdowns:Ze},Symbol.toStringTag,{value:"Module"}));export{D as a,Ie as b,L as c,We as d};

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.