PageSourceSearch

https://tesana.com/assets/useNotifications-CrW-0d5F.js

js tesana.com collected 2026-10-09 22:41:54 UTC 1,256 bytes, 1 lines download raw bytes

1import{r as e}from"./vendor-react-E98sgxjj.js";import{af as S,a1 as o,x as r,ag as w}from"./index-BKzE8EQ8.js";const u="notification_prompt_dismissed",I=7;function b(){const[s,l]=e.useState(()=>"Notification"in window?Notification.permission:"unsupported"),[d,a]=e.useState(!1),i=e.useRef(null),f=e.useCallback(async()=>{a(!0);try{const t=await S();return l(t==="granted"?"granted":t==="unsupported"?"unsupported":"denied"),t==="granted"?o.success(r.t("notifications.enabled",{ns:"common"})):t==="denied"&&o.error(r.t("notifications.denied",{ns:"common"})),t}finally{a(!1)}},[]);e.useEffect(()=>{if(s!=="granted")return;let t=!1;return w(({title:n,body:g,data:c})=>{o(n,{description:g,action:c?.click_url?{label:r.t("notifications.view",{ns:"common"}),onClick:()=>window.location.assign(c.click_url)}:void 0,duration:6e3})}).then(n=>{if(t){n?.();return}i.current=n}),()=>{t=!0,i.current?.(),i.current=null}},[s]);const m=e.useCallback(()=>{if(s!=="default")return!1;const t=localStorage.getItem(u);if(t){const n=parseInt(t,10);if(Date.now()-n<I*24*60*60*1e3)return!1}return!0},[s]),p=e.useCallback(()=>{localStorage.setItem(u,Date.now().toString())},[]);return{permission:s,loading:d,requestPermission:f,shouldShowPrompt:m,dismissPrompt:p}}export{b as u};

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.