1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DRoJQYoX.js","assets/index-DFRwvZ6i.js","assets/motion-DQrxb1aq.js","assets/vendor-BTbeRSw2.js","assets/index-Pgv31N5q.css","assets/index-BGL46_Uy.js","assets/imagePreprocess-DKqt_HU0.js","assets/index-XIFkKqiZ.js"])))=>i.map(i=>d[i]); 2var dc=Object.defineProperty,uc=Object.defineProperties;var fc=Object.getOwnPropertyDescriptors;var _r=Object.getOwnPropertySymbols;var ja=Object.prototype.hasOwnProperty,Na=Object.prototype.propertyIsEnumerable;var vn=(t,r,s)=>r in t?dc(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s,L=(t,r)=>{for(var s in r||(r={}))ja.call(r,s)&&vn(t,s,r[s]);if(_r)for(var s of _r(r))Na.call(r,s)&&vn(t,s,r[s]);return t},se=(t,r)=>uc(t,fc(r));var xe=(t,r)=>{var s={};for(var a in t)ja.call(t,a)&&r.indexOf(a)<0&&(s[a]=t[a]);if(t!=null&&_r)for(var a of _r(t))r.indexOf(a)<0&&Na.call(t,a)&&(s[a]=t[a]);return s};var Fe=(t,r,s)=>vn(t,typeof r!="symbol"?r+"":r,s);var Q=(t,r,s)=>new Promise((a,o)=>{var i=p=>{try{f(s.next(p))}catch(g){o(g)}},l=p=>{try{f(s.throw(p))}catch(g){o(g)}},f=p=>p.done?a(p.value):Promise.resolve(p.value).then(i,l);f((s=s.apply(t,r)).next())});import{c as We,X as Je,_ as Lt,P as Ht,u as rn,a as Dn,b as mr,d as Be,e as mc,f as gt,L as dr,s as Se,g as Ie,A as Ct,h as pc,C as Hr,M as gs,i as Sr,j as nn,S as Ur,k as mo,l as po,m as qe,n as vs,o as ho,R as hc,p as xc,q as xo,r as an,t as gc,v as vc,D as bc,w as yc,x as wc,y as jc,z as go,B as Jn,E as Nc,G as vo,H as Qn,I as Gr,J as kc,K as bo,N as _c,O as Sc,Q as ka,T as _a,U as Cc}from"./index-DFRwvZ6i.js";import{j as e}from"./motion-DQrxb1aq.js";import{r as n,g as Ec,a as Xt,u as bs,d as yo,h as Rc,i as Mc}from"./vendor-BTbeRSw2.js";import{B as Ms,S as Ac,u as Ks,a as Pc,C as Sa,b as wo,c as Cr,d as ea,e as pr,f as Vs,F as jo,I as Yr,P as hr,g as No,s as ko,h as on,i as Hs,j as Tc,k as xr,l as zn,m as Dc,n as zc,R as Ic,o as Lc,p as Fc,q as Oc,r as Kr,t as _o,H as ta,v as $c,w as Bc,x as Xr,y as ln,z as So,A as Co,D as Eo,M as qc,E as Wc,G as Ro,J as Mo,K as sa,L as ra,T as na,O as aa,N as oa,Q as Ao,W as Vc,U as Hc,V as Uc}from"./index-rm6UIHd4.js";import{C as ia,L as Us}from"./lock-BEU8CNk8.js";import{T as Vt}from"./trash-2-CT_YVMUm.js";import{C as gr,S as Gc}from"./smartphone-CPdOlcMA.js";import{B as Yc,b as Po}from"./button-s5Yi8lF6.js";/** 3 * @license lucide-react v0.462.0 - ISC 4 * 5 * This source code is licensed under the ISC license. 6 * See the LICENSE file in the root directory of this source tree. 7 */const Kc=We("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);/** 8 * @license lucide-react v0.462.0 - ISC 9 * 10 * This source code is licensed under the ISC license. 11 * See the LICENSE file in the root directory of this source tree. 12 */const To=We("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);/** 13 * @license lucide-react v0.462.0 - ISC 14 * 15 * This source code is licensed under the ISC license. 16 * See the LICENSE file in the root directory of this source tree. 17 */const Xc=We("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/** 18 * @license lucide-react v0.462.0 - ISC 19 * 20 * This source code is licensed under the ISC license. 21 * See the LICENSE file in the root directory of this source tree. 22 */const Zc=We("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);/** 23 * @license lucide-react v0.462.0 - ISC 24 * 25 * This source code is licensed under the ISC license. 26 * See the LICENSE file in the root directory of this source tree. 27 */const Do=We("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/** 28 * @license lucide-react v0.462.0 - ISC 29 * 30 * This source code is licensed under the ISC license. 31 * See the LICENSE file in the root directory of this source tree. 32 */const zo=We("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/** 33 * @license lucide-react v0.462.0 - ISC 34 * 35 * This source code is licensed under the ISC license. 36 * See the LICENSE file in the root directory of this source tree. 37 */const Io=We("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** 38 * @license lucide-react v0.462.0 - ISC 39 * 40 * This source code is licensed under the ISC license. 41 * See the LICENSE file in the root directory of this source tree. 42 */const Lo=We("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}
42]]);/** 43 * @license lucide-react v0.462.0 - ISC 44 * 45 * This source code is licensed under the ISC license. 46 * See the LICENSE file in the root directory of this source tree. 47 */const Fo=We("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/** 48 * @license lucide-react v0.462.0 - ISC 49 * 50 * This source code is licensed under the ISC license. 51 * See the LICENSE file in the root directory of this source tree. 52 */const Oo=We("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);/** 53 * @license lucide-react v0.462.0 - ISC 54 * 55 * This source code is licensed under the ISC license. 56 * See the LICENSE file in the root directory of this source tree. 57 */const $o=We("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** 58 * @license lucide-react v0.462.0 - ISC 59 * 60 * This source code is licensed under the ISC license. 61 * See the LICENSE file in the root directory of this source tree. 62 */const Bo=We("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/** 63 * @license lucide-react v0.462.0 - ISC 64 * 65 * This source code is licensed under the ISC license. 66 * See the LICENSE file in the root directory of this source tree. 67 */const qo=We("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** 68 * @license lucide-react v0.462.0 - ISC 69 * 70 * This source code is licensed under the ISC license. 71 * See the LICENSE file in the root directory of this source tree. 72 */const In=We("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/** 73 * @license lucide-react v0.462.0 - ISC 74 * 75 * This source code is licensed under the ISC license. 76 * See the LICENSE file in the root directory of this source tree. 77 */const Jc=We("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/** 78 * @license lucide-react v0.462.0 - ISC 79 * 80 * This source code is licensed under the ISC license. 81 * See the LICENSE file in the root directory of this source tree. 82 */const Wo=We("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/** 83 * @license lucide-react v0.462.0 - ISC 84 * 85 * This source code is licensed under the ISC license. 86 * See the LICENSE file in the root directory of this source tree. 87 */const Qc=We("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/** 88 * @license lucide-react v0.462.0 - ISC 89 * 90 * This source code is licensed under the ISC license. 91 * See the LICENSE file in the root directory of this source tree. 92 */const ed=We("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** 93 * @license lucide-react v0.462.0 - ISC 94 * 95 * This source code is licensed under the ISC license. 96 * See the LICENSE file in the root directory of this source tree. 97 */const Vo=We("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);/** 98 * @license lucide-react v0.462.0 - ISC 99 * 100 * This source code is licensed under the ISC license. 101 * See the LICENSE file in the root directory of this source tree. 102 */const Ho=We("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7
102a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);/** 103 * @license lucide-react v0.462.0 - ISC 104 * 105 * This source code is licensed under the ISC license. 106 * See the LICENSE file in the root directory of this source tree. 107 */const Es=We("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** 108 * @license lucide-react v0.462.0 - ISC 109 * 110 * This source code is licensed under the ISC license. 111 * See the LICENSE file in the root directory of this source tree. 112 */const Uo=We("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);/** 113 * @license lucide-react v0.462.0 - ISC 114 * 115 * This source code is licensed under the ISC license. 116 * See the LICENSE file in the root directory of this source tree. 117 */const td=We("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/** 118 * @license lucide-react v0.462.0 - ISC 119 * 120 * This source code is licensed under the ISC license. 121 * See the LICENSE file in the root directory of this source tree. 122 */const sd=We("SkipBack",[["polygon",{points:"19 20 9 12 19 4 19 20",key:"o2sva"}],["line",{x1:"5",x2:"5",y1:"19",y2:"5",key:"1ocqjk"}]]);/** 123 * @license lucide-react v0.462.0 - ISC 124 * 125 * This source code is licensed under the ISC license. 126 * See the LICENSE file in the root directory of this source tree. 127 */const rd=We("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);/** 128 * @license lucide-react v0.462.0 - ISC 129 * 130 * This source code is licensed under the ISC license. 131 * See the LICENSE file in the root directory of this source tree. 132 */const Go=We("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** 133 * @license lucide-react v0.462.0 - ISC 134 * 135 * This source code is licensed under the ISC license. 136 * See the LICENSE file in the root directory of this source tree. 137 */const Yo=We("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** 138 * @license lucide-react v0.462.0 - ISC 139 * 140 * This source code is licensed under the ISC license. 141 * See the LICENSE file in the root directory of this source tree. 142 */const nd=We("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/** 143 * @license lucide-react v0.462.0 - ISC 144 * 145 * This source code is licensed under the ISC license. 146 * See the LICENSE file in the root directory of this source tree. 147 */const ad=We("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/** 148 * @license lucide-react v0.462.0 - ISC 149 * 150 * This source code is licensed under the ISC license. 151 * See the LICENSE file in the root directory of this source tree. 152 */const xs=We("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.5
1525 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);/** 153 * @license lucide-react v0.462.0 - ISC 154 * 155 * This source code is licensed under the ISC license. 156 * See the LICENSE file in the root directory of this source tree. 157 */const od=We("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/** 158 * @license lucide-react v0.462.0 - ISC 159 * 160 * This source code is licensed under the ISC license. 161 * See the LICENSE file in the root directory of this source tree. 162 */const id=We("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function ld({fetchMore:t,hasMore:r,loading:s,rootMargin:a="200px",rootRef:o}){const i=n.useRef(null),l=n.useRef(r),f=n.useRef(s);n.useEffect(()=>{l.current=r},[r]),n.useEffect(()=>{f.current=s},[s]);const p=n.useRef(t);n.useEffect(()=>{p.current=t},[t]);const[g,c]=n.useState(null);return n.useEffect(()=>{var d;const x=(d=o==null?void 0:o.current)!=null?d:null;if(c(u=>u!==x?x:u),!x&&o){const u=setTimeout(()=>{var m;return c((m=o.current)!=null?m:null)},50);return()=>clearTimeout(u)}},[o,o==null?void 0:o.current]),n.useEffect(()=>{const x=i.current;if(!x)return;const d=new IntersectionObserver(u=>{var m;(m=u[0])!=null&&m.isIntersecting&&l.current&&!f.current&&p.current()},{root:g,rootMargin:a});return d.observe(x),()=>d.disconnect()},[a,g]),n.useEffect(()=>{if(s||!r||!i.current)return;const x=Number.parseInt(a,10)||200,d=i.current.getBoundingClientRect(),u=o!=null&&o.current?o.current.getBoundingClientRect().bottom:window.innerHeight;d.top<=u+x&&p.current()},[s,r,a,o]),i}function bn(){return e.jsxs("div",{className:"rounded-2xl px-5 py-5",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-light)"},children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-4",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-muted shrink-0 skeleton-shimmer"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-3 w-[60%] rounded bg-muted skeleton-shimmer"}),e.jsx("div",{className:"h-2.5 w-[40%] rounded bg-muted skeleton-shimmer"})]})]}),e.jsx("div",{className:"h-4 w-[85%] rounded bg-muted mb-2 skeleton-shimmer"}),e.jsx("div",{className:"h-4 w-[55%] rounded bg-muted mb-4 skeleton-shimmer"}),e.jsx("div",{className:"w-full rounded-xl bg-muted mb-4 skeleton-shimmer",style:{aspectRatio:"16/9"}}),e.jsxs("div",{className:"flex items-center gap-4 pt-3",style:{borderTop:"1px solid var(--sv-border-subtle)"},children:[e.jsx("div",{className:"h-3 w-10 rounded bg-muted skeleton-shimmer"}),e.jsx("div",{className:"h-3 w-10 rounded bg-muted skeleton-shimmer"})]})]})}const yn="push-prompt-shown",cd=/SetversoNativeIOS|SetversoNativeAndroid/.test(navigator.userAgent)||!!window.__IS_NATIVE_APP__;function dd({userId:t}){const[r,s]=n.useState(!1);n.useEffect(()=>{if(!cd||!t||localStorage.getItem(yn))return;const i=setTimeout(()=>s(!0),1500);return()=>clearTimeout(i)},[t]);const a=()=>{var i;try{window.ReactNativeWebView?window.ReactNativeWebView.postMessage(JSON.stringify({type:"REQUEST_NOTIFICATION_PERMISSION"})):(i=window.NativeBridge)!=null&&i.requestNotificationPermission&&window.NativeBridge.requestNotificationPermission()}catch(l){}localStorage.setItem(yn,"true"),s(!1)},o=()=>{localStorage.setItem(yn,"true"),s(!1)};return r?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[var(--sv-backdrop)] backdrop-blur-sm animate-in fade-in duration-300 p-6",children:e.jsxs("div",{className:"relative w-full max-w-[340px] overflow-hidden rounded-2xl border border-[var(--sv-border-medium)] bg-card shadow-[var(--sv-shadow-dropdown)] animate-in zoom-in-95 duration-300",children:[e.jsx("div",{className:"absolute -top-20 left-1/2 -translate-x-1/2 h-40 w-40 rounded-full bg-accent/20 blur-3xl pointer-events-none"}),e.jsx("button",{onClick:o,className:"absolute right-3 top-3 z-10 rounded-full p-1.5 text-[var(--sv-text-tertiary)] hover:text-[var(--sv-text-primary)] hover:bg-[var(--sv-surface-hover)] transition-all duration-200","aria-label":"Fechar",children:e.jsx(Je,{className:"h-5 w-5"})}),e.jsxs("div",{className:"relative flex flex-col items-center gap-5 px-6 pt-8 pb-6 text-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-accent/15 animate-ping",style:{animationDuration:"2.5s"}}),e.jsx("div",{className:"relative flex h-[72px] w-[72px] items-center justify-center rounded-full bg-accent/10 border border-accent/20",children:e.jsx(Ms,{className:"h-8 w-8 text-accent"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-[18px] font-bold tracking-tight text-foreground",children:"Ative as notificações"}),e.jsx("p",{className:"text-[14px] leading-relaxed text-muted-foreground",children:"Seja avisado sobre os testes e seletivas, receba notificações importantes."})]}),e.jsxs("div",{className:"flex w-full flex-col gap-2.5 pt-1",children:[e.jsxs("button",{onClick:a,className:"group relative w-full h-[50px] rounded-xl bg-accent text-accent-foreground text-[15px] font-semibold tracking-wide overflow-hidden transition-all duration-200 hover:brightness-110 active:scale-[0.98]",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-white/0 via-white/10 to-white/0 translate-x-[-100%] group-hover:translate-x-[100%] transition-transform duration-700"}),e.jsxs("span",{className:"relative flex items-center justify-center gap-2",children:[e.jsx(Ac,{className:"h-4 w-4"}),"Ativar agora"]})]}),e.jsx("button",{onClick:o,className:"w-full h-10 rounded-xl text-[14px] text-muted-foreground hover:text-foreground hover:bg-[var(--sv-surface)] transition-all duration-200",children:"Agora não"})]})]})]})}):null}
162const ud="https://setverso.com";function fd(t){return Q(this,null,function*(){var s,a;if(!!((a=(s=window.Capacitor)==null?void 0:s.isNativePlatform)!=null&&a.call(s)))try{const{Browser:o}=yield Lt(()=>Q(this,null,function*(){const{Browser:i}=yield import("./index-DRoJQYoX.js");return{Browser:i}}),__vite__mapDeps([0,1,2,3,4,5]));yield o.open({url:t})}catch(o){window.open(t,"_blank","noopener,noreferrer")}else window.open(t,"_blank","noopener,noreferrer")})}function md(t){return`${ud}/membros/post/${t}`}function Zr(t,r){return Q(this,null,function*(){const s=md(t),a={title:r||"Post SetVerso",url:s};if(navigator.share)try{yield navigator.share(a)}catch(o){}else yield navigator.clipboard.writeText(s)})}var Ko={exports:{}},Xo={};/** 163 * @license React 164 * use-sync-external-store-shim.production.js 165 * 166 * Copyright (c) Meta Platforms, Inc. and affiliates. 167 * 168 * This source code is licensed under the MIT license found in the 169 * LICENSE file in the root directory of this source tree. 170 */var Gs=n;function pd(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var hd=typeof Object.is=="function"?Object.is:pd,xd=Gs.useState,gd=Gs.useEffect,vd=Gs.useLayoutEffect,bd=Gs.useDebugValue;function yd(t,r){var s=r(),a=xd({inst:{value:s,getSnapshot:r}}),o=a[0].inst,i=a[1];return vd(function(){o.value=s,o.getSnapshot=r,wn(o)&&i({inst:o})},[t,s,r]),gd(function(){return wn(o)&&i({inst:o}),t(function(){wn(o)&&i({inst:o})})},[t]),bd(s),s}function wn(t){var r=t.getSnapshot;t=t.value;try{var s=r();return!hd(t,s)}catch(a){return!0}}function wd(t,r){return r()}var jd=typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"?wd:yd;Xo.useSyncExternalStore=Gs.useSyncExternalStore!==void 0?Gs.useSyncExternalStore:jd;Ko.exports=Xo;var Nd=Ko.exports;function kd(){return Nd.useSyncExternalStore(_d,()=>!0,()=>!1)}function _d(){return()=>{}}var la="Avatar",[Sd]=mr(la),[Cd,Zo]=Sd(la),Jo=n.forwardRef((t,r)=>{const l=t,{__scopeAvatar:s}=l,a=xe(l,["__scopeAvatar"]),[o,i]=n.useState("idle");return e.jsx(Cd,{scope:s,imageLoadingStatus:o,onImageLoadingStatusChange:i,children:e.jsx(Ht.span,se(L({},a),{ref:r}))})});Jo.displayName=la;var Qo="AvatarImage",ei=n.forwardRef((t,r)=>{const g=t,{__scopeAvatar:s,src:a,onLoadingStatusChange:o=()=>{}}=g,i=xe(g,["__scopeAvatar","src","onLoadingStatusChange"]),l=Zo(Qo,s),f=Ed(a,i),p=rn(c=>{o(c),l.onImageLoadingStatusChange(c)});return Dn(()=>{f!=="idle"&&p(f)},[f,p]),f==="loaded"?e.jsx(Ht.img,se(L({},i),{ref:r,src:a})):null});ei.displayName=Qo;var ti="AvatarFallback",si=n.forwardRef((t,r)=>{const p=t,{__scopeAvatar:s,delayMs:a}=p,o=xe(p,["__scopeAvatar","delayMs"]),i=Zo(ti,s),[l,f]=n.useState(a===void 0);return n.useEffect(()=>{if(a!==void 0){const g=window.setTimeout(()=>f(!0),a);return()=>window.clearTimeout(g)}},[a]),l&&i.imageLoadingStatus!=="loaded"?e.jsx(Ht.span,se(L({},o),{ref:r})):null});si.displayName=ti;function Ca(t,r){return t?r?(t.src!==r&&(t.src=r),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Ed(t,{referrerPolicy:r,crossOrigin:s}){const a=kd(),o=n.useRef(null),i=a?(o.current||(o.current=new window.Image),o.current):null,[l,f]=n.useState(()=>Ca(i,t));return Dn(()=>{f(Ca(i,t))},[i,t]),Dn(()=>{const p=x=>()=>
170{f(x)};if(!i)return;const g=p("loaded"),c=p("error");return i.addEventListener("load",g),i.addEventListener("error",c),r&&(i.referrerPolicy=r),typeof s=="string"&&(i.crossOrigin=s),()=>{i.removeEventListener("load",g),i.removeEventListener("error",c)}},[i,s,r]),l}var ri=Jo,ni=ei,ai=si;const ut=n.forwardRef((a,s)=>{var o=a,{className:t}=o,r=xe(o,["className"]);return e.jsx(ri,L({ref:s,className:Be("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t)},r))});ut.displayName=ri.displayName;const Ze=n.forwardRef((a,s)=>{var o=a,{className:t}=o,r=xe(o,["className"]);return e.jsx(ni,L({ref:s,className:Be("aspect-square h-full w-full",t)},r))});Ze.displayName=ni.displayName;const ft=n.forwardRef((a,s)=>{var o=a,{className:t}=o,r=xe(o,["className"]);return e.jsx(ai,L({ref:s,className:Be("flex h-full w-full items-center justify-center rounded-full bg-muted",t)},r))});ft.displayName=ai.displayName;var Ea=!1,Ss,Ln,Fn,Br,qr,oi,Wr,On,$n,Bn,ii,qn,Wn,li,ci;function St(){if(!Ea){Ea=!0;var t=navigator.userAgent,r=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Ice
170weasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(t),s=/(Mac OS X)|(Windows)|(Linux)/.exec(t);if(qn=/\b(iPhone|iP[ao]d)/.exec(t),Wn=/\b(iP[ao]d)/.exec(t),Bn=/Android/i.exec(t),li=/FBAN\/\w+;/i.exec(t),ci=/Mobile/i.exec(t),ii=!!/Win64/.exec(t),r){Ss=r[1]?parseFloat(r[1]):r[5]?parseFloat(r[5]):NaN,Ss&&document&&document.documentMode&&(Ss=document.documentMode);var a=/(?:Trident\/(\d+.\d+))/.exec(t);oi=a?parseFloat(a[1])+4:Ss,Ln=r[2]?parseFloat(r[2]):NaN,Fn=r[3]?parseFloat(r[3]):NaN,Br=r[4]?parseFloat(r[4]):NaN,Br?(r=/(?:Chrome\/(\d+\.\d+))/.exec(t),qr=r&&r[1]?parseFloat(r[1]):NaN):qr=NaN}else Ss=Ln=Fn=qr=Br=NaN;if(s){if(s[1]){var o=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(t);Wr=o?parseFloat(o[1].replace("_",".")):!0}else Wr=!1;On=!!s[2],$n=!!s[3]}else Wr=On=$n=!1}}var Vn={ie:function(){return St()||Ss},ieCompatibilityMode:function(){return St()||oi>Ss},ie64:function(){return Vn.ie()&&ii},firefox:function(){return St()||Ln},opera:function(){return St()||Fn},webkit:function(){return St()||Br},safari:function(){return Vn.webkit()},chrome:function(){return St()||qr},windows:function(){return St()||On},osx:function(){return St()||Wr},linux:function(){return St()||$n},iphone:function(){return St()||qn},mobile:function(){return St()||qn||Wn||Bn||ci},nativeApp:function(){return St()||li},android:function(){return St()||Bn},ipad:function(){return St()||Wn}},Rd=Vn,Md=!!(typeof window!="undefined"&&window.document&&window.document.createElement),Ad={canUseDOM:Md},Pd=Ad,di=Pd,ui;di.canUseDOM&&(ui=document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("","")!==!0);/** 171 * Checks if an event is supported in the current execution environment. 172 * 173 * NOTE: This will not work correctly for non-generic events such as `change`, 174 * `reset`, `load`, `error`, and `select`. 175 * 176 * Borrows from Modernizr. 177 * 178 * @param {string} eventNameSuffix Event name, e.g. "click". 179 * @param {?boolean} capture Check if the capture phase is supported. 180 * @return {boolean} True if the event is supported. 181 * @internal 182 * @license Modernizr 3.0.0pre (Custom Build) | MIT 183 */function Td(t,r){if(!di.canUseDOM||r&&!("addEventListener"in document))return!1;var s="on"+t,a=s in document;if(!a){var o=document.createElement("div");o.setAttribute(s,"return;"),a=typeof o[s]=="function"}return!a&&ui&&t==="wheel"&&(a=document.implementation.hasFeature("Events.wheel","3.0")),a}var Dd=Td,zd=Rd,Id=Dd,Ra=10,Ma=40,Aa=800;function fi(t){var r=0,s=0,a=0,o=0;return"detail"in t&&(s=t.detail),"wheelDelta"in t&&(s=-t.wheelDelta/120),"wheelDeltaY"in t&&(s=-t.wheelDeltaY/120),"wheelDeltaX"in t&&(r=-t.wheelDeltaX/120),"axis"in t&&t.axis===t.HORIZONTAL_AXIS&&(r=s,s=0),a=r*Ra,o=s*Ra,"deltaY"in t&&(o=t.deltaY),"deltaX"in t&&(a=t.deltaX),(a||o)&&t.deltaMode&&(t.deltaMode==1?(a*=Ma,o*=Ma):(a*=Aa,o*=Aa)),a&&!r&&(r=a<1?-1:1),o&&!s&&(s=o<1?-1:1),{spinX:r,spinY:s,pixelX:a,pixelY:o}}fi.getEventType=function(){return zd.firefox()?"DOMMouseScroll":Id("wheel")?"wheel":"mousewheel"};var Ld=fi,Fd=Ld;const Od=Ec(Fd);function $d(t,r,s,a,o,i){i===void 0&&(i=0);var l=Ys(t,r,i),f=l.width,p=l.height,g=Math.min(f,s),c=Math.min(p,a);return g>c*o?{width:c*o,height:c}:{width:g,height:g/o}}function Bd(t){return t.width>t.height?t.width/t.naturalWidth:t.height/t.naturalHeight}function er(t,r,s,a,o){o===void 0&&(o=0);var i=Ys(r.width,r.height,o),l=i.width,f=i.height;return{x:Pa(t.x,l,s.width,a),y:Pa(t.y,f,s.height,a)}}function Pa(t,r,s,a){var o=r*a/2-s/2;return cn(t,-o,o)}function Ta(t,r){return Math.sqrt(Math.pow(t.y-r.y,2)+Math.pow(t.x-r.x,2))}function Da(t,r){return Math.atan2(r.y-t.y,r.x-t.x)*180/Math.PI}function qd(t,r,s,a,o,i,l){i===void 0&&(i=0),l===void 0&&(l=!0);var f=l?Wd:Vd,p=Ys(r.width,r.height,i),g=Ys(r.naturalWidth,r.naturalHeight,i),c={x:f(100,((p.width-s.width/o)/2-t.x/o)/p.width*100),y:f(100,((p.height-s.height/o)/2-t.y/o)/p.height*100),width:f(100,s.width/p.width*100/o),height:f(100,s.height/p.height*100/o)},x=Math.round(f(g.width,c.width*g.width/100)),d=Math.round(f(g.height,c.height*g.height/100)),u=g.width>=g.height*a,m=u?{width:Math.round(d*a),height:d}:{width:x,height:Math.round(x/a)},b=gt(gt({},m),{x:Math.round(f(g.width-m.width,c.x*g.width/100)),y:Math.round(f(g.height-m.height,c.y*g.height/100))});return{croppedAreaPercentages:c,croppedAreaPixels:b}}function Wd(t,r){return Math.min(t,Math.max(0,r))}function Vd(t,r){return r}function Hd(t,r,s,a,o,i){var l=Ys(r.width,r.height,s),f=cn(a.width/l.width*(100/t.width),o,i),p={x:f*l.width/2-a.width/2-l.width*f*(t.x/100),y:f*l.height/2-a.height/2-l.height*f*(t.y/100)};return{crop:p,zoom:f}}function Ud(t,r,s){var a=Bd(r);return s.height>s.width?s.height/(t.height*a):s.width/(t.width*a)}function Gd(t,r,s,a,o,i){s===void 0&&(s=0);
183var l=Ys(r.naturalWidth,r.naturalHeight,s),f=cn(Ud(t,r,a),o,i),p=a.height>a.width?a.height/t.height:a.width/t.width,g={x:((l.width-t.width)/2-t.x)*p,y:((l.height-t.height)/2-t.y)*p};return{crop:g,zoom:f}}function za(t,r){return{x:(r.x+t.x)/2,y:(r.y+t.y)/2}}function Yd(t){return t*Math.PI/180}function Ys(t,r,s){var a=Yd(s);return{width:Math.abs(Math.cos(a)*t)+Math.abs(Math.sin(a)*r),height:Math.abs(Math.sin(a)*t)+Math.abs(Math.cos(a)*r)}}function cn(t,r,s){return Math.min(Math.max(t,r),s)}function Er(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return t.filter(function(s){return typeof s=="string"&&s.length>0}).join(" ").trim()}var Kd=`.reactEasyCrop_Container { 184 position: absolute; 185 top: 0; 186 left: 0; 187 right: 0; 188 bottom: 0; 189 overflow: hidden; 190 user-select: none; 191 touch-action: none; 192 cursor: move; 193 display: flex; 194 justify-content: center; 195 align-items: center; 196} 197 198.reactEasyCrop_Image, 199.reactEasyCrop_Video { 200 will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */ 201} 202 203.reactEasyCrop_Contain { 204 max-width: 100%; 205 max-height: 100%; 206 margin: auto; 207 position: absolute; 208 top: 0; 209 bottom: 0; 210 left: 0; 211 right: 0; 212} 213.reactEasyCrop_Cover_Horizontal { 214 width: 100%; 215 height: auto; 216} 217.reactEasyCrop_Cover_Vertical { 218 width: auto; 219 height: 100%; 220} 221 222.reactEasyCrop_CropArea { 223 position: absolute; 224 left: 50%; 225 top: 50%; 226 transform: translate(-50%, -50%); 227 border: 1px solid rgba(255, 255, 255, 0.5); 228 box-sizing: border-box; 229 box-shadow: 0 0 0 9999em; 230 color: rgba(0, 0, 0, 0.5); 231 overflow: hidden; 232} 233 234.reactEasyCrop_CropAreaRound { 235 border-radius: 50%; 236} 237 238.reactEasyCrop_CropAreaGrid::before { 239 content: ' '; 240 box-sizing: border-box; 241 position: absolute; 242 border: 1px solid rgba(255, 255, 255, 0.5); 243 top: 0; 244 bottom: 0; 245 left: 33.33%; 246 right: 33.33%; 247 border-top: 0; 248 border-bottom: 0; 249} 250 251.reactEasyCrop_CropAreaGrid::after { 252 content: ' '; 253 box-sizing: border-box; 254 position: absolute; 255 border: 1px solid rgba(255, 255, 255, 0.5); 256 top: 33.33%; 257 bottom: 33.33%; 258 left: 0; 259 right: 0; 260 border-left: 0; 261 border-right: 0; 262} 263`,Xd=1,Zd=3,Jd=1,Qd=function(t){mc(r,t);function r(){var s=t!==null&&t.apply(this,arguments)||this;return s.cropperRef=n.createRef(),s.imageRef=n.createRef(),s.videoRef=n.createRef(),s.containerPosition={x:0,y:0},s.containerRef=null,s.styleRef=null,s.containerRect=null,s.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},s.dragStartPosition={x:0,y:0},s.dragStartCrop={x:0,y:0},s.gestureZoomStart=0,s.gestureRotationStart=0,s.isTouching=!1,s.lastPinchDistance=0,s.lastPinchRotation=0,s.rafDragTimeout=null,s.rafPinchTimeout=null,s.wheelTimer=null,s.currentDoc=typeof document!="undefined"?document:null,s.currentWindow=typeof window!="undefined"?window:null,s.resizeObserver=null,s.previousCropSize=null,s.isInitialized=!1,s.state={cropSize:null,hasWheelJustStarted:!1,mediaObjectFit:void 0},s.initResizeObserver=function(){if(!(typeof window.ResizeObserver=="undefined"||!s.containerRef)){var a=!0;s.resizeObserver=new window.ResizeObserver(function(o){if(a){a=!1;return}s.computeSizes()}),s.resizeObserver.observe(s.containerRef)}},s.preventZoomSafari=function(a){return a.preventDefault()},s.cleanEvents=function(){s.currentDoc&&(s.currentDoc.removeEventListener("mousemove",s.onMouseMove),s.currentDoc.removeEventListener("mouseup",s.onDragStopped),s.currentDoc.removeEventListener("touchmove",s.onTouchMove),s.currentDoc.removeEventListener("touchend",s.onDragStopped),s.currentDoc.removeEventListener("gesturechange",s.onGestureChange),s.currentDoc.removeEventListener("gestureend",s.onGestureEnd),s.currentDoc.removeEventListener("scroll",s.onScroll))},s.clearScrollEvent=function(){s.containerRef&&s.containerRef.removeEventListener("wheel",s.onWheel),s.wheelTimer&&clearTimeout(s.wheelTimer)},s.onMediaLoad=function(){var a=s.computeSizes();a&&(s.previousCropSize=a,s.emitCropData(),s.setInitialCrop(a),s.isInitialized=!0),s.props.onMediaLoaded&&s.props.onMediaLoaded(s.mediaSize)},s.setInitialCrop=function(a){if(s.props.initialCroppedAreaPercentages){var o=Hd(s.props.initialCroppedAreaPercentages,s.mediaSize,s.props.rotation,a,s.props.minZoom,s.props.maxZoom),i=o.crop,l=o.zoom;s.props.onCropChange(i),s.props.onZoomChange&&s.props.onZoomChange(l)}else if(s.props.initialCroppedAreaPixels){var f=Gd(s.props.initialCroppedAreaPixels,s.mediaSize,s.props.rotation,a,s.props.minZoom,s.props.maxZoom),i=f.crop,l=f.zoom;s.props.onCropChange(i),s.props.onZoomChange&&s.props.onZoomChange(l)}},s.computeSizes=function(){var a,o,i,l,f,p,g=s.imageRef.current||s.videoRef.current;if(g&&s.containerRef){s.containerRect=s.containerRef.getBoundingClientRect(),s.saveContainerPosition();var c=s.containerRect.width/s.containerRect.height,x=((a=s.imageRef.current)===null||a===void 0?void 0:a.naturalWi
263dth)||((o=s.videoRef.current)===null||o===void 0?void 0:o.videoWidth)||0,d=((i=s.imageRef.current)===null||i===void 0?void 0:i.naturalHeight)||((l=s.videoRef.current)===null||l===void 0?void 0:l.videoHeight)||0,u=g.offsetWidth<x||g.offsetHeight<d,m=x/d,b=void 0;if(u)switch(s.state.mediaObjectFit){default:case"contain":b=c>m?{width:s.containerRect.height*m,height:s.containerRect.height}:{width:s.containerRect.width,height:s.containerRect.width/m};break;case"horizontal-cover":b={width:s.containerRect.width,height:s.containerRect.width/m};break;case"vertical-cover":b={width:s.containerRect.height*m,height:s.containerRect.height};break}else b={width:g.offsetWidth,height:g.offsetHeight};s.mediaSize=gt(gt({},b),{naturalWidth:x,naturalHeight:d}),s.props.setMediaSize&&s.props.setMediaSize(s.mediaSize);var v=s.props.cropSize?s.props.cropSize:$d(s.mediaSize.width,s.mediaSize.height,s.containerRect.width,s.containerRect.height,s.props.aspect,s.props.rotation);return(((f=s.state.cropSize)===null||f===void 0?void 0:f.height)!==v.height||((p=s.state.cropSize)===null||p===void 0?void 0:p.width)!==v.width)&&s.props.onCropSizeChange&&s.props.onCropSizeChange(v),s.setState({cropSize:v},s.recomputeCropPosition),s.props.setCropSize&&s.props.setCropSize(v),v}},s.saveContainerPosition=function(){if(s.containerRef){var a=s.containerRef.getBoundingClientRect();s.containerPosition={x:a.left,y:a.top}}},s.onMouseDown=function(a){s.currentDoc&&(a.preventDefault(),s.currentDoc.addEventListener("mousemove",s.onMouseMove),s.currentDoc.addEventListener("mouseup",s.onDragStopped),s.saveContainerPosition(),s.onDragStart(r.getMousePoint(a)))},s.onMouseMove=function(a){return s.onDrag(r.getMousePoint(a))},s.onScroll=function(a){s.currentDoc&&(a.preventDefault(),s.saveContainerPosition())},s.onTouchStart=function(a){s.currentDoc&&(s.isTouching=!0,!(s.props.onTouchRequest&&!s.props.onTouchRequest(a))&&(s.currentDoc.addEventListener("touchmove",s.onTouchMove,{passive:!1}),s.currentDoc.addEventListener("touchend",s.onDragStopped),s.saveContainerPosition(),a.touches.length===2?s.onPinchStart(a):a.touches.length===1&&s.onDragStart(r.getTouchPoint(a.touches[0]))))},s.onTouchMove=function(a){a.preventDefault(),a.touches.length===2?s.onPinchMove(a):a.touches.length===1&&s.onDrag(r.getTouchPoint(a.touches[0]))},s.onGestureStart=function(a){s.currentDoc&&(a.preventDefault(),s.currentDoc.addEventListener("gesturechange",s.onGestureChange),s.currentDoc.addEventListener("gestureend",s.onGestureEnd),s.gestureZoomStart=s.props.zoom,s.gestureRotationStart=s.props.rotation)},s.onGestureChange=function(a){if(a.preventDefault(),!s.isTouching){var o=r.getMousePoint(a),i=s.gestureZoomStart-1+a.scale;if(s.setNewZoom(i,o,{shouldUpdatePosition:!0}),s.props.onRotationChange){var l=s.gestureRotationStart+a.rotation;s.props.onRotationChange(l)}}},s.onGestureEnd=function(a){s.cleanEvents()},s.onDragStart=function(a){var o,i,l=a.x,f=a.y;s.dragStartPosition={x:l,y:f},s.dragStartCrop=gt({},s.props.crop),(i=(o=s.props).onInteractionStart)===null||i===void 0||i.call(o)},s.onDrag=function(a){var o=a.x,i=a.y;s.currentWindow&&(s.rafDragTimeout&&s.currentWindow.cancelAnimationFrame(s.rafDragTimeout),s.rafDragTimeout=s.currentWindow.requestAnimationFrame(function(){if(s.state.cropSize&&!(o===void 0||i===void 0)){var l=o-s.dragStartPosition.x,f=i-s.dragStartPosition.y,p={x:s.dragStartCrop.x+l,y:s.dragStartCrop.y+f},g=s.props.restrictPosition?er(p,s.mediaSize,s.state.cropSize,s.props.zoom,s.props.rotation):p;s.props.onCropChange(g)}}))},s.onDragStopped=function(){var a,o;s.isTouching=!1,s.cleanEvents(),s.emitCropData(),(o=(a=s.props).onInteractionEnd)===null||o===void 0||o.call(a)},s.onWheel=function(a){if(s.currentWindow&&!(s.props.onWheelRequest&&!s.props.onWheelRequest(a))){a.preventDefault();var o=r.getMousePoint(a),i=Od(a).pixelY,l=s.props.zoom-i*s.props.zoomSpeed/200;s.setNewZoom(l,o,{shouldUpdatePosition:!0}),s.state.hasWheelJustStarted||s.setState({hasWheelJustStarted:!0},function(){var f,p;return(p=(f=s.props).onInteractionStart)===null||p===void 0?void 0:p.call(f)}),s.wheelTimer&&clearTimeout(s.wheelTimer),s.wheelTimer=s.currentWindow.setTimeout(function(){return s.setState({hasWheelJustStarted:!1},function(){var f,p;return(p=(f=s.props).onInteractionEnd)===null||p===void 0?void 0:p.call(f)})},250)}},s.getPointOnContainer=function(a,o){var i=a.x,l=a.y;if(!s.containerRect)throw new Error("The Cropper is not mounted");return{x:s.containerRect.width/2-(i-o.x),y:s.containerRect.height/2-(l-o.y)}},s.getPointOnMedia=function(a){var o=a.x,i=a.y,l=s.props,f=l.crop,p=l.zoom;return{x:(o+f.x)/p,y:(i+f.y)/p}},s.setNewZoom=function(a,o,i){var l=i===void 0?{}:i,f=l.shouldUpdatePosition,p=f===void 0?!0:f;if(!(!s.state.cropSize||!s.props.onZoomChange)){var g=cn(a,s.props.minZoom,s.props.maxZoom);if(p){var c=s.getPointOnContainer(o,s.containerPosition),x=s.getPointOnMedia(c),d={x:x.x*g-c.x,y:x.y*g-c.y},u=s.props.restrictPosition?er(d,s.mediaSize,s.state.cropSize,g,s.props.rotation):d;s.props.onCropChange(u)}s.props.onZoomChange(g)}},s.getCropData=function(){if(!s.state.cropSize)return null;var a=s.props.restrictPosition?er(s.props.crop,s.mediaSize,s.state.cropSize,s.props.zoom,s.props.rotation):s.props.crop;return qd(a,s.mediaSize,s.state.cropSize,s.getAspect(),s.props.zoom,s.props.rotation,s.props.restrictPosition)},s.emitCropData=function(){var a=s.getCropData();if(a){var o=a.croppedAreaPercentages,i=a.croppedAreaPixels;s.props.onCropComplete&&s.props.onCropComplete(o,i),s.props.onCropAreaChange&&s.props.onCropAreaChange(o,i)}},s.emitCropAreaChange=function(){var a=s.getCropData();if(a){var o=a.croppedAreaPercentages,i=a.croppedAreaPixels;s.props.onCropAreaChange&&s.props.onCropAreaChange(o,i)}},s.recomputeCropPosition=function(){var a,o;if(s.state.cropSize){var i=s.props.crop;if(s.isInitialized&&(!((a=s.previousCropSize)===null||a===void 0)&&a.width)&&(!((o=s.previousCropSize)===null||o===void 0)&&o.height)){var l=Math.abs(s.previousCropSize.width-s.state.cropSize.width)>1e-6||Math.abs(s.previousCropSize.height-s.state.cropSize.height)>1e-6;if(l){var f=s.state.cropSize.width/s.previousCropSize.width,p=s.state.cropSize.height/s.previousCropSize.height;i={x:s.props.crop.x*f,y:s.props.crop.y*p}}}var g=s.props.restrictPosition?er(i,s.mediaSize,s.state.cropSize,s.props.zoom,s.props.rotation):i;s.previousCropSize=s.state.cropSize,s.props.onCropChange(g),s.emitCropData()}},s.onKeyDown=function(a){var o,i,l=s.props,f=l.crop,p=l.onCropChange,g=l.keyboardStep,c=l.zoom,x=l.rotation,d=g;if(s.state.cropSize){a.shiftKey&&(d*=.2);var u=gt({},f);switch(a.key){case"ArrowUp":u.y-=d,a.preventDefault();break;case"ArrowDown":u.y+=d,a.preventDefault();break;case"ArrowLeft":u.x-=d,a.preventDefault();break;case"ArrowRight":u.x+=d,a.preventDefault();break;default:return}s.props.restrictPosition&&(u=er(u,s.mediaSize,s.state.cropSize,c,x)),a.repeat||(i=(o=s.props).onInteractionStart)===null||i===void 0||i.call(o),p(u)}},s.onKeyUp=function(a){var o,i;switch(a.key){case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":a.preventDefault();break;default:return}s.emitCropData(),(i=(o=s.props).onInteractionEnd)===null||i===void 0||i.call(o)},s}return r.prototype.componentDidMount=function(){!this.currentDoc||!this.currentWindow||(this.containerRef&&(this.containerRef.ownerDocument&&(this.currentDoc=this.containerRef.ownerDocument),this.currentDoc.defaultView&&(this.currentWindow=this.currentDoc.defaultView),this.initResizeObserver(),typeof window.ResizeObserver=="undefined"&&this.currentWindow.addEventListener("resize",this.computeSizes),this.props.zoomWithScroll&&this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}),this.containerRef.addEventListener("gesturestart",this.onGestureStart)),this.currentDoc.addEventListener("scroll",this.onScroll),this.props.disableAutomaticStylesInjection||(this.styleRef=this.currentDoc.createElement("style"),this.styleRef.setAttribute("type","text/css"),this.props.nonce&&this.styleRef.setAttribute("nonce",this.props.nonce),this.styleRef.innerHTML=Kd,this.currentDoc.head.appendChild(this.styleRef)),this.imageRef.current&&this.imageRef.current.complete&&this.onMediaLoad(),this.props.setImageRef&&this.props.setImageRef(this.imageRef),this.props.setVideoRef&&this.props.setVideoRef(this.videoRef),this.props.setCropperRef&&this.props.setCropperRef(this.cropperRef))},r.prototype.componentWillUnmount=function(){var s,a;!this.currentDoc||!this.currentWindow||(typeof window.ResizeObserver=="undefined"&&this.currentWindow.removeEventListener("resize",this.computeSizes),(s=this.resizeObserver)===null||s===void 0||s.disconnect(),this.containerRef&&this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.styleRef&&((a=this.styleRef.parentNode)===null||a===void 0||a.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},r.prototype.componentDidUpdate=function(s){var a,o,i,l,f,p,g,c,x;s.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):s.aspect!==this.props.aspect?this.computeSizes():s.objectFit!==this.props.objectFit?this.computeSizes():s.zoom!==this.props.zoom?this.recomputeCropPosition():((a=s.cropSize)===null||a===void 0?void 0:a.height)!==((o=this.props.cropSize)===null||o===void 0?void 0:o.height)||((i=s.cropSize)===null||i===void 0?void 0:i.width)!==((l=this.props.cropSize)===null||l===void 0?void 0:l.width)?this.computeSizes():(((f=s.crop)===null||f===void 0?void 0:f.x)!==((p=this.props.crop)===null||p===void 0?void 0:p.x)||((g=s.crop)===null||g===void 0?void 0:g.y)!==((c=this.props.crop)===null||c===void 0?void 0:c.y))&&this.emitCropAreaChange(),s.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}):this.clearScrollEvent()),s.video!==this.props.video&&((x=this.videoRef.current)===null||x===void 0||x.load());var d=this.getObjectFit();d!==this.state.mediaObjectFit&&this.setState({mediaObjectFit:d},this.computeSizes)},r.prototype.getAspect=function(){var s=this.props,a=s.cropSize,o=s.aspect;return a?a.width/a.height:o},r.prototype.getObjectFit=function(){var s,a,o,i;if(this.props.objectFit==="cover"){var l=this.imageRef.current||this.videoRef.current;if(l&&this.containerRef){this.containerRect=this.containerRef.getBoundingClientRect();var f=this.containerRect.width/this.containerRect.height,p=((s=this.imageRef.current)===null||s===void 0?void 0:s.naturalWi
263dth)||((a=this.videoRef.current)===null||a===void 0?void 0:a.videoWidth)||0,g=((o=this.imageRef.current)===null||o===void 0?void 0:o.naturalHeight)||((i=this.videoRef.current)===null||i===void 0?void 0:i.videoHeight)||0,c=p/g;return c<f?"horizontal-cover":"vertical-cover"}return"horizontal-cover"}return this.props.objectFit},r.prototype.onPinchStart=function(s){var a=r.getTouchPoint(s.touches[0]),o=r.getTouchPoint(s.touches[1]);this.lastPinchDistance=Ta(a,o),this.lastPinchRotation=Da(a,o),this.onDragStart(za(a,o))},r.prototype.onPinchMove=function(s){var a=this;if(!(!this.currentDoc||!this.currentWindow)){var o=r.getTouchPoint(s.touches[0]),i=r.getTouchPoint(s.touches[1]),l=za(o,i);this.onDrag(l),this.rafPinchTimeout&&this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout),this.rafPinchTimeout=this.currentWindow.requestAnimationFrame(function(){var f=Ta(o,i),p=a.props.zoom*(f/a.lastPinchDistance);a.setNewZoom(p,l,{shouldUpdatePosition:!1}),a.lastPinchDistance=f;var g=Da(o,i),c=a.props.rotation+(g-a.lastPinchRotation);a.props.onRotationChange&&a.props.onRotationChange(c),a.lastPinchRotation=g})}},r.prototype.render=function(){var s=this,a,o=this.props,i=o.image,l=o.video,f=o.mediaProps,p=o.cropperProps,g=o.transform,c=o.crop,x=c.x,d=c.y,u=o.rotation,m=o.zoom,b=o.cropShape,v=o.showGrid,w=o.roundCropAreaPixels,_=o.style,y=_.containerStyle,k=_.cropAreaStyle,E=_.mediaStyle,S=o.classes,R=S.containerClassName,z=S.cropAreaClassName,j=S.mediaClassName,M=(a=this.state.mediaObjectFit)!==null&&a!==void 0?a:this.getObjectFit();return n.createElement("div",{onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,ref:function(q){return s.containerRef=q},"data-testid":"container",style:y,className:Er("reactEasyCrop_Container",R)},i?n.createElement("img",gt({alt:"",className:Er("reactEasyCrop_Image",M==="contain"&&"reactEasyCrop_Contain",M==="horizontal-cover"&&"reactEasyCrop_Cover_Horizontal",M==="vertical-cover"&&"reactEasyCrop_Cover_Vertical",j)},f,{src:i,ref:this.imageRef,style:gt(gt({},E),{transform:g||"translate(".concat(x,"px, ").concat(d,"px) rotate(").concat(u,"deg) scale(").concat(m,")")}),onLoad:this.onMediaLoad})):l&&n.createElement("video",gt({autoPlay:!0,playsInline:!0,loop:!0,muted:!0,className:Er("reactEasyCrop_Video",M==="contain"&&"reactEasyCrop_Contain",M==="horizontal-cover"&&"reactEasyCrop_Cover_Horizontal",M==="vertical-cover"&&"reactEasyCrop_Cover_Vertical",j)},f,{ref:this.videoRef,onLoadedMetadata:this.onMediaLoad,style:gt(gt({},E),{transform:g||"translate(".concat(x,"px, ").concat(d,"px) rotate(").concat(u,"deg) scale(").concat(m,")")}),controls:!1}),(Array.isArray(l)?l:[{src:l}]).map(function($){return n.createElement("source",gt({key:$.src},$))})),this.state.cropSize&&n.createElement("div",gt({ref:this.cropperRef,style:gt(gt({},k),{width:w?Math.round(this.state.cropSize.width):this.state.cropSize.width,height:w?Math.round(this.state.cropSize.height):this.state.cropSize.height}),tabIndex:0,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp,"data-testid":"cropper",className:Er("reactEasyCrop_CropArea",b==="round"&&"reactEasyCrop_CropAreaRound",v&&"reactEasyCrop_CropAreaGrid",z)},p)))},r.defaultProps={zoom:1,rotation:0,aspect:4/3,maxZoom:Zd,minZoom:Xd,cropShape:"rect",objectFit:"contain",showGrid:!0,style:{},classes:{},mediaProps:{},cropperProps:{},zoomSpeed:1,restrictPosition:!0,zoomWithScroll:!0,keyboardStep:Jd},r.getMousePoint=function(s){return{x:Number(s.clientX),y:Number(s.clientY)}},r.getTouchPoint=function(s){return{x:Number(s.clientX),y:Number(s.clientY)}},r}(n.Component);const eu=1080;function jn(t,r,s){return new Promise(a=>t.toBlob(o=>a(o),r,s))}function tu(t,r){return Q(this,null,function*(){const s=yield new Promise((g,c)=>{const x=new Image;x.crossOrigin="anonymous",x.onload=()=>g(x),x.onerror=()=>c(new Error("Failed to load image")),x.src=t}),a=Math.min(r.width,r.height),o=Math.max(1,Math.min(eu,Math.round(a))),i=document.createElement("canvas");i.width=o,i.height=o;const l=i.getContext("2d");if(!l)throw new Error("Canvas not supported");l.fillStyle="#ffffff",l.fillRect(0,0,o,o),l.drawImage(s,r.x,r.y,r.width,r.height,0,0,o,o);const f=800*1024;let p=yield jn(i,"image/webp",.82);if(p&&p.type==="image/webp"){if(p.size>f){const g=yield jn(i,"image/webp",.7);g&&g.type==="image/webp"&&(p=g)}return{blob:p,ext:"webp",contentType:"image/webp"}}if(p=yield jn(i,"image/jpeg",.85),!p)throw new Error("Crop failed");return{blob:p,ext:"jpg",contentType:"image/jpeg"}})}function su({imageSrc:t,onCropDone:r,onClose:s}){const[a,o]=n.useState({x:0,y:0}),[i,l]=n.useState(1),[f,p]=n.useState(null),[g,c]=n.useState(!1),[x,d]=n.useState(!1),[u,m]=n.useState(!1),b=n.useCallback((_,y)=>{p(y)},[]),v=n.useCallback(()=>{console.debug("[AvatarCrop] media loaded"),d(!0),m(!1)},[]);n.useEffect(()=>{d(!1),m(!1);const _=setTimeout(()=>{d(y=>(y||(console.warn("[AvatarCrop] image load timed out"),m(!0)),y))},3e4);return()=>clearTimeout(_)},[t]);const w=()=>Q(this,null,function*(){if(!(!f||!x)){c(!0);try{const _=yield tu(t,f);r(_)}catch(_){console.error("[AvatarCrop] crop failed:",_),m(!0)}finally{c(!1)}}});return e.jsxs("div",{style:{position:"fixed",inset:0,zIndex:1e5,background:"rgb(0,0,0)",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"max(env(safe-area-inset-top, 12px), 12px) 16px 12px",flexShrink:0},children:[e.jsx("button",{onClick:s,style:{width:40,height:40,borderRadius:"50%",background:"rgba(255,255,255,0.1)",border:"1px solid rgba(255,255,255,0.15)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"white"},children:e.jsx(Je,{size:18})}),e.jsx("p",{style:{fontSize:16,fontWeight:800,color:"white"},children:"Ajustar foto"}),e.jsx("button",{onClick:w,disabled:g||!x||u,style:{width:40,height:40,borderRadius:"50%",background:"hsl(var(--setverso-red))",border:"none",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"white",opacity:g||!x||u?.5:1},children:e.jsx(ia,{size:18})})]}),e.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,width:"100%"},children:[!u&&e.jsx(Qd,{image:t,crop:a,zoom:i,aspect:1,cropShape:"round",showGrid:!1,onCropChange:o,onZoomChange:l,onCropComplete:b,onMediaLoaded:v,minZoom:1,maxZoom:5,objectFit:"contain",style:{containerStyle:{background:"rgb(0,0,0)",width:"100%",height:"100%"}
263,cropAreaStyle:{border:"2px solid rgba(255,255,255,0.6)",boxShadow:"0 0 0 9999px rgba(0,0,0,0.7)"}}}),!x&&!u&&e.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",color:"rgba(255,255,255,0.7)",gap:10,fontSize:13},children:[e.jsx(dr,{size:18,className:"animate-spin"}),"Carregando imagem..."]}),u&&e.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:24,textAlign:"center",gap:16,color:"white"},children:[e.jsx("p",{style:{fontSize:15,fontWeight:700,lineHeight:1.4},children:"Não foi possÃvel abrir essa foto."}),e.jsx("p",{style:{fontSize:13,color:"rgba(255,255,255,0.65)",maxWidth:280,lineHeight:1.5},children:"Tente outra imagem em JPG, PNG ou WEBP. Fotos HEIC (iPhone) precisam ser convertidas antes."}),e.jsx("button",{onClick:s,style:{marginTop:8,padding:"10px 20px",borderRadius:999,background:"hsl(var(--setverso-red))",color:"white",fontWeight:700,fontSize:13,border:"none",cursor:"pointer"},children:"Escolher outra foto"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"16px 24px",paddingBottom:"max(env(safe-area-inset-bottom, 16px), 16px)",flexShrink:0,opacity:x&&!u?1:.4,pointerEvents:x&&!u?"auto":"none"},children:[e.jsx(id,{size:16,style:{color:"rgba(255,255,255,0.4)",flexShrink:0}}),e.jsx("input",{type:"range",min:1,max:5,step:.05,value:i,onChange:_=>l(Number(_.target.value)),style:{flex:1,height:4,appearance:"none",WebkitAppearance:"none",background:`linear-gradient(to right, hsl(var(--setverso-red)) ${(i-1)/4*100}%, rgba(255,255,255,0.15) ${(i-1)/4*100}%)`,borderRadius:4,outline:"none",cursor:"pointer"}}),e.jsx(od,{size:16,style:{color:"rgba(255,255,255,0.4)",flexShrink:0}})]})]})}let Rr=[];function ru(){return Q(this,null,function*(){if(Rr.length>0)return Rr;try{return Rr=(yield(yield fetch("https://servicodados.ibge.gov.br/api/v1/localidades/municipios?orderBy=nome")).json()).map(s=>{var a,o,i,l;return{name:s.nome,state:(l=(i=(o=(a=s.microrregiao)==null?void 0:a.mesorregiao)==null?void 0:o.UF)==null?void 0:i.sigla)!=null?l:""}}
263),Rr}catch(t){return[]}})}function nu({value:t,onChange:r,onValidChange:s,placeholder:a}){const[o,i]=n.useState([]),[l,f]=n.useState(!1),[p,g]=n.useState([]),[c,x]=n.useState(!1),d=n.useRef(null),u=n.useRef(null),[m,b]=n.useState({top:0,left:0,width:0});n.useEffect(()=>{ru().then(g)},[]),n.useEffect(()=>{if(t&&t.includes(" - ")&&p.length>0){const[E,S]=t.split(" - ");p.some(z=>z.name===(E==null?void 0:E.trim())&&z.state===(S==null?void 0:S.trim()))&&x(!0)}},[p,t]);const v=n.useCallback(()=>{if(d.current){const E=d.current.getBoundingClientRect();b({top:E.bottom+4,left:E.left,width:E.width})}},[]),w=n.useCallback(E=>{if(r(E),x(!1),s==null||s(!1),E.trim().length<2){i([]),f(!1);return}const S=E.trim().toLowerCase(),R=p.filter(z=>z.name.toLowerCase().includes(S)).slice(0,8);i(R),f(R.length>0),v()},[p,r,s,v]),_=E=>{r(`${E.name} - ${E.state}`),x(!0),s==null||s(!0),f(!1),i([])};n.useEffect(()=>{const E=S=>{u.current&&!u.current.contains(S.target)&&f(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]),n.useEffect(()=>{if(!l)return;const E=()=>v();return window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[l,v]);const y=t.trim().length>=2&&!c,k=l&&o.length>0?Xt.createPortal(e.jsx("div",{className:"fixed rounded-xl overflow-hidden max-h-52 overflow-y-auto bg-popover border border-border shadow-lg",style:{top:m.top,left:m.left,width:m.width,zIndex:999999},onMouseDown:E=>E.preventDefault(),children:o.map((E,S)=>e.jsxs("button",{type:"button",onClick:()=>_(E),className:"w-full text-left px-4 py-3 text-sm text-popover-foreground transition-colors hover:bg-accent hover:text-accent-foreground active:bg-accent flex items-center gap-2",style:{borderBottom:S<o.length-1?"1px solid hsl(var(--border))":"none"},children:[e.jsx(In,{size:13,className:"text-muted-foreground shrink-0"}),e.jsxs("span",{children:[E.name,e.jsxs("span",{className:"text-muted-foreground ml-1",children:["- ",E.state]})]})]},`${E.name}-${E.state}-${S}`))}),document.body):null;return e.jsxs("div",{ref:u,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{ref:d,type:"text",value:t,onChange:E=>w(E.target.value),onFocus:()=>{o.length>0&&(v(),f(!0))},placeholder:a||"São Paulo, SP",className:"flex-1 w-full bg-transparent text-sm text-foreground placeholder:text-muted-foreground/60 outline-none"}),c&&e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded-md shrink-0",style:{background:"rgba(34,197,94,0.15)",color:"rgb(74,222,128)",border:"1px solid rgba(34,197,94,0.3)"},children:"â"})]}),y&&e.jsxs("p",{className:"text-[11px] mt-1.5 flex items-center gap-1",style:{color:"rgba(245,158,11,0.8)"},children:[e.jsx(In,{size:10}),"Selecione uma cidade da lista"]}),k]})}function au(t){return!!(t&&t.includes(" - "))}const Ia=Se;function mi({open:t,onClose:r,userProfile:s,userId:a,onProfileUpdated:o,embedded:i}){const[l,f]=n.useState({}),[p,g]=n.useState(""),[c,x]=n.useState(!1),[d,u]=n.useState(!1),[m,b]=n.useState(""),v=n.useRef(null),[w,_]=n.useState(null),y=Ks(),k=n.useRef(!1),{fields:E,loading:S}=Pc();n.useEffect(()=>{t&&Se.auth.getUser().then(({data:P})=>{var N,Y;b((Y=(N=P.user)==null?void 0:N.email)!=null?Y:"")})},[t]),t&&(k.current=!0);const R=E.filter(P=>P.enabled&&P.show_on_edit);n.useEffect(()=>{var P;if(t&&s){const N={},Y=E.filter(F=>F.enabled&&F.show_on_edit);Y.forEach(F=>{const G=s[F.field_key];N[F.field_key]=typeof G=="string"?G:""}),console.debug("[EditProfileSheet] fields:",Y.length,"formData keys:",Object.keys(N)),f(N),g((P=s.avatar_url)!=null?P:"")}},[t,s,E]);const z=(P,N)=>{f(Y=>se(L({},Y),{[P]:N}))},j=P=>Q(this,null,function*(){var ge,le;const N=(ge=P.target.files)==null?void 0:ge[0];if(console.debug("[Avatar] file selected:",N==null?void 0:N.name,N==null?void 0:N.type,N==null?void 0:N.size),P.target.value="",!N)return;const Y=(N.name||"").toLowerCase(),F=(N.type||"").toLowerCase(),G=F.includes("heic")||F.includes("heif")||Y.endsWith(".heic")||Y.endsWith(".heif");
263if(N.size>50*1024*1024){Ie.error("Imagem muito grande. Máximo 50 MB.");return}const ee=N.size>8*1024*1024,re="avatar-prep";G?Ie.loading("Convertendo foto do iPhone...",{id:re}):ee&&Ie.loading("Preparando foto...",{id:re});const be=fe=>{Ie.dismiss(re),_(fe)};try{const{prepareImageFile:fe,blobToDataUrl:pe}=yield Lt(()=>Q(this,null,function*(){const{prepareImageFile:Z,blobToDataUrl:me}=yield import("./imagePreprocess-DKqt_HU0.js");return{prepareImageFile:Z,blobToDataUrl:me}}),__vite__mapDeps([6,1,2,3,4]));if(G){const Z=yield fe(N);be(yield pe(Z));return}try{if(typeof createImageBitmap=="function"){const Z=yield createImageBitmap(N);(le=Z.close)==null||le.call(Z)}else yield new Promise((Z,me)=>{const Me=URL.createObjectURL(N),te=new Image;te.onload=()=>{URL.revokeObjectURL(Me),Z()},te.onerror=()=>{URL.revokeObjectURL(Me),me(new Error("decode failed"))},te.src=Me});be(yield pe(N));return}catch(Z){console.warn("[Avatar] fast decode failed, falling back to normalize:",Z)}const Ne=yield fe(N);be(yield pe(Ne))}catch(fe){console.error("[Avatar] prepare failed:",fe),Ie.dismiss(re),Ie.error("Não foi possÃvel abrir essa imagem. Tente outro arquivo (JPG ou PNG).")}}),M=()=>{try{if(!v.current){console.warn("[Avatar] fileInputRef is null"),Ie.error("Não foi possÃvel abrir o seletor. Recarregue a página.");return}v.current.value="",v.current.click(),console.debug("[Avatar] file picker opened")}catch(P){console.error("[Avatar] open picker failed:",P),Ie.error("Não foi possÃvel abrir o seletor de arquivos.")}},$=n.useCallback(F=>Q(this,[F],function*({blob:P,ext:N,contentType:Y}){if(_(null),!!a){u(!0);try{const G=`${a}/avatar.${N}`,{data:ee}=yield Se.storage.from("avatars").list(a);if(ee&&ee.length>0){const fe=ee.map(pe=>`${a}/${pe.name}`);yield Se.storage.from("avatars").remove(fe)}const{error:re}=yield Se.storage.from("avatars").upload(G,P,{upsert:!0,contentType:Y});if(re)throw re;const{data:be}=Se.storage.from("avatars").getPublicUrl(G),ge=be.publicUrl+`?t=${Date.now()}`;g(ge);const{error:le}=yield Ia.from("profiles").update({avatar_url:ge}).eq("id",a);le?console.warn("[Avatar] profile update failed:",le):o(),Ie.success("Foto atualizada! ð¸")}catch(G){console.error("Avatar upload error:",G);const ee=G instanceof Error?G.message:"Erro ao enviar foto. Tente novamente.";Ie.error(ee)}finally{u(!1)}}}),[a,o]),q=()=>Q(this,null,function*(){var N,Y;if(!a)return;for(const F of R)if(F.required&&!((N=l[F.field_key])!=null&&N.trim())){Ie.error(`${F.label} é obrigatório.`);return}if(R.find(F=>F.field_key==="location")&&((Y=l.location)!=null&&Y.trim())&&!au(l.location)){Ie.error("Selecione uma cidade da lista.");return}x(!0);try{const F={avatar_url:p||null};R.forEach(ee=>{var be;let re=((be=l[ee.field_key])==null?void 0:be.trim())||null;ee.field_key==="username"&&re&&(re=re.toLowerCase().replace(/[^a-z0-9_]/g,"")),F[ee.field_key]=re});const{error:G}=yield Ia.from("profiles").update(F).eq("id",a);if(G)throw G;Ie.success("Perfil atualizado! â
"),o(),r()}catch(F){Ie.error("Erro ao salvar perfil. Tente novamente.")}finally{x(!1)}}),ae=(l.name||"").split(" ").filter(Boolean).slice(0,2).map(P=>P[0]).join("").toUpperCase()||"?",J=w?e.jsx(su,{imageSrc:w,onCropDone:P=>{$(P)},onClose:()=>{_(null)}}):null,je=e.jsxs("div",{className:"flex flex-col items-center pt-6 pb-4",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(ut,{className:"h-24 w-24 border-2",style:{borderColor:"hsl(var(--setverso-red) / 0.4)"},children:[p?e.jsx(Ze,{src:p,className:"object-cover"}):null,e.jsx(ft,{className:"text-2xl font-black text-primary-foreground",style:{background:"hsl(var(--setverso-red))"},children:ae})]}),e.jsx("button",{onClick:M,disabled:d,type:"button",className:"absolute -bottom-1 -right-1 w-9 h-9 rounded-full flex items-center justify-center transition-all active:scale-95",style:{background:"hsl(var(--setverso-red))",border:"2px solid hsl(var(--background))"},children:d?e.jsx(dr,{size:15,className:"text-white animate-spin"}):e.jsx(Xc,{size:15,className:"text-white"})}),e.jsx("input",{ref:v,type:"file",accept:"image/*,.heic,.heif,.avif",onChange:j,style:{position:"absolute",width:1,height:1,opacity:0,pointerEvents:"none",overflow:"hidden",left:0,top:0}})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Toque para alterar a foto"})]}),ke=e.jsxs("div",{className:"px-5 pb-8 space-y-4",children:[S?[...Array(3)].map((P,N)=>e.jsx("div",{className:"h-16 rounded-2xl animate-pulse bg-muted/30"},N)):R.map(P=>e.jsx(ou,{field:P,value:l[P.field_key]||"",onChange:N=>z(P.field_key,N)},P.id)),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:"E-mail"}),e.jsx("div",{className:"flex items-center rounded-2xl overflow-hidden relative opacity-60",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-light)"},children:e.jsx("input",{type:"email",value:m,readOnly:!0,className:"flex-1 bg-transparent py-3.5 text-sm text-foreground placeholder:text-muted-foreground
263/50 outline-none cursor-not-allowed",style:{paddingLeft:"16px",paddingRight:"16px"}})})]}),e.jsx("button",{onClick:q,disabled:c||d,className:"w-full py-4 rounded-2xl font-black text-[15px] transition-all active:scale-[0.98] disabled:opacity-60 mt-2 bg-green-500/15 border border-green-500/35 text-green-400 checkout-light:text-green-600",children:c?e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsx(dr,{size:16,className:"animate-spin"})," Salvando..."]}):"Salvar alterações"})]});if(i)return e.jsxs(e.Fragment,{children:[J,e.jsxs("div",{className:"flex flex-col h-full overflow-y-auto bg-background",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 pt-5 pb-4 shrink-0 border-b",style:{borderColor:"var(--sv-border-subtle)",paddingTop:"max(env(safe-area-inset-top), 20px)"},children:[e.jsx("button",{onClick:r,className:"w-9 h-9 rounded-full flex items-center justify-center transition-colors active:scale-95 shrink-0",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-light)"},children:e.jsx(Ct,{size:16,style:{color:"var(--sv-icon-default)"}})}),e.jsx("h2",{className:"text-lg font-black text-foreground",children:"Editar perfil"})]}),je,ke]})]});const ve=e.jsxs(e.Fragment,{children:[J,e.jsx("div",{className:"fixed inset-0 z-[9998]",style:{background:"var(--sv-backdrop)",backdropFilter:"blur(8px)",opacity:t?1:0,pointerEvents:t?"auto":"none",transition:"opacity 0.25s ease"},onClick:r}),e.jsxs("div",{className:y?"fixed bottom-0 left-0 right-0 z-[9999] rounded-t-[28px] overflow-hidden bg-card":"fixed top-1/2 left-1/2 z-[9999] rounded-[28px] overflow-hidden bg-card w-full max-w-[440px]",style:L({border:"1px solid var(--sv-border-light)",boxShadow:"var(--sv-shadow-dropdown)"},y?{transform:t?"translateY(0)":"translateY(100%)",transition:"transform 0.35s cubic-bezier(0.4,0,0.2,1)",maxHeight:"90vh",overflowY:"auto"}:{transform:t?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:t?1:0,transition:"transform 0.25s cubic-bezier(0.4,0,0.2,1), opacity 0.2s ease",maxHeight:"85vh",overflowY:"auto",pointerEvents:t?"auto":"none"}),onClick:P=>P.stopPropagation(),children:[y&&e.jsx("div",{className:"flex justify-center pt-3 pb-1",children:e.jsx("div",{className:"w-10 h-1 rounded-full",style:{background:"var(--sv-border-medium)"}})}),e.jsxs("div",{className:"flex items-center justify-between px-5 pt-4 pb-4",style:{borderBottom:"1px solid var(--sv-border-subtle)"},children:[e.jsx("h2",{className:"text-lg font-black text-foreground",children:"Editar perfil"}),e.jsx("button",{onClick:r,className:"w-8 h-8 rounded-full flex items-center justify-center transition-colors",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-light)"},children:e.jsx(Je,{size:16,style:{color:"var(--sv-icon-default)"}})})]}),je,ke]})]});return k.current?Xt.createPortal(ve,document.body):null}function ou({field:t,value:r,onChange:s}){const a=t.field_key==="username",o=t.field_type==="phone",i=t.field_key==="location",l=t.field_type==="textarea",f=240,p=g=>{s(a?g.toLowerCase().replace(/[^a-z0-9_]/g,""):o?pc(g):l?g.slice(0,f):g)};return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:[t.label,t.required?" *":""]}),e.jsxs("div",{className:l?"rounded-2xl overflow-hidden relative":"flex items-center rounded-2xl overflow-hidden relative",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-light)"},children:[a&&e.jsx("span",{className:"pl-4 text-muted-foreground text-sm font-medium select-none",children:"@"}),l?e.jsx("textarea",{value:r,onChange:g=>p(g.target.value),placeholder:t.placeholder||"",rows:4,maxLength:f,className:"w-full bg-transparent py-3.5 px-4 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none resize-none"}):i?e.jsx("div",{className:"flex-1 py-3.5",style:{paddingLeft:"16px",paddingRight:"16px"},children:e.jsx(nu,{value:r,onChange:s,placeholder:t.placeholder||""})}):e.jsx("input",{type:o?"tel":"text",value:r,onChange:g=>p(g.target.value),placeholder:t.placeholder||"",className:"flex-1 bg-transparent py-3.5 text-sm text-foreground placeholder:text-muted-foreground
263/50 outline-none",style:{paddingLeft:a?"4px":"16px",paddingRight:"16px"}})]})]})}function La(t){return new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"}).format(t/100)}function Mr(t){return t?new Date(t).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"}):"â"}function Nn({status:t}){const r={active:{label:"Ativa",color:"#22c55e",bg:"rgba(34,197,94,0.1)",icon:Hr},past_due:{label:"Atrasada",color:"#f59e0b",bg:"rgba(245,158,11,0.1)",icon:Cr},cancelled:{label:"Cancelada",color:"#ef4444",bg:"rgba(239,68,68,0.1)",icon:Cr},canceled:{label:"Cancelada",color:"#ef4444",bg:"rgba(239,68,68,0.1)",icon:Cr},pending:{label:"Pendente",color:"#f59e0b",bg:"rgba(245,158,11,0.1)",icon:ea},failed:{label:"Falhou",color:"#ef4444",bg:"rgba(239,68,68,0.1)",icon:Cr},paid:{label:"Pago",color:"#22c55e",bg:"rgba(34,197,94,0.1)",icon:Hr}},s=r[t]||r.pending,a=s.icon;return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,fontWeight:700,color:s.color,background:s.bg,padding:"4px 10px",borderRadius:8},children:[e.jsx(a,{size:14}),s.label]})}const Fa={card:"Cartão de crédito",pix:"Pix",debit:"Débito automático",apple_pay:"Apple Pay",google_pay:"Google Pay",stripe:"Stripe"};function Oa({open:t,onClose:r,userId:s,embedded:a}){const[o,i]=n.useState([]),[l,f]=n.useState([]),[p,g]=n.useState(0),[c,x]=n.useState(!0);if(n.useEffect(()=>{!t||!s||(x(!0),Se.functions.invoke("user-billing").then(({data:m,error:b})=>{if(b||!m){x(!1);return}i(m.subscriptions||[]),f(m.payments||[]),g(m.paid_count||0),x(!1)}))},[t,s]),!t)return null;const d=o.find(m=>m.status==="active")||o[0]||null;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--sv-surface-solid)",paddingTop:a?"max(env(safe-area-inset-top), 12px)":0,paddingBottom:a?"max(env(safe-area-inset-bottom), 24px)":0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"16px 20px 20px"},children:[e.jsx("button",{onClick:r,style:{width:40,height:40,borderRadius:"50%",background:"var(--sv-surface-hover)",border:"1px solid var(--sv-border-light)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"var(--sv-icon-default)",flexShrink:0},children:e.jsx(Ct,{size:20})}),e.jsx("p",{style:{fontSize:18,fontWeight:800,color:"var(--sv-text-heading)"},children:"Faturamento"})]}),e.jsx("div",{style:{padding:"0 16px",flex:1,overflowY:"auto"},children:c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:40},children:e.jsx("div",{className:"w-6 h-6 rounded-full border-2 animate-spin",style:{borderColor:"var(--sv-border-light)",borderTopColor:"var(--sv-text-primary)"}})}):d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-light)",borderRadius:20,padding:20,marginBottom:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:[e.jsx("p",{style:{fontSize:16,fontWeight:800,color:"var(--sv-text-heading)"},children:"Assinatura SetVerso"}),e.jsx(Nn,{status:d.status})]}),e.jsxs("div",{style:{background:"var(--sv-surface-hover)",borderRadius:14,padding:"14px 16px",marginBottom:16},children:[e.jsxs("p",{style:{fontSize:28,fontWeight:900,color:"var(--sv-text-heading)",letterSpacing:"-0.5px"},children:[d.amount?La(d.amount):"â",e.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--sv-text-muted)",marginLeft:4},children:"/mês"})]}),d.coupon_label&&e.jsxs("p",{style:{fontSize:12,color:"hsl(var(--setverso-red))",fontWeight:700,marginTop:4},children:["ðï¸ ",d.coupon_label]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsx(Ar,{icon:Sa,label:"Método",value:Fa[d.payment_method]||d.payment_method}),e.jsx(Ar,{icon:wo,label:"Próxima cobrança",value:Mr(d.next_billing_date)}),e.jsx(Ar,{icon:td,label:"Membro desde",value:Mr(d.created_at)}),e.jsx(Ar,{icon:Hr,label:"Faturas pagas",value:String(p)})]})]}),o.length>1&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("p",{className:"text-xs font-bold text-muted-foreground uppercase tracking-[0.15em] mb-3 px-1",children:"Outras assinaturas"}),o.filter(m=>m.id!==d.id).map(m=>e.jsxs("div",{style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-light)",borderRadius:14,padding:"12px 16px",marginBottom:8,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:13,fontWeight:600,color:"var(--sv-text-primary)"},children:Fa[m.payment_method]||m.payment_method}),e.jsx("p",{style:{fontSize:11,color:"var(--sv-text-muted)"},children:Mr(m.created_at)})]}),e.jsx(Nn,{status:m.status})]},m.id))]}),l.length>0&&e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("p",{className:"text-xs font-bold text-muted-foreground uppercase tracking-[0.15em] mb-3 px-1",children:"Histórico de pagamentos"}),l.map(m=>e.jsxs("div",{style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-light)",borderRadius:14,padding:"12px 16px",marginBottom:8,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:13,fontWeight:600,color:"var(--sv-text-primary)"},children:m.amount?La(m.amount):"â"}),e.jsx("p",{style:{fontSize:11,color:"var(--sv-text-muted)"},children:Mr(m.paid_at||m.issued_at||m.created_at)})]}),e.jsx(Nn,{status:m.status})]},m.id))]})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px 20px"},children:[e.jsx("div",{style:{width:64,height:64,borderRadius:20,margin:"0 auto 16px",background:"var(--sv-surface-hover)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Sa,{size:28,style:{color:"var(--sv-text-muted)"}})}),e.jsx("p",{style:{fontSize:16,fontWeight:700,color:"var(--sv-text-heading)",marginBottom:6},children:"Nenhuma assinatura encontrada"}),e.jsx("p",{style:{fontSize:14,color:"var(--sv-text-muted)",lineHeight:1.5},children:"Você ainda não possui uma assinatura vinculada ao seu e-mail."})]})})]})}function Ar({icon:t,label:r,value:s}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 0"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(t,{size:16,style:{color:"var(--sv-text-muted)"}}),e.jsx("span",{style:{fontSize:13,color:"var(--sv-text-secondary)"},children:r})]}),e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--sv-text-primary)"},children:s})]})}const pi="sv_native_platform";function iu(){try{const t=localStorage.getItem(pi);if(t==="ios"||t==="android")return t}catch(t){}return null}function lu(){var a;if(typeof navigator=="undefined")return null;const t=navigator.userAgent||"";if(/SetversoNativeIOS/i.test(t))return"ios";if(/SetversoNativeAndroid|LikePlayNativeAndroid/i.test(t))return"android";const r=window;if(!!r.ReactNativeWebView||!!((a=r.NativeBridge)!=null&&a.__isNativeApp)){if(/Android/i.test(t))return"android";if(/iPhone|iPad|iPod/i.test(t))return"ios"}return null}
263var co;let Hn=(co=iu())!=null?co:lu();const Un=new Set;function cu(t){if(!(!t||t===Hn)){Hn=t;try{localStorage.setItem(pi,t)}catch(r){}Un.forEach(r=>{try{r(t)}catch(s){}})}}function Jr(){return Hn==="android"}function hi(t){return Un.add(t),()=>{Un.delete(t)}}let $a=!1;function du(){if($a||typeof window=="undefined")return;$a=!0;const t=r=>{const s=r.data;if(typeof s=="string")try{const a=JSON.parse(s),o=a==null?void 0:a.platform;(o==="ios"||o==="android")&&cu(o)}catch(a){}};window.addEventListener("message",t),document.addEventListener("message",t)}du();const uu=[{id:"Feed",icon:Fo,label:"Feed"},{id:"messages",icon:gs,label:"Messages"},{id:"notifications",icon:Ms,label:"Notificações"}],Os=62,kn=62,Ba=8;function fu({activeTab:t,onTabChange:r,onSearchChange:s,unreadMessages:a=0}){const[o,i]=n.useState(!1),[l,f]=n.useState(!1),[p,g]=n.useState(""),[c,x]=n.useState(0),d=n.useRef(null),u=n.useRef(null),m=n.useRef(null),[b,v]=n.useState(()=>Jr());n.useEffect(()=>hi(()=>v(Jr())),[]);const w=n.useRef(null);n.useEffect(()=>{const k=()=>{d.current&&x(d.current.offsetWidth)};return k(),window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)},[]),n.useEffect(()=>{if(!o)return;const k=E=>{u.current&&!u.current.contains(E.target)&&i(!1)};return document.addEventListener("mousedown",k),document.addEventListener("touchstart",k),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("touchstart",k)}},[o]),n.useEffect(()=>{if(!l)return;const k=E=>{m.current&&!m.current.contains(E.target)&&(f(!1),g(""))};return document.addEventListener("mousedown",k),document.addEventListener("touchstart",k),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("touchstart",k)}},[l]),n.useEffect(()=>{l&&setTimeout(()=>{var k;return(k=w.current)==null?void 0:k.focus()},150)},[l]);const _=()=>{i(!1),l?(f(!1),g(""),s==null||s("")):f(!0)},y=c>0?c-Os-Ba-kn-Ba:0;return e.jsx("div",{className:"fixed bottom-0 left-1/2 -translate-x-1/2 w-full max-w-[430px] z-50",style:{pointerEvents:"none"},children:e.jsxs("div",{ref:d,className:Be("mx-4 flex items-center gap-2",b?"mb-16":"mb-8"),style:{position:"relative",pointerEvents:"auto"},children:[e.jsxs("div",{ref:u,className:"flex items-center rounded-full overflow-hidden justify-center shrink-0",style:{background:"var(--sv-glass-bg)",backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)",border:"1px solid var(--sv-border-light)",boxShadow:"none",transition:"all 0.35s cubic-bezier(0.4, 0, 0.2, 1)",width:o?"auto":`${Os}px`,height:`${Os}px`,paddingLeft:o?"8px":"0",paddingRight:o?"8px":"0"},children:[e.jsxs("button",{onClick:()=>{o?(r("Feed"),i(!1)):i(!0)},className:Be("relative flex flex-col items-center justify-center px-4 rounded-full transition-all duration-300 shrink-0 h-full",t==="Feed"&&o?"bg-foreground
263/10":"bg-transparent"),style:{minWidth:`${Os}px`},children:[e.jsx(Fo,{size:22,className:Be("transition-all duration-300",t==="Feed"?"text-foreground":"text-muted-foreground")}),!o&&a>0&&e.jsx("span",{className:"absolute top-3 right-3 w-2 h-2 rounded-full animate-in zoom-in-50 duration-200",style:{background:"hsl(var(--setverso-red))"}}),e.jsx("span",{className:Be("text-[10px] font-medium mt-0.5 transition-all duration-300",t==="Feed"?"text-foreground":"text-muted-foreground"),style:{opacity:o?1:0,maxHeight:o?"20px":"0px",overflow:"hidden",transition:"opacity 0.2s ease, max-height 0.2s ease"},children:"Feed"})]}),e.jsx("div",{style:{display:"flex",opacity:o?1:0,maxWidth:o?"200px":"0px",overflow:"hidden",transition:"opacity 0.25s ease 0.05s, max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1)",pointerEvents:o?"auto":"none"},children:uu.slice(1).map(({id:k,icon:E,label:S})=>{const R=t===k,z=k==="messages"&&a>0;return e.jsxs("button",{onClick:()=>{r(k),i(!1)},className:Be("relative flex flex-col items-center justify-center px-4 rounded-full transition-all duration-300 shrink-0 h-full",R?"bg-foreground
263/10":"bg-transparent"),style:{minWidth:`${Os}px`},children:[e.jsx(E,{size:22,className:Be("transition-all duration-300",R?"text-foreground fill-foreground":"text-muted-foreground")}),z&&e.jsx("span",{className:"absolute top-2 right-2 min-w-[18px] h-[18px] flex items-center justify-center rounded-full text-[10px] font-bold text-white animate-in zoom-in-50 duration-200",style:{background:"hsl(var(--setverso-red))",padding:"0 4px"},children:a>99?"99+":a}),e.jsx("span",{className:Be("text-[10px] font-medium mt-0.5",R?"text-foreground":"text-muted-foreground"),children:S})]},k)})})]}),e.jsx("div",{className:"flex-1",style:{pointerEvents:"none"}}),e.jsxs("div",{ref:m,className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{style:{overflow:"hidden",width:l?`${y}px`:"0px",opacity:l?1:0,transition:"width 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease",pointerEvents:l?"auto":"none",flexShrink:0},children:e.jsxs("div",{className:"flex items-center gap-2 px-4",style:{background:"var(--sv-glass-bg-strong)",backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)",border:"1px solid var(--sv-border-light)",boxShadow:"none",borderRadius:"9999px",height:`${Os}px`,width:`${y}px`},children:[e.jsx("input",{ref:w,type:"text",value:p,onChange:k=>{g(k.target.value),s==null||s(k.target.value)},placeholder:"Buscar...",className:"flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground outline-none min-w-0"}),p&&e.jsx("button",{onClick:()=>{g(""),s==null||s("")},children:e.jsx(Je,{size:14,className:"text-muted-foreground"})})]})}),e.jsx("button",{onClick:_,className:"rounded-full flex items-center justify-center transition-all duration-300 shrink-0",style:{width:`${kn}px`,height:`${kn}px`,background:l?"var(--sv-surface-active)":"var(--sv-glass-bg)",backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)",border:l?"1px solid var(--sv-border-medium)":"1px solid var(--sv-border-light)",boxShadow:"none"},children:l?e.jsx(Je,{size:20,className:"text-foreground/80 transition-all duration-300"}):e.jsx(pr,{size:22,className:"text-foreground/80 transition-all duration-300"})})]})]})})}const Pr="sv_post_draft_v1",qa=[{icon:To,label:"Negrito",wrap:["**","**"],placeholder:"texto"},{icon:Oo,label:"Itálico",wrap:["_","_"],placeholder:"texto"},{icon:Lo,label:"TÃtulo",wrap:["## ",""],placeholder:"TÃtulo"},{icon:Bo,label:"Lista",wrap:["- ",""],placeholder:"item"},{icon:Uo,label:"Citação",wrap:["> ",""],placeholder:"texto"},{icon:Do,label:"Código",wrap:["`","`"],placeholder:"código"},{icon:$o,label:"Link",wrap:["[","](url)"],placeholder:"texto"},{icon:Wo,label:"Divisória",wrap:[` 264--- 265`,""],placeholder:""}];function $s(t,r,s,a,o,i,l){const f=i!=null?i:t.selectionStart,p=l!=null?l:t.selectionEnd,g=r.slice(f,p)||o,c=r.slice(0,f)+a[0]+g+a[1]+r.slice(p);s(c),requestAnimationFrame(()=>{t.focus();const x=f+a[0].length;t.setSelectionRange(x,x+g.length)})}function mu(t,r){const s=t.slice(0,r),a=s.match(/(^|[\s\n])\/([^\s]*)$/);return a?{query:a[2],slashIndex:s.lastIndexOf("/")}:null}function pu(t){const r=t.match(/(?:youtube\.com\/(?:watch\?v=|shorts\/)|youtu\.be\/)([^&\n?#]+)/);return r?r[1]:null}function hu({videoId:t,onRemove:r}){const[s,a]=n.useState(!1),o=`https://img.youtube.com/vi/${t}/maxresdefault.jpg`;return e.jsxs("div",{className:"relative rounded-2xl overflow-hidden",style:{border:"1px solid rgba(255,255,255,0.08)"},children:[s?e.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${t}?autoplay=1&modestbranding=1&rel=0&showinfo=0&iv_load_policy=3&cc_load_policy=0&controls=1&disablekb=0`,style:{position:"absolute",inset:0,width:"100%",height:"100%",border:0},allow:"autoplay; encrypted-media; fullscreen",allowFullScreen:!0})}):e.jsxs("div",{className:"relative cursor-pointer",onClick:()=>a(!0),children:[e.jsx("img",{src:o,alt:"Thumbnail",className:"w-full object-cover",style:{aspectRatio:"16/9",display:"block"}}),e.jsx("div",{className:"absolute inset-0",style:{background:"linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 50%)"}}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"flex items-center justify-center rounded-full transition-transform active:scale-90",style:{width:"56px",height:"56px",background:"rgba(220,38,38,0.9)",boxShadow:"0 4px 24px rgba(220,38,38,0.5)"},children:e.jsx(Es,{size:22,className:"text-white ml-1",fill:"white"})})}),e.jsxs("div",{className:"absolute bottom-2 left-3 flex items-center gap-1.5 px-2.5 py-1 rounded-full",style:{background:"rgba(0,0,0,0.6)",backdropFilter:"blur(8px)"},children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"rgb(220,38,38)"}}),e.jsx("span",{className:"text-[11px] font-semibold text-white/80",children:"VÃdeo"})]})]}),e.jsx("button",{onClick:r,className:"absolute top-2 right-2 w-7 h-7 rounded-full flex items-center justify-center transition-all active:scale-90",style:{background:"rgba(0,0,0,0.6)",backdropFilter:"blur(8px)",border:"1px solid rgba(255,255,255,0.15)"},children:e.jsx(Je,{size:13,className:"text-white/80"})})]})}function xu({open:t,onClose:r,initialSpace:s,addOptimisticPost:a,createPost:o,userId:i,userProfile:l,posts:f}){var O,H,ce,V;const[p,g]=n.useState(!1);n.useEffect(()=>{t&&g(!0)},[t]);const[c,x]=n.useState(""),[d,u]=n.useState(""),[m,b]=n.useState([]),[v,w]=n.useState(!1),_=Ks(),[y,k]=n.useState(!1),[E,S]=n.useState(""),[R,z]=n.useState(!1),[j,M]=n.useState(null),[$,q]=n.useState(0),[ne,ae]=n.useState(!1),[J,je]=n.useState(0),[ke,ve]=n.useState([]);n.useEffect(()=>{if(j===null){ve([]);return}const C=setTimeout(()=>Q(this,null,function*(){let h=Se.from("posts").select("id, title").order("created_at",{ascending:!1}).limit(5);j.length>0&&(h=h.ilike("title",`%${j}%`));const{data:T}=yield h;ve(T||[])}),200);return()=>clearTimeout(C)},[j]);const P=n.useRef(null),N=n.useRef(null),Y=n.useRef(null),F=n.useRef(null),G=n.useRef(0),ee=n.useRef(0),re=()=>{N.current&&(G.current=N.current.selectionStart,ee.current=N.current.selectionEnd)};n.useEffect(()=>{t&&setTimeout(()=>{var C;return(C=P.current)==null?void 0:C.focus()},380)},[t]);const be=n.useRef(!1);n.useEffect(()=>{if(!be.current){be.current=!0;try{const C=Sr.getItem(Pr);if(!C)return;const h=JSON.parse(C);if(h.title&&x(h.title),h.content&&u(h.content),Array.isArray(h.attachments)){const T=h.attachments.filter(I=>(I==null?void 0:I.type)==="youtube");T.length&&b(T)}}catch(C){}}},[]),n.useEffect(()=>{if(!be.current)return;const C=setTimeout(()=>{try{const h=m.filter(T=>T.type==="youtube");if(!c&&!d&&h.length===0){Sr.removeItem(Pr);return}Sr.setItem(Pr,JSON.stringify({title:c,content:d,attachments:h,updatedAt:Date.now()}))}catch(h){}},400);return()=>clearTimeout(C)},[c,d,m]);const ge=()=>{try{Sr.removeItem(Pr)}catch(C){}},le=()=>{const C={title:c,content:d,attachments:m};x(""),u(""),b([]),w(!1),k(!1),S(""),M(null),ge(),Ie.success("Rascunho descartado",{action:{label:"Desfazer",onClick:()=>{x(C.title),u(C.content),b(C.attachments)}},duration:5e3})},fe=!!(c.trim()||d.trim()||m.some(C=>C.type==="youtube"));n.useEffect(()=>{y&&setTimeout(()=>{var C;return(C=F.current)==null?void 0:C.focus()},80)},[y]),n.useEffect(()=>
265{const C=window.visualViewport;if(!C)return;const h=()=>{const T=window.innerHeight-C.height-C.offsetTop;je(Math.max(0,T))};return C.addEventListener("resize",h),C.addEventListener("scroll",h),h(),()=>{C.removeEventListener("resize",h),C.removeEventListener("scroll",h)}},[]);const pe=C=>{const h=C.target.value;u(h);const T=C.target.selectionStart,I=mu(h,T);I?(M(I.query),q(I.slashIndex)):M(null)},Ne=C=>{if(!N.current)return;const h=`[â ${C.title}](/membros/post/${C.id})`,T=d.slice(0,$),I=d.slice(N.current.selectionStart);u(T+h+I),M(null),requestAnimationFrame(()=>{if(!N.current)return;N.current.focus();const K=T.length+h.length;N.current.setSelectionRange(K,K)})},Z=C=>{var I;const h=(I=C.target.files)==null?void 0:I[0];if(!h)return;const T=URL.createObjectURL(h);b(K=>[...K,{type:"image",url:T,name:h.name}]),C.target.value="",w(!1)},me=()=>{const C=pu(E);if(!C){z(!0);return}b(h=>[...h,{type:"youtube",videoId:C,thumbnail:`https://img.youtube.com/vi/${C}/maxresdefault.jpg`}]),S(""),k(!1),z(!1),w(!1)},Me=C=>{b(h=>h.filter((T,I)=>I!==C))},te=C=>Q(this,null,function*(){if(!i)return C;const h=[];for(const T of C){if(T.type!=="image"||!T.url.startsWith("blob:")){h.push(T);continue}try{const I=yield fetch(T.url).then(Ve=>Ve.blob()),K=(T.name.split(".").pop()||"jpg").toLowerCase().replace(/[^a-z0-9]/g,"")||"jpg",ie=`${i}/posts/${crypto.randomUUID()}.${K}`,{error:Ae}=yield Se.storage.from("avatars").upload(ie,I,{contentType:I.type||"image/jpeg",upsert:!1});if(Ae)throw Ae;const{data:Te}=Se.storage.from("avatars").getPublicUrl(ie);h.push({type:"image",url:Te.publicUrl,name:T.name})}catch(I){throw console.error("Falha ao enviar imagem:",I),I}}return h}),we=()=>Q(this,null,function*(){if(!Pe||ne||!s)return;if(!i){Ie.error("Você precisa estar logado para publicar.");return}ae(!0);let C;try{C=yield te(m)}catch(K){Ie.error("Não foi possÃvel enviar a imagem. Tente novamente."),ae(!1);return}const h={title:c.trim(),content:d.trim(),preview:d.trim().replace(/[#*_>`\-\[\]]/g,"").slice(0,200),space_id:s.id,spaceName:s.name,spaceEmoji:s.emoji,attachments:C},T=a(h);ge(),x(""),u(""),b([]),w(!1),k(!1),S(""),M(null),ae(!1),r();const I=K=>Q(this,null,function*(){try{yield o(h,T),Ie.success("Post publicado! ð¬")}catch(ie){console.error(`Tentativa ${K} falhou:`,ie);const Ae=Math.min(500*Math.pow(2,K-1),4e3);return yield new Promise(Te=>setTimeout(Te,Ae)),I(K+1)}});I(1)}),Pe=c.trim()&&s&&d.trim()&&!!i,oe=({onPress:C,children:h,title:T})=>e.jsx("button",{onMouseDown:I=>I.preventDefault(),onClick:C,title:T,className:"flex items-center justify-center rounded-xl transition-all duration-150 active:scale-90 shrink-0 text-muted-foreground hover:text-foreground hover:bg-muted",style:{width:"38px",height:"38px"},children:h});return!p&&!t?null:e.jsxs(e.Fragment,{children:[!_&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:199,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",opacity:t?1:0,pointerEvents:t?"auto":"none",transition:"opacity 0.28s ease"},onClick:r}),e.jsxs("div",{style:_?{position:"fixed",inset:0,zIndex:200,background:"var(--sv-surface-solid, rgb(8,8,8))",display:"flex",flexDirection:"column",transform:t?"translateY(0%)":"translateY(100%)",transition:"transform 0.4s cubic-bezier(0.4,0,0.2,1)"}:{position:"fixed",top:"50%",left:"50%",zIndex:200,width:"100%",maxWidth:"640px",maxHeight:"85vh",background:"var(--sv-surface-solid, rgb(8,8,8))",display:"flex",flexDirection:"column",borderRadius:"24px",border:"1px solid var(--sv-border-subtle)",boxShadow:"0 20px 80px rgba(0,0,0,0.5)",transform:t?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:t?1:0,transition:"transform 0.28s cubic-bezier(0.4,0,0.2,1), opacity 0.28s ease",pointerEvents:t?"auto":"none",overflow:"hidden"},children:[e.jsxs("div",{className:"flex items-center justify-between px-5 shrink-0",style:{borderBottom:"1px solid var(--sv-border-subtle)",paddingTop:_?"calc(env(safe-area-inset-top, 0px) + 14px)":"14px",paddingBottom:"14px"},children:[e.jsx("button",{onClick:r,className:"w-11 h-11 rounded-full flex items-center justify-center transition-all active:scale-90",style:{background:"rgba(220,38,38,0.15)",border:"1px solid rgba(220,38,38,0.3)"},children:e.jsx(Je,{size:20,style:{color:"rgba(220,38,38,0.9)"}})}),e.jsx("p",{className:"text-sm font-bold",style:{color:"var(--sv-text-heading)"},children:"Nova publicação"}),e.jsxs("div",{className:"flex items-center gap-2",children:[fe&&e.jsx("button",{onClick:le,title:"Descartar rascunho",className:"w-11 h-11 rounded-full flex items-center justify-center transition-all active:scale-90",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)"},children:e.jsx(Vt,{size:16,style:{color:"rgba(255,255,255,0.55)"}})}),e.jsxs("button",{disabled:!Pe||ne,className:"flex items-center gap-1.5 px-4 h-11 rounded-full text-sm font-bold transition-all duration-200 active:scale-95",style:{background:Pe?"rgba(34,197,94,0.2)":"rgba(255,255,255,0.05)",border:Pe?"1px solid rgba(34,197,94,0.4)":"1px solid rgba(255,255,255,0.08)",color:Pe?"rgb(74,222,128)":"rgba(255,255,255,0.25)"},onClick:we,children:[e.jsx(Vs,{size:13})," ",ne?"Publicando...":"Publicar"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 shrink-0",children:[e.jsxs(ut,{className:"h-9 w-9 border shrink-0",style:{borderColor:"var(--sv-border-subtle)"},children:[(l==null?void 0:l.avatar_url)&&e.jsx(Ze,{src:l.avatar_url,alt:(O=l.n
265ame)!=null?O:"Perfil",className:"object-cover"}),e.jsx(ft,{className:"text-xs font-bold text-white",style:{background:"hsl(var(--setverso-red))"},children:(ce=(H=l==null?void 0:l.name)==null?void 0:H.split(" ").slice(0,2).map(C=>C[0]).join("").toUpperCase())!=null?ce:"?"})]}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"text-sm font-bold leading-tight",style:{color:"var(--sv-text-heading)"},children:(V=l==null?void 0:l.name)!=null?V:"Carregando..."}),s&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-semibold",style:{background:"var(--sv-surface-hover)",border:"1px solid var(--sv-border-subtle)",color:"var(--sv-text-muted)"},children:[e.jsx("span",{children:s.emoji}),e.jsx("span",{children:s.name})]})]}),e.jsx("p",{className:"text-xs",style:{color:"var(--sv-text-muted)"},children:l!=null&&l.username?`@${l.username}`:""})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pt-1 pb-28",children:[e.jsx("input",{ref:P,type:"text",value:c,onChange:C=>x(C.target.value),placeholder:"TÃtulo da publicação...",className:"w-full bg-transparent text-3xl font-black placeholder:opacity-20 outline-none mb-4",style:{color:"var(--sv-text-heading)"}}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:N,value:d,onChange:pe,onSelect:re,onKeyUp:re,onMouseUp:re,onBlur:re,onKeyDown:C=>{re(),j!==null&&C.key==="Escape"&&(M(null),C.preventDefault())},placeholder:`Escreva sua publicação... 266 267Dica: use / para citar outro post`,rows:10,className:"w-full bg-transparent text-lg placeholder:opacity-20 outline-none resize-none leading-relaxed",style:{color:"var(--sv-text-primary)"}}),j!==null&&ke.length>0&&e.jsxs("div",{style:{position:"absolute",bottom:"calc(100% + 8px)",left:0,right:0,zIndex:220,background:"rgba(15,15,15,0.97)",backdropFilter:"blur(32px) saturate(200%)",WebkitBackdropFilter:"blur(32px) saturate(200%)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"18px",boxShadow:"0 -8px 40px rgba(0,0,0,0.6)",overflow:"hidden"},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.2em] px-4 pt-3 pb-1.5",style:{color:"rgba(99,179,237,0.7)"},children:"Posts encontrados"}),e.jsx("div",{className:"flex flex-col p-1.5 gap-0.5",children:ke.map(C=>e.jsxs("button",{onMouseDown:h=>h.preventDefault(),onClick:()=>Ne(C),className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-xl text-left transition-all duration-100 active:scale-[0.98]",style:{background:"transparent"},onMouseEnter:h=>{h.currentTarget.style.background="rgba(99,179,237,0.08)"},onMouseLeave:h=>{h.currentTarget.style.background="transparent"},children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0",style:{background:"rgba(99,179,237,0.1)",border:"1px solid rgba(99,179,237,0.2)"},children:e.jsx(jo,{size:13,style:{color:"rgba(99,179,237,0.8)"}})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[13px] font-semibold leading-snug line-clamp-1",style:{color:"rgba(255,255,255,0.85)"},children:C.title}),e.jsx("p",{className:"text-[11px] mt-0.5",style:{color:"rgba(255,255,255,0.3)"},children:"post"})]}),e.jsx("span",{className:"text-[11px] font-semibold shrink-0",style:{color:"rgba(99,179,237,0.6)"},children:"citar"})]},C.id))}),e.jsx("div",{style:{height:"6px"}})]}),j!==null&&j.length>0&&ke.length===0&&e.jsx("div",{style:{position:"absolute",bottom:"calc(100% + 8px)",left:0,right:0,zIndex:220,background:"rgba(15,15,15,0.95)",backdropFilter:"blur(24px)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:"16px",padding:"14px 16px"},children:e.jsxs("p",{className:"text-[13px] text-white/30 text-center",children:['Nenhum post com "',j,'"']})})]}),m.length>0&&e.jsx("div",{className:"mt-4 flex flex-col gap-3",children:m.map((C,h)=>C.type==="youtube"?e.jsx(hu,{videoId:C.videoId,onRemove:()=>Me(h)},h):e.jsxs("div",{className:"relative rounded-2xl overflow-hidden",style:{border:"1px solid rgba(255,255,255,0.08)"},children:[e.jsx("img",{src:C.url,alt:C.name,className:"w-full h-auto rounded-2xl block"}),e.jsx("button",{onClick:()=>Me(h),className:"absolute top-2 right-2 w-7 h-7 rounded-full flex items-center justify-center transition-all active:scale-90",style:{background:"rgba(0,0,0,0.6)",backdropFilter:"blur(8px)",border:"1px solid rgba(255,255,255,0.15)"},children:e.jsx(Je,{size:13,className:"text-white/80"})})]},h))})]}),!_&&t&&e.jsxs("div",{className:"px-4 py-3 shrink-0",style:{borderTop:"1px solid var(--sv-border-subtle)",background:"var(--sv-surface-solid, rgb(8,8,8))"},children:[e.jsx("input",{ref:_?void 0:Y,type:"file",accept:"image/*",className:"hidden",onChange:Z}),y&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 px-3 py-2 rounded-2xl",style:{background:"rgba(15,15,15,0.95)",backdropFilter:"blur(20px)",border:"1px solid rgba(255,255,255,0.1)",boxShadow:"0 8px 32px rgba(0,0,0,0.5)"},children:[e.jsx(xs,{size:15,style:{color:R?"rgb(220,38,38)":"rgba(255,255,255,0.35)"},className:"shrink-0"}),e.jsx("input",{type:"url",value:E,onChange:C=>{S(C.target.value),z(!1)},onKeyDown:C=>{C.key==="Enter"&&me(),C.key==="Escape"&&(k(!1),S(""),z(!1))},placeholder:"Cole o link do YouTube...",className:"flex-1 bg-transparent text-sm text-white placeholder:text-white/25 outline-none",style:{color:R?"rgb(220,38,38)":void 0}}),E&&e.jsx("button",{onClick:me,className:"px-3 py-1 rounded-full text-[12px] font-bold transition-all active:scale-95",style:{background:"rgba(220,38,38,0.2)",border:"1px solid rgba(220,38,38,0.35)",color:"rgb(252,165,165)"},children:"Adicionar"}),e.jsx("button",{onClick:()=>{k(!1),S(""),z(!1)},children:e.jsx(Je,{size:14,style:{color:"rgba(255,255,255,0.3)"}})})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5 flex-wrap",children:[qa.map(({icon:C,label:h,wrap:T,placeholder:I})=>e.jsx(oe,{onPress:()=>{N.current&&$s(N.current,d,u,T,I,G.current,ee.current)},title:h,children:e.jsx(C,{size:15,strokeWidth:2})},h)),e.jsx("div",{className:"w-px h-4 mx-1 shrink-0",style:{background:"rgba(255,255,255,0.1)"}}),[{char:"#",label:"Agrupar conteúdo",color:"rgba(129,140,248,0.85)",action:()=>{N.current&&$s(N.current,d,u,["#",""],"tema",G.current,ee.current)}},{char:"@",label:"Citar membro",color:"rgba(251,191,36,0.85)",action:()=>{N.current&&$s(N.current,d,u,["@",""],"membro",G.current,ee.current)}},{char:"/",label:"Linkar post",color:"rgba(74,222,128,0.85)",action:()=>
267{if(!N.current)return;const C=G.current,h=d.slice(0,C),T=d.slice(C),I=h.length>0&&!/[\s\n]$/.test(h),K=h+(I?" /":"/")+T;u(K),requestAnimationFrame(()=>{if(!N.current)return;N.current.focus();const ie=C+(I?2:1);N.current.setSelectionRange(ie,ie),M(""),q(ie-1)})}}].map(({char:C,label:h,color:T,action:I})=>e.jsx("button",{onMouseDown:K=>K.preventDefault(),onClick:I,title:h,className:"flex items-center justify-center rounded-xl transition-all duration-150 active:scale-90 shrink-0 hover:bg-muted",style:{width:"36px",height:"38px"},children:e.jsx("span",{className:"text-[15px] font-black leading-none",style:{color:T},children:C})},C)),e.jsx("div",{className:"w-px h-4 mx-1 shrink-0",style:{background:"rgba(255,255,255,0.1)"}}),e.jsx(oe,{onPress:()=>{var C;return(C=Y.current)==null?void 0:C.click()},title:"Adicionar imagem",children:e.jsx(Yr,{size:16})}),e.jsx(oe,{onPress:()=>{k(C=>!C)},title:"Adicionar vÃdeo do YouTube",children:e.jsx(xs,{size:16})}),e.jsx("span",{className:"text-[10px] font-mono ml-1 shrink-0",style:{color:d.length>1800?"rgb(251,146,60)":"hsl(var(--muted-foreground) / 0.4)"},children:d.length})]})]})]}),t&&_&&Xt.createPortal(e.jsxs("div",{className:"fixed right-4 z-[300] flex flex-col items-end",style:{bottom:`calc(${J}px + env(safe-area-inset-bottom, 0px) + 12px)`,transition:"bottom 0.2s ease"},children:[e.jsx("input",{ref:Y,type:"file",accept:"image/*",className:"hidden",onChange:Z}),y&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 px-3 py-2 rounded-2xl w-72",style:{background:"rgba(15,15,15,0.95)",backdropFilter:"blur(20px)",border:"1px solid rgba(255,255,255,0.1)",boxShadow:"0 8px 32px rgba(0,0,0,0.5)"},children:[e.jsx(xs,{size:15,style:{color:R?"rgb(220,38,38)":"rgba(255,255,255,0.35)"},className:"shrink-0"}),e.jsx("input",{ref:F,type:"url",value:E,onChange:C=>{S(C.target.value),z(!1)},onKeyDown:C=>{C.key==="Enter"&&me(),C.key==="Escape"&&(k(!1),S(""),z(!1))},placeholder:"Cole o link do YouTube...",className:"flex-1 bg-transparent text-sm text-white placeholder:text-white/25 outline-none",style:{color:R?"rgb(220,38,38)":void 0}}),E&&e.jsx("button",{onClick:me,className:"px-3 py-1 rounded-full text-[12px] font-bold transition-all active:scale-95",style:{background:"rgba(220,38,38,0.2)",border:"1px solid rgba(220,38,38,0.35)",color:"rgb(252,165,165)"},children:"Adicionar"}),e.jsx("button",{onClick:()=>{k(!1),S(""),z(!1)},children:e.jsx(Je,{size:14,style:{color:"rgba(255,255,255,0.3)"}})})]}),e.jsxs("div",{className:"flex items-center rounded-full overflow-hidden",style:{height:"62px",width:v?"calc(100vw - 32px)":"62px",maxWidth:v?"398px":"62px",background:v?"rgba(22,22,22,0.92)":"rgba(22,22,22,0.8)",backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)",border:"1px solid rgba(255,255,255,0.1)",transition:"all 0.35s cubic-bezier(0.4,0,0.2,1)",boxShadow:v?"0 8px 32px rgba(0,0,0,0.5)":"0 4px 16px rgba(0,0,0,0.4)",flexDirection:"row-reverse"},children:[e.jsx("button",{onTouchStart:C=>C.stopPropagation(),onClick:C=>{C.preventDefault(),C.stopPropagation(),w(h=>!h),y&&k(!1)},className:"flex items-center justify-center shrink-0 transition-transform active:scale-90",style:{width:"62px",height:"62px"},children:e.jsx(hr,{size:22,style:{color:v?"rgba(255,255,255,0.8)":"rgba(255,255,255,0.55)",transform:v?"rotate(45deg)":"rotate(0deg)",transition:"transform 0.3s cubic-bezier(0.4,0,0.2,1), color 0.2s ease"}})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1px",flex:1,overflowX:"auto",paddingLeft:"8px",opacity:v?1:0,pointerEvents:v?"auto":"none",transition:"opacity 0.18s ease "+(v?"0.12s":"0s")},className:"scrollbar-none",children:[qa.map(({icon:C,label:h,wrap:T,placeholder:I})=>e.jsx(oe,{onPress:()=>{N.current&&$s(N.current,d,u,T,I,G.current,ee.current)},title:h,children:e.jsx(C,{size:15,strokeWidth:2})},h)),e.jsx("div",{className:"w-px h-4 mx-1 shrink-0",style:{background:"rgba(255,255,255,0.1)"}}),[{char:"#",label:"Agrupar conteúdo",color:"rgba(129,140,248,0.85)",action:()=>{N.current&&$s(N.current,d,u,["#",""],"tema",G.current,ee.current)}},{char:"@",label:"Citar membro",color:"rgba(251,191,36,0.85)",action:()=>{N.current&&$s(N.current,d,u,["@",""],"membro",G.current,ee.current)}},{char:"/",label:"Linkar post",color:"rgba(74,222,128,0.85)",action:()=>
267{if(!N.current)return;const C=G.current,h=d.slice(0,C),T=d.slice(C),I=h.length>0&&!/[\s\n]$/.test(h),K=h+(I?" /":"/")+T;u(K),requestAnimationFrame(()=>{if(!N.current)return;N.current.focus();const ie=C+(I?2:1);N.current.setSelectionRange(ie,ie),M(""),q(ie-1)})}}].map(({char:C,label:h,color:T,action:I})=>e.jsx("button",{onMouseDown:K=>K.preventDefault(),onClick:I,title:h,className:"flex items-center justify-center rounded-xl transition-all duration-150 active:scale-90 shrink-0",style:{width:"36px",height:"38px",background:"transparent"},onMouseEnter:K=>{K.currentTarget.style.background="rgba(255,255,255,0.06)"},onMouseLeave:K=>{K.currentTarget.style.background="transparent"},children:e.jsx("span",{className:"text-[15px] font-black leading-none",style:{color:T},children:C})},C)),e.jsx("div",{className:"w-px h-4 mx-1 shrink-0",style:{background:"rgba(255,255,255,0.1)"}}),e.jsx(oe,{onPress:()=>{var C;return(C=Y.current)==null?void 0:C.click()},title:"Adicionar imagem",children:e.jsx(Yr,{size:16})}),e.jsx(oe,{onPress:()=>{k(C=>!C),w(!1)},title:"Adicionar vÃdeo do YouTube",children:e.jsx(xs,{size:16})}),e.jsx("span",{className:"text-[10px] font-mono ml-1 shrink-0",style:{color:d.length>1800?"rgb(251,146,60)":"rgba(255,255,255,0.2)"},children:d.length})]})]})]}),document.body)]})}function gu({open:t,onClose:r,onSelect:s,spaces:a,isAdmin:o}){const i=n.useRef(null),l=Ks(),[f,p]=n.useState(!1);n.useEffect(()=>{t&&p(!0)},[t]);const g=o?a:a.filter(c=>c.post_permission==="all"&&!c.locked);return n.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t]),!f&&!t?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:i,onClick:r,style:{position:"fixed",inset:0,zIndex:190,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",opacity:t?1:0,pointerEvents:t?"auto":"none",transition:"opacity 0.28s ease"}}),e.jsxs("div",{onClick:c=>c.stopPropagation(),style:l?{position:"fixed",left:0,right:0,bottom:0,zIndex:195,background:"var(--sv-surface-solid, var(--sv-surface))",borderRadius:"24px 24px 0 0",border:"1px solid var(--sv-border-subtle)",borderBottom:"none",boxShadow:"0 -20px 60px rgba(0,0,0,0.5)",transform:t?"translateY(0%)":"translateY(100%)",transition:"transform 0.32s cubic-bezier(0.4,0,0.2,1)",paddingBottom:"calc(env(safe-area-inset-bottom, 0px) + 12px)"}:{position:"fixed",top:"50%",left:"50%",zIndex:195,width:"100%",maxWidth:"440px",background:"var(--sv-surface-solid, var(--sv-surface))",borderRadius:"24px",border:"1px solid var(--sv-border-subtle)",boxShadow:"0 20px 80px rgba(0,0,0,0.5)",transform:t?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:t?1:0,transition:"transform 0.28s cubic-bezier(0.4,0,0.2,1), opacity 0.28s ease",pointerEvents:t?"auto":"none"},children:[l&&e.jsx("div",{className:"flex justify-center pt-3 pb-1",children:e.jsx("div",{className:"w-10 h-1 rounded-full",style:{background:"var(--sv-border-medium, rgba(255,255,255,0.12))"}})}),e.jsxs("div",{className:"flex items-center justify-between px-5 pt-4 pb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-base font-black leading-tight",style:{color:"var(--sv-text-heading)"},children:"Onde deseja publicar?"}),e.jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--sv-text-muted)"},children:"Escolha o espaço para sua publicação"})]}),e.jsx("button",{onClick:r,className:"w-9 h-9 rounded-full flex items-center justify-center transition-all active:scale-90",style:{background:"var(--sv-surface-hover)",border:"1px solid var(--sv-border-subtle)"},children:e.jsx(Je,{size:16,style:{color:"var(--sv-text-muted)"}})})]}),e.jsx("div",{className:"flex flex-col px-3 gap-1 pb-4",children:g.map(c=>e.jsxs("button",{onClick:()=>{s({id:c.id,emoji:c.emoji,name:c.name})},className:"flex items-center gap-4 w-full px-4 py-3.5 rounded-2xl text-left transition-all duration-150 active:scale-[0.98]",style:{background:"var(--sv-surface-hover)",border:"1px solid var(--sv-border-subtle)"},onMouseEnter:x=>{x.currentTarget.style.background="var(--sv-surface-elevated, rgba(255,255,255,0.07))",x.currentTarget.style.borderColor="var(--sv-border-medium, rgba(255,255,255,0.12))"},onMouseLeave:x=>{x.currentTarget.style.background="var(--sv-surface-hover)",x.currentTarget.style.borderColor="var(--sv-border-subtle)"},children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shrink-0 text-xl",style:{background:"var(--sv-surface)"},children:c.emoji}),e.jsx("span",{className:"flex-1 text-[15px] font-semibold",style:{color:"var(--sv-text-primary)"},children:c.name}),e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center shrink-0",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-subtle)"},children:e.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"var(--sv-text-muted)"}})})]},c.id))})]})]})}const vu=["posts_changed","spaces_changed","access_group_spaces_changed"],Qr={posts_changed:new Set,spaces_changed:new Set,access_group_spaces_changed:new Set};let Tr=0,qs=null;function bu(){qs||(qs=nn("feed:global",vu.map(t=>({type:"broadcast",event:t})),t=>{const r=t==null?void 0:t.event;r&&Qr[r]&&Qr[r].forEach(s=>s())},{private:!0}))}function xi(t,r){Tr++,bu(),t.forEach(a=>Qr[a].add(r));let s=!1;return()=>{s||(s=!0,t.forEach(a=>Qr[a].delete(r)),Tr--,Tr<=0&&(Tr=0,qs==null||qs(),qs=null))}}const cr=new Set;let Cs=null,_n=!1;function yu(){cr.forEach(t=>t())}function wu(){return Q(this,null,function*(){var r,s,a;if(Cs||_n)return;_n=!0;let t=null;try{const{data:o}=yield Se.auth.getSession();t=(a=(s=(r=o.session)==null?void 0:r.user)==null?void 0:s.id)!=null?a:null}catch(o){t=null}_n=!1,!(!t||Cs||cr.size===0)&&(Cs=nn(`user-access-groups:${t}`,{type:"postgres_changes",event:"*",schema:"public",table:"user_access_groups",filter:`user_id=eq.${t}`},yu))})}function gi(t){return cr.add(t),wu(),()=>{cr.delete(t),cr.size===0&&(Cs==null||Cs(),Cs=null)}}const Dr=Se,vi="sv_spaces_cache";function ju(){try{const t=localStorage.getItem(vi);if(t)return JSON.parse(t)}catch(t){}return[]}function Wa(t){try{localStorage.setItem(vi,JSON.stringify(t))}catch(r){}}function Nu(t,r){let s=null;return()=>{s&&clearTimeout(s),s=setTimeout(t,r)}}function ca(){const t=ju(),[r,s]=n.useState(t),[a,o]=n.useState(t.length===0),i=n.useCallback(()=>Q(this,null,function*(){var v;const[p,g]=yield Promise.all([Dr.from("spaces").select("*").order("sort_order"),Se.auth.getSession()]),c=p.data;if(!c){o(!1);return}const x=(v=g.data.session)==null?void 0:v.user;if(!x){s([]),o(!1);return}const{data:d}=yield Dr.rpc("has_role",{_user_id:x.id,_role:"admin"});if(d){const w=c.map(_=>se(L({},_),{locked:!1}));s(w),Wa(w),o(!1);return}const{data:u}=yield Dr.from("user_access_groups").select("group_id").eq("user_id",x.id);let m=new Set;if(u&&u.length>0){const w=u.map(y=>y.group_id),{data:_}=yield Dr.from("access_group_spaces").select("space_id").in("group_id",w);m=new Set((_!=null?_:[]).map(y=>y.space_id))}const b=c.map(w=>se(L({},w),{locked:w.public_access?!1:!m.has(w.id)}));s(b),Wa(b),o(!1)}),[]);n.useEffect(()=>{i()},[i]);const l=n.useRef(i);n.useEffect(()=>{l.current=i},[i]);const f=n.useRef(Nu(()=>l.current(),500)).current;return n.useEffect(()=>{const p=()=>f();return window.addEventListener("access-groups-changed",p),()=>window.removeEventListener("access-groups-changed",p)},[]),n.useEffect(()=>{const p=()=>{document.visibilityState==="visible"&&f()};return document.addEventListener("visibilitychange",p),()=>{document.removeEventListener("visibilitychange",p)}},[]),n.useEffect(()=>{const p=xi(["spaces_changed","access_group_spaces_changed"],f),g=gi(f);return()=>{p(),g()}},[]),{spaces:r,loading:a,refetch:i}}const ku=Se;var Or,uo;const _u=!!((uo=(Or=window.Capacitor)==null?void 0:Or.isNativePlatform)!=null&&uo.call(Or)),Va=[{icon:Yo,label:"Editar perfil",danger:!1,action:"edit"},{icon:Tc,label:"Central de Notificações",danger:!1,action:"notifications"},{icon:qo,label:"Sair",danger:!0,action:"logout"}],Su={icon:Ur,label:"Painel Admin",danger:!1,action:"admin"};function Cu(){const[t,r]=n.useState(()=>!document.documentElement.classList.contains("checkout-light")),s=a=>
267{if(r(a),a){document.documentElement.classList.remove("checkout-light");try{localStorage.setItem("sv_theme","dark")}catch(o){}}else{document.documentElement.classList.add("checkout-light");try{localStorage.setItem("sv_theme","light")}catch(o){}}};return e.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-2 mb-2",children:[e.jsx(Go,{size:16,className:"shrink-0",style:{color:t?"var(--sv-icon-muted)":"hsl(38, 92%, 50%)"}}),e.jsx("span",{className:"text-[13px] font-semibold flex-1",style:{color:"var(--sv-text-secondary)"},children:"Modo escuro"}),e.jsx(xr,{checked:t,onCheckedChange:s})]})}function Eu({activeTab:t,onTabChange:r,onAdminOpen:s,onNewPost:a,onEditProfile:o,onNotifications:i,onSpaceSelect:l,isAdmin:f,authLoading:p,userProfile:g}){var j;const{isLight:c}=No(),x=bs(),{spaces:d}=ca(),[u,m]=n.useState(!1),[b,v]=n.useState({}),[w,_]=n.useState([]),y=n.useRef(null);n.useEffect(()=>{const M=()=>Q(this,null,function*(){const{data:q}=yield ku.from("nav_links").select("*").eq("visible",!0).order("sort_order");_(q!=null?q:[])});M();const $=()=>{document.visibilityState==="visible"&&M()};return document.addEventListener("visibilitychange",$),()=>{document.removeEventListener("visibilitychange",$)}},[]);const k=d.reduce((M,$)=>{var ne;const q=(ne=$.group_name)!=null?ne:"Outros";return M[q]||(M[q]=[]),M[q].push($),M},{}),E=["Ponto de Partida","Comunidade"],S=[...E.filter(M=>k[M]),...Object.keys(k).filter(M=>!E.includes(M))],R=M=>v($=>se(L({},$),{[M]:$[M]===void 0?!1:!$[M]})),z=M=>b[M]===void 0?!0:b[M];return n.useEffect(()=>{if(!u)return;const M=$=>{y.current&&!y.current.contains($.target)&&m(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[u]),e.jsxs("aside",{className:"hidden lg:flex flex-col fixed left-0 top-0 h-full z-40 overflow-y-auto",style:{width:"260px",background:"var(--sv-surface-solid)",backdropFilter:"blur(24px) saturate(180%)",WebkitBackdropFilter:"blur(24px) saturate(180%)",borderRight:"1px solid var(--sv-border-subtle)",scrollbarWidth:"none"},children:[e.jsx("div",{className:"flex items-center px-4 pt-4 pb-4 shrink-0",children:e.jsx("div",{className:"w-[130px] h-[50px] flex items-center justify-start overflow-hidden",style:{mixBlendMode:c?"normal":"screen"},children:e.jsx("img",{src:c?ko:on,alt:"SetVerso",className:"object-contain object-left",style:{width:c?"140%":"100%",height:c?"140%":"100%"}})})}),e.jsxs("div",{className:"px-3 flex-1",children:[e.jsxs("button",{onClick:()=>{r&&r("Feed")},className:"flex items-center gap-2.5 w-full px-3 py-2 rounded-xl mb-1 transition-all duration-150",style:{background:t==="Feed"?"var(--sv-surface-hover)":"transparent"},onMouseEnter:M=>{M.currentTarget.style.background="var(--sv-surface-hover)"},onMouseLeave:M=>{t!=="Feed"&&(M.currentTarget.style.background="transparent")},children:[e.jsx("span",{className:"text-base shrink-0 leading-none",children:"ð°"}),e.jsx("span",{className:"flex-1 text-[13px] text-left font-medium",style:{color:t==="Feed"?"var(--sv-text-heading)":"var(--sv-text-secondary)"},children:"Feed"})]}),S.map(M=>e.jsxs("div",{className:"mb-4",children:[e.jsxs("button",{onClick:()=>R(M),className:"flex items-center gap-2 w-full px-3 mb-1.5 text-left active:opacity-70 transition-opacity",children:[e.jsx(Hs,{size:12,className:"shrink-0 transition-transform duration-200",style:{color:"var(--sv-text-muted)",transform:z(M)?"rotate(0deg)":"rotate(-90deg)"}}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em]",style:{color:"var(--sv-text-muted)"},children:M}),!z(M)&&e.jsx("span",{className:"text-[9px] font-medium",style:{color:"var(--sv-text-faint)"},children:k[M].length})]}),e.jsx("div",{className:"flex flex-col gap-0.5 overflow-hidden transition-all duration-300",style:{maxHeight:z(M)?`${k[M].length*44}px`:"0px",opacity:z(M)?1:0},children:k[M].map($=>{const q=!!$.locked;return e.jsxs("button",{className:"flex items-center gap-2.5 w-full px-3 py-2 rounded-xl text-left transition-all duration-150 group",style:{opacity:q?.55:1,cursor:q?"not-allowed":"pointer"},onClick:()=>{if(q){Ie.info("Este espaço não está incluso no seu plano.");return}l==null||l($)},onMouseEnter:ne=>{ne.currentTarget.style.background="var(--sv-surface-hover)"},onMouseLeave:ne=>{ne.currentTarget.style.background="transparent"},"aria-disabled":q,children:[e.jsx("span",{className:"text-base shrink-0 leading-none",style:{filter:q?"grayscale(0.4)":void 0},children:$.emoji}),e.jsx("span",{className:"flex-1 text-[13px] transition-colors truncate font-medium",style:{color:"var(--sv-text-secondary)"},children:$.name}),q?e.jsx(Us,{size:12,className:"shrink-0",style:{color:"var(--sv-text-muted)"}}):$.badge?e.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded-full shrink-0",style:{background:"var(--sv-surface-hover)",color:"var(--sv-text-tertiary)"},children:$.badge}):null]},$.id)})})]},M)),w.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em] px-3 mb-2",style:{color:"var(--sv-text-muted)"},children:"Links"}),e.jsx("div",{className:"flex flex-col gap-0.5",children:w.filter(M=>!(_u&&(M.label.toLowerCase().includes("aplicativo")||M.label.toLowerCase().includes("download")))).map(M=>e.jsxs("a",{href:M.url,target:M.open_external?"_blank":void 0,rel:
267M.open_external?"noopener noreferrer":void 0,"data-external":M.open_external?"true":void 0,className:"flex items-center gap-2.5 w-full px-3 py-2 rounded-xl transition-all duration-150 group text-left no-underline",onMouseEnter:$=>{$.currentTarget.style.background="var(--sv-surface-hover)"},onMouseLeave:$=>{$.currentTarget.style.background="transparent"},children:[M.emoji&&M.emoji!=="ð"?e.jsx("span",{className:"text-base shrink-0 leading-none",children:M.emoji}):e.jsx(Io,{size:12,className:"shrink-0",style:{color:"var(--sv-text-muted)"}}),e.jsx("span",{className:"text-[13px] transition-colors font-medium",style:{color:"var(--sv-text-secondary)"},children:M.label})]},M.id))})]})]}),e.jsxs("div",{className:"px-3 pb-6 shrink-0 relative",ref:y,children:[e.jsx("div",{className:"h-px mx-1 mb-3",style:{background:"var(--sv-border-subtle)"}}),e.jsx(Cu,{}),e.jsxs("button",{onClick:()=>a==null?void 0:a(),className:"flex items-center gap-2.5 w-full px-4 py-3 rounded-2xl mb-2 transition-all duration-200 hover:opacity-90",style:{background:"rgba(34, 197, 94, 0.12)",border:"1px solid rgba(34, 197, 94, 0.25)"},children:[e.jsx(hr,{size:16,style:{color:"rgb(74, 222, 128)"},className:"shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold",style:{color:"rgb(74, 222, 128)"},children:"Nova publicação"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{style:{position:"absolute",bottom:"100%",left:0,right:0,marginBottom:"8px",overflow:"hidden",maxHeight:u?"300px":"0px",opacity:u?1:0,transition:"max-height 0.35s cubic-bezier(0.4,0,0.2,1), opacity 0.2s ease",background:"var(--sv-surface-elevated)",backdropFilter:"blur(24px) saturate(180%)",WebkitBackdropFilter:"blur(24px) saturate(180%)",borderRadius:"20px",border:"1px solid var(--sv-border-medium)",boxShadow:"var(--sv-shadow-dropdown)",pointerEvents:u?"auto":"none",zIndex:50},children:e.jsx("div",{className:"flex flex-col gap-0.5 p-2",children:(!p&&f?[Su,...Va]:Va).map(({icon:M,label:$,danger:q,action:ne})=>e.jsxs("button",{onClick:()=>{if(m(!1),ne==="admin"){x("/admin");return}if(ne==="edit"&&o){requestAnimationFrame(()=>{requestAnimationFrame(()=>o())});return}if(ne==="notifications"&&i){requestAnimationFrame(()=>{requestAnimationFrame(()=>i())});return}ne==="logout"&&Lt(()=>Q(this,null,function*(){const{logoutWithPushCleanup:ae}=yield import("./index-DFRwvZ6i.js").then(J=>J.al);return{logoutWithPushCleanup:ae}}),__vite__mapDeps([1,2,3,4])).then(({logoutWithPushCleanup:ae})=>{ae()})},className:"flex items-center gap-3.5 w-full px-4 py-3.5 rounded-2xl text-left transition-all duration-150 active:scale-[0.98]",style:{color:ne==="admin"||q?"hsl(var(--setverso-red))":"var(--sv-text-primary)"},children:[e.jsx(M,{size:17,className:"shrink-0",style:ne==="admin"?{color:"hsl(var(--setverso-red))"}:void 0}),e.jsx("span",{className:"text-[14px] font-semibold",children:$})]},$))})}),e.jsxs("button",{onClick:()=>m(M=>!M),className:"flex items-center gap-3 px-2 py-2 w-full rounded-xl transition-all duration-200 group",children:[(()=>{var $,q,ne;const M=(q=($=g==null?void 0:g.name)==null?void 0:$.split(" ").slice(0,2).map(ae=>ae[0]).join("").toUpperCase())!=null?q:"?";return e.jsxs(ut,{className:"h-8 w-8 border-2 shrink-0",style:{borderColor:"hsl(var(--setverso-red) / 0.4)"},children:[e.jsx(ft,{className:"text-xs font-bold text-white",style:{background:"hsl(var(--setverso-red))"},children:M}),(g==null?void 0:g.avatar_url)&&e.jsx(Ze,{src:g.avatar_url,alt:(ne=g.name)!=null?ne:"Perfil",className:"object-cover"})]})})(),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsx("p",{className:"text-sm font-bold leading-tight truncate",style:{color:"var(--sv-text-heading)"},children:(j=g==null?void 0:g.name)!=null?j:"Carregando..."}),e.jsx("p",{className:"text-xs leading-tight",style:{color:"var(--sv-text-tertiary)"},children:g!=null&&g.username?`@${g.username}`:""})]}),e.jsx(Hs,{size:14,className:"shrink-0 transition-transform duration-300",style:{color:"var(--sv-text-muted)",transform:u?"rotate(180deg)":"rotate(0deg)"}})]})]})]})]})}const Ru=mo("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function bi(a){var o=a,{className:t,variant:r}=o,s=xe(o,["className","variant"]);return e.jsx("div",L({className:Be(Ru({variant:r}),t)},s))}var Mu=n.createContext(void 0);function yi(t){const r=n.useContext(Mu);return t||r||"ltr"}var Sn="rovingFocusGroup.onEntryFocus",Au={bubbles:!1,cancelable:!0},vr="RovingFocusGroup",[Gn,wi,Pu]=po(vr),[Tu,ji]=mr(vr,[Pu]),[Du,zu]=Tu(vr),Ni=n.forwardRef((t,r)=>e.jsx(Gn.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Gn.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Iu,se(L({},t),{ref:r}))})}));Ni.displayName=vr;var Iu=n.forwardRef((t,r)=>{const z=t,{__scopeRovingFocusGroup:s,orientation:a,loop:o=!1,dir:i,currentTabStopId:l,defaultCurrentTabStopId:f,onCurrentTabStopIdChange:p,onEntryFocus:g,preventScrollOnEntryFocus:c=!1}=z,x=xe(z,["__scopeRovingFocusGroup","orientation","loop","dir","currentTabStopId","defaultCurrentTabStopId","onCurrentTabStopIdChange","onEntryFocus","preventScrollOnEntryFocus"]),d=n.useRef(null),u=vs(r,d),m=yi(i),[b,v]=ho({prop:l,defaultProp:f!=null?f:null,onChange:p,caller:vr}),[w,_]=n.useState(!1),y=rn(g),k=wi(s),E=n.useRef(!1),[S,R]=n.useState(0);return n.useEffect(()=>{const j=d.current;if(j)return j.addEventListener(Sn,y),()=>j.removeEventListener(Sn,y)},[y]),e.jsx(Du,{scope:s,orientation:a,dir:m,loop:o,currentTabStopId:b,onItemFocus:n.useCallback(j=>v(j),[v]),onItemShiftTab:n.useCallback(()=>_(!0),[]),onFocusableItemAdd:n.useCallback(()=>R(j=>j+1),[]),onFocusableItemRemove:n.useCallback(()=>R(j=>j-1),[]),children:e.jsx(Ht.div,se(L({tabIndex:w||S===0?-1:0,"data-orientation":a},x),{ref:u,style:L({outline:"none"},t.style),onMouseDown:qe(t.onMouseDown,()=>{E.current=!0}),onFocus:qe(t.onFocus,j=>{const M=!E.current;if(j.target===j.currentTarget&&M&&!w){const $=new CustomEvent(Sn,Au);if(j.currentTarget.dispatchEvent($),!$.defaultPrevented){const q=k().filter(ke=>ke.focusable),ne=q.find(ke=>ke.active),ae=q.find(ke=>
vendor: 9,609 bytes, line 267
267ke.id===b),je=[ne,ae,...q].filter(Boolean).map(ke=>ke.ref.current);Si(je,c)}}E.current=!1}),onBlur:qe(t.onBlur,()=>_(!1))}))})}),ki="RovingFocusGroupItem",_i=n.forwardRef((t,r)=>{const v=t,{__scopeRovingFocusGroup:s,focusable:a=!0,active:o=!1,tabStopId:i,children:l}=v,f=xe(v,["__scopeRovingFocusGroup","focusable","active","tabStopId","children"]),p=zn(),g=i||p,c=zu(ki,s),x=c.currentTabStopId===g,d=wi(s),{onFocusableItemAdd:u,onFocusableItemRemove:m,currentTabStopId:b}=c;return n.useEffect(()=>{if(a)return u(),()=>m()},[a,u,m]),e.jsx(Gn.ItemSlot,{scope:s,id:g,focusable:a,active:o,children:e.jsx(Ht.span,se(L({tabIndex:x?0:-1,"data-orientation":c.orientation},f),{ref:r,onMouseDown:qe(t.onMouseDown,w=>{a?c.onItemFocus(g):w.preventDefault()}),onFocus:qe(t.onFocus,()=>c.onItemFocus(g)),onKeyDown:qe(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){c.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const _=Ou(w,c.orientation,c.dir);if(_!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let k=d().filter(E=>E.focusable).map(E=>E.ref.current);if(_==="last")k.reverse();else if(_==="prev"||_==="next"){_==="prev"&&k.reverse();const E=k.indexOf(w.currentTarget);k=c.loop?$u(k,E+1):k.slice(E+1)}setTimeout(()=>Si(k))}}),children:typeof l=="function"?l({isCurrentTabStop:x,hasTabStop:b!=null}):l}))})});_i.displayName=ki;var Lu={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Fu(t,r){return r!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Ou(t,r,s){const a=Fu(t.key,s);if(!(r==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(r==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return Lu[a]}function Si(t,r=!1){const s=document.activeElement;for(const a of t)if(a===s||(a.focus({preventScroll:r}),document.activeElement!==s))return}function $u(t,r){return t.map((s,a)=>t[(r+a)%t.length])}var Bu=Ni,qu=_i,Yn=["Enter"," "],Wu=["ArrowDown","PageUp","Home"],Ci=["ArrowUp","PageDown","End"],Vu=[...Wu,...Ci],Hu={ltr:[...Yn,"ArrowRight"],rtl:[...Yn,"ArrowLeft"]},Uu={ltr:["ArrowLeft"],rtl:["ArrowRight"]},br="Menu",[ur,Gu,Yu]=po(br),[As,Ei]=mr(br,[Yu,xo,ji]),dn=xo(),Ri=ji(),[Ku,Ps]=As(br),[Xu,yr]=As(br),Mi=t=>{const{__scopeMenu:r,open:s=!1,children:a,dir:o,onOpenChange:i,modal:l=!0}=t,f=dn(r),[p,g]=n.useState(null),c=n.useRef(!1),x=rn(i),d=yi(o);return n.useEffect(()=>{const u=()=>{c.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>c.current=!1;return document.addEventListener("keydown",u,{capture:!0}),()=>{document.removeEventListener("keydown",u,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),e.jsx(hc,se(L({},f),{children:e.jsx(Ku,{scope:r,open:s,onOpenChange:x,content:p,onContentChange:g,children:e.jsx(Xu,{scope:r,onClose:n.useCallback(()=>x(!1),[x]),isUsingKeyboardRef:c,dir:d,modal:l,children:a})})}))};Mi.displayName=br;var Zu="MenuAnchor",da=n.forwardRef((t,r)=>{const i=t,{__scopeMenu:s}=i,a=xe(i,["__scopeMenu"]),o=dn(s);return e.jsx(xc,se(L(L({},o),a),{ref:r}))});da.displayName=Zu;var ua="MenuPortal",[Ju,Ai]=As(ua,{forceMount:void 0}),Pi=t=>{const{__scopeMenu:r,forceMount:s,children:a,container:o}=t,i=Ps(ua,r);return e.jsx(Ju,{scope:r,forceMount:s,children:e.jsx(an,{present:s||i.open,children:e.jsx(gc,{asChild:!0,container:o,children:a})})})};Pi.displayName=ua;var Ft="MenuContent",[Qu,fa]=As(Ft),Ti=n.forwardRef((t,r)=>{const s=Ai(Ft,t.__scopeMenu),f=t,{forceMount:a=s.forceMount}=f,o=xe(f,["forceMount"]),i=Ps(Ft,t.__scopeMenu),l=yr(Ft,t.__scopeMenu);return e.jsx(ur.Provider,{scope:t.__scopeMenu,children:e.jsx(an,{present:a||i.open,children:e.jsx(ur.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(ef,se(L({},o),{ref:r})):e.jsx(tf,se(L({},o),{ref:r}))})})})}),ef=n.forwardRef((t,r)=>{const s=Ps(Ft,t.__scopeMenu),a=n.useRef(null),o=vs(r,a);return n.useEffect(()=>{const i=a.current;if(i)return Dc(i)},[]),e.jsx(ma,se(L({},t),{ref:o,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:qe(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)}))}),tf=n.forwardRef((t,r)=>{const s=Ps(Ft,t.__scopeMenu);return e.jsx(ma,se(L({},t),{ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)}))}),sf=wc("MenuContent.ScrollLock"),ma=n.forwardRef((t,r)=>{const P=t,{__scopeMenu:s,loop:a=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:l,disableOutsidePointerEvents:f,onEntryFocus:p,onEscapeKeyDown:g,onPointerDownOutside:c,onFocusOutside:x,onInteractOutside:d,onDismiss:u,disableOutsideScroll:m}=P,b=xe(P,["__scopeMenu","loop","trapFocus","onOpenAutoFocus","onCloseAutoFocus","disableOutsidePointerEvents","onEntryFocus","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","disableOutsideScroll"]),v=Ps(Ft,s),w=yr(Ft,s),_=dn(s),y=Ri(s),k=Gu(s),[E,S]=n.useState(null),R=n.useRef(null),z=vs(r,R,v.onContentChange),j=n.useRef(0),M=n.useRef(""),$=n.useRef(0),q=n.useRef(null),ne=n.useRef("right"),ae=n.useRef(0),J=m?Ic:n.Fragment,je=m?{as:sf,allowPinchZoom:!0}:void 0,ke=N=>{var le,fe;const Y=M.current+N,F=k().filter(pe=>!pe.disabled),G=document.activeElement,ee=(le=F.find(pe=>pe.ref.current===G))==null?void 0:le.textValue,re=F.map(pe=>pe.textValue),be=hf(re,Y,ee),ge=(fe=F.find(pe=>pe.textValue===be))==null?void 0:fe.ref.current;(function pe(Ne){M.current=Ne,window.clearTimeout(j.current),Ne!==""&&(j.current=window.setTimeout(()=>pe(""),1e3))})(Y),ge&&setTimeout(()=>ge.focus())};n.useEffect(()=>()=>window.clearTimeout(j.current),[]),zc();const ve=n.useCallback(N=>{var F,G;return ne.current===((F=q.current)==null?void 0:F.side)&&gf(N,(G=q.current)==null?void 0:G.area)},[]);return e.jsx(Qu,{scope:s,searchRef:M,onItemEnter:n.useCallback(N=>{ve(N)&&N.preventDefault()},[ve]),onItemLeave:n.useCallback(N=>{var Y;ve(N)||((Y=R.current)==null||Y.focus(),S(null))},[ve]),onTriggerLeave:n.useCallback(N=>{ve(N)&&N.preventDefault()},[ve]),pointerGraceTimerRef:$,onPointerGraceIntentChange:n.useCallback(N=>{q.current=N},[]),children:e.jsx(J,se(L({},je),{children:e.jsx(Lc,{asChild:!0,trapped:o,onMountAutoFocus:qe(i,N=>{var Y;N.preventDefault(),(Y=R.current)==null||Y.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(bc,{asChild:!0,disableOutsidePointerEvents:f,onEscapeKeyDown:g,onPointerDownOutside:c,onFocusOutside:x,onInteractOutside:d,onDismiss:u,children:e.jsx(Bu,se(L({asChild:!0},y),{dir:w.dir,orientation:"vertical",loop:a,currentTabStopId:E,onCurrentTabStopIdChange:S,onEntryFocus:qe(p,N=>{w.isUsingKeyboardRef.current||N.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(yc,se(L(L({role:"menu","aria-orientation":"vertical","data-state":Ki(v.open),"data-radix-menu-content":"",dir:w.dir},_),b),{ref:z,style:L({outline:"none"},b.style),onKeyDown:qe(b.onKeyDown,N=>{const F=N.target.closest("[data-radix-menu-content]")===N.currentTarget,G=N.ctrlKey||N.altKey||N.metaKey,ee=N.key.length===1;F&&(N.key==="Tab"&&N.preventDefault(),!G&&ee&&ke(N.key));const re=R.current;if(N.target!==re||!Vu.includes(N.key))return;N.preventDefault();const ge=k().filter(le=>!le.disabled).map(le=>le.ref.current);Ci.includes(N.key)&&ge.reverse(),mf(ge)}),onBlur:qe(t.onBlur,N=>{N.currentTarget.contains(N.target)||(window.clearTimeout(j.current),M.current="")}),onPointerMove:qe(t.onPointerMove,fr(N=>{const Y=N.target,F=ae.current!==N.clientX;if(N.currentTarget.contains(Y)&&F){const G=N.clientX>ae.current?"right":"left";ne.current=G,ae.current=N.clientX}}))}))}))})})}))})});Ti.displayName=Ft;var rf="MenuGroup",pa=n.forwardRef((t,r)=>{const o=t,{__scopeMenu:s}=o,a=xe(o,["__scopeMenu"]);return e.jsx(Ht.div,se(L({role:"group"},a),{ref:r}))});pa.displayName=rf;var nf="MenuLabel",Di=n.forwardRef((t,r)=>{const o=t,{__scopeMenu:s}=o,a=xe(o,["__scopeMenu"]);return e.jsx(Ht.div,se(L({},a),{ref:r}))});Di.displayName=nf;var en="MenuItem",Ha="menu.itemSelect",un=n.forwardRef((t,r)=>{const x=t,{disabled:s=!1,onSelect:a}=x,o=xe(x,["disabled","onSelect"]),i=n.useRef(null),l=yr(en,t.__scopeMenu),f=fa(en,t.__scopeMenu),p=vs(r,i),g=n.useRef(!1),c=()=>{const d=i.current;if(!s&&d){const u=new CustomEvent(Ha,{bubbles:!0,cancelable:!0});d.addEventListener(Ha,m=>a==null?void 0:a(m),{once:!0}),vc(d,u),u.defaultPrevented?g.current=!1:l.onClose()}};return e.jsx(zi,se(L({},o),{ref:p,disabled:s,onClick:qe(t.onClick,c),onPointerDown:d=>{var u;(u=t.onPointerDown)==null||u.call(t,d),g.current=!0},onPointerUp:qe(t.onPointerUp,d=>{var u;g.current||(u=d.currentTarget)==null||u.click()}),onKeyDown:qe(t.onKeyDown,d=>{const u=f.searchRef.current!=="";s||u&&d.key===" "||Yn.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})}))});un.displayName=en;var zi=n.forwardRef((t,r)=>{const m=t,{__scopeMenu:s,disabled:a=!1,textValue:o}=m,i=xe(m,["__scopeMenu","disabled","textValue"]),l=fa(en,s),f=Ri(s),p=n.useRef(null),g=vs(r,p),[c,x]=n.useState(!1),[d,u]=n.useState("");return n.useEffect(()=>{var v;const b=p.current;b&&u(((v=b.textContent)!=null?v:"").trim())},[i.children]),e.jsx(ur.ItemSlot,{scope:s,disabled:a,textValue:o!=null?o:d,children:e.jsx(qu,se(L({asChild:!0},f),{focusable:!a,children:e.jsx(Ht.div,se(L({role:"menuitem","data-highlighted":c?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0},i),{ref:g,onPointerMove:qe(t.onPointerMove,fr(b=>{a?l.onItemLeave(b):(l.onItemEnter(b),b.defaultPrevented||b.currentTarget.focu
267s({preventScroll:!0}))})),onPointerLeave:qe(t.onPointerLeave,fr(b=>l.onItemLeave(b))),onFocus:qe(t.onFocus,()=>x(!0)),onBlur:qe(t.onBlur,()=>x(!1))}))}))})}),af="MenuCheckboxItem",Ii=n.forwardRef((t,r)=>{const i=t,{checked:s=!1,onCheckedChange:a}=i,o=xe(i,["checked","onCheckedChange"]);return e.jsx(Bi,{scope:t.__scopeMenu,checked:s,children:e.jsx(un,se(L({role:"menuitemcheckbox","aria-checked":tn(s)?"mixed":s},o),{ref:r,"data-state":xa(s),onSelect:qe(o.onSelect,()=>a==null?void 0:a(tn(s)?!0:!s),{checkForDefaultPrevented:!1})}))})});Ii.displayName=af;var Li="MenuRadioGroup",[of,lf]=As(Li,{value:void 0,onValueChange:()=>{}}),Fi=n.forwardRef((t,r)=>{const l=t,{value:s,onValueChange:a}=l,o=xe(l,["value","onValueChange"]),i=rn(a);return e.jsx(of,{scope:t.__scopeMenu,value:s,onValueChange:i,children:e.jsx(pa,se(L({},o),{ref:r}))})});Fi.displayName=Li;var Oi="MenuRadioItem",$i=n.forwardRef((t,r)=>{const l=t,{value:s}=l,a=xe(l,["value"]),o=lf(Oi,t.__scopeMenu),i=s===o.value;return e.jsx(Bi,{scope:t.__scopeMenu,checked:i,children:e.jsx(un,se(L({role:"menuitemradio","aria-checked":i},a),{ref:r,"data-state":xa(i),onSelect:qe(a.onSelect,()=>{var f;return(f=o.onValueChange)==null?void 0:f.call(o,s)},{checkForDefaultPrevented:!1})}))})});$i.displayName=Oi;var ha="MenuItemIndicator",[Bi,cf]=As(ha,{checked:!1}),qi=n.forwardRef((t,r)=>{const l=t,{__scopeMenu:s,forceMount:a}=l,o=xe(l,["__scopeMenu","forceMount"]),i=cf(ha,s);return e.jsx(an,{present:a||tn(i.checked)||i.checked===!0,children:e.jsx(Ht.span,se(L({},o),{ref:r,"data-state":xa(i.checked)}))})});qi.displayName=ha;var df="MenuSeparator",Wi=n.forwardRef((t,r)=>{const o=t,{__scopeMenu:s}=o,a=xe(o,["__scopeMenu"]);return e.jsx(Ht.div,se(L({role:"separator","aria-orientation":"horizontal"},a),{ref:r}))});Wi.displayName=df;var uf="MenuArrow",Vi=n.forwardRef((t,r)=>{const i=t,{__scopeMenu:s}=i,a=xe(i,["__scopeMenu"]),o=dn(s);return e.jsx(jc,se(L(L({},o),a),{ref:r}))});Vi.displayName=uf;var ff="MenuSub",[eh,Hi]=As(ff),lr="MenuSubTrigger",Ui=n.forwardRef((t,r)=>{const s=Ps(lr,t.__scopeMenu),a=yr(lr,t.__scopeMenu),o=Hi(lr,t.__scopeMenu),i=fa(lr,t.__scopeMenu),l=n.useRef(null),{pointerGraceTimerRef:f,onPointerGraceIntentChange:p}=i,g={__scopeMenu:t.__scopeMenu},c=n.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return n.useEffect(()=>c,[c]),n.useEffect(()=>{const x=f.current;return()=>{window.clearTimeout(x),p(null)}},[f,p]),e.jsx(da,se(L({asChild:!0},g),{children:e.jsx(zi,se(L({id:o.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":o.contentId,"data-state":Ki(s.open)},t),{ref:go(r,o.onTriggerChange),onClick:x=>{var d;(d=t.onClick)==null||d.call(t,x),!(t.disabled||x.defaultPrevented)&&(x.currentTarget.focus(),s.open||s.onOpenChange(!0))},onPointerMove:qe(t.onPointerMove,fr(x=>{i.onItemEnter(x),!x.defaultPrevented&&!t.disabled&&!s.open&&!l.current&&(i.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{s.onOpenChange(!0),c()},100))})),onPointerLeave:qe(t.onPointerLeave,fr(x=>{var u,m;c();const d=(u=s.content)==null?void 0:u.getBoundingClientRect();if(d){const b=(m=s.content)==null?void 0:m.dataset.side,v=b==="right",w=v?-5:5,_=d[v?"left":"right"],y=d[v?"right":"left"];i.onPointerGraceIntentChange({area:[{x:x.clientX+w,y:x.clientY},{x:_,y:d.top},{x:y,y:d.top},{x:y,y:d.bottom},{x:_,y:d.bottom}],side:b}),window.clearTimeout(f.current),f.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(x),x.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:qe(t.onKeyDown,x=>{var u;const d=i.searchRef.current!=="";t.disabled||d&&x.key===" "||Hu[a.dir].includes(x.key)&&(s.onOpenChange(!0),(u=s.content)==null||u.focus(),x.preventDefault())})}))}))});Ui.displayName=lr;var Gi="MenuSubContent",Yi=n.forwardRef((t,r)=>{const s=Ai(Ft,t.__scopeMenu),c=t,{forceMount:a=s.forceMount}=c,o=xe(c,["forceMount"]),i=Ps(Ft,t.__scopeMenu),l=yr(Ft,t.__scopeMenu),f=Hi(Gi,t.__scopeMenu),p=n.useRef(null),g=vs(r,p);return e.jsx(ur.Provider,{scope:t.__scopeMenu,children:e.jsx(an,{present:a||i.open,children:e.jsx(ur.Slot,{scope:t.__scopeMenu,children:e.jsx(ma,se(L({id:f.contentId,"aria-labelledby":f.triggerId}
267,o),{ref:g,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:x=>{var d;l.isUsingKeyboardRef.current&&((d=p.current)==null||d.focus()),x.preventDefault()},onCloseAutoFocus:x=>x.preventDefault(),onFocusOutside:qe(t.onFocusOutside,x=>{x.target!==f.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:qe(t.onEscapeKeyDown,x=>{l.onClose(),x.preventDefault()}),onKeyDown:qe(t.onKeyDown,x=>{var m;const d=x.currentTarget.contains(x.target),u=Uu[l.dir].includes(x.key);d&&u&&(i.onOpenChange(!1),(m=f.trigger)==null||m.focus(),x.preventDefault())})}))})})})});Yi.displayName=Gi;function Ki(t){return t?"open":"closed"}function tn(t){return t==="indeterminate"}function xa(t){return tn(t)?"indeterminate":t?"checked":"unchecked"}function mf(t){const r=document.activeElement;for(const s of t)if(s===r||(s.focus(),document.activeElement!==r))return}function pf(t,r){return t.map((s,a)=>t[(r+a)%t.length])}function hf(t,r,s){const o=r.length>1&&Array.from(r).every(g=>g===r[0])?r[0]:r,i=s?t.indexOf(s):-1;let l=pf(t,Math.max(i,0));o.length===1&&(l=l.filter(g=>g!==s));const p=l.find(g=>g.toLowerCase().startsWith(o.toLowerCase()));return p!==s?p:void 0}function xf(t,r){const{x:s,y:a}=t;let o=!1;for(let i=0,l=r.length-1;i<r.length;l=i++){const f=r[i],p=r[l],g=f.x,c=f.y,x=p.x,d=p.y;c>a!=d>a&&s<(x-g)*(a-c)/(d-c)+g&&(o=!o)}return o}function gf(t,r){if(!r)return!1;const s={x:t.clientX,y:t.clientY};return xf(s,r)}function fr(t){return r=>r.pointerType==="mouse"?t(r):void 0}var vf=Mi,bf=da,yf=Pi,wf=Ti,jf=pa,Nf=Di,kf=un,_f=Ii,Sf=Fi,Cf=$i,Ef=qi,Rf=Wi,Mf=Vi,Af=Ui,Pf=Yi,fn="DropdownMenu",[Tf]=mr(fn,[Ei]),yt=Ei(),[Df,Xi]=Tf(fn),Zi=t=>{const{__scopeDropdownMenu:r,children:s,dir:a,open:o,defaultOpen:i,onOpenChange:l,modal:f=!0}=t,p=yt(r),g=n.useRef(null),[c,x]=ho({prop:o,defaultProp:i!=null?i:!1,onChange:l,caller:fn});return e.jsx(Df,{scope:r,triggerId:zn(),triggerRef:g,contentId:zn(),open:c,onOpenChange:x,onOpenToggle:n.useCallback(()=>x(d=>!d),[x]),modal:f,children:e.jsx(vf,se(L({},p),{open:c,onOpenChange:x,dir:a,modal:f,children:s}))})};Zi.displayName=fn;var Ji="DropdownMenuTrigger",Qi=n.forwardRef((t,r)=>{const f=t,{__scopeDropdownMenu:s,disabled:a=!1}=f,o=xe(f,["__scopeDropdownMenu","disabled"]),i=Xi(Ji,s),l=yt(s);return e.jsx(bf,se(L({asChild:!0},l),{children:e.jsx(Ht.button,se(L({type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":a?"":void 0,disabled:a},o),{ref:go(r,i.triggerRef),onPointerDown:qe(t.onPointerDown,p=>{!a&&p.button===0&&p.ctrlKey===!1&&(i.onOpenToggle(),i.open||p.preventDefault())}),onKeyDown:qe(t.onKeyDown,p=>{a||(["Enter"," "].includes(p.key)&&i.onOpenToggle(),p.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(p.key)&&p.preventDefault())})}))}))});Qi.displayName=Ji;var zf="DropdownMenuPortal",el=t=>{const o=t,{__scopeDropdownMenu:r}=o,s=xe(o,["__scopeDropdownMenu"]),a=yt(r);return e.jsx(yf,L(L({},a),s))};el.displayName=zf;var tl="DropdownMenuContent",sl=n.forwardRef((t,r)=>{const f=t,{__scopeDropdownMenu:s}=f,a=xe(f,["__scopeDropdownMenu"]),o=Xi(tl,s),i=yt(s),l=n.useRef(!1);return e.jsx(wf,se(L(L({id:o.contentId,"aria-labelledby":o.triggerId},i),a),{ref:r,onCloseAutoFocus:qe(t.onCloseAutoFocus,p=>{var g;l.current||(g=o.triggerRef.current)==null||g.focus(),l.current=!1,p.preventDefault()}),onInteractOutside:qe(t.onInteractOutside,p=>{const g=p.detail.originalEvent,c=g.button===0&&g.ctrlKey===!0,x=g.button===2||c;(!o.modal||x)&&(l.current=!0)}),style:se(L({},t.style),{"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"})}))});sl.displayName=tl;var If="DropdownMenuGroup",Lf=n.forwardRef((t,r)=>{const i=t,{__scopeDropdownMenu:s}=i,a=xe(i,["__scopeDropdownMenu"]),o=yt(s);return e.jsx(jf,se(L(L({},o),a),{ref:r}))});Lf.displayName=If;var Ff="DropdownMenuLabel",rl=n.forwardRef((t,r)=>{const i=t,{__scopeDropdownMenu:s}=i,a=xe(i,["__scopeDropdownMenu"]),o=yt(s);return e.jsx(Nf,se(L(L({},o),a),{ref:r}))});rl.displayName=Ff;var Of="DropdownMenuItem",nl=n.forwardRef((t,r)=>{const i=t,{__scopeDropdownMenu:s}=i,a=xe(i,["__scopeDropdownMenu"]),o=yt(s);return e.jsx(kf,se(L(L({},o),a),{ref:r}))});
267nl.displayName=Of;var $f="DropdownMenuCheckboxItem",al=n.forwardRef((t,r)=>{const i=t,{__scopeDropdownMenu:s}=i,a=xe(i,["__scopeDropdownMenu"]),o=yt(s);return e.jsx(_f,se(L(L({},o),a),{ref:r}))});al.displayName=$f;var Bf="DropdownMenuRadioGroup",qf=n.forwardRef((t,r)=>{const i=t,{__scopeDropdownMenu:s}=i,a=xe(i,["__scopeDropdownMenu"]),o=yt(s);return e.jsx(Sf,se(L(L({},o),a),{ref:r}))});qf.displayName=Bf;var Wf="DropdownMenuRadioItem",ol=n.forwardRef((t,r)=>{const i=t,{__scopeDropdownMenu:s}=i,a=xe(i,["__scopeDropdownMenu"]),o=yt(s);return e.jsx(Cf,se(L(L({},o),a),{ref:r}))});ol.displayName=Wf;var Vf="DropdownMenuItemIndicator",il=n.forwardRef((t,r)=>{const i=t,{__scopeDropdownMenu:s}=i,a=xe(i,["__scopeDropdownMenu"]),o=yt(s);return e.jsx(Ef,se(L(L({},o),a),{ref:r}))});il.displayName=Vf;var Hf="DropdownMenuSeparator",ll=n.forwardRef((t,r)=>{const i=t,{__scopeDropdownMenu:s}=i,a=xe(i,["__scopeDropdownMenu"]),o=yt(s);return e.jsx(Rf,se(L(L({},o),a),{ref:r}))});ll.displayName=Hf;var Uf="DropdownMenuArrow",Gf=n.forwardRef((t,r)=>{const i=t,{__scopeDropdownMenu:s}=i,a=xe(i,["__scopeDropdownMenu"]),o=yt(s);return e.jsx(Mf,se(L(L({},o),a),{ref:r}))});Gf.displayName=Uf;var Yf="DropdownMenuSubTrigger",cl=n.forwardRef((t,r)=>{const i=t,{__scopeDropdownMenu:s}=i,a=xe(i,["__scopeDropdownMenu"]),o=yt(s);return e.jsx(Af,se(L(L({},o),a),{ref:r}))});cl.displayName=Yf;var Kf="DropdownMenuSubContent",dl=n.forwardRef((t,r)=>{const i=t,{__scopeDropdownMenu:s}=i,a=xe(i,["__scopeDropdownMenu"]),o=yt(s);return e.jsx(Pf,se(L(L({},o),a),{ref:r,style:se(L({},t.style),{"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"})}))});dl.displayName=Kf;var Xf=Zi,Zf=Qi,Jf=el,ul=sl,fl=rl,ml=nl,pl=al,hl=ol,xl=il,gl=ll,vl=cl,bl=dl;const yl=Xf,wl=Zf,Qf=n.forwardRef((i,o)=>{var l=i,{className:t,inset:r,children:s}=l,a=xe(l,["className","inset","children"]);return e.jsxs(vl,se(L({ref:o,className:Be("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",r&&"pl-8",t)},a),{children:[s,e.jsx(gr,{className:"ml-auto h-4 w-4"})]}))});Qf.displayName=vl.displayName;const em=n.forwardRef((a,s)=>{var o=a,{className:t}=o,r=xe(o,["className"]);return e.jsx(bl,L({ref:s,className:Be("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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",t)},r))});em.displayName=bl.displayName;const ga=n.forwardRef((o,a)=>{var i=o,{className:t,sideOffset:r=4}=i,s=xe(i,["className","sideOffset"]);return e.jsx(Jf,{children:e.jsx(ul,L({ref:a,sideOffset:r,className:Be("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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",t)},s))})});ga.displayName=ul.displayName;const Rs=n.forwardRef((o,a)=>{var i=o,{className:t,inset:r}=i,s=xe(i,["className","inset"]);return e.jsx(ml,L({ref:a,className:Be("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",r&&"pl-8",t)},s))});Rs.displayName=ml.displayName;const tm=n.forwardRef((i,o)=>{var l=i,{className:t,children:r,checked:s}=l,a=xe(l,["className","children","checked"]);return e.jsxs(pl,se(L({ref:o,className:Be("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),checked:s},a),{children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(xl,{children:e.jsx(ia,{className:"h-4 w-4"})})}),r]}))});tm.displayName=pl.displayName;const sm=n.forwardRef((o,a)=>{var i=o,{className:t,children:r}=i,s=xe(i,["className","children"]);return e.jsxs(hl,se(L({ref:a,className:Be("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t)},s),{children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(xl,{children:e.jsx(Fc,{className:"h-2 w-2 fill-current"})})}),r]}))});sm.displayName=hl.displayName;const rm=n.forwardRef((o,a)=>{var i=o,{className:t,inset:r}=i,s=xe(i,["className","inset"]);return e.jsx(fl,L({ref:a,className:Be("px-2 py-1.5 text-sm font-semibold",r&&"pl-8",t)},s))});rm.displayName=fl.displayName;const nm=n.forwardRef((a,s)=>{var o=a,{className:t}=o,r=xe(o,["className"]);return e.jsx(gl,L({ref:s,className:Be("-mx-1 my-1 h-px bg-muted",t)},r))});nm.displayName=gl.displayName;const tr=Se;function jl(t){const[r,s]=n.useState([]),[a,o]=n.useState(!1),[i,l]=n.useState(!1),f=n.useRef(null),p=n.useRef(!1);n.useEffect(()=>{Q(this,null,function*(){const{data:{user:d}}=yield Se.auth.getUser();if(!d)return;const{data:u}=yield tr.from("profiles").select("name, avatar_url").eq("id",d.id).single();u&&(f.current=u)})},[]);const g=n.useCallback(()=>Q(this,null,function*(){if(t){p.current||o(!0);try{let d=yield tr.from("comments").select("*, profiles:author_id ( name, avatar_url )").eq("post_id",t).order("created_at",{ascending:!0});(d.error||!d.data)&&(d=yield tr.from("comments").select("*").eq("post_id",t).order("created_at",{ascending:!0})),d.data&&s(d.data),p.current=!0}catch(d){console.error("Error fetching comments:",d)}finally{o(!1)}}}),[t]);return n.useEffect(()=>{p.current=!1,g()},[g]),n.useEffect(()=>{if(t)return nn(`comments:${t}`,{type:"postgres_changes",event:"*",schema:"public",table:"comments",filter:`post_id=eq.${t}`},()=>g())},[t,g]),{comments:r,loading:a,submitting:i,addComment:d=>Q(this,null,function*(){try{const{data:{user:u}}=yield Se.auth.getUser();if(!u||!t)return;const m=`temp-${Date.now()}`,b={id:m,post_id:t,author_id:u.id,content:d,created_at:new Date().toISOString(),profiles:f.current};s(w=>[...w,b]),l(!0),window.dispatchEvent(new CustomEvent("comment-added",{detail:{postId:t}}));const{error:v}=yield tr.from("comments").insert({post_id:t,author_id:u.id,content:d});l(!1),v&&(s(w=>w.filter(_=>_.id!==m)),window.dispatchEvent(new CustomEvent("comment-removed",{detail:{postId:t}})))}catch(u){console.error("Error adding comment:",u),l(!1)}}),deleteComment:d=>Q(this,null,function*(){const u=r;s(m=>m.filter(b=>b.id!==d)),window.dispatchEvent(new CustomEvent("comment-removed",{detail:{postId:t}}));try{const{error:m}=yield tr.from("comments").delete().eq("id",d);m&&(console.error("Error deleting comment:",m),s(u),window.dispatchEvent(new CustomEvent("comment-added",{detail:{postId:t}})))}catch(m){console.error("Error deleting comment:",m),s(u),window.dispatchEvent(new CustomEvent("comment-added",{detail:{postId:t}}))}}),refetch:g}}function am(t){const r=t.match(/(?:youtube\.com\/(?:watch\?v=|shorts\/)|youtu\.be\/)([^&\n?#]+)/);return r?r[1]:null}function om({videoId:t,onRemove:r}){const[s,a]=n.useState(!1),o=`https://img.youtube.com/vi/${t}/maxresdefault.jpg`;return e.jsxs("div",{className:"relative rounded-2xl overflow-hidden",style:{border:"1px solid rgba(255,255,255,0.08)"},children:[s?e.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${t}?autoplay=1&modestbranding=1&rel=0&showinfo=0&iv_load_policy=3&cc_load_policy=0&controls=1&disablekb=0`,style:{position:"absolute",inset:0,width:"100%",height:"100%",border:0},allow:"autoplay; encrypted-media; fullscreen",allowFullScreen:!0})}):e.jsxs("div",{className:"relative cursor-pointer",onClick:()=>
267a(!0),children:[e.jsx("img",{src:o,alt:"Thumbnail",className:"w-full object-cover",style:{aspectRatio:"16/9",display:"block"}}),e.jsx("div",{className:"absolute inset-0",style:{background:"linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 50%)"}}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"flex items-center justify-center rounded-full transition-transform active:scale-90",style:{width:"56px",height:"56px",background:"rgba(220,38,38,0.9)",boxShadow:"0 4px 24px rgba(220,38,38,0.5)"},children:e.jsx(Es,{size:22,className:"text-white ml-1",fill:"white"})})}),e.jsxs("div",{className:"absolute bottom-2 left-3 flex items-center gap-1.5 px-2.5 py-1 rounded-full",style:{background:"rgba(0,0,0,0.6)",backdropFilter:"blur(8px)"},children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:"rgb(220,38,38)"}}),e.jsx("span",{className:"text-[11px] font-semibold text-white/80",children:"VÃdeo"})]})]}),e.jsx("button",{onClick:r,className:"absolute top-2 right-2 w-7 h-7 rounded-full flex items-center justify-center transition-all active:scale-90",style:{background:"rgba(0,0,0,0.6)",backdropFilter:"blur(8px)",border:"1px solid rgba(255,255,255,0.15)"},children:e.jsx(Je,{size:13,className:"text-white/80"})})]})}function Nl({open:t,post:r,onClose:s,onSave:a,posts:o=[]}){const[i,l]=n.useState(!1),[f,p]=n.useState(""),[g,c]=n.useState(""),[x,d]=n.useState(""),[u,m]=n.useState([]),[b,v]=n.useState(!1),[w,_]=n.useState(!1),[y,k]=n.useState(""),[E,S]=n.useState(!1),[R,z]=n.useState(0),[j,M]=n.useState(!1),[$,q]=n.useState(""),[ne,ae]=n.useState([]),J=n.useRef(null),je=n.useRef(null),ke=n.useRef(null),ve=n.useRef(null),P=Ks(),[N,Y]=n.useState(null),[F,G]=n.useState(null),[ee,re]=n.useState(null),[be,ge]=n.useState([]);n.useEffect(()=>{if(N===null){ge([]);return}const h=setTimeout(()=>Q(this,null,function*(){let T=Se.from("posts").select("id, title").order("created_at",{ascending:!1}).limit(5);N.length>0&&(T=T.ilike("title",`%${N}%`));const{data:I}=yield T;ge(I||[])}),200);return()=>clearTimeout(h)},[N]),n.useEffect(()=>{t&&l(!0)},[t]);const le=n.useRef(null);n.useEffect(()=>{var h;if(!t||!r){le.current=null;return}le.current!==r.id&&(le.current=r.id,p(r.title||""),c(r.createdAt?new Date(r.createdAt).toISOString().slice(0,16):new Date().toISOString().slice(0,16)),d(r.authorId||""),m((h=r.attachments)!=null?h:[]),q(""),M(!1),v(!P),_(!1),Y(null),requestAnimationFrame(()=>{J.current&&(J.current.innerHTML=Jn(r.fullContent.content||""))}),setTimeout(()=>{var T;return(T=je.current)==null?void 0:T.focus()},380))},[t,r,P]),n.useEffect(()=>{if(!t)return;Q(this,null,function*(){const{data:T}=yield Se.from("profiles").select("id, name, avatar_url").order("name");T&&ae(T)})},[t]),n.useEffect(()=>{t||setTimeout(()=>{p(""),c(""),d(""),m([]),v(!1),_(!1),k(""),Y(null),q(""),M(!1),J.current&&(J.current.innerHTML="")},400)},[t]),n.useEffect(()=>{w&&setTimeout(()=>{var h;return(h=ve.current)==null?void 0:h.focus()},80)},[w]),n.useEffect(()=>{const h=window.visualViewport;if(!h)return;const T=()=>{const I=window.innerHeight-h.height-h.offsetTop;z(Math.max(0,I))};return h.addEventListener("resize",T),h.addEventListener("scroll",T),T(),()=>{h.removeEventListener("resize",T),h.removeEventListener("scroll",T)}},[]);const fe=n.useCallback(()=>{const h=window.getSelection();if(!h||h.rangeCount===0||!J.current){Y(null);return}const T=h.getRangeAt(0),I=T.cloneRange();I.selectNodeContents(J.current),I.setEnd(T.startContainer,T.startOffset);const K=I.toString(),ie=K.match(/(^|[\s\n])\/([^\s]*)$/);if(ie){Y(ie[2]);const Ae=K.lastIndexOf("/"),Te=document.createRange(),Ve=document.createTreeWalker(J.current,NodeFilter.SHOW_TEXT);let Ge=0,Le=null,it=0;for(;Ve.nextNode();){const X=(Ve.currentNode.textContent||"").length;if(Ge+X>Ae){Le=Ve.currentNode,it=Ae-Ge;break}Ge+=X}Le&&(Te.setStart(Le,it),Te.setEnd(T.startContainer,T.startOffset),G(Te));const A=T.getBoundingClientRect();re({top:A.bottom+6,left:A.left})}else Y(null),G(null),re(null)},[]),pe=h=>{if(!F||!J.current)return;const T=window.getSelection();if(!T)return;F.deleteContents();const I=document.createElement("a");I.href=`/membros/post/${h.id}`,I.textContent=`â ${h.title}`,I.style.color="rgba(99,179,237,0.9)",I.style.textDecoration="underline",I.contentEditable="false",F.insertNode(I);const K=document.createRange();K.setStartAfter(I),K.collapse(!0);const ie=document.createTextNode(" ");K.insertNode(ie),K.setStartAfter(ie),K.collapse(!0),T.removeAllRanges(),T.addRange(K),Y(null),G(null)},Ne=h=>{var K;const T=(K=h.target.files)==null?void 0:K[0];if(!T)return;const I=URL.createObjectURL(T);m(ie=>[...ie,{type:"image",url:I,name:T.name}]),h.target.value="",v(!1)},Z=()=>{const h=am(y);if(!h){S(!0);return}m(T=>[...T,{type:"youtube",videoId:h,thumbnail:`https://img.youtube.com/vi/${h}/maxresdefault.jpg`}]),k(""),_(!1),S(!1),v(!1)},me=h=>{m(T=>T.filter((I,K)=>K!==h))},Me=h=>Q(this,null,function*(){var Ae;if(!h.some(Te=>Te.type==="image"&&typeof Te.url=="string"&&Te.url.startsWith("blob:")))return h;const{data:I}=yield Se.auth.getUser(),K=(Ae=I.user)==null?void 0:Ae.id;if(!K)throw new Error("not-authenticated");const ie=[];
267for(const Te of h){if(Te.type!=="image"||!Te.url||!Te.url.startsWith("blob:")){ie.push(Te);continue}const Ve=yield fetch(Te.url).then(X=>X.blob()),Ge=((Te.name||"").split(".").pop()||"jpg").toLowerCase().replace(/[^a-z0-9]/g,"")||"jpg",Le=`${K}/posts/${crypto.randomUUID()}.${Ge}`,{error:it}=yield Se.storage.from("avatars").upload(Le,Ve,{contentType:Ve.type||"image/jpeg",upsert:!1});if(it)throw it;const{data:A}=Se.storage.from("avatars").getPublicUrl(Le);ie.push(se(L({},Te),{type:"image",url:A.publicUrl,name:Te.name}))}return ie}),te=()=>{if(!J.current)return"";let h=J.current.innerHTML;return h=h.replace(/(<div>(\s| |<br\s*\/?>)*<\/div>\s*)+$/i,""),h=h.replace(/(<br\s*\/?>\s*)+$/i,""),Nc(h.trim())},[we,Pe]=n.useState(!1),oe=()=>Q(this,null,function*(){if(!r||we)return;Pe(!0);let h;try{h=yield Me(u)}catch(K){console.error("Falha ao enviar imagem:",K),Pe(!1);try{(yield Lt(()=>Q(this,null,function*(){const{toast:ie}=yield import("./index-DFRwvZ6i.js").then(Ae=>Ae.aj);return{toast:ie}}),__vite__mapDeps([1,2,3,4]))).toast.error("Não foi possÃvel enviar a imagem. Tente novamente.")}catch(ie){}return}m(h);const T={};f&&(T.title=f);const I=te();T.content=I,g&&(T.created_at=new Date(g).toISOString()),x&&x!==r.authorId&&(T.author_id=x),T.attachments=h;try{if((yield Promise.resolve(a(T)))===!1)return;s()}finally{Pe(!1)}}),O=(h,T)=>{var I;(I=J.current)==null||I.focus(),document.execCommand(h,!1,T)},H=ne.find(h=>h.id===x),ce=ne.filter(h=>!$||(h.name||"").toLowerCase().includes($.toLowerCase())),V=({onPress:h,children:T,title:I})=>e.jsx("button",{onMouseDown:K=>K.preventDefault(),onClick:h,title:I,className:"flex items-center justify-center rounded-xl transition-all duration-150 active:scale-90 shrink-0 text-muted-foreground hover:text-foreground hover:bg-muted",style:{width:"38px",height:"38px"},children:T}),C=[{icon:To,label:"Negrito",action:()=>O("bold")},{icon:Oo,label:"Itálico",action:()=>O("italic")},{icon:Lo,label:"TÃtulo",action:()=>O("formatBlock","h2")},{icon:Bo,label:"Lista",action:()=>O("insertUnorderedList")},{icon:Uo,label:"Citação",action:()=>O("formatBlock","blockquote")},{icon:Do,label:"Código",action:()=>{const h=window.getSelection();if(h&&h.rangeCount>0&&!h.isCollapsed){const T=h.getRangeAt(0),I=document.createElement("code");I.style.background="rgba(255,255,255,0.08)",I.style.padding="2px 6px",I.style.borderRadius="4px",I.style.fontFamily="monospace",I.style.fontSize="0.9em",T.surroundContents(I)}}},{icon:$o,label:"Link",action:()=>{const h=prompt("URL do link:");h&&(O("createLink",h),setTimeout(()=>{J.current&&J.current.querySelectorAll("a:not([style])").forEach(T=>{T.style.color="rgba(99,179,237,0.9)",T.style.textDecoration="underline"})},0))}},{icon:Wo,label:"Divisória",action:()=>O("insertHorizontalRule")}];return!i&&!t?null:e.jsxs(e.Fragment,{children:[!P&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:199,background:"rgba(0,0,0,0.6)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",opacity:t?1:0,pointerEvents:t?"auto":"none",transition:"opacity 0.28s ease"},onMouseDown:h=>{h.target===h.currentTarget&&s()}}),e.jsxs("div",{style:P?{position:"fixed",inset:0,zIndex:200,background:"var(--sv-surface-solid, rgb(8,8,8))",display:"flex",flexDirection:"column",transform:t?"translateY(0%)":"translateY(100%)",transition:"transform 0.4s cubic-bezier(0.4,0,0.2,1)"}:{position:"fixed",top:"50%",left:"50%",zIndex:200,width:"100%",maxWidth:"640px",maxHeight:"85vh",background:"var(--sv-surface-solid, rgb(8,8,8))",display:"flex",flexDirection:"column",borderRadius:"24px",border:"1px solid var(--sv-border-subtle)",boxShadow:"0 20px 80px rgba(0,0,0,0.5)",transform:t?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:t?1:0,transition:"transform 0.28s cubic-bezier(0.4,0,0.2,1), opacity 0.28s ease",pointerEvents:t?"auto":"none",overflow:"hidden"},children:[e.jsxs("div",{className:"flex items-center justify-between px-5 shrink-0",style:{borderBottom:"1px solid var(--sv-border-subtle)",paddingTop:P?"calc(env(safe-area-inset-top, 0px) + 14px)":"14px",paddingBottom:"14px"},children:[e.jsx("button",{onClick:s,className:"w-11 h-11 rounded-full flex items-center justify-center transition-all active:scale-90",style:{background:"rgba(220,38,38,0.15)",border:"1px solid rgba(220,38,38,0.3)"},children:e.jsx(Je,{size:20,style:{color:"rgba(220,38,38,0.9)"}})}),e.jsx("p",{className:"text-sm font-bold",style:{color:"var(--sv-text-heading)"},children:"Editar publicação"}),e.jsxs("button",{className:"flex items-center gap-1.5 px-4 h-11 rounded-full text-sm font-bold transition-all duration-200 active:scale-95",style:{background:"rgba(34,197,94,0.2)",border:"1px solid rgba(34,197,94,0.4)",color:"rgb(74,222,128)"},onClick:oe,disabled:we,children:[e.jsx(Oc,{size:13})," ",we?"Salvandoâ¦":"Salvar"]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-5 py-3 shrink-0 flex-wrap",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>M(!j),className:"flex items-center gap-2 px-3 py-1.5 rounded-full transition-all active:scale-95",style:{background:"var(--sv-surface-hover)",border:"1px solid var(--sv-border-subtle)"},children:[H&&e.jsxs(ut,{className:"h-5 w-5 border shrink-0",style:{borderColor:"var(--sv-border-subtle)"},children:[H.avatar_url&&e.jsx(Ze,{src:H.avatar_url,alt:H.name||"",className:"object-cover"}),e.jsx(ft,{className:"text-[7px] font-bold text-white",style:{background:"hsl(var(--setverso-red))"},children:(H.name||"?").split(" ").slice(0,2).map(h=>h[0]).join("").toUpperCase()})]}),e.jsx("span",{className:"text-xs font-semibold",style:{color:"var(--sv-text-heading)"},children:(H==null?void 0:H.name)||"Selecionar autor"}),e.jsx(Hs,{size:12,className:"text-muted-foreground"})]}),j&&e.jsxs("div",{className:"absolute left-0 top-full mt-1 rounded-xl z-50 max-h-48 overflow-y-auto min-w-[220px]",style:{background:"var(--sv-surface-elevated)",border:"1px solid var(--sv-border-medium)",boxShadow:"var(--sv-shadow-dropdown)"},children:[e.jsx("div",{className:"p-2",children:e.jsx("input",{value:$,onChange:h=>q(h.target.value),placeholder:"Buscar autor...",autoFocus:!0,className:"w-full bg-transparent outline-none text-xs px-2 py-1.5 rounded-lg",style:{color:"var(--sv-text-heading)",background:"var(--sv-surface)"}})}),ce.map(h=>{const T=(h.name||"?").split(" ").slice(0,2).map(I=>I[0]).join("").toUpperCase();return e.jsxs("button",{onClick:()=>{d(h.id),M(!1),q("")},className:"flex items-center gap-3 w-full px-4 py-2.5 text-left transition-colors hover:bg-muted/50",children:[e.jsxs(ut,{className:"h-6 w-6 border border-border",children:[h.avatar_url&&e.jsx(Ze,{src:h.avatar_url,alt:h.name||"",className:"object-cover"}),e.jsx(ft,{className:"text-[8px] font-bold",children:T})]}),e.jsx("span",{className:"text-sm text-foreground truncate",children:h.name})]}
267,h.id)})]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-full",style:{background:"var(--sv-surface-hover)",border:"1px solid var(--sv-border-subtle)"},children:[e.jsx(wo,{size:12,className:"text-muted-foreground shrink-0"}),e.jsx("input",{type:"datetime-local",value:g,onChange:h=>c(h.target.value),className:"bg-transparent text-xs font-semibold outline-none",style:{color:"var(--sv-text-heading)",colorScheme:"dark"}})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pt-1 pb-28",children:[e.jsx("input",{ref:je,type:"text",value:f,onChange:h=>p(h.target.value),placeholder:"TÃtulo da publicação...",className:"w-full bg-transparent text-3xl font-black placeholder:opacity-20 outline-none mb-4",style:{color:"var(--sv-text-heading)"}}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{ref:J,contentEditable:!0,suppressContentEditableWarning:!0,onInput:()=>fe(),onKeyUp:()=>fe(),onKeyDown:h=>{N!==null&&h.key==="Escape"&&(Y(null),h.preventDefault())},"data-placeholder":"Conteúdo da publicação...",className:"w-full bg-transparent outline-none min-h-[300px] rich-editor post-content",style:{color:"var(--sv-text-primary)"}}),N!==null&&ee&&be.length>0&&Xt.createPortal(e.jsxs("div",{style:{position:"fixed",top:ee.top,left:ee.left,zIndex:9999,width:"340px",maxWidth:"90vw",background:"rgba(15,15,15,0.97)",backdropFilter:"blur(32px) saturate(200%)",WebkitBackdropFilter:"blur(32px) saturate(200%)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"18px",boxShadow:"0 8px 40px rgba(0,0,0,0.6)",overflow:"hidden"},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.2em] px-4 pt-3 pb-1.5",style:{color:"rgba(99,179,237,0.7)"},children:"Posts encontrados"}),e.jsx("div",{className:"flex flex-col p-1.5 gap-0.5",children:be.map(h=>e.jsxs("button",{onMouseDown:T=>T.preventDefault(),onClick:()=>pe(h),className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-xl text-left transition-all duration-100 active:scale-[0.98]",style:{background:"transparent"},onMouseEnter:T=>{T.currentTarget.style.background="rgba(99,179,237,0.08)"},onMouseLeave:T=>{T.currentTarget.style.background="transparent"},children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0",style:{background:"rgba(99,179,237,0.1)",border:"1px solid rgba(99,179,237,0.2)"},children:e.jsx(jo,{size:13,style:{color:"rgba(99,179,237,0.8)"}})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[13px] font-semibold leading-snug line-clamp-1",style:{color:"rgba(255,255,255,0.85)"},children:h.title}),e.jsx("p",{className:"text-[11px] mt-0.5",style:{color:"rgba(255,255,255,0.3)"},children:"post"})]}),e.jsx("span",{className:"text-[11px] font-semibold shrink-0",style:{color:"rgba(99,179,237,0.6)"},children:"citar"})]},h.id))}),e.jsx("div",{style:{height:"6px"}})]}),document.body),N!==null&&ee&&N.length>0&&be.length===0&&Xt.createPortal(e.jsx("div",{style:{position:"fixed",top:ee.top,left:ee.left,zIndex:9999,width:"340px",maxWidth:"90vw",background:"rgba(15,15,15,0.95)",backdropFilter:"blur(24px)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:"16px",padding:"14px 16px"},children:e.jsxs("p",{className:"text-[13px] text-white/30 text-center",children:['Nenhum post com "',N,'"']})}),document.body)]}),u.length>0&&e.jsx("div",{className:"mt-4 flex flex-col gap-3",children:u.map((h,T)=>h.type==="youtube"?e.jsx(om,{videoId:h.videoId,onRemove:()=>me(T)},T):e.jsxs("div",{className:"relative rounded-2xl overflow-hidden",style:{border:"1px solid rgba(255,255,255,0.08)"},children:[e.jsx("img",{src:h.url,alt:h.name,className:"w-full h-auto rounded-2xl block"}),e.jsx("button",{onClick:()=>me(T),className:"absolute top-2 right-2 w-7 h-7 rounded-full flex items-center justify-center transition-all active:scale-90",style:{background:"rgba(0,0,0,0.6)",backdropFilter:"blur(8px)",border:"1px solid rgba(255,255,255,0.15)"},children:e.jsx(Je,{size:13,className:"text-white/80"})})]},T))})]}),!P&&t&&e.jsxs("div",{className:"px-4 py-3 shrink-0",style:{borderTop:"1px solid var(--sv-border-subtle)",background:"var(--sv-surface-solid, rgb(8,8,8))"},children:[e.jsx("input",{ref:P?void 0:ke,type:"file",accept:"image/*",className:"hidden",onChange:Ne}),w&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 px-3 py-2 rounded-2xl",style:{background:"rgba(15,15,15,0.95)",backdropFilter:"blur(20px)",border:"1px solid rgba(255,255,255,0.1)",boxShadow:"0 8px 32px rgba(0,0,0,0.5)"},children:[e.jsx(xs,{size:15,style:{color:E?"rgb(220,38,38)":"rgba(255,255,255,0.35)"},className:"shrink-0"}),e.jsx("input",{type:"url",value:y,onChange:h=>{k(h.target.value),S(!1)},onKeyDown:h=>{h.key==="Enter"&&Z(),h.key==="Escape"&&(_(!1),k(""),S(!1))},placeholder:"Cole o link do YouTube...",className:"flex-1 bg-transparent text-sm text-white placeholder:text-white/25 outline-none",style:{color:E?"rgb(220,38,38)":void 0}}),y&&e.jsx("button",{onClick:Z,className:"px-3 py-1 rounded-full text-[12px] font-bold transition-all active:scale-95",style:{background:"rgba(220,38,38,0.2)",border:"1px solid rgba(220,38,38,0.35)",color:"rgb(252,165,165)"},children:"Adicionar"}),e.jsx("button",{onClick:()=>{_(!1),k(""),S(!1)},children:e.jsx(Je,{size:14,style:{color:"rgba(255,255,255,0.3)"}})})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5 flex-wrap",children:[C.map(({icon:h,label:T,action:I})=>e.jsx(V,{onPress:I,title:T,children:e.jsx(h,{size:15,strokeWidth:2})},T)),e.jsx("div",{className:"w-px h-4 mx-1 shrink-0",style:{background:"rgba(255,255,255,0.1)"}}),[{char:"#",label:"Agrupar conteúdo",color:"rgba(129,140,248,0.85)",action:()=>O("formatBlock","h3")},{char:"@",label:"Citar membro",color:"rgba(251,191,36,0.85)",action:()=>{const h=prompt("Nome do membro:");h&&document.execCommand("insertText",!1,`@${h}`)}},{char:"/",label:"Linkar post",color:"rgba(74,222,128,0.85)",action:()=>{var h;(h=J.current)==null||h.focus(),document.execCommand("insertText",!1,"/"),setTimeout(fe,10)}}].map(({char:h,label:T,color:I,action:K})=>e.jsx("button",{onMouseDown:ie=>ie.preventDefault(),onClick:K,title:T,className:"flex items-center justify-center rounded-xl transition-all duration-150 active:scale-90 shrink-0 hover:bg-muted",style:{width:"36px",height:"38px"},children:e.jsx("span",{className:"text-[15px] font-black leading-none",style:{color:I},children:h})},h)),e.jsx("div",{className:"w-px h-4 mx-1 shrink-0",style:{background:"rgba(255,255,255,0.1)"}}),e.jsx(V,{onPress:()=>{var h;
267return(h=ke.current)==null?void 0:h.click()},title:"Adicionar imagem",children:e.jsx(Yr,{size:16})}),e.jsx(V,{onPress:()=>{_(h=>!h)},title:"Adicionar vÃdeo do YouTube",children:e.jsx(xs,{size:16})})]})]})]}),t&&P&&Xt.createPortal(e.jsxs("div",{className:"fixed right-4 z-[300] flex flex-col items-end",style:{bottom:`calc(${R}px + env(safe-area-inset-bottom, 0px) + 12px)`,transition:"bottom 0.2s ease"},children:[e.jsx("input",{ref:ke,type:"file",accept:"image/*",className:"hidden",onChange:Ne}),w&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 px-3 py-2 rounded-2xl w-72",style:{background:"rgba(15,15,15,0.95)",backdropFilter:"blur(20px)",border:"1px solid rgba(255,255,255,0.1)",boxShadow:"0 8px 32px rgba(0,0,0,0.5)"},children:[e.jsx(xs,{size:15,style:{color:E?"rgb(220,38,38)":"rgba(255,255,255,0.35)"},className:"shrink-0"}),e.jsx("input",{ref:ve,type:"url",value:y,onChange:h=>{k(h.target.value),S(!1)},onKeyDown:h=>{h.key==="Enter"&&Z(),h.key==="Escape"&&(_(!1),k(""),S(!1))},placeholder:"Cole o link do YouTube...",className:"flex-1 bg-transparent text-sm text-white placeholder:text-white/25 outline-none",style:{color:E?"rgb(220,38,38)":void 0}}),y&&e.jsx("button",{onClick:Z,className:"px-3 py-1 rounded-full text-[12px] font-bold transition-all active:scale-95",style:{background:"rgba(220,38,38,0.2)",border:"1px solid rgba(220,38,38,0.35)",color:"rgb(252,165,165)"},children:"Adicionar"}),e.jsx("button",{onClick:()=>{_(!1),k(""),S(!1)},children:e.jsx(Je,{size:14,style:{color:"rgba(255,255,255,0.3)"}})})]}),e.jsxs("div",{className:"flex items-center rounded-full overflow-hidden",style:{height:"62px",width:b?"calc(100vw - 32px)":"62px",maxWidth:b?"398px":"62px",background:b?"rgba(22,22,22,0.92)":"rgba(22,22,22,0.8)",backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)",border:"1px solid rgba(255,255,255,0.1)",transition:"all 0.35s cubic-bezier(0.4,0,0.2,1)",boxShadow:b?"0 8px 32px rgba(0,0,0,0.5)":"0 4px 16px rgba(0,0,0,0.4)",flexDirection:"row-reverse"},children:[e.jsx("button",{onTouchStart:h=>h.stopPropagation(),onClick:h=>{h.preventDefault(),h.stopPropagation(),v(T=>!T),w&&_(!1)},className:"flex items-center justify-center shrink-0 transition-transform active:scale-90",style:{width:"62px",height:"62px"},children:e.jsx(hr,{size:22,style:{color:b?"rgba(255,255,255,0.8)":"rgba(255,255,255,0.55)",transform:b?"rotate(45deg)":"rotate(0deg)",transition:"transform 0.3s cubic-bezier(0.4,0,0.2,1), color 0.2s ease"}})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1px",flex:1,overflowX:"auto",paddingLeft:"8px",opacity:b?1:0,pointerEvents:b?"auto":"none",transition:"opacity 0.18s ease "+(b?"0.12s":"0s")},className:"scrollbar-none",children:[C.map(({icon:h,label:T,action:I})=>e.jsx(V,{onPress:I,title:T,children:e.jsx(h,{size:15,strokeWidth:2})},T)),e.jsx("div",{className:"w-px h-4 mx-1 shrink-0",style:{background:"rgba(255,255,255,0.1)"}}),[{char:"#",label:"Agrupar conteúdo",color:"rgba(129,140,248,0.85)",action:()=>O("formatBlock","h3")},{char:"@",label:"Citar membro",color:"rgba(251,191,36,0.85)",action:()=>{const h=prompt("Nome do membro:");h&&document.execCommand("insertText",!1,`@${h}`)}},{char:"/",label:"Linkar post",color:"rgba(74,222,128,0.85)",action:()=>{var h;(h=J.current)==null||h.focus(),document.execCommand("insertText",!1,"/"),setTimeout(fe,10)}}].map(({char:h,label:T,color:I,action:K})=>e.jsx("button",{onMouseDown:ie=>ie.preventDefault(),onClick:K,title:T,className:"flex items-center justify-center rounded-xl transition-all duration-150 active:scale-90 shrink-0",style:{width:"36px",height:"38px",background:"transparent"},onMouseEnter:ie=>{ie.currentTarget.style.background="rgba(255,255,255,0.06)"},onMouseLeave:ie=>{ie.currentTarget.style.background="transparent"},children:e.jsx("span",{className:"text-[15px] font-black leading-none",style:{color:I},children:h})},h)),e.jsx("div",{className:"w-px h-4 mx-1 shrink-0",style:{background:"rgba(255,255,255,0.1)"}}),e.jsx(V,{onPress:()=>{var h;return(h=ke.current)==null?void 0:h.click()},title:"Adicionar imagem",children:e.jsx(Yr,{size:16})}),e.jsx(V,{onPress:()=>{_(h=>!h),v(!1)},title:"Adicionar vÃdeo do YouTube",children:e.jsx(xs,{size:16})})]})]})]}),document.body)]})}function va({attachments:t,className:r}){return!t||t.length===0?null:e.jsx("div",{className:`flex flex-col gap-3 ${r!=null?r:""}`,children:t.map((s,a)=>{var o;if(!s)return null;if(s.type==="youtube"){const i=vo(`https://youtu.be/${s.videoId}`),l=(o=i==null?void 0:i.embedUrl)!=null?o:`https://www.youtube.com/embed/${s.videoId}`;return e.jsx("div",{className:"sv-video-wrap rounded-2xl overflow-hidden",style:{border:"1px solid rgba(255,255,255,0.08)"},children:e.jsx("iframe",{src:l,title:`YouTube video ${s.videoId}`,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,className:"sv-yt-iframe"})},a)}return s.type==="image"&&s.url?e.jsx("div",{className:"rounded-2xl overflow-hidden",style:{border:"1px solid rgba(255,255,255,0.08)"},children:e.jsx("img",{src:s.url,alt:s.name||"Imagem do post",loading:"lazy",className:"w-full h-auto block rounded-2xl"})},a):null})})}const mn="/assets/pedro-pimentel-BnS4dk4s.jpeg",Cn="swipe_tutorial_shown";function im({post:t,onBack:r,currentUserId:s,isAdmin:a,onDelete:o,onTogglePin:i,onEditPost:l,onEditingChange:f,scrollToComments:p,onScrolledToComments:g,dbPosts:c=[],onOpenLinkedPost:x}){var Me;bs();const[d,u]=n.useState(!1),[m,b]=n.useState(t.likes),[v,w]=n.useState(!1),_=n.useCallback(te=>{const we=te.target.closest("a");if(!we||!we.href)return;const Pe=Qn(we.href);if(Pe&&x){te.preventDefault(),x(Pe);return}we.getAttribute("data-external")!=="true"&&(te.preventDefault(),window.open(we.href,"_blank","noopener,noreferrer"))},[x]),[y,k]=n.useState(!1);n.useEffect(()=>{f==null||f(y)},[y,f]);const E=(Me=t.isPinned)!=null?Me:!1,[S,R]=n.useState(""),z=n.useRef(null),j=n.useRef(null);n.useEffect(()=>{var te;(te=j.current)==null||te.scrollTo({top:0})},[t.id]);const{comments:M,loading:$,submitting:q,addComment:ne,deleteComment:ae}=jl(t.commentsEnabled?t.id:null);n.useEffect(()=>{p&&z.current&&setTimeout(()=>{var te;(te=z.current)==null||te.scrollIntoView({behavior:"smooth",block:"start"}),g==null||g()},300)},[p,$]);
267const[J,je]=n.useState(0),ke=n.useRef(null),ve=n.useRef(null),P=n.useRef(!1),[N,Y]=n.useState(!1),[F,G]=n.useState("visible"),re=!!s&&s===t.authorId||a;n.useEffect(()=>{window.scrollTo({top:0,behavior:"instant"})},[]),n.useEffect(()=>{try{if(!localStorage.getItem(Cn)){const we=setTimeout(()=>Y(!0),600);return()=>clearTimeout(we)}}catch(te){}},[]),n.useEffect(()=>{if(N){const te=setTimeout(()=>{G("fading"),setTimeout(()=>{Y(!1);try{localStorage.setItem(Cn,"1")}catch(we){}},500)},2800);return()=>clearTimeout(te)}},[N]);const be=()=>{u(te=>!te),b(te=>d?te-1:te+1)},ge=()=>Q(this,null,function*(){o==null||o(),r()}),le=te=>{ke.current=te.touches[0].clientX,ve.current=te.touches[0].clientY,P.current=!1},fe=te=>{if(ke.current===null||ve.current===null)return;const we=te.touches[0].clientX-ke.current,Pe=te.touches[0].clientY-ve.current;!P.current&&Math.abs(Pe)>Math.abs(we)||we>0&&(P.current=!0,te.preventDefault(),je(we))},pe=()=>{if(J>100){je(window.innerWidth),N&&Y(!1);try{localStorage.setItem(Cn,"1")}catch(te){}setTimeout(()=>r(),260)}else je(0);ke.current=null,ve.current=null},Ne=J>window.innerWidth*.4,Z=()=>Q(this,null,function*(){S.trim()&&(yield ne(S.trim()),R(""))}),me=te=>{const we=Date.now()-new Date(te).getTime(),Pe=Math.floor(we/6e4);if(Pe<1)return"agora";if(Pe<60)return`${Pe}min`;const oe=Math.floor(Pe/60);if(oe<24)return`${oe}h`;const O=Math.floor(oe/24);return O===1?"1d":O<30?`${O}d`:`${Math.floor(O/30)}m`};return e.jsxs("div",{ref:j,className:"fixed inset-0 z-50 flex flex-col bg-background text-foreground overflow-x-hidden overflow-y-auto",onTouchStart:le,onTouchMove:fe,onTouchEnd:pe,style:{transform:`translateX(${J}px)`,transition:P.current?"none":"transform 0.25s cubic-bezier(0.4,0,0.2,1)",opacity:P.current?Math.max(.4,1-J/400):1,overscrollBehavior:"none"},children:[N&&e.jsxs("div",{className:"absolute inset-0 z-50 flex items-center justify-center pointer-events-none",style:{opacity:F==="fading"?0:1,transition:"opacity 0.5s ease"},children:[e.jsx("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-md"}),e.jsxs("div",{className:"relative flex flex-col items-center gap-4 px-8 py-7 rounded-3xl",style:{background:"hsl(var(--card) / 0.92)",border:"1px solid hsl(var(--border))",backdropFilter:"blur(20px)",boxShadow:"0 20px 60px hsl(var(--foreground) / 0.15)"},children:[e.jsxs("div",{className:"relative w-24 h-12 flex items-center",children:[e.jsx("div",{className:"absolute left-0 right-0 h-px bg-border"}),e.jsxs("div",{className:"absolute flex items-center gap-1",style:{animation:"swipeHint 1.4s cubic-bezier(0.4,0,0.2,1) infinite"},children:[e.jsx(Ct,{size:16,className:"text-muted-foreground"}),e.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center bg-muted border border-border",children:e.jsx("span",{style:{fontSize:14},children:"ð"})})]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-foreground font-bold text-base mb-1",children:"Deslize para voltar"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Arraste da esquerda para a direita"})]})]})]}),P.current&&J>10&&e.jsx("div",{className:"absolute left-0 top-0 bottom-0 flex items-center justify-start pl-3 pointer-events-none z-20",style:{opacity:Math.min(1,J/80)},children:e.jsx("div",{className:"w-9 h-9 rounded-full flex items-center justify-center",style:{background:Ne?"rgba(255,255,255,0.2)":"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.2)",transition:"background 0.15s ease"},children:e.jsx(Ct,{size:18,className:"text-white"})})}),e.jsxs("div",{className:"flex items-center justify-between px-4 pt-14 pb-4 sticky top-0 z-30 bg-background/80 backdrop-blur-lg",children:[e.jsx("button",{onClick:r,className:"w-9 h-9 rounded-full flex items-center justify-center bg-secondary border border-border active:scale-95 transition-transform",children:e.jsx(Ct,{size:18})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>Q(this,null,function*(){yield Zr(t.id,t.title),navigator.share||Ie.success("Link copiado!")}),className:"w-9 h-9 rounded-full flex items-center justify-center bg-secondary border border-border active:scale-95 transition-transform",children:e.jsx(Kr,{size:18})}),re&&e.jsxs(e.Fragment,{children:[e.jsxs(yl,{children:[e.jsx(wl,{asChild:!0,children:e.jsx("button",{className:"w-9 h-9 rounded-full flex items-center justify-center bg-secondary border border-border active:scale-95 transition-transform",children:e.jsx(zo,{size:18})})}),e.jsxs(ga,{align:"end",className:"rounded-2xl min-w-[200px] p-1.5",style:{background:"var(--sv-surface-elevated)",border:"1px solid var(--sv-border-medium)",backdropFilter:"blur(20px)",boxShadow:"var(--sv-shadow-dropdown)"},children:[a&&e.jsxs(e.Fragment,{children:[e.jsxs(Rs,{onClick:()=>k(!0),className:"flex items-center gap-3 px-4 py-3 rounded-xl cursor-pointer",style:{color:"var(--sv-text-primary)"},children:[e.jsx(_o,{size:15,className:"shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold",children:"Editar publicação"})]}),e.jsxs(Rs,{onClick:()=>i==null?void 0:i(!E),className:"flex items-center gap-3 px-4 py-3 rounded-xl cursor-pointer",style:{color:"var(--sv-text-primary)"},children:[E?e.jsx(Vo,{size:15,className:"shrink-0"}):e.jsx(Ho,{size:15,className:"shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold",children:E?"Desafixar post":"Fixar post"})]})]}),e.jsxs(Rs,{onClick:()=>w(!0),className:"flex items-center gap-3 px-4 py-3 rounded-xl cursor-pointer",style:{color:"hsl(var(--setverso-red))"},children:[e.jsx(Vt,{size:15,className:"shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold",children:"Excluir publicação"})]})]})]}),v&&e.jsx("div",{className:"fixed inset-0 z-[200] flex items-center justify-center px-6",style:{background:"var(--sv-backdrop)",backdropFilter:"blur(8px)"},onClick:te=>{te.target===te.currentTarget&&w(!1)},children:e.jsxs("div",{className:"w-full max-w-sm rounded-3xl overflow-hidden",style:{background:"var(--sv-surface-elevated)",border:"1px solid var(--sv-border-medium)",boxShadow:"var(--sv-shadow-dropdown)"},children:[e.jsxs("div",{className:"flex flex-col items-center pt-8 pb-5 px-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{background:"hsl(var(--destructive) / 0.12)",border:"1.5px solid hsl(var(--destructive) / 0.3)"},children:e.jsx(Vt,{size:28,style:{color:"hsl(var(--setverso-red))"}})}),e.jsx("h2",{className:"text-xl font-black text-foreground text-center mb-2",children:"Excluir publicação?"}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:["Essa ação é ",e.jsx("span",{className:"text-foreground font-semibold",children:"irreversÃvel"}),". O post será removido permanentemente e não poderá ser recuperado."]})]}),e.jsx("div",{style:{height:"1px",background:"var(--sv-border-subtle)"}}),e.jsxs("div",{className:"flex",children:[e.jsx("button",{onClick:()=>w(!1),className:"flex-1 py-4 text-sm font-semibold transition-all active:scale-95",style:{color:"var(--sv-text-secondary)",borderRight:"1px solid var(--sv-border-subtle)"},children:"Cancelar"}),e.jsx("button",{onClick:ge,className:"flex-1 py-4 text-sm font-bold transition-all active:scale-95 active:opacity-80",style:{color:"hsl(var(--setverso-red))"},children:"Sim, excluir"})]})]})})]})]})]}),e.jsx("div",{className:"px-5 mb-2",children:e.jsx("span",{className:"text-xs text-muted-foreground uppercase tracking-widest",children:t.space})}),e.jsx("div",{className:"px-5 mb-5",children:e.jsx("h1",{className:"text-3xl font-black leading-tight",children:Gr(t.title)})}),e.jsxs("div",{className:"flex items-center justify-between px-5 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(ut,{className:"h-10 w-10 border border-border",children:[t.authorAvatar?e.jsx(Ze,{src:t.authorAvatar,alt:t.author,className:"object-cover"}):t.authorInitials==="PP"?e.jsx(Ze,{src:mn,alt:t.author,className:"object-cover"}):t.author.includes("SetVerso")?e.jsx(Ze,{src:on,alt:t.author,className:"object-contain",style:{mixBlendMode:"screen",background:"black"}}):null,e.jsx(ft,{className:"bg-accent text-accent-foreground text-xs font-bold",children:t.authorInitials})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:t.author}),t.isAdmin&&e.jsx(bi,{className:"text-[9px] px-1.5 py-0 h-4 rounded-sm font-bold tracking-wide bg-secondary text-muted-foreground border-0",children:"Admin"})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.timeAgo," atrás"]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("button",{onClick:be,className:"flex items-center gap-1.5 active:scale-95 transition-transform",children:[e.jsx(ta,{size:20,className:"transition-colors duration-200",style:{fill:d?"hsl(var(--setverso-red))":"transparent",color:d?"hsl(var(--setverso-red))":"hsl(var(--muted-foreground))"}}),e.jsx("span",{className:"text-sm font-medium",style:{color:d?"hsl(var(--setverso-red))":"hsl(var(--muted-foreground))"},children:m})]}),t.commentsEnabled&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(gs,{size:20,className:"text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:M.length})]}),e.jsx("button",{onClick:()=>Q(this,null,function*(){yield Zr(t.id,t.title),Ie.success("Link copiado!")}),className:"flex items-center gap-1.5 active:scale-95 transition-transform",children:e.jsx(Kr,{size:20,className:"text-muted-foreground"})})]})]}),t.fullContent.content&&e.jsx("div",{className:"px-5 mb-6",children:e.jsx("div",{className:"post-content text-foreground
267/85",dangerouslySetInnerHTML:{__html:Jn(t.fullContent.content)},onClick:_})}),t.attachments&&t.attachments.length>0&&e.jsx("div",{className:"px-5 mb-6",children:e.jsx(va,{attachments:t.attachments})}),e.jsxs("div",{className:"px-5 space-y-5 flex-1",children:[e.jsx(Ns,{label:"Perfis",value:t.fullContent.perfis}),e.jsx(Ns,{label:"Local",value:t.fullContent.local}),e.jsx(Ns,{label:"Data",value:t.fullContent.data}),e.jsx(Ns,{label:"Horário",value:t.fullContent.horario}),e.jsx(Ns,{label:"Cachê",value:t.fullContent.cache}),e.jsx(Ns,{label:"Requisitos",value:t.fullContent.requisitos}),t.fullContent.observacoes&&e.jsx(Ns,{label:"Observações",value:t.fullContent.observacoes})]}),e.jsxs("div",{ref:z,className:"px-5 mt-8 mb-36",children:[e.jsx("div",{className:"h-px bg-border mb-5"}),e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(gs,{size:16,className:"text-muted-foreground"}),e.jsxs("p",{className:"text-sm font-bold text-foreground",children:["Comentários ",t.commentsEnabled&&M.length>0&&`(${M.length})`]})]}),t.commentsEnabled?e.jsxs(e.Fragment,{children:[$?e.jsx("div",{className:"space-y-3",children:[...Array(2)].map((te,we)=>e.jsx("div",{className:"h-16 rounded-xl animate-pulse",style:{background:"rgba(255,255,255,0.03)"}},we))}):M.length===0?e.jsx("p",{className:"text-xs text-muted-foreground/50 text-center py-4",children:"Nenhum comentário ainda. Seja o primeiro!"}):e.jsx("div",{className:"space-y-3",children:M.map(te=>{var O,H,ce;const we=(H=(O=te.profiles)==null?void 0:O.name)!=null?H:"Membro",Pe=we.split(" ").slice(0,2).map(V=>V[0]).join("").toUpperCase(),oe=s===te.author_id;return e.jsxs("div",{className:"rounded-xl px-4 py-3",style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.05)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsxs(ut,{className:"h-6 w-6 border border-border",children:[(ce=te.profiles)!=null&&ce.avatar_url?e.jsx(Ze,{src:te.profiles.avatar_url,alt:we,className:"object-cover"}):null,e.jsx(ft,{className:"text-[8px] font-bold text-accent-foreground",style:{background:"hsl(var(--setverso-red))"},children:Pe})]}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:we}),e.jsx("span",{className:"text-[10px] text-muted-foreground/50",children:me(te.created_at)}),(oe||a)&&e.jsx("button",{onClick:()=>ae(te.id),className:"ml-auto w-5 h-5 flex items-center justify-center rounded transition-all hover:bg-white/05 active:scale-90",children:e.jsx(Vt,{size:10,className:"text-muted-foreground/40"})})]}),e.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed pl-8",children:te.content})]},te.id)})}),s&&e.jsxs("div",{className:"flex items-center gap-2 rounded-2xl px-4 py-3 mt-4",style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.07)"},children:[e.jsx("input",{type:"text",value:S,onChange:te=>R(te.target.value),onKeyDown:te=>te.key==="Enter"&&Z(),placeholder:"Escreva um comentário...",className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground/50"}),e.jsx("button",{onClick:Z,disabled:q||!S.trim(),className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0 transition-all active:scale-90 disabled:opacity-30",style:{background:"hsl(var(--setverso-red) / 0.15)"},children:e.jsx(Vs,{size:14,style:{color:"hsl(var(--setverso-red))"}})})]})]}):e.jsx("div",{className:"flex items-center gap-2 rounded-2xl px-4 py-3",style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.07)"},children:e.jsx("span",{className:"text-sm text-muted-foreground/50",children:"Esse espaço não permite comentários"})})]}),Xt.createPortal(e.jsx(Nl,{open:y,post:t,onClose:()=>k(!1),onSave:te=>l==null?void 0:l(te),posts:c}),document.body),e.jsx("style",{children:` 268 @keyframes swipeHint { 269 0% { left: 0%; opacity: 0; } 270 15% { opacity: 1; } 271 60% { left: 55%; opacity: 1; } 272 80% { left: 60%; opacity: 0; } 273 100% { left: 60%; opacity: 0; } 274 } 275 `})]})}function Ns({label:t,value:r}){return r?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1",children:t}
275),e.jsx("p",{className:"text-base text-foreground/90 leading-relaxed",children:r})]}):null}function lm({post:t,onClose:r,currentUserId:s,isAdmin:a,onDelete:o,onTogglePin:i,onEditPost:l,scrollToComments:f,onScrolledToComments:p,dbPosts:g=[],onOpenLinkedPost:c}){var P,N,Y;bs();const x=n.useRef(null),[d,u]=n.useState(!1),[m,b]=n.useState((P=t==null?void 0:t.likes)!=null?P:0),[v,w]=n.useState(!1),[_,y]=n.useState(!1),k=n.useCallback(F=>{const G=F.target.closest("a");if(!G||!G.href)return;const ee=Qn(G.href);if(ee&&c){F.preventDefault(),c(ee);return}G.getAttribute("data-external")!=="true"&&(F.preventDefault(),window.open(G.href,"_blank","noopener,noreferrer"))},[c]),[E,S]=n.useState(""),R=(N=t==null?void 0:t.isPinned)!=null?N:!1,z=n.useRef(null),{comments:j,loading:M,submitting:$,addComment:q,deleteComment:ne}=jl(t!=null&&t.commentsEnabled&&(Y=t==null?void 0:t.id)!=null?Y:null);n.useEffect(()=>{f&&z.current&&setTimeout(()=>{var F;(F=z.current)==null||F.scrollIntoView({behavior:"smooth",block:"start"}),p==null||p()},300)},[f,M]);const J=!!s&&!!(t!=null&&t.authorId)&&s===t.authorId||a;if(n.useEffect(()=>{var F;u(!1),w(!1),S(""),(F=x.current)==null||F.scrollTo({top:0})},[t==null?void 0:t.id]),n.useEffect(()=>{var F;b((F=t==null?void 0:t.likes)!=null?F:0)},[t==null?void 0:t.id,t==null?void 0:t.likes]),n.useEffect(()=>{const F=G=>{G.key==="Escape"&&r()};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[r]),n.useEffect(()=>(document.body.style.overflow=t?"hidden":"",()=>{document.body.style.overflow=""}),[t]),!t)return null;const je=()=>{u(F=>(b(G=>F?G-1:G+1),!F))},ke=()=>{o==null||o(t.id),r()},ve=()=>{i==null||i(t.id,!R)};return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"var(--sv-backdrop)",backdropFilter:"blur(8px)"},onClick:()=>{_||r()},children:[e.jsxs("div",{ref:x,className:"relative w-full max-w-[560px] max-h-[85vh] overflow-y-auto rounded-3xl mx-4",style:{background:"var(--sv-surface-elevated)",border:"1px solid var(--sv-border-light)",boxShadow:"var(--sv-shadow-dropdown)"},onClick:F=>F.stopPropagation(),children:[e.jsxs("div",{className:"sticky top-0 flex items-center justify-between px-6 pt-5 pb-4 z-10",style:{background:"var(--sv-surface-elevated)",borderBottom:"1px solid var(--sv-border-subtle)"},children:[e.jsx("span",{className:"text-xs text-muted-foreground uppercase tracking-widest font-semibold",children:t.space}),e.jsxs("div",{className:"flex items-center gap-2",children:[J&&e.jsxs(e.Fragment,{children:[e.jsxs(yl,{children:[e.jsx(wl,{asChild:!0,children:e.jsx("button",{className:"w-8 h-8 rounded-full flex items-center justify-center transition-colors hover:bg-muted",style:{border:"1px solid hsl(var(--border))"},children:e.jsx(zo,{size:16,className:"text-muted-foreground"})})}),e.jsxs(ga,{align:"end",className:"rounded-2xl min-w-[200px] p-1.5",style:{background:"var(--sv-surface-elevated)",border:"1px solid var(--sv-border-medium)",backdropFilter:"blur(20px)",boxShadow:"var(--sv-shadow-dropdown)"},children:[a&&e.jsxs(e.Fragment,{children:[e.jsxs(Rs,{onClick:()=>y(!0),className:"flex items-center gap-3 px-4 py-3 rounded-xl cursor-pointer",style:{color:"var(--sv-text-primary)"},children:[e.jsx(_o,{size:15,className:"shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold",children:"Editar publicação"})]}),e.jsxs(Rs,{onClick:ve,className:"flex items-center gap-3 px-4 py-3 rounded-xl cursor-pointer",style:{color:"var(--sv-text-primary)"},children:[R?e.jsx(Vo,{size:15,className:"shrink-0"}):e.jsx(Ho,{size:15,className:"shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold",children:R?"Desafixar post":"Fixar post"})]})]}),e.jsxs(Rs,{onClick:()=>w(!0),className:"flex items-center gap-3 px-4 py-3 rounded-xl cursor-pointer",style:{color:"hsl(var(--setverso-red))"},children:[e.jsx(Vt,{size:15,className:"shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold",children:"Excluir publicação"})]})]})]}),v&&e.jsx("div",{className:"fixed inset-0 z-[200] flex items-center justify-center px-6",style:{background:"var(--sv-backdrop)",backdropFilter:"blur(8px)"},onClick:F=>{F.target===F.currentTarget&&w(!1)},children:e.jsxs("div",{className:"w-full max-w-sm rounded-3xl overflow-hidden",style:{background:"var(--sv-surface-elevated)",border:"1px solid var(--sv-border-medium)",boxShadow:"var(--sv-shadow-dropdown)"},children:[e.jsxs("div",{className:"flex flex-col items-center pt-8 pb-5 px-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{background:"hsl(var(--destructive) / 0.12)",border:"1.5px solid hsl(var(--destructive) / 0.3)"},children:e.jsx(Vt,{size:28,style:{color:"hsl(var(--setverso-red))"}})}),e.jsx("h2",{className:"text-xl font-black text-foreground text-center mb-2",children:"Excluir publicação?"}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:["Essa ação é ",e.jsx("span",{className:"text-foreground font-semibold",children:"irreversÃvel"}),"."]})]}),e.jsx("div",{style:{height:"1px",background:"var(--sv-border-subtle)"}}),e.jsxs("div",{className:"flex",children:[e.jsx("button",{onClick:()=>w(!1),className:"flex-1 py-4 text-sm font-semibold",style:{color:"var(--sv-text-secondary)",borderRight:"1px solid var(--sv-border-subtle)"},children:"Cancelar"}),e.jsx("button",{onClick:ke,className:"flex-1 py-4 text-sm font-bold",style:{color:"hsl(var(--setverso-red))"},children:"Sim, excluir"})]})]})})]}),e.jsx("button",{onClick:r,className:"w-8 h-8 rounded-full flex items-center justify-center transition-colors hover:bg-muted",style:{border:"1px solid hsl(var(--border))"},children:e.jsx(Je,{size:16,className:"text-muted-foreground"})})]})]}),e.jsxs("div",{className:"px-6 pt-5 pb-6",children:[e.jsx("h1",{className:"text-2xl font-black leading-tight mb-5",style:{color:"var(--sv-text-heading)"},children:Gr(t.title)}),e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(ut,{className:"h-10 w-10 shrink-0 border border-border",children:[t.authorAvatar&&t.authorAvatar.length>1?e.jsx(Ze,{src:t.authorAvatar,alt:t.author,className:"object-cover"}):t.authorInitials==="PP"?e.jsx(Ze,{src:mn,alt:t.author,className:"object-cover"}):t.author.includes("SetVerso")?e.jsx(Ze,{src:on,alt:t.author,className:"object-contain",style:{mixBlendMode:"screen",background:"black"}}):null,e.jsx(ft,{className:"text-xs font-bold text-white",style:{background:"hsl(var(--setverso-red))"},children:t.authorInitials})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:t.author}),t.isAdmin&&e.jsx(bi,{className:"text-[9px] px-1.5 py-0 h-4 rounded-sm font-bold tracking-wide bg-secondary text-muted-foreground border-0",children:"Admin"})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.timeAgo," atrás"]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("button",{onClick:je,className:"flex items-center gap-1.5 transition-transform active:scale-95",children:[e.jsx(ta,{size:20,className:"transition-colors duration-200",style:{fill:d?"hsl(var(--setverso-red))":"transparent",color:d?"hsl(var(--setverso-red))":"hsl(var(--muted-foreground))"}}),e.jsx("span",{className:"text-sm font-medium",style:{color:d?"hsl(var(--setverso-red))":"hsl(var(--muted-foreground))"},children:m})]}),t.commentsEnabled&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(gs,{size:20,className:"text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:j.length})]}),e.jsx("button",{onClick:()=>Q(this,null,function*(){yield Zr(t.id,t.title),Ie.success("Link copiado!")}),className:"flex items-center gap-1.5 transition-transform active:scale-95",children:e.jsx(Kr,{size:20,className:"text-muted-foreground"})})]})]}),e.jsx("div",{className:"h-px bg-border mb-5"}),t.fullContent.content&&e.jsx("div",{className:"post-content text-foreground
275/85 mb-5",dangerouslySetInnerHTML:{__html:Jn(t.fullContent.content)},onClick:k}),t.attachments&&t.attachments.length>0&&e.jsx(va,{attachments:t.attachments,className:"mb-5"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ks,{label:"ð¤ Perfis",value:t.fullContent.perfis}),e.jsx(ks,{label:"ð Local",value:t.fullContent.local}),e.jsx(ks,{label:"ð
Data",value:t.fullContent.data}),e.jsx(ks,{label:"ð Horário",value:t.fullContent.horario}),e.jsx(ks,{label:"ð° Cachê",value:t.fullContent.cache}),e.jsx(ks,{label:"ð Requisitos",value:t.fullContent.requisitos}),e.jsx(ks,{label:"ð¬ Observações",value:t.fullContent.observacoes})]}),e.jsxs("div",{ref:z,className:"mt-6",children:[e.jsx("div",{className:"h-px bg-border mb-5"}),e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(gs,{size:16,className:"text-muted-foreground"}),e.jsxs("p",{className:"text-sm font-bold text-foreground",children:["Comentários ",t.commentsEnabled&&j.length>0&&`(${j.length})`]})]}),t.commentsEnabled?e.jsxs(e.Fragment,{children:[M?e.jsx("div",{className:"space-y-3",children:[...Array(2)].map((F,G)=>e.jsx("div",{className:"h-14 rounded-xl animate-pulse",style:{background:"var(--sv-surface)"}},G))}):j.length===0?e.jsx("p",{className:"text-xs text-muted-foreground/50 text-center py-4",children:"Nenhum comentário ainda."}):e.jsx("div",{className:"space-y-3",children:j.map(F=>{var ge,le,fe;const G=(le=(ge=F.profiles)==null?void 0:ge.name)!=null?le:"Membro",ee=G.split(" ").slice(0,2).map(pe=>pe[0]).join("").toUpperCase(),re=s===F.author_id,be=(()=>{const pe=Date.now()-new Date(F.created_at).getTime(),Ne=Math.floor(pe/6e4);if(Ne<1)return"agora";if(Ne<60)return`${Ne}min`;const Z=Math.floor(Ne/60);if(Z<24)return`${Z}h`;const me=Math.floor(Z/24);return me<30?`${me}d`:`${Math.floor(me/30)}m`})();return e.jsxs("div",{className:"rounded-xl px-4 py-3",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-subtle)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsxs(ut,{className:"h-6 w-6 border border-border",children:[(fe=F.profiles)!=null&&fe.avatar_url?e.jsx(Ze,{src:F.profiles.avatar_url,alt:G,className:"object-cover"}):null,e.jsx(ft,{className:"text-[8px] font-bold text-accent-foreground",style:{background:"hsl(var(--setverso-red))"},children:ee})]}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:G}),e.jsx("span",{className:"text-[10px] text-muted-foreground/50",children:be}),(re||a)&&e.jsx("button",{onClick:()=>ne(F.id),className:"ml-auto w-5 h-5 flex items-center justify-center rounded transition-all hover:bg-[var(--sv-surface-hover)] active:scale-90",children:e.jsx(Vt,{size:10,className:"text-muted-foreground/40"})})]}),e.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed pl-8",children:F.content})]},F.id)})}),s&&e.jsxs("div",{className:"flex items-center gap-2 rounded-2xl px-4 py-3 mt-4",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-subtle)"},children:[e.jsx("input",{type:"text",value:E,onChange:F=>S(F.target.value),onKeyDown:F=>{F.key==="Enter"&&E.trim()&&(q(E.trim()),S(""))},placeholder:"Escreva um comentário...",className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground/50"}),e.jsx("button",{onClick:()=>{E.trim()&&(q(E.trim()),S(""))},disabled:$||!E.trim(),className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0 transition-all active:scale-90 disabled:opacity-30",style:{background:"hsl(var(--setverso-red) / 0.15)"},children:e.jsx(Vs,{size:14,style:{color:"hsl(var(--setverso-red))"}})})]})]}):e.jsx("div",{className:"flex items-center gap-2 rounded-2xl px-4 py-3",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-subtle)"},children:e.jsx("span",{className:"text-sm text-muted-foreground/50",children:"Esse espaço não permite comentários"})})]})]})]}),e.jsx(Nl,{open:_,post:t,onClose:()=>y(!1),onSave:F=>l==null?void 0:l(t.id,F),posts:g})]})}function ks({label:t,value:r}){return r?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1",children:t}
275),e.jsx("p",{className:"text-sm text-foreground/90 leading-relaxed",children:r})]}):null}var $r,fo;const cm=!!((fo=($r=window.Capacitor)==null?void 0:$r.isNativePlatform)!=null&&fo.call($r)),dm=Se;function um({onSelectSpace:t}){const{spaces:r,loading:s}=ca(),[a,o]=n.useState({}),[i,l]=n.useState([]);n.useEffect(()=>{const u=()=>Q(this,null,function*(){const{data:b}=yield dm.from("nav_links").select("*").eq("visible",!0).order("sort_order");l(b!=null?b:[])});u();const m=()=>{document.visibilityState==="visible"&&u()};return document.addEventListener("visibilitychange",m),()=>{document.removeEventListener("visibilitychange",m)}},[]);const f=cm?i.filter(u=>!u.label.toLowerCase().includes("aplicativo")&&!u.label.toLowerCase().includes("download")):i,p=r.reduce((u,m)=>{var v;const b=(v=m.group_name)!=null?v:"Outros";return u[b]||(u[b]=[]),u[b].push(m),u},{}),g=["Ponto de Partida","Comunidade"],c=[...g.filter(u=>p[u]),...Object.keys(p).filter(u=>!g.includes(u))],x=u=>o(m=>se(L({},m),{[u]:m[u]===void 0?!1:!m[u]})),d=u=>a[u]===void 0?!0:a[u];return s?e.jsx("div",{className:"flex-1 pb-32 px-5 pt-2",children:[...Array(2)].map((u,m)=>e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"h-3 w-24 rounded bg-white/08 animate-pulse"}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),[...Array(3)].map((b,v)=>e.jsx("div",{className:"flex items-center gap-3.5 w-full rounded-2xl px-3 py-3 mb-1 animate-pulse",style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.05)",height:"60px"}},v))]},m))}):e.jsxs("div",{className:"flex-1 pb-44 px-5 pt-2",children:[c.map(u=>e.jsxs("div",{className:"mb-4",children:[e.jsxs("button",{onClick:m=>{m.stopPropagation(),x(u)},onTouchEnd:m=>{m.stopPropagation()},className:"flex items-center gap-3 mb-3 w-full text-left active:opacity-70 transition-opacity",children:[e.jsx(Hs,{size:14,className:"text-muted-foreground shrink-0 transition-transform duration-200",style:{transform:d(u)?"rotate(0deg)":"rotate(-90deg)"}}),e.jsx("p",{className:"text-xs font-bold uppercase tracking-[0.18em] text-muted-foreground",children:u}),!d(u)&&e.jsx("span",{className:"text-[10px] text-muted-foreground/50 font-medium",children:p[u].length}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx("div",{className:"flex flex-col gap-1 overflow-hidden transition-all duration-300",style:{maxHeight:d(u)?`${p[u].length*72}px`:"0px",opacity:d(u)?1:0},children:p[u].map(m=>{var v,w,_;const b=!!m.locked;return e.jsxs("button",{onClick:()=>{var y,k;if(b){Ie.info("Este espaço não está incluso no seu plano.");return}t({id:m.id,emoji:m.emoji,name:m.name,badge:(y=m.badge)!=null?y:void 0,highlight:m.highlight,color:(k=m.color)!=null?k:void 0,post_order:m.post_order,locked:b})},className:Be("group flex items-center gap-3.5 w-full rounded-2xl px-3 py-2.5 transition-all duration-150",b?"cursor-not-allowed":"active:scale-[0.98]"),style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.05)",opacity:b?.55:1},"aria-disabled":b,children:[e.jsxs("div",{className:"w-11 h-11 rounded-xl flex items-center justify-center shrink-0 text-xl relative",style:{background:`linear-gradient(135deg, ${(v=m.color)!=null?v:"#444"}33 0%, ${(w=m.color)!=null?w:"#444"}11 100%)`,border:`1px solid ${(_=m.color)!=null?_:"#444"}30`},children:[e.jsx("span",{style:{filter:b?"grayscale(0.4)":void 0},children:m.emoji}),b&&e.jsx("div",{className:"absolute inset-0 rounded-xl flex items-center justify-center",style:{background:"rgba(0,0,0,0.45)"},children:e.jsx(Us,{size:14,className:"text-white/85"})})]}),e.jsx("span",{className:Be("flex-1 text-left text-[15px] leading-tight",m.highlight&&!b?"font-bold text-foreground":"font-normal text-foreground/80"),children:m.name}),m.badge&&!b&&e.jsx("span",{className:"text-[11px] font-bold px-2.5 py-1 rounded-full mr-1",style:{background:"rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.55)",border:"1px solid rgba(255,255,255,0.1)"},children:m.badge}),b?e.jsx(Us,{size:14,className:"text-white/30 shrink-0"}):e.jsx(gr,{size:15,className:"text-white/20 group-active:text-white/40 transition-colors shrink-0"})]},m.id)})})]},u)),f.length>0&&e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-[0.18em] text-muted-foreground",children:"Links"}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx("div",{className:"flex flex-col gap-1",children:f.map(u=>e.jsxs("a",{href:u.url,target:u.open_external?"_blank":void 0,rel:u.open_external?"noopener noreferrer":void 0,"data-external":u.open_external?"true":void 0,className:"flex items-center gap-3 w-full rounded-2xl px-3 py-3.5 active:scale-[0.98] transition-all duration-150 text-left no-underline",style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.04)"},children:[e.jsx("span",{className:"text-base shrink-0",children:u.emoji}),e.jsx("span",{className:"flex-1 text-left text-[14px] text-foreground
275/70",children:u.label}),u.open_external&&e.jsx(Io,{size:12,className:"text-muted-foreground/40 shrink-0"})]},u.id))})]})]})}const ps=Se;function kl(t){const r=Math.max(1,Math.floor((Date.now()-new Date(t).getTime())/1e3));if(r<60)return`há ${r}s`;const s=Math.floor(r/60);if(s<60)return`há ${s}min`;const a=Math.floor(s/60);if(a<24)return`há ${a}h`;const o=Math.floor(a/24);if(o<30)return`há ${o}d`;const i=Math.floor(o/30);return i<12?`há ${i} mês${i>1?"es":""}`:`há ${Math.floor(i/12)}a`}function fm(t){return t?t.trim().split(/\s+/).slice(0,2).map(r=>{var s,a;return(a=(s=r[0])==null?void 0:s.toUpperCase())!=null?a:""}).join(""):"?"}function Ua({lessonId:t}){const[r,s]=n.useState(null),[a,o]=n.useState([]),[i,l]=n.useState(!0),[f,p]=n.useState(""),[g,c]=n.useState(!1),[x,d]=n.useState(null),[u,m]=n.useState(""),b=n.useRef(null);n.useEffect(()=>{let R=!1;return Q(this,null,function*(){const{data:{user:z}}=yield Se.auth.getUser();if(!z||R)return;const[{data:j},{data:M}]=yield Promise.all([ps.from("profiles").select("id, name, username, avatar_url").eq("id",z.id).maybeSingle(),ps.from("user_roles").select("role").eq("user_id",z.id)]);if(R)return;const $=(M!=null?M:[]).some(q=>q.role==="admin");s({id:z.id,profile:j!=null?j:void 0,isAdmin:$})}),()=>{R=!0}},[]);const v=n.useCallback(()=>Q(this,null,function*(){l(!0);const{data:R,error:z}=yield ps.from("lesson_comments").select("id, lesson_id, user_id, parent_id, content, status, created_at").eq("lesson_id",t).order("created_at",{ascending:!0});if(z){console.error(z),o([]),l(!1);return}const j=R!=null?R:[],M=Array.from(new Set(j.map($=>$.user_id)));if(M.length){const[{data:$},{data:q}]=yield Promise.all([ps.from("profiles").select("id, name, username, avatar_url").in("id",M),ps.from("user_roles").select("user_id, role").in("user_id",M).eq("role","admin")]),ne=new Map(($!=null?$:[]).map(J=>[J.id,J])),ae=new Set((q!=null?q:[]).map(J=>J.user_id));j.forEach(J=>{J.author=ne.get(J.user_id),J.isAdmin=ae.has(J.user_id)})}o(j),l(!1)}),[t]);n.useEffect(()=>{v()},[v]);const{topLevel:w,repliesByParent:_}=n.useMemo(()=>{const R=a.filter(M=>!!(M.status==="approved"||r!=null&&r.isAdmin||r&&M.user_id===r.id)),z=[],j=new Map;return R.forEach(M=>{var $;if(M.parent_id){const q=($=j.get(M.parent_id))!=null?$:[];q.push(M),j.set(M.parent_id,q)}else z.push(M)}),z.sort((M,$)=>+new Date($.created_at)-+new Date(M.created_at)),{topLevel:z,repliesByParent:j}},[a,r]),y=()=>Q(this,null,function*(){if(!r){Ie.error("Faça login para comentar");return}const R=f.trim();if(!R)return;c(!0);const{error:z}=yield ps.from("lesson_comments").insert({lesson_id:t,user_id:r.id,content:R});if(c(!1),z){Ie.error("Não foi possÃvel enviar");return}p(""),Ie.success(r.isAdmin?"Comentário publicado":"Enviado! Aguardando aprovação"),v()}),k=()=>Q(this,null,function*(){if(!(r!=null&&r.isAdmin)||!x)return;const R=u.trim();if(!R)return;const{error:z}=yield ps.from("lesson_comments").insert({lesson_id:t,user_id:r.id,parent_id:x.id,content:R});if(z){Ie.error("Erro ao responder");return}m(""),d(null),Ie.success("Resposta enviada"),v()}),E=R=>Q(this,null,function*(){if(!confirm("Excluir este comentário?"))return;const{error:z}=yield ps.from("lesson_comments").delete().eq("id",R);if(z){Ie.error("Erro ao excluir");return}v()}),S=a.filter(R=>R.status==="approved"&&!R.parent_id).length;return e.jsxs("section",{className:"mt-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(gs,{size:18,style:{color:"var(--sv-text-primary)"}}),e.jsx("h3",{className:"text-base font-bold",style:{color:"var(--sv-text-primary)"},children:"Comentários e dúvidas"}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"var(--sv-surface-hover, rgba(255,255,255,0.06))",color:"var(--sv-text-muted)"},children:S})]}),e.jsxs("div",{className:"rounded-2xl p-3 flex gap-3 items-start",style:{background:"var(--sv-surface, rgba(255,255,255,0.03))",border:"1px solid var(--sv-border-subtle, rgba(255,255,255,0.08))"},children:[e.jsx(Vr,{profile:r==null?void 0:r.profile,size:36}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("textarea",{ref:b,value:f,onChange:R=>p(R.target.value),placeholder:r?"Escreva sua dúvida ou comentário...":"Faça login para comentar",disabled:!r||g,rows:2,className:"w-full resize-none bg-transparent outline-none text-sm leading-relaxed placeholder:opacity-60",style:{color:"var(--sv-text-primary)"},onInput:R=>{const z=R.currentTarget;z.style.height="auto",z.style.height=`${Math.min(180,z.scrollHeight)}px`}}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx("span",{className:"text-[11px]",style:{color:"var(--sv-text-muted)"},children:r!=null&&r.isAdmin?"Publicado automaticamente como admin":"Será publicado após aprovação"}),e.jsxs("button",{onClick:y,disabled:!r||g||!f.trim(),className:"inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-full text-xs font-semibold transition-all disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--sv-text-primary)",color:"var(--sv-bg-primary, #000)"},children:[g?e.jsx(dr,{size:13,className:"animate-spin"}):e.jsx(Vs,{size:13}),"Enviar"]})]})]})]}),e.jsx("div",{className:"mt-5 space-y-4",children:i?e.jsx("div",{className:"space-y-3",children:[1,2].map(R=>e.jsx("div",{className:"h-20 rounded-2xl animate-pulse",style:{background:"var(--sv-surface, rgba(255,255,255,0.04))"}},R))}):w.length===0?e.jsx("p",{className:"text-sm py-8 text-center",style:{color:"var(--sv-text-muted)"},children:"Seja o primeiro a comentar nesta aula."}):w.map(R=>{var q;const z=(q=_.get(R.id))!=null?q:[],j=R.user_id===(r==null?void 0:r.id),M=R.status==="pending",$=R.status==="rejected";return e.jsxs("article",{className:"rounded-2xl p-4",style:{background:"var(--sv-surface, rgba(255,255,255,0.03))",border:"1px solid var(--sv-border-subtle, rgba(255,255,255,0.08))",opacity:$?.5:1},children:[e.jsx(mm,{c:R,mine:j}),M&&j&&e.jsxs("div",{className:"mb-2 inline-flex items-center gap-1.5 text-[11px] px-2 py-0.5 rounded-full",style:{background:"rgba(234,179,8,0.12)",color:"rgb(234,179,8)"},children:[e.jsx(ea,{size:11})," Aguardando aprovação"]}),$&&j&&e.jsx("div",{className:"mb-2 inline-flex items-center gap-1.5 text-[11px] px-2 py-0.5 rounded-full",style:{background:"rgba(239,68,68,0.12)",color:"rgb(248,113,113)"},children:"Reprovado"}),e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",style:{color:"var(--sv-text-primary)"},children:R.content}),e.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[(r==null?void 0:r.isAdmin)&&e.jsxs("button",{onClick:()=>{d(R),m("")},className:"inline-flex items-center gap-1 text-[11px] font-medium hover:opacity-80 transition-opacity",style:{color:"var(--sv-text-muted)"},children:[e.jsx($c,{size:12})," Responder"]}),(j||(r==null?void 0:r.isAdmin))&&e.jsxs("button",{onClick:()=>E(R.id),className:"inline-flex items-center gap-1 text-[11px] font-medium hover:opacity-80 transition-opacity",style:{color:"var(--sv-text-muted)"},children:[e.jsx(Vt,{size:12})," Excluir"]})]}),z.length>0&&e.jsx("div",{className:"mt-3 pt-3 space-y-3",style:{borderTop:"1px solid var(--sv-border-subtle, rgba(255,255,255,0.06))"},children:z.map(ne=>{var ae,J,je,ke;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Vr,{profile:ne.author,size:28}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("span",{className:"text-xs font-semibold",style:{color:"var(--sv-text-primary)"},children:(ke=(je=(ae=ne.author)==null?void 0:ae.name)!=null?je:(J=ne.author)==null?void 0:J.username)!=null?ke:"Usuário"}),ne.isAdmin&&e.jsx(_l,{}),e.jsx("span",{className:"text-[10px]",style:{color:"var(--sv-text-muted)"},children:kl(ne.created_at)})]}),e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",style:{color:"var(--sv-text-secondary, var(--sv-text-primary))"},children:ne.content}),(ne.user_id===(r==null?void 0:r.id)||(r==null?void 0:r.isAdmin))&&e.jsxs("button",{onClick:()=>E(ne.id),className:"mt-1 inline-flex items-center gap-1 text-[10px] font-medium hover:opacity-80",style:{color:"var(--sv-text-muted)"},children:[e.jsx(Vt,{size:10})," Excluir"]})]})]},ne.id)})}),(r==null?void 0:r.isAdmin)&&(x==null?void 0:x.id)===R.id&&e.jsxs("div",{className:"mt-3 pt-3 flex gap-2 items-start",style:{borderTop:"1px solid var(--sv-border-subtle, rgba(255,255,255,0.06))"},children:[e.jsx(Vr,{profile:r.profile,size:28}),e.jsxs("div",{className:"flex-1",children:[e.jsx("textarea",{autoFocus:!0,value:u,onChange:ne=>m(ne.target.value),rows:2,placeholder:"Responder como admin...",className:"w-full resize-none bg-transparent outline-none text-sm placeholder:opacity-60",style:{color:"var(--sv-text-primary)"}}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsxs("button",{onClick:k,disabled:!u.trim(),className:"inline-flex items-center gap-1 px-3 py-1 rounded-full text-[11px] font-semibold disabled:opacity-40",style:{background:"var(--sv-text-primary)",color:"var(--sv-bg-primary, #000)"},children:[e.jsx(Vs,{size:11})," Enviar"]}),e.jsxs("button",{onClick:()=>{d(null),m("")},className:"inline-flex items-center gap-1 px-3 py-1 rounded-full text-[11px] font-medium",style:{color:"var(--sv-text-muted)"},children:[e.jsx(Je,{size:11})," Cancelar"]})]})]})]})]},R.id)})})]})}function mm({c:t,mine:r}){var s,a,o,i;return e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Vr,{profile:t.author,size:36}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-semibold truncate",style:{color:"var(--sv-text-primary)"},children:(i=(o=(s=t.author)==null?void 0:s.name)!=null?o:(a=t.author)==null?void 0:a.username)!=null?i:"Usuário"}),t.isAdmin&&e.jsx(_l,{}),r&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full",style:{background:"rgba(255,255,255,0.06)",color:"var(--sv-text-muted)"},children:"Você"})]}),e.jsx("span",{className:"text-[11px]",style:{color:"var(--sv-text-muted)"},children:kl(t.created_at)})]})]})}function _l(){return e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-bold px-1.5 py-0.5 rounded-full",style:{background:"linear-gradient(135deg, rgb(99,102,241), rgb(139,92,246))",color:"#fff"},children:[e.jsx(Bc,{size:10})," Admin"]})}function Vr({profile:t,size:r}){var s;return t!=null&&t.avatar_url?e.jsx("img",{src:t.avatar_url,alt:"",className:"rounded-full object-cover shrink-0",style:{width:r,height:r}}):e.jsx("div",{className:"rounded-full flex items-center justify-center font-bold shrink-0",style:{width:r,height:r,background:"linear-gradient(135deg, rgba(99,102,241,0.4), rgba(139,92,246,0.4))",color:"#fff",fontSize:r*.38},children:fm((s=t==null?void 0:t.name)!=null?s:t==null?void 0:t.username)})}const xt={play:"M8 5v14l11-7z",pause:"M6 5h4v14H6zm8 0h4v14h-4z",menos:"M12.5 8V5l-5 4 5 4v-3c2.5 0 4.5 2 4.5 4.5S15 19 12.5 19 8 17 8 14.5H6c0 3.6 2.9 6.5 6.5 6.5s6.5-2.9 6.5-6.5S16.1 8 12.5 8z",mais:"M11.5 8V5l5 4-5 4v-3C9 10 7 12 7 14.5S9 19 11.5 19s4.5-2 4.5-4.5h2c0 3.6-2.9 6.5-6.5 6.5S5 18.1 5 14.5 7.9 8 11.5 8z",som:"M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.8-1-3.3-2.5-4v8c1.5-.7 2.5-2.2 2.5-4zM14 3.2v2.1c2.9.9 5 3.5 5 6.7s-2.1 5.8-5 6.7v2.1c4-1 7-4.5 7-8.8s-3-7.8-7-8.8z",mudo:"M16.5 12c0-1.8-1-3.3-2.5-4v2.2l2.5 2.5v-.7zM19 12c0 .9-.2 1.8-.5 2.6l1.5 1.5c.7-1.2 1-2.6 1-4.1 0-4.3-3-7.8-7-8.8v2.1c2.9.9 5 3.5 5 6.7zM4.3 3L3 4.3 7.7 9H3v6h4l5 5v-6.7l4.3 4.3c-.7.5-1.4.9-2.3 1.1v2.1c1.4-.3 2.6-.9 3.7-1.7l2 2 1.3-1.3L4.3 3zM12 4L9.9 6.1 12 8.2V4z",audio:"M12 3v10.55A4 4 0 1 0 14 17V7h4V3h-6z",qual:"M19.4 13a7.6 7.6 0 0 0 0-2l2.1-1.6a.5.5 0 0 0 .1-.6l-2-3.5a.5.5 0 0 0-.6-.2l-2.5 1a7.3 7.3 0 0 0-1.7-1l-.4-2.6a.5.5 0 0 0-.5-.4h-4a.5.5 0 0 0-.5.4l-.4 2.6a7.3 7.3 0 0 0-1.7 1l-2.5-1a.5.5 0 0 0-.6.2l-2 3.5a.5.5 0 0 0 .1.6L4.6 11a7.6 7.6 0 0 0 0 2l-2.1 1.6a.5.5 0 0 0-.1.6l2 3.5a.5.5 0 0 0 .6.2l2.5-1a7.3 7.3 0 0 0 1.7 1l.4 2.6a.5.5 0 0 0 .5.4h4a.5.5 0 0 0 .5-.4l.4-2.6a7.3 7.3 0 0 0 1.7-1l2.5 1a.5.5 0 0 0 .6-.2l2-3.5a.5.5 0 0 0-.1-.6L19.4 13zM12 15.5A3.5 3.5 0 1 1 15.5 12 3.5 3.5 0 0 1 12 15.5z",tela:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z",g
275irar:"M16.48 2.52c3.27 1.55 5.61 4.72 5.99 8.48h1.5C23.44 4.84 18.29 0 12 0l-.66.03 3.81 3.81 1.33-1.32zm-6.25-.77a1.49 1.49 0 0 0-2.12 0L1.75 8.11a1.49 1.49 0 0 0 0 2.12l12.02 12.02c.59.59 1.54.59 2.12 0l6.36-6.36c.59-.59.59-1.54 0-2.12L10.23 1.75zm4.6 19.44L2.81 9.17l6.36-6.36 12.02 12.02-6.36 6.36zM7.52 21.48C4.25 19.94 1.91 16.76 1.53 13H.03C.56 19.16 5.71 24 12 24l.66-.03-3.81-3.81-1.33 1.32z",telaSai:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z",aulaAnterior:"M6 6h2v12H6zm3.5 6l8.5 6V6z",proximaAula:"M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"},It=({d:t})=>e.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{d:t})}),En=t=>{(!isFinite(t)||t<0)&&(t=0);const r=Math.floor(t/3600),s=Math.floor(t%3600/60),a=Math.floor(t%60),o=i=>String(i).padStart(2,"0");return`${o(r)}:${o(s)}:${o(a)}`},Rn=[.5,.75,1,1.25,1.5,2];function pm(t){const[r,s]=n.useState(null),[a,o]=n.useState(null),[i,l]=n.useState(!1),[f,p]=n.useState(null),g=n.useRef(null);n.useEffect(()=>{t.visivel||(s(null),o(null))},[t.visivel]);const c=n.useCallback((y,k)=>{const E=g.current;if(!E||t.duracao<=0)return null;const S=E.getBoundingClientRect(),R=(t.girada?S.height:S.width)||1,z=t.girada?k-S.top:y-S.left,j=Math.min(1,Math.max(0,z/R));return{t:j*t.duracao,x:j*R}},[t.duracao,t.girada]),x=y=>{const k=c(y.clientX,y.clientY);k&&(o(k),i&&(p(k.t),t.onBuscar(k.t)))},d=y=>{var k,E;(E=(k=y.currentTarget).hasPointerCapture)!=null&&E.call(k,y.pointerId)&&y.currentTarget.releasePointerCapture(y.pointerId),l(!1),p(null),y.pointerType==="touch"&&o(null)},u=i&&f!==null?f:t.atual,m=t.duracao>0?u/t.duracao*100:0,b=t.duracao>0?t.bufferAte/t.duracao*100:0,v=a&&t.temTrickplay?t.quadroEm(a.t):null,w=(y,k,E,S)=>e.jsxs("div",{className:"dp-menu",role:"menu",onClick:R=>R.stopPropagation(),children:[e.jsxs("div",{className:"tit",children:[y,e.jsx("button",{"aria-label":"Fechar",onClick:()=>s(null),children:"Ã"})]}),k.map(R=>e.jsxs("button",{role:"menuitemradio",className:"it","aria-checked":E===R.id,onClick:()=>{S(R.id),s(null)},children:[R.rotulo,R.detalhe&&e.jsx("small",{children:R.detalhe})]},R.id))]}),_=(y,k,E,S,R="")=>e.jsxs("div",{className:`dp-anc dp-anc-${y}`,children:[e.jsx("button",{className:`dp-bt${R?` ${R}`:""}${r===y?" ativo":""}`,"aria-label":k,"aria-haspopup":"menu","aria-expanded":r===y,onClick:z=>{var M;z.stopPropagation();const j=r!==y;s(j?y:null),j&&((M=t.onAbrirMenu)==null||M.call(t))},children:E}),r===y&&S]});return e.jsxs("div",{className:`dp-ctrl${t.visivel?" on":""}`,onClick:y=>y.stopPropagation(),children:[e.jsxs("div",{ref:g,className:`dp-barra${i?" arrastando":""}`,role:"slider",tabIndex:0,"aria-label":"Posição do vÃdeo","aria-valuemin":0,"aria-valuemax":Math.round(t.duracao),"aria-valuenow":Math.round(t.atual),onPointerMove:x,onPointerLeave:()=>{i||o(null)},onPointerDown:y=>{y.preventDefault(),y.currentTarget.setPointerCapture(y.pointerId),l(!0);const k=c(y.clientX,y.clientY);k&&(p(k.t),o(k),t.onBuscar(k.t))},onPointerUp:d,onPointerCancel:d,children:[e.jsxs("div",{className:"dp-trilho",children:[e.jsx("div",{className:"dp-bufer",style:{width:`${b}%`}}),e.jsx("div",{className:"dp-tocado",style:{width:`${m}%`}})]}),e.jsx("div",{className:"dp-puxador",style:{left:`${m}%`}}),a&&e.jsxs("div",{className:"dp-balao on",style:{left:a.x,transform:"translateX(-50%)"},children:[e.jsx("div",{className:`dp-mini${v!=null&&v.pronto?"":" vazio"}`,style:v!=null&&v.pronto?{"--mw":`${v.w}px`,backgroundImage:`url(${v.url})`,backgroundPosition:`-${v.x}px -${v.y}px`}:void 0}),e.jsx("div",{className:"dp-hora",children:En(a.t)})]})]}),e.jsxs("div",{className:"dp-fila",children:[e.jsxs("div",{className:"dp-lado",children:[e.jsxs("div",{className:"dp-vol",children:[e.jsx("button",{className:"dp-bt","aria-label":t.mudo?"Ativar som":"Silenciar",onClick:y=>{y.stopPropagation(),t.onMudo()},children:e.jsx(It,{d:t.mudo||t.volume===0?xt.mudo:xt.som})}),e.jsx("input",{type:"range",min:0,max:1,step:.01,value:t.mudo?0:t.volume,"aria-label":"Volume",style:{"--vp":`${(t.mudo?0:t.volume)*100}%`},onClick:y=>y.stopPropagation(),onChange:y=>t.onVolume(parseFloat(y.target.value))})]}),e.jsxs("div",{className:"dp-tempo",children:[e.jsx("b",{children:En(t.atual)})," ",e.jsxs("span",{children:["/ ",En(t.duracao)]})]})]}),e.jsx("div",{className:"dp-centro",children:t.onAulaAnterior||t.onProximaAula?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"dp-bt dp-pulo dp-aula","aria-label":"Aula anterior",disabled:!t.onAulaAnterior,style:t.onAulaAnterior?void 0:{opacity:.35,pointerEvents:"none"},onClick:y=>{var k;y.stopPropagation(),(k=t.onAulaAnterior)==null||k.call(t)},children:e.jsx(It,{d:xt.aulaAnterior})}),e.jsx("button",{className:"dp-bt dp-play","aria-label":t.tocando?"Pausar":"Reproduzir",onClick:y=>{y.stopPropagation(),t.onPlayPause()},children:e.jsx(It,{d:t.tocando?xt.pause:xt.play})}),e.jsx("button",{className:"dp-bt dp-pulo dp-aula","aria-label":"Próxima aula",disabled:!t.onProximaAula,style:t.onProximaAula?void 0:{opacity:.35,pointerEvents:"none"},onClick:y=>{var k;y.stopPropagation(),(k=t.onProximaAula)==null||k.call(t)},children:e.jsx(It,{d:xt.proximaAula})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"dp-bt dp-pulo","aria-label":"Voltar 10 segundos",onClick:y=>{y.stopPropagation(),t.onPular(-10)},children:[e.jsx(It,{d:xt.menos}),e.jsx("em",{children:"10"})]}),e.jsx("button",{className:"dp-bt dp-play","aria-label":t.tocando?"Pausar":"Reproduzir",onClick:y=>{y.stopPropagation(),t.onPlayPause()},children:e.jsx(It,{d:t.tocando?xt.pause:xt.play})}),e.jsxs("button",{className:"dp-bt dp-pulo","aria-label":"Avançar 10 segundos",onClick:y=>{y.stopPropagation(),t.onPular(10)},children:[e.jsx(It,{d:xt.mais}),e.jsx("em",{children:"10"})]})]})}),e.jsxs("div",{className:"dp-lado dp-dir",children:[_("vel","Velocidade de reprodução",e.jsxs(e.Fragment,{children:[t.velocidade,"x"]}),w("Velocidade",Rn.map((y,k)=>({id:k,rotulo:`${y}Ã`})),Rn.indexOf(t.velocidade),y=>t.onVelocidade(Rn[y])),"txt"),t.audios.length>1&&_("audio","Faixa de áudio",e.jsx(It,{d:xt.audio}),w("Ãudio",t.audios,t.audioAtual,t.onAudio)),_("leg","Legendas",e.jsx("span",{className:"dp-cc-txt",children:"CC"}),w("Legendas",[{id:-1,rotulo:"Desativadas"},...t.legendas],t.legendaAtual,t.onLegenda),t.legendaAtual!==-1?"txt cc on":"txt cc"),_("qual","Qualidade",e.jsx(It,{d:xt.qual}),w("Qualidade",[{id:-1,rotulo:"Automática",detalhe:t.qualidadeEmUso},...t.qualidades],t.qualidadeAtual,t.onQualidade)),t.onGirar&&!t.girada&&e.jsx("button",{className:"dp-bt dp-girar","aria-label":"Virar a tela",onClick:y=>{var k;y.stopPropagation(),(k=t.onGirar)==null||k.call(t)},children:e.jsx(It,{d:xt.girar})}),t.girada?e.jsx("button",{className:"dp-bt","aria-label":"Voltar para vertical",onClick:y=>{var k;y.stopPropagation(),(k=t.onGirar)==null||k.call(t)},children:e.jsx(It,{d:xt.girar})}):e.jsx("button",{className:"dp-bt","aria-label":t.telaCheia?"Sair da tela cheia":"Tela cheia",onClick:y=>{y.stopPropagation(),t.onTelaCheia()},children:e.jsx(It,{d:t.telaCheia?xt.telaSai:xt.tela})})]})]})]})}const hm=6,Ga=t=>{const r=t.trim().split(":").map(parseFloat);return r.length===3?r[0]*3600+r[1]*60+r[2]:r.length===2?r[0]*60+r[1]:r[0]||0},Sl=(t,r)=>{try{return new URL(r,t).toString()}catch(s){return r}};function Cl(t,r){const s=[],a=t.split(/\r?\n/);for(let o=0;o<a.length;o++){const i=a[o].match(/^([\d:.]+)\s*-->\s*([\d:.]+)/);if(!i)continue;const l=(a[o+1]||"").trim().match(/^(.+?)#xywh=(\d+),(\d+),(\d+),(\d+)$/);l&&s.push({ini:Ga(i[1]),fim:Ga(i[2]),img:Sl(r,l[1]),x:+l[2],y:+l[3],w:+l[4],h:+l[5]})}return s}function El(t,r){const s=t.match(/TRICKPLAY="([^"]+)"/);return s?Sl(r,s[1]):null}function xm(t,r){const[s,a]=n.useState([]),o=n.useRef(new Map),[,i]=n.useState(0),l=n.useRef(!0);n.useEffect(()=>{if(l.current=!0,a([]),o.current.forEach(c=>{!c.ok&&!c.erro&&(c.el.src="")}),o.current.clear(),!(!t||!/\.m3u8(\?|$)/i.test(t)))return Q(this,null,function*(){try{const c=yield fetch(t);if(!c.ok||!l.current)return;const x=El(yield c.text(),t);if(!x||!l.current)return;const d=yield fetch(x);if(!d.ok||!l.current)return;const u=Cl(yield d.text(),x);if(!l.current)return;a(u),u.length&&p.current(u[0].img)}catch(c){}}),()=>{l.current=!1}},[t,r]);const f=n.useCallback(c=>{const x=o.current,d=x.get(c);if(d)return x.delete(c),x.set(c,d),d;const u=new Image,m={el:u,ok:!1,erro:!1};for(u.onload=()=>{m.ok=!0,l.current&&i(b=>b+1)},u.onerror=()=>{m.erro=!0},u.src=c,x.set(c,m);x.size>hm;){const b=x.keys().next().value,v=x.get(b);!v.ok&&!v.erro&&(v.el.src=""),x.delete(b)}return m},[]),p=n.useRef(f);n.useEffect(()=>{p.current=f},[f]);const g=n.useCallback(c=>{if(!s.length)return null;let x=0,d=s.length-1,u=-1;for(;x<=d;){const w=x+d>>1;s[w].ini<=c?(u=w,x=w+1):d=w-1}const m=s[u<0?0:u],b=f(m.img),v=s[Math.min((u<0?0:u)+12,s.length-1)];
275return v&&v.img!==m.img&&f(v.img),{url:m.img,x:m.x,y:m.y,w:m.w,h:m.h,pronto:b.ok}},[s,f]);return{disponivel:s.length>0,quadroEm:g,total:s.length}}const gm={niveis:[],nivelAtual:-1,nivelEmUso:-1,audios:[],audioAtual:-1,legendas:[],legendaAtual:-1},sr=(t,r)=>{const s=t.match(new RegExp(`${r}="([^"]*)"`))||t.match(new RegExp(`${r}=([^,]*)`));return s?s[1]:""};function vm(t){const r=t.split(/\r?\n/),s=[],a=[],o=[];for(const i of r){if(i.startsWith("#EXT-X-MEDIA:")){const l=sr(i,"TYPE"),f=sr(i,"NAME"),p=sr(i,"LANGUAGE");l==="AUDIO"&&a.push({id:a.length,nome:f||p||`Faixa ${a.length+1}`,idioma:p}),l==="SUBTITLES"&&o.push({id:o.length,nome:f||p||`Legenda ${o.length+1}`,idioma:p});continue}if(i.startsWith("#EXT-X-STREAM-INF:")){const l=sr(i,"RESOLUTION"),f=l.includes("x")&&parseInt(l.split("x")[1],10)||0,p=parseInt(sr(i,"BANDWIDTH"),10)||0;s.push({id:s.length,altura:f,rotulo:f?`${f}p`:`${Math.round(p/1e3)} kbps`,bitrate:p})}}return s.sort((i,l)=>l.altura-i.altura||l.bitrate-i.bitrate),{niveis:s,audios:a,legendas:o}}function bm(t,r,s){const[a,o]=n.useState(null),[i,l]=n.useState(gm),f=n.useRef(()=>{});n.useEffect(()=>{if(o(null),!r||!/\.m3u8(\?|$)/i.test(r))return;let d=!0;return Q(this,null,function*(){try{const u=yield fetch(r);if(!u.ok||!d)return;const m=vm(yield u.text());d&&o(m)}catch(u){}}),()=>{d=!1}},[r]),n.useEffect(()=>{const d=()=>{var S,R,z,j,M;if(t){const $=(t.levels||[]).map((ae,J)=>({id:J,altura:ae.height||0,rotulo:ae.height?`${ae.height}p`:`${Math.round((ae.bitrate||0)/1e3)} kbps`,bitrate:ae.bitrate||0})).sort((ae,J)=>J.altura-ae.altura),q=(t.audioTracks||[]).map((ae,J)=>({id:J,nome:ae.name||ae.lang||`Faixa ${J+1}`,idioma:ae.lang||""})),ne=(t.subtitleTracks||[]).map((ae,J)=>({id:J,nome:ae.name||ae.lang||`Legenda ${J+1}`,idioma:ae.lang||""}));l({niveis:$.length?$:(a==null?void 0:a.niveis)||[],nivelAtual:(S=t.currentLevel)!=null?S:-1,nivelEmUso:t.currentLevel===-1?(R=t.loadLevel)!=null?R:-1:(z=t.currentLevel)!=null?z:-1,audios:q.length?q:(a==null?void 0:a.audios)||[],audioAtual:q.length?(j=t.audioTrack)!=null?j:-1:a!=null&&a.audios.length?0:-1,legendas:ne.length?ne:(a==null?void 0:a.legendas)||[],legendaAtual:t.subtitleDisplay===!1?-1:(M=t.subtitleTrack)!=null?M:-1});return}const v=s?Array.from(s.textTracks):[],w=v.filter($=>$.kind==="subtitles"||$.kind==="captions").map(($,q)=>({id:q,nome:$.label||$.language||`Legenda ${q+1}`,idioma:$.language||""})),_=s&&s.audioTracks?Array.from(s.audioTracks):[],y=_.map(($,q)=>({id:q,nome:$.label||$.language||`Faixa ${q+1}`,idioma:$.language||""})),k=v.filter($=>$.kind==="subtitles"||$.kind==="captions").findIndex($=>$.mode!=="disabled"),E=_.findIndex($=>$.enabled);l({niveis:(a==null?void 0:a.niveis)||[],nivelAtual:-1,nivelEmUso:-1,audios:y.length?y:(a==null?void 0:a.audios)||[],audioAtual:y.length?E:a!=null&&a.audios.length?0:-1,legendas:w.length?w:(a==null?void 0:a.legendas)||[],legendaAtual:w.length?k:-1})};f.current=d,d();const u=window.setInterval(d,1e3),m=["hlsManifestParsed","hlsLevelSwitched","hlsAudioTrackSwitched","hlsSubtitleTrackSwitch","hlsSubtitleTracksUpdated","hlsAudioTracksUpdated","hlsLevelLoaded","hlsAudioTrackLoaded","hlsSubtitleTrackLoaded","hlsManifestLoaded"],b=v=>{try{t==null||t.on(v,d)}catch(w){}};return t&&m.forEach(b),s==null||s.addEventListener("loadedmetadata",d),()=>{window.clearInterval(u),f.current=()=>{},t&&m.forEach(v=>{try{t.off(v,d)}catch(w){}}),s==null||s.removeEventListener("loadedmetadata",d)}},[t,s,a]);const p=n.useCallback(d=>{t&&(t.currentLevel=d),l(u=>se(L({},u),{nivelAtual:d}))},[t]),g=n.useCallback(d=>{t?t.audioTrack=d:s&&s.audioTracks&&Array.from(s.audioTracks).forEac
275h((m,b)=>{m.enabled=b===d}),l(u=>se(L({},u),{audioAtual:d}))},[t,s]),c=n.useCallback(d=>{t?d<0?(t.subtitleDisplay=!1,t.subtitleTrack=-1):(t.subtitleTrack=d,t.subtitleDisplay=!0):s&&Array.from(s.textTracks).filter(m=>m.kind==="subtitles"||m.kind==="captions").forEach((m,b)=>{m.mode=b===d?"hidden":"disabled"}),l(u=>se(L({},u),{legendaAtual:d}))},[t,s]),x=n.useCallback(()=>f.current(),[]);return se(L({},i),{definirNivel:p,definirAudio:g,definirLegenda:c,atualizar:x})}const Ya=(t,r)=>{const s=t.match(new RegExp(`${r}="([^"]*)"`))||t.match(new RegExp(`${r}=([^,]*)`));return s?s[1]:""};function ym(t,r){const s=[];for(const a of t.split(/\r?\n/)){if(!a.startsWith("#EXT-X-MEDIA:")||Ya(a,"TYPE")!=="SUBTITLES")continue;const o=Ya(a,"URI");if(o)try{s.push(new URL(o,r).toString())}catch(i){}}return s}const Ka=t=>{const r=t.trim().split(":"),s=parseFloat(r.pop()||"0"),a=parseInt(r.pop()||"0",10)||0;return(parseInt(r.pop()||"0",10)||0)*3600+a*60+s},wm=t=>t.replace(/<br\s*\/?>/gi,` 276`).replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").trim();function jm(t){var a;const r=[],s=t.split(/\r?\n/);for(let o=0;o<s.length;o++){const i=s[o];if(!i.match(/(\d{1,2}:)?\d{1,2}:\d{2}[.,]\d{1,3}\s*-->\s*(\d{1,2}:)?\d{1,2}:\d{2}[.,]\d{1,3}/))continue;const[f,p]=i.split("-->"),g=Ka(f.replace(",",".")),c=Ka(((a=(p||"").split(/\s+/).filter(Boolean)[0])==null?void 0:a.replace(",","."))||"0"),x=[];for(o++;o<s.length&&s[o].trim()!=="";)x.push(s[o]),o++;const d=wm(x.join(` 277`));d&&r.push({start:g,end:c,texto:d})}return r}function Nm(t,r){const s=[];let a=0,o=0;for(const i of t.split(/\r?\n/)){const l=i.trim();if(l.startsWith("#EXTINF:")){a=parseFloat(l.slice(8).split(",")[0])||0;continue}if(!l||l.startsWith("#"))continue;let f=l;try{f=new URL(l,r).toString()}catch(p){}s.push({url:f,inicio:o,fim:o+a}),o+=a}return s}function km(t,r,s,a){const[o,i]=n.useState([]),[l,f]=n.useState([]),p=n.useRef(new Set),g=n.useRef(!1);n.useEffect(()=>{if(i([]),f([]),p.current=new Set,!s||!t||r<0||!/\.m3u8(\?|$)/i.test(t))return;let u=!0;return Q(this,null,function*(){try{const m=yield fetch(t);if(!m.ok||!u)return;const v=ym(yield m.text(),t)[r];if(!v)return;const w=yield fetch(v);if(!w.ok||!u)return;const _=Nm(yield w.text(),v);u&&i(_)}catch(m){}}),()=>{u=!1}},[t,r,s]),n.useEffect(()=>{if(!s||o.length===0||g.current)return;const u=o.filter(b=>b.fim>=a-4&&b.inicio<=a+60).filter(b=>!p.current.has(b.url)).slice(0,12);if(u.length===0)return;g.current=!0;let m=!0;return Q(this,null,function*(){const b=yield Promise.all(u.map(w=>Q(this,null,function*(){p.current.add(w.url);try{const _=yield fetch(w.url);return _.ok?jm(yield _.text()):[]}catch(_){return[]}})));if(g.current=!1,!m)return;const v=b.flat();v.length!==0&&f(w=>{const _=new Map(w.map(y=>[`${y.start}|${y.end}|${y.texto}`,y]));for(const y of v)_.set(`${y.start}|${y.end}|${y.texto}`,y);return Array.from(_.values()).sort((y,k)=>y.start-k.start)})}),()=>{m=!1}},[s,o,a]);const c=n.useMemo(()=>l.filter(u=>a>=u.start&&a<=u.end).map(u=>u.texto).join(` 278`),[l,a]),x=o.length>0,d=n.useCallback(()=>{p.current=new Set,f([])},[]);return{textoAtual:c,disponivel:x,reiniciar:d}}const Xa=t=>t.replace(/<br\s*\/?>/gi,` 279`).replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");function _m({src:t,title:r,orientation:s="horizontal",initialPosition:a=0,autoPlay:o=!1,onProgress:i,onTick:l,onComplete:f,onEnded:p,onPrev:g,onNext:c,metrics:x}){var it;const d=n.useRef(null),[u,m]=n.useState(null),b=n.useRef(null),v=n.useRef(),w=n.useRef(!1),_=n.useRef(!1),y=n.useRef(0),k=n.useRef(0),E=n.useRef(i);n.useEffect(()=>{E.current=i},[i]);const[S,R]=n.useState(!1),[z,j]=n.useState(!1),[M,$]=n.useState(1),[q,ne]=n.useState(0),[ae,J]=n.useState(0),[je,ke]=n.useState(0),[ve,P]=n.useState(1),[N,Y]=n.useState(!0),[F,G]=n.useState(!1),[ee,re]=n.useState(null),[be,ge]=n.useState(null),[le,fe]=n.useState([]);n.useEffect(()=>{w.current=!1,_.current=!1,re(null),P(1),fe([]),ne(0),ke(0)},[t]);const Ne=!n.useMemo(()=>{const A=navigator.userAgent;return(/iPad|iPhone|iPod/.test(A)||/Safari/.test(A)&&!/Chrome|Chromium|Edg|OPR|Android/.test(A))&&!!document.createElement("video").canPlayType("application/vnd.apple.mpegurl")},[]);n.useEffect(()=>{if(!Ne||!u||!t){ge(null);return}re(null);let A=!1,X=null;return Q(this,null,function*(){const Ce=(yield Lt(()=>
279import("./hls-ZtzyzKKo.js"),[])).default;if(A||!Ce.isSupported())return;const Oe=new Ce({enableWorker:!0,renderTextTracksNatively:!1,startLevel:-1});X=Oe,Oe.attachMedia(u),Oe.on(Ce.Events.MEDIA_ATTACHED,()=>Oe.loadSource(t)),Oe.on(Ce.Events.SUBTITLE_TRACK_SWITCH,()=>fe([])),Oe.on(Ce.Events.CUES_PARSED,(Et,et)=>{et.type!=="subtitles"||!Array.isArray(et.cues)||fe(Ut=>{const vt=[...Ut];for(const Rt of et.cues)vt.some(lt=>lt.startTime===Rt.startTime&<.endTime===Rt.endTime&<.text===Rt.text)||vt.push(Rt);return vt.sort((Rt,lt)=>Rt.startTime-lt.startTime)})}),Oe.on(Ce.Events.MANIFEST_PARSED,()=>{try{Oe.currentLevel=-1}catch(Et){}if(re(null),!_.current&&a>0&&u.currentTime<1){_.current=!0;try{u.currentTime=a}catch(Et){}}o&&u.play().catch(()=>{})}),Oe.on(Ce.Events.ERROR,(Et,et)=>{var Ut,vt;if(et!=null&&et.fatal){if((vt=h.current)==null||vt.onError(`hls_${et.type}_${(Ut=et.details)!=null?Ut:""}`),et.type==="networkError"){Oe.startLoad();return}if(et.type==="mediaError"){Oe.recoverMediaError();return}re("Não foi possÃvel iniciar este vÃdeo. Tente novamente em instantes.")}}),ge(Oe)}),()=>{A=!0,fe([]),ge(null),X==null||X.destroy()}},[Ne,t,u,o]);const Z=xm(t,!0),me=bm(be,t,u),Me=n.useMemo(()=>{var X;if(me.legendaAtual<0)return"";if(Ne)return le.filter(he=>q>=he.startTime&&q<=he.endTime).map(he=>Xa(he.text)).filter(Boolean).join(` 280`);if(!u)return"";const A=Array.from(u.textTracks).filter(he=>he.kind==="subtitles"||he.kind==="captions").find(he=>he.mode!=="disabled");return Array.from((X=A==null?void 0:A.activeCues)!=null?X:[]).map(he=>{var Ce;return Xa((Ce=he.text)!=null?Ce:"")}).filter(Boolean).join(` 281`)},[q,le,me.legendaAtual,Ne,u]),[te,we]=n.useState(!1);n.useEffect(()=>{we(!1)},[t]),n.useEffect(()=>{if(me.legendaAtual<0||te||Me)return;const A=window.setTimeout(()=>we(!0),2500);return()=>window.clearTimeout(A)},[me.legendaAtual,Me,te]);const Pe=km(t,me.legendaAtual,me.legendaAtual>=0&&(!Ne||te),q),oe=Me||Pe.textoAtual;n.useEffect(()=>{if(!u)return;const A=u.textTracks,X=()=>{for(let Ce=0;Ce<A.length;Ce++)A[Ce].mode==="showing"&&(A[Ce].mode="hidden")},he=window.setInterval(X,500);return A.addEventListener("addtrack",X),A.addEventListener("change",X),X(),()=>{window.clearInterval(he),A.removeEventListener("addtrack",X),A.removeEventListener("change",X)}},[u]),n.useEffect(()=>{d.current&&(d.current.playbackRate=ve)},[ve,t]),n.useEffect(()=>{const A=window.setInterval(()=>{const X=d.current;if(X)try{const he=X.buffered;he.length&&ke(he.end(he.length-1))}catch(he){}},500);return()=>window.clearInterval(A)},[]),n.useEffect(()=>{const A=()=>{var he;const X=!!document.fullscreenElement;G(X),(he=h.current)==null||he.onFullscreen(X)};return document.addEventListener("fullscreenchange",A),document.addEventListener("webkitfullscreenchange",A),()=>{document.removeEventListener("fullscreenchange",A),document.removeEventListener("webkitfullscreenchange",A)}},[]);const O=n.useCallback(()=>{var X,he,Ce,Oe;const A=b.current;A&&(document.fullscreenElement?(((Ce=document.exitFullscreen)==null?void 0:Ce.bind(document))||((Oe=document.webkitExitFullscreen)==null?void 0:Oe.bind(document))||(()=>{}))():(((X=A.requestFullscreen)==null?void 0:X.bind(A))||((he=A.webkitRequestFullscreen)==null?void 0:he.bind(A))||(()=>{}))())},[]),H=n.useCallback(()=>{Y(!0),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{d.current&&!d.current.paused&&Y(!1)},3500)},[]);n.useEffect(()=>(H(),()=>{v.current&&clearTimeout(v.current)}),[H]);const ce=n.useCallback(()=>{const A=d.current;A&&(A.paused?A.play().catch(()=>{}):A.pause())},[]),V=n.useCallback(A=>{const X=d.current;X&&(X.currentTime=Math.min(Math.max(0,X.currentTime+A),X.duration||1/0))},[]),C=n.useCallback(()=>{const A=d.current;A&&(A.muted=!A.muted,j(A.muted))},[]);n.useEffect(()=>{const A=X=>{var Oe;const he=X.target;if(!(he&&(he.isContentEditable||/input|textarea|select/i.test(he.tagName))||!((Oe=b.current)!=null&&Oe.contains(he)||document.fullscreenElement===b.current))){switch(X.key){case" ":case"Enter":X.preventDefault(),ce();break;case"ArrowRight":X.preventDefault(),V(10);break;case"ArrowLeft":X.preventDefault(),V(-10);break;case"m":X.preventDefault(),C();break;case"f":X.preventDefault(),O();break;default:return}H()}};return window.addEventListener("keydown",A,!0),()=>window.removeEventListener("keydown",A,!0)},[ce,V,C,O,H]);const h=n.useRef(x);n.useEffect(()=>{h.current=x},[x]);const T=n.useRef(0),I=n.useRef(!1),K=n.useCallback(A=>{var X,he,Ce,Oe;if(y.current>0&&k.current>0&&((X=E.current)==null||X.call(E,Math.floor(y.current),Math.floor(k.current)),(he=h.current)==null||he.savePosition(y.current,k.current)),A!=="pause"){if(A==="hidden"){(Ce=h.current)==null||Ce.flushPartial("hidden");return}I.current||(I.current=!0,(Oe=h.current)==null||Oe.finish(A))}},[]),ie=()=>{var X;const A=d.current;if(A&&(J(A.duration||0),k.current=A.duration||0,!_.current&&(_.current=!0,a>0&&a<(A.duration||1/0)-5))){try{A.currentTime=a}catch(he){}(X=h.current)==null||X.setStartPosition(a)}},Ae=()=>{var X;const A=d.current;A&&(ne(A.currentTime),J(A.duration||0),y.current=A.currentTime,k.current=A.duration||0,(X=h.current)==null||X.tick(A.currentTime,A.duration||0),l==null||l(A.currentTime,A.duration||0),!w.current&&A.currentTime>=10&&(w.current=!0,f==null||f()))},Te=()=>{var X;const A=d.current;R(!1),A&&((X=h.current)==null||X.onEnded(A.currentTime),i==null||i(Math.floor(A.currentTime),Math.floor(A.duration||0))),p==null||p()};n.useEffect(()=>{const A=()=>{document.visibilityState==="hidden"&&K("hidden")},X=()=>K("pagehide");return document.addEventListener("visibilitychange",A),window.addEventListener("pagehide",X),window.addEventListener("beforeunload",X),window.addEventListener("freeze",X),()=>{document.removeEventListener("visibilitychange",A),window.removeEventListener("pagehide",X),window.removeEventListener("beforeunload",X),window.removeEventListener("freeze",X)}},[K]),n.useEffect(()=>(I.current=!1,()=>{K("unmount")}),[t,K]);const Ve=s==="vertical",Ge=kc(),Le=Z;return e.jsxs("div",{ref:b,className:`dp-player${Ge?" dp-player-native":""} relative w-full mx-auto rounded-xl overflow-hidden select-none`,style:{aspectRatio:F?void 0:Ve?"9/16":"16/9",width:"100%",height:F?"100%":void 0,maxWidth:Ve&&!F?"min(100%, 360
281px)":"100%",background:"#000"},tabIndex:0,onMouseMove:H,onTouchStart:H,onClick:A=>{A.target.closest(".dp-ctrl")||(ce(),H())},children:[e.jsx("video",L({ref:A=>{d.current=A,m(A)},title:r,playsInline:!0,preload:"metadata",autoPlay:o,className:"w-full h-full object-contain dp-video",onTimeUpdate:Ae,onLoadedMetadata:ie,onPlay:()=>{var A,X,he;R(!0),(he=h.current)==null||he.onPlay((X=(A=d.current)==null?void 0:A.currentTime)!=null?X:0)},onPause:()=>{var X;R(!1);const A=d.current;A&&!A.ended&&((X=h.current)==null||X.onPause(A.currentTime),K("pause"))},onSeeking:()=>{T.current=y.current},onSeeked:()=>{var X;const A=d.current;A&&Math.abs(A.currentTime-T.current)>1&&((X=h.current)==null||X.onSeek(T.current,A.currentTime))},onRateChange:()=>{var X;const A=d.current;A&&((X=h.current)==null||X.onRate(A.playbackRate))},onWaiting:()=>{var A,X,he;return(he=h.current)==null?void 0:he.onBufferStart((X=(A=d.current)==null?void 0:A.currentTime)!=null?X:0)},onPlaying:()=>{var A,X,he;return(he=h.current)==null?void 0:he.onBufferEnd((X=(A=d.current)==null?void 0:A.currentTime)!=null?X:0)},onError:()=>{var X,he,Ce;const A=(he=(X=d.current)==null?void 0:X.error)==null?void 0:he.code;(Ce=h.current)==null||Ce.onError(`media_error_${A!=null?A:"unknown"}`)},onVolumeChange:()=>{const A=d.current;A&&(j(A.muted),$(A.volume))},onEnded:Te},Ne?{}:{src:t})),oe&&e.jsx("div",{className:"dp-caption-layer","aria-live":"off",children:e.jsx("span",{className:"dp-caption-text",children:oe})}),e.jsx(pm,{visivel:N,tocando:S,mudo:z,volume:M,atual:q,duracao:ae,bufferAte:je,velocidade:ve,telaCheia:F,qualidades:me.niveis.map(A=>({id:A.id,rotulo:A.rotulo})),qualidadeAtual:me.nivelAtual,qualidadeEmUso:(it=me.niveis.find(A=>A.id===me.nivelEmUso))==null?void 0:it.rotulo,audios:me.audios.map(A=>({id:A.id,rotulo:A.nome})),audioAtual:me.audioAtual,legendas:me.legendas.map(A=>({id:A.id,rotulo:A.nome})),legendaAtual:me.legendaAtual,quadroEm:Le.quadroEm,temTrickplay:Le.disponivel,onAbrirMenu:me.atualizar,onPlayPause:ce,onPular:V,onAulaAnterior:g,onProximaAula:c,onBuscar:A=>{const X=d.current;X&&(X.currentTime=A,ne(A))},onMudo:C,onVolume:A=>{const X=d.current;X&&(X.volume=A,X.muted=A===0,$(A),j(A===0))},onVelocidade:P,onQualidade:A=>{var he,Ce,Oe;me.definirNivel(A);const X=(Ce=(he=me.niveis.find(Et=>Et.id===A))==null?void 0:he.rotulo)!=null?Ce:null;(Oe=h.current)==null||Oe.onQuality(X,A<0)},onAudio:A=>{var X,he,Ce;me.definirAudio(A),(Ce=h.current)==null||Ce.onAudio((he=(X=me.audios.find(Oe=>Oe.id===A))==null?void 0:X.nome)!=null?he:null)},onLegenda:A=>{var X,he,Ce;me.definirLegenda(A),(Ce=h.current)==null||Ce.onSubtitle(A<0?null:(he=(X=me.legendas.find(Oe=>Oe.id===A))==null?void 0:X.nome)!=null?he:null)},onTelaCheia:O}),ee&&e.jsx("div",{className:"absolute inset-0 z-[26] flex items-center justify-center p-4 text-center text-xs text-white bg-black/70",children:ee})]})}const Mn=new Map,Rl="sv_tp_cover:",Sm=.12,Cm=320;function Em(t){try{const r=sessionStorage.getItem(Rl+t);return r===null?void 0:r===""?null:r}catch(r){return}}function Rm(t,r){try{sessionStorage.setItem(Rl+t,r!=null?r:"")}catch(s){}}function Mm(t){return new Promise((r,s)=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>r(a),a.onerror=()=>s(new Error("sprite")),a.src=t})}function Am(t){return Q(this,null,function*(){const r=yield fetch(t);if(!r.ok)return null;const s=El(yield r.text(),t);if(!s)return null;const a=yield fetch(s);if(!a.ok)return null;const o=Cl(yield a.text(),s);if(!o.length)return null;const i=o[Math.min(o.length-1,Math.floor(o.length*Sm))],l=yield Mm(i.img),f=Math.min(1,Cm/i.w),p=document.createElement("canvas");p.width=Math.round(i.w*f),p.height=Math.round(i.h*f);const g=p.getContext("2d");return g?(g.drawImage(l,i.x,i.y,i.w,i.h,0,0,p.width,p.height),p.toDataURL("image/jpeg",.72)):null})}function Pm(t){if(!t||!/\.m3u8(\?|$)/i.test(t))return Promise.resolve(null);const r=Mn.get(t);if(r)return r;const s=Em(t);if(s!==void 0){const o=Promise.resolve(s);return Mn.set(t,o),o}const a=Am(t).catch(()=>null).then(o=>(Rm(t,o),o));return Mn.set(t,a),a}function Ml(t,r){var o;const[s,a]=n.useState(null);return n.useEffect(()=>{let i=!0;if(a(null),!!t)return Pm(t).then(l=>{i&&l&&a(l)}),()=>{i=!1}},[t]),(o=s!=null?s:r)!=null?o:null}const Tm="https://rnxhicoiinwcninuxxej.supabase.co",Za="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJueGhpY29paW53Y25pbnV4eGVqIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQzODQ3MjAsImV4cCI6MjA4OTk2MDcyMH0.Sxn4K7nhXHpKTRTW4llQVBnApUwqO5IFOz63C_RsYsw",Bs=()=>typeof performance!="undefined"?performance.now():Date.now();function Dm(){if(typeof navigator=="undefined")return"unknown";const t=navigator.userAgent;return/iPad|Tablet/i.test(t)?"tablet":/iPhone|Android.+Mobile|Mobile/i.test(t)?"mobile":"desktop"}function zm(){var r;const t=navigator.connection;return(r=t==null?void 0:t.effectiveType)!=null?r:null}function Ja(t){const r=[...t].filter(a=>a.end-a.start>.4).sort((a,o)=>a.start-o.start),s=[];for(const a of r){const o=s[s.length-1];o&&a.start<=o.end+1?o.end=Math.max(o.end,a.end):s.push(L({},a))}return s}function rr(t,r,s,a,o){try{return fetch(`${Tm}/rest/v1/${t}`,{method:s,keepalive:!0,headers:{"Content-Type":"application/json",apikey:Za,Authorization:`Bearer ${a||Za}`,Prefer:o!=null?o:"return=minimal"},body:JSON.stringify(r)}).catch(()=>{})}catch(i){return}}class Im{constructor(r){Fe(this,"sessionId",crypto.randomUUID());Fe(this,"ctx");Fe(this,"token");Fe(this,"startedAt",new Date().toISOString());Fe(this,"createdRow",!1);Fe(this,"finished",!1);Fe(this,"duration",0);Fe(this,"startPosition",0);Fe(this,"lastTick",0);Fe(this,"lastTickAt",0);Fe(this,"exitPosition",0);Fe(this,"maxPosition",0);Fe(this,"watchedSeconds",0);Fe(this,"ranges",[]);Fe(this,"openRange",null);Fe(this,"playCount",0);Fe(this,"pauseCount",0);Fe(this,"seekCount",0);Fe(this,"seekForward",0);Fe(this,"seekBackward",0);Fe(this,"replayCount",0);Fe(this,"rateChanges",0);Fe(this,"maxRate",1);Fe(this,"fullscreenCount",0);Fe(this,"bufferingCount",0);Fe(this,"bufferingSeconds",0);Fe(this,"bufferingStartedAt",null);Fe(this,"mountedAt",Bs());Fe(this,"startupMs",null);Fe(this,"qualityChanges",0);Fe(this,"qualityLast",null);Fe(this,"qualityAuto",null);Fe(this,"subtitleLang",null);Fe(this,"audioLang",null);Fe(this,"errorCount",0);Fe(this,"lastError",null);Fe(this,"events",[]);var s;this.ctx=r,this.token=(s=r.accessToken)!=null?s:null,this.startPosition=0}setToken(r){this.token=r}savePosition(r,s){var i;
281if(!this.ctx.userId||!(r>0))return;const a=Math.floor(r),o=`course_progress?user_id=eq.${this.ctx.userId}&lesson_id=eq.${this.ctx.lessonId}`;rr(o,{last_position_seconds:a,updated_at:new Date().toISOString()},"PATCH",this.token),rr("course_progress?on_conflict=user_id,lesson_id",{user_id:this.ctx.userId,lesson_id:this.ctx.lessonId,module_id:(i=this.ctx.moduleId)!=null?i:null,last_position_seconds:a,updated_at:new Date().toISOString()},"POST",this.token,"resolution=ignore-duplicates,return=minimal")}ensureRow(){var r,s;this.createdRow||!this.ctx.userId||(this.createdRow=!0,rr("lesson_watch_sessions",{session_id:this.sessionId,user_id:this.ctx.userId,lesson_id:this.ctx.lessonId,module_id:(r=this.ctx.moduleId)!=null?r:null,source:(s=this.ctx.source)!=null?s:"directplay",started_at:this.startedAt,start_position_seconds:this.startPosition,device:Dm(),user_agent:typeof navigator!="undefined"?navigator.userAgent.slice(0,500):null,viewport:typeof window!="undefined"?`${window.innerWidth}x${window.innerHeight}`:null,connection:zm()},"POST",this.token))}event(r,s,a){var o;this.events.push({session_id:this.sessionId,user_id:this.ctx.userId,lesson_id:this.ctx.lessonId,module_id:(o=this.ctx.moduleId)!=null?o:null,event_type:r,position_seconds:s!=null?Number(s.toFixed(2)):null,data:a!=null?a:{},created_at:new Date().toISOString()}),this.events.length>=40&&this.flushEvents()}flushEvents(){if(!this.events.length||!this.ctx.userId)return;const r=this.events;this.events=[],rr("lesson_player_events",r,"POST",this.token)}setStartPosition(r){this.startPosition=r||0,this.lastTick=this.startPosition,this.exitPosition=this.startPosition,this.maxPosition=this.startPosition}onPlay(r){this.ensureRow(),this.playCount+=1,this.startupMs==null&&(this.startupMs=Math.round(Bs()-this.mountedAt)),this.openRange={start:r,end:r},this.lastTick=r,this.lastTickAt=Bs(),this.event("play",r)}onPause(r){this.pauseCount+=1,this.closeRange(r),this.event("pause",r)}onSeek(r,s){this.seekCount+=1;const a=s-r;a>=0?this.seekForward+=a:this.seekBackward+=-a,s<1&&r>5&&(this.replayCount+=1),this.closeRange(r),this.openRange={start:s,end:s},this.lastTick=s,this.event("seek",s,{from:Number(r.toFixed(2)),delta:Number(a.toFixed(2))})}onRate(r){this.rateChanges+=1,this.maxRate=Math.max(this.maxRate,r),this.event("rate_change",this.exitPosition,{rate:r})}onQuality(r,s){this.qualityChanges+=1,this.qualityLast=r,this.qualityAuto=s,this.event("quality_change",this.exitPosition,{quality:r,auto:s})}onBufferStart(r){this.bufferingStartedAt==null&&(this.bufferingStartedAt=Bs(),this.bufferingCount+=1,this.event("buffer_start",r))}onBufferEnd(r){if(this.bufferingStartedAt==null)return;const s=(Bs()-this.bufferingStartedAt)/1e3;this.bufferingStartedAt=null,s>.15&&(this.bufferingSeconds+=s),this.event("buffer_end",r,{seconds:Number(s.toFixed(2))})}onFullscreen(r){r&&(this.fullscreenCount+=1),this.event("fullscreen",this.exitPosition,{on:r})}onSubtitle(r){this.subtitleLang=r,this.event("subtitle",this.exitPosition,{lang:r})}onAudio(r){this.audioLang=r,this.event("audio_track",this.exitPosition,{lang:r})}onError(r){this.errorCount+=1,this.lastError=r.slice(0,300),this.ensureRow(),this.event("error",this.exitPosition,{message:this.lastError})}onEnded(r){this.closeRange(r),this.event("ended",r)}tick(r,s){s>0&&(this.duration=s),this.ensureRow();const a=Math.abs(r-this.lastTick);a>0&&a<=2?(this.watchedSeconds+=a,this.openRange?this.openRange.end=Math.max(this.openRange.end,r):this.openRange={start:this.lastTick,end:r}):a>2&&(this.closeRange(this.lastTick),this.openRange={start:r,end:r}),this.lastTick=r,this.lastTickAt=Bs(),this.exitPosition=r,r>this.maxPosition&&(this.maxPosition=r)}closeRange(r){if(!this.openRange)return;const s=r!=null?r:this.openRange.end;s>this.openRange.start&&this.ranges.push({start:this.openRange.start,end:s}),this.openRange=null}flushPartial(r="hidden"){if(this.finished||!this.ctx.userId)return;const s=this.openRange?L({},this.openRange):null,a=[...this.ranges];this.finish(r),this.finished=!1,this.ranges=a,this.openRange=s}finish(r){if(this.finished||!this.ctx.userId)return;this.finished=!0,this.closeRange(),this.bufferingStartedAt!=null&&this.onBufferEnd(this.exitPosition),this.ensureRow();const s=Ja(this.ranges),a=s.reduce((l,f)=>l+(f.end-f.start),0),o=this.duration>0?Math.min(100,Math.round(a/this.duration*100)):0,i={ended_at:new Date().toISOString(),end_reason:r,duration_seconds:Number(this.duration.toFixed(2)),start_position_seconds:Number(this.startPosition.toFixed(2)),exit_position_seconds:Number(this.exitPosition.toFixed(2)),max_position_seconds:Number(this.maxPosition.toFixed(2)),watched_seconds:Number(this.watchedSeconds.toFixed(2)),unique_watched_seconds:Number(a.toFixed(2)),percent_watched:o,completed:o>=90||r==="ended",watched_ranges:s.map(l=>[Number(l.start.toFixed(2)),Number(l.end.toFixed(2))]),play_count:this.playCount,pause_count:this.pauseCount,seek_count:this.seekCount,seek_forward_seconds:Number(this.seekForward.toFixed(2)),seek_backward_seconds:Number(this.seekBackward.toFixed(2)),replay_count:this.replayCount,buffering_count:this.bufferingCount,buffering_seconds:Number(this.bufferingSeconds.toFixed(2)),startup_ms:this.startupMs,quality_changes:this.qual
281ityChanges,quality_last:this.qualityLast,quality_auto:this.qualityAuto,rate_changes:this.rateChanges,max_playback_rate:this.maxRate,fullscreen_count:this.fullscreenCount,subtitle_lang:this.subtitleLang,audio_lang:this.audioLang,error_count:this.errorCount,last_error:this.lastError};rr(`lesson_watch_sessions?session_id=eq.${this.sessionId}`,i,"PATCH",this.token),this.event("session_end",this.exitPosition,{reason:r}),this.flushEvents()}snapshot(){const s=Ja([...this.ranges,...this.openRange?[this.openRange]:[]]).reduce((a,o)=>a+(o.end-o.start),0);return{position_seconds:Math.floor(this.exitPosition),duration_seconds:Math.floor(this.duration),percent_watched:this.duration>0?Math.min(100,Math.round(s/this.duration*100)):0,watched_seconds:this.watchedSeconds}}}const Wt=Se,Lm=[{id:"fb-1",title:"Cursos Rápidos",vertical_covers:!0,modules:[{id:"cr1",title:"Atuação para Câmera",subtitle:"Fundamentos",cover_url:null,cover_color:"linear-gradient(135deg, #e53e3e, #c53030)",cover_emoji:"ð¬",locked:!0},{id:"cr2",title:"Preparação Vocal",subtitle:"Técnicas essenciais",cover_url:null,cover_color:"linear-gradient(135deg, #dd6b20, #c05621)",cover_emoji:"ðï¸",locked:!0},{id:"cr3",title:"Expressão Corporal",subtitle:"Movimento cênico",cover_url:null,cover_color:"linear-gradient(135deg, #805ad5, #6b46c1)",cover_emoji:"ð",locked:!0},{id:"cr4",title:"Improvisação",subtitle:"Criação espontânea",cover_url:null,cover_color:"linear-gradient(135deg, #2b6cb0, #2c5282)",cover_emoji:"â¡",locked:!0},{id:"cr5",title:"Direção de Cena",subtitle:"Visão do diretor",cover_url:null,cover_color:"linear-gradient(135deg, #38a169, #2f855a)",cover_emoji:"ð¥",locked:!0}]},{id:"fb-2",title:"Formação em TV e Cinema 0ao7 Plus",vertical_covers:!1,modules:[{id:"f1",title:"Módulo 1",subtitle:"Introdução ao Audiovisual",cover_url:null,cover_color:"linear-gradient(135deg, #1a1a2e, #16213e)",cover_emoji:"ðº",locked:!0},{id:"f2",title:"Módulo 2",subtitle:"Linguagem Cinematográfica",cover_url:null,cover_color:"linear-gradient(135deg, #1a1a2e, #0f3460)",cover_emoji:"ðï¸",locked:!0},{id:"f3",title:"Módulo 3",subtitle:"Construção de Personagem",cover_url:null,cover_color:"linear-gradient(135deg, #1a1a2e, #533483)",cover_emoji:"ð§âð¨",locked:!0},{id:"f4",title:"Módulo 4",subtitle:"Técnica de Set",cover_url:null,cover_color:"linear-gradient(135deg, #1a1a2e, #e94560)",cover_emoji:"ð¬",locked:!0}]},{id:"fb-3",title:"Mentoria em TV e Cinema 0ao7 Pro",vertical_covers:!1,modules:[{id:"m1",title:"Sessão 1",subtitle:"Análise de Perfil",cover_url:null,cover_color:"linear-gradient(135deg, #0d0d0d, #434343)",cover_emoji:"ð¯",locked:!0},{id:"m2",title:"Sessão 2",subtitle:"Plano de Carreira",cover_url:null,cover_color:"linear-gradient(135deg, #0d0d0d, #6b21a8)",cover_emoji:"ð",locked:!0},{id:"m3",title:"Sessão 3",subtitle:"Portfólio & Demo Reel",cover_url:null,cover_color:"linear-gradient(135deg, #0d0d0d, #b91c1c)",cover_emoji:"ð¼",locked:!0}]}];function Al(t){var s;const r=t.match(/(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|shorts\/))([^?&/#]+)/);return(s=r==null?void 0:r[1])!=null?s:null}function Fm(t){return`https://i.ytimg.com/vi/${t}/maxresdefault.jpg`}function An(t){const r=Math.floor(t/60),s=Math.floor(t%60);return`${r}:${String(s).padStart(2,"0")}`}let Pn=!1,zr=null;function Om(){return Pn?Promise.resolve():zr||(zr=new Promise(t=>{var s;if((s=window.YT)!=null&&s.Player){Pn=!0,t();return}const r=document.createElement("script");r.src="https://www.youtube.com/iframe_api",document.head.appendChild(r),window.onYouTubeIframeAPIReady=()=>{Pn=!0,t()}}),zr)}function $m({ytId:t,title:r,initialPosition:s,orientation:a,onProgress:o,onComplete:i,onEnded:l,onTick:f,onPrev:p,onNext:g,autoPlay:c=!1}){const x=a==="vertical",d=x?{aspectRatio:"9 / 16",height:"min(72vh, 620px)",width:"auto",maxWidth:"100%"}:{paddingBottom:"56.25%"},u=n.useRef(null),m=n.useRef(null),b=n.useRef(null),v=n.useRef(!1),w=n.useRef(-999),_=n.useRef(c),y=n.useRef(o),k=n.useRef(i),E=n.useRef(l),S=n.useRef(f);n.useEffect(()=>{y.current=o},[o]),n.useEffect(()=>{k.current=i},[i]),n.useEffect(()=>{E.current=l},[l]),n.useEffect(()=>{S.current=f},[f]);const[R,z]=n.useState(!1),[j,M]=n.useState(!1),[$,q]=n.useState(0),[ne,ae]=n.useState(0),[J,je]=n.useState(!c),[ke,ve]=n.useState(!0),[P,N]=n.useState(!1),[Y,F]=n.useState(!1),[G,ee]=n.useState(!1),[re,be]=n.useState(1),[ge,le]=n.useState(!1),fe=n.useRef(null),pe=n.useRef(null);n.useEffect(()=>{let V=!1;return v.current=!1,Q(this,null,function*(){if(yield Om(),V||!u.current)return;
281const h=`yt-player-${t}`,T=document.createElement("div");T.id=h,T.style.width="100%",T.style.height="100%",u.current.innerHTML="",u.current.appendChild(T),m.current=new window.YT.Player(h,{videoId:t,playerVars:{autoplay:c?1:0,mute:c?0:1,controls:0,modestbranding:1,rel:0,showinfo:0,iv_load_policy:3,fs:0,playsinline:1,disablekb:1,cc_load_policy:0,enablejsapi:1,origin:window.location.origin},events:{onReady:I=>{if(!V){if(ae(I.target.getDuration()),z(!0),s>1){try{I.target.seekTo(s,!0)}catch(K){}q(s)}if(c)try{I.target.playVideo()}catch(K){}else{try{I.target.pauseVideo()}catch(K){}try{I.target.mute()}catch(K){}}}},onStateChange:I=>{var ie,Ae,Te,Ve,Ge,Le,it,A,X;if(V)return;const K=I.data;if(K===1&&!_.current){try{I.target.pauseVideo()}catch(he){}M(!1);return}if(M(K===1),K===1){F(!0),ae(I.target.getDuration());try{(Ae=(ie=I.target).isMuted)!=null&&Ae.call(ie)&&(I.target.unMute(),je(!1))}catch(he){}ee(!0),N(!1)}if(K===2)try{const he=(Ge=(Ve=(Te=I.target).getCurrentTime)==null?void 0:Ve.call(Te))!=null?Ge:0;w.current=he,y.current(Math.floor(he),Math.floor((A=(it=(Le=I.target).getDuration)==null?void 0:it.call(Le))!=null?A:0))}catch(he){}K===0&&(v.current||(v.current=!0,k.current()),(X=E.current)==null||X.call(E))}}})}),()=>{var h,T,I,K,ie,Ae,Te,Ve,Ge;V=!0,b.current&&clearInterval(b.current);try{const Le=m.current,it=(T=(h=Le==null?void 0:Le.getCurrentTime)==null?void 0:h.call(Le))!=null?T:0,A=(K=(I=Le==null?void 0:Le.getDuration)==null?void 0:I.call(Le))!=null?K:0;A>0&&it>0&&y.current(Math.floor(it),Math.floor(A))}catch(Le){}try{(Ae=(ie=m.current)==null?void 0:ie.mute)==null||Ae.call(ie)}catch(Le){}try{(Ve=(Te=m.current)==null?void 0:Te.stopVideo)==null||Ve.call(Te)}catch(Le){}try{(Ge=m.current)==null||Ge.destroy()}catch(Le){}m.current=null}},[t]),n.useEffect(()=>{if(R)return b.current=window.setInterval(()=>{var C,h,T,I,K;const V=m.current;if(V)try{const ie=(h=(C=V.getCurrentTime)==null?void 0:C.call(V))!=null?h:0,Ae=(I=(T=V.getDuration)==null?void 0:T.call(V))!=null?I:0;q(ie),(K=S.current)==null||K.call(S,ie,Ae),Ae>0&&(Math.abs(ie-w.current)>=5&&(w.current=ie,y.current(Math.floor(ie),Math.floor(Ae))),!v.current&&ie>=10&&(v.current=!0,k.current()))}catch(ie){}},500),()=>{b.current&&clearInterval(b.current)}},[R]),n.useEffect(()=>{if(!Y){ee(!1);return}},[Y]),n.useEffect(()=>{if(!j){ve(!0);return}return fe.current=window.setTimeout(()=>ve(!1),3e3),()=>{fe.current&&clearTimeout(fe.current)}},[j,ke]);const Ne=()=>{ve(!0),fe.current&&clearTimeout(fe.current),j&&(fe.current=window.setTimeout(()=>ve(!1),3e3))},Z=()=>{const V=m.current;if(V)try{j?V.pauseVideo():(_.current=!0,N(!0),V.playVideo())}catch(C){}},me=()=>{const V=m.current;if(V)try{J?(V.unMute(),je(!1)):(V.mute(),je(!0))}catch(C){}},Me=V=>{var h;const C=m.current;be(V),le(!1);try{(h=C==null?void 0:C.setPlaybackRate)==null||h.call(C,V)}catch(T){}},te=n.useRef(!1),we=V=>{const C=pe.current,h=m.current;if(!C||!h||!ne)return;const T=C.getBoundingClientRect(),K=Math.max(0,Math.min(1,(V-T.left)/T.width))*ne;try{h.seekTo(K,!0)}catch(ie){}q(K)},Pe=V=>{var C,h;V.stopPropagation(),V.preventDefault(),te.current=!0,(h=(C=V.currentTarget).setPointerCapture)==null||h.call(C,V.pointerId),we(V.clientX)},oe=V=>{te.current&&(V.stopPropagation(),we(V.clientX))},O=V=>{var C,h;if(te.current){te.current=!1;try{(h=(C=V.currentTarget).releasePointerCapture)==null||h.call(C,V.pointerId)}catch(T){}V.stopPropagation()}},H=()=>{var C,h;const V=(C=u.current)==null?void 0:C.parentElement;V&&(document.fullscreenElement?document.exitFullscreen():(h=V.requestFullscreen)==null||h.call(V))},ce=ne>0?$/ne*100:0;return e.jsxs("div",{className:`relative ${x?"":"w-full"} overflow-hidden rounded-xl bg-black group mx-auto`,style:d,onMouseMove:Ne,onClick:V=>{Y&&(V.target.closest("[data-controls]")||Z())},children:[e.jsx("div",{className:"absolute inset-0 overflow-hidden rounded-xl",children:x?e.jsx("div",{ref:u,className:"absolute pointer-events-none [&_iframe]:!w-full [&_iframe]:!h-full [&_iframe]:!absolute [&_iframe]:!inset-0 [&>div]:!w-full [&>div]:!h-full",style:{left:"50%",top:"50%",width:"300%",height:"300%",transform:"translate(-50%, -50%)"}}):e.jsx("div",{ref:u,className:"absolute pointer-events-none [&_iframe]:!w-full [&_iframe]:!h-full [&_iframe]:!absolute [&_iframe]:!inset-0 [&>div]:!w-full [&>
281div]:!h-full",style:{top:"-88px",left:"-24px",right:"-24px",bottom:"-88px",width:"calc(100% + 48px)",height:"calc(100% + 176px)"}})}),e.jsx("div",{className:"absolute inset-0 z-10"}),!Y&&e.jsxs("button",{type:"button",onClick:V=>{var C;if(V.stopPropagation(),!!R){_.current=!0,N(!0);try{(C=m.current)==null||C.playVideo()}catch(h){}}},className:"group absolute inset-0 w-full h-full z-20",children:[e.jsx("div",{className:"absolute inset-0 bg-black"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:R&&!P?e.jsx("div",{className:"w-12 h-12 md:w-14 md:h-14 rounded-full bg-white/15 backdrop-blur-xl border border-white/25 flex items-center justify-center shadow-[0_8px_32px_rgba(0,0,0,0.35)] group-hover:bg-white/25 group-hover:scale-105 transition-all duration-300",children:e.jsx(Es,{size:20,className:"text-white ml-0.5",fill:"currentColor"})}):e.jsx("div",{className:"w-10 h-10 border-2 border-white/40 border-t-white rounded-full animate-spin"})}),s>5&&R&&!P&&e.jsx("div",{className:"absolute bottom-3 left-3 right-3 px-3 py-1.5 rounded-md bg-black/70 backdrop-blur-sm",children:e.jsxs("span",{className:"text-xs text-white font-medium",children:["ⶠContinuar de ",An(s)]})})]}),Y&&!G&&e.jsx("div",{className:"absolute inset-0 z-20 pointer-events-none bg-black flex items-center justify-center",children:e.jsx("div",{className:"w-10 h-10 border-2 border-white/40 border-t-white rounded-full animate-spin"})}),Y&&e.jsxs("div",{"data-controls":!0,className:"absolute bottom-0 left-0 right-0 z-30 transition-opacity duration-300",style:{opacity:ke?1:0,pointerEvents:ke?"auto":"none",background:"linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.3) 60%, transparent 100%)",padding:"40px 12px 10px"},children:[e.jsx("div",{ref:pe,onPointerDown:Pe,onPointerMove:oe,onPointerUp:O,onPointerCancel:O,onClick:V=>V.stopPropagation(),className:"w-full h-3 flex items-center cursor-pointer mb-2 group/seek touch-none",children:e.jsx("div",{className:"w-full h-1 group-hover/seek:h-1.5 rounded-full transition-all",style:{background:"rgba(255,255,255,0.25)"},children:e.jsx("div",{className:"h-full rounded-full relative",style:{width:`${ce}%`,background:"var(--sv-accent, #fff)"},children:e.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 w-3 h-3 rounded-full bg-white shadow-md opacity-0 group-hover/seek:opacity-100 transition-opacity"})})})}),e.jsxs("div",{className:"flex items-center gap-3",children:[p&&e.jsx("button",{onClick:V=>{V.stopPropagation(),p()},className:"text-white hover:text-white/80 transition-colors",title:"Aula anterior",children:e.jsx(sd,{size:18,fill:"white"})}),e.jsx("button",{onClick:Z,className:"text-white hover:text-white/80 transition-colors",children:j?e.jsx(Qc,{size:20,fill:"white"}):e.jsx(Es,{size:20,fill:"white",className:"ml-0.5"})}),g&&e.jsx("button",{onClick:V=>{V.stopPropagation(),g()},className:"text-white hover:text-white/80 transition-colors",title:"Próxima aula",children:e.jsx(rd,{size:18,fill:"white"})}),e.jsx("button",{onClick:me,className:"text-white hover:text-white/80 transition-colors",children:J?e.jsx(ad,{size:18}):e.jsx(nd,{size:18})}),e.jsxs("span",{className:"text-xs text-white/80 font-mono tabular-nums select-none",children:[An($)," / ",An(ne)]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:V=>{V.stopPropagation(),le(C=>!C)},className:"text-white hover:text-white/80 transition-colors text-xs font-bold tabular-nums px-1.5 py-0.5 rounded hover:bg-white/10",title:"Velocidade",children:[re,"x"]}),ge&&e.jsx("div",{onClick:V=>V.stopPropagation(),className:"absolute bottom-full right-0 mb-2 rounded-lg overflow-hidden shadow-2xl border border-white/10 min-w-[80px]",style:{background:"rgba(0,0,0,0.92)",backdropFilter:"blur(8px)"},children:[.5,1,1.5,2].map(V=>e.jsxs("button",{onClick:()=>Me(V),className:`block w-full px-3 py-1.5 text-xs font-semibold text-left transition-colors ${V===re?"text-black bg-white":"text-white hover:bg-white/10"}`,children:[V,"x"]},V))})]}),e.jsx("button",{onClick:H,className:"text-white hover:text-white/80 transition-colors",children:e.jsx(Jc,{size:18})})]})]}),!j&&Y&&G&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:e.jsx("div",{className:"w-16 h-16 rounded-full bg-black/50 backdrop-blur-sm flex items-center justify-center",children:e.jsx(Es,{size:28,className:"text-white ml-1",fill:"white"})})})]})}function Qa({lesson:t,initialPosition:r,initialPercentWatched:s,initialCompleted:a,orientation:o,onProgress:i,onPlayerSnapshot:l,onComplete:f,onEnded:p,onTick:g,onPrev:c,onNext:x,autoPlay:d=!1,userId:u,moduleId:m}){var M,$;const b=n.useRef(null),v=n.useRef(null),w=n.useRef(!1),[_,y]=n.useState(d),k=(M=t.video_provider)!=null?M:"youtube",E=($=t.video_url)!=null?$:"",S=k==="youtube"?Al(E):null;n.useEffect(()=>{y(d),w.current=!1},[t.id,d]);const R=ln(t),z=n.useMemo(()=>!R||!u?null:new Im({userId:u,lessonId:t.id,moduleId:m!=null?m:null,source:"directplay"}),[R,u,t.id,m]);if(n.useEffect(()=>{if(!z)return;let q=!0;return Se.auth.getSession().then(({data:ne})=>{var ae,J;q&&z.setToken((J=(ae=ne.session)==null?void 0:ae.access_token)!=null?J:null)}),()=>{q=!1}},[z]),R)return e.jsx(_m,{src:t.directplay_master_url,title:t.title,orientation:o,initialPosition:r,autoPlay:d,onProgress:i,onTick:g,onComplete:f,onEnded:p,onPrev:c,onNext:x,metrics:z},`dp:${t.id}`);if(n.useEffect(()=>{if(S||!_)return;const q=b.current;if(!q)return;const ne=()=>{r>0&&r<(q.duration||1/0)-5&&(q.currentTime=r)};q.addEventListener("loadedmetadata",ne);const ae=()=>{g==null||g(q.currentTime,q.duration||0)};return q.addEventListener("timeupdate",ae),v.current=window.setInterval(()=>{!q.paused&&q.duration&&(i(Math.floor(q.currentTime),Math.floor(q.duration)),!w.current&&q.currentTime>=10&&(w.current=!0,f()))},5e3),()=>{q.removeEventListener("loadedmetadata",ne),q.removeEventListener("timeupdate",ae),v.current&&window.clearInterval(v.current),q.duration&&i(Math.floor(q.currentTime),Math.floor(q.duration))}},[_,S,r,i,f,g]),S)return e.jsx($m,{ytId:S,title:t.title,initialPosition:r,orientation:o,onProgress:i,onComplete:f,onEnded:p,onPrev:c,onNext:x,onTick:g,autoPlay:d},t.id);const j=o==="vertical";return E?e.jsx("div",{className:"mx-auto",style:{maxWidth:j?"min(100%, 360
281px)":void 0},children:e.jsx("video",{ref:b,controls:!0,autoPlay:_,onPlay:()=>y(!0),onPause:()=>{const q=b.current;q!=null&&q.duration&&i(Math.floor(q.currentTime),Math.floor(q.duration))},onEnded:()=>{w.current||(w.current=!0,f()),p==null||p()},className:"w-full rounded-xl bg-black",style:{aspectRatio:j?"9/16":"16/9",objectFit:"contain"},src:E})}):e.jsx("div",{className:"w-full rounded-xl flex items-center justify-center mx-auto",style:{aspectRatio:j?"9/16":"16/9",maxWidth:j?"min(100%, 360px)":void 0,background:"var(--sv-bg-secondary, rgba(255,255,255,0.05))"},children:e.jsx("p",{className:"text-sm",style:{color:"var(--sv-text-muted)"},children:"VÃdeo em breve"})})}function Bm({lesson:t,index:r,thumb:s,isActive:a,isCompleted:o,hasProgress:i,onClick:l}){const f=a?"play":o?"done":i?"prog":"",p=Ml(ln(t)?t.directplay_master_url:null,s);return e.jsxs("button",{onClick:l,className:`svl-item${a?" on":""}`,children:[e.jsx("span",{className:`svl-dot ${f}`,children:a?e.jsx(Es,{size:11,fill:"currentColor",className:"ml-0.5"}):o?e.jsx(ia,{size:13,strokeWidth:3}):null}),e.jsx("span",{className:"svl-thumb",children:p?e.jsx("img",{src:p,alt:"",loading:"lazy"}):String(r+1).padStart(2,"0")}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"svl-title",children:t.title}),i&&!o&&!a&&e.jsx("span",{className:"svl-tag",children:"Em progresso"})]}),t.duration_minutes?e.jsxs("span",{className:"svl-dur",children:[t.duration_minutes,"min"]}):null]})}function qm({lesson:t,lessonNumber:r,completed:s,fallback:a,onClick:o}){const i=Ml(ln(t)?t.directplay_master_url:null,a);return e.jsxs("button",{onClick:o,className:"snap-start shrink-0 w-44 text-left rounded-xl overflow-hidden transition-transform active:scale-[0.97]",style:{background:"var(--sv-bg-secondary, rgba(255,255,255,0.05))"},children:[e.jsxs("div",{className:"relative w-full aspect-video bg-black",children:[i?e.jsx("img",{src:i,alt:"",className:"w-full h-full object-cover",loading:"lazy"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Es,{size:24,className:"text-white/40"})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/60 to-transparent"}),e.jsxs("div",{className:"absolute bottom-1.5 left-1.5 px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-black/60",children:["Aula ",r]}),s&&e.jsx("div",{className:"absolute top-1.5 right-1.5",children:e.jsx(Hr,{size:16,className:"text-white drop-shadow"})})]}),e.jsxs("div",{className:"p-2.5",children:[e.jsx("p",{className:"text-xs font-semibold line-clamp-2",style:{color:"var(--sv-text-primary)"},children:t.title}),t.duration_minutes!=null&&e.jsxs("p",{className:"text-[10px] mt-1 flex items-center gap-1",style:{color:"var(--sv-text-muted)"},children:[e.jsx(ea,{size:10}),t.duration_minutes," min"]})]})]})}function Wm({mod:t,parentSection:r,nextModule:s,onBack:a,onAdvanceModule:o}){var Is,Xs,Nr,Tt,Zs,Js,Ls,es,Fs,ws;const i=!!(r!=null&&r.single_course),[l,f]=n.useState([]),[p,g]=n.useState(!0),[c,x]=n.useState(null),[d,u]=n.useState({}),[m,b]=n.useState(null),[v,w]=n.useState(typeof window!="undefined"&&window.innerWidth>=1024),[_,y]=n.useState(!0),[k,E]=n.useState(new Set),S=bs(),R=yo(),z=R.pathname.split("/").filter(Boolean),j=(Is=z[2])!=null?Is:null,M=(Xs=z[3])!=null?Xs:null,$=(Nr=z[4])!=null?Nr:null,q=new URLSearchParams(R.search).get("aula"),ne=j||(r==null?void 0:r.slug)||(r==null?void 0:r.id)||"_",ae=M||t.slug||t.id,J=$||q,je=n.useRef(null),ke=(c==null?void 0:c.video_orientation)==="vertical"?"vertical":"horizontal";n.useEffect(()=>{const U=()=>w(window.innerWidth>=1024);return window.addEventListener("resize",U),()=>window.removeEventListener("resize",U)},[]),n.useEffect(()=>{c!=null&&c.module_id&&E(U=>U.size===1&&U.has(c.module_id)?U:new Set([c.module_id]))},[c==null?void 0:c.module_id]),n.useEffect(()=>{Q(this,null,function*(){var U,de,_e,$e,De,He,rt;try{const{data:ot}=yield Se.auth.getUser(),mt=(de=(U=ot.user)==null?void 0:U.id)!=null?de:null;b(mt);const Ot=i&&r?r.modules.map(tt=>tt.id):[t.id],{data:Dt}=yield Wt.from("course_lessons").select("*").in("module_id",Ot).eq("visible",!0).order("sort_order");let nt=Dt!=null?Dt:[];
281if(i&&r){const tt=new Map(r.modules.map((bt,wt)=>[bt.id,wt]));nt=[...nt].sort((bt,wt)=>{var At,Zt,kr,Qs;const zt=(At=tt.get(bt.module_id))!=null?At:999,ts=(Zt=tt.get(wt.module_id))!=null?Zt:999;return zt!==ts?zt-ts:((kr=bt.sort_order)!=null?kr:0)-((Qs=wt.sort_order)!=null?Qs:0)})}f(nt);let Mt={};if(mt&&nt.length>0)try{let tt=Wt.from("course_progress").select("lesson_id, completed, last_position_seconds, percent_watched, updated_at").eq("user_id",mt);i?tt=tt.in("module_id",Ot):tt=tt.eq("module_id",t.id);const{data:bt}=yield tt;(bt!=null?bt:[]).forEach(wt=>{Mt[wt.lesson_id]=wt}),u(Mt)}catch(tt){}if(nt.length>0){let tt=null;if(J&&(tt=(_e=nt.find(bt=>bt.slug===J))!=null?_e:null,!tt&&Xr(J)&&(tt=($e=nt.find(bt=>bt.id===J))!=null?$e:null)),!tt){const wt=(De=Object.values(Mt).filter(zt=>zt.updated_at&&nt.some(ts=>ts.id===zt.lesson_id)).sort((zt,ts)=>{var At,Zt;return((At=ts.updated_at)!=null?At:"").localeCompare((Zt=zt.updated_at)!=null?Zt:"")})[0])==null?void 0:De.lesson_id;tt=(rt=(He=wt?nt.find(zt=>zt.id===wt):null)!=null?He:nt[0])!=null?rt:null}tt&&(x(tt),v||y(!1))}}catch(ot){}g(!1)})},[t.id,i,r==null?void 0:r.id]);const ve=n.useCallback((U,de,_e)=>Q(this,null,function*(){var ot;if(!m)return;let $e=_e;$e===!0&&P.current.has(U)&&($e=void 0);const De=l.find(mt=>mt.id===U),He=(ot=De==null?void 0:De.module_id)!=null?ot:t.id,rt=se(L({user_id:m,lesson_id:U,module_id:He,last_position_seconds:de},$e!==void 0?{completed:$e}:{}),{updated_at:new Date().toISOString()});try{yield Wt.from("course_progress").upsert(rt,{onConflict:"user_id,lesson_id"}),u(mt=>{var Ot,Dt,nt,Mt;return se(L({},mt),{[U]:{lesson_id:U,completed:(Dt=$e!=null?$e:(Ot=mt[U])==null?void 0:Ot.completed)!=null?Dt:!1,last_position_seconds:de,percent_watched:(Mt=(nt=mt[U])==null?void 0:nt.percent_watched)!=null?Mt:0,updated_at:rt.updated_at}})})}catch(mt){}}),[m,t.id,l]),P=n.useRef(new Set),[N,Y]=n.useState(0),F=n.useCallback(U=>Q(this,null,function*(){var De;if(!m)return;const de=l.find(He=>He.id===U),_e=(De=de==null?void 0:de.module_id)!=null?De:t.id,$e={user_id:m,lesson_id:U,module_id:_e,last_position_seconds:0,completed:!1,updated_at:new Date().toISOString()};try{P.current.add(U),yield Wt.from("course_progress").upsert($e,{onConflict:"user_id,lesson_id"}),u(He=>se(L({},He),{[U]:{lesson_id:U,completed:!1,last_position_seconds:0,percent_watched:0,updated_at:$e.updated_at}})),ge(0),Y(He=>He+1)}catch(He){}}),[m,t.id,l]),G=n.useCallback((U,de)=>Q(this,null,function*(){var Dt,nt;if(!m)return;const _e=l.find(Mt=>Mt.id===U),$e=(Dt=_e==null?void 0:_e.module_id)!=null?Dt:t.id,De=d[U],He=Math.max((nt=De==null?void 0:De.percent_watched)!=null?nt:0,de.percent_watched),rt=!!(De!=null&&De.completed),mt=P.current.has(U)?!1:rt||de.ended||He>=90||de.position_seconds>=10,Ot={user_id:m,lesson_id:U,module_id:$e,last_position_seconds:de.position_seconds,percent_watched:He,completed:mt,updated_at:new Date().toISOString()};try{yield Wt.from("course_progress").upsert(Ot,{onConflict:"user_id,lesson_id"}),u(Mt=>se(L({},Mt),{[U]:{lesson_id:U,completed:mt,last_position_seconds:de.position_seconds,percent_watched:He,updated_at:Ot.updated_at}}))}catch(Mt){}}),[m,t.id,l,d]);n.useEffect(()=>{if(!c||!j||!M)return;const U=c.slug||c.id,de=`/membros/cursos/${ne}/${ae}/${U}`;($||"")===U&&!q||S(de,{replace:!0})},[c==null?void 0:c.id,c==null?void 0:c.slug,j,M,ne,ae,$,q,S]),n.useEffect(()=>{var de,_e;if(!l.length)return;const U=je.current;if(U){const $e=l.find(He=>He.id===U),De=($e==null?void 0:$e.slug)||U;if(J===De||J===U)je.current=null;else return}if(J){let $e=(de=l.find(De=>De.slug===J))!=null?de:null;!$e&&Xr(J)&&($e=(_e=l.find(De=>De.id===J))!=null?_e:null),$e&&(c==null?void 0:c.id)!==$e.id&&x($e)}},[J,l,c==null?void 0:c.id]);const[ee,re]=n.useState(!1),[be,ge]=n.useState(0),le=n.useRef(()=>{}),fe=n.useCallback((U,de)=>{le.current(U,de)},[]),[pe,Ne]=n.useState(null),Z=n.useRef(null),me=n.useCallback(()=>{Ne(null),Z.current=null},[]),Me=n.useRef(null),te=U=>{je.current=U.id,re(!1),me(),x(U),v||y(!1),requestAnimationFrame(()=>{const de=Me.current;if(!de)return;const _e=de.getBoundingClientRect();(_e.top<0||_e.top>120)&&window.scrollTo({top:window.scrollY+_e.top-80,behavior:"smooth"})})},we=c?l.findIndex(U=>U.id===c.id):-1,Pe=we>
2810?l[we-1]:null,oe=we>=0&&we<l.length-1?l[we+1]:null,O=i&&r&&c&&(Tt=r.modules.find(U=>U.id===c.module_id))!=null?Tt:t,H=(()=>{if(!i||!r)return s!=null?s:null;const U=r.modules.findIndex(de=>de.id===O.id);if(U<0)return s!=null?s:null;for(let de=U+1;de<r.modules.length;de++){const _e=r.modules[de];if(!_e.locked&&_e.status!=="coming_soon")return _e}return null})(),ce=n.useRef(0),V=ln(c),C=V,h=C?10:30,T=n.useCallback(()=>{Z.current||Date.now()<ce.current||(oe?(Z.current={kind:"lesson",lesson:oe},Ne(h)):H&&o&&(Z.current={kind:"module",module:H},Ne(h)))},[oe,H,o,h]),I=n.useCallback((U,de)=>{if(c&&(V&&de>0?G(c.id,{lesson_id:c.id,position_seconds:U,duration_seconds:de,percent_watched:Math.min(100,Math.round(U/de*100)),ended:de-U<=1}):ve(c.id,U)),C)return;const _e=h;de>_e+5&&de-U<=_e&&Z.current===null&&T()},[c,ve,G,T,h,C,V]);n.useEffect(()=>{le.current=(U,de)=>{if(ge(De=>U>De?U:De),C&&c){const De=d[c.id];!(De!=null&&De.completed)&&U>=10&&ve(c.id,Math.floor(U),!0)}if(!de||de<=0||Date.now()<ce.current)return;const _e=Math.max(0,de-U);if(C&&_e<=.35){Z.current||(oe?Z.current={kind:"lesson",lesson:oe}:H&&o&&(Z.current={kind:"module",module:H})),Z.current&&Ne(0);return}if(_e>0&&_e<=h&&de>h+3){if(!Z.current)if(oe)Z.current={kind:"lesson",lesson:oe};else if(H&&o)Z.current={kind:"module",module:H};else return;Ne(Math.max(1,Math.ceil(_e)))}else Z.current&&(Z.current=null,Ne(null))}},[oe,H,o,h,C,c,d,ve]);const K=n.useCallback(()=>{var U,de;c&&ve(c.id,(de=(U=d[c.id])==null?void 0:U.last_position_seconds)!=null?de:0,!0)},[c,ve,d]),ie=n.useCallback(()=>{Pe&&(je.current=Pe.id,re(!1),x(Pe))},[Pe]),Ae=n.useCallback(()=>{oe?(je.current=oe.id,re(!1),x(oe)):H&&o&&o(H)},[oe,H,o]),Te=n.useCallback(()=>{const U=Z.current;Ne(null),Z.current=null,U&&(ce.current=Date.now()+4e3,U.kind==="lesson"?(je.current=U.lesson.id,me(),re(!0),x(U.lesson)):U.kind==="module"&&o&&(me(),re(!0),o(U.module)))},[me,C,o]),[Ve,Ge]=n.useState(0),Le=n.useRef(null),it=n.useCallback(()=>{c&&(me(),ce.current=Date.now()+4e3,re(!0),Le.current=c.id,u(U=>{var de,_e;return se(L({},U),{[c.id]:{lesson_id:c.id,completed:(_e=(de=U[c.id])==null?void 0:de.completed)!=null?_e:!1,last_position_seconds:0,updated_at:new Date().toISOString()}})}),ve(c.id,0),ge(0),Ge(U=>U+1))},[c,me,ve]);n.useEffect(()=>{ge(0)},[c==null?void 0:c.id]);const A=n.useCallback(()=>{Date.now()<ce.current||Z.current||(oe?(Z.current={kind:"lesson",lesson:oe},Ne(C?0:h)):H&&o&&(Z.current={kind:"module",module:H},Ne(C?0:h)))},[oe,H,o,h,C]);n.useEffect(()=>{if(pe===null)return;if(pe<=0){Te();return}const U=window.setTimeout(()=>Ne(de=>de===null?null:de-1),1e3);return()=>window.clearTimeout(U)},[pe,Te]),n.useEffect(()=>{me(),ce.current=Math.max(ce.current,Date.now()+1200)},[c==null?void 0:c.id,me]);const X=((Zs=Z.current)==null?void 0:Zs.kind)==="lesson"?Z.current.lesson.title:((Js=Z.current)==null?void 0:Js.kind)==="module"?`${Z.current.module.title}${Z.current.module.subtitle?" · "+Z.current.module.subtitle:""}`:"",he=pe!==null&&pe>0?C?e.jsxs("button",{type:"button",onClick:Te,className:"absolute bottom-20 right-4 z-40 flex items-center gap-2 rounded-full px-3.5 py-1.5 text-white/90 hover:text-white focus:outline-none",style:{background:"rgba(20,20,22,0.55)",backdropFilter:"blur(18px) saturate(180%)",WebkitBackdropFilter:"blur(18px) saturate(180%)",border:"1px solid rgba(255,255,255,0.14)",boxShadow:"0 6px 22px rgba(0,0,0,0.35)",transition:"transform 180ms ease, background 180ms ease"},"aria-label":`Próxima aula em ${pe} segundos`,children:[e.jsx("span",{className:"text-[11px] font-medium tracking-wide opacity-80",children:"Próxima aula em"}),e.jsxs("span",{className:"text-[12px] font-semibold tabular-nums",children:[pe,"s"]})]}):e.jsxs("div",{className:"absolute bottom-3 right-3 z-40 w-[min(360px,92%)] md:w-[300px] rounded-lg shadow-xl overflow-hidden",style:{background:"rgba(0,0,0,0.92)",backdropFilter:"blur(8px)",border:"1px solid rgba(255,255,255,0.12)"},children:[e.jsxs("div",{className:"px-3 pt-2 pb-1.5",children:[e.jsxs("p",{className:"text-[9px] font-bold uppercase tracking-wider text-white/60",children:["Próximo em ",pe,"s"]}),e.jsx("p",{className:"text-[13px] font-semibold text-white mt-0.5 line-clamp-2 leading-snug",children:X})]}),e.jsx("div",{className:"h-0.5 w-full bg-white/10",children:e.jsx("div",{className:"h-full transition-all duration-1000 ease-linear",style:{width:`${(h-pe)/h*100}%`,background:"var(--sv-accent, #fff)"}})}),e.jsxs("div",{className:"flex",children:[e.jsx("button",{onClick:it,className:"flex-1 px-2 py-1.5 text-[11px] font-semibold text-white/70 hover:text-white hover:bg-white/5 transition-colors",children:"Assistir novamente"}),e.jsx("button",{onClick:Te,className:"flex-1 px-2 py-1.5 text-[11px] font-bold text-black bg-white hover:bg-white/90 transition-colors",children:"Assistir próxima"})]})]}
281):null,Ce=c?d[c.id]:void 0,Oe=!!(Ce!=null&&Ce.completed),Et=c?`${c.id}:${Ve}`:"none",et=!!c&&Le.current===c.id,Ut=et?0:(Ls=Ce==null?void 0:Ce.last_position_seconds)!=null?Ls:0,vt=et?0:(es=Ce==null?void 0:Ce.percent_watched)!=null?es:0,Rt=et?!1:!!(Ce!=null&&Ce.completed);et&&(Le.current=null);const lt=n.useCallback(U=>{var _e;const de=(_e=U.lesson_id)!=null?_e:c==null?void 0:c.id;de&&G(de,U)},[c,G]),Ts=n.useCallback(()=>{c&&(P.current.delete(c.id),Y(U=>U+1),ve(c.id,Math.floor(be),!0))},[c,ve,be]),Ds=!!c&&P.current.has(c.id),ys=c?Oe?e.jsx("button",{type:"button",onClick:()=>F(c.id),className:"shrink-0 inline-flex items-center gap-1.5 text-xs font-medium transition-colors",style:{color:"var(--sv-text-muted)"},children:"Marcar como não vista"}):Ds?e.jsx("button",{type:"button",onClick:Ts,className:"shrink-0 inline-flex items-center gap-1.5 text-xs font-medium transition-colors",style:{color:"var(--sv-text-muted)"},children:"Marcar como visto"}):e.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1.5 text-xs font-medium",style:{color:"var(--sv-text-muted)"},children:["Assista ",Math.max(1,Math.ceil(10-be)),"s para marcar como visto"]}):null,pn=(U,de)=>{var De,He,rt,ot;const _e=d[U.id],$e=!!_e&&!_e.completed&&(((De=_e.percent_watched)!=null?De:0)>0||((He=_e.last_position_seconds)!=null?He:0)>1);return e.jsx(Bm,{lesson:U,index:de,thumb:((rt=zs.find(mt=>mt.id===U.module_id))!=null?rt:O).cover_url,isActive:(c==null?void 0:c.id)===U.id,isCompleted:(ot=_e==null?void 0:_e.completed)!=null?ot:!1,hasProgress:$e,onClick:()=>te(U)},U.id)},wr=U=>{E(de=>{const _e=new Set(de);return _e.has(U)?_e.delete(U):_e.add(U),_e})},zs=i&&r?r.modules:[O],Gt=oe?{label:"Próxima aula",title:oe.title,go:()=>te(oe)}:H&&o?{label:"Próximo módulo",title:H.title,go:()=>o(H)}:null,jr=e.jsx("div",{className:"svl space-y-2.5",children:zs.map(U=>{const de=i?l.filter(rt=>rt.module_id===U.id):l;if(de.length===0)return null;const _e=U.id===O.id,$e=i?k.has(U.id):!0,De=de.filter(rt=>{var ot;return(ot=d[rt.id])==null?void 0:ot.completed}).length,He=Math.round(De/de.length*100);return $e?e.jsxs("div",{className:"svl-card overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>i&&wr(U.id),className:"svl-mod-head",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"svl-mod-title",children:U.title}),U.subtitle&&e.jsx("p",{className:"svl-mod-sub",children:U.subtitle})]}),i&&e.jsx(Hs,{size:18,className:"shrink-0 rotate-180 mt-0.5",style:{color:"var(--sv-text-muted)"}})]}),e.jsxs("div",{className:"svl-prog",children:[e.jsx("div",{className:"svl-bar",children:e.jsx("i",{style:{width:`${He}%`}})}),e.jsxs("div",{className:"svl-prog-meta",children:[e.jsxs("span",{children:[De," / ",de.length," aulas concluÃdas"]}),e.jsxs("b",{children:[He,"%"]})]})]}),e.jsx("div",{className:"svl-list",children:de.map((rt,ot)=>pn(rt,ot))}),_e&&Gt&&e.jsxs("button",{type:"button",onClick:Gt.go,className:"svl-next",style:{width:"calc(100% - 16px)"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("small",{children:Gt.label}),e.jsx("span",{className:"truncate",children:Gt.title})]}),e.jsx(gr,{size:20,className:"shrink-0"})]})]},U.id):e.jsx("div",{className:"svl-card",children:e.jsxs("button",{type:"button",onClick:()=>wr(U.id),className:"svl-mod-mini",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"svl-mod-title",children:U.title}),U.subtitle&&e.jsx("p",{className:"svl-mod-sub",children:U.subtitle})]}),e.jsx(Hs,{size:18,className:"shrink-0",style:{color:"var(--sv-text-muted)"}})]})},U.id)})});return v?e.jsxs("div",{className:"pb-32",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 md:px-8 py-4 border-b",style:{borderColor:"var(--sv-border, rgba(255,255,255,0.08))"},children:[e.jsx("button",{onClick:a,className:"p-1.5 rounded-lg hover:bg-white/10 transition-colors",children:e.jsx(Ct,{size:20,style:{color:"var(--sv-text-primary)"}})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-base font-bold truncate",style:{color:"var(--sv-text-primary)"},children:O.title}),O.subtitle&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--sv-text-muted)"},children:O.subtitle})]})]}),e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_minmax(300px,34vw)] 2xl:gr
281id-cols-[minmax(0,1fr)_390px] gap-4 xl:gap-6 px-5 md:px-8 pt-6",children:[e.jsx("div",{className:"min-w-0",ref:Me,children:c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end gap-x-4 gap-y-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-2xl font-bold tracking-tight truncate",style:{color:"var(--sv-text-primary)"},children:c.title}),e.jsxs("p",{className:"text-sm mt-1 truncate",style:{color:"var(--sv-text-muted)"},children:[O.title,O.subtitle?` - ${O.subtitle}`:""]})]}),e.jsx("div",{className:"max-w-full pb-1",children:ys})]}),e.jsxs("div",{className:"relative rounded-2xl overflow-hidden",style:{boxShadow:"0 0 0 1px rgba(255,255,255,0.08), 0 24px 60px -24px rgba(0,0,0,0.9)"},children:[e.jsx(Qa,{lesson:c,initialPosition:Ut,initialPercentWatched:vt,initialCompleted:Rt,orientation:ke,onProgress:I,onPlayerSnapshot:lt,onComplete:K,onEnded:A,onPrev:Pe?ie:void 0,onNext:oe||H?Ae:void 0,autoPlay:ee,onTick:fe,userId:m,moduleId:(Fs=c.module_id)!=null?Fs:t.id},Et),he]}),c.description&&e.jsx("p",{className:"mt-4 text-sm leading-relaxed",style:{color:"var(--sv-text-secondary)"},children:c.description}),e.jsx(Ua,{lessonId:c.id})]}):e.jsx("div",{className:"w-full rounded-xl flex items-center justify-center",style:{aspectRatio:"16/9",background:"var(--sv-bg-secondary, rgba(255,255,255,0.05))"},children:e.jsx("p",{className:"text-sm",style:{color:"var(--sv-text-muted)"},children:p?"Carregando...":l.length===0?"Nenhuma aula disponÃvel ainda":"Selecione uma aula"})})}),e.jsx("aside",{className:"min-w-0 xl:sticky xl:top-4 self-start",children:p?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(U=>e.jsx("div",{className:"h-16 rounded-xl animate-pulse",style:{background:"var(--sv-bg-secondary, rgba(255,255,255,0.05))"}},U))}):jr})]})]}):!_&&c?e.jsxs("div",{className:"pb-32",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-4",children:[e.jsx("button",{onClick:()=>y(!0),className:"p-1 rounded-lg hover:bg-white/10 transition-colors",children:e.jsx(Ct,{size:20,style:{color:"var(--sv-text-primary)"}})}),e.jsx("h2",{className:"flex-1 text-base font-bold truncate",style:{color:"var(--sv-text-primary)"},children:c.title})]}),e.jsxs("div",{className:"px-5",children:[ys&&e.jsx("div",{className:"mb-3 flex justify-end",children:ys}),e.jsxs("div",{className:"relative",children:[e.jsx(Qa,{lesson:c,initialPosition:Ut,initialPercentWatched:vt,initialCompleted:Rt,orientation:ke,onProgress:I,onPlayerSnapshot:lt,onComplete:K,onEnded:A,onPrev:Pe?ie:void 0,onNext:oe||H?Ae:void 0,autoPlay:ee,onTick:fe,userId:m,moduleId:(ws=c.module_id)!=null?ws:t.id},Et),he]}),c.description&&e.jsx("p",{className:"mt-4 text-sm leading-relaxed",style:{color:"var(--sv-text-secondary)"},children:c.description}),e.jsx(Ua,{lessonId:c.id})]}),(()=>{const U=we>=0?l.slice(we+1):[];return U.length===0?null:e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 mb-3",children:[e.jsx("h4",{className:"text-xs font-bold uppercase tracking-wider",style:{color:"var(--sv-text-muted)"},children:"Próximas aulas"}),e.jsx("button",{onClick:()=>y(!0),className:"text-xs font-semibold",style:{color:"var(--sv-text-secondary)"},children:"Ver todas"})]}),e.jsx("div",{className:"flex gap-3 overflow-x-auto px-5 pb-2 snap-x snap-mandatory [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:U.map((de,_e)=>{var ot;const $e=d[de.id],De=de.video_url?Al(de.video_url):null,He=De?Fm(De):O.cover_url,rt=we+1+_e;return e.jsx(qm,{lesson:de,lessonNumber:rt+1,completed:(ot=$e==null?void 0:$e.completed)!=null?ot:!1,fallback:He,onClick:()=>te(de)},de.id)})})]})})()]}):e.jsxs("div",{className:"pb-32",children:[e.jsxs("div",{className:"relative w-full h-44 flex items-end",style:{background:t.cover_url?void 0:t.cover_color},children:[t.cover_url&&e.jsx("img",{src:t.cover_url,alt:t.title,className:"absolute inset-0 w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0",style:{background:"linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 60%)"}}),e.jsx("button",{onClick:a,className:"absolute top-4 left-4 p-2 rounded-full z-10",style:{background:"rgba(0,0,0,0.4)",backdropFilter:"blur(4px)"},children:e.jsx(Ct,{size:18,className:"text-white"})}),e.jsxs("div",{className:"relative z-10 px-5 pb-4",children:[e.jsx("h2",{className:"text-lg font-bold text-white",children:t.title}),t.subtitle&&e.jsx("p",{className:"text-xs text-white/70 mt-0.5",children:t.subtitle})]})]}),e.jsx("div",{className:"px-5 mt-4",children:p?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(U=>e.jsx("div",{className:"h-16 rounded-xl animate-pulse",style:{background:"var(--sv-bg-secondary, rgba(255,255,255,0.05)
281)"}},U))}):l.length===0?e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-sm",style:{color:"var(--sv-text-muted)"},children:"Nenhuma aula disponÃvel ainda"})}):jr})]})}function Vm({mod:t,defaultVertical:r,onOpen:s}){const[a,o]=n.useState(r?"vertical":"horizontal"),i=t.locked||t.status==="coming_soon",l=a==="vertical",f=l?130:200,p=l?190:130;return e.jsxs("div",{onClick:i?void 0:s,className:"shrink-0 rounded-2xl overflow-hidden relative cursor-pointer active:scale-[0.97] transition-transform duration-150",style:{width:`${f}px`,height:`${p}px`,background:t.cover_url?void 0:t.cover_color},children:[t.cover_url&&e.jsx("img",{src:t.cover_url,alt:t.title,className:"absolute inset-0 w-full h-full object-cover",onLoad:g=>{const c=g.target;c.naturalHeight>c.naturalWidth?o("vertical"):o("horizontal")}}),!t.cover_url&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-20",children:e.jsx("span",{style:{fontSize:l?"60px":"48px"},children:t.cover_emoji})}),i&&e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-1 rounded-2xl",style:{background:"rgba(0,0,0,0.35)",backdropFilter:"blur(2px)"},children:[e.jsx(Us,{size:20,className:"text-white/60"}),e.jsx("span",{className:"text-white/60 text-[10px] font-medium uppercase tracking-wide",children:"em breve"})]}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-3 z-10",style:{background:"linear-gradient(to top, rgba(0,0,0,0.7), transparent)"},children:[e.jsx("p",{className:"text-[12px] font-bold text-white leading-tight",children:t.title}),t.subtitle&&e.jsx("p",{className:"text-[10px] text-white/70 leading-tight mt-0.5",children:t.subtitle})]})]})}function Hm({section:t,onOpenModule:r}){const s=n.useRef(null),a=!!t.locked;return e.jsxs("div",{className:"mb-6 relative",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 mb-3",children:[e.jsxs("h3",{className:"text-sm font-bold flex items-center gap-2",style:{color:"var(--sv-text-primary)"},children:[t.title,a&&e.jsx(Us,{size:13,style:{color:"var(--sv-text-muted)"}})]}),!a&&e.jsx(gr,{size:16,style:{color:"var(--sv-text-muted)"}})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{ref:s,className:"flex gap-3 overflow-x-auto px-5 pb-2",style:{scrollbarWidth:"none",WebkitOverflowScrolling:"touch",filter:a?"grayscale(0.6)":void 0,opacity:a?.55:1,pointerEvents:a?"none":void 0},children:t.modules.map(o=>e.jsx(Vm,{mod:o,defaultVertical:t.vertical_covers,onOpen:()=>r(o)},o.id))}),a&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center md:justify-start md:pl-5 pointer-events-none",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-full shadow-lg",style:{background:"rgba(0,0,0,0.75)",backdropFilter:"blur(8px)",border:"1px solid rgba(255,255,255,0.15)"},children:[e.jsx(Us,{size:12,className:"text-white/90"}),e.jsx("span",{className:"text-[11px] font-semibold text-white/90 whitespace-nowrap",children:"DisponÃvel em outro plano"})]})})]})]})}function eo(){var b,v,w;const[t,r]=n.useState(Lm),[s,a]=n.useState(null),o=bs(),i=yo(),l=i.pathname.split("/").filter(Boolean),f=(b=l[2])!=null?b:null,p=(v=l[3])!=null?v:null,g=(w=l[4])!=null?w:null,c=new URLSearchParams(i.search),x=c.get("curso"),d=c.get("aula");n.useEffect(()=>{Q(this,null,function*(){var _;try{const[{data:y},{data:k,error:E},{data:S},{data:R}]=yield Promise.all([Se.auth.getSession(),Wt.from("course_sections").select("*").eq("visible",!0).order("sort_order"),Wt.from("course_modules").select("*").eq("visible",!0).order("sort_order"),Wt.from("access_group_courses").select("course_section_id, group_id")]);if(E||!k||k.length===0)return;const z=(_=y.session)==null?void 0:_.user;let j=!1,M=new Set;if(z){const{data:ae}=yield Wt.rpc("has_role",{_user_id:z.id,_role:"admin"});if(j=!!ae,!j){const{data:J}=yield Wt.from("user_access_groups").select("group_id").eq("user_id",z.id);M=new Set((J!=null?J:[]).map(je=>je.group_id))}}const $=new Map;(R!=null?R:[]).forEach(ae=>{$.has(ae.course_section_id)||$.set(ae.course_section_id,new Set),$.get(ae.course_section_id).add(ae.group_id)});const q={};
281(S!=null?S:[]).forEach(ae=>{ae.status!=="draft"&&(q[ae.section_id]||(q[ae.section_id]=[]),q[ae.section_id].push(ae))});const ne=k.map(ae=>{var ke,ve,P;const J=(ke=$.get(ae.id))!=null?ke:new Set;let je=!1;return j||(je=J.size===0||![...J].some(N=>M.has(N))),se(L({},ae),{slug:(ve=ae.slug)!=null?ve:null,single_course:!!ae.single_course,modules:(P=q[ae.id])!=null?P:[],locked:je})});r(j?ne:ne.filter(ae=>!ae.locked))}catch(y){}})},[]),n.useEffect(()=>{var y,k,E;if(!t.length)return;const _=(S,R=null)=>{for(const z of t){if(R&&z.slug!==R)continue;const j=z.modules.find(M=>M.slug===S);if(j)return{section:z,module:j}}if(Xr(S))for(const z of t){if(R&&z.slug!==R&&z.id!==R)continue;const j=z.modules.find(M=>M.id===S);if(j)return{section:z,module:j}}return null};if(x){const S=_(x);if(S){const R=d?`/${d}`:"";o(`/membros/cursos/${S.section.slug||S.section.id}/${S.module.slug||S.module.id}${R}`,{replace:!0});return}}if(!f){s&&a(null);return}if(p){const S=(k=(y=t.find(R=>R.slug===f))!=null?y:t.find(R=>R.id===f))!=null?k:null;if(S){const R=(E=S.modules.find(z=>z.slug===p))!=null?E:Xr(p)?S.modules.find(z=>z.id===p):void 0;if(R){const z=S.slug||S.id,j=R.slug||R.id;if(f!==z||p!==j){const M=g?`/${g}`:"";o(`/membros/cursos/${z}/${j}${M}`,{replace:!0});return}(s==null?void 0:s.id)!==R.id&&a(R);return}}}{const S=_(f);if(S){const R=p?`/${p}`:"";o(`/membros/cursos/${S.section.slug||S.section.id}/${S.module.slug||S.module.id}${R}`,{replace:!0});return}}Q(this,null,function*(){try{const S=l.slice(0,5);for(let R=S.length;R>=3;R--){const z="/"+S.slice(0,R).join("/"),{data:j}=yield Wt.from("url_redirects").select("new_path").eq("old_path",z).maybeSingle();if(j!=null&&j.new_path){const M=l.slice(R).join("/"),$=M?`${j.new_path}/${M}`:j.new_path;o($,{replace:!0});return}}}catch(S){}})},[f,p,g,t,s,x,d,l,o]);const u=n.useCallback(_=>{const y=t.find(E=>E.modules.some(S=>S.id===_.id)),k=(y==null?void 0:y.slug)||(y==null?void 0:y.id)||"_";o(`/membros/cursos/${k}/${_.slug||_.id}`)},[o,t]),m=n.useCallback(()=>{o("/membros/cursos")},[o]);if(s){const _=t.find(k=>k.modules.some(E=>E.id===s.id));let y=null;if(_&&!_.locked){const k=_.modules.findIndex(E=>E.id===s.id);for(let E=k+1;E<_.modules.length;E++){const S=_.modules[E];if(!S.locked&&S.status!=="coming_soon"){y=S;break}}}return e.jsx(Wm,{mod:s,parentSection:_!=null?_:null,nextModule:y,onBack:m,onAdvanceModule:k=>u(k)})}return e.jsx("div",{className:"pt-2 pb-32",children:t.map(_=>e.jsx(Hm,{section:_,onOpenModule:u},_.id))})}const sn=Se;function Um(t){const r=Date.now()-new Date(t).getTime(),s=Math.floor(r/6e4);if(s<1)return"agora";if(s<60)return`${s}min`;const a=Math.floor(s/60);if(a<24)return`${a}h`;const o=Math.floor(a/24);return o===1?"1d":o<30?`${o}d`:`${Math.floor(o/30)}m`}function Gm({userId:t}){var R;const{isSupported:r,isEnabled:s,enableNotifications:a,disableNotifications:o,isLoading:i}=So(t),l=!!((R=window.NativeBridge)!=null&&R.__isNativeApp||window.__IS_NATIVE_APP__||/SetversoNative(IOS|Android)|LikePlayNative(IOS|Android)/i.test(navigator.userAgent)),{data:f,refetch:p}=Co(t),g=Eo(),[c,x]=n.useState(!1),[d,u]=n.useState({push_enabled:!0,email_enabled:!0,in_app_enabled:!0}),[m,b]=n.useState(!1),[v,w]=n.useState(null),_=l?!!(f!=null&&f.is_active):!1;n.useEffect(()=>{Q(this,null,function*(){const{data:z}=yield sn.from("notification_preferences").select("push_enabled, email_enabled, in_app_enabled").eq("user_id",t).maybeSingle();z&&u({push_enabled:z.push_enabled,email_enabled:z.email_enabled,in_app_enabled:z.in_app_enabled}),b(!0)})},[t]);const y=(z,j)=>Q(this,null,function*(){w(z);const M=se(L({},d),{[z]:j});u(M);const{error:$}=yield sn.from("notification_preferences").upsert({user_id:t,email_enabled:M.email_enabled,in_app_enabled:M.in_app_enabled,updated_at:new Date().toISOString()},{onConflict:"user_id"});$&&(console.error("Failed to save pref:",$),u(d),Ie.error("Erro ao salvar preferência")),w(null)}),k=z=>Q(this,null,function*(){var j;if(l){x(!0);try{z?((j=window.NativeBridge)!=null&&j.requestPushPermission&&window.NativeBridge.requestPushPermission(),Ie.info("Ative as notificações nas configurações do app.")):(yield g.mutateAsync(),yield p())}finally{x(!1)}}else z?yield a():yield o()});if(!m)return null;const E=r||l,S=[{key:"email_enabled",icon:bo,label:"Notificações por Email",desc:"Todos os dispositivos",checked:d.email_enabled,onChange:z=>y("email_enabled",z),disabled:v==="email_enabled",show:!0},{key:"in_app_enabled",icon:qc,label:"Notificações In-App",desc:"Todos os dispositivos",checked:d.in_app_enabled,onChange:z=>y("in_app_enabled",z),disabled:v==="in_app_enabled",show:!0},{key:"push_enabled",icon:Ms,label:"Notificações Push",desc:"Apenas este dispositivo",checked:l?_:s,onChange:k,disabled:i||c,show:E}];return e.jsxs("div",{className:"rounded-2xl p-4 mb-4",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-subtle)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Wc,{size:14,className:"text-muted-foreground"}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em] text-muted-foreground",children:"Configurações"})]}),e.jsx("div",{className:"flex flex-col gap-1",children:S.filter(z=>
281z.show).map(({key:z,icon:j,label:M,desc:$,checked:q,onChange:ne,disabled:ae})=>e.jsxs("div",{className:"flex items-center gap-4 px-1 py-2.5",children:[e.jsx(j,{size:18,className:"shrink-0 text-foreground"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground block",children:M}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:$})]}),e.jsx(xr,{checked:q,onCheckedChange:ne,disabled:ae})]},z))})]})}const Tn=20;function Ym({userId:t}){const[r,s]=n.useState([]),[a,o]=n.useState(!0),[i,l]=n.useState(!0),f=n.useRef(!1),p=Ks(),g=bs(),c=n.useCallback(b=>Q(this,null,function*(){const v={limit:String(Tn)};b&&(v.cursor=b);const y=`https://rnxhicoiinwcninuxxej.supabase.co/functions/v1/list-notifications?${new URLSearchParams(v).toString()}`,{data:{session:k}}=yield Se.auth.getSession();if(!(k!=null&&k.access_token))return[];const E=yield fetch(y,{headers:{Authorization:`Bearer ${k.access_token}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJueGhpY29paW53Y25pbnV4eGVqIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQzODQ3MjAsImV4cCI6MjA4OTk2MDcyMH0.Sxn4K7nhXHpKTRTW4llQVBnApUwqO5IFOz63C_RsYsw"}});if(!E.ok)return console.error("Error fetching notifications:",E.status),[];const S=yield E.json();return S!=null?S:[]}),[]);n.useEffect(()=>{let b=!1;return o(!0),c().then(v=>{b||(s(v),l(v.length>=Tn),o(!1))}),()=>{b=!0}},[c]);const x=n.useCallback(()=>Q(this,null,function*(){if(f.current||!i||r.length===0)return;f.current=!0;const b=r[r.length-1],v=yield c(b.created_at);v.length>0&&s(w=>{const _=new Set(w.map(y=>y.id));return[...w,...v.filter(y=>!_.has(y.id))]}),l(v.length>=Tn),f.current=!1}),[r,i,c]),d=n.useCallback(b=>{const v=b.currentTarget;v.scrollHeight-v.scrollTop-v.clientHeight<400&&x()},[x]),u=n.useCallback(b=>Q(this,null,function*(){s(w=>w.filter(_=>_.id!==b));const{error:v}=yield sn.from("user_notifications").delete().eq("id",b);v&&(console.error("Error deleting notification:",v),Ie.error("Erro ao excluir notificação"))}),[]),m=n.useCallback(b=>Q(this,null,function*(){b.read_at||sn.from("user_notifications").update({read_at:new Date().toISOString()}).eq("id",b.id).then(()=>{});const v=(b.content_url||"").trim();if(!v)return;const w=Qn(v);if(w){g(`/membros/post/${w}`);return}try{const _=new URL(v,window.location.origin);if(new Set([window.location.hostname,"setverso.com","www.setverso.com","membrossetverso.lovable.app"]).has(_.hostname)){g(`${_.pathname}${_.search}${_.hash}`||"/");return}fd(_.href)}catch(_){v.startsWith("/")&&g(v)}}),[g]);return a?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(dr,{size:24,className:"animate-spin text-muted-foreground"})}):e.jsx("div",{className:"flex flex-col flex-1",onScroll:d,children:e.jsxs("div",{className:"px-4 pt-2 pb-4",children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-[0.18em] text-muted-foreground mb-3",children:"Notificações"}),!p&&t&&e.jsx(Gm,{userId:t}),r.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center gap-3",children:[e.jsx(Ms,{size:40,className:"text-muted-foreground/40"}),e.jsx("h2",{className:"text-lg font-bold text-foreground",children:"Nenhuma notificação"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-xs",children:"Quando houver novidades, elas aparecerão aqui."})]}):e.jsx("div",{className:"flex flex-col gap-2",children:r.map(b=>{const v=!!(b.content_url&&b.content_url.trim());return e.jsxs("div",{role:v?"button":void 0,tabIndex:v?0:void 0,onClick:v?()=>m(b):void 0,onKeyDown:v?w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),m(b))}:void 0,className:`relative flex items-start gap-3 p-3 rounded-2xl transition-colors ${v?"cursor-pointer hover:opacity-90 active:opacity-80":""}`,style:{background:"var(--sv-surface)"},children:[e.jsxs("div",{className:"absolute top-2 right-2 flex flex-col items-center gap-1",children:[e.jsx("button",{onClick:w=>{w.stopPropagation(),u(b.id)},className:"w-5 h-5 flex items-center justify-center rounded-full text-muted-foreground/40 hover:text-muted-foreground transition-colors",children:e.jsx(Je,{size:12})}
281),e.jsx("span",{className:"text-[10px] text-muted-foreground/50",children:Um(b.created_at)})]}),b.image_url?e.jsx("img",{src:b.image_url,alt:"",className:"w-10 h-10 rounded-xl object-cover shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shrink-0",style:{background:"hsl(var(--setverso-red) / 0.15)"},children:e.jsx(Ms,{size:18,style:{color:"hsl(var(--setverso-red))"}})}),e.jsxs("div",{className:"flex-1 min-w-0 pr-8",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground leading-snug",children:b.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:b.body})]})]},b.id)})})]})})}function Km(t,r){const s=(t||"").toLowerCase();return s==="suspended"||s==="grace_period"&&(r||"").toLowerCase()==="membro"}const Xm=new Set(["expired","inadimplente","refunded","revoked","inactive"]);function Zm(t,r){const s=(t||"").toLowerCase();if(Xm.has(s))return!0;if(s==="cancelled"||s==="canceled"){if(!r)return!0;const a=new Date(r);return Number.isNaN(a.getTime())?!0:a.getTime()<=Date.now()}return!1}const Kn=Se,Xn="sv_user_plan_cache",Zn="sv_user_suspended_cache";function Jm(t){const r=t.toLowerCase();return r.includes("community")||r.includes("communit")?"community":r.includes("vertical")?"vertical":r.includes("pró")||r.includes("pro")?"pro":r.includes("plus")?"plus":"other"}function Qm(){try{const t=localStorage.getItem(Xn);if(t)return JSON.parse(t)}catch(t){}return null}function _s(t){try{t?localStorage.setItem(Xn,JSON.stringify(t)):localStorage.removeItem(Xn)}catch(r){}}function ep(){try{return localStorage.getItem(Zn)==="1"}catch(t){}return!1}function Ir(t){try{t?localStorage.setItem(Zn,"1"):localStorage.removeItem(Zn)}catch(r){}}function tp(t,r){return Q(this,null,function*(){let s=Kn.from("audience").select("status, stage, expires_at").eq("user_id",t).order("updated_at",{ascending:!1}).limit(1),{data:a}=yield s.maybeSingle();return!a&&r&&(a=(yield Kn.from("audience").select("status, stage, expires_at").ilike("email",r.toLowerCase().trim()).order("updated_at",{ascending:!1}).limit(1).maybeSingle()).data),a})}function sp(){const t=Qm(),r=ep(),[s,a]=n.useState(r?null:t),[o,i]=n.useState(r),[l,f]=n.useState(!r&&t===null),[p,g]=n.useState(null),c=n.useCallback(()=>Q(this,null,function*(){var y,k,E,S,R,z;const{data:d}=yield Se.auth.getSession(),u=(E=(k=(y=d.session)==null?void 0:y.user)==null?void 0:k.id)!=null?E:null,m=(z=(R=(S=d.session)==null?void 0:S.user)==null?void 0:R.email)!=null?z:null;if(g(u),!u){a(null),i(!1),_s(null),Ir(!1),f(!1);return}const b=yield tp(u,m);if(b&&Km(b.status,b.stage)){a(null),i(!0),_s(null),Ir(!0),f(!1);return}if(i(!1),Ir(!1),b&&Zm(b.status,b.expires_at)){a(null),_s(null),f(!1);return}const v=(j,M)=>{var $;return{id:j.id,name:j.name,access_group_id:j.access_group_id,status:M,tier:Jm(($=j.name)!=null?$:"")}},w=()=>Q(this,null,function*(){return yield Kn.from("user_subscriptions").select("status, plan_id, subscription_plans(id, name, access_group_id)").eq("user_id",u).in("status",["active","trialing","past_due"]).order("created_at",{ascending:!1}).limit(1).maybeSingle()});let{data:_}=yield w();if((!_||!_.subscription_plans)&&(yield new Promise(M=>setTimeout(M,1e3)),_=(yield w()).data),_&&_.subscription_plans){const j=v(_.subscription_plans,_.status);a(j),_s(j),f(!1);return}try{const{data:j}=yield Se.functions.invoke("sync-user-entitlements");if((j==null?void 0:j.source)==="suspended"){a(null),i(!0),_s(null),Ir(!0),f(!1);return}if(j!=null&&j.plan){const M=v(j.plan,"active");a(M),_s(M),f(!1);return}}catch(j){console.warn("[useUserPlan] sync-user-entitlements failed",j)}a(null),_s(null),f(!1)}),[]);n.useEffect(()=>{c()},[c]);const x=n.useRef(c);return n.useEffect(()=>{x.current=c},[c]),n.useEffect(()=>{if(!p)return;const d=Se.channel(`user-plan-rt-${p}`).on("postgres_changes",{event:"*",schema:"public",table:"user_subscriptions",filter:`user_id=eq.${p}`},()=>x.current()).on("postgres_changes",{event:"UPDATE",schema:"public",table:"audience",filter:`user_id=eq.${p}`},()=>x.current()).subscribe();return()=>{Se.removeChannel(d)}},[p]),n.useEffect(()=>{const d=()=>{document.visibilityState==="visible"&&x.current()};return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[]),{plan:s,hasPlan:!!s&&!o,isSuspended:o,loading:l,refetch:c}}
281const Lr=Se,to="sv_members_cache";let nr=null;function Pl(){const[t,r]=n.useState(()=>{if(nr)return nr;try{const i=localStorage.getItem(to);if(i){const l=JSON.parse(i);return nr=l,l}}catch(i){}return[]}),[s,a]=n.useState(!nr),o=n.useCallback(()=>Q(this,null,function*(){var u;const[{data:i},{data:l},{data:f},{data:p}]=yield Promise.all([Lr.from("profiles").select("*").order("created_at"),Lr.from("user_tags").select("*"),Lr.from("tags").select("*"),Lr.from("user_roles").select("user_id, role")]),g={};(f!=null?f:[]).forEach(m=>{var b;g[m.id]={id:m.id,name:m.name,color:m.color,emoji:(b=m.emoji)!=null?b:null}});const c={};(l!=null?l:[]).forEach(m=>{c[m.user_id]||(c[m.user_id]=[]),g[m.tag_id]&&c[m.user_id].push(g[m.tag_id])});const x=new Set;if((p!=null?p:[]).forEach(m=>{m.role==="admin"&&x.add(m.user_id)}),x.size===0)try{const{data:m}=yield Se.functions.invoke("manage-role",{body:{action:"list_admin_ids"}});((u=m==null?void 0:m.user_ids)!=null?u:[]).forEach(v=>x.add(v))}catch(m){}const d=(i!=null?i:[]).map(m=>{var b,v;return se(L({},m),{skills:(b=m.skills)!=null?b:[],tags:(v=c[m.id])!=null?v:[],isAdmin:x.has(m.id)})});nr=d,r(d),a(!1);try{localStorage.setItem(to,JSON.stringify(d))}catch(m){}}),[]);return n.useEffect(()=>{o()},[o]),{members:t,loading:s,refetch:o}}const Tl=Ro,rp=Mo,Dl=n.forwardRef((a,s)=>{var o=a,{className:t}=o,r=xe(o,["className"]);return e.jsx(aa,se(L({className:Be("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t)},r),{ref:s}))});Dl.displayName=aa.displayName;const np=mo("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),ba=n.forwardRef((i,o)=>{var l=i,{side:t="right",className:r,children:s}=l,a=xe(l,["side","className","children"]);return e.jsxs(rp,{children:[e.jsx(Dl,{}),e.jsxs(sa,se(L({ref:o,className:Be(np({side:t}),r)},a),{children:[s,e.jsxs(ra,{className:"absolute right-4 top-4 roun
281ded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(Je,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]}))]})});ba.displayName=sa.displayName;const zl=n.forwardRef((a,s)=>{var o=a,{className:t}=o,r=xe(o,["className"]);return e.jsx(na,L({ref:s,className:Be("text-lg font-semibold text-foreground",t)},r))});zl.displayName=na.displayName;const ap=n.forwardRef((a,s)=>{var o=a,{className:t}=o,r=xe(o,["className"]);return e.jsx(oa,L({ref:s,className:Be("text-sm text-muted-foreground",t)},r))});ap.displayName=oa.displayName;function Il({member:t,open:r,onClose:s,onStartConversation:a,currentUserId:o}){var p,g,c;if(!t)return null;const i=((p=t.name)!=null?p:"?").split(" ").slice(0,2).map(x=>x[0]).join("").toUpperCase(),l=o===t.id,f=t.created_at?new Date(t.created_at).toLocaleDateString("pt-BR",{month:"long",year:"numeric"}):null;return e.jsx(Tl,{open:r,onOpenChange:x=>!x&&s(),children:e.jsx(ba,{side:"bottom",className:"rounded-t-3xl p-0 border-t bg-background max-h-[85vh]",style:{borderColor:"hsl(var(--border))"},children:e.jsxs("div",{className:"flex flex-col items-center pt-6 pb-8 px-6",children:[e.jsx("div",{className:"w-10 h-1 rounded-full mb-6",style:{background:"hsl(var(--muted-foreground) / 0.3)"}}),e.jsxs(ut,{className:"h-20 w-20 border-[3px] mb-4",style:{borderColor:"hsl(var(--border))"},children:[t.avatar_url?e.jsx(Ze,{src:t.avatar_url,alt:(g=t.name)!=null?g:"",className:"object-cover"}):null,e.jsx(ft,{className:"text-xl font-black text-white",style:{background:"linear-gradient(135deg, hsl(var(--setverso-red)) 0%, hsl(var(--setverso-red) / 0.6) 100%)"},children:i})]}),e.jsx("h2",{className:"text-lg font-black text-foreground leading-tight text-center",children:(c=t.name)!=null?c:"Membro"}),t.bio&&e.jsx("p",{className:"text-sm text-muted-foreground text-center whitespace-pre-wrap mt-2 max-w-[34ch] leading-relaxed",children:t.bio}),t.username&&e.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[e.jsx(Kc,{size:12,className:"text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t.username})]}),t.phone&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[e.jsx(ed,{size:12,className:"text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t.phone})]}),t.location&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[e.jsx(In,{size:12,className:"text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t.location})]}),t.tags&&t.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-4 justify-center",children:t.tags.map(x=>{var d,u,m;return e.jsxs("span",{className:"text-[11px] font-bold px-3 py-1 rounded-full",style:{background:`${(d=x.color)!=null?d:"hsl(var(--setverso-red))"}20`,color:(u=x.color)!=null?u:"hsl(var(--setverso-red))",border:`1px solid ${(m=x.color)!=null?m:"hsl(var(--setverso-red))"}40`},children:[x.emoji?`${x.emoji} `:"",x.name]},x.id)})}),t.isAdmin&&e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider px-3 py-1 rounded-full mt-3",style:{background:"hsl(var(--setverso-red) / 0.15)",color:"hsl(var(--setverso-red))",border:"1px solid hsl(var(--setverso-red) / 0.3)"},children:"Administrador"}),f&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-4",children:["Membro desde ",f]}),t.skills&&t.skills.length>0&&e.jsxs("div",{className:"w-full mt-5",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em] text-muted-foreground mb-2",children:"Habilidades"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.skills.map((x,d)=>e.jsx("span",{className:"text-xs px-2.5 py-1 rounded-lg bg-muted text-muted-foreground",children:x},d))})]}),!l&&a&&e.jsxs(Yc,{onClick:()=>a(t.id),className:"w-full mt-6 gap-2 rounded-2xl h-12 font-bold",style:{background:"hsl(var(--setverso-red))",color:"white"},children:[e.jsx(gs,{size:18}),"Enviar mensagem"]})]})})})}function op({currentUserId:t,onStartConversation:r}){const[s,a]=n.useState(""),[o,i]=n.useState(null),[l,f]=n.useState(null),{members:p,loading:g}=Pl();n.useEffect(()=>{let u=!1;return Q(this,null,function*(){try{const{data:v}=yield Se.functions.invoke("public-members-count"),w=v==null?void 0:v.count;if(!u&&typeof w=="number"&&w>0){f(w);return}}catch(v){}const m=Se,{count:b}=yield m.from("profiles").select("*",{count:"exact",head:!0});!u&&typeof b=="number"&&f(b)}),()=>{u=!0}},[]);const c=p.filter(u=>{var m,b;return((m=u.name)!=null?m:"").toLowerCase().includes(s.toLowerCase())||((b=u.location)!=null?b:"").toLowerCase().includes(s.toLowerCase())}),x=c.filter(u=>u.isAdmin),d=c.filter(u=>!u.isAdmin);return e.jsxs("div",{className:"px-5 pt-2 pb-32",children:[e.jsxs("div",{className:"flex items-center gap-2.5 rounded-2xl px-4 py-3 mb-5",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-subtle)"},children:[e.jsx(pr,{size:15,style:{color:"hsl(var(--muted-foreground))",flexShrink:0}}),e.jsx("input",{type:"text",placeholder:"Buscar membro...",value:s,onChange:u=>a(u.target.value),className:"flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground outline-none"}),s&&e.jsx("button",{onClick:()=>a(""),className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:"â"})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:"text-xs font-bold uppercase tracking-[0.18em]",style:{color:"hsl(var(--muted-foreground))"},children:(()=>{const u=s?c.length:l!=null?l:g?null:c.length;
281return u===null?"...":`${u.toLocaleString("pt-BR")} ${u===1?"membro":"membros"}`})()}),e.jsx("div",{className:"flex-1 h-px",style:{background:"hsl(var(--border))"}})]}),g?e.jsx("div",{className:"flex flex-col gap-2",children:[...Array(6)].map((u,m)=>e.jsx("div",{className:"flex items-center gap-3 rounded-2xl px-4 py-3 animate-pulse",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-subtle)",minHeight:"60px"}},m))}):c.length>0?e.jsxs("div",{className:"flex flex-col gap-5",children:[x.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.18em]",style:{color:"hsl(var(--muted-foreground))"},children:"Administradores"}),e.jsx("div",{className:"flex-1 h-px",style:{background:"hsl(var(--border))"}})]}),e.jsx("div",{className:"flex flex-col gap-2",children:x.map(u=>e.jsx(so,{member:u,onClick:()=>i(u)},u.id))})]}),d.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.18em]",style:{color:"hsl(var(--muted-foreground))"},children:"Membros"}),e.jsx("div",{className:"flex-1 h-px",style:{background:"hsl(var(--border))"}})]}),e.jsx("div",{className:"flex flex-col gap-2",children:d.map(u=>e.jsx(so,{member:u,onClick:()=>i(u)},u.id))})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-40 gap-2",children:[e.jsx("p",{className:"text-sm font-semibold",style:{color:"hsl(var(--muted-foreground))"},children:"Nenhum membro encontrado"}),e.jsx("p",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:"Tente outro termo de busca"})]}),e.jsx(Il,{member:o,open:!!o,onClose:()=>i(null),currentUserId:t,onStartConversation:u=>{i(null),r==null||r(u)}})]})}function so({member:t,onClick:r}){var a,o,i,l,f;const s=((a=t.name)!=null?a:"?").split(" ").slice(0,2).map(p=>p[0]).join("").toUpperCase();return e.jsxs("div",{onClick:r,className:"flex items-center gap-3 rounded-2xl px-4 py-3 active:scale-[0.99] transition-all duration-150 cursor-pointer",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-subtle)"},children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsxs(ut,{className:"h-11 w-11 border-2",style:{borderColor:"var(--sv-border-subtle)"},children:[t.avatar_url?e.jsx(Ze,{src:t.avatar_url,alt:(o=t.name)!=null?o:"",className:"object-cover"}):t.username==="pedropimentel"||(i=t.name)!=null&&i.toLowerCase().includes("pedro")?e.jsx(Ze,{src:mn,alt:(l=t.name)!=null?l:"",className:"object-cover"}):null,e.jsx(ft,{className:"text-sm font-black text-white",style:{background:"linear-gradient(135deg, hsl(var(--setverso-red)) 0%, hsl(var(--setverso-red) / 0.6) 100%)"},children:s})]}),e.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 rounded-full border-2",style:{background:"hsl(142 71% 45%)",borderColor:"var(--sv-surface)"}})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-bold leading-tight truncate",style:{color:"var(--sv-text-primary)"}
281,children:(f=t.name)!=null?f:"Membro"}),e.jsxs("p",{className:"text-[10px] leading-tight mt-0.5 truncate",style:{color:"var(--sv-text-muted)"},children:["Membro desde ",new Date(t.created_at).toLocaleDateString("pt-BR")]})]}),t.tags&&t.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[t.tags.slice(0,1).map(p=>{var g,c,x;return e.jsxs("span",{className:"text-[9px] font-bold px-2 py-0.5 rounded-full truncate max-w-[90px]",style:{background:`${(g=p.color)!=null?g:"hsl(var(--setverso-red))"}20`,color:(c=p.color)!=null?c:"hsl(var(--setverso-red))",border:`1px solid ${(x=p.color)!=null?x:"hsl(var(--setverso-red))"}40`},children:[p.emoji?`${p.emoji} `:"",p.name]},p.id)}),t.tags.length>1&&e.jsxs("span",{className:"text-[9px]",style:{color:"var(--sv-text-muted)"},children:["+",t.tags.length-1]})]})]})}function ip(t){return t?t.split(" ").slice(0,2).map(r=>r[0]).join("").toUpperCase():"?"}function ro({member:t,onSelect:r}){var s,a;return e.jsxs("button",{onClick:()=>r(t.id,{id:t.id,name:t.name,avatar_url:t.avatar_url}),className:"flex items-center gap-3 px-5 py-3 w-full text-left transition-colors active:bg-white/5",children:[e.jsxs(ut,{className:"h-10 w-10 border border-border shrink-0",children:[t.avatar_url?e.jsx(Ze,{src:t.avatar_url,alt:(s=t.name)!=null?s:"",className:"object-cover"}):null,e.jsx(ft,{className:"text-xs font-bold text-white",style:{background:"hsl(var(--setverso-red))"},children:ip(t.name)})]}),e.jsx("div",{children:e.jsx("p",{className:"text-sm font-semibold text-foreground",children:(a=t.name)!=null?a:"Membro"})})]})}function lp({open:t,onClose:r,userId:s,onSelect:a}){const{members:o,loading:i}=Pl(),[l,f]=n.useState(""),p=d=>d.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim(),g=o.filter(d=>d.id!==s).filter(d=>{var u;return!l.trim()||p((u=d.name)!=null?u:"").includes(p(l))}),c=g.filter(d=>d.isAdmin),x=g.filter(d=>!d.isAdmin);return e.jsx(Tl,{open:t,onOpenChange:d=>!d&&r(),children:e.jsx(ba,{side:"bottom",className:"h-[80vh] rounded-t-3xl p-0 border-t border-border bg-background",children:e.jsxs("div",{className:"flex flex-col h-full pt-4",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:"w-10 h-1 rounded-full bg-muted-foreground/30"})}),e.jsx(zl,{className:"px-5 text-lg font-black text-foreground mb-3",children:"Nova Conversa"}),e.jsx("div",{className:"px-5 pb-3",children:e.jsxs("div",{className:"flex items-center gap-2 px-4 rounded-xl",style:{height:42,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)"},children:[e.jsx(pr,{size:16,className:"text-muted-foreground shrink-0"}),e.jsx("input",{type:"text",value:l,onChange:d=>f(d.target.value),placeholder:"Buscar membro...",className:"flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground outline-none"}),l&&e.jsx("button",{onClick:()=>f(""),children:e.jsx(Je,{size:14,className:"text-muted-foreground"})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:i?e.jsx("div",{className:"flex flex-col gap-2 px-5",children:[...Array(5)].map((d,u)=>e.jsx("div",{className:"h-14 rounded-xl animate-pulse",style:{background:"rgba(255,255,255,0.03)"}},u))}):g.length===0?e.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:"Poxa, essa pessoa ainda não faz parte do SetVerso ;("}):e.jsxs(e.Fragment,{children:[c.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"px-5 pt-2 pb-1 text-[11px] font-bold uppercase tracking-wider text-muted-foreground/60",children:"Administradores"}),c.map(d=>e.jsx(ro,{member:d,onSelect:a},d.id))]}),x.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"px-5 pt-4 pb-1 text-[11px] font-bold uppercase tracking-wider text-muted-foreground/60",children:"Membros"}),x.map(d=>e.jsx(ro,{member:d,onSelect:a},d.id))]})]})})]})})})}var Ll="AlertDialog",[cp]=mr(Ll,[Ao]),Qt=Ao(),Fl=t=>{const o=t,{__scopeAlertDialog:r}=o,s=xe(o,["__scopeAlertDialog"]),a=Qt(r);return e.jsx(Ro,se(L(L({},a),s),{modal:!0}))};Fl.displayName=Ll;var dp="AlertDialogTrigger",up=n.forwardRef((t,r)=>{const i=t,{__scopeAlertDialog:s}=i,a=xe(i,["__scopeAlertDialog"]),o=Qt(s);return e.jsx(Hc,se(L(L({},o),a),{ref:r}))});up.displayName=dp;var fp="AlertDialogPortal",Ol=t=>{const o=t,{__scopeAlertDialog:r}=o,s=xe(o,["__scopeAlertDialog"]),a=Qt(r);return e.jsx(Mo,L(L({},a),s))};Ol.displayName=fp;var mp="AlertDialogOverlay",$l=n.forwardRef((t,r)=>{const i=t,{__scopeAlertDialog:s}=i,a=xe(i,["__scopeAlertDialog"]),o=Qt(s);return e.jsx(aa,se(L(L({},o),a),{ref:r}))});$l.displayName=mp;var Ws="AlertDialogContent",[pp,hp]=cp(Ws),xp=_c("AlertDialogContent"),Bl=n.forwardRef((t,r)=>{const g=t,{__scopeAlertDialog:s,children:a}=g,o=xe(g,["__scopeAlertDialog","children"]),i=Qt(s),l=n.useRef(null),f=vs(r,l),p=n.useRef(null);return e.jsx(Vc,{contentName:Ws,titleName:ql,docsSlug:"alert-dialog",children:e.jsx(pp,{scope:s,cancelRef:p,children:e.jsxs(sa,se(L(L({role:"alertdialog"},i),o),{ref:f,onOpenAutoFocus:qe(o.onOpenAutoFocus,c=>{var x;c.preventDefault(),(x=p.current)==null||x.focus({preventScroll:!0})}),onPointerDownOutside:c=>c.preventDefault(),onInteractOutside:c=>c.preventDefault(),children:[e.jsx(xp,{children:a}),e.jsx(vp,{contentRef:l})]}))})})});Bl.displayName=Ws;var ql="AlertDialogTitle",Wl=n.forwardRef((t,r)=>{const i=t,{__scopeAlertDialog:s}=i,a=xe(i,["__scopeAlertDialog"]),o=Qt(s);return e.jsx(na,se(L(L({},o),a),{ref:r}))});Wl.displayName=ql;var Vl="AlertDialogDescription",Hl=n.forwardRef((t,r)=>{const i=t,{__scopeAlertDialog:s}=i,a=xe(i,["__scopeAlertDialog"]),o=Qt(s);return e.jsx(oa,se(L(L({},o),a),{ref:r}))});Hl.displayName=Vl;var gp="AlertDialogAction",Ul=n.forwardRef((t,r)=>{const i=t,{__scopeAlertDialog:s}=i,a=xe(i,["__scopeAlertDialog"]),o=Qt(s);return e.jsx(ra,se(L(L({},o),a),{ref:r}))});Ul.displayName=gp;var Gl="AlertDialogCancel",Yl=n.forwardRef((t,r)=>{const f=t,{__scopeAlertDialog:s}=f,a=xe(f,["__scopeAlertDialog"]),{cancelRef:o}=hp(Gl,s),i=Qt(s),l=vs(r,o);return e.jsx(ra,se(L(L({},i),a),{ref:l}))});Yl.displayName=Gl;var vp=({contentRef:t})=>{const r=`\`${Ws}\` requires a description for the component to be accessible for screen reader users. 282
283You can add a description to the \`${Ws}\` by passing a \`${Vl}\` component as a child, which also benefits sighted users by adding visible context to the dialog. 284 285Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Ws}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. 286 287For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return n.useEffect(()=>{var a;document.getElementById((a=t.current)==null?void 0:a.getAttribute("aria-describedby"))||console.warn(r)},[r,t]),null},bp=Fl,yp=Ol,Kl=$l,Xl=Bl,Zl=Ul,Jl=Yl,Ql=Wl,ec=Hl;const wp=bp,jp=yp,tc=n.forwardRef((a,s)=>{var o=a,{className:t}=o,r=xe(o,["className"]);return e.jsx(Kl,se(L({className:Be("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t)},r),{ref:s}))});tc.displayName=Kl.displayName;const sc=n.forwardRef((a,s)=>{var o=a,{className:t}=o,r=xe(o,["className"]);return e.jsxs(jp,{children:[e.jsx(tc,{}),e.jsx(Xl,L({ref:s,className:Be("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t)},r))]})});sc.displayName=Xl.displayName;const rc=s=>{var a=s,{className:t}=a,r=xe(a,["className"]);return e.jsx("div",L({className:Be("flex flex-col space-y-2 text-center sm:text-left",t)},r))};rc.displayName="AlertDialogHeader";const nc=s=>{var a=s,{className:t}=a,r=xe(a,["className"]);return e.jsx("div",L({className:Be("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t)},r))};nc.displayName="AlertDialogFooter";const ac=n.forwardRef((a,s)=>{var o=a,{className:t}=o,r=xe(o,["className"]);return e.jsx(Ql,L({ref:s,className:Be("text-lg font-semibold",t)},r))});ac.displayName=Ql.displayName;const oc=n.forwardRef((a,s)=>{var o=a,{className:t}=o,r=xe(o,["className"]);return e.jsx(ec,L({ref:s,className:Be("text-sm text-muted-foreground",t)},r))});oc.displayName=ec.displayName;const ic=n.forwardRef((a,s)=>{var o=a,{className:t}=o,r=xe(o,["className"]);return e.jsx(Zl,L({ref:s,className:Be(Po(),t)},r))});ic.displayName=Zl.displayName;const lc=n.forwardRef((a,s)=>{var o=a,{className:t}=o,r=xe(o,["className"]);return e.jsx(Jl,L({ref:s,className:Be(Po({variant:"outline"}),"mt-2 sm:mt-0",t)},r))});lc.displayName=Jl.displayName;function Np(t){return t?t.split(" ").slice(0,2).map(r=>r[0]).join("").toUpperCase():"?"}function kp(t){if(!t)return"";const r=Date.now()-new Date(t).getTime(),s=Math.floor(r/6e4);if(s<1)return"agora";if(s<60)return`${s}min`;const a=Math.floor(s/60);return a<24?`${a}h`:`${Math.floor(a/24)}d`}function _p({children:t,isOpen:r,onOpen:s,onClose:a,onDelete:o}){const i=n.useRef(0),l=n.useRef(0),f=n.useRef(0),p=n.useRef(!1),[g,c]=n.useState(0),x=80,d=60,u=n.useCallback(_=>{i.current=_.touches[0].clientX,l.current=_.touches[0].clientY,f.current=0,p.current=!1},[]),m=n.useCallback(_=>{const y=i.current-_.touches[0].clientX,k=Math.abs(_.touches[0].clientY-l.current);if(!p.current&&k>Math.abs(y)||(Math.abs(y)>10&&(p.current=!0),!p.current))return;let E;r?E=Math.min(x,Math.max(0,x+y)):E=Math.max(0,Math.min(x,y)),f.current=y,c(E)},[r]),b=n.useCallback(()=>{if(!p.current){r&&a();return}p.current=!1,r?g<x-d?(a(),c(0)):c(x):g>=d?(s(),c(x)):c(0)},[r,g,s,a]),v=n.useRef(r);n.useEffect(()=>{v.current!==r&&(v.current=r,r||c(0))},[r]);const w=r&&!p.current?x:g;return e.jsxs("div",{className:"relative overflow-hidden",children:[e.jsx("div",{className:"absolute right-0 top-0 bottom-0 flex items-center justify-center",style:{width:x,background:"hsl(var(--destructive, 0 84% 60%))"},children:e.jsxs("button",{onClick:_=>{_.stopPropagation(),o()},className:"flex flex-col items-center gap-1 text-white",children:[e.jsx(Vt,{size:20}),e.jsx("span",{className:"text-[10px] font-bold",children:"Excluir"})]})}),e.jsx("div",{onTouchStart:u,onTouchMove:m,onTouchEnd:b,className:"relative bg-background",style:{transform:`translateX(-${w}px)`,transition:p.current?"none":"transform 0.25s ease-out"},children:t})]})}function Sp({conversations:t,loading:r,userId:s,onBack:a,onOpenChat:o,onCreateConversation:i,onDeleteConversation:l}){const[f,p]=n.useState(""),[g,c]=n.useState(!1),[x,d]=n.useState(null),[u,m]=n.useState(null),b=n.useRef(0),v=n.useRef(0),w=n.useRef(!1),_=S=>{const R=S.touches[0].clientX;R<window.innerWidth*.4&&(b.current=R,v.current=S.touches[0].clientY,w.current=!0)},y=S=>{if(!w.current)return;w.current=!1;const R=S.changedTouches[0].clientX-b.current,z=Math.abs(S.changedTouches[0].clientY-v.current);R>60&&z<R*.7&&a()},k=S=>S.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim(),E=f.trim()?t.filter(S=>{var R;
287return k((R=S.other_user.name)!=null?R:"").includes(k(f))}):t;return e.jsxs("div",{className:"flex flex-col h-full bg-background",onTouchStart:_,onTouchEnd:y,style:{overscrollBehavior:"contain",paddingTop:"max(env(safe-area-inset-top), 12px)"},children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 pt-4 pb-3",children:[e.jsx("button",{onClick:a,className:"w-10 h-10 rounded-full flex items-center justify-center shrink-0 active:scale-95 transition-transform",style:{background:"rgba(255,255,255,0.06)",border:"1px solid rgba(255,255,255,0.1)"},children:e.jsx(Ct,{size:20,className:"text-foreground/70"})}),e.jsx("h1",{className:"text-xl font-black text-foreground flex-1",children:"Mensagens"}),e.jsx("button",{onClick:()=>c(!0),className:"w-10 h-10 rounded-full flex items-center justify-center shrink-0 active:scale-95 transition-transform",style:{background:"rgba(255,255,255,0.06)",border:"1px solid rgba(255,255,255,0.1)"},children:e.jsx(hr,{size:20,className:"text-foreground/70"})})]}),e.jsx("div",{className:"px-5 pb-3",children:e.jsxs("div",{className:"flex items-center gap-2 px-4 rounded-xl",style:{height:42,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)"},children:[e.jsx(pr,{size:16,className:"text-muted-foreground shrink-0"}),e.jsx("input",{type:"text",value:f,onChange:S=>p(S.target.value),placeholder:"Buscar conversa...",className:"flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground outline-none"}),f&&e.jsx("button",{onClick:()=>p(""),children:e.jsx(Je,{size:14,className:"text-muted-foreground"})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto pb-40",children:r?e.jsx("div",{className:"flex flex-col gap-2 px-5",children:[...Array(4)].map((S,R)=>e.jsx("div",{className:"h-16 rounded-xl animate-pulse",style:{background:"rgba(255,255,255,0.03)"}},R))}):E.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-48 gap-3 text-center",children:[e.jsx("span",{className:"text-3xl",children:"ð¬"}),e.jsx("p",{className:"text-sm font-semibold text-muted-foreground",children:f.trim()?"Nenhuma conversa encontrada":"Nenhuma mensagem ainda"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Toque no ",e.jsx("strong",{children:"+"})," para iniciar uma ",f.trim()?"nova conversa":"conversa"]})]}):e.jsx("div",{className:"flex flex-col",children:E.map(S=>{var R,z,j;return e.jsx(_p,{isOpen:x===S.id,onOpen:()=>d(S.id),onClose:()=>d(null),onDelete:()=>{d(null),m(S.id)},children:e.jsxs("button",{onClick:()=>{if(x){d(null);return}o(S.id,S.other_user)},className:"flex items-center gap-3 px-5 py-3 text-left transition-colors active:bg-white/5 w-full",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsxs(ut,{className:"h-12 w-12 border border-border",children:[S.other_user.avatar_url?e.jsx(Ze,{src:S.other_user.avatar_url,alt:(R=S.other_user.name)!=null?R:"",className:"object-cover"}):null,e.jsx(ft,{className:"text-xs font-bold text-white",style:{background:"hsl(var(--setverso-red))"},children:Np(S.other_user.name)})]}),S.unread_count>0&&e.jsx("div",{className:"absolute -top-1 -right-1 w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-bold text-white",style:{background:"hsl(var(--setverso-red))"},children:S.unread_count>9?"9+":S.unread_count})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:`text-sm truncate ${S.unread_count>0?"font-bold text-foreground":"font-semibold text-foreground/80"}`,children:(z=S.other_user.name)!=null?z:"Membro"}),e.jsx("span",{className:"text-[11px] text-muted-foreground shrink-0",children:kp(S.last_message_at)})]}),e.jsx("p",{className:`text-xs truncate mt-0.5 ${S.unread_count>0?"text-foreground/70 font-medium":"text-muted-foreground"}`,children:(j=S.last_message_text)!=null?j:"Nova conversa"})]})]})},S.id)})})}),e.jsx(wp,{open:!!u,onOpenChange:S=>{S||m(null)},children:e.jsxs(sc,{className:"max-w-[calc(100%-3rem)] rounded-2xl",children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Excluir conversa?"}),e.jsx(oc,{children:"A conversa será apagada para ambos os participantes. Essa ação não pode ser desfeita."})]}),e.jsxs(nc,{children:[e.jsx(lc,{children:"Cancelar"}),e.jsx(ic,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{u&&l(u),m(null)},children:"Excluir"})]})]})}),e.jsx(lp,{open:g,onClose:()=>c(!1),userId:s,onSelect:(S,R)=>{c(!1);const z=t.find(j=>j.other_user.id===S);z?o(z.id,R):(o(null,R),i(S).then(j=>
287{j&&o(j,R)}))}})]})}const ar=Se;function Cp(t,r,s){const[a,o]=n.useState([]),[i,l]=n.useState(!0),f=n.useRef({}),p=n.useRef(s);n.useEffect(()=>{p.current=s},[s]);const g=n.useCallback(()=>Q(this,null,function*(){if(!t){o([]),l(!1);return}const{data:d}=yield ar.from("messages").select("*").eq("conversation_id",t).order("created_at",{ascending:!0}),u=d!=null?d:[];o(m=>{const b=m.filter(v=>v.id.startsWith("optimistic-")&&!u.some(w=>w.sender_id===v.sender_id&&w.content===v.content));return[...u,...b]}),l(!1)}),[t]);n.useEffect(()=>{g()},[g]),n.useEffect(()=>{if(!t||!r)return;Q(this,null,function*(){yield ar.from("messages").update({read_at:new Date().toISOString()}).eq("conversation_id",t).neq("sender_id",r).is("read_at",null)})},[t,r,a]),n.useEffect(()=>{if(t)return nn(`messages:${t}`,{type:"postgres_changes",event:"INSERT",schema:"public",table:"messages",filter:`conversation_id=eq.${t}`},d=>{const u=d.new;o(m=>{if(m.find(v=>v.id===u.id))return m;const b=m.findIndex(v=>v.id.startsWith("optimistic-")&&v.sender_id===u.sender_id&&v.content===u.content);if(b!==-1){const v=[...m];return v[b]=u,v}return[...m,u]}),u.sender_id!==r&&ar.from("messages").update({read_at:new Date().toISOString()}).eq("id",u.id).then(()=>{})})},[t,r]),n.useEffect(()=>{if(!t||!r)return;const d=Se.channel(`conv-presence:${t}`,{config:{presence:{key:r}}}),u=()=>{var m;f.current=(m=d.presenceState())!=null?m:{}};return d.on("presence",{event:"sync"},u).on("presence",{event:"join"},u).on("presence",{event:"leave"},u).subscribe(m=>{m==="SUBSCRIBED"&&d.track({user_id:r,online_at:Date.now()})}),()=>{try{d.untrack()}catch(m){}Se.removeChannel(d),f.current={}}},[t,r]);const c=n.useCallback(d=>Q(this,null,function*(){var v;if(!t||!r||!d.trim())return;const u={id:`optimistic-${Date.now()}`,conversation_id:t,sender_id:r,content:d.trim(),read_at:null,created_at:new Date().toISOString()};o(w=>[...w,u]);const m=p.current;let b=!1;if(m){const w=f.current||{},_=!!((v=w[m])!=null&&v.length),y=Object.values(w).some(k=>Array.isArray(k)&&k.some(E=>(E==null?void 0:E.user_id)===m));b=_||y}ar.from("messages").insert({conversation_id:t,sender_id:r,content:d.trim(),skip_push:b}).then(()=>{})}),[t,r]),x=n.useCallback(d=>Q(this,null,function*(){if(o(m=>m.filter(b=>b.id!==d)),d.startsWith("optimistic-"))return;const{error:u}=yield ar.from("messages").delete().eq("id",d);u&&(console.error("[useMessages] delete failed",u),g())}),[g]);return n.useEffect(()=>{if(!t)return;const u=setInterval(()=>{document.visibilityState==="visible"&&g()},6e4),m=()=>{document.visibilityState==="visible"&&g()};return document.addEventListener("visibilitychange",m),()=>{clearInterval(u),document.removeEventListener("visibilitychange",m)}},[t,g]),{messages:a,loading:i,sendMessage:c,deleteMessage:x}}const Ep=/((?:https?:\/\/|www\.)[^\s<]+)/gi;function cc(t){try{const r=new URL(t.startsWith("http")?t:`https://${t}`),s=r.hostname.toLowerCase().replace(/^www\./,"");if(s==="setverso.com"||s.endsWith(".setverso.com"))return`${r.pathname}${r.search}${r.hash}`||"/"}catch(r){}return null}function Rp(t,r){const s=cc(r);s&&(t.preventDefault(),Sc(s)||(window.location.href=s))}function Mp(t){return t.split(Ep).map((s,a)=>
287{if(a%2===1){const o=s.startsWith("http")?s:`https://${s}`,i=cc(o);return e.jsx("a",{href:o,onClick:l=>Rp(l,o),target:i?void 0:"_blank",rel:i?void 0:"noopener noreferrer","data-external":i?void 0:"true",className:"underline break-all",style:{color:"inherit",textUnderlineOffset:2},children:s},a)}return e.jsx("span",{children:s},a)})}function no(t){return t?t.split(" ").slice(0,2).map(r=>r[0]).join("").toUpperCase():"?"}function Ap(t){return new Date(t).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}function Pp(t){const r=new Date(t),s=new Date,a=new Date(s);return a.setDate(a.getDate()-1),r.toDateString()===s.toDateString()?"Hoje":r.toDateString()===a.toDateString()?"Ontem":r.toLocaleDateString("pt-BR",{day:"2-digit",month:"short"})}function Tp({conversationId:t,otherUser:r,userId:s,onBack:a}){var Ne,Z,me,Me,te,we,Pe,oe;const o=!t,{messages:i,loading:l,sendMessage:f,deleteMessage:p}=Cp(t,s,(r==null?void 0:r.id)||null),[g,c]=n.useState(""),[x,d]=n.useState(!1),[u,m]=n.useState(null),[b,v]=n.useState(null),[w,_]=n.useState(!1),[y,k]=n.useState(null),[E,S]=n.useState(null),[R,z]=n.useState(!1);n.useEffect(()=>{const O=(r==null?void 0:r.id)||(E==null?void 0:E.id);if(!O){z(!1);return}let H=!1;const ce=Se;return Q(this,null,function*(){const{data:V}=yield ce.from("audience").select("status, stage").eq("user_id",O).maybeSingle();if(H)return;if(!V){z(!1);return}if(V.stage==="admin"){z(!1);return}const C=["cancelled","inadimplente","expired","inactive"].includes(V.status);z(C)}),()=>{H=!0}},[r==null?void 0:r.id,E==null?void 0:E.id]),n.useEffect(()=>{if(r!=null&&r.name&&(r!=null&&r.avatar_url)){S(null);return}let O=!1;const H=Se;return Q(this,null,function*(){let ce=(r==null?void 0:r.id)||null;if(!ce&&t&&s){const{data:C}=yield H.from("conversations").select("user1_id,user2_id").eq("id",t).maybeSingle();if(O||!C)return;ce=C.user1_id===s?C.user2_id:C.user1_id}if(!ce)return;const{data:V}=yield H.from("profiles").select("name, avatar_url").eq("id",ce).maybeSingle();O||!V||S({id:ce,name:V.name,avatar_url:V.avatar_url})}),()=>{O=!0}},[r==null?void 0:r.id,r==null?void 0:r.name,r==null?void 0:r.avatar_url,t,s]),n.useEffect(()=>{if(!t)return;const O=window==null?void 0:window.ReactNativeWebView,H=ce=>{var V;try{(V=O==null?void 0:O.postMessage)==null||V.call(O,JSON.stringify(ce))}catch(C){}try{window.dispatchEvent(new CustomEvent("nativeBridgeMessage",{detail:ce}))}catch(C){}};return H({type:"CONVERSATION_OPENED",conversationId:t}),()=>{H({type:"CONVERSATION_CLOSED",conversationId:t})}},[t]);const j={id:r.id||(E==null?void 0:E.id)||"",name:(Z=(Ne=r.name)!=null?Ne:E==null?void 0:E.name)!=null?Z:null,avatar_url:(Me=(me=r.avatar_url)!=null?me:E==null?void 0:E.avatar_url)!=null?Me:null},M=()=>Q(this,null,function*(){var K;if(_(!0),(y==null?void 0:y.id)===r.id)return;const O=Se,[{data:H},{data:ce},{data:V},{data:C}]=yield Promise.all([O.from("profiles").select("*").eq("id",r.id).maybeSingle(),O.from("user_tags").select("tag_id").eq("user_id",r.id),O.from("tags").select("id, name, color, emoji"),O.from("user_roles").select("role").eq("user_id",r.id)]);if(!H)return;const h={};(V!=null?V:[]).forEach(ie=>{var Ae;h[ie.id]={id:ie.id,name:ie.name,color:ie.color,emoji:(Ae=ie.emoji)!=null?Ae:null}});const T=(ce!=null?ce:[]).map(ie=>h[ie.tag_id]).filter(Boolean),I=(C!=null?C:[]).some(ie=>ie.role==="admin");k(se(L({},H),{skills:(K=H.skills)!=null?K:[],tags:T,isAdmin:I}))}),[$,q]=n.useState(()=>Jr());n.useEffect(()=>hi(()=>q(Jr())),[]);const ne=n.useRef(null),ae=n.useRef(null),J=n.useRef(null),je=n.useRef(!1),ke=n.useRef(0),ve=n.useRef(0),P=n.useRef(!1),N=O=>{const H=O.touches[0].clientX;H<window.innerWidth*.4&&(ke.current=H,ve.current=O.touches[0].clientY,P.current=!0)},Y=O=>{if(!P.current)return;P.current=!1;const H=O.changedTouches[0].clientX-ke.current,ce=Math.abs(O.changedTouches[0].clientY-ve.current);H>60&&ce<H*.7&&a()},F=n.useRef(!0),G=()=>{const O=ne.current;if(!O)return;const H=O.scrollHeight-O.scrollTop-O.clientHeight;F.current=H<80},ee=n.useCallback(()=>{F.current=!0;const O=ne.current;O&&(O.scrollTop=O.scrollHeight)},[]),re=n.useCallback(()=>{ee(),requestAnimationFrame(ee),window.setTimeout(ee,40),window.setTimeout(ee,140),window.setTimeout(ee,320)},[ee]);n.useEffect(()=>{ne.current&&F.current&&(ne.current.scrollTop=ne.current.scrollHeight)},[i]);const be=()=>Q(this,null,function*(){var H;if(!g.trim()||x||o)return;F.current=!0,d(!0);const O=g;c(""),yield f(O),d(!1);try{window.dispatchEvent(new CustomEvent("conversations:refresh"))}catch(ce){}(H=ae.current)==null||H.focus()}),ge=O=>{O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),be())},[le,fe]=n.useState(()=>({offsetTop:0,height:typeof window!="undefined"?window.innerHeight:0}));n.useEffect(()=>
287{const O=window.visualViewport;let H=null;const ce=()=>{fe(O?{offsetTop:O.offsetTop,height:O.height}:{offsetTop:0,height:window.innerHeight})};ce(),O==null||O.addEventListener("resize",ce),O==null||O.addEventListener("scroll",ce),window.addEventListener("resize",ce);const V=ae.current,C=()=>{const T=performance.now(),I=()=>{ce(),performance.now()-T<1200&&(H=requestAnimationFrame(I))};H&&cancelAnimationFrame(H),H=requestAnimationFrame(I)},h=()=>{re(),C(),requestAnimationFrame(()=>{try{V==null||V.scrollIntoView({block:"end"})}catch(T){}})};return V==null||V.addEventListener("focus",h),V==null||V.addEventListener("blur",C),()=>{O==null||O.removeEventListener("resize",ce),O==null||O.removeEventListener("scroll",ce),window.removeEventListener("resize",ce),V==null||V.removeEventListener("focus",h),V==null||V.removeEventListener("blur",C),H&&cancelAnimationFrame(H)}},[re]),n.useEffect(()=>{let O=null;return Q(this,null,function*(){try{const H=yield Lt(()=>import("./index-XIFkKqiZ.js"),__vite__mapDeps([7,5])).catch(()=>null);if(!(H!=null&&H.Keyboard))return;const ce=K=>{fe({offsetTop:0,height:window.innerHeight-((K==null?void 0:K.keyboardHeight)||0)}),re()},V=()=>{fe({offsetTop:0,height:window.innerHeight})},C=yield H.Keyboard.addListener("keyboardWillShow",ce),h=yield H.Keyboard.addListener("keyboardDidShow",ce),T=yield H.Keyboard.addListener("keyboardWillHide",V),I=yield H.Keyboard.addListener("keyboardDidHide",V);O=()=>{C.remove(),h.remove(),T.remove(),I.remove()}}catch(H){}}),()=>{O==null||O()}},[re]),n.useEffect(()=>{const O=document.body.style.overflow,H=document.body.style.position,ce=document.body.style.width;return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",()=>{document.body.style.overflow=O,document.body.style.position=H,document.body.style.width=ce}},[]);let pe="";return e.jsxs("div",{className:"flex flex-col bg-background",onTouchStart:N,onTouchEnd:Y,style:{position:"fixed",left:0,right:0,top:le.offsetTop,height:le.height,overscrollBehavior:"contain",paddingTop:"max(env(safe-area-inset-top), 12px)",zIndex:50},children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 shrink-0",style:{borderBottom:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx("button",{onClick:a,className:"w-10 h-10 rounded-full flex items-center justify-center shrink-0 active:scale-95 transition-transform",style:{background:"rgba(255,255,255,0.06)",border:"1px solid rgba(255,255,255,0.1)"},children:e.jsx(Ct,{size:20,className:"text-foreground/70"})}),e.jsxs("button",{onClick:M,className:"flex items-center gap-3 flex-1 min-w-0 active:opacity-70 transition-opacity text-left",children:[e.jsxs(ut,{className:"h-9 w-9 border border-border shrink-0",children:[j.avatar_url?e.jsx(Ze,{src:j.avatar_url,alt:(te=j.name)!=null?te:"",className:"object-cover"}):null,e.jsx(ft,{className:"text-xs font-bold text-white",style:{background:"hsl(var(--setverso-red))"},children:no(j.name)})]}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm font-bold text-foreground truncate",children:(we=j.name)!=null?we:"Membro"})})]})]}),e.jsx("div",{ref:ne,onScroll:G,className:"flex-1 overflow-y-auto px-4 py-4 flex flex-col",children:e.jsx("div",{className:"mt-auto w-full",children:l?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx("div",{className:"w-5 h-5 rounded-full border-2 border-muted-foreground/20 border-t-muted-foreground/60 animate-spin"})}):i.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center",children:[e.jsxs(ut,{className:"h-16 w-16 border border-border",children:[j.avatar_url?e.jsx(Ze,{src:j.avatar_url,alt:(Pe=j.name)!=null?Pe:"",className:"object-cover"}):null,e.jsx(ft,{className:"text-lg font-bold text-white",style:{background:"hsl(var(--setverso-red))"},children:no(j.name)})]}),e.jsx("p",{className:"text-sm font-semibold text-foreground mt-2",children:(oe=j.name)!=null?oe:"Membro"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Inicie uma conversa"})]}):i.map((O,H)=>{const ce=O.sender_id===s,V=new Date(O.created_at).toDateString();let C=!1;return V!==pe&&(C=!0,pe=V),e.jsxs("div",{children:[C&&e.jsx("div",{className:"flex justify-center my-4",children:e.jsx("span",{className:"text-[10px] font-semibold px-3 py-1 rounded-full",style:{background:"rgba(255,255,255,0.06)",color:"rgba(255,255,255,0.4)"},children:Pp(O.created_at)})}),e.jsx("div",{className:`flex mb-1.5 ${ce?"justify-end":"justify-start"}`,children:e.jsxs("div",{className:"max-w-[80%] px-3.5 py-2.5 rounded-2xl cursor-pointer active:opacity-80",style:{background:ce?"hsl(var(--setverso-red) / 0.85)":"var(--sv-surface-active)",borderBottomRightRadius:ce?"6px":"16px",borderBottomLeftRadius:ce?"16px":"6px",WebkitUserSelect:"text",userSelect:"text",WebkitTouchCallout:"default"},onTouchStart:h=>{const T=h.touches[0],I=T.clientX,K=T.clientY;je.current=!1,J.current=window.setTimeout(()=>{var Ae;const ie=(Ae=window.getSelection)==null?void 0:Ae.call(window);ie&&ie.toString().length>0||(je.current=!0,navigator.vibrate&&navigator.vibrate(30),v({x:I,y:K}),m(O))},550)},onTouchEnd:()=>{J.current&&(clearTimeout(J.current),J.current=null)},onTouchMove:()=>{J.current&&(clearTimeout(J.current),J.current=null)},onContextMenu:h=>{h.preventDefault(),v({x:h.clientX,y:h.clientY}),m(O)},children:[e.jsx("p",{className:"text-sm text-foreground leading-relaxed whitespace-pre-wrap break-words",children:Mp(O.content)}),e.jsxs("div",{className:"flex items-center justify-end gap-1 mt-1",children:[e.jsx("span",{className:"text-[10px]",style:{color:ce?"rgba(255,255,255,0.6)":"var(--sv-text-tertiary)"},children:Ap(O.created_at)}),ce&&e.jsx(Zc,{size:14,className:"shrink-0",style:{color:O.read_at?"#53bdeb"
287:"rgba(255,255,255,0.5)"}})]})]})})]},O.id)})})}),e.jsx("div",{className:"shrink-0 px-4 pt-2",style:(()=>{const O=typeof window!="undefined"&&le.height<window.innerHeight-50,H="env(safe-area-inset-bottom, 0px)";return{paddingBottom:O?0:$?`calc(${H} + 48px)`:H,marginBottom:0}})(),children:R?e.jsx("div",{className:"px-4 py-3 rounded-2xl bg-muted/40 text-center",style:{border:"1px solid hsl(var(--border))"},children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"Essa pessoa não faz mais parte do SetVerso"})}):e.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 rounded-2xl bg-muted/40",style:{border:"1px solid hsl(var(--border))"},children:[e.jsx("textarea",{ref:ae,value:g,onChange:O=>{c(O.target.value),O.target.style.height="auto",O.target.style.height=Math.min(O.target.scrollHeight,100)+"px"},onKeyDown:ge,placeholder:"Digite sua mensagem...",rows:1,className:"flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground outline-none resize-none min-h-[20px] max-h-[100px] py-1",style:{lineHeight:"1.3"}}),e.jsx("button",{onClick:be,disabled:!g.trim()||x,className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0 transition-all active:scale-90 disabled:opacity-30",style:{background:"hsl(var(--setverso-red))"},children:e.jsx(Vs,{size:14,className:"text-white"})})]})}),u&&b&&(()=>{const ce=(u.sender_id===s?2:1)*44+8,V=typeof window!="undefined"?window.innerWidth:360,C=typeof window!="undefined"?window.innerHeight:640;let h=b.x-200/2;h=Math.max(8,Math.min(V-200-8,h));let T=b.y-ce-12;return T<8&&(T=Math.min(C-ce-8,b.y+12)),e.jsx("div",{className:"fixed inset-0 z-50",onClick:()=>{m(null),v(null)},children:e.jsxs("div",{className:"absolute rounded-2xl overflow-hidden shadow-2xl animate-in fade-in zoom-in-95",style:{left:h,top:T,width:200,background:"hsl(var(--background))",border:"1px solid rgba(255,255,255,0.12)",boxShadow:"0 10px 30px rgba(0,0,0,0.5)"},onClick:I=>I.stopPropagation(),children:[e.jsxs("button",{onClick:()=>Q(this,null,function*(){var I;try{if((I=navigator.clipboard)!=null&&I.writeText)yield navigator.clipboard.writeText(u.content);else{const K=document.createElement("textarea");K.value=u.content,K.style.position="fixed",K.style.opacity="0",document.body.appendChild(K),K.select(),document.execCommand("copy"),document.body.removeChild(K)}navigator.vibrate&&navigator.vibrate(20)}catch(K){}m(null),v(null)}),className:"w-full flex items-center gap-3 px-4 py-3 text-left active:bg-white/5 text-foreground",children:[e.jsx(Uc,{size:16}),e.jsx("span",{className:"text-sm font-semibold",children:"Copiar"})]}),u.sender_id===s&&e.jsxs("button",{onClick:()=>{p(u.id),m(null),v(null)},className:"w-full flex items-center gap-3 px-4 py-3 text-left active:bg-white/5",style:{color:"hsl(var(--setverso-red))",borderTop:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx(Vt,{size:16}),e.jsx("span",{className:"text-sm font-semibold",children:"Excluir"})]})]})})})(),e.jsx(Il,{member:y,open:w,onClose:()=>_(!1),currentUserId:s})]})}const st=Se;function Dp(t,r){let s=null;return()=>{s&&clearTimeout(s),s=setTimeout(t,r)}}const or=10;function zp(){const[t,r]=n.useState([]),[s,a]=n.useState(!0),[o,i]=n.useState(!1),[l,f]=n.useState(!0),[p,g]=n.useState(null),[c,x]=n.useState(null),[d,u]=n.useState(!1),[m,b]=n.useState(!0),[v,w]=n.useState(null),_=P=>Q(this,null,function*(){const[{data:N},{data:Y}]=yield Promise.all([st.from("user_roles").select("role").eq("user_id",P).eq("role","admin").maybeSingle(),st.from("profiles").select("*").eq("id",P).maybeSingle()]);u(!!N),w(Y!=null?Y:null)});n.useEffect(()=>{let P=!0;Se.auth.getSession().then(F=>Q(this,[F],function*({data:Y}){var ee,re,be;if(!P)return;const G=(be=(re=(ee=Y.session)==null?void 0:ee.user)==null?void 0:re.id)!=null?be:null;x(G),G&&(yield _(G)),P&&b(!1)}));const{data:N}=Se.auth.onAuthStateChange((Y,F)=>{var ee,re;if(!P)return;const G=(re=(ee=F==null?void 0:F.user)==null?void 0:ee.id)!=null?re:null;x(G),G?setTimeout(()=>{P&&_(G)},0):(u(!1),w(null))});return()=>{P=!1,N.subscription.unsubscribe()}},[]);const y=n.useRef(null);n.useEffect(()=>{y.current=c},[c]);const k=n.useRef(!1);n.useEffect(()=>{k.current=d},[d]);const E=n.useRef(null),S=n.useRef(!1),R=n.useRef(!0),z=n.useCallback(P=>Q(this,null,function*(){var ce,V,C,h,T;P||a(!0),E.current=null,R.current=!0,S.current=!1;const N=y.current,Y=k.current,F=st.from("posts").select("*, profiles ( name, username, avatar_url, role_title ), spaces ( name, emoji, post_permission, comments_enabled, show_in_feed, public_access )").eq("is_pinned",!0).order("created_at",{ascending:!1}),G=st.from("posts").select("*, profiles ( name, username, avatar_url, role_title ), spaces ( name, emoji, post_permission, comments_enabled, show_in_feed, public_access )").eq("is_pinned",!1).order("created_at",{ascending:!1}).order("id",{ascending:!1}
287).limit(or),ee=N?st.from("post_likes").select("post_id").eq("user_id",N):Promise.resolve({data:[]}),re=N&&!Y?Q(this,null,function*(){const{data:I}=yield st.from("user_access_groups").select("group_id").eq("user_id",N);if(!I||I.length===0)return{allowedSpaceIds:new Set};const K=I.map(Ae=>Ae.group_id),{data:ie}=yield st.from("access_group_spaces").select("space_id").in("group_id",K);return{allowedSpaceIds:new Set((ie!=null?ie:[]).map(Ae=>Ae.space_id))}}):Promise.resolve(null),[be,ge,le,fe]=yield Promise.all([F,G,ee,re]);if(ge.error){g(ge.error.message),a(!1);return}const pe=new Set(((ce=le.data)!=null?ce:[]).map(I=>I.post_id)),Ne=(V=be.data)!=null?V:[],Z=(C=ge.data)!=null?C:[],me=new Set(Ne.map(I=>I.id));let Me=[...Ne,...Z.filter(I=>!me.has(I.id))];const te=Z.length>=or;if(Me=Me.filter(I=>{var K;return((K=I.spaces)==null?void 0:K.show_in_feed)!==!1}),!Y&&fe){const I=fe.allowedSpaceIds;Me=Me.filter(K=>{var ie;return K.space_id&&(I.has(K.space_id)||((ie=K.spaces)==null?void 0:ie.public_access)===!0)})}else!Y&&!fe&&(Me=[]);const we=Me.map(I=>I.id);let Pe={},oe={};if(we.length>0){const K=[],ie=[];for(let Ve=0;Ve<we.length;Ve+=200){const Ge=we.slice(Ve,Ve+200);K.push(st.from("post_likes").select("post_id").in("post_id",Ge)),ie.push(st.from("comments").select("post_id").in("post_id",Ge))}const[Ae,Te]=yield Promise.all([Promise.all(K),Promise.all(ie)]);for(const Ve of Ae)((h=Ve.data)!=null?h:[]).forEach(Ge=>{var Le;Pe[Ge.post_id]=((Le=Pe[Ge.post_id])!=null?Le:0)+1});
287for(const Ve of Te)((T=Ve.data)!=null?T:[]).forEach(Ge=>{var Le;oe[Ge.post_id]=((Le=oe[Ge.post_id])!=null?Le:0)+1})}const O=Me.map(I=>{var K,ie;return se(L({},I),{attachments:Array.isArray(I.attachments)?I.attachments:[],likes_count:(K=Pe[I.id])!=null?K:0,user_liked:pe.has(I.id),comments_count:(ie=oe[I.id])!=null?ie:0})}),H=O.filter(I=>!I.is_pinned);if(H.length>0){const I=H[H.length-1];E.current={createdAt:I.created_at,id:I.id}}r(O),R.current=te,f(te),a(!1)}),[]),j=n.useCallback(()=>Q(this,null,function*(){var Me,te,we,Pe;if(S.current||!R.current||!E.current)return;S.current=!0,i(!0);const P=y.current,N=k.current,Y=E.current,F=or+20,G=st.from("posts").select("*, profiles ( name, username, avatar_url, role_title ), spaces ( name, emoji, post_permission, comments_enabled, show_in_feed, public_access )").eq("is_pinned",!1).order("created_at",{ascending:!1}).order("id",{ascending:!1}).lte("created_at",Y.createdAt).limit(F),ee=P&&!N?Q(this,null,function*(){const{data:oe}=yield st.from("user_access_groups").select("group_id").eq("user_id",P);if(!oe||oe.length===0)return{allowedSpaceIds:new Set};const O=oe.map(ce=>ce.group_id),{data:H}=yield st.from("access_group_spaces").select("space_id").in("group_id",O);return{allowedSpaceIds:new Set((H!=null?H:[]).map(ce=>ce.space_id))}}):Promise.resolve(null),[re,be]=yield Promise.all([G,ee]);if(re.error){S.current=!1,i(!1);return}let ge=((Me=re.data)!=null?Me:[]).filter(oe=>oe.created_at===Y.createdAt?oe.id<Y.id:!0);const le=((te=re.data)!=null?te:[]).length>=F;if(ge=ge.slice(0,or),ge=ge.filter(oe=>{var O;return((O=oe.spaces)==null?void 0:O.show_in_feed)!==!1}),!N&&be){const oe=be.allowedSpaceIds;ge=ge.filter(O=>{var H;return O.space_id&&(oe.has(O.space_id)||((H=O.spaces)==null?void 0:H.public_access)===!0)})}else!N&&!be&&(ge=[]);const fe=ge.map(oe=>oe.id);let pe={},Ne={};const Z=new Set;if(P&&fe.length>0){const{data:oe}=yield st.from("post_likes").select("post_id").eq("user_id",P).in("post_id",fe);(oe!=null?oe:[]).forEach(O=>Z.add(O.post_id))}if(fe.length>0){const[oe,O]=yield Promise.all([st.from("post_likes").select("post_id").in("post_id",fe),st.from("comments").select("post_id").in("post_id",fe)]);((we=oe.data)!=null?we:[]).forEach(H=>{var ce;pe[H.post_id]=((ce=pe[H.post_id])!=null?ce:0)+1}
287),((Pe=O.data)!=null?Pe:[]).forEach(H=>{var ce;Ne[H.post_id]=((ce=Ne[H.post_id])!=null?ce:0)+1})}const me=ge.map(oe=>{var O,H;return se(L({},oe),{attachments:Array.isArray(oe.attachments)?oe.attachments:[],likes_count:(O=pe[oe.id])!=null?O:0,user_liked:Z.has(oe.id),comments_count:(H=Ne[oe.id])!=null?H:0})});if(r(oe=>{const O=new Set(oe.map(ce=>ce.id)),H=me.filter(ce=>!O.has(ce.id));return[...oe,...H]}),me.length>0){const oe=me[me.length-1];E.current={createdAt:oe.created_at,id:oe.id}}R.current=le,f(le),S.current=!1,i(!1),le&&me.length<or/2&&setTimeout(()=>j(),100)}),[]);n.useEffect(()=>{m||z()},[m,c,d]);const M=n.useRef(z);n.useEffect(()=>{M.current=z},[z]);const $=n.useRef(Dp(()=>M.current(!0),500)).current;n.useEffect(()=>{const P=()=>$(),N=F=>{var ee;const G=(ee=F.detail)==null?void 0:ee.postId;G&&r(re=>re.map(be=>{var ge;return be.id===G?se(L({},be),{comments_count:((ge=be.comments_count)!=null?ge:0)+1}):be}))},Y=F=>{var ee;const G=(ee=F.detail)==null?void 0:ee.postId;G&&r(re=>re.map(be=>{var ge;return be.id===G?se(L({},be),{comments_count:Math.max(((ge=be.comments_count)!=null?ge:1)-1,0)}):be}))};return window.addEventListener("access-groups-changed",P),window.addEventListener("comment-added",N),window.addEventListener("comment-removed",Y),()=>{window.removeEventListener("access-groups-changed",P),window.removeEventListener("comment-added",N),window.removeEventListener("comment-removed",Y)}},[]),n.useEffect(()=>{const P=()=>{document.visibilityState==="visible"&&$()};return document.addEventListener("visibilitychange",P),()=>{document.removeEventListener("visibilitychange",P)}},[]),n.useEffect(()=>{const P=xi(["posts_changed","spaces_changed","access_group_spaces_changed"],$),N=gi($);return()=>{P(),N()}},[]);const q=P=>Q(this,null,function*(){if(!c)return;const N=t.find(Y=>Y.id===P);N&&(r(Y=>Y.map(F=>{var G,ee;return F.id===P?se(L({},F),{user_liked:!F.user_liked,likes_count:F.user_liked?((G=F.likes_count)!=null?G:1)-1:((ee=F.likes_count)!=null?ee:0)+1}):F})),N.user_liked?yield st.from("post_likes").delete().eq("post_id",P).eq("user_id",c):yield st.from("post_likes").insert({post_id:P,user_id:c}))}),ne=P=>{var F,G,ee,re,be,ge,le,fe,pe,Ne,Z,me,Me;if(!c)return"";const N=crypto.randomUUID(),Y={id:N,author_id:c,space_id:(F=P.space_id)!=null?F:null,title:P.title,preview:(G=P.preview)!=null?G:null,content:(ee=P.content)!=null?ee:null,perfis:(re=P.perfis)!=null?re:null,local:(be=P.local)!=null?be:null,data_projeto:(ge=P.data_projeto)!=null?ge:null,horario:(le=P.horario)!=null?le:null,cache:(fe=P.cache)!=null?fe:null,requisitos:(pe=P.requisitos)!=null?pe:null,observacoes:(Ne=P.observacoes)!=null?Ne:null,link_original:(Z=P.link_original)!=null?Z:null,attachments:(me=P.attachments)!=null?me:[],is_pinned:!1,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),profiles:v,spaces:P.spaceName?{name:P.spaceName,emoji:(Me=P.spaceEmoji)!=null?Me:""}:null,likes_count:0,user_liked:!1};return r(te=>[Y,...te]),N};return{posts:t,loading:s,loadingMore:o,hasMore:l,error:p,toggleLike:q,addOptimisticPost:ne,createPost:(P,N)=>Q(this,null,function*(){if(!c)throw new Error("Não autenticado");const Y=N!=null?N:ne(P),{data:F,error:G}=yield st.from("posts").insert({title:P.title,content:P.content,preview:P.preview,space_id:P.space_id,perfis:P.perfis,local:P.local,data_projeto:P.data_projeto,horario:P.horario,cache:P.cache,requisitos:P.requisitos,observacoes:P.observacoes,link_original:P.link_original,attachments:P.attachments,author_id:c}).select("*, profiles ( name, username, avatar_url, role_title ), spaces ( name, emoji )").single();if(G)throw r(ee=>ee.filter(re=>re.id!==Y)),G;r(ee=>ee.map(re=>re.id===Y?se(L({},F),{attachments:Array.isArray(F.attachments)?F.attachments:[],likes_count:0,user_liked:!1}):re))}),deletePost:P=>Q(this,null,function*(){const N=t.find(F=>F.id===P);r(F=>F.filter(G=>G.id!==P));const{error:Y}=yield st.from("posts").delete().eq("id",P);Y&&N&&(r(F=>[N,...F].sort((ee,re)=>ee.is_pinned!==re.is_pinned?ee.is_pinned?-1:1:new Date(re.created_at).getTime()-new Date(ee.created_at).getTime())),Ie.error("Erro ao excluir post. Tente novamente."))}),togglePin:P=>Q(this,null,function*(){const N=t.find(G=>
287G.id===P);if(!N)return;const Y=!N.is_pinned;r(G=>G.map(re=>re.id===P?se(L({},re),{is_pinned:Y}):re).sort((re,be)=>re.is_pinned!==be.is_pinned?re.is_pinned?-1:1:new Date(be.created_at).getTime()-new Date(re.created_at).getTime()));const{error:F}=yield st.from("posts").update({is_pinned:Y}).eq("id",P);F?(r(G=>G.map(ee=>ee.id===P?se(L({},ee),{is_pinned:!Y}):ee)),Ie.error("Erro ao fixar/desafixar post.")):Ie.success(Y?"Post fixado! ð":"Post desafixado.")}),updatePost:(P,N)=>Q(this,null,function*(){const Y=t;r(ee=>ee.map(re=>re.id===P?L(L({},re),N):re));const{data:F,error:G}=yield st.from("posts").update(N).eq("id",P).select("id");return G?(r(Y),Ie.error(`Erro ao editar post: ${G.message}`),!1):!F||F.length===0?(r(Y),Ie.error("Sem permissão para editar este post."),!1):(Ie.success("Post atualizado! âï¸"),!0)}),refetch:z,fetchMorePosts:j,refetchProfile:()=>{c&&_(c)},userId:c,isAdmin:d,authLoading:m,userProfile:v}}const hs=Se;function Ip(t,r,s=!1){const[a,o]=n.useState([]),[i,l]=n.useState(!0),f=n.useCallback(()=>Q(this,null,function*(){if(!t)return;l(!0);const{data:b}=yield hs.from("conversations").select("*").or(`user1_id.eq.${t},user2_id.eq.${t}`);if(!b||b.length===0){o([]),l(!1);return}const v=b.map(j=>j.user1_id===t?j.user2_id:j.user1_id),w=b.map(j=>j.id),[{data:_},{data:y},{data:k}]=yield Promise.all([hs.from("profiles").select("id, name, avatar_url").in("id",v),hs.from("messages").select("conversation_id").in("conversation_id",w).neq("sender_id",t).is("read_at",null),hs.from("messages").select("conversation_id, content, created_at").in("conversation_id",w).order("created_at",{ascending:!1})]),E={};
287(_!=null?_:[]).forEach(j=>{E[j.id]=j});const S={};(y!=null?y:[]).forEach(j=>{S[j.conversation_id]=(S[j.conversation_id]||0)+1});const R={};(k!=null?k:[]).forEach(j=>{R[j.conversation_id]||(R[j.conversation_id]={content:j.content,created_at:j.created_at})});const z=b.map(j=>{var q,ne,ae,J,je;const M=j.user1_id===t?j.user2_id:j.user1_id,$=R[j.id];return se(L({},j),{last_message_text:(q=$==null?void 0:$.content)!=null?q:null,last_message_at:(ae=(ne=$==null?void 0:$.created_at)!=null?ne:j.last_message_at)!=null?ae:null,other_user:(J=E[M])!=null?J:{id:M,name:null,avatar_url:null},unread_count:(je=S[j.id])!=null?je:0})});z.sort((j,M)=>{const $=j.last_message_at?new Date(j.last_message_at).getTime():0;return(M.last_message_at?new Date(M.last_message_at).getTime():0)-$}),o(z),l(!1)}),[t]);n.useEffect(()=>{f()},[f]);const p=n.useRef(f);n.useEffect(()=>{p.current=f},[f]);const g=n.useRef(a);n.useEffect(()=>{g.current=a},[a]);const c=n.useRef(r);n.useEffect(()=>{c.current=r},[r]);const x=n.useRef(t);n.useEffect(()=>{x.current=t},[t]),n.useEffect(()=>{if(!t||!s)return;const b=Se.channel(`conversations-realtime:${t}`).on("postgres_changes",{event:"*",schema:"public",table:"conversations"},()=>{p.current()}).on("postgres_changes",{event:"INSERT",schema:"public",table:"messages"},v=>{var S,R,z,j,M,$;p.current();const w=v.new;if(!w||w.sender_id===x.current||w.conversation_id===c.current)return;let _=!0;try{_=localStorage.getItem("notif_push")!=="false"}catch(q){}if(!_||!("Notification"in window)||Notification.permission!=="granted")return;const y=g.current.find(q=>q.id===w.conversation_id),k=(R=(S=y==null?void 0:y.other_user)==null?void 0:S.name)!=null?R:"Nova mensagem",E=(j=(z=y==null?void 0:y.other_user)==null?void 0:z.avatar_url)!=null?j:void 0;try{const q=new Notification(k,{body:($=(M=w.content)==null?void 0:M.substring(0,100))!=null?$:"",icon:E});q.onclick=()=>{window.focus(),q.close()}}catch(q){}}).on("postgres_changes",{event:"DELETE",schema:"public",table:"messages"},()=>{p.current()}).subscribe();return()=>{Se.removeChannel(b)}},[t,s]),n.useEffect(()=>{if(!t)return;const b=()=>{p.current()},v=()=>{document.visibilityState==="visible"&&p.current()};return window.addEventListener("conversations:refresh",b),document.addEventListener("visibilitychange",v),()=>{window.removeEventListener("conversations:refresh",b),document.removeEventListener("visibilitychange",v)}},[t]);const d=n.useCallback(b=>Q(this,null,function*(){if(!t)return null;const[v,w]=[t,b].sort(),{data:_}=yield hs.from("conversations").select("id").or(`and(user1_id.eq.${v},user2_id.eq.${w}),and(user1_id.eq.${w},user2_id.eq.${v})`).limit(1);if(_&&_.length>0)return _[0].id;const{data:y,error:k}=yield hs.from("conversations").insert({user1_id:v,user2_id:w}).select("id").single();return k?(console.error("Error creating conversation:",k),null):y.id}),[t]),u=n.useCallback(b=>Q(this,null,function*(){o(_=>_.filter(y=>y.id!==b));const{error:v}=yield hs.from("messages").delete().eq("conversation_id",b);v&&console.error("Error deleting messages:",v);const{error:w}=yield hs.from("conversations").delete().eq("id",b);w&&(console.error("Error deleting conversation:",w),f())}),[f]),m=n.useCallback(b=>{o(v=>v.map(w=>w.id===b?se(L({},w),{unread_count:0}):w))},[]);return{conversations:a,loading:i,refetch:f,createOrOpenConversation:d,deleteConversation:u,markConversationRead:m}}const Fr=new Map;function Lp({url:t}){const[r,s]=n.useState(()=>{var i;return(i=Fr.get(t))!=null?i:null}),a=n.useRef(null),o=n.useRef(!1);return n.useEffect(()=>{if(Fr.has(t)){s(Fr.get(t));return}if(o.current)return;o.current=!0;const i=document.createElement("video");i.crossOrigin="anonymous",i.preload="auto",i.muted=!0,i.playsInline=!0,i.src=t;const l=()=>{try{const g=document.createElement("canvas");g.width=i.videoWidth||640,g.height=i.videoHeight||360;const c=g.getContext("2d");if(c){c.drawImage(i,0,0,g.width,g.height);const x=g.toDataURL("image/jpeg",.7);x.length>5e3&&(Fr.set(t,x),s(x))}}catch(g){}p()},f=()=>{i.currentTime=.5},p=()=>{i.removeEventListener("seeked",l),i.removeEventListener("loadeddata",f),i.removeEventListener("error",p),i.src="",i.load()};return i.addEventListener("loadeddata",f),i.addEventListener("seeked",l),i.addEventListener("error",p),setTimeout(()=>{r||p()},8e3),()=>p()},[t]),e.jsx("div",{className:"sv-video-wrap mb-4",children:e.jsx("video",L({ref:a,src:`${t}
287#t=0.5`,controls:!0,playsInline:!0,preload:"auto",className:"w-full rounded-lg",style:{background:"hsl(var(--secondary))"}},r?{poster:r}:{}))})}const ao=["Feed","Espaços","Cursos","Membros","Ranking"],Fp="[email protected]",oo={feed:"Feed",espacos:"Espaços",cursos:"Cursos",membros:"Membros",ranking:"Ranking",notificacoes:"Notificações"},Op={Feed:"feed",Espaços:"espacos",Cursos:"cursos",Membros:"membros",Ranking:"ranking",Notificações:"notificacoes"};function ir(t){const r=Date.now()-new Date(t).getTime(),s=Math.floor(r/6e4);if(s<1)return"agora";if(s<60)return`${s}min atrás`;const a=Math.floor(s/60);if(a<24)return`${a}h atrás`;const o=Math.floor(a/24);if(o===1)return"1 dia atrás";if(o<30)return`${o} dias atrás`;const i=Math.floor(o/30);return i===1?"1 mês atrás":`${i} meses atrás`}function io({icon:t,label:r,storageKey:s}){const[a,o]=n.useState(()=>{try{const l=localStorage.getItem(s);if(l!==null)return l==="true"}catch(l){}return s!=="notif_push"}),i=l=>{o(l);try{localStorage.setItem(s,String(l))}catch(f){}};return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"18px 16px",borderRadius:16},children:[e.jsx(t,{size:22,style:{flexShrink:0,color:"var(--sv-text-primary)"}}),e.jsx("span",{style:{flex:1,fontSize:16,fontWeight:600,color:"var(--sv-text-primary)"},children:r}),e.jsx(xr,{checked:a,onCheckedChange:i})]})}function $p({userId:t}){var m;const{isSupported:r,isEnabled:s,enableNotifications:a,disableNotifications:o,isLoading:i}=So(t),l=!!((m=window.NativeBridge)!=null&&m.__isNativeApp||window.__IS_NATIVE_APP__||/SetversoNative(IOS|Android)|LikePlayNative(IOS|Android)/i.test(navigator.userAgent)),{data:f,refetch:p}=Co(t),g=Eo(),[c,x]=n.useState(!1),d=l?!!(f!=null&&f.is_active):!1,u=b=>Q(this,null,function*(){var v;if(l){x(!0);try{b?((v=window.NativeBridge)!=null&&v.requestPushPermission&&window.NativeBridge.requestPushPermission(),Ie.info("Ative as notificações nas configurações do app.")):(yield g.mutateAsync(),yield p())}finally{x(!1)}}else b?yield a():yield o()});return!r&&!l?null:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"18px 16px",borderRadius:16},children:[e.jsx(Ms,{size:22,style:{flexShrink:0,color:"var(--sv-text-primary)"}}),e.jsx("span",{style:{flex:1,fontSize:16,fontWeight:600,color:"var(--sv-text-primary)"},children:"Notificações Push"}),e.jsx(xr,{checked:l?d:s,onCheckedChange:u,disabled:l?c:i})]})}function Bp(){const[t,r]=n.useState(()=>!document.documentElement.classList.contains("checkout-light")),s=a=>{if(r(a),a){document.documentElement.classList.remove("checkout-light");try{localStorage.setItem("sv_theme_choice","dark")}catch(o){}try{localStorage.removeItem("sv_theme")}catch(o){}}else{document.documentElement.classList.add("checkout-light");try{localStorage.setItem("sv_theme_choice","light")}catch(o){}try{localStorage.removeItem("sv_theme")}catch(o){}}};return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"10px 0"},children:[e.jsx(Go,{size:22,style:{flexShrink:0,color:t?"var(--sv-icon-muted)":"hsl(38, 92%, 50%)"}}),e.jsx("span",{style:{flex:1,fontSize:16,fontWeight:600,color:"var(--sv-text-primary)"},children:"Modo escuro"}),e.jsx(xr,{checked:t,onCheckedChange:s})]})}function qp(){var a;const r=(typeof navigator!="undefined"&&navigator.userAgent||"").match(/(?:SetversoNative(?:IOS|Android)|SetVersoApp|LikePlayNativeAndroid)\/([\d.]+)/i),s=(a=r==null?void 0:r[1])!=null?a:null;return s?e.jsxs("p",{style:{margin:"6px 0 0",textAlign:"center",fontSize:11,fontWeight:500,letterSpacing:"0.02em",color:"var(--sv-text-faint, #9ca3af)",opacity:.7},children:["Versão ",s]}):null}const lo=[{icon:Yo,label:"Editar perfil",action:"edit"},{icon:Ms,label:"Gerenciar Notificações",action:"notifications"},{icon:qo,label:"Sair",action:"logout",danger:!0}];function Wp({open:t,onClose:r,anchorRef:s,onAdminOpen:a,onEditProfile:o,isAdmin:i,authLoading:l,userId:f,userProfile:p,onProfileUpdated:g,initialLayer:c}){var ge;const x=bs(),d=n.useRef(null),[u,m]=n.useState(null),[b,v]=n.useState(!1),w=n.useRef(0),_=n.useRef(0),y=n.useRef(!1),k=n.useRef(null),[E,S]=n.useState(0),[R,z]=n.useState(0),[j,M]=n.useState(!1),$=n.useRef(!1),[q,ne]=n.useState(!1),ae=le=>{w.current=le.touches[0].clientX,_.current=le.touches[0].clientY,y.current=!0,k.current=null,$.current=!u,M(!0)},J=le=>{if(!y.current)return;const fe=le.touches[0].clientX-w.current,pe=Math.abs(le.touches[0].clientY-_.current);if(!k.current){(Math.abs(fe)>10||pe>10)&&(k.current=Math.abs(fe)>pe?"horizontal":"vertical");return}if(k.current!=="horizontal")return;const Ne=Math.max(0,fe);$.current?S(Ne):z(Ne)},je=()=>{if(!y.current)return;y.current=!1,M(!1);const le=window.innerWidth*.3;$.current?E>le?(ne(!0),r(),setTimeout(()=>{S(0),ne(!1)},350)):S(0):(R>le&&m(null),z(0)),k.current=null},[ke,ve]=n.useState(null),[P,N]=n.useState(null);n.useEffect(()=>{if(u)ve(u),requestAnimationFrame(()=>{requestAnimationFrame(()=>{N(u)})});else{N(null);const le=setTimeout(()=>ve(null),400);return()=>clearTimeout(le)}},[u]),n.useEffect(()=>{t&&c&&m(c)},[t,c]),n.useEffect(()=>{if(!t){S(0),z(0);const le=setTimeout(()=>{m(null),ve(null)},350);return()=>clearTimeout(le)}},[t]),n.useEffect(()=>{if(!t)return;const le=pe=>{d.current&&!d.current.contains(pe.target)&&s.current&&!s.current.contains(pe.target)&&r()},fe=setTimeout(()=>{document.addEventListener("mousedown",le),document.addEventListener("touchstart",le)},300);return()=>{clearTimeout(fe),document.removeEventListener("mousedown",le),document.removeEventListener("touchstart",le)}},[t,r,s]);const Y=le=>{const fe=window.innerWidth<1024;if(le==="admin"){r(),x("/admin");return}if(le==="edit"&&fe){m("edit");return}if(le==="notifications"&&fe){m("notifications");return}if(le==="billing"&&fe){m("billing");return}if(le==="edit"){r(),requestAnimationFrame(()=>requestAnimationFrame(()=>o()));return}if(le==="billing"&&!fe){r(),v(!0);return}r(),le==="logout"&&Lt(()=>Q(this,null,function*(){const{logoutWithPushCleanup:pe}=yield import("./index-DFRwvZ6i.js").then(Ne=>Ne.al);return{logoutWithPushCleanup:pe}}),__vite__mapDeps([1,2,3,4])).then(({logoutWithPushCleanup:pe})=>{pe()})},F=!l&&i?[{icon:Ur,label:"Painel Admin",action:"admin"},...lo]:lo;if(window.innerWidth<1024){const le=t||q,fe=q?`translateX(${Math.max(E,window.innerWidth)}px)`:t?`translateX(${E}px)`:"translateX(100%)",pe=j&&E>0,Ne=t?Math.max(0,.35*(1-E/window.innerWidth)):0;return Xt.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:r,style:{position:"fixed",inset:0,zIndex:99990,background:`rgba(0,0,0,${Ne})`,transition:pe?"none":"background 0.35s ease",pointerEvents:le?"auto":"none",visibility:le?"visible":"hidden"}}),e.jsxs("div",{ref:d,onMouseDown:Z=>Z.stopPropagation(),onTouchStart:Z=>{Z.stopPropagation(),ae(Z)},onTouchMove:J,onTouchEnd:je,onClick:Z=>Z.stopPropagation(),style:{position:"fixed",inset:0,zIndex:99999,background:"var(--sv-surface-solid)",transform:fe,visibility:le?"visible":"hidden",transition:pe?"none":"transform 0.35s cubic-bezier(0.4,0,0.2,1)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",transform:P?"translateX(-100%)":"translateX(0)",transition:"transform 0.3s cubic-bezier(0.4,0,0.2,1)",paddingTop:"max(env(safe-area-inset-top), 12px)",paddingBottom:"max(env(safe-area-inset-bottom), 24px)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"16px 20px 20px"},children:[e.jsx("button",{onClick:r,style:{width:40,height:40,borderRadius:"50%",background:"var(--sv-surface-hover)",border:"1px solid var(--sv-border-light)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"var(--sv-icon-default)",flexShrink:0},children:e.jsx(Ct,{size:20})}),e.jsx("p",{style:{fontSize:18,fontWeight:800,color:"var(--sv-text-heading)"},children:"Menu"})]}),e.jsxs("div",{style:{padding:"0 12px",flex:1},children:[F.map(({icon:Z,label:me,action:Me,danger:te})=>e.jsxs("button",{onClick:we=>{we.stopPropagation(),Y(Me)},style:{display:"flex",alignItems:"center",gap:16,width:"100%",padding:"18px 16px",borderRadius:16,textAlign:"left",background:"transparent",color:te||Me==="admin"?"hsl(var(--setverso-red))":"var(--sv-text-primary)",border:"none",cursor:"pointer",fontSize:16,fontWeight:600,transition:"background 0.15s ease",position:"relative",zIndex:1e5},onTouchStart:we=>{we.currentTarget.style.background="var(--sv-surface-hover)"},onTouchEnd:we=>{we.currentTarget.style.background="transparent"},children:[e.jsx(Z,{size:22,style:{flexShrink:0}}),e.jsx("span",{style:{flex:1},children:me}),e.jsx(gr,{size:18,style:{color:"var(--sv-text-muted)",flexShrink:0}})]},Me)),e.jsxs("div",{style:{padding:"8px 16px 0"},children:[e.jsx("div",{style:{height:1,background:"var(--sv-border-subtle)",margin:"4px 0 12px"}}),e.jsx(Bp,{}),e.jsx(qp,{})]})]})]}),(ke==="edit"||u==="edit")&&e.jsx("div",{style:{position:"absolute",inset:0,zIndex:2,transform:P==="edit"?`translateX(${R}px)`:"translateX(100%)",transition:R>0?"none":"transform 0.3s cubic-bezier(0.4,0,0.2,1)"},children:e.jsx(mi,{open:!0,onClose:()=>m(null),userProfile:p!=null?p:null,userId:f,onProfileUpdated:g,embedded:!0})}),(ke==="notifications"||u==="notifications")&&e.jsxs("div",{style:{position:"absolute",inset:0,zIndex:2,background:"var(--sv-surface-solid)",transform:P==="notifications"?`translateX(${R}px)`:"translateX(100%)",transition:R>0?"none":"transform 0.3s cubic-bezier(0.4,0,0.2,1)",display:"flex",flexDirection:"column",paddingTop:"max(env(safe-area-inset-top), 12px)",paddingBottom:"max(env(safe-area-inset-bottom), 24px)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"16px 20px 20px"},children:[e.jsx("button",{onClick:()=>m(null),style:{width:40,height:40,borderRadius:"50%",background:"var(--sv-surface-hover)",border:"1px solid var(--sv-border-light)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"var(--sv-icon-default)",flexShrink:0},children:e.jsx(Ct,{size:20})}),e.jsx("p",{style:{fontSize:18,fontWeight:800,color:"var(--sv-text-heading)"},children:"Notificações"})]}),e.jsxs("div",{style:{padding:"0 12px",flex:1},children:[e.jsx(io,{icon:Gc,label:"No App",storageKey:"notif_in_app"}),e.jsx($p,{userId:f}),e.jsx(io,{icon:bo,label:"E-mail",storageKey:"notif_email"})]})]}),(ke==="billing"||u==="billing")&&e.jsx("div",{style:{position:"absolute",inset:0,zIndex:2,background:"var(--sv-surface-solid)",transform:P==="billing"?`translateX(${R}px)`:"translateX(100%)",transition:R>0?"none":"transform 0.3s cubic-bezier(0.4,0,0.2,1)"},children:e.jsx(Oa,{open:!0,onClose:()=>m(null),userId:f,embedded:!0})})]})]}),document.body)}const ee=(ge=s.current)==null?void 0:ge.getBoundingClientRect(),re=ee?ee.bottom+10:70,be=ee?window.innerWidth-ee.right:16;return e.jsxs(e.Fragment,{children:[t&&Xt.createPortal(e.jsx("div",{ref:d,onMouseDown:le=>le.stopPropagation(),onClick:le=>le.stopPropagation(),style:{position:"fixed",top:`${re}px`,right:`${be}px`,zIndex:9999,minWidth:"260px",background:"var(--sv-surface-elevated)",backdropFilter:"blur(24px) saturate(180%)",WebkitBackdropFilter:"blur(24px) saturate(180%)",border:"1px solid var(--sv-border-strong)",borderRadius:"22px",boxShadow:"var(--sv-shadow-dropdown)",padding:"8px"},children:F.map(({icon:le,label:fe,action:pe,danger:Ne})=>e.jsxs("button",{onClick:()=>Y(pe),className:"flex items-center gap-4 w-full px-4 py-4 rounded-2xl text-left transition-all duration-150 active:scale-[0.97]",style:{color:Ne||pe
287==="admin"?"hsl(var(--setverso-red))":"var(--sv-text-primary)",background:"transparent"},onMouseEnter:Z=>{Z.currentTarget.style.background="var(--sv-surface-hover)"},onMouseLeave:Z=>{Z.currentTarget.style.background="transparent"},children:[e.jsx(le,{size:18,className:"shrink-0"}),e.jsx("span",{className:"text-[15px] font-semibold",children:fe})]},pe))}),document.body),b&&Xt.createPortal(e.jsxs("div",{style:{position:"fixed",inset:0,zIndex:99999,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx("div",{onClick:()=>v(!1),style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.4)"}}),e.jsx("div",{style:{position:"relative",zIndex:1,width:"100%",maxWidth:480,maxHeight:"80vh",borderRadius:24,overflow:"hidden",background:"var(--sv-surface-solid)",boxShadow:"0 20px 60px rgba(0,0,0,0.3)"},children:e.jsx(Oa,{open:!0,onClose:()=>v(!1),userId:f})})]}),document.body)]})}function Vp({value:t,onChange:r}){const[s,a]=n.useState(!1),o=n.useRef(null);return n.useEffect(()=>{const i=l=>{var f;(l.metaKey||l.ctrlKey)&&l.key==="k"&&(l.preventDefault(),(f=o.current)==null||f.focus())};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[]),e.jsx("div",{className:"hidden lg:flex mt-5 mb-1 max-w-[480px] mx-auto",children:e.jsxs("div",{className:"flex items-center gap-3 w-full px-4 rounded-2xl transition-all duration-200",style:{height:"46px",background:s?"var(--sv-surface-hover)":"var(--sv-surface)",border:s?"1px solid var(--sv-border-medium)":"1px solid var(--sv-border-light)",boxShadow:s?"0 0 0 3px var(--sv-surface)":"none"},children:[e.jsx(pr,{size:15,style:{color:s?"var(--sv-text-secondary)":"var(--sv-text-muted)"},className:"shrink-0 transition-colors duration-200"}),e.jsx("input",{ref:o,type:"text",value:t,onChange:i=>r(i.target.value),onFocus:()=>a(!0),onBlur:()=>a(!1),placeholder:"Pesquisar no feed...",className:"flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground outline-none min-w-0"}),t?e.jsx("button",{onClick:()=>r(""),className:"shrink-0 p-0.5 rounded-full transition-colors hover:bg-white/10",children:e.jsx(Je,{size:13,style:{color:"var(--sv-text-tertiary)"}})}):e.jsx("kbd",{className:"hidden xl:flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-mono shrink-0",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-light)",color:"var(--sv-text-muted)"},children:"âK"})]})})}const th=()=>{var ya,wa;const t=bs(),{postId:r,section:s}=Rc(),{isLight:a}=No(),o=Ks(),i=s&&(ya=oo[s])!=null?ya:"Feed",[l,f]=n.useState(i),[p,g]=n.useState("home"),[c,x]=n.useState(null),[d,u]=n.useState(null),[m,b]=n.useState(!1),[v,w]=n.useState(null),[_,y]=n.useState([]),[k,E]=n.useState(!1);n.useRef(null);const[S,R]=n.useState(!0),[z,j]=n.useState(!1),[M,$]=n.useState(null),[q,ne]=n.useState(!1),[ae,J]=n.useState(null),[je,ke]=n.useState(""),[ve,P]=n.useState(!1),[N,Y]=n.useState(null),{posts:F,loading:G,loadingMore:ee,hasMore:re,toggleLike:be,deletePost:ge,togglePin:le,updatePost:fe,addOptimisticPost:pe,createPost:Ne,userId:Z,isAdmin:me,authLoading:Me,userProfile:te,fetchMorePosts:we,refetchProfile:Pe}=zp(),{conversations:oe,loading:O,refetch:H,createOrOpenConversation:ce,deleteConversation:V,markConversationRead:C}=Ip(Z,(wa=N==null?void 0:N.conversationId)!=null?wa:null,ve||!!N),h=n.useRef(null);n.useEffect(()=>{h.current&&!N&&H(),h.current=N},[N,H]),n.useEffect(()=>{H()},[l,H]);const T=n.useMemo(()=>oe.reduce((D,B)=>D+(B.unread_count||0),0),[oe]),[I,K]=n.useState(0),ie=n.useCallback(()=>Q(void 0,null,function*(){if(!Z){K(0);return}try{const D=Se,{count:B}=yield D.from("user_notifications").select("id",{count:"exact",head:!0}).eq("user_id",Z).is("read_at",null);K(B||0)}catch(D){}}),[Z]);n.useEffect(()=>{ie()},[ie,l]);const Ae=n.useCallback(D=>{var B,ue;try{(ue=(B=window==null?void 0:window.ReactNativeWebView)==null?void 0:B.postMessage)==null||ue.call(B,JSON.stringify(D))}catch(W){}try{window.dispatchEvent(new CustomEvent("nativeBridgeMessage",{detail:D}))}catch(W){}},[]);n.useEffect(()=>{Ae({type:"UNREAD_COUNT",count:T}),T===0&&Ae({type:"CLEAR_APP_BADGE"})},[T,Ae]),n.useEffect(()=>{l==="Feed"&&T===0&&(Ae({type:"CLEAR_APP_BADGE"}),Ae({type:"UNREAD_COUNT",count:0}))},[l,T,Ae]);const{spaces:Te}=ca(),{hasPlan:Ve,loading:Ge,isSuspended:Le}=sp();n.useEffect(()=>{let D=!0;Se.auth.getSession().then(({data:ue})=>{var ye,Ee,ze;if(!D)return;const W=(ze=(Ee=(ye=ue.session)==null?void 0:ye.user)==null?void 0:Ee.email)!=null?ze:null;J(W)});const{data:B}=Se.auth.onAuthStateChange((ue,W)=>{var ye,Ee;D&&J((Ee=(ye=W==null?void 0:W.user)==null?void 0:ye.email)!=null?Ee:null)});return()=>{D=!1,B==null||B.subscription.unsubscribe()}},[]);const it=n.useMemo(()=>ae===Fp?ao.filter(D=>D!=="Cursos"):ao,[ae]),[A,X]=Mc();n.useEffect(()=>
287{if(!v){y([]),E(!1);return}let D=!0;E(!0);const B=v.post_order==="oldest_first",ue="*, profiles ( name, username, avatar_url, role_title ), spaces ( name, emoji, post_permission, comments_enabled, post_order ), post_likes(count), comments(count)";return Q(void 0,null,function*(){var at,ht;const W=(yield Lt(()=>Q(void 0,null,function*(){const{supabase:Xe}=yield import("./index-DFRwvZ6i.js").then(Qe=>Qe.ak);return{supabase:Xe}}),__vite__mapDeps([1,2,3,4]))).supabase,[ye,Ee]=yield Promise.all([W.from("posts").select(ue).eq("space_id",v.id).eq("is_pinned",!0).order("created_at",{ascending:!1}),W.from("posts").select(ue).eq("space_id",v.id).eq("is_pinned",!1).order("created_at",{ascending:B}).limit(100)]);if(!D)return;const ze=(at=ye.data)!=null?at:[],Ye=(ht=Ee.data)!=null?ht:[],Ue=[...ze,...Ye],Ke=new Set;if(Z&&Ue.length>0){const Xe=Ue.map(ct=>ct.id),{data:Qe}=yield W.from("post_likes").select("post_id").eq("user_id",Z).in("post_id",Xe);(Qe!=null?Qe:[]).forEach(ct=>Ke.add(ct.post_id))}const pt=Ue.map(Xe=>{var Qe,ct,jt,Nt,kt,_t;return se(L({},Xe),{attachments:Array.isArray(Xe.attachments)?Xe.attachments:[],likes_count:(jt=(ct=(Qe=Xe.post_likes)==null?void 0:Qe[0])==null?void 0:ct.count)!=null?jt:0,user_liked:Ke.has(Xe.id),comments_count:(_t=(kt=(Nt=Xe.comments)==null?void 0:Nt[0])==null?void 0:kt.count)!=null?_t:0,post_likes:void 0})});D&&(y(pt),E(!1))}),()=>{D=!1}},[v==null?void 0:v.id,v==null?void 0:v.post_order,Z]),n.useEffect(()=>{_.length!==0&&y(D=>{let B=!1;const ue=D.map(W=>{const ye=F.find(ze=>ze.id===W.id);if(!ye)return W;const Ee=L(L({},W),ye);return JSON.stringify(Ee)!==JSON.stringify(W)?(B=!0,Ee):W});return B?ue:D})},[F]),n.useEffect(()=>{if(!v)return;const D=Te.find(B=>B.id===v.id);D&&D.post_order!==v.post_order&&w(B=>B&&se(L({},B),{post_order:D.post_order}))},[Te,v==null?void 0:v.id]);const he=n.useRef(null),Ce=n.useRef(null),Oe=n.useCallback(D=>Q(void 0,null,function*(){var ze,Ye,Ue,Ke,pt,at,ht,Xe,Qe,ct,jt,Nt,kt,_t,$t,Bt,qt,Yt,ss,rs,ns,as,os,is,ls,cs,ds,us;let B=F.find(Pt=>Pt.id===D);if(!B)try{const{supabase:Pt}=yield Lt(()=>Q(void 0,null,function*(){const{supabase:js}=yield import("./index-DFRwvZ6i.js").then(dt=>dt.ak);return{supabase:js}}),__vite__mapDeps([1,2,3,4])),{data:Kt}=yield Pt.from("posts").select("*, profiles:author_id(name, avatar_url), spaces:space_id(name, comments_enabled), likes_count:post_likes(count), comments_count:comments(count)").eq("id",D).maybeSingle();Kt&&(B=se(L({},Kt),{likes_count:(Ue=(Ye=(ze=Kt.likes_count)==null?void 0:ze[0])==null?void 0:Ye.count)!=null?Ue:0,comments_count:(at=(pt=(Ke=Kt.comments_count)==null?void 0:Ke[0])==null?void 0:pt.count)!=null?at:0}))}catch(Pt){console.error("Failed to fetch post by id:",Pt)}if(!B)return!1;const ue=(Xe=(ht=B.profiles)==null?void 0:ht.name)!=null?Xe:"Membro",W=ue.split(" ").slice(0,2).map(Pt=>Pt[0]).join("").toUpperCase(),ye=(jt=(ct=(Qe=B.spaces)==null?void 0:Qe.name)!=null?ct:B.space_id)!=null?jt:"",Ee={id:B.id,author:ue,authorInitials:W,authorAvatar:(kt=(Nt=B.profiles)==null?void 0:Nt.avatar_url)!=null?kt:void 0,authorId:B.author_id,space:ye,timeAgo:ir(B.created_at),title:B.title,preview:(_t=B.preview)!=null?_t:"",isPinned:B.is_pinned,fullContent:{content:($t=B.content)!=null?$t:void 0,perfis:(Bt=B.perfis)!=null?Bt:"",local:(qt=B.local)!=null?qt:"",data:(Yt=B.data_projeto)!=null?Yt:"",horario:(ss=B.horario)!=null?ss:"",cache:(rs=B.cache)!=null?rs:"",requisitos:(ns=B.requisitos)!=null?ns:"",observacoes:(as=B.observacoes)!=null?as:void 0,link:(os=B.link_original)!=null?os:void 0},likes:(is=B.likes_count)!=null?is:0,commentsEnabled:(cs=(ls=B.spaces)==null?void 0:ls.comments_enabled)!=null?cs:!0,commentsCount:(ds=B.comments_count)!=null?ds:0,attachments:(us=B.attachments)!=null?us:[]};return window.innerWidth>=1024?u(Ee):x(Ee),g("home"),f("Feed"),P(!1),t(`/membros/post/${Ee.id}`),!0}),[F,t]);n.useEffect(()=>{var W;const D=A.get("post"),B=A.get("chat"),ue=D||B||null;if(!ue){he.current=null;return}if(ue!==he.current){if(D){if(G)return;he.current=ue,Oe(D).then(ye=>{if(!ye){he.current=null;return}setTimeout(()=>{X(Ee=>{const ze=new URLSearchParams(Ee);return ze.get("post")===D&&ze.delete("post"),ze},{replace:!0})},1500)});return}
287else if(B){if(!Z||Ce.current===B)return;const ye=()=>{he.current=ue,setTimeout(()=>{X(Ue=>{const Ke=new URLSearchParams(Ue);return Ke.get("chat")===B&&Ke.delete("chat"),Ke},{replace:!0})},1500)},Ee=Ue=>{P(!0),g("messages"),Y({conversationId:B,otherUser:Ue}),C(B),ye()},ze=()=>{P(!0),g("messages"),ye()},Ye=oe.find(Ue=>Ue.id===B);Ye&&((W=Ye.other_user)!=null&&W.name)?Ee(Ye.other_user):(Ce.current=B,Q(void 0,null,function*(){try{const{supabase:Ue}=yield Lt(()=>Q(void 0,null,function*(){const{supabase:Xe}=yield import("./index-DFRwvZ6i.js").then(Qe=>Qe.ak);return{supabase:Xe}}),__vite__mapDeps([1,2,3,4])),{data:Ke}=yield Ue.from("conversations").select("user1_id,user2_id").eq("id",B).maybeSingle(),pt=Ke?Ke.user1_id===Z?Ke.user2_id:Ke.user1_id:null;if(!pt){ze();return}const{data:at}=yield Ue.from("profiles").select("id,name,avatar_url").eq("id",pt).maybeSingle(),ht=at?{id:at.id,name:at.name,avatar_url:at.avatar_url}:{id:pt,name:null,avatar_url:null};Ee(ht)}catch(Ue){ze()}finally{Ce.current=null}}))}}},[A,F,G,oe,O,Z,Oe,X]);const Et=n.useRef(null),et=n.useRef(!1);n.useEffect(()=>{r&&Et.current!==r&&(G||(Et.current=r,Oe(r).then(D=>
287{if(!D){Et.current=null;return}et.current=!0})))},[r,G,Oe,t]),n.useEffect(()=>{r||(d&&u(null),c&&x(null),Et.current=null,et.current=!1)},[r]),n.useEffect(()=>{!d&&!c&&r&&et.current&&(et.current=!1,t("/membros/feed",{replace:!0}))},[d,c,r,t]),n.useEffect(()=>{if(r||!s)return;if(s==="mensagens"){ve||P(!0);return}const D=oo[s];D&&(D===l&&!ve||(D==="Notificações"?(P(!1),Y(null),x(null),w(null)):ve&&P(!1),f(D)))},[s,r]),n.useEffect(()=>{var B;if(r)return;const D=ve?"mensagens":(B=Op[l])!=null?B:"feed";s!==D&&t(`/membros/${D}`,{replace:!0})},[l,ve,r]),n.useEffect(()=>{var D,B,ue,W,ye,Ee,ze,Ye,Ue,Ke,pt,at,ht,Xe,Qe,ct,jt,Nt,kt,_t,$t,Bt,qt,Yt,ss,rs,ns,as,os,is,ls,cs,ds,us,Pt,Kt,js,dt,fs,ms;if(c){const Re=F.find(Jt=>Jt.id===c.id);if(Re){const Jt=(B=(D=Re.profiles)==null?void 0:D.name)!=null?B:"Membro",hn=Jt.split(" ").slice(0,2).map(gn=>gn[0]).join("").toUpperCase(),xn=(ye=(W=(ue=Re.spaces)==null?void 0:ue.name)!=null?W:Re.space_id)!=null?ye:"";x({id:Re.id,author:Jt,authorInitials:hn,authorAvatar:(ze=(Ee=Re.profiles)==null?void 0:Ee.avatar_url)!=null?ze:void 0,authorId:Re.author_id,space:xn,timeAgo:ir(Re.created_at),title:Re.title,preview:(Ye=Re.preview)!=null?Ye:"",isPinned:Re.is_pinned,fullContent:{content:(Ue=Re.content)!=null?Ue:void 0,perfis:(Ke=Re.perfis)!=null?Ke:"",local:(pt=Re.local)!=null?pt:"",data:(at=Re.data_projeto)!=null?at:"",horario:(ht=Re.horario)!=null?ht:"",cache:(Xe=Re.cache)!=null?Xe:"",requisitos:(Qe=Re.requisitos)!=null?Qe:"",observacoes:(ct=Re.observacoes)!=null?ct:void 0,link:(jt=Re.link_original)!=null?jt:void 0},likes:(Nt=Re.likes_count)!=null?Nt:0,commentsEnabled:(_t=(kt=Re.spaces)==null?void 0:kt.comments_enabled)!=null?_t:!0,commentsCount:($t=Re.comments_count)!=null?$t:0,attachments:Array.isArray(Re.attachments)?Re.attachments:[]})}}if(d){const Re=F.find(Jt=>Jt.id===d.id);if(Re){const Jt=(qt=(Bt=Re.profiles)==null?void 0:Bt.name)!=null?qt:"Membro",hn=Jt.split(" ").slice(0,2).map(gn=>gn[0]).join("").toUpperCase(),xn=(rs=(ss=(Yt=Re.spaces)==null?void 0:Yt.name)!=null?ss:Re.space_id)!=null?rs:"";u({id:Re.id,author:Jt,authorInitials:hn,authorId:Re.author_id,space:xn,timeAgo:ir(Re.created_at),title:Re.title,preview:(ns=Re.preview)!=null?ns:"",isPinned:Re.is_pinned,fullContent:{content:(as=Re.content)!=null?as:void 0,perfis:(os=Re.perfis)!=null?os:"",local:(is=Re.local)!=null?is:"",data:(ls=Re.data_projeto)!=null?ls:"",horario:(cs=Re.horario)!=null?cs:"",cache:(ds=Re.cache)!=null?ds:"",requisitos:(us=Re.requisitos)!=null?us:"",observacoes:(Pt=Re.observacoes)!=null?Pt:void 0,link:(Kt=Re.link_original)!=null?Kt:void 0},likes:(js=Re.likes_count)!=null?js:0,commentsEnabled:(fs=(dt=Re.spaces)==null?void 0:dt.comments_enabled)!=null?fs:!0,commentsCount:(ms=Re.comments_count)!=null?ms:0,attachments:Array.isArray(Re.attachments)?Re.attachments:[]})}}},[F]);const Ut=D=>D.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim(),vt=(D,B)=>{const ue=Ut(D),W=Ut(B);return!W||ue.includes(W)?!0:W.split(/\s+/).filter(Boolean).every(Ee=>ue.includes(Ee))},Rt=n.useMemo(()=>{let D=v?_:F;return je.trim()&&(D=D.filter(B=>{var ue,W,ye,Ee,ze,Ye;return vt(B.title,je)||vt((ue=B.content)!=null?ue:"",je)||vt((W=B.preview)!=null?W:"",je)||vt((Ee=(ye=B.profiles)==null?void 0:ye.name)!=null?Ee:"",je)||vt((Ye=(ze=B.spaces)==null?void 0:ze.name)!=null?Ye:"",je)})),D},[F,_,v,je]),[lt,Ts]=n.useState(!1),[Ds,ys]=n.useState(!1),[pn,wr]=n.useState(!1),[zs,Gt]=n.useState(!1),[jr,Is]=n.useState(null),Xs=n.useRef(null),Nr=n.useRef(null),Tt=n.useRef(null),Zs=n.useRef(null),Js=n.useRef(null),Ls=n.useRef(null),es=n.useRef(0),Fs=n.useCallback(()=>{const D=es.current;x(null),b(!1);const B=performance.now(),ue=()=>{const W=Tt.current;if(!W){performance.now()-B<600&&requestAnimationFrame(ue);return}const ye=W.scrollHeight-W.clientHeight;W.scrollTop=Math.min(D,Math.max(0,ye)),W.scrollTop<D-2&&performance.now()-B<600&&requestAnimationFrame(ue)};requestAnimationFrame(ue)},[]);n.useEffect(()=>{const D=()=>Ds?(ys(!1),Is(null),!0):zs?(Gt(!1),Ts(!1),!0):q?(ne(!1),!0):z?(j(!1),$(null),!0):N?(Y(null),!0):d?(u(null),b(!1),!0):c?(Fs(),!0):ve?(P(!1),g("home"),!0):!1,B=window;return B.SetVersoWeb=se(L({},B.SetVersoWeb||{}),{backEvent:D}),()=>{var ue;((ue=B.SetVersoWeb)==null?void 0:ue.backEvent)===D&&delete B.SetVersoWeb.backEvent}},[Ds,zs,q,z,N,d,c,ve,Fs]);const ws=n.useCallback(D=>({Feed:Tt,Espaços:Zs,Membros:Js,Cursos:Ls})[D],[]),U=n.useCallback(D=>{var ye;const B=(ye=ws(l))==null?void 0:ye.current;if(!B)return;let ue=D.target;for(;ue&&ue!==D.currentTarget;){if(ue===B)return;const Ee=window.getComputedStyle(ue);
287if(/(auto|scroll|overlay)/.test(Ee.overflowY)&&ue.scrollHeight>ue.clientHeight)return;ue=ue.parentElement}const W=D.deltaMode===1?D.deltaY*16:D.deltaMode===2?D.deltaY*B.clientHeight:D.deltaY;B.scrollTop+=W},[l,ws]),de=n.useCallback((D,B="auto")=>{var ye;const ue=(ye=ws(D))==null?void 0:ye.current;if(!ue)return;[ue,...Array.from(ue.querySelectorAll("*")).filter(Ee=>{const ze=window.getComputedStyle(Ee);return[ze.overflow,ze.overflowY].some(Ye=>Ye==="auto"||Ye==="scroll")})].forEach((Ee,ze)=>{B==="smooth"&&ze===0?Ee.scrollTo({top:0,behavior:"smooth"}):Ee.scrollTop=0}),B==="smooth"?window.scrollTo({top:0,behavior:"smooth"}):window.scrollTo(0,0)},[ws]),_e=n.useCallback(D=>{var B,ue;es.current=(ue=(B=Tt.current)==null?void 0:B.scrollTop)!=null?ue:0,window.innerWidth>=1024?u(D):x(D),t(`/membros/post/${D.id}`)},[t]),$e=n.useCallback(D=>{var B,ue;es.current=(ue=(B=Tt.current)==null?void 0:B.scrollTop)!=null?ue:0,x(D),t(`/membros/post/${D.id}`)},[t]),De=n.useRef(l);n.useEffect(()=>{De.current=l,requestAnimationFrame(()=>{de(l)})},[l,de]);const He=n.useRef(!1);n.useEffect(()=>{He.current=ee},[ee]);const rt=n.useCallback(()=>{De.current==="Feed"&&we()},[we]),ot=n.useCallback(()=>{if(v)return;const D=Tt.current;if(!D||He.current||!re)return;D.scrollHeight-D.scrollTop-D.clientHeight<600&&we()},[we,re,v]),mt=ld({fetchMore:rt,hasMore:v?!1:re,loading:G||ee||k,rootMargin:"400px",rootRef:Tt}),Ot=n.useRef(0),Dt=n.useRef(0),nt=n.useRef(!1),Mt=D=>{if(l==="Cursos")return;const B=D.touches[0].clientX;B>window.innerWidth*.6&&(Ot.current=B,Dt.current=D.touches[0].clientY,nt.current=!0)},tt=D=>{if(!nt.current)return;nt.current=!1;const B=D.changedTouches[0].clientX,ue=D.changedTouches[0].clientY,W=Ot.current-B,ye=Math.abs(ue-Dt.current);W>60&&ye<W*.7&&j(!0)},bt=(D,B)=>{D.stopPropagation(),Z&&be(B)},wt=D=>{if(g(D),console.log("Nav change to:",D,"Current Active:",l,"Has post/space:",!!c,!!v),A.has("curso")||A.has("aula")){const B=new URLSearchParams(A);B.delete("curso"),B.delete("aula"),X(B,{replace:!0})}if(D==="notifications"){P(!1),Y(null),x(null),w(null),f("Notificações");return}if(D==="messages"){P(!0),Y(null),x(null),w(null);return}if(P(!1),Y(null),D==="Feed"||D==="home"){if(x(null),w(null),A.has("curso")||A.has("aula")){const B=new URLSearchParams(A);B.delete("curso"),B.delete("aula"),X(B,{replace:!0})}l==="Feed"?de("Feed","smooth"):f("Feed");return}if(D==="Espaços"||D==="Membros"||D==="Cursos"||D==="Ranking"){if(x(null),w(null),A.has("curso")||A.has("aula")){const B=new URLSearchParams(A);B.delete("curso"),B.delete("aula"),X(B,{replace:!0})}D==="Cursos"&&t("/membros/cursos",{replace:!0}),f(D)}},zt=!!N||ve||!!c,ts=()=>{var D,B,ue;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex lg:hidden items-center justify-between px-5 pt-0 pb-0",style:{paddingTop:"env(safe-area-inset-top, 0px)"},children:[e.jsx("div",{className:"w-[90px] h-[90px] flex items-center justify-center overflow-hidden",style:{mixBlendMode:a?"normal":"screen"},children:e.jsx("img",{src:a?ko:on,alt:"SetVerso Logo",className:"object-contain",style:{width:a?"130%":"100%",height:a?"130%":"100%"}})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{ref:Nr,children:e.jsxs("button",{onClick:()=>{lt?(Ts(!1),Gt(!0)):Ts(!0)},className:"flex items-center rounded-full overflow-hidden active:scale-95 shrink-0",style:{height:"44px",width:lt?"auto":"44px",paddingLeft:lt?"16px":"0",paddingRight:lt?"16px":"0",background:"rgba(34, 197, 94, 0.15)",border:"1px solid rgba(34, 197, 94, 0.35)",boxShadow:lt?"0 0 14px rgba(34,197,94,0.2)":"none",transition:"all 0.35s cubic-bezier(0.4, 0, 0.2, 1)",justifyContent:"center",gap:lt?"8px":"0"},children:[e.jsx(hr,{size:20,className:"shrink-0",style:{color:"rgb(74, 222, 128)",transition:"transform 0.3s ease",transform:lt?"rotate(45deg)":"rotate(0deg)"}}),e.jsx("span",{className:"text-sm font-semibold whitespace-nowrap",style:{color:"rgb(74, 222, 128)",opacity:lt?1:0,maxWidth:lt?"160px":"0px",overflow:"hidden",transition:"opacity 0.2s ease 0.1s, max-width 0.35s cubic-bezier(0.4,0,0.2,1)"},children:"Criar publicação"})]})}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{ref:Xs,onClick:()=>j(W=>!W),className:"rounded-full active:scale-95 transition-transform flex items-center justify-center",style:{width:44,height:44},children:e.jsxs(ut,{className:"h-full w-full border-2 border-border box-border",children:[te!=null&&te.avatar_url?e.jsx(Ze,{src:te.avatar_url,alt:(D=te.name)!=null?D:"Perfil",className:"object-cover"}):null,e.jsx(ft,{className:"text-xs font-bold text-accent-foreground",style:{background:"hsl(var(--setverso-red))"},children:(ue=(B=te==null?void 0:te.name)==null?void 0:B.split(" ").slice(0,2).map(W=>W[0]).join("").toUpperCase())!=null?ue:"?"})]})}),e.jsx(Wp,{open:z,onClose:()=>{j(!1),$(null)},anchorRef:Xs,onAdminOpen:()=>t("/admin"),onEditProfile:()=>ne(!0),isAdmin:me,authLoading:Me,userId:Z,userProfile:te!=null?te:null,onProfileUpdated:()=>Pe(),initialLayer:M})]})]})]}),e.jsxs("div",{className:"hidden lg:flex items-center gap-3 pt-10 pb-0 px-0",children:[v&&e.jsx("button",{onClick:()=>{w(null)},className:"w-9 h-9 rounded-full flex items-center justify-center bg-secondary border border-border active:scale-95 transition-transform shrink-0",children:e.jsx(Ct,{size:18})}),e.jsx("h1",{className:"text-3xl font-black tracking-tight text-foreground leading-tight",children:v?v.name:"Feed"})]}),e.jsx(Vp,{value:je,onChange:ke}),e.jsxs("div",{className:"lg:hidden px-5 mb-1 -mt-6 flex items-center gap-3",children:[v&&e.jsx("button",{onClick:()=>{w(null)},className:"w-9 h-9 rounded-full flex items-center justify-center bg-secondary border border-border active:scale-95 transition-transform shrink-0",children:e.jsx(Ct,{size:18})}),e.jsx("h1",{className:"text-3xl font-black tracking-tight text-foreground leading-tight",children:v?v.name:"SetVerso Community"})]}),e.jsx("div",{className:"flex justify-start lg:justify-center gap-2 px-5 lg:px-0 mb-3 mt-2 lg:mt-6 overflow-x-auto scrollbar-none",children:it.map(W=>{const ye=l===W;return e.jsx("button",{onClick:()=>{l===W?W==="Feed"&&v?w(null):W==="Cursos"?t("/membros/cursos",{replace:!0}):de(W,"smooth"):(W!=="Feed"&&w(null),W==="Cursos"&&t("/membros/cursos",{replace:!0}),f(W))},className:Be("shrink-0 px-4 py-1.5 rounded-full text-sm font-semibold transition-all duration-200 active:scale-95",ye?"bg-foreground text-background":"bg-secondary text-muted-foreground border border-border hover:border-white/20"),children:W},W)})})]})},At=zt?null:e.jsx("div",{className:"shrink-0 w-full",children:ts()}),Zt=D=>{var ue;const B=(ue=D==null?void 0:D.skipCursos)!=null?ue:!1;return N?e.jsx(Tp,{conversationId:N.conversationId,otherUser:N.otherUser,userId:Z,onBack:()=>Y(null)}):ve?e.jsx(Sp,{conversations:oe,loading:O,userId:Z,onBack:()=>{P(!1),g("home")},onOpenChat:(W,ye)=>{W&&C(W),Y({conversationId:W,otherUser:ye})},onCreateConversation:ce,onDeleteConversation:V}):c?e.jsx(im,{post:c,onBack:Fs,currentUserId:Z,isAdmin:me,onDelete:()=>
287ge(c.id),onTogglePin:W=>le(c.id),onEditPost:W=>(x(ye=>{var Ee,ze,Ye,Ue;return ye&&se(L({},ye),{title:(Ee=W.title)!=null?Ee:ye.title,fullContent:se(L({},ye.fullContent),{content:(ze=W.content)!=null?ze:ye.fullContent.content}),attachments:(Ye=W.attachments)!=null?Ye:ye.attachments,authorId:(Ue=W.author_id)!=null?Ue:ye.authorId})}),fe(c.id,W)),onEditingChange:wr,scrollToComments:m,onScrolledToComments:()=>b(!1),dbPosts:F,onOpenLinkedPost:W=>Oe(W)}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pointer-events-none select-none absolute -right-36 top-10 z-0",style:{width:"460px",height:"460px",opacity:.15},children:e.jsx("img",{src:ka,alt:"",className:"w-full h-full object-contain"})}),e.jsxs("div",{ref:Tt,onScroll:ot,className:"flex-1 overflow-y-auto overflow-x-hidden pb-40 lg:pb-10 min-w-0 flex-col",style:{display:l==="Feed"?"flex":"none"},children:[At,e.jsxs("div",{className:"flex flex-col gap-3 px-5 lg:px-0 min-w-0",children:[S&&!v&&e.jsx("div",{className:"relative z-10 rounded-2xl overflow-hidden border border-border",children:e.jsxs("div",{className:"relative overflow-hidden rounded-2xl",style:{height:"150px",background:"linear-gradient(135deg, hsl(4, 70%, 18%) 0%, hsl(0, 0%, 8%) 50%, hsl(220, 40%, 10%) 100%)"},children:[e.jsx("div",{className:"absolute inset-0 opacity-30",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E")`,backgroundSize:"200px 200px"}}),e.jsxs("div",{className:"absolute top-4 left-5 flex items-center gap-2 opacity-40",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border border-white/50"}),e.jsx("div",{className:"h-px w-12 bg-white/30"}),e.jsx("div",{className:"text-white/50 text-[9px] font-mono tracking-widest",children:"ð¬ REC"})]}),e.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 select-none",style:{opacity:.55},children:e.jsx("img",{src:ka,alt:"",className:"w-28 h-28 object-contain"})}),e.jsxs("div",{className:"absolute inset-0 flex flex-col justify-end px-5 pb-5 z-10",children:[e.jsx("p",{className:"text-white/40 text-[10px] font-bold uppercase tracking-[0.2em] mb-1.5",children:"SetVerso Community"}),e.jsx("h3",{className:"text-white font-black text-xl leading-tight mb-1.5",children:"Seja Bem-Vindo(a)! ð¬"}),e.jsx("p",{className:"text-white/50 text-xs leading-relaxed",children:"Explore castings e oportunidades do mercado audiovisual."})]})]})}),G||k?[1,2,3].map(W=>e.jsx(bn,{},W)):Rt.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-48 gap-3 text-center",children:[e.jsx("span",{className:"text-3xl",children:je.trim()?"ð":"ð"}),e.jsx("p",{className:"text-sm font-semibold text-muted-foreground",children:je.trim()?`Nenhum resultado para "${je}"`:"Nenhuma publicação ainda"}),!je.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Seja o primeiro a publicar!"})]}):Rt.map(W=>{var Xe,Qe,ct,jt,Nt,kt,_t,$t,Bt,qt,Yt,ss,rs,ns,as,os,is,ls,cs,ds,us,Pt,Kt,js;const ye=(Xe=W.user_liked)!=null?Xe:!1,Ee=(Qe=W.likes_count)!=null?Qe:0,ze=(jt=(ct=W.profiles)==null?void 0:ct.name)!=null?jt:"Membro",Ye=ze.split(" ").slice(0,2).map(dt=>dt[0]).join("").toUpperCase(),Ue=(_t=(kt=(Nt=W.spaces)==null?void 0:Nt.name)!=null?kt:W.space_id)!=null?_t:"";new Date(W.created_at);const Ke=ir(W.created_at),pt=(Bt=($t=W.spaces)==null?void 0:$t.comments_enabled)!=null?Bt:!0,at=(qt=W.comments_count)!=null?qt:0,ht={id:W.id,author:ze,authorInitials:Ye,authorAvatar:(ss=(Yt=W.profiles)==null?void 0:Yt.avatar_url)!=null?ss:void 0,authorId:W.author_id,space:Ue,spaceId:(rs=W.space_id)!=null?rs:void 0,timeAgo:Ke,createdAt:W.created_at,title:W.title,preview:(ns=W.preview)!=null?ns:"",isPinned:W.is_pinned,commentsEnabled:pt,commentsCount:at,fullContent:{content:(as=W.content)!=null?as:void 0,perfis:(os=W.perfis)!=null?os:"",local:(is=W.local)!=null?is:"",data:(ls=W.data_projeto)!=null?ls:"",horario:(cs=W.horario)!=null?cs:"",cache:(ds=W.cache)!=null?ds:"",requisitos:(us=W.requisitos)!=null?us:"",observacoes:(Pt=W.observacoes)!=null?Pt:void 0,link:(Kt=W.link_original)!=null?Kt:void 0}
287,likes:Ee,isAdmin:!1,attachments:Array.isArray(W.attachments)?W.attachments:[]};return e.jsxs("div",{role:"button",tabIndex:0,className:"w-full min-w-0 text-left rounded-2xl px-5 py-5 transition-all duration-150 active:scale-[0.995] cursor-pointer",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-light)"},onClick:()=>_e(ht),children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-3",children:[e.jsxs(ut,{className:"h-9 w-9 shrink-0 border border-border",children:[(js=W.profiles)!=null&&js.avatar_url?e.jsx(Ze,{src:W.profiles.avatar_url,alt:ze,className:"object-cover"}):Ye==="PP"?e.jsx(Ze,{src:mn,alt:ze,className:"object-cover"}):null,e.jsx(ft,{className:"text-[10px] font-bold text-white",style:{background:"hsl(var(--setverso-red))"},children:Ye})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground leading-tight truncate",children:ze}),e.jsx("p",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:v?Ke:e.jsxs(e.Fragment,{children:["Publicado em ",e.jsx("span",{className:"text-foreground/70",children:Ue})," · ",Ke]})})]})]}),e.jsx("h2",{className:"text-[17px] font-black text-foreground leading-snug mb-2 break-words",style:{overflowWrap:"anywhere"},children:Gr(W.title)}),(()=>{const dt=_a(W.content)||_a(W.preview);if(dt){const ms=vo(dt);return ms?e.jsx("div",{className:"sv-video-wrap mb-4",children:e.jsx("iframe",{src:ms.embedUrl,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,className:"sv-yt-iframe"})}):e.jsx(Lp,{url:dt})}const fs=Cc(W.content)||W.preview||"";return fs?e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed line-clamp-3 mb-4 break-words",style:{overflowWrap:"anywhere"},children:fs}):null})(),W.attachments&&W.attachments.length>0&&e.jsx(va,{attachments:W.attachments,className:"mb-4"}),e.jsxs("div",{className:"flex items-center pt-3",style:{borderTop:"1px solid var(--sv-border-subtle)"},onClick:dt=>dt.stopPropagation(),children:[e.jsxs("button",{onClick:dt=>bt(dt,W.id),className:"flex items-center gap-1.5 active:scale-95 transition-transform",children:[e.jsx(ta,{size:18,className:"transition-all duration-200",style:{fill:ye?"hsl(var(--setverso-red))":"transparent",color:ye?"hsl(var(--setverso-red))":"hsl(var(--muted-foreground))"}}),Ee>0&&e.jsx("span",{className:"text-sm font-semibold",style:{color:ye?"hsl(var(--setverso-red))":"hsl(var(--muted-foreground))"},children:Ee})]}),pt&&e.jsxs("button",{className:"flex items-center gap-1.5 ml-4 active:scale-95 transition-transform",onClick:dt=>{var fs,ms;dt.stopPropagation(),es.current=(ms=(fs=Tt.current)==null?void 0:fs.scrollTop)!=null?ms:0,window.innerWidth>=1024?u(ht):x(ht),b(!0)},children:[e.jsx(gs,{size:18,className:"text-muted-foreground"}),at>0&&e.jsx("span",{className:"text-sm font-semibold text-muted-foreground",children:at})]}),e.jsx("button",{className:"flex items-center gap-1.5 ml-auto active:scale-95 transition-transform",onClick:dt=>Q(void 0,null,function*(){dt.stopPropagation(),yield Zr(W.id,W.title),navigator.share||Ie.success("Link copiado!")}),children:e.jsx(Kr,{size:18,className:"text-muted-foreground"})})]})]},W.id)}),e.jsx("div",{ref:mt,style:{height:1}}),ee&&!v&&e.jsxs("div",{className:"flex flex-col gap-3 mt-3",children:[e.jsx(bn,{}),e.jsx(bn,{})]}),!G&&!k&&(v||!re)&&Rt.length>0&&!je.trim()&&e.jsx("p",{className:"text-center text-xs text-muted-foreground py-4",children:"Você viu todas as publicações ð¬"})]})]}),e.jsxs("div",{ref:Zs,className:"flex-1 overflow-y-auto overflow-x-hidden pb-40 lg:pb-10 min-w-0 flex-col",style:{display:l==="Espaços"?"flex":"none"},children:[At,e.jsx(um,{onSelectSpace:W=>{var ye,Ee;es.current=(Ee=(ye=Tt.current)==null?void 0:ye.scrollTop)!=null?Ee:0,w(W),f("Feed")}})]}),e.jsxs("div",{ref:Js,className:"flex-1 overflow-y-auto overflow-x-hidden pb-40 lg:pb-10 min-w-0 flex-col",style:{display:l==="Membros"?"flex":"none"},children:[At,e.jsx(op,{currentUserId:Z,onStartConversation:W=>Q(void 0,null,function*(){const ye=yield ce(W);ye&&(P(!0),g("messages"),Y({conversationId:ye,otherUser:{id:W,name:null,avatar_url:null}}))})})]}),!B&&e.jsxs("div",{ref:Ls,className:"flex-1 overflow-y-auto overflow-x-hidden pb-40 lg:pb-10 min-w-0 flex-col",style:{display:l
287==="Cursos"?"flex":"none"},children:[At,e.jsx(eo,{})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto overflow-x-hidden pb-40 lg:pb-10 min-w-0 flex-col",style:{display:l==="Notificações"?"flex":"none"},children:[At,e.jsx(Ym,{userId:Z})]}),l==="Ranking"&&e.jsxs("div",{className:"flex-1 overflow-y-auto overflow-x-hidden pb-40 lg:pb-10 min-w-0 flex flex-col items-center py-24 px-6 text-center gap-3",children:[At,e.jsx("span",{className:"text-4xl",children:"ð"}),e.jsx("h2",{className:"text-lg font-bold text-foreground",children:"Ranking"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-xs",children:"DisponÃvel em breve"})]})]})},kr=[...F].sort((D,B)=>{var ue,W;return((ue=B.likes_count)!=null?ue:0)-((W=D.likes_count)!=null?W:0)}).slice(0,5),Qs=e.jsx("aside",{className:"hidden xl:block w-[300px] shrink-0 pt-10 pr-8 h-full min-h-0 overflow-y-auto",children:e.jsxs("div",{className:"rounded-2xl p-4",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-subtle)"},children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-[0.18em] text-muted-foreground mb-4",children:"ð¥ Posts em Alta"}),e.jsx("div",{className:"flex flex-col gap-1",children:kr.map((D,B)=>{var Ye,Ue,Ke,pt,at,ht,Xe,Qe,ct,jt,Nt,kt,_t,$t,Bt,qt;const ue=(Ue=(Ye=D.profiles)==null?void 0:Ye.name)!=null?Ue:"Membro",W=ue.split(" ").slice(0,2).map(Yt=>Yt[0]).join("").toUpperCase(),ye=(at=(pt=(Ke=D.spaces)==null?void 0:Ke.name)!=null?pt:D.space_id)!=null?at:"",Ee=ir(D.created_at),ze={id:D.id,author:ue,authorInitials:W,authorAvatar:(Xe=(ht=D.profiles)==null?void 0:ht.avatar_url)!=null?Xe:void 0,space:ye,timeAgo:Ee,createdAt:D.created_at,title:D.title,preview:(Qe=D.preview)!=null?Qe:"",fullContent:{content:(ct=D.content)!=null?ct:void 0,perfis:(jt=D.perfis)!=null?jt:"",local:(Nt=D.local)!=null?Nt:"",data:(kt=D.data_projeto)!=null?kt:"",horario:(_t=D.horario)!=null?_t:"",cache:($t=D.cache)!=null?$t:"",requisitos:(Bt=D.requisitos)!=null?Bt:""},likes:(qt=D.likes_count)!=null?qt:0,isAdmin:!1};return e.jsxs("button",{onClick:()=>$e(ze),className:"flex items-start gap-3 w-full text-left px-3 py-3 rounded-xl transition-all duration-150 group",children:[e.jsx("span",{className:"text-xs font-black mt-0.5 shrink-0 w-4 text-center",style:{color:"hsl(var(--setverso-red) / 0.6)"},children:B+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[13px] font-semibold text-foreground/80 group-hover:text-foreground leading-snug line-clamp-2 transition-colors",children:Gr(D.title)}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-1",children:[ye," · ",Ee]})]})]},D.id)})}),e.jsxs("div",{className:"mt-5 pt-4",style:{borderTop:"1px solid var(--sv-border-subtle)"},children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-[0.18em] text-muted-foreground mb-3",children:"Espaços em Alta"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["ð¬ Seletivas Gerais","ð¬ Bate-Papo","ð NotÃcias"].map(D=>e.jsx("span",{className:"text-xs px-3 py-1.5 rounded-full font-medium cursor-pointer transition-all duration-150 hover:opacity-80",style:{background:"var(--sv-surface)",border:"1px solid var(--sv-border-light)",color:"var(--sv-text-secondary)"},children:D},D))})]})]})});return Z&&!Me&&!Ge&&Le&&!me?e.jsx("div",{className:"min-h-screen flex items-center justify-center px-6 bg-background",children:e.jsxs("div",{className:"max-w-md w-full text-center flex flex-col items-center gap-6",children:[e.jsx("div",{className:"w-20 h-20 rounded-2xl flex items-center justify-center",style:{background:"linear-gradient(135deg, rgba(234,140,60,0.18), rgba(234,140,60,0.05))",border:"1px solid rgba(234,140,60,0.3)"},children:e.jsx(Ur,{size:32,style:{color:"rgb(234,140,60)"}})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",style:{color:"var(--sv-text-heading)"},children:"Acesso temporariamente suspenso"}),e.jsx("p",{className:"text-sm leading-relaxed",style:{color:"var(--sv-text-secondary)"},children:"Sua conta foi suspensa pela equipe SetVerso. Seu plano e permissões foram preservados. Entre em contato para reativar o acesso."})]}),e.jsx("button",{onClick:()=>{Lt(()=>Q(void 0,null,function*(){const{supabase:D}=yield import("./index-DFRwvZ6i.js").then(B=>B.ak);return{supabase:D}}),__vite__mapDeps([1,2,3,4])).then(({supabase:D})=>D.auth.signOut())},className:"w-full px-6 py-3 rounded-2xl font-medium text-sm transition-all active:scale-[0.98]",style:{background:"var(--sv-surface-hover)",border:"1px solid var(--sv-border-subtle)",color:"var(--sv-text-secondary)"},children:"Sair"})]})}):Z&&!Me&&!Ge&&!Ve&&!me?e.jsx("div",{className:"min-h-screen flex items-center justify-center px-6 bg-background",children:e.jsxs("div",{className:"max-w-md w-full text-center flex flex-col items-center gap-6",children:[e.jsx("div",{className:"w-20 h-20 rounded-2xl flex items-center justify-center",style:{background:"linear-gradient(135deg, hsl(var(--setverso-red) / 0.18), hsl(var(--setverso-red) / 0.05))",border:"1px solid hsl(var(--setverso-red) / 0.3)"},children:e.jsx(Ur,{size:32,style:{color:"hsl(var(--setverso-red))"}})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",style:{color:"var(--sv-text-heading)"},children:"Você ainda não possui um plano ativo"}),e.jsx("p",{className:"text-sm leading-relaxed",style:{color:"var(--sv-text-secondary)"},children:"Para acessar a comunidade, conteúdos e cursos, é preciso ter um plano ativo. Entre em contato para escolher o melhor plano para você."})]}),e.jsxs("div",{className:"flex flex-col gap-3 w-full",children:[e.jsx("a",{href:"https://lp.setverso.com",target:"_blank",rel:"noopener noreferrer","data-external":"true",className:"w-full px-6 py-3.5 rounded-2xl font-semibold text-sm text-center transition-all active:scale-[0.98]",style:{background:"hsl(var(--setverso-red))",color:"white",boxShadow:"0 8px 20px hsl(var(--setverso-red) / 0.3)"},children:"Ver planos disponÃveis"}),e.jsx("button",{onClick:()=>{Lt(()=>Q(void 0,null,function*(){const{supabase:D}=yield import("./index-DFRwvZ6i.js").then(B=>B.ak);return{supabase:D}}),__vite__mapDeps([1,2,3,4])).then(({supabase:D})=>D.auth.signOut())},className:"w-full px-6 py-3 rounded-2xl font-medium text-sm transition-all active:scale-[0.98]",style:{background:"var(--sv-surface-hover)",border:"1px solid var(--sv-border-subtle)",color:"var(--sv-text-secondary)"},children:"Sair"})]})]})}):e.jsxs(e.Fragment,{children:[e.jsx(dd,{userId:Z}),e.jsxs("div",{className:"flex bg-background min-h-screen",children:[e.jsx(Eu,{activeTab:p,onTabChange:wt,onAdminOpen:()=>t("/admin"),onNewPost:()=>Gt(!0),onEditProfile:()=>ne(!0),onNotifications:()=>wt("notifications"),onSpaceSelect:D=>{var B;f("Feed"),w({id:D.id,name:D.name,emoji:D.emoji,color:(B=D.color)!=null?B:"#e53935",post_order:D.post_order})},isAdmin:me,authLoading:Me,userProfile:te}),e.jsxs("div",{className:"flex-1 flex min-h-screen min-w-0",children:[o&&e.jsx("div",{className:"w-full flex justify-center overflow-hidden min-w-0",onTouchStart:Mt,onTouchEnd:tt,style:{overscrollBehavior:"none"},children:e.jsxs("div",{className:"w-full max-w-[430px] relative flex flex-col h-screen overflow-hidden bg-background min-w-0",style:{overscrollBehavior:"contain",scrollbarGutter:"stable"},children:[Zt(),!N&&!Ds&&!pn&&e.jsx(fu,{activeTab:p,onTabChange:wt,onSearchChange:ke,unreadMessages:oe.reduce((D,B)=>D+B.unread_count,0)})]})}),!o&&(zt?e.jsxs("div",{className:"flex flex-1 pl-[260px] h-screen min-h-0 overflow-hidden",children:[e.jsx("div",{className:"flex-1 flex justify-center h-full min-h-0",children:e.jsx("div",{className:"w-full max-w-[560px] px-4 relative flex flex-col h-full min-h-0",children:Zt()})}),!c&&Qs]}):e.jsx("div",{className:"flex flex-col flex-1 pl-[260px] min-w-0 h-screen overflow-hidden",style:{scrollbarGutter:"stable"},onWheel:U,children:l==="Cursos"?e.jsxs("div",{ref:Ls,className:"flex-1 overflow-y-auto overflow-x-hidden pb-10 min-w-0 min-h-0 flex flex-col w-full px-6",
287style:{scrollbarGutter:"stable"},children:[At,e.jsx(eo,{})]}):e.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0",children:[e.jsx("div",{className:"flex-1 flex justify-center min-w-0 h-full min-h-0",children:e.jsx("div",{className:"w-full max-w-[560px] px-4 relative flex flex-col h-full min-h-0",children:Zt({skipCursos:!0})})}),Qs]})}))]}),e.jsx(lm,{post:d,onClose:()=>{u(null),b(!1)},currentUserId:Z,isAdmin:me,onDelete:D=>{ge(D),u(null)},onTogglePin:(D,B)=>le(D),onEditPost:(D,B)=>(u(ue=>{var W,ye,Ee,ze;return ue&&se(L({},ue),{title:(W=B.title)!=null?W:ue.title,fullContent:se(L({},ue.fullContent),{content:(ye=B.content)!=null?ye:ue.fullContent.content}),attachments:(Ee=B.attachments)!=null?Ee:ue.attachments,authorId:(ze=B.author_id)!=null?ze:ue.authorId})}),fe(D,B)),scrollToComments:m,onScrolledToComments:()=>b(!1),dbPosts:F,onOpenLinkedPost:D=>Oe(D)}),e.jsx(gu,{open:zs,onClose:()=>{Gt(!1),Ts(!1)},onSelect:D=>{Is(D),Gt(!1),ys(!0)},spaces:Te,isAdmin:me}),e.jsx(xu,{open:Ds,onClose:()=>{ys(!1),Is(null)},initialSpace:jr,addOptimisticPost:pe,createPost:Ne,userId:Z,userProfile:te,posts:F}),e.jsx(mi,{open:q,onClose:()=>ne(!1),userProfile:te!=null?te:null,userId:Z,onProfileUpdated:()=>{Pe()}})]})]})};export{th as default};
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.