1 line
7.0 KiB
JavaScript
Vendored
1 line
7.0 KiB
JavaScript
Vendored
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1398],{99134:function(e,t,r){"use strict";var i=(0,r(67294).createContext)({});t.Z=i},92820:function(e,t,r){"use strict";var i=r(87462),n=r(4942),o=r(71002),s=r(97685),a=r(94184),c=r.n(a),l=r(67294),f=r(53124),d=r(98082),u=r(24308),p=r(93355),h=r(99134),w=function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)0>t.indexOf(i[n])&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]]);return r};function v(e,t){var r=l.useState("string"==typeof e?e:""),i=(0,s.Z)(r,2),n=i[0],a=i[1],c=function(){if("string"==typeof e&&a(e),"object"===(0,o.Z)(e))for(var r=0;r<u.c4.length;r++){var i=u.c4[r];if(t[i]){var n=e[i];if(void 0!==n){a(n);return}}}};return l.useEffect(function(){c()},[JSON.stringify(e),t]),n}(0,p.b)("top","middle","bottom","stretch"),(0,p.b)("start","end","center","space-around","space-between","space-evenly");var b=l.forwardRef(function(e,t){var r,a,p=e.prefixCls,b=e.justify,y=e.align,m=e.className,g=e.style,x=e.children,j=e.gutter,N=void 0===j?0:j,Z=e.wrap,_=w(e,["prefixCls","justify","align","className","style","children","gutter","wrap"]),C=l.useContext(f.E_),O=C.getPrefixCls,S=C.direction,M=l.useState({xs:!0,sm:!0,md:!0,lg:!0,xl:!0,xxl:!0}),B=(0,s.Z)(M,2),P=B[0],k=B[1],A=l.useState({xs:!1,sm:!1,md:!1,lg:!1,xl:!1,xxl:!1}),E=(0,s.Z)(A,2),R=E[0],L=E[1],T=v(y,R),I=v(b,R),J=(0,d.Z)(),V=l.useRef(N);l.useEffect(function(){var e=u.ZP.subscribe(function(e){L(e);var t=V.current||0;(!Array.isArray(t)&&"object"===(0,o.Z)(t)||Array.isArray(t)&&("object"===(0,o.Z)(t[0])||"object"===(0,o.Z)(t[1])))&&k(e)});return function(){return u.ZP.unsubscribe(e)}},[]);var F=O("row",p),K=(r=[void 0,void 0],(Array.isArray(N)?N:[N,void 0]).forEach(function(e,t){if("object"===(0,o.Z)(e))for(var i=0;i<u.c4.length;i++){var n=u.c4[i];if(P[n]&&void 0!==e[n]){r[t]=e[n];break}}else r[t]=e}),r),G=c()(F,(a={},(0,n.Z)(a,"".concat(F,"-no-wrap"),!1===Z),(0,n.Z)(a,"".concat(F,"-").concat(I),I),(0,n.Z)(a,"".concat(F,"-").concat(T),T),(0,n.Z)(a,"".concat(F,"-rtl"),"rtl"===S),a),m),U={},q=null!=K[0]&&K[0]>0?-(K[0]/2):void 0,H=null!=K[1]&&K[1]>0?-(K[1]/2):void 0;if(q&&(U.marginLeft=q,U.marginRight=q),J){var W=(0,s.Z)(K,2);U.rowGap=W[1]}else H&&(U.marginTop=H,U.marginBottom=H);var D=(0,s.Z)(K,2),z=D[0],Q=D[1],X=l.useMemo(function(){return{gutter:[z,Q],wrap:Z,supportFlexGap:J}},[z,Q,Z,J]);return l.createElement(h.Z.Provider,{value:X},l.createElement("div",(0,i.Z)({},_,{className:G,style:(0,i.Z)((0,i.Z)({},U),g),ref:t}),x))});t.Z=b},71230:function(e,t,r){"use strict";var i=r(92820);t.Z=i.Z},41398:function(e,t,r){"use strict";r.r(t),r.d(t,{BrowserNotifyModal:function(){return N}});var i=r(85893),n=r(85818),o=r(71577),s=r(11382),a=r(71230),c=r(67294),l=r(4480),f=r(37068),d=r(44974);async function u(e,t,r){console.log("saveNotificationRegistration");let i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:e,destination:t})};await fetch("".concat("/api/notifications/register","?accessToken=").concat(r),i)}async function p(e){let t=await navigator.serviceWorker.ready,r=await t.pushManager.getSubscription();return r||(r=await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:function(e){let t="=".repeat((4-e.length%4)%4),r=(e+t).replace(/-/g,"+").replace(/_/g,"/"),i=window.atob(r),n=new Uint8Array(i.length);for(let e=0;e<i.length;++e)n[e]=i.charCodeAt(e);return n}(e)})),JSON.stringify(r)}var h=r(67940),w=r.n(h),v=r(34148),b=r(69183);let{Title:y}=n.Z,m=()=>(0,i.jsx)("div",{children:"Browser notifications are not supported in your browser."}),g=()=>(0,i.jsx)("div",{children:"Browser notifications are not supported for local servers."}),x=e=>{let{start:t}=e;return(0,i.jsx)("div",{id:"browser-push-preview-box",className:w().pushPreview,children:(0,i.jsxs)("div",{className:w().inner,children:[(0,i.jsxs)("div",{className:w().title,children:[window.location.toString()," wants to"]}),(0,i.jsxs)("div",{className:w().permissionLine,children:[(0,i.jsx)("svg",{className:w().bell,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)("path",{d:"M14 12.3333V13H2V12.3333L3.33333 11V7C3.33333 4.93333 4.68667 3.11333 6.66667 2.52667C6.66667 2.46 6.66667 2.4 6.66667 2.33333C6.66667 1.97971 6.80714 1.64057 7.05719 1.39052C7.30724 1.14048 7.64638 1 8 1C8.35362 1 8.69276 1.14048 8.94281 1.39052C9.19286 1.64057 9.33333 1.97971 9.33333 2.33333C9.33333 2.4 9.33333 2.46 9.33333 2.52667C11.3133 3.11333 12.6667 4.93333 12.6667 7V11L14 12.3333ZM9.33333 13.6667C9.33333 14.0203 9.19286 14.3594 8.94281 14.6095C8.69276 14.8595 8.35362 15 8 15C7.64638 15 7.30724 14.8595 7.05719 14.6095C6.80714 14.3594 6.66667 14.0203 6.66667 13.6667",fill:"#676670"})}),(0,i.jsx)("span",{className:w().showNotificationsText,children:"Show notifications"})]}),(0,i.jsxs)("div",{className:w().buttonRow,children:[(0,i.jsx)(o.Z,{type:"primary",onClick:()=>{t()},children:"Allow"}),(0,i.jsx)("button",{type:"button",className:w().disabled,children:"Block"})]})]})})},j=()=>(0,i.jsxs)("div",{children:[(0,i.jsx)(y,{level:2,children:"Notifications are enabled"}),"To disable push notifications from ",window.location.hostname.toString()," access your browser permissions for this site and turn off notifications.",(0,i.jsx)("a",{href:"https://owncast.online/docs/notifications",children:" Learn more."})]}),N=()=>{let[e,t]=(0,c.useState)(null),r=(0,l.sJ)(d.FI),n=(0,l.sJ)(d.g1),[o,h]=(0,c.useState)(!1),y=(0,v.Z)()&&"default"!==Notification.permission,{notifications:N}=n,{browser:Z}=N,{publicKey:_}=Z,C=Z.enabled&&(0,v.Z)();if(y)return(0,i.jsx)(j,{});let O=async()=>{if(!(0,v.Z)()||"default"===Notification.permission){h(!0);try{let e=await p(_);u("BROWSER_PUSH_NOTIFICATION",e,r),t(null)}catch(e){t("Error registering for live notifications: ".concat(e.message,". Make sure you're not inside a private browser environment or have previously disabled notifications for this stream."))}h(!1)}};return"localhost"===window.location.hostname?(0,i.jsx)(g,{}):C?(0,i.jsx)(f.SV,{fallbackRender:e=>{let{error:t,resetErrorBoundary:r}=e;return(0,i.jsx)(b.A,{componentName:"BrowserNotifyModal",message:t.message,retryFunction:r})},children:(0,i.jsxs)(s.Z,{spinning:o,children:[(0,i.jsxs)(a.Z,{className:w().description,children:["Get notified right in the browser each time this stream goes live.",(0,i.jsx)("a",{href:"https://owncast.online/docs/notifications/#browser-notifications",children:"Learn more"}),"\xa0 about Owncast browser notifications."]}),(0,i.jsx)(a.Z,{children:e}),(0,i.jsx)(x,{start:()=>O()})]})}):(0,i.jsx)(m,{})}},67940:function(e){e.exports={description:"BrowserNotifyModal_description__tMKKq",pushPreview:"BrowserNotifyModal_pushPreview__4Og4q",inner:"BrowserNotifyModal_inner__uhFDw",title:"BrowserNotifyModal_title__dd_Lh",permissionLine:"BrowserNotifyModal_permissionLine__K8nyJ",bell:"BrowserNotifyModal_bell__9mIeI",buttonRow:"BrowserNotifyModal_buttonRow__oxJUg",disabled:"BrowserNotifyModal_disabled__v88lb"}}}]); |