new-site/site/public/_astro/hoisted.yFz1BYXO.js
justin f8cd37ac8c Initial commit — Performance West telecom compliance platform
Includes: API (Express/TypeScript), Astro site, Python workers,
document generators, FCC compliance tools, Canada CRTC formation,
Ansible infrastructure, and deployment scripts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-27 06:54:22 -05:00

1 line
15 KiB
JavaScript

const ue=window.__PW_API;function me(e){document.getElementById("nav-login-btn")?.classList.add("hidden"),document.getElementById("nav-account-btn")?.classList.remove("hidden");const n=e.name?.split(" ")[0],o=document.getElementById("nav-greeting");o&&(o.textContent=n?`Hi, ${n}`:"My Account");const s=document.getElementById("nav-account-email");s&&(s.textContent=e.email)}function Be(){document.getElementById("nav-login-btn")?.classList.remove("hidden"),document.getElementById("nav-account-btn")?.classList.add("hidden")}(async()=>{try{const t=await(await fetch(`${ue}/api/v1/auth/me`,{credentials:"include"})).json();t.authenticated&&me(t.customer)}catch{}})();window.addEventListener("pw:auth",e=>{const t=e.detail;me(t),window.dispatchEvent(new CustomEvent("pw:portal-ready",{detail:t}))});document.getElementById("nav-logout-btn")?.addEventListener("click",async()=>{try{await fetch(`${ue}/api/v1/auth/logout`,{method:"POST",credentials:"include"})}catch{}Be(),document.getElementById("nav-account-menu")?.classList.add("hidden"),window.dispatchEvent(new CustomEvent("pw:portal-logout"))});const ae=document.getElementById("services-btn"),$=document.getElementById("services-menu"),H=document.getElementById("services-chevron"),ce=document.getElementById("services-dropdown");ae&&$&&H&&ce&&(ae.addEventListener("click",e=>{e.stopPropagation();const t=!$.classList.contains("hidden");$.classList.toggle("hidden",t),H.style.transform=t?"":"rotate(180deg)"}),document.addEventListener("click",e=>{ce.contains(e.target)||($.classList.add("hidden"),H.style.transform="")}));const de=document.getElementById("mobile-menu-btn"),re=document.getElementById("mobile-menu");de&&re&&de.addEventListener("click",()=>re.classList.toggle("hidden"));const le=document.getElementById("footer-support-link");le&&le.addEventListener("click",()=>{const e=document.getElementById("support-fab");e&&e.click()});const Le=document.getElementById("nav-account-trigger"),ge=document.getElementById("nav-account-menu");Le?.addEventListener("click",e=>{e.stopPropagation(),ge?.classList.toggle("hidden")});document.addEventListener("click",()=>ge?.classList.add("hidden"));(function(){const e=window.__PW_API||"https://api.performancewest.net",t="https://api.performancewest.net",n="https://portal.performancewest.net",o=document.getElementById("support-fab"),s=document.getElementById("support-panel"),g=document.getElementById("support-fab-icon-open"),M=document.getElementById("support-fab-icon-close"),b=document.getElementById("support-step-categories"),d=document.getElementById("support-step-form"),h=document.getElementById("support-step-opportunity"),A=document.getElementById("support-step-signin"),T=document.getElementById("support-step-success"),q=document.getElementById("support-back-btn"),_=document.getElementById("support-category-badge"),r=document.getElementById("support-submit-btn"),B=document.getElementById("support-char-count"),R=document.getElementById("support-message"),p=document.getElementById("support-ticket-id"),z=document.getElementById("support-success-message"),K=document.getElementById("support-new-ticket-btn"),ye=document.querySelectorAll(".support-cat-btn"),X=document.getElementById("opportunity-back-btn"),he=document.getElementById("opportunity-category-badge"),E=document.getElementById("opp-submit-btn"),Z=document.getElementById("signin-back-btn"),ee=document.getElementById("signin-auth-btn"),te=document.getElementById("signin-guest-btn"),ne=document.getElementById("support-signin-link"),se=document.getElementById("support-signin-btn");if(!o||!s)return;let j=!1,f="",u=null;const W={question:"Question",support:"Support",issue:"Issue Report",service_request:"Service Request",quote:"Quote Request"},Ee=["service_request","quote"],ve=["question","support"];async function be(){try{const i=[e+"/api/v1/auth/me",t+"/api/v1/auth/me"].filter((c,a,v)=>v.indexOf(c)===a);for(const c of i)try{const a=await fetch(c,{credentials:"include"});if(a.ok){const v=await a.json();if(v.authenticated&&v.customer){u=v.customer;return}}u=null;return}catch{}u=null}catch{u=null}}function oe(){ne&&ne.classList.toggle("hidden",!!u)}function J(){j=!j,j?(s.classList.remove("translate-y-4","opacity-0","pointer-events-none"),s.classList.add("translate-y-0","opacity-100","pointer-events-auto"),g.classList.add("hidden"),M.classList.remove("hidden"),be().then(oe)):(s.classList.add("translate-y-4","opacity-0","pointer-events-none"),s.classList.remove("translate-y-0","opacity-100","pointer-events-auto"),g.classList.remove("hidden"),M.classList.add("hidden"))}function y(i){b.classList.add("hidden"),d.classList.add("hidden"),h.classList.add("hidden"),A.classList.add("hidden"),T.classList.add("hidden"),i.classList.remove("hidden")}function G(){d.reset&&d.reset(),B&&(B.textContent="0"),r&&(r.disabled=!1,r.textContent="Submit")}function ie(){h.reset&&h.reset(),E&&(E.disabled=!1,E.textContent="Submit Request")}o.addEventListener("click",J),document.addEventListener("keydown",i=>{i.key==="Escape"&&j&&J()}),document.addEventListener("click",i=>{j&&!s.contains(i.target)&&!o.contains(i.target)&&J()}),ye.forEach(i=>{i.addEventListener("click",()=>{if(f=i.dataset.category,Ee.includes(f)){if(he.textContent=W[f]||f,ie(),u){const c=document.getElementById("opp-name"),a=document.getElementById("opp-email");c&&u.name&&(c.value=u.name),a&&u.email&&(a.value=u.email)}y(h)}else ve.includes(f)?u?window.location.href=n:y(A):(_.textContent=W[f]||f,G(),y(d))})}),q&&q.addEventListener("click",()=>y(b)),X&&X.addEventListener("click",()=>y(b)),Z&&Z.addEventListener("click",()=>y(b)),R&&B&&R.addEventListener("input",()=>{B.textContent=R.value.length}),K&&K.addEventListener("click",()=>{G(),ie(),y(b)}),ee&&ee.addEventListener("click",()=>{typeof window.pwOpenAuth=="function"?window.pwOpenAuth("login"):window.location.href=n}),te&&te.addEventListener("click",()=>{_.textContent=W[f]||f,G(),y(d)}),se&&se.addEventListener("click",()=>{typeof window.pwOpenAuth=="function"?window.pwOpenAuth("login"):window.location.href=n}),window.addEventListener("pw:auth",i=>{u=i.detail?.customer||null,oe(),A.classList.contains("hidden")||(window.location.href=n)}),d&&d.addEventListener("submit",async i=>{i.preventDefault();const c=document.getElementById("support-subject").value.trim(),a=document.getElementById("support-message").value.trim(),v=document.getElementById("support-email").value.trim(),U=document.getElementById("support-name").value.trim();if(!c||c.length<3){alert("Subject must be at least 3 characters.");return}if(!a||a.length<10){alert("Message must be at least 10 characters.");return}r.disabled=!0,r.textContent="Submitting...";try{const S=JSON.stringify({category:f,subject:c,message:a,email:v||void 0,name:U||void 0,page:window.location.pathname}),Q=["/api/v1/tickets",e+"/api/v1/tickets",t+"/api/v1/tickets"].filter((m,C,x)=>!!m&&x.indexOf(m)===C);let w=null,L=null,I=null;for(const m of Q)try{w=await fetch(m,{method:"POST",headers:{"Content-Type":"application/json"},body:S}),L=await w.json();break}catch(C){I=C}if(!w)throw I||new Error("All ticket endpoints failed");w.ok&&L.success?(z.textContent="We'll get back to you within one business day.",L.ticket_id&&p?(p.querySelector("span").textContent=L.ticket_id,p.classList.remove("hidden")):p&&p.classList.add("hidden"),y(T)):(alert(L.error||"Something went wrong. Please try again."),r.disabled=!1,r.textContent="Submit")}catch(S){console.error("Ticket submission failed:",S),alert("Could not reach the server. Please try again later."),r.disabled=!1,r.textContent="Submit"}}),h&&h.addEventListener("submit",async i=>{i.preventDefault();const c=document.getElementById("opp-name").value.trim(),a=document.getElementById("opp-email").value.trim(),v=document.getElementById("opp-company").value.trim(),U=document.getElementById("opp-phone").value.trim(),S=document.getElementById("opp-service").value,Q=document.getElementById("opp-details").value.trim();if(!c||c.length<2){alert("Name is required (at least 2 characters).");return}if(!a||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)){alert("A valid email address is required.");return}if(!S){alert("Please select a service.");return}E.disabled=!0,E.textContent="Submitting...";try{const w=JSON.stringify({name:c,email:a,company:v||void 0,phone:U||void 0,service_slug:S,details:Q||void 0}),L=["/api/v1/quotes",e+"/api/v1/quotes",t+"/api/v1/quotes"].filter((x,Y,we)=>!!x&&we.indexOf(x)===Y);let I=null,m=null,C=null;for(const x of L)try{I=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:w}),m=await I.json();break}catch(Y){C=Y}if(!I)throw C||new Error("All quote endpoints failed");I.ok&&m.success?(z.textContent=m.message||"We'll send your quote within one business day.",m.quote_id&&p?(p.querySelector("span").textContent=m.quote_id,p.classList.remove("hidden")):p&&p.classList.add("hidden"),y(T)):(alert(m.error||"Something went wrong. Please try again."),E.disabled=!1,E.textContent="Submit Request")}catch(w){console.error("Opportunity submission failed:",w),alert("Could not reach the server. Please try again later."),E.disabled=!1,E.textContent="Submit Request"}})})();(function(){const e=document.getElementById("subscribe-modal-global"),t=document.getElementById("subscribe-close-global"),n=document.getElementById("subscribe-form-global"),o=document.getElementById("subscribe-success-global"),s=document.getElementById("sub-submit-g");if(!e||!n)return;const g=document.getElementById("sub-ts-g");function M(){e.classList.remove("hidden"),e.classList.add("flex"),g&&(g.value=String(Date.now()))}function b(){e.classList.add("hidden"),e.classList.remove("flex")}document.querySelectorAll("[id^='subscribe-btn']").forEach(d=>{d.addEventListener("click",M)}),t?.addEventListener("click",b),e.addEventListener("click",d=>{d.target===e&&b()}),n.addEventListener("submit",async d=>{d.preventDefault();const h=document.getElementById("sub-email-g").value.trim(),A=document.getElementById("sub-name-g").value.trim(),T=document.getElementById("sub-company-g").value.trim(),q=document.getElementById("sub-consent-g").checked,_=document.getElementById("sub-website-g").value,r=g?.value?parseInt(g.value,10):0;if(!(!h||!q||!s)&&!_&&!(r&&Date.now()-r<2e3)){s.disabled=!0,s.textContent="Subscribing...";try{const B=await fetch((window.__PW_API||"https://api.performancewest.net")+"/api/v1/subscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:h,name:A||void 0,company:T||void 0,consent:q,_hp:_||void 0,_ts:r||void 0})});if(B.ok)n.classList.add("hidden"),o.classList.remove("hidden");else{const R=await B.json();alert(R.error||"Subscription failed. Try again."),s.disabled=!1,s.textContent="Subscribe"}}catch{alert("Could not reach the server. Try again later."),s.disabled=!1,s.textContent="Subscribe"}}})})();const V=window.__PW_API,O=document.getElementById("auth-modal-backdrop"),N=document.getElementById("auth-tab-login"),F=document.getElementById("auth-tab-register"),pe=document.getElementById("auth-login-form"),fe=document.getElementById("auth-register-form");function Ie(e="login"){O.classList.remove("hidden"),O.classList.add("flex"),k(e),setTimeout(()=>{(e==="login"?document.getElementById("auth-login-email"):document.getElementById("auth-reg-email"))?.focus()},50)}function D(){O.classList.add("hidden"),O.classList.remove("flex")}const ke=document.getElementById("auth-forgot-form"),Se=document.getElementById("auth-tabs");function k(e){const t=e==="login",n=e==="register",o=e==="forgot";pe.classList.toggle("hidden",!t),fe.classList.toggle("hidden",!n),ke.classList.toggle("hidden",!o),Se.classList.toggle("hidden",o),N.classList.toggle("text-pw-700",t),N.classList.toggle("border-pw-600",t),N.classList.toggle("text-gray-400",!t),N.classList.toggle("border-transparent",!t),F.classList.toggle("text-pw-700",n),F.classList.toggle("border-pw-600",n),F.classList.toggle("text-gray-400",!n),F.classList.toggle("border-transparent",!n)}window.pwOpenAuth=Ie;O.addEventListener("click",e=>{e.target===O&&D()});document.getElementById("auth-modal-close")?.addEventListener("click",D);document.addEventListener("keydown",e=>{e.key==="Escape"&&D()});N.addEventListener("click",()=>k("login"));F.addEventListener("click",()=>k("register"));document.getElementById("auth-forgot-link")?.addEventListener("click",()=>k("forgot"));document.getElementById("auth-back-to-login")?.addEventListener("click",()=>k("login"));function l(e,t){const n=document.getElementById(e);n.textContent=t,n.classList.toggle("hidden",!t)}function P(e,t,n){const o=document.getElementById(e);o.disabled=t,o.textContent=t?"Please wait…":n}pe.addEventListener("submit",async e=>{e.preventDefault(),l("auth-login-err","");const t=document.getElementById("auth-login-email").value.trim(),n=document.getElementById("auth-login-password").value;if(!t||!n){l("auth-login-err","Email and password required.");return}P("auth-login-btn",!0,"Sign In");try{const o=await fetch(`${V}/api/v1/auth/login`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,password:n})}),s=await o.json();o.ok?(D(),window.dispatchEvent(new CustomEvent("pw:auth",{detail:s.customer}))):(s.code==="NO_PASSWORD"&&k("register"),l("auth-login-err",s.error||"Login failed."))}catch{l("auth-login-err","Network error. Please try again.")}finally{P("auth-login-btn",!1,"Sign In")}});document.getElementById("auth-forgot-email-form")?.addEventListener("submit",async e=>{e.preventDefault(),l("auth-forgot-err","");const t=document.getElementById("auth-forgot-email").value.trim();if(!t){l("auth-forgot-err","Email required.");return}P("auth-forgot-btn",!0,"Send reset link");try{const n=await fetch(`${V}/api/v1/auth/forgot-password`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t})}),o=document.getElementById("auth-forgot-ok");n.ok?(o.textContent="✓ If an account exists for that email, a reset link is on its way.",o.classList.remove("hidden")):l("auth-forgot-err","Something went wrong. Please try again.")}catch{l("auth-forgot-err","Network error. Please try again.")}finally{P("auth-forgot-btn",!1,"Send reset link")}});fe.addEventListener("submit",async e=>{e.preventDefault(),l("auth-reg-err","");const t=document.getElementById("auth-reg-name").value.trim(),n=document.getElementById("auth-reg-email").value.trim(),o=document.getElementById("auth-reg-password").value;if(!n||!o){l("auth-reg-err","Email and password required.");return}if(o.length<8){l("auth-reg-err","Password must be at least 8 characters.");return}P("auth-reg-btn",!0,"Create Account");try{const s=await fetch(`${V}/api/v1/auth/register`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:n,password:o,name:t})}),g=await s.json();s.ok?(D(),window.dispatchEvent(new CustomEvent("pw:auth",{detail:g.customer}))):(s.status===409&&k("login"),l("auth-reg-err",g.error||"Registration failed."))}catch{l("auth-reg-err","Network error. Please try again.")}finally{P("auth-reg-btn",!1,"Create Account")}});