1import{c as fe,al as Ut,r as m,an as Ht,s as F,y as J,j as o,ag as Os,am as Es,F as Ts,aY as $t,aZ as Ms,P as As,J as je,a_ as Is,a$ as Ps,b0 as _s,b1 as ks,b2 as Ds,b3 as Ls,b4 as Us,b5 as Hs,b6 as $s,b7 as zs,b8 as Bs,b9 as Vs,ba as Fs,aI as Ks,bb as Ws,O as G,a7 as Gs,Q as qs,aW as Ys,I as pe,B as q,bc as zt,bd as Bt,be as Xs,X as Vt,bf as Ft,bg as Kt,bh as Js,bi as Zs,bj as Qs,ah as ei,a6 as ti,x as ni,o as si,l as Fe,R as ii,bk as oi,v as re,g as ai}from"./index-q_JQ1u3V.js";import{L as ri,A as li}from"./AdminLayout-DIeqrqa0.js";import{P as Wt,c as nt,E as Gt,d as ci,p as qt,N as ui,e as di,f as fi,u as Yt,h as hi,i as Xt,a as Jt,b as Zt,j as pt,g as mi}from"./index-D0vEOkKd.js";import{k as pi,i as Qt,a as en,b as tn,c as nn,d as sn,T as on,e as an,f as rn,g as ln,h as cn,F as un,j as dn,C as fn,A as gi,s as xi,u as vi}from"./useCarouselEnhancement-DvYRNcK6.js";import{B as bi,I as wi,T as yi,i as Ci}from"./index-DNSz8ypY.js";import{P as Ye}from"./plus-BC8tAOmr.js";import{I as hn}from"./image-BYTAmUb0.js";import{C as Si}from"./code-Bl6AxUNO.js";import{E as Ni}from"./ellipsis-CNGraz6D.js";import{L as ji}from"./link-DbFNda72.js";import{C as Ri,S as gt,a as xt,b as vt,c as bt,d as Ke}from"./select-CzTV_e-A.js";import{M as mn}from"./message-square-D2INmnV8.js";import{M as wt}from"./minus-BypH-0QB.js";import{T as Oi}from"./trash-2-DFA3OBNd.js";import{T as yt}from"./textarea-BqvS_ucd.js";import{B as Ei}from"./badge-CvbmWKJ4.js";import{P as Ti}from"./progress-CP4mJA8M.js";import{C as Mi}from"./circle-check-big-CS81DKep.js";import{C as Ai}from"./circle-alert-D1VY4YSu.js";import{C as Ii}from"./circle-x-t_Eouy1A.js";import{s as Pi}from"./richText-Wy7DLs86.js";import{C as _i}from"./clock-DTOZ-4oq.js";import{E as ki}from"./eye-BH7aaCKm.js";import{S as Di}from"./save-CTUDJwE9.js";import{S as Ct}from"./send-DjdyN-VN.js";import"./shopping-bag-CgHBTCIQ.js";import"./file-text-RmbE5Tly.js";import"./video-D5dLy0jS.js";import"./users-CYc5Aycy.js";import"./briefcase-DeToZG6N.js";import"./film-C6E9mld6.js";import"./chevron-left-B7sCBZWu.js";import"./index-D6IRRUFF.js";import"./purify.es-GoFsRstw.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Li=fe("AlignCenter",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const St=fe("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const Ui=fe("GalleryHorizontal",[["path",{d:"M2 3v18",key:"pzttux"}],["rect",{width:"12",height:"18",x:"6",y:"3",rx:"2",key:"btr8bg"}],["path",{d:"M22 3v18",key:"6jf3v"}]]);/** 17 * @license lucide-react v0.462.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const Hi=fe("Highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);/** 22 * @license lucide-react v0.462.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const $i=fe("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"}]]);/** 27 * @license lucide-react v0.462.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const zi=fe("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** 32 * @license lucide-react v0.462.0 - ISC 33 * 34 * This source code is licensed under the ISC license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const Bi=fe("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"}]]);/** 37 * @license lucide-react v0.462.0 - ISC 38 * 39 * This source code is licensed under the ISC license. 40 * See the LICENSE file in the root directory of this source tree. 41 */const Nt=fe("Rows2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]]),pn=["top","right","bottom","left"],jt=["start","end"],Rt=pn.reduce((e,t)=>
vendor: 5,315 bytes, line 41
41e.concat(t,t+"-"+jt[0],t+"-"+jt[1]),[]),oe=Math.min,z=Math.max,Ie=Math.round,ie=e=>({x:e,y:e}),Vi={left:"right",right:"left",bottom:"top",top:"bottom"};function Xe(e,t,n){return z(e,oe(t,n))}function le(e,t){return typeof e=="function"?e(t):e}function Y(e){return e.split("-")[0]}function Z(e){return e.split("-")[1]}function gn(e){return e==="x"?"y":"x"}function st(e){return e==="y"?"height":"width"}function se(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function it(e){return gn(se(e))}function xn(e,t,n){n===void 0&&(n=!1);const i=Z(e),s=it(e),r=st(s);let a=s==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(a=_e(a)),[a,_e(a)]}function Fi(e){const t=_e(e);return[Pe(e),t,Pe(t)]}function Pe(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Ot=["left","right"],Et=["right","left"],Ki=["top","bottom"],Wi=["bottom","top"];function Gi(e,t,n){switch(e){case"top":case"bottom":return n?t?Et:Ot:t?Ot:Et;case"left":case"right":return t?Ki:Wi;default:return[]}}function qi(e,t,n,i){const s=Z(e);let r=Gi(Y(e),n==="start",i);return s&&(r=r.map(a=>a+"-"+s),t&&(r=r.concat(r.map(Pe)))),r}function _e(e){const t=Y(e);return Vi[t]+e.slice(t.length)}function Yi(e){return{top:0,right:0,bottom:0,left:0,...e}}function ot(e){return typeof e!="number"?Yi(e):{top:e,right:e,bottom:e,left:e}}function be(e){const{x:t,y:n,width:i,height:s}=e;return{width:i,height:s,top:n,left:t,right:t+i,bottom:n+s,x:t,y:n}}function Tt(e,t,n){let{reference:i,floating:s}=e;const r=se(t),a=it(t),l=st(a),d=Y(t),p=r==="y",h=i.x+i.width/2-s.width/2,c=i.y+i.height/2-s.height/2,u=i[l]/2-s[l]/2;let f;switch(d){case"top":f={x:h,y:i.y-s.height};break;case"bottom":f={x:h,y:i.y+i.height};break;case"right":f={x:i.x+i.width,y:c};break;case"left":f={x:i.x-s.width,y:c};break;default:f={x:i.x,y:i.y}}switch(Z(t)){case"start":f[a]-=u*(n&&p?-1:1);break;case"end":f[a]+=u*(n&&p?-1:1);break}return f}async function Xi(e,t){var n;t===void 0&&(t={});const{x:i,y:s,platform:r,rects:a,elements:l,strategy:d}=e,{boundary:p="clippingAncestors",rootBoundary:h="viewport",elementContext:c="floating",altBoundary:u=!1,padding:f=0}=le(t,e),g=ot(f),v=l[u?c==="floating"?"reference":"floating":c],b=be(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(v)))==null||n?v:v.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(l.floating)),boundary:p,rootBoundary:h,strategy:d})),y=c==="floating"?{x:i,y:s,width:a.floating.width,height:a.floating.height}:a.reference,C=await(r.getOffsetParent==null?void 0:r.getOffsetParent(l.floating)),S=await(r.isElement==null?void 0:r.isElement(C))?await(r.getScale==null?void 0:r.getScale(C))||{x:1,y:1}:{x:1,y:1},R=be(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:C,strategy:d}):y);return{top:(b.top-R.top+g.top)/S.y,bottom:(R.bottom-b.bottom+g.bottom)/S.y,left:(b.left-R.left+g.left)/S.x,right:(R.right-b.right+g.right)/S.x}}const Ji=50,Zi=async(e,t,n)=>{const{placement:i="bottom",strategy:s="absolute",middleware:r=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:Xi},d=await(a.isRTL==null?void 0:a.isRTL(t));let p=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:h,y:c}=Tt(p,i,d),u=i,f=0;const g={};for(let x=0;x<r.length;x++){const v=r[x];if(!v)continue;const{name:b,fn:y}=v,{x:C,y:S,data:R,reset:j}=await y({x:h,y:c,initialPlacement:i,placement:u,strategy:s,middlewareData:g,rects:p,platform:l,elements:{reference:e,floating:t}});h=C??h,c=S??c,g[b]={...g[b],...R},j&&f<Ji&&(f++,typeof j=="object"&&(j.placement&&(u=j.placement),j.rects&&(p=j.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):j.rects),{x:h,y:c}=Tt(p,u,d)),x=-1)}return{x:h,y:c,placement:u,strategy:s,middlewareData:g}},Qi=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:i,placement:s,rects:r,platform:a,elements:l,middlewareData:d}=t,{element:p,padding:h=0}=le(e,t)||{};if(p==null)return{};const c=ot(h),u={x:n,y:i},f=it(s),g=st(f),x=await a.getDimensions(p),v=f==="y",b=v?"top":"left",y=v?"bottom":"right",C=v?"clientHeight":"clientWidth",S=r.reference[g]+r.reference[f]-u[f]-r.floating[g],R=u[f]-r.reference[f],j=await(a.getOffsetParent==null?void 0:a.getOffsetParent(p));let T=j?j[C]:0;(!T||!await(a.isElement==null?void 0:a.isElement(j)))&&(T=l.floating[C]||r.floating[g]);const O=S/2-R/2,E=T/2-x[g]/2-1,N=oe(c[b],E),A=oe(c[y],E),_=N,k=T-x[g]-A,I=T/2-x[g]/2+O,U=Xe(_,I,k),L=!d.arrow&&Z(s)!=null&&I!==U&&r.reference[g]/2-(I<_?N:A)-x[g]/2<0,H=L?I<_?I-_:I-k:0;return{[f]:u[f]+H,data:{[f]:U,centerOffset:I-U-H,...L&&{alignmentOffset:H}},reset:L}}});function eo(e,t,n){return(e?[...n.filter(s=>Z(s)===e),...n.filter(s=>Z(s)!==e)]:n.filter(s=>Y(s)===s)).filter(s=>e?Z(s)===e||(t?Pe(s)!==s:!1):!0)}const to=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,i,s;const{rects:r,middlewareData:a,placement:l,platform:d,elements:p}=t,{crossAxis:h=!1,alignment:c,allowedPlacements:u=Rt,autoAlignment:f=!0,...g}=le(e,t),x=c!==void 0||u===Rt?eo(c||null,f,u):u,v=await d.detectOverflow(t,g),b=((n=a.autoPlacement)==null?void 0:n.index)||0,y=x[b];if(y==null)return{};const C=xn(y,r,await(d.isRTL==null?void 0:d.isRTL(p.floating)));
41if(l!==y)return{reset:{placement:x[0]}};const S=[v[Y(y)],v[C[0]],v[C[1]]],R=[...((i=a.autoPlacement)==null?void 0:i.overflows)||[],{placement:y,overflows:S}],j=x[b+1];if(j)return{data:{index:b+1,overflows:R},reset:{placement:j}};const T=R.map(N=>{const A=Z(N.placement);return[N.placement,A&&h?N.overflows.slice(0,2).reduce((_,k)=>_+k,0):N.overflows[0],N.overflows]}).sort((N,A)=>N[1]-A[1]),E=((s=T.filter(N=>N[2].slice(0,Z(N[0])?2:3).every(A=>A<=0))[0])==null?void 0:s[0])||T[0][0];return E!==l?{data:{index:b+1,overflows:R},reset:{placement:E}}:{}}}},no=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,i;const{placement:s,middlewareData:r,rects:a,initialPlacement:l,platform:d,elements:p}=t,{mainAxis:h=!0,crossAxis:c=!0,fallbackPlacements:u,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:x=!0,...v}=le(e,t);if((n=r.arrow)!=null&&n.alignmentOffset)return{};const b=Y(s),y=se(l),C=Y(l)===l,S=await(d.isRTL==null?void 0:d.isRTL(p.floating)),R=u||(C||!x?[_e(l)]:Fi(l)),j=g!=="none";!u&&j&&R.push(...qi(l,x,g,S));const T=[l,...R],O=await d.detectOverflow(t,v),E=[];let N=((i=r.flip)==null?void 0:i.overflows)||[];if(h&&E.push(O[b]),c){const I=xn(s,a,S);E.push(O[I[0]],O[I[1]])}if(N=[...N,{placement:s,overflows:E}],!E.every(I=>I<=0)){var A,_;const I=(((A=r.flip)==null?void 0:A.index)||0)+1,U=T[I];if(U&&(!(c==="alignment"?y!==se(U):!1)||N.every(D=>se(D.placement)===y?D.overflows[0]>0:!0)))return{data:{index:I,overflows:N},reset:{placement:U}};let L=(_=N.filter(H=>H.overflows[0]<=0).sort((H,D)=>H.overflows[1]-D.overflows[1])[0])==null?void 0:_.placement;if(!L)switch(f){case"bestFit":{var k;const H=(k=N.filter(D=>{if(j){const X=se(D.placement);return X===y||X==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(X=>X>0).reduce((X,He)=>X+He,0)]).sort((D,X)=>D[1]-X[1])[0])==null?void 0:k[0];H&&(L=H);break}case"initialPlacement":L=l;break}if(s!==L)return{reset:{placement:L}}}return{}}}};function Mt(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function At(e){return pn.some(t=>e[t]>=0)}const so=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:i}=t,{strategy:s="referenceHidden",...r}=le(e,t);switch(s){case"referenceHidden":{const a=await i.detectOverflow(t,{...r,elementContext:"reference"}),l=Mt(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:At(l)}}}case"escaped":{const a=await i.detectOverflow(t,{...r,altBoundary:!0}),l=Mt(a,n.floating);return{data:{escapedOffsets:l,escaped:At(l)}}}default:return{}}}}};function vn(e){const t=oe(...e.map(r=>r.left)),n=oe(...e.map(r=>r.top)),i=z(...e.map(r=>r.right)),s=z(...e.map(r=>r.bottom));return{x:t,y:n,width:i-t,height:s-n}}function io(e){const t=e.slice().sort((s,r)=>s.y-r.y),n=[];let i=null;for(let s=0;s<t.length;s++){const r=t[s];!i||r.y-i.y>i.height/2?n.push([r]):n[n.length-1].push(r),i=r}return n.map(s=>be(vn(s)))}const oo=function(e){return e===void 0&&(e={}),{name:"inline",options:e,async fn(t){const{placement:n,elements:i,rects:s,platform:r,strategy:a}=t,{padding:l=2,x:d,y:p}=le(e,t),h=Array.from(await(r.getClientRects==null?void 0:r.getClientRects(i.reference))||[]),c=io(h),u=be(vn(h)),f=ot(l);function g(){if(c.length===2&&c[0].left>c[1].right&&d!=null&&p!=null)return c.find(v=>d>v.left-f.left&&d<v.right+f.right&&p>v.top-f.top&&p<v.bottom+f.bottom)||u;if(c.length>=2){if(se(n)==="y"){const N=c[0],A=c[c.length-1],_=Y(n)==="top",k=N.top,I=A.bottom,U=_?N.left:A.left,L=_?N.right:A.right,H=L-U,D=I-k;return{top:k,bottom:I,left:U,right:L,width:H,height:D,x:U,y:k}}const v=Y(n)==="left",b=z(...c.map(N=>N.right)),y=oe(...c.map(N=>N.left)),C=c.filter(N=>v?N.left===y:N.right===b),S=C[0].top,R=C[C.length-1].bottom,j=y,T=b,O=T-j,E=R-S;return{top:S,bottom:R,left:j,right:T,width:O,height:E,x:j,y:S}}return u}const x=await r.getElementRects({reference:{getBoundingClientRect:g},floating:i.floating,strategy:a});return s.reference.x!==x.reference.x||s.reference.y!==x.reference.y||s.reference.width!==x.reference.width||s.reference.height!==x.reference.height?{reset:{rects:x}}:{}}
vendor: 4,428 bytes, line 41
41}},ao=new Set(["left","top"]);async function ro(e,t){const{placement:n,platform:i,elements:s}=e,r=await(i.isRTL==null?void 0:i.isRTL(s.floating)),a=Y(n),l=Z(n),d=se(n)==="y",p=ao.has(a)?-1:1,h=r&&d?-1:1,c=le(t,e);let{mainAxis:u,crossAxis:f,alignmentAxis:g}=typeof c=="number"?{mainAxis:c,crossAxis:0,alignmentAxis:null}:{mainAxis:c.mainAxis||0,crossAxis:c.crossAxis||0,alignmentAxis:c.alignmentAxis};return l&&typeof g=="number"&&(f=l==="end"?g*-1:g),d?{x:f*h,y:u*p}:{x:u*p,y:f*h}}const lo=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,i;const{x:s,y:r,placement:a,middlewareData:l}=t,d=await ro(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:s+d.x,y:r+d.y,data:{...d,placement:a}}}}},co=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:i,placement:s,platform:r}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:d={fn:b=>{let{x:y,y:C}=b;return{x:y,y:C}}},...p}=le(e,t),h={x:n,y:i},c=await r.detectOverflow(t,p),u=se(Y(s)),f=gn(u);let g=h[f],x=h[u];if(a){const b=f==="y"?"top":"left",y=f==="y"?"bottom":"right",C=g+c[b],S=g-c[y];g=Xe(C,g,S)}if(l){const b=u==="y"?"top":"left",y=u==="y"?"bottom":"right",C=x+c[b],S=x-c[y];x=Xe(C,x,S)}const v=d.fn({...t,[f]:g,[u]:x});return{...v,data:{x:v.x-n,y:v.y-i,enabled:{[f]:a,[u]:l}}}}}},uo=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,i;const{placement:s,rects:r,platform:a,elements:l}=t,{apply:d=()=>{},...p}=le(e,t),h=await a.detectOverflow(t,p),c=Y(s),u=Z(s),f=se(s)==="y",{width:g,height:x}=r.floating;let v,b;c==="top"||c==="bottom"?(v=c,b=u===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(b=c,v=u==="end"?"top":"bottom");const y=x-h.top-h.bottom,C=g-h.left-h.right,S=oe(x-h[v],y),R=oe(g-h[b],C),j=!t.middlewareData.shift;let T=S,O=R;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(O=C),(i=t.middlewareData.shift)!=null&&i.enabled.y&&(T=y),j&&!u){const N=z(h.left,0),A=z(h.right,0),_=z(h.top,0),k=z(h.bottom,0);f?O=g-2*(N!==0||A!==0?N+A:z(h.left,h.right)):T=x-2*(_!==0||k!==0?_+k:z(h.top,h.bottom))}await d({...t,availableWidth:O,availableHeight:T});const E=await a.getDimensions(l.floating);return g!==E.width||x!==E.height?{reset:{rects:!0}}:{}}}};function ke(){return typeof window<"u"}function ye(e){return bn(e)?(e.nodeName||"").toLowerCase():"#document"}function W(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ce(e){var t;return(t=(bn(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function bn(e){return ke()?e instanceof Node||e instanceof W(e).Node:!1}function Q(e){return ke()?e instanceof Element||e instanceof W(e).Element:!1}function ue(e){return ke()?e instanceof HTMLElement||e instanceof W(e).HTMLElement:!1}function It(e){return!ke()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof W(e).ShadowRoot}function Oe(e){const{overflow:t,overflowX:n,overflowY:i,display:s}=ee(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+n)&&s!=="inline"&&s!=="contents"}function fo(e){return/^(table|td|th)$/.test(ye(e))}function De(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const ho=/transform|translate|scale|rotate|perspective|filter/,mo=/paint|layout|strict|content/,me=e=>!!e&&e!=="none";let We;function at(e){const t=Q(e)?ee(e):e;return me(t.transform)||me(t.translate)||me(t.scale)||me(t.rotate)||me(t.perspective)||!rt()&&(me(t.backdropFilter)||me(t.filter))||ho.test(t.willChange||"")||mo.test(t.contain||"")}function po(e){let t=de(e);for(;ue(t)&&!we(t);){if(at(t))return t;if(De(t))return null;t=de(t)}return null}function rt(){return We==null&&(We=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),We}function we(e){return/^(html|body|#document)$/.test(ye(e))}function ee(e){return W(e).getComputedStyle(e)}function Le(e){return Q(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function de(e){if(ye(e)==="html")return e;const t=e.assignedSlot||e.parentNode||It(e)&&e.host||ce(e);return It(t)?t.host:t}function wn(e){const t=de(e);return we(t)?e.ownerDocument?e.ownerDocument.body:e.body:ue(t)&&Oe(t)?t:wn(t)}function Je(e,t,n){var i;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=wn(e),r=s===((i=e.ownerDocument)==null?void 0:i.body),a=W(s);if(r){const l=Ze(a);
vendor: 4,286 bytes, line 41
41return t.concat(a,a.visualViewport||[],Oe(s)?s:[],l&&n?Je(l):[])}else return t.concat(s,Je(s,[],n))}function Ze(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function yn(e){const t=ee(e);let n=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const s=ue(e),r=s?e.offsetWidth:n,a=s?e.offsetHeight:i,l=Ie(n)!==r||Ie(i)!==a;return l&&(n=r,i=a),{width:n,height:i,$:l}}function Cn(e){return Q(e)?e:e.contextElement}function ve(e){const t=Cn(e);if(!ue(t))return ie(1);const n=t.getBoundingClientRect(),{width:i,height:s,$:r}=yn(t);let a=(r?Ie(n.width):n.width)/i,l=(r?Ie(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const go=ie(0);function Sn(e){const t=W(e);return!rt()||!t.visualViewport?go:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function xo(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==W(e)?!1:t}function Re(e,t,n,i){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),r=Cn(e);let a=ie(1);t&&(i?Q(i)&&(a=ve(i)):a=ve(e));const l=xo(r,n,i)?Sn(r):ie(0);let d=(s.left+l.x)/a.x,p=(s.top+l.y)/a.y,h=s.width/a.x,c=s.height/a.y;if(r){const u=W(r),f=i&&Q(i)?W(i):i;let g=u,x=Ze(g);for(;x&&i&&f!==g;){const v=ve(x),b=x.getBoundingClientRect(),y=ee(x),C=b.left+(x.clientLeft+parseFloat(y.paddingLeft))*v.x,S=b.top+(x.clientTop+parseFloat(y.paddingTop))*v.y;d*=v.x,p*=v.y,h*=v.x,c*=v.y,d+=C,p+=S,g=W(x),x=Ze(g)}}return be({width:h,height:c,x:d,y:p})}function Ue(e,t){const n=Le(e).scrollLeft;return t?t.left+n:Re(ce(e)).left+n}function Nn(e,t){const n=e.getBoundingClientRect(),i=n.left+t.scrollLeft-Ue(e,n),s=n.top+t.scrollTop;return{x:i,y:s}}function vo(e){let{elements:t,rect:n,offsetParent:i,strategy:s}=e;const r=s==="fixed",a=ce(i),l=t?De(t.floating):!1;if(i===a||l&&r)return n;let d={scrollLeft:0,scrollTop:0},p=ie(1);const h=ie(0),c=ue(i);if((c||!c&&!r)&&((ye(i)!=="body"||Oe(a))&&(d=Le(i)),c)){const f=Re(i);p=ve(i),h.x=f.x+i.clientLeft,h.y=f.y+i.clientTop}const u=a&&!c&&!r?Nn(a,d):ie(0);return{width:n.width*p.x,height:n.height*p.y,x:n.x*p.x-d.scrollLeft*p.x+h.x+u.x,y:n.y*p.y-d.scrollTop*p.y+h.y+u.y}}function bo(e){return Array.from(e.getClientRects())}function wo(e){const t=ce(e),n=Le(e),i=e.ownerDocument.body,s=z(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),r=z(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let a=-n.scrollLeft+Ue(e);const l=-n.scrollTop;return ee(i).direction==="rtl"&&(a+=z(t.clientWidth,i.clientWidth)-s),{width:s,height:r,x:a,y:l}}const Pt=25;function yo(e,t){const n=W(e),i=ce(e),s=n.visualViewport;let r=i.clientWidth,a=i.clientHeight,l=0,d=0;if(s){r=s.width,a=s.height;const h=rt();(!h||h&&t==="fixed")&&(l=s.offsetLeft,d=s.offsetTop)}const p=Ue(i);if(p<=0){const h=i.ownerDocument,c=h.body,u=getComputedStyle(c),f=h.compatMode==="CSS1Compat"&&parseFloat(u.marginLeft)+parseFloat(u.marginRight)||0,g=Math.abs(i.clientWidth-c.clientWidth-f);g<=Pt&&(r-=g)}else p<=Pt&&(r+=p);return{width:r,height:a,x:l,y:d}}function Co(e,t){const n=Re(e,!0,t==="fixed"),i=n.top+e.clientTop,s=n.left+e.clientLeft,r=ue(e)?ve(e):ie(1),a=e.clientWidth*r.x,l=e.clientHeight*r.y,d=s*r.x,p=i*r.y;return{width:a,height:l,x:d,y:p}}function _t(e,t,n){let i;if(t==="viewport")i=yo(e,n);else if(t==="document")i=wo(ce(e));else if(Q(t))i=Co(t,n);else{const s=Sn(e);i={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return be(i)}function jn(e,t){const n=de(e);return n===t||!Q(n)||we(n)?!1:ee(n).position==="fixed"||jn(n,t)}function So(e,t){const n=t.get(e);if(n)return n;let i=Je(e,[],!1).filter(l=>Q(l)&&ye(l)!=="body"),s=null;const r=ee(e).position==="fixed";let a=r?de(e):e;for(;Q(a)&&!we(a);){const l=ee(a),d=at(a);!d&&l.position==="fixed"&&(s=null),(r?!d&&!s:!d&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Oe(a)&&!d&&jn(e,a))?i=i.filter(h=>h!==a):s=l,a=de(a)}return t.set(e,i),i}function No(e){let{element:t,boundary:n,rootBoundary:i,strategy:s}=e;const a=[...n==="clippingAncestors"?De(t)?[]:So(t,this._c):[].concat(n),i],l=_t(t,a[0],s);let d=l.top,p=l.right,h=l.bottom,c=l.left;for(let u=1;u<a.length;u++){const f=_t(t,a[u],s);d=z(f.top,d),p=oe(f.right,p),h=oe(f.bottom,h),c=z(f.left,c)}return{width:p-c,height:h-d,x:c,y:d}}function jo(e){const{width:t,height:n}=yn(e);return{width:t,height:n}}
41function Ro(e,t,n){const i=ue(t),s=ce(t),r=n==="fixed",a=Re(e,!0,r,t);let l={scrollLeft:0,scrollTop:0};const d=ie(0);function p(){d.x=Ue(s)}if(i||!i&&!r)if((ye(t)!=="body"||Oe(s))&&(l=Le(t)),i){const f=Re(t,!0,r,t);d.x=f.x+t.clientLeft,d.y=f.y+t.clientTop}else s&&p();r&&!i&&s&&p();const h=s&&!i&&!r?Nn(s,l):ie(0),c=a.left+l.scrollLeft-d.x-h.x,u=a.top+l.scrollTop-d.y-h.y;return{x:c,y:u,width:a.width,height:a.height}}function Ge(e){return ee(e).position==="static"}function kt(e,t){if(!ue(e)||ee(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ce(e)===n&&(n=n.ownerDocument.body),n}function Rn(e,t){const n=W(e);if(De(e))return n;if(!ue(e)){let s=de(e);for(;s&&!we(s);){if(Q(s)&&!Ge(s))return s;s=de(s)}return n}let i=kt(e,t);for(;i&&fo(i)&&Ge(i);)i=kt(i,t);return i&&we(i)&&Ge(i)&&!at(i)?n:i||po(e)||n}const Oo=async function(e){const t=this.getOffsetParent||Rn,n=this.getDimensions,i=await n(e.floating);return{reference:Ro(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Eo(e){return ee(e).direction==="rtl"}const To={convertOffsetParentRelativeRectToViewportRelativeRect:vo,getDocumentElement:ce,getClippingRect:No,getOffsetParent:Rn,getElementRects:Oo,getClientRects:bo,getDimensions:jo,getScale:ve,isElement:Q,isRTL:Eo},On=lo,En=to,Tn=co,Mn=no,An=uo,In=so,Pn=Qi,_n=oo,kn=(e,t,n)=>{const i=new Map,s={platform:To,...n},r={...s.platform,_c:i};return Zi(e,t,{...s,platform:r})};function Mo(e,t){const n=Math.min(e.top,t.top),i=Math.max(e.bottom,t.bottom),s=Math.min(e.left,t.left),a=Math.max(e.right,t.right)-s,l=i-n,d=s,p=n;return new DOMRect(d,p,a,l)}var Ao=class{constructor({editor:e,element:t,view:n,pluginKey:i="bubbleMenu",updateDelay:s=250,resizeDelay:r=60,shouldShow:a,appendTo:l,getReferencedVirtualElement:d,options:p}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:c,state:u,from:f,to:g})=>{const{doc:x,selection:v}=u,{empty:b}=v,y=!x.textBetween(f,g).length&&ci(u.selection),C=this.element.contains(document.activeElement);return!(!(c.hasFocus()||C)||b||y||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:c})=>{var u;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}c!=null&&c.relatedTarget&&((u=this.element.parentNode)!=null&&u.contains(c.relatedTarget))||(c==null?void 0:c.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(c,u)=>{const f=!(u!=null&&u.selection.eq(c.state.selection)),g=!(u!=null&&u.doc.eq(c.state.doc));!f&&!g||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(c,f,g,u)},this.updateDelay))},this.updateHandler=(c,u,f,g)=>{const{composing:x}=c;if(x||!u&&!f)return;if(!this.getShouldShow(g)){this.hide();return}this.show(),this.updatePosition()},this.transactionHandler=({transaction:c})=>{const u=c.getMeta(this.pluginKey);u==="updatePosition"?this.updatePosition():u&&typeof u=="object"&&u.type==="updateOptions"?this.updateOptions(u.options):u==="hide"?this.hide():u==="show"&&(this.updatePosition(),this.show())};var h;this.editor=e,this.element=t,this.view=n,this.pluginKey=i,this.updateDelay=s,this.resizeDelay=r,this.appendTo=l,this.scrollTarget=(h=p==null?void 0:p.scrollTarget)!=null?h:window,this.getReferencedVirtualElement=d,this.floatingUIOptions={...this.floatingUIOptions,...p},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.get
41ShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(Mn(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Tn(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(On(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(Pn(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(An(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(En(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(In(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(_n(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}get virtualElement(){var e,t,n;const{selection:i}=this.editor.state,s=(e=this.getReferencedVirtualElement)==null?void 0:e.call(this);if(s)return s;if(!((n=(t=this.view)==null?void 0:t.dom)!=null&&n.parentNode))return;const r=qt(this.view,i.from,i.to);let a={getBoundingClientRect:()=>r,getClientRects:()=>[r]};if(i instanceof ui){let l=this.view.nodeDOM(i.from);const d=l.dataset.nodeViewWrapper?l:l.querySelector("[data-node-view-wrapper]");d&&(l=d),l&&(a={getBoundingClientRect:()=>l.getBoundingClientRect(),getClientRects:()=>[l.getBoundingClientRect()]})}if(i instanceof pi){const{$anchorCell:l,$headCell:d}=i,p=l?l.pos:d.pos,h=d?d.pos:l.pos,c=this.view.nodeDOM(p),u=this.view.nodeDOM(h);if(!c||!u)return;const f=c===u?c.getBoundingClientRect():Mo(c.getBoundingClientRect(),u.getBoundingClientRect());a={getBoundingClientRect:()=>f,getClientRects:()=>[f]}}return a}updatePosition(){if(!this.isVisible)return;const e=this.virtualElement;e&&kn(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:n,strategy:i,middlewareData:s})=>{var r,a;if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if((r=s.hide)!=null&&r.referenceHidden||(a=s.hide)!=null&&a.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=i,this.element.style.left=`${t}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){const{state:n}=e,i=n.selection.from!==n.selection.to;if(this.updateDelay>0&&i){this.handleDebouncedUpdate(e,t);return}const s=!(t!=null&&t.selection.eq(e.state.selection)),r=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,s,r,t)}getShouldShow(e){var t;const{state:n}=this.view,{selection:i}=n,{ranges:s}=i,r=Math.min(...s.map(d=>d.$from.pos)),a=Math.max(...s.map(d=>d.$to.pos));return((t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:e,from:r,to:a}))||!1}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const n=(t=e.options.scrollTarget)!=null?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Dn=e=>new Wt({key:typeof e.pluginKey=="string"?new nt(e.pluginKey):e.pluginKey,view:t=>new Ao({view:t,...e})});Gt.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Dn({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var Io=class{constructor({editor:e,element:t,view:n,pluginKey:i="floatingMenu",updateDelay:s=250,resizeDelay:r=60,options:a,appendTo:l,shouldShow:d}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:h,state:c})=>{const{selection:u}=c,{$anchor:f,empty:g}=u,x=f.depth===1,v=f.parent.isTextblock&&!f.parent.type.spec.code&&!f.parent.textContent&&f.parent.childCount===0&&!this.getTextContent(f.parent);return!(!h.hasFocus()||!g||!x||!v||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(h,c,u,f)=>{const{composing:g}=h;if(g||!c&&!u)return;if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:h})=>{var c;if(this.preventHide){this.preventHide=!1;return}h!=null&&h.relatedTarget&&((c=this.element.parentNode)!=null&&c.contains(h.relatedTarget))||(h==null?void 0:h.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:h})=>{const c=h.getMeta(this.pluginKey);c==="updatePosition"?this.updatePosition():c&&typeof c=="object"&&c.type==="updateOptions"?this.updateOptions(c.options):c==="hide"?this.hide():c==="show"&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)};var p;this.editor=e,this.element=t,this.view=n,this.pluginKey=i,this.updateDelay=s,this.resizeDelay=r,this.appendTo=l,this.scrollTarget=(p=a==null?void 0:a.scrollTarget)!=null?p:window,this.floatingUIOptions={...this.floatingUIOptions,...a},this.element.tabIndex=0,d&&(this.shouldShow=d),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.get
41ShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return di(e,{textSerializers:fi(this.editor.schema)})}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(Mn(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Tn(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(On(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(Pn(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(An(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(En(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(In(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(_n(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}getShouldShow(e){var t;const{state:n}=this.view,{selection:i}=n,{ranges:s}=i,r=Math.min(...s.map(d=>d.$from.pos)),a=Math.max(...s.map(d=>d.$to.pos));return(t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,view:this.view,state:n,oldState:e,from:r,to:a})}updateOptions(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const n=(t=e.options.scrollTarget)!=null?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){const{selection:e}=this.editor.state,t=qt(this.view,e.from,e.to);kn({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:i,y:s,strategy:r,middlewareData:a})=>{var l,d;if((l=a.hide)!=null&&l.referenceHidden||(d=a.hide)!=null&&d.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${i}px`,this.element.style.top=`${s}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const n=!(t!=null&&t.selection.eq(e.state.selection)),i=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,n,i,t)}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Ln=e=>new Wt({key:typeof e.pluginKey=="string"?new nt(e.pluginKey):e.pluginKey,view:t=>new Io({view:t,...e})});Gt.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[Ln({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function Un(e,t){return e??new nt(t)}var Po=typeof window<"u"?m.useLayoutEffect:m.useEffect,Hn=new Set(["left","opacity","position","top","visibility","width"]),_o=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","o
41pacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),ko=new Set(["children","className","style"]),Do=new Set(["tabIndex"]),Lo=new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),Uo={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function Qe(e,t){return/^on[A-Z]/.test(e)&&typeof t=="function"}function Ho(e){return e.startsWith("aria-")||e.startsWith("data-"),e}function $o(e){return e.startsWith("aria-")||e.startsWith("data-")||Lo.has(e)}function $n(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function zo(e){var t;const n=e.endsWith("Capture"),s=(n?e.slice(0,-7):e).slice(2);return{eventName:(t=Uo[s])!=null?t:s.toLowerCase(),options:n?{capture:!0}:void 0}}function Bo(e,t){let n=t.defaultPrevented,i=!1;const s=Object.create(t);return Object.defineProperties(s,{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>{}},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>i},preventDefault:{value:()=>{n=!0,t.preventDefault()}},stopPropagation:{value:()=>{i=!0,t.stopPropagation()}}}),s}function qe(e){return Do.has(e)}function Dt(e,t,n){if(t==="tabIndex"){e.tabIndex=Number(n);return}e[t]=n}function Vo(e,t){if(t==="tabIndex"){e.removeAttribute("tabindex");return}const n=e[t];if(typeof n=="boolean"){e[t]=!1;return}if(typeof n=="number"){e[t]=0;return}e[t]=""}function Fo(e,t){return typeof t!="number"||t===0||e.startsWith("--")||_o.has(e)?String(t):`${t}px`}function Ko(e,t){Hn.has(t)||e.style.removeProperty($n(t))}function Wo(e,t,n){Hn.has(t)||e.style.setProperty($n(t),Fo(t,n))}function Go(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(s=>{if(ko.has(s)||!$o(s)||Qe(s,t[s])||Qe(s,n[s]))return;const r=t[s],a=n[s];if(r===a)return;const l=Ho(s);if(a==null||a===!1){qe(s)&&Vo(e,s),e.removeAttribute(l);return}if(a===!0){qe(s)&&Dt(e,s,!0),e.setAttribute(l,"");return}if(qe(s)){Dt(e,s,a);return}e.setAttribute(l,String(a))})}function qo(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute("class")}}function Yo(e,t,n){const i=t??{},s=n??{};new Set([...Object.keys(i),...Object.keys(s)]).forEach(a=>{const l=i[a],d=s[a];if(l!==d){if(d==null){Ko(e,a);return}Wo(e,a,d)}})}function Xo(e,t,n){t.forEach(({eventName:s,listener:r,options:a})=>{e.removeEventListener(s,r,a)});const i=[];return Object.entries(n).forEach(([s,r])=>{if(!Qe(s,r))return;const{eventName:a,options:l}=zo(s),d=p=>{r(Bo(e,p))};e.addEventListener(a,d,l),i.push({eventName:a,listener:d,options:l})}),i}function zn(e,t){const n=m.useRef({}),i=m.useRef([]);Po(()=>{const s=n.current;return qo(e,s.className,t.className),Yo(e,s.style,t.style),Go(e,s,t),i.current=Xo(e,i.current,t),n.current=t,()=>{i.current.forEach(({eventName:r,listener:a,options:l})=>{e.removeEventListener(r,a,l)}),i.current=[]}},[e,t])}var Jo=Ut.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:i,appendTo:s,shouldShow:r=null,getReferencedVirtualElement:a,options:l,children:d,...p},h)=>{const c=m.useRef(document.createElement("div")),u=m.useRef(Un(e,"bubbleMenu")).current;zn(c.current,p),typeof h=="function"?h(c.current):h&&(h.current=c.current);const{editor:f}=Yt(),g=t||f,x={updateDelay:n,resizeDelay:i,appendTo:s,pluginKey:u,shouldShow:r,getReferencedVirtualElement:a,options:l},v=m.useRef(x);v.current=x;const[b,y]=m.useState(!1),C=m.useRef(!0);return m.useEffect(()=>{if(g!=null&&g.isDestroyed)return;if(!g){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const S=c.current;S.style.visibility="hidden",S.style.position="absolute";const R=Dn({...v.current,editor:g,element:S});g.registerPlugin(R);const j=v.current.pluginKey;return C.current=!0,y(!0),()=>{y(!1),g.unregisterPlugin(j),window.requestAnimationFrame(()=>{S.parentNode&&S.parentNode.removeChild(S)})}},[g]),m.useEffect(()=>{if(!(!b||!g||g.isDestroyed)){if(C.current){C.current=!1;return}g.view.dispatch(g.state.tr.setMeta(u,{type:"updateOptions",options:v.current}))}},[b,g,n,i,r,l,s,a,u]),Ht.createPortal(d,c.current)}),Zo=Ut.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:i,appendTo:s,shouldShow:r=null,options:a,children:l,...d},p)=>{const h=m.useRef(document.createElement("div")),c=m.useRef(Un(e,"floatingMenu")).current;zn(h.current,d),typeof p=="function"?p(h.current):p&&(p.current=h.current);const{editor:u}=Yt(),f=t||u,g={updateDelay:n,resizeDelay:i,appendTo:s,pluginKey:c,shouldShow:r,options:a},x=m.useRef(g);x.current=g;const[v,b]=m.useState(!1),y=m.useRef(!0);return m.useEffect(()=>{if(f!=null&&f.isDestroyed)return;if(!f){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const C=h.current;C.style.visibility="hidden",C.style.position="absolute";const S=Ln({...x.current,editor:f,element:C});f.registerPlugin(S);const R=x.current.pluginKey;return y.current=!0,b(!0),()=>{b(!1),f.unregisterPlugin(R),window.requestAnimationFrame(()=>{C.parentNode&&C.parentNode.removeChild(C)})}},[f]),m.useEffect(()=>{if(!(!v||!f||f.isDestroyed)){if(y.current){y.current=!1;return}f.view.dispatch(f.state.tr.setMeta(c,{type:"updateOptions",options:x.current}))}},[v,f,n,i,r,a,s,c]),Ht.createPortal(l,h.current)});const Qo=({editor:e})=>{const[t,n]=m.useState(!1),i=m.useRef(null),s=m.useRef(null);m.useEffect(()=>{if(!e)return;const u=()=>n(!1);return e.on("selectionUpdate",u),()=>{e.off("selectionUpdate",u)}},[e]);const r=m.useCallback(async u=>{const{data:{user:f}}=await F.auth.getUser();if(!f){J.error("Not authenticated");return}const g=u.name.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/-+/g,"-"),x=`${f.id}/${Date.now()}-${g}`,{error:v}=await F.storage.from("blog-images").upload(x,u,{contentType:u.type,upsert:!1});if(v){console.error("Blog image upload failed",v),J.error(`Image upload failed: ${v.message}`);return}const{data:{publicUrl:b}}=F.storage.from("blog-images").getPublicUrl(x);e.chain().focus().insertContent({type:"figure",content:[{type:"image",attrs:{src:b}},{type:"figcaption"}]}).run(),n(!1)},[e]),a=m.useCallback(async(u,f)=>{const g=u.name.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/-+/g,"-"),x=`${f}/${Date.now()}-${Math.random().toString(36).slice(2,8)}-${g}`,{error:v}=await F.storage.from("blog-images").upload(x,u,{contentType:u.type,upsert:!1});return v?(console.error("Blog image upload failed",v),J.error(`Image upload failed: ${v.message}`),null):F.storage.from("blog-images").getPublicUrl(x).data.publicUrl},[]),l=m.useCallback(async u=>{const{data:{user:f}}=await F.auth.getUser();if(!f){J.error("Not authenticated");return}if(u.length<2){J.error("Pick at least 2 images for a carousel");return}J.info(`Uploading ${u.length} imagesâ¦`);const g=[];for(const x of u){const v=await a(x,f.id);
41v&&g.push(v)}g.length!==0&&(e.chain().focus().insertContent({type:"carousel",content:g.map(x=>({type:"figure",content:[{type:"image",attrs:{src:x}},{type:"figcaption"}]}))}).run(),J.success("Carousel added â click a caption to edit"),n(!1))},[e,a]),d=u=>{u(),n(!1)},p=()=>{const u=window.prompt("Paste a YouTube or Vimeo URL:");if(!u){n(!1);return}/youtu\.?be/.test(u)?e.chain().focus().setYoutubeVideo({src:u}).run():e.chain().focus().insertContent(`<div data-embed="true"><iframe src="${u}" frameborder="0" allowfullscreen style="width:100%;aspect-ratio:16/9;"></iframe></div>`).run(),n(!1)},h=()=>{const u=window.prompt("Paste a URL to embed (Twitter, CodePen, Spotify, etc.):");if(!u){n(!1);return}e.chain().focus().insertContent(`<div data-embed="true"><iframe src="${u}" frameborder="0" allowfullscreen style="width:100%;min-height:400px;"></iframe></div>`).run(),n(!1)},c=({onClick:u,title:f,children:g})=>o.jsx("button",{type:"button",onClick:u,title:f,children:g});return o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:i,type:"file",accept:"image/*",className:"hidden",onChange:u=>{var g;const f=(g=u.target.files)==null?void 0:g[0];f&&r(f),u.target.value=""}}),o.jsx("input",{ref:s,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:u=>{const f=Array.from(u.target.files??[]);f.length&&l(f),u.target.value=""}}),o.jsx(Zo,{editor:e,options:{placement:"left",offset:12},shouldShow:({state:u})=>{const{$from:f}=u.selection;return f.parent.type.name==="paragraph"&&f.parent.content.size===0},children:o.jsxs("div",{className:"slash-menu-container",children:[o.jsx("button",{type:"button",className:"slash-menu-trigger",onClick:()=>n(!t),title:"Add",children:o.jsx(Ye,{className:`w-5 h-5 transition-transform duration-200 ${t?"rotate-45":""}`})}),t&&o.jsxs("div",{className:"slash-menu-items",children:[o.jsx(c,{onClick:()=>{var u;return(u=i.current)==null?void 0:u.click()},title:"Add image",children:o.jsx(hn,{className:"w-4 h-4"})}),o.jsx(c,{onClick:()=>{var u;return(u=s.current)==null?void 0:u.click()},title:"Add image carousel",children:o.jsx(Ui,{className:"w-4 h-4"})}),o.jsx(c,{onClick:p,title:"Add video",children:o.jsx(Os,{className:"w-4 h-4"})}),o.jsx(c,{onClick:h,title:"Embed",children:o.jsx(ri,{className:"w-4 h-4"})}),o.jsx(c,{onClick:()=>d(()=>e.chain().focus().toggleCodeBlock().run()),title:"Code block",children:o.jsx(Si,{className:"w-4 h-4"})}),o.jsx(c,{onClick:()=>d(()=>e.chain().focus().setHorizontalRule().run()),title:"New part",children:o.jsx(Ni,{className:"w-4 h-4"})})]})]})})]})},ea=({editor:e})=>{const t=()=>{const a=e.getAttributes("link").href,l=window.prompt("Enter URL:",a||"");l!==null&&(l===""?e.chain().focus().unsetLink().run():e.chain().focus().setLink({href:l}).run())},n=()=>{e.isActive("heading",{level:1})||(e.isActive("heading",{level:2})?e.chain().focus().toggleHeading({level:1}).run():e.isActive("heading",{level:3})?e.chain().focus().toggleHeading({level:2}).run():e.chain().focus().toggleHeading({level:3}).run())},i=()=>{e.isActive("heading",{level:1})?e.chain().focus().toggleHeading({level:2}).run():e.isActive("heading",{level:2})?e.chain().focus().toggleHeading({level:3}).run():e.isActive("heading",{level:3})&&e.chain().focus().setParagraph().run()},s=()=>e.isActive("heading",{level:1})?"H1":e.isActive("heading",{level:2})?"H2":e.isActive("heading",{level:3})?"H3":"P",r=()=>{if(e.isActive("adminComment")){const a=e.getAttributes("adminComment").comment||"",l=window.prompt("Edit admin comment (leave blank to remove):",a);if(l===null)return;l.trim()===""?e.chain().focus().unsetAdminComment().run():e.chain().focus().setAdminComment(l).run()}else{const a=window.prompt("Add an admin comment (visible only in the editor, not on the published post):");a&&a.trim()&&e.chain().focus().setAdminComment(a).run()}};return o.jsx(Jo,{editor:e,options:{placement:"top",offset:8},shouldShow:({state:a})=>{const{from:l,to:d}=a.selection;return l!==d},children:o.jsxs("div",{className:"bubble-menu-pill",children:[o.jsx("button",{type:"button",onClick:()=>e.chain().focus().toggleBold().run(),className:e.isActive("bold")?"is-active":"",title:"Bold",children:o.jsx(bi,{className:"w-4 h-4"})}),o.jsx("button",{type:"button",onClick:()=>e.chain().focus().toggleItalic().run(),className:e.isActive("italic")?"is-active":"",title:"Italic",children:o.jsx(wi,{className:"w-4 h-4"})}),o.jsx("span",{className:"bubble-sep"}),o.jsx("button",{type:"button",onClick:t,className:e.isActive("link")?"is-active":"",title:"Link",children:o.jsx(ji,{className:"w-4 h-4"})}),o.jsx("span",{className:"bubble-sep"}),o.jsx("button",{type:"button",onClick:n,title:"Increase text size",children:o.jsx(Ri,{className:"w-4 h-4"})}),o.jsx("span",{className:"bubble-level",children:s()}),o.jsx("button",{type:"button",onClick:i,title:"Decrease text size",children:o.jsx(Es,{className:"w-4 h-4"})}),o.jsx("span",{className:"bubble-sep"}),o.jsx("button",{type:"button",onClick:()=>e.chain().focus().toggleBlockquote().run(),className:e.isActive("blockquote")?"is-active":"",title:"Quote",children:o.jsx(Bi,{className:"w-4 h-4"})}),o.jsx("button",{type:"button",onClick:()=>e.chain().focus().toggleHighlight().run(),className:e.isActive("highlight")?"is-active":"",title:"Highlight",children:o.jsx(Hi,{className:"w-4 h-4"})}),o.jsx("span",{className:"bubble-sep"}),o.jsx("button",{type:"button",onClick:r,className:e.isActive("adminComment")?"is-active":"",title:"Admin comment (editor-only, hidden from readers)",children:o.jsx(mn,{className:"w-4 h-4"})})]})})};var lt="ContextMenu",[ta,Cr]=Ts(lt,[$t]),B=$t(),[na,Bn]=ta(lt),Vn=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:i,dir:s,modal:r=!0}=e,[a,l]=m.useState(!1),d=B(t),p=Ks(i),h=m.useCallback(c=>{l(c),p(c)},[p]);return o.jsx(na,{scope:t,open:a,onOpenChange:h,modal:r,children:o.jsx(Ws,{...d,dir:s,open:a,onOpenChange:h,modal:r,children:n})})};Vn.displayName=lt;var Fn="ContextMenuTrigger",Kn=m.forwardRef((e,t)=>
41{const{__scopeContextMenu:n,disabled:i=!1,...s}=e,r=Bn(Fn,n),a=B(n),l=m.useRef({x:0,y:0}),d=m.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),p=m.useRef(0),h=m.useCallback(()=>window.clearTimeout(p.current),[]),c=u=>{l.current={x:u.clientX,y:u.clientY},r.onOpenChange(!0)};return m.useEffect(()=>h,[h]),m.useEffect(()=>void(i&&h()),[i,h]),o.jsxs(o.Fragment,{children:[o.jsx(Ms,{...a,virtualRef:d}),o.jsx(As.span,{"data-state":r.open?"open":"closed","data-disabled":i?"":void 0,...s,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:i?e.onContextMenu:je(e.onContextMenu,u=>{h(),c(u),u.preventDefault()}),onPointerDown:i?e.onPointerDown:je(e.onPointerDown,Ae(u=>{h(),p.current=window.setTimeout(()=>c(u),700)})),onPointerMove:i?e.onPointerMove:je(e.onPointerMove,Ae(h)),onPointerCancel:i?e.onPointerCancel:je(e.onPointerCancel,Ae(h)),onPointerUp:i?e.onPointerUp:je(e.onPointerUp,Ae(h))})]})});Kn.displayName=Fn;var sa="ContextMenuPortal",Wn=e=>{const{__scopeContextMenu:t,...n}=e,i=B(t);return o.jsx(Fs,{...i,...n})};Wn.displayName=sa;var Gn="ContextMenuContent",qn=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...i}=e,s=Bn(Gn,n),r=B(n),a=m.useRef(!1);return o.jsx(Is,{...r,...i,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:l=>{var d;(d=e.onCloseAutoFocus)==null||d.call(e,l),!l.defaultPrevented&&a.current&&l.preventDefault(),a.current=!1},onInteractOutside:l=>{var d;(d=e.onInteractOutside)==null||d.call(e,l),!l.defaultPrevented&&!s.modal&&(a.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});qn.displayName=Gn;var ia="ContextMenuGroup",oa=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...i}=e,s=B(n);return o.jsx(Ps,{...s,...i,ref:t})});oa.displayName=ia;var aa="ContextMenuLabel",Yn=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...i}=e,s=B(n);return o.jsx(_s,{...s,...i,ref:t})});Yn.displayName=aa;var ra="ContextMenuItem",Xn=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...i}=e,s=B(n);return o.jsx(ks,{...s,...i,ref:t})});Xn.displayName=ra;var la="ContextMenuCheckboxItem",Jn=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...i}=e,s=B(n);return o.jsx(Ds,{...s,...i,ref:t})});Jn.displayName=la;var ca="ContextMenuRadioGroup",ua=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...i}=e,s=B(n);return o.jsx(Ls,{...s,...i,ref:t})});ua.displayName=ca;var da="ContextMenuRadioItem",Zn=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...i}=e,s=B(n);return o.jsx(Us,{...s,...i,ref:t})});Zn.displayName=da;var fa="ContextMenuItemIndicator",Qn=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...i}=e,s=B(n);return o.jsx(Hs,{...s,...i,ref:t})});Qn.displayName=fa;var ha="ContextMenuSeparator",es=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...i}=e,s=B(n);return o.jsx($s,{...s,...i,ref:t})});es.displayName=ha;var ma="ContextMenuArrow",pa=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...i}=e,s=B(n);return o.jsx(zs,{...s,...i,ref:t})});pa.displayName=ma;var ga="ContextMenuSubTrigger",ts=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...i}=e,s=B(n);return o.jsx(Bs,{...s,...i,ref:t})});ts.displayName=ga;var xa="ContextMenuSubContent",ns=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...i}=e,s=B(n);return o.jsx(Vs,{...s,...i,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ns.displayName=xa;function Ae(e){return t=>t.pointerType!=="mouse"?e(t):void 0}var va=Vn,ba=Kn,wa=Wn,ss=qn,is=Yn,os=Xn,as=Jn,rs=Zn,ls=Qn,cs=es,us=ts,ds=ns;const ya=va,Ca=ba,Sa=m.forwardRef(({className:e,inset:t,children:n,...i},s)=>o.jsxs(us,{ref:s,className:G("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent data-[state=open]:text-accent-foreground focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...i,children:[n,o.jsx(Gs,{className:"ml-auto h-4 w-4"})]}));Sa.displayName=us.displayName;const Na=m.forwardRef(({className:e,...t},n)=>o.jsx(ds,{ref:n,className:G("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]:sli
41de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));Na.displayName=ds.displayName;const fs=m.forwardRef(({className:e,...t},n)=>o.jsx(wa,{children:o.jsx(ss,{ref:n,className:G("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 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",e),...t})}));fs.displayName=ss.displayName;const xe=m.forwardRef(({className:e,inset:t,...n},i)=>o.jsx(os,{ref:i,className:G("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...n}));xe.displayName=os.displayName;const ja=m.forwardRef(({className:e,children:t,checked:n,...i},s)=>o.jsxs(as,{ref:s,className:G("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),checked:n,...i,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(ls,{children:o.jsx(qs,{className:"h-4 w-4"})})}),t]}));ja.displayName=as.displayName;const Ra=m.forwardRef(({className:e,children:t,...n},i)=>o.jsxs(rs,{ref:i,className:G("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...n,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(ls,{children:o.jsx(Ys,{className:"h-2 w-2 fill-current"})})}),t]}));Ra.displayName=rs.displayName;const et=m.forwardRef(({className:e,inset:t,...n},i)=>o.jsx(is,{ref:i,className:G("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",e),...n}));et.displayName=is.displayName;const tt=m.forwardRef(({className:e,...t},n)=>o.jsx(cs,{ref:n,className:G("-mx-1 my-1 h-px bg-border",e),...t}));tt.displayName=cs.displayName;const Oa=({editor:e,children:t})=>{const[n,i]=m.useState(""),[s,r]=m.useState(!1),[a,l]=m.useState(null),d=m.useRef(null),p=m.useCallback(x=>{const b=x.target.closest("img");if(!b)return null;const y=e.view,C=b.closest("figure.blog-figure");if(C){const j=y.posAtDOM(C,0);if(j==null)return null;const T=y.state.doc.resolve(j);for(let O=T.depth;O>=0;O--){const E=T.node(O);if(E.type.name==="figure")return{pos:T.before(O),node:E}}return null}const S=y.posAtDOM(b,0);if(S==null)return null;const R=y.state.doc.resolve(S);for(let j=R.depth;j>=0;j--){const T=R.node(j);if(T.type.name==="image"){const O=R.before(j),{schema:E}=y.state;if(!E.nodes.figure||!E.nodes.figcaption)return null;const N=E.nodes.figure.create({layout:"normal"},[E.nodes.image.create(T.attrs),E.nodes.figcaption.create()]),A=y.state.tr.replaceRangeWith(O,O+T.nodeSize,N);return y.dispatch(A),{pos:O,node:N}}}return null},[e]),h=m.useCallback(x=>{var b;const v=p(x);if(v){l(v.pos);const y=v.node.firstChild;i(((b=y==null?void 0:y.attrs)==null?void 0:b.alt)||""),r(!1)}},[p]),c=m.useCallback(x=>{if(a==null)return;const v=e.state.tr,b=e.state.doc.nodeAt(a);b&&b.type.name==="figure"&&(v.setNodeMarkup(a,void 0,{...b.attrs,layout:x}),e.view.dispatch(v))},[e,a]),u=m.useCallback(()=>{if(a==null||!e.state.doc.nodeAt(a))return;const v=a+1,b=e.state.doc.nodeAt(v);if(b&&b.type.name==="image"){const y=e.state.tr;y.setNodeMarkup(v,void 0,{...b.attrs,alt:n}),e.view.dispatch(y)}r(!1)},[e,a,n]),f=m.useCallback(()=>{if(a==null)return;const x=e.state.doc.nodeAt(a);if(!x)return;const v=x.firstChild;if(!v)return;const b=a+1+v.nodeSize+1;e.chain().focus().setTextSelection(b).scrollIntoView().run()},[e,a]),g=(()=>{var v;if(a==null)return"normal";const x=e.state.doc.nodeAt(a);return((v=x==null?void 0:x.attrs)==null?void 0:v.layout)||"normal"})();return o.jsxs(ya,{children:[o.jsx(Ca,{asChild:!0,onContextMenu:h,children:t}),o.jsxs(fs,{className:"w-56 bg-card text-card-foreground border-border",children:[o.jsx(et,{className:"text-xs text-muted-foreground",children:"Image Options"}),o.jsx(tt,{}),o.jsxs(xe,{onClick:f,className:"gap-2 cursor-pointer",children:[o.jsx(yi,{className:"h-4 w-4"})," Edit Caption"]}),o.jsxs(xe,{onClick:x=>{x.preventDefault(),r(!0),setTimeout(()=>{var v;return(v=d.current)==null?void 0:v.focus()},50)},className:"gap-2 cursor-pointer",children:[o.jsx(hn,{className:"h-4 w-4"})," Alt Text"]}),s&&o.jsx("div",{className:"px-2 py-1.5",children:o.jsx(pe,{ref:d,value:n,onChange:x=>i(x.target.value),onKeyDown:x=>{x.key==="Enter"&&u(),x.stopPropagation()},onBlur:u,placeholder:"Describe image for accessibilityâ¦",className:"h-7 text-xs"})}),o.jsx(tt,{}),o.jsx(et,{className:"text-xs text-muted-foreground",children:"Layout"}),o.jsxs(xe,{onClick:()=>c("normal"),className:`gap-2 cursor-pointer ${g==="normal"?"bg-accent":""}`,children:[o.jsx(Li,{className:"h-4 w-4"})," Normal (720px)"]}),o.jsxs(xe,{onClick:()=>c("outset"),className:`gap-2 cursor-pointer ${g==="outset"?"bg-accent":""}`,children:[o.jsx(zi,{className:"h-4 w-4"})," Outset (~900px)"]}
41),o.jsxs(xe,{onClick:()=>c("wide"),className:`gap-2 cursor-pointer ${g==="wide"?"bg-accent":""}`,children:[o.jsx($i,{className:"h-4 w-4"})," Wide (full width)"]})]})]})};function Ea(e){const{state:t}=e,{schema:n}=t;if(!n.nodes.figure||!n.nodes.figcaption)return;const i=t.tr;let s=!1;const r=[];t.doc.descendants((a,l,d)=>{a.type.name==="image"&&d&&d.type.name!=="figure"&&r.push({pos:l,attrs:a.attrs})});for(let a=r.length-1;a>=0;a--){const{pos:l,attrs:d}=r[a],p=n.nodes.image.create(d),h=n.nodes.figcaption.create(),c=n.nodes.figure.create({layout:"normal"},[p,h]),u=t.doc.nodeAt(l);u&&(i.replaceRangeWith(l,l+u.nodeSize,c),s=!0)}s&&(i.setMeta("addToHistory",!1),e.view.dispatch(i))}const Ta=({content:e,onChange:t,onWordCount:n,onEditorReady:i})=>{const s=hi({extensions:[Xt.configure({heading:{levels:[1,2,3]}}),Qt.configure({inline:!1,allowBase64:!1}),Jt.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),en.configure({types:["heading","paragraph"]}),Zt,Ci.configure({placeholder:"Start writing your story..."}),tn,nn,sn.configure({nested:!0}),on.configure({resizable:!0}),an,rn,ln,cn.configure({inline:!1,ccLanguage:"en"}),un,dn,fn,gi],content:e||void 0,onUpdate:({editor:a})=>{t(a.getJSON());const l=a.getText();n==null||n(l.split(/\s+/).filter(Boolean).length)},editorProps:{attributes:{class:"blog-prose min-h-[400px] focus:outline-none"}}});m.useEffect(()=>{if(s&&e&&!s.isFocused){const a=JSON.stringify(s.getJSON()),l=JSON.stringify(e);if(a!==l&&Object.keys(e).length>0){s.commands.setContent(e),queueMicrotask(()=>Ea(s));const d=s.getText();n==null||n(d.split(/\s+/).filter(Boolean).length)}}},[e,s,n]),m.useEffect(()=>{if(!s)return;const a=s.getText();n==null||n(a.split(/\s+/).filter(Boolean).length)},[s,n]),m.useEffect(()=>{s&&i&&i(s)},[s,i]);const r=(s==null?void 0:s.isActive("table"))??!1;return s?o.jsx(Oa,{editor:s,children:o.jsxs("div",{className:"relative",children:[r&&o.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 mb-2 border rounded-md bg-muted/20 text-xs",children:[o.jsx("span",{className:"font-medium mr-2 text-foreground/70",children:"Table:"}),o.jsxs(q,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1",onClick:()=>s.chain().focus().addRowAfter().run(),children:[o.jsx(Ye,{className:"w-3 h-3"}),o.jsx(Nt,{className:"w-3 h-3"})," Row"]}),o.jsxs(q,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1",onClick:()=>s.chain().focus().deleteRow().run(),children:[o.jsx(wt,{className:"w-3 h-3"}),o.jsx(Nt,{className:"w-3 h-3"})," Row"]}),o.jsxs(q,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1",onClick:()=>s.chain().focus().addColumnAfter().run(),children:[o.jsx(Ye,{className:"w-3 h-3"}),o.jsx(St,{className:"w-3 h-3"})," Col"]}),o.jsxs(q,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1",onClick:()=>s.chain().focus().deleteColumn().run(),children:[o.jsx(wt,{className:"w-3 h-3"}),o.jsx(St,{className:"w-3 h-3"})," Col"]}),o.jsxs(q,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1 text-destructive hover:text-destructive",onClick:()=>s.chain().focus().deleteTable().run(),children:[o.jsx(Oi,{className:"w-3 h-3"})," Delete"]})]}),o.jsx(Qo,{editor:s}),o.jsx(ea,{editor:s}),o.jsx(pt,{editor:s})]})}):o.jsx("div",{className:"relative",children:o.jsx(pt,{editor:s})})},Ma=Js,Aa=Zs,Ia=Qs,hs=m.forwardRef(({className:e,...t},n)=>o.jsx(zt,{className:G("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",e),...t,ref:n}));hs.displayName=zt.displayName;const Pa=ei("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"}}),ms=m.forwardRef(({side:e="right",className:t,children:n,...i},s)=>o.jsxs(Ia,{children:[o.jsx(hs,{}),o.jsxs(Bt,{ref:s,className:G(Pa({side:e}),t),...i,children:[n,o.jsxs(Xs,{className:"absolute right-4 top-4 roun
41ded-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:[o.jsx(Vt,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ms.displayName=Bt.displayName;const ps=({className:e,...t})=>o.jsx("div",{className:G("flex flex-col space-y-2 text-center sm:text-left",e),...t});ps.displayName="SheetHeader";const gs=m.forwardRef(({className:e,...t},n)=>o.jsx(Ft,{ref:n,className:G("text-lg font-semibold text-foreground",e),...t}));gs.displayName=Ft.displayName;const _a=m.forwardRef(({className:e,...t},n)=>o.jsx(Kt,{ref:n,className:G("text-sm text-muted-foreground",e),...t}));_a.displayName=Kt.displayName;const ka=e=>{const{title:t,slug:n,seoDescription:i,coverImageUrl:s,excerpt:r,tags:a,wordCount:l}=e,d=a.split(",").map(f=>f.trim()).filter(Boolean),p=[],h=t.length;h>=50&&h<=60?p.push({label:"Title length",score:20,max:20,status:"good",hint:`${h} chars - perfect`}):h>=30&&h<=70?p.push({label:"Title length",score:14,max:20,status:"warning",hint:`${h} chars - aim for 50-60`}):p.push({label:"Title length",score:5,max:20,status:"poor",hint:`${h} chars - should be 50-60`});const c=i.length;c>=120&&c<=160?p.push({label:"Meta description",score:20,max:20,status:"good",hint:`${c} chars - perfect`}):c>=80&&c<=200&&c>0?p.push({label:"Meta description",score:14,max:20,status:"warning",hint:`${c} chars - aim for 120-160`}):p.push({label:"Meta description",score:c>0?5:0,max:20,status:"poor",hint:c>0?`${c} chars - should be 120-160`:"Missing"}),n&&n.length>3&&!n.includes(" ")?p.push({label:"URL slug",score:10,max:10,status:"good",hint:"Readable slug set"}):p.push({label:"URL slug",score:n?5:0,max:10,status:n?"warning":"poor",hint:n?"Could be improved":"Missing"}),p.push({label:"Cover image",score:s?15:0,max:15,status:s?"good":"poor",hint:s?"Set":"Missing - adds visual appeal"}),p.push({label:"Excerpt",score:r.length>10?15:r.length>0?8:0,max:15,status:r.length>10?"good":r.length>0?"warning":"poor",hint:r.length>10?"Good summary":r.length>0?"Too short":"Missing"});const u=d.length;return u>=1&&u<=5?p.push({label:"Tags",score:10,max:10,status:"good",hint:`${u} tags`}):u>5?p.push({label:"Tags",score:7,max:10,status:"warning",hint:"Too many - aim for 1-5"}):p.push({label:"Tags",score:0,max:10,status:"poor",hint:"No tags added"}),l>=300?p.push({label:"Content length",score:10,max:10,status:"good",hint:`${l} words`}):l>=100?p.push({label:"Content length",score:6,max:10,status:"warning",hint:`${l} words - aim for 300+`}):p.push({label:"Content length",score:2,max:10,status:"poor",hint:`${l} words - too short`}),p},Da=({status:e})=>e==="good"?o.jsx(Mi,{className:"w-4 h-4 text-green-500"}):e==="warning"?o.jsx(Ai,{className:"w-4 h-4 text-yellow-500"}):o.jsx(Ii,{className:"w-4 h-4 text-red-500"}),La=e=>{const t=ka(e),n=t.reduce((i,s)=>i+s.score,0);return o.jsxs("div",{className:"space-y-3 rounded-lg border border-border p-4 bg-muted/30",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm font-semibold",children:"SEO Score"}),o.jsxs("span",{className:`text-lg font-bold ${n>=80?"text-green-600":n>=50?"text-yellow-600":"text-red-600"}`,children:[n,"/100"]})]}),o.jsx(Ti,{value:n,className:"h-2"}),o.jsx("div",{className:"space-y-2 mt-2",children:t.map(i=>o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx(Da,{status:i.status}),o.jsx("span",{className:"font-medium min-w-[120px]",children:i.label}),o.jsx("span",{className:"text-muted-foreground text-xs",children:i.hint})]},i.label))})]})},Ua=({editor:e,containerRef:t})=>{const[n,i]=m.useState([]),[s,r]=m.useState(null),a=m.useRef(),l=m.useCallback(()=>{if(!e||!t.current)return;const c=e.view.dom,u=t.current.getBoundingClientRect(),f=c.querySelectorAll("span[data-admin-comment]"),g=[],x=new Map;f.forEach((C,S)=>{var k;const R=C.getAttribute("data-comment")||"";if(!R)return;const T=C.getBoundingClientRect().top-u.top,O=(C.textContent||"").slice(0,80);let E=0,N=0;try{const I=e.view.posAtDOM(C,0);E=I,N=I+(((k=C.textContent)==null?void 0:k.length)||0)}catch{}const A=`${E}-${N}-${R}`;if(x.has(A))return;const _={id:`c-${S}-${E}`,comment:R,snippet:O,top:T,from:E,to:N};x.set(A,_),g.push(_)}),g.sort((C,S)=>C.top-S.top);const v=8;let b=-1/0;const y=80;g.forEach(C=>{C.top<b+v&&(C.top=b+v),b=C.top+y}),i(g)},[e,t]),d=m.useCallback(()=>{a.current&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(l)},[l]);m.useEffect(()=>{if(!e)return;d(),e.on("update",d),e.on("selectionUpdate",d),e.on("transaction",d);const c=()=>d();window.addEventListener("resize",c);const u=new ResizeObserver(d);u.observe(e.view.dom);const f=e.view.dom.querySelectorAll("img");return f.forEach(g=>g.addEventListener("load",d)),()=>{e.off("update",d),e.off("selectionUpdate",d),e.off("transaction",d),window.removeEventListener("resize",c),u.disconnect(),f.forEach(g=>g.removeEventListener("load",d)),a.current&&cancelAnimationFrame(a.current)}},[e,d]);const p=c=>{if(!e)return;r(c.id),e.chain().focus().setTextSelection({from:c.from,to:c.to}).run();const f=e.view.dom.querySelector("span[data-admin-comment]");f==null||f.scrollIntoView({behavior:"smooth",block:"center"})},h=(c,u)=>{u.stopPropagation(),e&&(e.chain().focus().setTextSelection({from:c.from,to:c.to}).unsetMark("adminComment").run(),setTimeout(d,50))};return e?o.jsx("div",{className:"relative w-full h-full",children:n.length===0?o.jsxs("div",{className:"sticky top-4 text-xs text-muted-foreground p-3 border border-dashed rounded-md flex items-start gap-2",children:[o.jsx(mn,{className:"w-4 h-4 mt-0.5 shrink-0"}),o.jsx("span",{children:"Admin comments appear here. Highlight text and click the comment icon to add one."})]}):n.map(c=>o.jsxs("button",{type:"button",onClick:()=>p(c),className:`absolute left-0 right-0 text-left p-3 rounded-md border bg-card shadow-sm transition-all hover:shadow-md hover:border-primary/50 ${s===c.id?"border-primary ring-1 ring-primary/30":"border-border"}
41`,style:{top:`${c.top}px`},children:[o.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[o.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground font-semibold",children:"Comment"}),o.jsx("span",{role:"button",tabIndex:0,onClick:u=>h(c,u),className:"text-muted-foreground hover:text-destructive transition-colors cursor-pointer","aria-label":"Remove comment",children:o.jsx(Vt,{className:"w-3.5 h-3.5"})})]}),o.jsxs("p",{className:"text-xs text-muted-foreground italic line-clamp-1 mb-1",children:['"',c.snippet,'"']}),o.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap break-words",children:c.comment})]},c.id))}):null},Ha=[Xt.configure({heading:{levels:[1,2,3]}}),Qt,Jt.configure({openOnClick:!0,protocols:["https","http","mailto","tel"]}),en.configure({types:["heading","paragraph"]}),Zt,tn,nn,sn,on,an,rn,ln,cn,un,dn,fn],$a=["General","Eco-Heroes","EcoCupid Community","YSEALI Adventures"],Lt=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"").slice(0,80),za=({content:e})=>{const t=m.useRef(null),n=(()=>{try{const i=xi(e||{type:"doc",content:[]});return Pi(mi(i,Ha))}catch{return"<p>Nothing to preview yet.</p>"}})();return vi(t,[n]),o.jsx("div",{ref:t,className:"blog-prose",dangerouslySetInnerHTML:{__html:n}})},Sr=({mode:e="admin"})=>{const{id:t}=ti(),n=ni(),{user:i}=si(),s=!t,r=e==="volunteer",a=r?"/volunteer/blogs":"/admin/blogs",l=r?ai:li,[d,p]=m.useState(""),[h,c]=m.useState(""),[u,f]=m.useState({}),[g,x]=m.useState(""),[v,b]=m.useState(""),[y,C]=m.useState("General"),[S,R]=m.useState(""),[j,T]=m.useState(""),[O,E]=m.useState("draft"),[N,A]=m.useState(""),[_,k]=m.useState([]),[I,U]=m.useState(null),[L,H]=m.useState(0),[D,X]=m.useState(!1),[He,xs]=m.useState(!s),[Ee,Te]=m.useState("saved"),[ge,ct]=m.useState(t||null),[Me,vs]=m.useState(!1),[bs,ws]=m.useState(null),[$e,ut]=m.useState(""),[ys,Cs]=m.useState([]),[Ce,ze]=m.useState(""),[dt,Ss]=m.useState(null),[ft,Be]=m.useState(null),Ve=m.useRef(),ht=m.useRef(u);ht.current=u;const mt=m.useRef(null);m.useEffect(()=>{t&&(async()=>{const{data:w,error:P}=await F.from("blog_drafts").select("*").eq("id",t).maybeSingle();if(P||!w){J.error("Failed to load draft"),n(a);return}Be(w.author_id??null),p(w.title),c(w.slug),f(w.content),x(w.excerpt||""),b(w.cover_image_url||""),C(w.category),R((w.tags||[]).join(", ")),T(w.seo_description||""),E(w.status),A(w.author_name||""),U(w.updated_at||null),ct(w.id),ut(w.linked_project_id||"");const $=w.published_at;if(Ss($),$){const te=new Date($),K=ae=>String(ae).padStart(2,"0");ze(`${te.getFullYear()}-${K(te.getMonth()+1)}-${K(te.getDate())}T${K(te.getHours())}:${K(te.getMinutes())}`)}xs(!1)})()},[t,n]),m.useEffect(()=>{(async()=>{const{data:w}=await F.from("map_projects").select("id, name").order("name");Cs(w||[])})()},[]),m.useEffect(()=>{(async()=>{const{data:w}=await F.from("blog_drafts").select("author_name").not("author_name","is",null),P=Array.from(new Set((w||[]).map($=>($.author_name||"").trim()).filter(Boolean))).sort();k(P)})()},[ge]);const Se=m.useCallback(async w=>{if(!i)return;X(!0),Te("saving");const P=w||O,$=S.split(",").map(M=>M.trim()).filter(Boolean),te=Math.max(1,Math.ceil(L/200)),K=h||Lt(d)||`draft-${Date.now()}`;let ae=K;{const{data:M}=await F.from("blog_drafts").select("id, slug").ilike("slug",`${K}%`),ne=new Set((M||[]).filter(he=>he.id!==ge).map(he=>he.slug));if(ne.has(ae)){let he=2;for(;ne.has(`${K}-${he}`);)he++;ae=`${K}-${he}`}ae!==h&&c(ae)}const Ne={title:d||"Untitled",slug:ae,content:ht.current,excerpt:g||null,cover_image_url:v||null,...ge&&ft?{}:{author_id:i.id},author_name:N.trim()||null,category:y,tags:$,status:P,reading_time_minutes:te,seo_description:j||null,linked_project_id:$e||null,published_at:(()=>{const M=Ce?new Date(Ce).toISOString():null;return M||(P==="published"?dt??new Date().toISOString():null)})()};try{if(ge){const{data:M,error:ne}=await F.from("blog_drafts").update(Ne).eq("id",ge).select("updated_at, author_id").maybeSingle();if(ne)throw ne;if(!M)throw new Error("You don't have permission to edit this article â ask an admin to assign it to you.");Be(M.author_id??null),M.updated_at&&U(M.updated_at)}else{const{data:M,error:ne}=await F.from("blog_drafts").insert(Ne).select("id, updated_at, author_id").maybeSingle();if(ne)throw ne;if(!M)throw new Error("Couldn't create this article â you may
41not have permission.");ct(M.id),Be(M.author_id??null),M.updated_at&&U(M.updated_at)}E(P),Te("saved"),w&&J.success(P==="published"?"Published!":"Saved"),N.trim()&&!_.includes(N.trim())&&k(M=>[...M,N.trim()].sort())}catch(M){console.error(M);const ne=(M==null?void 0:M.code)==="23505"||/blog_drafts_slug_unique/.test((M==null?void 0:M.message)||"");J.error(ne?"Another article already uses this link â edit the slug field slightly and save again.":M.message||"Save failed"),Te("unsaved")}finally{X(!1)}},[i,d,h,g,v,y,S,j,O,L,ge,N,_,$e,Ce,dt,ft]),V=m.useCallback(()=>{Te("unsaved"),Ve.current&&clearTimeout(Ve.current),Ve.current=setTimeout(()=>Se(),3e4)},[Se]),Ns=m.useCallback(w=>{f(w),V()},[V]),js=w=>{p(w),s&&!h&&c(Lt(w)),V()},Rs=async w=>{var Ne;const P=(Ne=w.target.files)==null?void 0:Ne[0];if(!P||!i)return;const $=P.name.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/-+/g,"-"),te=`${i.id}/covers/${Date.now()}-${$}`,{error:K}=await F.storage.from("blog-images").upload(te,P,{contentType:P.type,upsert:!1});if(K){console.error("Cover upload failed",K),J.error(`Upload failed: ${K.message}`);return}const{data:{publicUrl:ae}}=F.storage.from("blog-images").getPublicUrl(te);b(ae),V()};return He?o.jsx(l,{children:o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Fe,{className:"w-8 h-8 animate-spin text-primary"})})}):o.jsx(l,{children:o.jsxs("div",{className:"space-y-4 bg-white min-h-screen p-4 -m-4 rounded-lg",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(q,{variant:"ghost",size:"icon",onClick:()=>n(a),children:o.jsx(ii,{className:"w-5 h-5"})}),o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx(Ei,{variant:O==="published"?"default":"secondary",children:O}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(_i,{className:"w-3 h-3"}),Math.max(1,Math.ceil(L/200))," min · ",L," words"]}),o.jsx("span",{className:"text-xs",children:Ee==="saving"?"Saving...":Ee==="saved"?"Saved":"Unsaved changes"}),I&&o.jsxs("span",{className:"text-xs italic",children:["Last edited ",new Date(I).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(q,{variant:"outline",size:"sm",onClick:()=>vs(!Me),children:[o.jsx(ki,{className:"w-4 h-4 mr-1"}),Me?"Edit":"Preview"]}),o.jsxs(q,{variant:"outline",size:"sm",onClick:()=>Se(),disabled:D,children:[o.jsx(Di,{className:"w-4 h-4 mr-1"}),"Save Draft"]}),r?(()=>{const P=O==="pending_review"&&!(Ee==="unsaved"),$=O==="published";return o.jsxs(q,{size:"sm",onClick:()=>Se("pending_review"),disabled:D||$||P,variant:P||$?"secondary":"default",className:P||$?"opacity-60 cursor-not-allowed":"",title:$?"Already published":P?"Awaiting editor review":"Send to editor for publishing",children:[D&&o.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}),o.jsx(Ct,{className:"w-4 h-4 mr-1"}),$?"Published":P?"Awaiting editor":"Send to editor for publishing"]})})():(()=>{const w=Ee==="unsaved",P=w||O!=="published";return o.jsxs(q,{size:"sm",onClick:()=>Se("published"),disabled:D||!P,variant:P?"default":"secondary",className:P?"":"opacity-60 cursor-not-allowed",children:[D&&o.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}),o.jsx(Ct,{className:"w-4 h-4 mr-1"}),O==="published"&&!w?"Published":"Publish"]})})(),o.jsxs(Ma,{children:[o.jsx(Aa,{asChild:!0,children:o.jsx(q,{variant:"ghost",size:"icon",children:o.jsx(oi,{className:"w-5 h-5"})})}),o.jsxs(ms,{className:"flex flex-col h-full p-0",children:[o.jsx(ps,{className:"px-6 pt-6 pb-2 border-b shrink-0",children:o.jsx(gs,{children:"Post Settings"})}),o.jsxs("div",{className:"space-y-4 mt-6 flex-1 overflow-y-auto px-6 pb-6",children:[o.jsx(La,{title:d,slug:h,excerpt:g,seoDescription:j,coverImageUrl:v,tags:S,wordCount:L}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(re,{children:"Author Name"}),o.jsx(pe,{list:"author-suggestions",value:N,onChange:w=>{A(w.target.value),V()},placeholder:"e.g. Jane Doe"}),o.jsx("datalist",{id:"author-suggestions",children:_.map(w=>o.jsx("option",{value:w},w))}),o.jsx("p",{className:"text-xs text-muted-foreground",children:'Previously-used names appear as suggestions. Leave blank to default to "EcoCupid Team".'})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(re,{children:"Slug"}),o.jsx(pe,{value:h,onChange:w=>{c(w.target.value),V()},placeholder:"url-friendly-slug"})]}),!r&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(re,{children:"Published date"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(pe,{type:"datetime-local",value:Ce,onChange:w=>{ze(w.target.value),V()}}),Ce&&o.jsx(q,{type:"button",variant:"ghost",size:"sm",onClick:()=>{ze(""),V()},children:"Clear"})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Override the displayed publish date â useful for backdating posts s
41o the article timeline reflects when they were originally written. Leave blank to use the time of first publish."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(re,{children:"Category"}),o.jsxs(gt,{value:y,onValueChange:w=>{C(w),V()},children:[o.jsx(xt,{children:o.jsx(vt,{})}),o.jsx(bt,{children:$a.map(w=>o.jsx(Ke,{value:w,children:w},w))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(re,{children:"Linked Eco-Project"}),o.jsxs(gt,{value:$e||"none",onValueChange:w=>{ut(w==="none"?"":w),V()},children:[o.jsx(xt,{children:o.jsx(vt,{placeholder:"None"})}),o.jsxs(bt,{children:[o.jsx(Ke,{value:"none",children:"None"}),ys.map(w=>o.jsx(Ke,{value:w.id,children:w.name},w.id))]})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Link this post to an eco-project on the map (used in homepage carousels & project pages)."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(re,{children:"Tags (comma separated)"}),o.jsx(pe,{value:S,onChange:w=>{R(w.target.value),V()},placeholder:"environment, conservation"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(re,{children:"Excerpt"}),o.jsx(yt,{value:g,onChange:w=>{x(w.target.value),V()},rows:3,placeholder:"Short summary for cards..."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(re,{children:"SEO Description"}),o.jsx(yt,{value:j,onChange:w=>{T(w.target.value),V()},rows:2,placeholder:"Meta description for search engines..."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(re,{children:"Cover Image"}),v&&o.jsx("img",{src:v,alt:"Cover",className:"w-full h-32 object-cover rounded-md"}),o.jsx(pe,{type:"file",accept:"image/*",onChange:Rs}),o.jsx(pe,{value:v,onChange:w=>{b(w.target.value),V()},placeholder:"Or paste image URL..."})]})]})]})]})]})]}),o.jsxs("div",{className:"lg:grid lg:grid-cols-[1fr_280px] lg:gap-8 lg:max-w-[1080px] lg:mx-auto",children:[o.jsxs("div",{ref:mt,className:"mx-auto w-full",style:{maxWidth:"720px"},children:[v&&o.jsx("div",{className:"relative aspect-[3/1] overflow-hidden rounded-lg mb-8",children:o.jsx("img",{src:v,alt:"Cover",className:"w-full h-full object-cover"})}),o.jsx("input",{value:d,onChange:w=>js(w.target.value),placeholder:"Post title...",className:"w-full text-[2.625rem] leading-[1.2] font-bold tracking-tight bg-transparent border-none outline-none mb-6",style:{fontFamily:"'Libre Baskerville', serif",color:"#1A1A1A"}}),Me?o.jsx(za,{content:u}):o.jsx(Ta,{content:u,onChange:Ns,onWordCount:H,onEditorReady:ws})]}),!Me&&o.jsx("aside",{className:"hidden lg:block relative",children:o.jsx(Ua,{editor:bs,containerRef:mt})})]})]})})};export{Sr as default}; 42//# sourceMappingURL=BlogEditor-C1g930um.js.map
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.