1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[484],{5314:(e,t,n)=>{n.d(t,{$9:()=>c,Pn:()=>f,dA:()=>m});var r=n(35625),a=n(26708),i=n(48934),o=n(12115),s=n(7236),l=n(26185),d=n(49574),u=n(39982);async function c(e){let t=(0,s.U)(),n=`team/dm/${crypto.randomUUID()}-${(0,u.CO)(e.name)}`,{error:r}=await t.storage.from(d.Y4).upload(n,e,{contentType:e.type||void 0,upsert:!1});if(r)throw r;return{name:e.name,mime:e.type||"application/octet-stream",size:e.size,path:n}}async function m(e,t=3600){let n=(0,s.U)(),{data:r,error:a}=await n.storage.from(d.Y4).createSignedUrl(e,t);return a||!r?null:r.signedUrl}function f(e){let t=e?.subscribe??!0,n=(0,r.useQueryClient)(),u=(0,l.i)(),c=u?.id??null,m=["direct-messages",c],f=(0,a.useQuery)({queryKey:m,enabled:!!c,staleTime:15e3,queryFn:async()=>{let e=(0,s.U)(),{data:t,error:n}=await e.from("direct_messages").select("*").or(`sender_id.eq.${c},recipient_id.eq.${c}`).is("deleted_at",null).order("created_at",{ascending:!0}).limit(2e3);if(n)throw n;return t??[]}});(0,o.useEffect)(()=>{if(!c||!t)return;let e=(0,s.U)(),r=`dm-${c}-${Math.random().toString(36).slice(2)}`,a=()=>n.invalidateQueries({queryKey:m}),i=e.channel(r).on("postgres_changes",{event:"*",schema:"public",table:"direct_messages",filter:`recipient_id=eq.${c}`},a).on("postgres_changes",{event:"*",schema:"public",table:"direct_messages",filter:`sender_id=eq.${c}`},a).subscribe();return()=>{e.removeChannel(i)}},[c,t]);let p=(0,i.useMutation)({mutationFn:async({recipientId:e,content:t,attachment:n})=>{let r=(0,s.U)(),{error:a}=await r.from("direct_messages").insert({sender_id:c,recipient_id:e,content:t,attachment_name:n?.name??null,attachment_mime:n?.mime??null,attachment_size:n?.size??null,attachment_path:n?.path??null});if(a)throw a},onSuccess:()=>n.invalidateQueries({queryKey:m})}),g=(0,i.useMutation)({mutationFn:async e=>{let t=(0,s.U)(),{error:n}=await t.from("direct_messages").update({read_at:new Date().toISOString()}).eq("sender_id",e).eq("recipient_id",c).is("read_at",null);if(n)throw n},onSuccess:()=>n.invalidateQueries({queryKey:m})}),h=(0,i.useMutation)({mutationFn:async({id:e,content:t})=>{let n=(0,s.U)(),{error:r}=await n.from("direct_messages").update({content:t,edited_at:new Date().toISOString()}).eq("id",e).eq("sender_id",c);if(r)throw r},onSuccess:()=>n.invalidateQueries({queryKey:m})}),b=(0,i.useMutation)({mutationFn:async e=>{let t=(0,s.U)(),r=n.getQueryData(m)?.find(t=>t.id===e),{error:a}=await t.from("direct_messages").delete().eq("id",e).eq("sender_id",c);if(a)throw a;r?.attachment_path&&await t.storage.from(d.Y4).remove([r.attachment_path]).catch(()=>{})},onSuccess:()=>n.invalidateQueries({queryKey:m})});return{messages:f.data??[],isLoading:f.isLoading,myId:c,send:p,markRead:g,editMessage:h,deleteMessage:b}}},7910:(e,t,n)=>{n.d(t,{H:()=>a,j:()=>i});let r=[{f:523.25,at:0,dur:.32,gain:.16},{f:659.25,at:.18,dur:.32,gain:.15},{f:783.99,at:.36,dur:.36,gain:.15},{f:1046.5,at:.6,dur:.7,gain:.13}];function a(){let e=null,t=null,n=!0;function a(){if(e)for(let t of r)!function(t,n,r,a){if(!e)return;let i=e.currentTime+n;for(let[n,o]of[[1,1],[2,.22]]){let s=e.createOscillator(),l=e.createGain();s.type="sine",s.frequency.setValueAtTime(t*n,i),l.gain.setValueAtTime(0,i),l.gain.linearRampToValueAtTime(a*o,i+.015),l.gain.exponentialRampToValueAtTime(1e-4,i+r),s.connect(l).connect(e.destination),s.start(i),s.stop(i+r+.05)}}(t.f,t.at,t.dur,t.gain)}return{start(){if(n){n=!1;try{let r=window.AudioContext||window.webkitAudioContext;if(!r)return;if(e=new r,"suspended"===e.state){let t=()=>{document.removeEventListener("pointerdown",t),document.removeEventListener("keydown",t),!n&&e&&e.resume().then(()=>a())};document.addEventListener("pointerdown",t,{once:!0}),document.addEventListener("keydown",t,{once:!0})}e.resume(),a(),t=setInterval(a,3e3)}catch{}}},stop(){n=!0,t&&clearInterval(t),t=null,e&&(e.close(),e=null)}}}function i(){try{let e=new(window.AudioContext??window.webkitAudioContext),t=e.createGain();t.gain.value=1e-4,t.connect(e.destination),[659.25,880].forEach((n,r)=>{let a=e.createOscillator();a.type="sine",a.frequency.value=n,a.connect(t);let i=e.currentTime+.14*r;a.start(i),a.stop(i+.22)}),t.gain.exponentialRampToValueAtTime(.12,e.currentTime+.02),t.gain.exponentialRampToValueAtTime(1e-4,e.currentTime+.5),setTimeout(()=>void e.close().catch(()=>{}),900)}catch{}}},19381:(e,t,n)=>{n.d(t,{Cf:()=>a,TJ:()=>r,a4:()=>i,bW:()=>o,vk:()=>s});
1let r=[{id:"soare",emoji:"âï¸",label:"Sunt o razÄ de soare"},{id:"greu",emoji:"\uD83E\uDD71",label:"M-am trezit greu"},{id:"anxios",emoji:"\uD83E\uDEC2",label:"Anxios Èi cu nevoie de reasigurare"},{id:"cearta",emoji:"âï¸",label:"Pus pe ceartÄ asertivÄ"},{id:"excited",emoji:"\uD83D\uDE80",label:"Excited sÄ pun Èara la cale af"}],a="meet:presence",i=e=>`meet:user:${e}`,o=5;function s(){let e="abcdefghijklmnopqrstuvwxyz0123456789",t=new Uint8Array(12);crypto.getRandomValues(t);let n=[...t].map(t=>e[t%e.length]).join("");return`${n.slice(0,4)}-${n.slice(4,8)}-${n.slice(8,12)}`}},22210:(e,t,n)=>{n.d(t,{Bg:()=>s,FI:()=>f,N4:()=>o,Os:()=>h,QQ:()=>c,_0:()=>p,aR:()=>l,r3:()=>g,sO:()=>u,xI:()=>i,yg:()=>m,zN:()=>d});var r=n(7236);let a="BEfN8-FjrADj21O7BOX0aO_ow2KYRxaT5nbvgnrhy5BP33y0F4jG39vPlYDm_kJXZ2M0ehAh60C8ftOeLDwdCDQ";function i(){return"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window}function o(){return i()?Notification.permission:"denied"}function s(){let e=window.matchMedia?.("(display-mode: standalone)").matches??!1,t=!0===window.navigator.standalone;return e||t}function l(){let e=window.navigator.userAgent;return/iPad|iPhone|iPod/.test(e)}async function d(){return i()?(await navigator.serviceWorker.ready).pushManager.getSubscription():null}async function u(e){if(!i())throw Error("Browser-ul nu suportÄ notificÄri push.");if(!a)throw Error("VAPID public key lipsÄ (NEXT_PUBLIC_VAPID_PUBLIC_KEY).");if("granted"!==await Notification.requestPermission())throw Error("Permisiunea pentru notificÄri a fost refuzatÄ.");let t=await navigator.serviceWorker.ready,n=function(e){let t="=".repeat((4-e.length%4)%4),n=atob((e+t).replace(/-/g,"+").replace(/_/g,"/")),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}(a),o=await t.pushManager.getSubscription();if(!o)try{o=await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:n})}catch(r){if(r?.name!=="InvalidStateError")throw r;let e=await t.pushManager.getSubscription();e&&await e.unsubscribe().catch(()=>{}),o=await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:n})}let l=o.toJSON(),d=l.keys?.p256dh,u=l.keys?.auth;if(!d||!u)throw Error("Subscription invalidÄ (lipsesc cheile).");let c={ua:navigator.userAgent,lang:navigator.language,platform:navigator.platform,standalone:s(),screen:{w:window.screen?.width,h:window.screen?.height,dpr:window.devicePixelRatio}},m=(0,r.U)(),{error:f}=await m.from("push_subscriptions").upsert({user_id:e,endpoint:o.endpoint,p256dh:d,auth:u,device_info:c,last_seen_at:new Date().toISOString()},{onConflict:"endpoint"});if(f)throw f;return o}async function c(){if(!i())return;let e=await navigator.serviceWorker.ready,t=await e.pushManager.getSubscription();if(!t)return;let n=t.endpoint;await t.unsubscribe();let a=(0,r.U)();await a.from("push_subscriptions").delete().eq("endpoint",n)}async function m(e){let t=(0,r.U)(),{data:n,error:a}=await t.functions.invoke("send-push",{body:{user_id:e,payload:{title:"PSYTECH Cockpit",body:"NotificÄrile push sunt activate. \uD83C\uDF89",url:"/dashboard",category:"test"}}});if(a)throw a;return n}async function f(e){let t=(0,r.U)(),{data:n,error:a}=await t.functions.invoke("send-email",{body:{user_id:e,payload:{title:"PSYTECH Cockpit â email de test",body:"Acesta este un email de test. DacÄ \xeel vezi, configurarea Resend funcÈioneazÄ corect.\n\nVei primi notificÄri similare pentru orice eveniment important: refund-uri, task-uri asignate, deadline-uri, mesaje noi etc.",url:"/dashboard/setari",category:"test"}}});if(a)throw a;return n}async function p(e){let t=(0,r.U)(),{data:n,error:a}=await t.from("push_subscriptions").select("id, endpoint, device_info, created_at, last_seen_at").eq("user_id",e).order("last_seen_at",{ascending:!1});if(a)throw a;return n??[]}let g={emails_enabled:!0,push_enabled:!0};async function h(e){let t=(0,r.U)(),{data:n}=await t.from("notification_settings").select("prefs").eq("user_id",e).maybeSingle(),a=n?.prefs??{};return{emails_enabled:!1!==a.emails_enabled,push_enabled:!1!==a.push_enabled}}},25110:(e,t,n)=>{n.d(t,{N:()=>a});var r=n(9339);let a=(0,r.createServerReference)("405d13354cd08c74a9d2eb66234e88b6d0d1851950",r.callServer,void 0,r.findSourceMapURL,"sendRingPush")},39540:(e,t,n)=>{n.d(t,{T:()=>i});var r=n(95155);n(12115);var a=n(91337);function i({className:e,...t}){return(0,r.jsx)("textarea",{"data-slot":"textarea",className:(0,a.cn)("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...t})}},39658:(e,t,n)=>{n.d(t,{p:()=>i});var r=n(95155);n(12115);var a=n(91337);function i({className:e,type:t,...n}){return(0,r.jsx)("input",{type:t,"data-slot":"input",className:(0,a.cn)("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...n})}},39982:(e,t,n)=>{n.d(t,{CO:()=>c,Kc:()=>u,XZ:()=>i,qw:()=>d,sP:()=>o,z3:()=>a});var r=n(49574);function a(e){return!Number.isFinite(e)||e<0?"â":e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(0)} KB`:e<0x40000000?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(2)} GB`}function i(e){return e?e===r.Gi?"design":e===r.DOCUMENT_MIME?"doc":e===r.Rk?"spreadsheet":e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":"application/pdf"===e?"pdf":e.includes("spreadsheet")||"text/csv"===e||e.includes("excel")?"spreadsheet":e.includes("word")||"application/rtf"===e?"doc":e.includes("presentation")||e.includes("powerpoint")?"slides":e.includes("zip")||e.includes("rar")||e.includes("tar")||e.includes("gzip")?"archive":"application/json"===e||"application/javascript"===e||e.startsWith("text/x-")||e.includes("typescript")?"code":e.startsWith("text/")?"text":"other":"other"}let o={image:{bg:"bg-violet-50",fg:"text-violet-700",ring:"ring-violet-200"}
1,video:{bg:"bg-pink-50",fg:"text-pink-700",ring:"ring-pink-200"},audio:{bg:"bg-amber-50",fg:"text-amber-700",ring:"ring-amber-200"},pdf:{bg:"bg-red-50",fg:"text-red-700",ring:"ring-red-200"},spreadsheet:{bg:"bg-emerald-50",fg:"text-emerald-700",ring:"ring-emerald-200"},doc:{bg:"bg-blue-50",fg:"text-blue-700",ring:"ring-blue-200"},slides:{bg:"bg-orange-50",fg:"text-orange-700",ring:"ring-orange-200"},archive:{bg:"bg-slate-100",fg:"text-slate-700",ring:"ring-slate-200"},code:{bg:"bg-cyan-50",fg:"text-cyan-700",ring:"ring-cyan-200"},text:{bg:"bg-stone-50",fg:"text-stone-700",ring:"ring-stone-200"},design:{bg:"bg-indigo-50",fg:"text-indigo-700",ring:"ring-indigo-200"},other:{bg:"bg-muted",fg:"text-muted-foreground",ring:"ring-border"}},s=new Intl.DateTimeFormat("ro-RO",{day:"2-digit",month:"short",year:"numeric"}),l=new Intl.DateTimeFormat("ro-RO",{hour:"2-digit",minute:"2-digit"});function d(e){let t=new Date(e);return Number.isNaN(t.getTime())?"â":s.format(t)}function u(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return"â";let n=Math.floor((Date.now()-t.getTime())/6e4);if(n<1)return"acum";if(n<60)return`${n} min`;let r=Math.floor(n/60);if(r<24)return`${r} h`;let a=Math.floor(r/24);return a<7?`${a} z`:`${s.format(t)} \xb7 ${l.format(t)}`}function c(e){return e.normalize("NFKD").replace(/[^a-zA-Z0-9._-]/g,"_").slice(0,120)}},43447:(e,t,n)=>{n.d(t,{Hr:()=>f,Ht:()=>p,M5:()=>v,SQ:()=>u,_2:()=>c,hO:()=>m,lp:()=>g,lv:()=>b,mB:()=>h,nV:()=>x,rI:()=>l,ty:()=>d});var r=n(95155);n(12115);var a=n(57793),i=n(91337),o=n(64577),s=n(76721);function l({...e}){return(0,r.jsx)(a.bL,{"data-slot":"dropdown-menu",...e})}function d({...e}){return(0,r.jsx)(a.l9,{"data-slot":"dropdown-menu-trigger",...e})}function u({className:e,align:t="start",sideOffset:n=4,...o}){return(0,r.jsx)(a.ZL,{children:(0,r.jsx)(a.UC,{"data-slot":"dropdown-menu-content",sideOffset:n,align:t,className:(0,i.cn)("z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o})})}function c({className:e,inset:t,variant:n="default",...o}){return(0,r.jsx)(a.q7,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:(0,i.cn)("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",e),...o})}function m({className:e,children:t,checked:n,inset:s,...l}){return(0,r.jsxs)(a.H_,{"data-slot":"dropdown-menu-checkbox-item","data-inset":s,className:(0,i.cn)("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:n,...l,children:[(0,r.jsx)("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-checkbox-item-indicator",children:(0,r.jsx)(a.VF,{children:(0,r.jsx)(o.A,{})})}),t]})}function f({...e}){return(0,r.jsx)(a.z6,{"data-slot":"dropdown-menu-radio-group",...e})}function p({className:e,children:t,inset:n,...s}){return(0,r.jsxs)(a.hN,{"data-slot":"dropdown-menu-radio-item","data-inset":n,className:(0,i.cn)("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...s,children:[(0,r.jsx)("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-radio-item-indicator",children:(0,r.jsx)(a.VF,{children:(0,r.jsx)(o.A,{})})}),t]})}function g({className:e,inset:t,...n}){return(0,r.jsx)(a.JU,{"data-slot":"dropdown-menu-label","data-inset":t,className:(0,i.cn)("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",e),...n})}function h({className:e,...t}){return(0,r.jsx)(a.wv,{"data-slot":"dropdown-menu-separator",className:(0,i.cn)("-mx-1 my-1 h-px bg-border",e),...t})}function b({...e}){return(0,r.jsx)(a.Pb,{"data-slot":"dropdown-menu-sub",...e})}function x({className:e,inset:t,children:n,...o}){return(0,r.jsxs)(a.ZP,{"data-slot":"dropdown-menu-sub-trigger","data-inset":t,className:(0,i.cn)("flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...o,children:[n,(0,r.jsx)(s.A,{className:"ml-auto"})]})}function v({className:e,...t}){return(0,r.jsx)(a.G5,{"data-slot":"dropdown-menu-sub-content",className:(0,i.cn)("z-50 min-w-[96px] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground
1/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...t})}},49574:(e,t,n)=>{n.d(t,{DOCUMENT_MIME:()=>o,Gi:()=>i,MA:()=>l,Rk:()=>s,SYSTEM_FOLDER:()=>r,Y4:()=>a,gZ:()=>d,xd:()=>u});let r={taskAttachments:"task-uri",meetingMinutes:"procese-verbale",presentations:"prezentari",meetChat:"meet-chat"},a="drive",i="application/vnd.psytech.design+json",o="application/vnd.psytech.document+json",s="application/vnd.psytech.sheet+json";function l(e){return e===o?"document":e===s?"sheet":null}let d=0x6400000,u="https://drive.google.com/drive/folders/1HBvxHaOFnXWQjwb4Dd3bF94DFABUfBEf"},62489:(e,t,n)=>{n.d(t,{AM:()=>o,Wv:()=>s,hl:()=>l});var r=n(95155);n(12115);var a=n(40093),i=n(91337);function o({...e}){return(0,r.jsx)(a.bL,{"data-slot":"popover",...e})}function s({...e}){return(0,r.jsx)(a.l9,{"data-slot":"popover-trigger",...e})}function l({className:e,align:t="center",sideOffset:n=4,...o}){return(0,r.jsx)(a.ZL,{children:(0,r.jsx)(a.UC,{"data-slot":"popover-content",align:t,sideOffset:n,className:(0,i.cn)("z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o})})}},73927:(e,t,n)=>{n.d(t,{U:()=>i,h:()=>o});var r=n(12115);let a="psytech:deeplink";function i(e){try{window.dispatchEvent(new CustomEvent(a,{detail:e}))}catch{}}function o(e,t,n=!0){let i=(0,r.useRef)(!1),s=(0,r.useRef)(t),l=(0,r.useRef)(n),d=(0,r.useRef)(null);(0,r.useEffect)(()=>{s.current=t},[t]),(0,r.useEffect)(()=>{if(l.current=n,n&&null!==d.current){let e=d.current;d.current=null,s.current(e)}},[n]),(0,r.useEffect)(()=>{if(i.current||!n)return;let r=new URLSearchParams(window.location.search),a=r.get(e);if(!a){i.current=!0;return}t(a),i.current=!0,r.delete(e);let o=r.toString();window.history.replaceState(null,"",o?`${window.location.pathname}?${o}`:window.location.pathname)},[e,t,n]),(0,r.useEffect)(()=>{let t=t=>{let n,r=t.detail;if(!r)return;try{n=new URL(r,window.location.origin)}catch{return}if(n.pathname!==window.location.pathname)return;let a=n.searchParams.get(e);if(!a)return;l.current?s.current(a):d.current=a;let i=0,o=()=>{let t=new URLSearchParams(window.location.search);if(t.get(e)===a){t.delete(e);let n=t.toString();window.history.replaceState(null,"",n?`${window.location.pathname}?${n}`:window.location.pathname)}else++i<20&&setTimeout(o,100)};setTimeout(o,100)};return window.addEventListener(a,t),()=>window.removeEventListener(a,t)},[e])}},8e4:(e,t,n)=>{n.d(t,{b:()=>d,s:()=>u});var r=n(26708),a=n(35625),i=n(48934),o=n(7236),s=n(26185);let l=["meet","rooms"];function d(e=!0){let t=(0,o.U)();return(0,r.useQuery)({queryKey:l,enabled:e,queryFn:async()=>{let{data:e,error:n}=await t.from("meet_rooms").select("*").order("sort_order",{ascending:!0}).order("created_at",{ascending:!0});if(n)throw n;return e??[]}})}function u(){let e=(0,o.U)(),t=(0,a.useQueryClient)(),n=(0,s.i)(),r=()=>t.invalidateQueries({queryKey:l}),d=(0,i.useMutation)({mutationFn:async({name:t,emoji:r})=>{let{data:a}=await e.from("meet_rooms").select("sort_order").order("sort_order",{ascending:!1}).limit(1).maybeSingle(),i=(a?.sort_order??0)+1,{data:o,error:s}=await e.from("meet_rooms").insert({name:t.trim(),emoji:r??null,sort_order:i,is_permanent:!1,created_by:n?.id??null,created_by_name:n?.full_name??null}).select("*").single();if(s)throw s;return o},onSuccess:r});return{createRoom:d,updateRoom:(0,i.useMutation)({mutationFn:async({id:t,name:n,emoji:r})=>{let a={};if(void 0!==n&&(a.name=n.trim()),void 0!==r&&(a.emoji=r),0===Object.keys(a).length)return t;let{error:i}=await e.from("meet_rooms").update(a).eq("id",t);if(i)throw i;return t},onSuccess:r}),deleteRoom:(0,i.useMutation)({mutationFn:async t=>{let{error:n}=await e.from("meet_rooms").delete().eq("id",t);if(n)throw n},onSuccess:r})}}},85580:(e,t,n)=>{n.d(t,{MeetCallProvider:()=>D,V:()=>$});var r=n(95155),a=n(12115),i=n(73321),o=n(66609),s=n(7236),l=n(26185),d=n(19381),u=n(7910),c=n(25110),m=n(95861),f=n(86602),p=n(8e4),g=n(5314),h=n(47650),b=n(4705),x=n(16369),v=n(15532),w=n(27791);function y({enabled:e,incoming:t,onAccept:n,onDecline:i,onlineCount:s}){let[l,d]=(0,a.useState)(null),u=(0,a.useRef)(null),[c,m]=(0,a.useState)(0),f=(0,a.useRef)(!1),p=(0,a.useCallback)(async()=>{let e;if(u.current&&!u.current.closed)return;let t=window.documentPictureInPicture;if(!t){f.current||(f.current=!0,o.oR.error("Bula de apeluri merge doar pe Chrome, Edge sau Arc (Document Picture-in-Picture)."));return}try{try{e=await t.requestWindow({width:40,height:40})}catch{e=await t.requestWindow()}}catch{m(e=>e+1),f.current||(f.current=!0,(0,o.oR)("Bula de apeluri se deschide la urmÄtorul click \xeen paginÄ."));return}document.querySelectorAll('style, link[rel="stylesheet"]').forEach(t=>{e.document.head.appendChild(t.cloneNode(!0))}),e.document.documentElement.className=document.documentElement.className,e.document.title="Apeluri PSYTECH",e.document.body.style.margin="0",e.addEventListener("pagehide",()=>{u.current=null,d(null)}),u.current=e,d(e)},[]);return((0,a.useEffect)(()=>
1{if(e){let e=setTimeout(()=>void p(),0);return()=>clearTimeout(e)}u.current?.close(),u.current=null},[e,p]),(0,a.useEffect)(()=>{if(!e||l)return;let t=()=>void p();return document.addEventListener("pointerdown",t,{once:!0}),()=>document.removeEventListener("pointerdown",t)},[e,l,c,p]),(0,a.useEffect)(()=>()=>u.current?.close(),[]),l)?(0,h.createPortal)((0,r.jsx)(j,{incoming:t,onAccept:n,onDecline:i,onlineCount:s}),l.document.body):null}function j({incoming:e,onAccept:t,onDecline:n,onlineCount:a}){return(0,r.jsx)("div",{className:"flex h-dvh w-dvw items-center justify-center overflow-hidden bg-neutral-950 text-white",children:e?(0,r.jsxs)("div",{className:"flex w-full max-w-full items-center gap-2 px-2",children:[(0,r.jsxs)("span",{className:"relative shrink-0",children:[(0,r.jsx)("span",{className:"absolute inset-0 animate-ping rounded-full bg-emerald-500/40"}),(0,r.jsx)(w.H,{name:e.fromName,color:e.fromAvatarColor??"#4a6280",url:e.fromAvatarUrl??void 0,size:32})]}),(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"block truncate text-xs font-semibold",children:e.fromName}),(0,r.jsx)("span",{className:"block text-[10px] text-emerald-400",children:"te sunÄâ¦"})]}),(0,r.jsx)("button",{type:"button",onClick:n,"aria-label":"RefuzÄ",title:"RefuzÄ",className:"grid size-8 shrink-0 place-items-center rounded-full bg-rose-600 transition-colors hover:bg-rose-500",children:(0,r.jsx)(b.A,{className:"size-4"})}),(0,r.jsx)("button",{type:"button",onClick:t,"aria-label":"RÄspunde",title:"RÄspunde",className:"grid size-8 shrink-0 place-items-center rounded-full bg-emerald-500 transition-colors hover:bg-emerald-400",children:(0,r.jsx)(x.A,{className:"size-4"})})]}):(0,r.jsxs)("div",{className:"relative grid size-10 place-items-center rounded-full bg-gradient-to-br from-brand-700 to-accent-600 shadow-lg",title:"PSYTECH â bula de apeluri",children:[(0,r.jsx)(v.A,{className:"size-4"}),a>0&&(0,r.jsx)("span",{className:"absolute -right-1 -top-1 grid min-w-4 place-items-center rounded-full bg-emerald-500 px-1 text-[9px] font-bold ring-2 ring-neutral-950",children:a})]})})}var N=n(12980);function _({incoming:e,onAccept:t,onDecline:n}){let[i,o]=(0,a.useState)(null);return e&&i!==e.callId?(0,r.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center p-4",children:[(0,r.jsx)("button",{type:"button","aria-label":"Ascunde (ringul rÄm\xe2ne \xeen bara de sus)",onClick:()=>o(e.callId),className:"absolute inset-0 bg-brand-900/50 backdrop-blur-sm animate-in fade-in duration-200"}),(0,r.jsxs)("div",{className:"relative w-[min(94vw,360px)] overflow-hidden rounded-3xl border border-emerald-500/30 bg-card shadow-2xl shadow-emerald-900/30 animate-in fade-in zoom-in-90 slide-in-from-top-4 duration-300",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"absolute inset-0 bg-gradient-to-b from-emerald-500/15 via-transparent to-transparent"}),(0,r.jsx)("span",{"aria-hidden":!0,className:"absolute inset-x-0 top-0 h-28 text-foreground/[0.05]",style:{backgroundImage:"radial-gradient(currentColor 1px, transparent 1px)",backgroundSize:"12px 12px"}}),(0,r.jsxs)("div",{className:"relative flex flex-col items-center px-6 pb-6 pt-7 text-center",children:[(0,r.jsxs)("p",{className:"mb-4 inline-flex items-center gap-1.5 rounded-full bg-emerald-500/15 px-2.5 py-1 text-[10px] font-bold uppercase tracking-wider text-emerald-600 dark:text-emerald-300",children:[(0,r.jsx)(N.A,{className:"size-3"})," Apel PSYTECH"]}),(0,r.jsxs)("span",{className:"relative mb-4",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"absolute -inset-2 animate-ping rounded-full bg-emerald-500/25"}),(0,r.jsx)("span",{"aria-hidden":!0,className:"absolute -inset-2 rounded-full ring-2 ring-emerald-500/40"}),(0,r.jsx)("span",{"aria-hidden":!0,className:"absolute -inset-5 animate-pulse rounded-full ring-1 ring-emerald-500/20"}),(0,r.jsx)(w.H,{name:e.fromName,color:e.fromAvatarColor??"#4a6280",url:e.fromAvatarUrl??void 0,size:84})]}),(0,r.jsx)("h2",{className:"text-lg font-bold text-foreground",children:e.fromName}),(0,r.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["te sunÄ \xb7 ",e.roomName]}),(0,r.jsxs)("div",{className:"mt-6 flex items-center justify-center gap-8",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center gap-1.5",children:[(0,r.jsx)("button",{type:"button",onClick:n,"aria-label":"RefuzÄ",className:"flex size-14 items-center justify-center rounded-full bg-rose-600 text-white shadow-lg shadow-rose-600/30 transition-transform hover:scale-105 active:scale-95",children:(0,r.jsx)(b.A,{className:"size-6"})}),(0,r.jsx)("span",{className:"text-[10.5px] text-muted-foreground",children:"RefuzÄ"})]}),(0,r.jsxs)("div",{className:"flex flex-col items-center gap-1.5",children:[(0,r.jsx)("button",{type:"button",onClick:t,"aria-label":"RÄspunde",className:"flex size-14 animate-bounce items-center justify-center rounded-full bg-emerald-500 text-white shadow-lg shadow-emerald-500/40 transition-transform hover:scale-105 active:scale-95",children:(0,r.jsx)(x.A,{className:"size-6"})}),(0,r.jsx)("span",{className:"text-[10.5px] text-muted-foreground",children:"RÄspunde"})]})]})]})]})]}):null}var I=n(69203),k=n(95e3),S=n(42556),C=n(92571),E=n(46395),z=n(64577),A=n(22210);let R="psytech:pushgate:done";function T(){let e=(0,l.i)(),[t,n]=(0,a.useState)("hidden"),[i,o]=(0,a.useState)(!1),[s,d]=(0,a.useState)(""),[u,c]=(0,a.useState)(0);async function m(){if(e&&!i){o(!0),d("");try{await (0,A.sO)(e.id),sessionStorage.setItem(R,"1"),n("hidden")}catch(e){if("granted"!==(0,A.N4)())"denied"===t&&c(e=>e+1),n("denied");else{let t,n;d((t=e?.name??"",n=e?.message??String(e),"AbortError"===t||/push service/i.test(n)?"Serviciul de push al browserului nu rÄspunde (des pe VPN sau reÈele c
1are blocheazÄ Google/Apple push). \xcencearcÄ altÄ reÈea sau dezactiveazÄ VPN-ul.":"NotAllowedError"===t?"Sistemul blocheazÄ notificÄrile pentru browser. Pe macOS: SetÄri â NotificÄri â alege browserul â Permite notificÄrile.":"NotSupportedError"===t?"Browserul nu suportÄ push pe acest profil (mod incognito?). Deschide PSYTECH \xeentr-o fereastrÄ normalÄ.":`${t?t+": ":""}${n}`)),c(e=>e+1)}}finally{o(!1)}}}function f(){sessionStorage.setItem(R,"1"),n("hidden")}return((0,a.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{try{if("1"===sessionStorage.getItem(R))return;if(!(0,A.xI)()){!t&&(0,A.aR)()&&!(0,A.Bg)()&&n("ios");return}if("denied"===(0,A.N4)()){t||n("denied");return}if(await (0,A.zN)())return void sessionStorage.setItem(R,"1");t||n("ask")}catch{}})(),()=>{t=!0}},[e]),"hidden"===t)?null:(0,r.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center p-4",role:"dialog","aria-modal":"true","aria-label":"ActiveazÄ notificÄrile",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-brand-900/60 backdrop-blur-sm animate-in fade-in"}),(0,r.jsxs)("div",{className:"relative w-full max-w-sm overflow-hidden rounded-3xl border border-border bg-card shadow-2xl animate-in fade-in zoom-in-95",children:[(0,r.jsxs)("div",{className:"relative flex h-28 items-center justify-center overflow-hidden bg-gradient-to-br from-emerald-600 via-teal-600 to-brand-800",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"absolute size-24 animate-ping rounded-full bg-white/10"}),(0,r.jsx)("span",{"aria-hidden":!0,className:"absolute size-16 rounded-full ring-2 ring-white/25"}),(0,r.jsx)("span",{className:"grid size-14 place-items-center rounded-full bg-white/15 text-white backdrop-blur",children:"denied"===t?(0,r.jsx)(I.A,{className:"size-7"}):"ios"===t?(0,r.jsx)(k.A,{className:"size-7"}):(0,r.jsx)(S.A,{className:"size-7"})})]}),(0,r.jsxs)("div",{className:"space-y-3 p-5",children:["ask"===t&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h2",{className:"text-lg font-bold text-foreground",children:"ActiveazÄ notificÄrile de apel"}),(0,r.jsxs)("p",{className:"text-sm text-muted-foreground",children:["C\xe2nd un coleg te sunÄ Èi nu eÈti pe tab-ul PSYTECH, apelul ajunge la tine ca notificare cu ",(0,r.jsx)("strong",{children:"RÄspunde / RefuzÄ"})," â ca un telefon. E obligatoriu pentru toatÄ echipa, o singurÄ datÄ per dispozitiv."]}),s&&(0,r.jsx)("p",{className:"rounded-lg bg-rose-500/10 px-3 py-2 text-xs text-rose-600 dar
1k:text-rose-400",children:s}),(0,r.jsxs)("button",{type:"button",onClick:()=>void m(),disabled:i,className:"inline-flex w-full items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-emerald-600 to-teal-600 px-4 py-3 text-sm font-semibold text-white shadow-md shadow-emerald-600/25 transition hover:from-emerald-500 hover:to-teal-500 disabled:opacity-60",children:[i?(0,r.jsx)(C.A,{className:"size-4 animate-spin"}):(0,r.jsx)(E.A,{className:"size-4"}),"ActiveazÄ notificÄrile"]}),(0,r.jsx)("p",{className:"text-center text-[11px] text-muted-foreground",children:'Browserul va cere permisiunea â apasÄ âPermite".'}),u>=1&&(0,r.jsx)("button",{type:"button",onClick:f,className:"inline-flex w-full items-center justify-center rounded-xl px-4 py-2 text-xs text-muted-foreground transition hover:text-foreground",children:"Mai t\xe2rziu â continuÄ fÄrÄ apeluri pe acest dispozitiv"})]}),"denied"===t&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h2",{className:"text-lg font-bold text-foreground",children:"NotificÄrile sunt blocate"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Browserul a blocat notificÄrile pentru PSYTECH, deci apelurile nu te pot ajunge. DeblocheazÄ-le aÈa:"}),(0,r.jsxs)("ol",{className:"list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[(0,r.jsxs)("li",{children:["ApasÄ pe ",(0,r.jsx)("strong",{children:'âNotifications blocked"'})," (clopoÈelul tÄiat \uD83D\uDD15) din bara de adresÄ â sau pe iconiÈa \uD83D\uDD12 â NotificÄri."]}),(0,r.jsxs)("li",{children:["Alege ",(0,r.jsx)("strong",{children:'âAlways allow notifications on this site"'})," (Permite \xeentotdeauna) Èi apasÄ",(0,r.jsx)("strong",{children:" Done"}),"."]}),(0,r.jsx)("li",{children:"Revino aici Èi apasÄ butonul de mai jos."})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>void m(),disabled:i,className:"inline-flex w-full items-center justify-center gap-2 rounded-xl bg-emerald-600 px-4 py-2.5 text-sm font-semibold text-white transition hover:bg-emerald-500 disabled:opacity-60",children:[i?(0,r.jsx)(C.A,{className:"size-4 animate-spin"}):(0,r.jsx)(z.A,{className:"size-4"}),"Am deblocat â verificÄ din nou"]}),u>=1&&(0,r.jsx)("button",{type:"button",onClick:f,className:"inline-flex w-full items-center justify-center rounded-xl px-4 py-2 text-xs text-muted-foreground transition hover:text-foreground",children:"Mai t\xe2rziu â continuÄ fÄrÄ apeluri pe acest dispozitiv"})]}),"ios"===t&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h2",{className:"text-lg font-bold text-foreground",children:"InstaleazÄ PSYTECH pe ecran"}),(0,r.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Pe iPhone/iPad, notificÄrile de apel funcÈioneazÄ doar din aplicaÈia instalatÄ: Safari â ",(0,r.jsx)("strong",{children:"Share"})," â ",(0,r.jsx)("strong",{children:"AdaugÄ pe ecranul principal"}),", apoi deschide de acolo."]}),(0,r.jsx)("button",{type:"button",onClick:f,className:"inline-flex w-full items-center justify-center rounded-xl bg-accent px-4 py-2.5 text-sm font-medium text-foreground transition hover:bg-accent/70",children:"Am \xeenÈeles"})]})]})]})]})}let U="psytech:meet:calldock",M=(0,a.createContext)(null);function $(){let e=(0,a.useContext)(M);if(!e)throw Error("useMeetCall must be used within MeetCallProvider");return e}function P(e,t,n,r,a){let i=new URLSearchParams({uid:n,name:r,room:t,mode:a});return window.open(`/meet/${e}?${i.toString()}`,"_blank")}function D({children:e}){let t=(0,l.i)(),n=(0,a.useMemo)(()=>(0,s.U)(),[]);(0,m.cR)();let{lastSeen:h,isRecentlyActive:b}=(0,m.sS)(),[x,v]=(0,a.useState)([]),[w,j]=(0,a.useState)(null),[N,I]=(0,a.useState)(null),[k,S]=(0,a.useState)(null),C=(0,a.useRef)(null),E=(0,a.useRef)(null),z=(0,a.useRef)(null),A=(0,a.useRef)(null),R=(0,a.useRef)(null),$=(0,a.useRef)(null),q=(0,a.useRef)(new Map),L=(0,a.useRef)(()=>{}),F=(0,a.useRef)(!1),O=(0,a.useRef)(null),B=(0,a.useRef)(null),H=(0,a.useRef)(null),Q=(0,a.useRef)(null);(0,a.useEffect)(()=>{H.current=w},[w]);let W=(0,a.useRef)(null);(0,a.useEffect)(()=>{O.current=k},[k]);let Y=(0,a.useRef)(null);(0,a.useEffect)(()=>{Y.current=N},[N]);let K=(0,a.useSyncExternalStore)(e=>(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)),()=>"on"===localStorage.getItem(U),()=>!1),V=(0,a.useCallback)(e=>{localStorage.setItem(U,e?"on":"off"),window.dispatchEvent(new StorageEvent("storage",{key:U}))},[]);(0,a.useEffect)(()=>
1{if(!t)return;let e=n.channel(d.Cf,{config:{private:!0,presence:{key:`dash:${t.id}`}}});return C.current=e,e.on("presence",{event:"sync"},()=>{let n=e.presenceState(),r=new Map,a=null;for(let e of Object.values(n))for(let n of e){if(!n.userId)continue;if(n.userId===t.id){"in-call"===n.status&&n.roomId&&(a={roomId:n.roomId,roomName:n.roomName??"Apel"});continue}let e=r.get(n.userId);e&&("in-call"!==n.status||"in-call"===e.status)||r.set(n.userId,n)}v([...r.values()]),j(a);let i=Y.current;a&&i&&i.roomUrl.endsWith(`/${a.roomId}`)&&(z.current?.stop(),z.current=null,R.current&&(clearTimeout(R.current),R.current=null),I(null));let o=()=>{A.current?.stop(),A.current=null};a||(Q.current=null);let s=O.current;if(s)if(a&&a.roomId===s.roomId)F.current=!0,B.current&&(clearTimeout(B.current),B.current=null),s.ringingName&&[...r.values()].some(e=>e.roomId===s.roomId&&"in-call"===e.status)&&(o(),W.current=null,S(e=>e?{...e,ringingName:null}:e));else if(F.current&&a){let e=q.current.get(s.roomId);q.current.delete(s.roomId),q.current.set(a.roomId,e??null),o(),S({roomId:a.roomId,roomName:a.roomName,url:`${window.location.origin}/meet/${a.roomId}`,mode:"room",ringingName:null})}else!F.current||a||B.current||(B.current=setTimeout(()=>{B.current=null,F.current&&(F.current=!1,o(),S(null))},4e3));else F.current=!1,a&&Q.current!==a.roomId&&(F.current=!0,S({roomId:a.roomId,roomName:a.roomName,url:`${window.location.origin}/meet/${a.roomId}`,mode:"room",ringingName:null}))}),e.subscribe(async n=>{"SUBSCRIBED"===n&&await e.track({userId:t.id,name:t.full_name,avatarColor:t.avatar_color,avatarUrl:t.avatar_url,status:"online",roomId:null,roomName:null})}),()=>{e.untrack(),n.removeChannel(e),C.current=null}},[t,n]);let G=(0,a.useCallback)(()=>{z.current?.stop(),z.current=null},[]),Z=(0,a.useCallback)(()=>{G(),R.current&&clearTimeout(R.current),R.current=null,I(null)},[G]);(0,a.useEffect)(()=>{if(!t)return;let e=n.channel((0,d.a4)(t.id),{config:{private:!0}});return E.current=e,e.on("broadcast",{event:"ring"},({payload:e})=>{let t=H.current;if(t&&e.roomUrl.endsWith(`/${t.roomId}`))return;G(),I(e);let n=(0,u.H)();z.current=n,n.start(),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>Z(),35e3)}),e.on("broadcast",{event:"ring-cancel"},({payload:e})=>{I(t=>t&&t.callId===e.callId?(G(),null):t)}),e.on("broadcast",{event:"ring-decline"},({payload:e})=>{let t=W.current;t&&t.callId===e.callId&&(W.current=null,$.current&&clearTimeout($.current),A.current?.stop(),A.current=null,S(e=>e?{...e,ringingName:null}:e),(0,o.oR)(`${e.byName?.trim()||"Colegul"} nu poate rÄspunde acum`,{description:"PoÈi rÄm\xe2ne \xeen camerÄ sau \xeenchide fereastra apelului."}))}),e.on("broadcast",{event:"nudge"},({payload:e})=>{(0,o.oR)(`ð ${e.fromName} te-a ciupit`,{description:"IntrÄ \xeen apel dacÄ eÈti liber. RÄm\xe2ne activ 5 minute.",duration:3e5,closeButton:!0,...e.fromId?{action:{label:"CiupeÈte \xeenapoi \uD83D\uDC4B",onClick:()=>
1L.current({id:e.fromId,name:e.fromName})}}:{}})}),e.subscribe(),()=>{n.removeChannel(e),E.current=null}},[t,n,Z,G]);let X=(0,a.useCallback)(()=>{A.current?.stop(),A.current=null},[]);(0,a.useEffect)(()=>()=>{G(),A.current?.stop(),$.current&&clearTimeout($.current),R.current&&clearTimeout(R.current)},[G]);let J=(0,a.useCallback)((e,t,r)=>{let a=n.channel((0,d.a4)(e),{config:{private:!0}});a.subscribe(e=>{"SUBSCRIBED"===e&&(a.send({type:"broadcast",event:t,payload:r}),setTimeout(()=>void n.removeChannel(a),1e3))})},[n]),ee=(0,a.useCallback)((e,t,n,r)=>{(0,c.N)({toUserId:e,title:t,body:n,url:r}).catch(()=>{})},[]),et=(0,a.useCallback)(()=>{let e=W.current;e&&(J(e.userId,"ring-cancel",{callId:e.callId}),W.current=null,$.current&&clearTimeout($.current),A.current?.stop(),A.current=null)},[J]),en=(0,a.useCallback)(e=>{for(let t of new Set([O.current?.roomId,H.current?.roomId].filter(Boolean))){if(t===e)continue;let n=q.current.get(t);n&&!n.closed&&n.close(),q.current.delete(t)}},[]),er=(0,a.useCallback)(e=>{if(!t)return;et();let n=(0,d.vk)();en(n);let r=`Apel cu ${t.firstName}`,a=crypto.randomUUID(),i=`${window.location.origin}/meet/${n}`;q.current.set(n,P(n,r,t.id,t.full_name,"call")),F.current=!1;let o={callId:a,fromId:t.id,fromName:t.full_name,fromAvatarColor:t.avatar_color,fromAvatarUrl:t.avatar_url,roomUrl:i,roomName:r};J(e.id,"ring",o);let s=new URLSearchParams({uid:e.id,name:e.name,room:r,mode:"call"});ee(e.id,`ð ${t.full_name} te sunÄ`,"Apel video PSYTECH â intrÄ \xeen ÈedinÈÄ.",`${i}?${s.toString()}`),W.current={callId:a,userId:e.id},S({roomId:n,roomName:r,url:i,mode:"call",ringingName:e.name}),X();let l=(0,u.H)();A.current=l,l.start(),$.current&&clearTimeout($.current),$.current=setTimeout(()=>{X();let e=W.current;e&&e.callId===a&&(J(e.userId,"ring-cancel",{callId:e.callId}),W.current=null),S(e=>e&&e.roomId===n?{...e,ringingName:null}:e)},2e4)},[t,J,ee,X,en,et]),ea=(0,a.useCallback)((e,n)=>{if(!t)return;et(),en(e);let r=q.current.get(e);r&&!r.closed?r.focus():(q.current.set(e,P(e,n,t.id,t.full_name,"room")),F.current=!1),S({roomId:e,roomName:n,url:`${window.location.origin}/meet/${e}`,mode:"room",ringingName:null})},[t,en,et]),ei=(0,a.useCallback)(e=>{t&&(J(e.id,"nudge",{fromName:t.full_name,fromId:t.id}),ee(e.id,`ð ${t.full_name} te-a ciupit`,"Te cheamÄ \xeentr-un apel PSYTECH.","/dashboard/panou/mesaje"),o.oR.success(`Ai ciupit pe ${e.name} ð`))},[t,J,ee]);(0,a.useEffect)(()=>{L.current=ei},[ei]);let eo=(0,a.useCallback)(()=>{if(!N||!t)return;let e=new URL(N.roomUrl).pathname.split("/").pop()??"";et(),en(e);let n=q.current.get(e),r=n&&!n.closed?(n.focus(),n):P(e,N.roomName,t.id,t.full_name,"call");if(!r){window.focus(),(0,o.oR)("RÄspunde din fereastra PSYTECH",{description:"Browserul a blocat deschiderea automatÄ a camerei."});return}q.current.set(e,r),F.current=!1,S({roomId:e,roomName:N.roomName,url:N.roomUrl,mode:"call",ringingName:null}),J(t.id,"ring-cancel",{callId:N.callId}),Z()},[N,t,Z,en,J,et]),es=(0,a.useCallback)(()=>{N&&t&&(J(N.fromId,"ring-decline",{callId:N.callId,byName:t.full_name}),J(t.id,"ring-cancel",{callId:N.callId})),Z()},[N,t,J,Z]);(0,a.useEffect)(()=>{let e="u">typeof navigator?navigator.serviceWorker:void 0;if(!e)return;let t=e=>{e.data?.type==="PUSH_MEET_DECLINE"&&es()};return e.addEventListener("message",t),()=>e.removeEventListener("message",t)},[es]);let el=(0,a.useCallback)(()=>{if(!k||!t)return;let e=q.current.get(k.roomId);e&&!e.closed?e.focus():(q.current.set(k.roomId,P(k.roomId,k.roomName,t.id,t.full_name,k.mode)),F.current=!1)},[k,t]),ed=(0,a.useCallback)(()=>{Q.current=O.current?.roomId??null,X(),$.current&&clearTimeout($.current);let e=W.current;e&&(J(e.userId,"ring-cancel",{callId:e.callId}),W.current=null),S(null)},[X,J]);(0,a.useEffect)(()=>()=>{B.current&&clearTimeout(B.current)},[]),(0,a.useEffect)(()=>{let e=setInterval(()=>{let e=O.current;if(!e||e.ringingName)return;let t=q.current.get(e.roomId);(!t||t.closed)&&H.current?.roomId!==e.roomId&&(F.current=!1,A.current?.stop(),A.current=null,S(null))},4e3);return()=>clearInterval(e)},[]);let eu=(0,a.useMemo)(()=>{let e=new Map;for(let t of x)"in-call"===t.status&&t.userId&&t.roomId&&e.set(t.userId,{roomId:t.roomId,roomName:t.roomName??"Apel"});return e},[x]),ec=(0,a.useCallback)(e=>b(e)||x.some(t=>t.userId===e&&"in-call"===t.status),[x,b]),em=(0,a.useCallback)(e=>h.get(e)??null,[h]),ef=(0,a.useMemo)(()=>{let e=new Set;
1for(let n of h.keys())n!==t?.id&&b(n)&&e.add(n);for(let t of x)"in-call"===t.status&&t.userId&&e.add(t.userId);return e.size},[h,x,t?.id,b]);(0,f.yU)({subscribe:!0});let{data:ep=[]}=(0,p.b)(),eg=(0,a.useRef)(new Map);(0,a.useEffect)(()=>{eg.current=new Map(ep.map(e=>[e.id,e.name]))},[ep]),(0,a.useEffect)(()=>{if(!t)return;let e=`room-toast-${t.id}-${Math.random().toString(36).slice(2)}`,r=n.channel(e).on("postgres_changes",{event:"INSERT",schema:"public",table:"meet_messages"},({new:e})=>{if(!e?.room_id||e.author_id===t.id||(0,f.Iy)()===e.room_id)return;let n=eg.current.get(e.room_id);if(!n)return;let r=Array.isArray(e.mentions)&&e.mentions.includes(t.id);(0,o.oR)(r?`@ ${e.author_name??"Cineva"} te-a menÈionat \xeen # ${n}`:`${e.author_name??"Cineva"} \xb7 # ${n}`,{description:(e.content??"").slice(0,120)||"(fÄrÄ text)",duration:r?2e4:6e3,closeButton:r,action:{label:"Deschide",onClick:()=>{window.location.href="/dashboard/panou/mesaje"}}})}).subscribe();return()=>{n.removeChannel(r)}},[t,n]);let{messages:eh,myId:eb}=(0,g.Pn)(),ex=(0,a.useRef)(null),ev=(0,i.usePathname)(),ew=ev?.startsWith("/dashboard/panou/mesaje")??!1;(0,a.useEffect)(()=>{if(!eb)return;let e=eh.filter(e=>e.recipient_id===eb&&!e.deleted_at),t=e[e.length-1];if(!t)return;if(null===ex.current){ex.current=t.id;return}if(ex.current===t.id||(ex.current=t.id,t.read_at||ew))return;let n=x.find(e=>e.userId===t.sender_id)?.name??"Un coleg";(0,o.oR)(`ð¬ Mesaj privat de la ${n}`,{description:t.content?.slice(0,120)||"(fÄrÄ text)",duration:12e3,action:{label:"Deschide",onClick:()=>{window.location.href="/dashboard/panou/mesaje"}}})},[eh,eb,ew,x]);let ey=(0,a.useMemo)(()=>({others:x,inCallByUser:eu,selfCall:w,isOnline:ec,lastSeenOf:em,callUser:er,joinRoom:ea,nudgeUser:ei,dockEnabled:K,setDockEnabled:V,incoming:N,activeCall:k,acceptIncoming:eo,declineIncoming:es,openActiveCall:el,closeActiveCall:ed}),[x,eu,w,ec,em,er,ea,ei,K,V,N,k,eo,es,el,ed]);return(0,r.jsxs)(M.Provider,{value:ey,children:[e,(0,r.jsx)(T,{}),(0,r.jsx)(_,{incoming:N,onAccept:eo,onDecline:es},N?.callId??"idle"),(0,r.jsx)(y,{enabled:K,incoming:N,onAccept:eo,onDecline:es,onlineCount:ef})]})}},86602:(e,t,n)=>{n.d(t,{Iy:()=>d,ti:()=>c,yU:()=>u});var r=n(12115),a=n(35625),i=n(26708),o=n(7236),s=n(26185);let l=e=>["comunicare","room-unread",e];function d(){return null}function u(e){let t=e?.subscribe??!1,n=(0,s.i)(),d=n?.id??null,u=(0,a.useQueryClient)(),c=(0,r.useMemo)(()=>(0,o.U)(),[]),m=(0,i.useQuery)({queryKey:l(d),enabled:!!d,staleTime:2e4,refetchInterval:12e4,refetchOnWindowFocus:!0,queryFn:async()=>{let{data:e,error:t}=await c.rpc("meet_room_unread");if(t)throw t;return e??[]}});return(0,r.useEffect)(()=>{if(!d||!t)return;let e=`room-unread-${d}-${Math.random().toString(36).slice(2)}`,n=c.channel(e).on("postgres_changes",{event:"*",schema:"public",table:"meet_messages"},()=>u.invalidateQueries({queryKey:l(d)})).subscribe();return()=>{c.removeChannel(n)}},[d,t,c,u]),m}function c(e){return Array.isArray(e)?e.reduce((e,t)=>e+(t.unread??0),0):0}},95861:(e,t,n)=>{n.d(t,{cR:()=>u,mu:()=>s,sS:()=>d});var r=n(12115),a=n(26708),i=n(7236),o=n(26185);let s=6e5,l=["meet","heartbeats"];function d(){let e=(0,r.useMemo)(()=>(0,i.U)(),[]),t=(0,a.useQuery)({queryKey:l,queryFn:async()=>{let{data:t,error:n}=await e.from("user_heartbeats").select("user_id, last_seen");if(n)throw n;return t??[]},refetchInterval:45e3,refetchOnWindowFocus:!0,staleTime:2e4}).data,n=(0,r.useMemo)(()=>{let e=new Map;if(Array.isArray(t))for(let n of t)e.set(n.user_id,new Date(n.last_seen));return e},[t]),o=(0,r.useMemo)(()=>(e,t=s)=>{let r=n.get(e);return!!r&&Date.now()-r.getTime()<=t},[n]);return{lastSeen:n,isRecentlyActive:o}}function u(){let e=(0,o.i)(),t=(0,r.useMemo)(()=>(0,i.U)(),[]);(0,r.useEffect)(()=>{if(!e?.id)return;let n=Date.now(),r=0,a=()=>{r=Date.now(),t.rpc("touch_heartbeat").then(({error:e})=>{e&&console.debug("heartbeat failed:",e.message)})},i=()=>{"visible"!==document.visibilityState||Date.now()-n>3e5||a()},o=()=>{(n=Date.now())-r>6e4&&i()},s=()=>{"visible"===document.visibilityState&&o()};a();let l=setInterval(i,6e4),d=["pointerdown","pointermove","keydown","wheel","touchstart"];for(let e of d)document.addEventListener(e,o,{passive:!0});
1return document.addEventListener("visibilitychange",s),()=>{for(let e of(clearInterval(l),d))document.removeEventListener(e,o);document.removeEventListener("visibilitychange",s)}},[e?.id,t])}}}]);
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.