/*
 =======================================================================*\
|| ###################################################################### ||
|| # vBulletin 6.2.3
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2026 MH Sub I, LLC dba vBulletin. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
vBulletin.precache(["error_pushmanager_subscribe","error_serviceworker_registration"],["push_publickey"]);
((g,h,w,x)=>{function q(){return navigator.serviceWorker.register("vb_serviceworker.js?c="+pageData.cachebuster).then(a=>{const b=a.installing||a.waiting||a.active;return a.active?a:new Promise((d,c)=>{b.addEventListener("statechange",e=>{"activated"==e.target.state&&d(a)})})}).catch(a=>{console.error("Error during service worker registration: ",a);return Promise.reject("error_serviceworker_registration")})}function k(){return q().then(a=>{console.log("Service worker successfully registered.",a);
return a.pushManager.subscribe(l).then(l).catch(b=>{console.log("Error during pushManager subscribe: ",b);return a.pushManager.getSubscription().then(d=>{d.unsubscribe().then(()=>{a.pushManager.subscribe(l).then(c=>v(d,c).then(c))})})})}).catch(a=>{console.error("Error during pushManager subscribe: ",a);return Promise.reject("error_pushmanager_subscribe")})}function v(a,b){return new Promise((d,c)=>{m({call:"/ajax/api/pushnotification/updateExpiredSubscription",data:{oldSub:f(a),newSub:f(b)},success(e,
r,y){n(b.endpoint);d(e)},api_error(e){console.error("Error during push subscription update on server: ",e);c(e)}})})}function n(a){t.setCookie("vb_push_endpoint",a)}g=h.options.get;const t=h.storagetools,p=a=>btoa(String.fromCharCode.apply(null,new Uint8Array(a))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),f=a=>({endpoint:a.endpoint,keys:{p256dh:p(a.getKey("p256dh")),auth:p(a.getKey("auth"))},expiration:Number.parseInt(a.expirationTime/1E3,10)}),u=g("push_publickey"),l={userVisibleOnly:!0,
applicationServerKey:u},m=h.AJAX;"serviceWorker"in navigator&&"PushManager"in window&&(g={getPushSubscriptionPayload:f,getExistingSubscription:function(){return q().then(a=>{console.log("Service worker successfully registered.",a);return a.pushManager.getSubscription().then(b=>b&&p(b.options&&b.options.applicationServerKey)!==u?(console.log("Old app key does not match the current app key. Unsubscribing from existing subscription."),b.unsubscribe().then(()=>a.pushManager.getSubscription())):b)})},
getPushSubscription:k,subscribeUserToPush:function(){return k().then(a=>new Promise((b,d)=>{m({call:"/ajax/api/pushnotification/subscribeUser",data:f(a),success(c,e,r){n(a.endpoint);b(c)},api_error(c){console.error("Error during push subscription save to server: ",c);d(c)}})}))},unsubscribeUserFromPush:function(){return k().then(a=>new Promise((b,d)=>{m({call:"/ajax/api/pushnotification/unsubscribeUser",data:f(a),success(c,e,r){b(c)},api_error(c){console.error("Error during push subscription delete from server: ",
c);d(c)}})}))},setEndpointToCookie:n,getEndpointFromCookie:function(){t.getCookie("vb_push_endpoint")}},h.ready("pushnotification").resolve(g))})(jQuery,vBulletin,vBulletin.dialogtools,vBulletin.phrase.get);
