shadcn-rte 0.0.0-stage โ†’ 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,133 @@
1
- # Temporary Holding Version
1
+ # shadcn-rte API Reference
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Full reference for the components exported by `shadcn-rte`.
4
+
5
+ ```tsx
6
+ import { RichTextEditor, RichTextViewer } from 'shadcn-rte';
7
+ ```
8
+
9
+ ## `RichTextEditor`
10
+
11
+ A controlled rich text editor. The value is HTML, and every change is sanitized before `onChange` is called.
12
+
13
+ ### Props
14
+
15
+ | Prop | Type | Default | Description |
16
+ | --------------- | --------------------------------- | ---------------------- | -------------------------------------------------------------------------------------- |
17
+ | `value` | `string` | required | HTML content of the editor |
18
+ | `onChange` | `(value: string) => void` | required | Called with sanitized HTML. Empty content is `''`. |
19
+ | `placeholder` | `string` | `'Write something...'` | Shown when the editor is empty |
20
+ | `disabled` | `boolean` | `false` | Disables editing, the toolbar, and slash commands |
21
+ | `style` | `React.CSSProperties` | | Applied to the outer wrapper. Merged over the defaults. |
22
+ | `minHeight` | `number` | `240` | Minimum height of the content area, in px |
23
+ | `maxHeight` | `number` | `600` | Maximum height of the content area before it scrolls, in px |
24
+ | `maxFileSizeMB` | `number` | `10` | Largest file accepted for image or video upload |
25
+ | `maxLength` | `number` | | Maximum number of visible characters. Excess typing is blocked. |
26
+ | `onImageUpload` | `(file: File) => Promise<string>` | | Uploads an image and returns its URL. Without it, the image is inserted as a data URL. |
27
+ | `onVideoUpload` | `(file: File) => Promise<string>` | | Uploads a video and returns its URL. Without it, the video is inserted as a data URL. |
28
+ | `onError` | `(message: string) => void` | | Called with a message when an action fails |
29
+ | `onSuccess` | `(message: string) => void` | | Called after a successful action, such as copying content |
30
+
31
+ ### Behavior notes
32
+
33
+ - **Controlled value:** when `value` changes from outside the editor, the content is replaced. Changes made inside the editor are not overwritten while they match the last emitted value.
34
+ - **Empty content:** an empty editor emits `''`, not `'<p><br></p>'`.
35
+ - **Source mode:** the HTML source toggle edits raw HTML. Edits are sanitized as you type.
36
+ - **Reset:** the reset button restores the `value` that was passed in on first render.
37
+ - **Fullscreen:** press `Esc` to exit.
38
+
39
+ ### Example
40
+
41
+ ```tsx
42
+ import { useState } from 'react';
43
+ import { RichTextEditor } from 'shadcn-rte';
44
+
45
+ export function PostForm() {
46
+ const [content, setContent] = useState('');
47
+
48
+ return (
49
+ <RichTextEditor
50
+ value={content}
51
+ onChange={setContent}
52
+ maxLength={5000}
53
+ onImageUpload={async (file) => {
54
+ const form = new FormData();
55
+ form.append('file', file);
56
+ const res = await fetch('/api/upload', { method: 'POST', body: form });
57
+ const { url } = await res.json();
58
+ return url;
59
+ }}
60
+ onError={(message) => toast.error(message)}
61
+ onSuccess={(message) => toast.success(message)}
62
+ />
63
+ );
64
+ }
65
+ ```
66
+
67
+ ## `RichTextViewer`
68
+
69
+ Displays saved HTML with the same sanitizer and styles as the editor. It is read-only.
70
+
71
+ ### Props
72
+
73
+ | Prop | Type | Description |
74
+ | ------- | --------------------- | ------------------------------ |
75
+ | `value` | `string` | HTML to display |
76
+ | `style` | `React.CSSProperties` | Applied to the wrapper element |
77
+
78
+ ### Example
79
+
80
+ ```tsx
81
+ import { RichTextViewer } from 'shadcn-rte';
82
+
83
+ export function Article({ html }: { html: string }) {
84
+ return <RichTextViewer value={html} style={{ maxWidth: 720 }} />;
85
+ }
86
+ ```
87
+
88
+ ## Supported HTML
89
+
90
+ The sanitizer keeps only these elements:
91
+
92
+ - **Text:** `p`, `br`, `div`, `span`, `strong`, `b`, `em`, `i`, `u`, `s`, `strike`, `del`, `sub`, `sup`, `code`, `pre`, `mark`, `blockquote`
93
+ - **Headings:** `h1`, `h2`, `h3`, `h4`
94
+ - **Lists:** `ul`, `ol`, `li`. Checklists use `data-checklist` on `ul` and `data-checked` on `li`.
95
+ - **Links and media:** `a`, `img`, `video`, `source`, `iframe`
96
+ - **Tables:** `table`, `thead`, `tbody`, `tr`, `th`, `td`
97
+ - **Other:** `hr`
98
+
99
+ Elements not on this list are removed, and their text content is kept.
100
+
101
+ ### Allowed attributes
102
+
103
+ | Element | Attributes |
104
+ | ---------- | ------------------------------------------------- |
105
+ | `a` | `href`, `title`, `target`, `rel` |
106
+ | `img` | `src`, `alt`, `title` |
107
+ | `video` | `src`, `controls`, `loop`, `muted`, `playsinline` |
108
+ | `source` | `src`, `type` |
109
+ | `iframe` | `src`, `allowfullscreen`, `frameborder`, `title` |
110
+ | `td`, `th` | `colspan`, `rowspan` |
111
+ | `ol` | `start` |
112
+ | `ul`, `li` | `data-checklist`, `data-checked` |
113
+
114
+ ### Allowed inline styles
115
+
116
+ `color`, `background-color`, `text-align`, `font-size`, `font-family`, `font-weight`, `font-style`, `text-decoration`, `width`, `max-width`, `height`, `margin-left`, `margin-right`, `display`, `aspect-ratio`, `line-height`.
117
+
118
+ ### Allowed URLs
119
+
120
+ - **Links:** `http:`, `https:`, `mailto:`, `tel:`, relative paths starting with `/`, and anchors starting with `#`
121
+ - **Images:** `http(s)` URLs, relative paths, and `data:image/` URLs for png, jpeg, gif, webp, avif, and bmp
122
+ - **Videos:** `http(s)` URLs, relative paths, and `data:video/` URLs for mp4, webm, and ogg
123
+ - **Embeds (`iframe`):** YouTube, YouTube nocookie, and Vimeo player URLs only
124
+
125
+ Links that `target="_blank"` get `rel="noopener noreferrer"` added.
126
+
127
+ ## Exports summary
128
+
129
+ | Export | Kind |
130
+ | --------------------- | --------- |
131
+ | `RichTextEditor` | Component |
132
+ | `RichTextViewer` | Component |
133
+ | `RichTextEditorProps` | Type |
package/dist/index.cjs ADDED
@@ -0,0 +1,36 @@
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("react");c=s(c,1);let l=require("radix-ui"),u=require("react/jsx-runtime"),d=require("lucide-react");function f(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=f(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function p(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=f(e))&&(r&&(r+=` `),r+=t);return r}var m=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,h=p,g=(e,t)=>n=>{if(t?.variants==null)return h(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=m(t)||m(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return h(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},_=48,v=(e,t=0)=>{let n=new Int32Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r)-_-t;return n},y=e=>{let t=new Int32Array(e.length+1);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n];return t},b=e=>{let t=new Int32Array(e.length),n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r)-_;n+=i>>>1^-(i&1),t[r]=n}return t},ee=384,x=[],S=y(v(`E0500002005282000000002000150000020021820000011200000003022202000300004200120000200420001200021200301200010400162000010000220021010:2192001200220012000220012000200200200400010200040000000000400200108200110100000022010313000162002000020020012020080213000228200000000082000000000120002000120020020040101020300130001001010`)),te=y(v(`:11111111211111119311546544411119731869:671397415686432441111111111161114151214313433415:78311132233313187211117221449443411141111151152226611131111112212518142224214215421421542142424242516171151615616347111111111197911327451111111111111111111113134714133513411111311111111111111111111112444411111342312715245411117:3`)),ne=`@containerabcdefghinlmoprstunderlineviawzccentlignnimatespectuto-colsrowsaglorightnessckdrop-sisbcontrastfiltergrayscalehue-rotateinvertopacityslurrightnessaturateepia-coniclinearpositionradialsizeockurrderttom-belrstxyespacing-xyaretoursorlnt-umnsendspantartainentrasteividerop-shadowurationcorationlay-xyasendillexontromlter-featuresstretchapr-xyayscaleidow-colsrowsue-rotatedentlinesetvert-beringsxyeshadoweiadingftnest-clamp-imageabein-lrstxyskx--b-coniclpositionrsizet-x-y-fromto-fromto-inearfromto-fromto-adialfromto-fromtofromtofromtofromtoblockhinlinew-screenesblockhinlinewbjectpacityrutlinederigin-offsetbelrstxyesrspective-originaceholderioghtng-offsettateundedw-xyz-belrstlreseslr-endspantartaturatecepiahizekewpace-taleroll-xyz-barmpbelrstxyesbelrstxyes-thumbrackadowrink-xyxyartrokeabextora-shadowpckingnsformitionlate-xyz-offsetill-changeoom`,C=(()=>{let e=S.length-1,t=new Int32Array(e);for(let n=e-1;n>=0;n--){let e=1,r=n+1;for(let i=S[n];i<S[n+1];i++)e+=t[r],r+=t[r];t[n]=e}let n=new Int32Array(S[e]),r=0;for(let i=0;i<e;i++){let e=i+1;for(let a=S[i];a<S[i+1];a++)n[r++]=e,e+=t[e]}return n})(),w=v(`02000000000000900<=0?000B000F00F00ลI0J0LNPRTVX0000]_a00000000000000000000000rst0000000zล00000000000ย…ล000ยˆ0000ล000000ย0000ย—0000000000000000000000000000000000000000000000000000ร‹000000000000000000000รž000000000000000000รฐ0000000รธ0รนรบรปรผรฝรพรฟฤ€ฤฤ‚ฤƒฤ„ฤ…ฤ†000000000000000000000000000000000000000000ฤง0ฤจฤช00000000000000000000ฤผฤฝ00000ลฌ000000`,1),re=y(v(`123333359346463635126536711576`)),ie=v(`93203242332583253248325D>E?F@03263243255B:032523853:0325B:8GA032542H<C=12727B:0328432553;D>E?3257D>032585:0325B:;0328B:032`),T=v(`012113445661666666789111:5;;;;;;;;444;;;:62999<1161=62>>?61:21@ABCD4446996:64E:::;:?::64:F114GHHIHHHHIHH1HH1HH1HHHHHH::EEJ4444::EE4444441691;644444114244444:;K6666555555555555555999666664444444444444444444444226?6:66644L9M?D:111::::6DE199`),ae=b(`020200202020020020020020020020200200200200200200200002020202001003040106000200200200200200200200200200200200200200200200200200200200200200200200200200200200020020020020020020002020200202002002002002002002002002002020002002020020200220200200200200200200200200200200020020020000200020002000200200200020020020002000200200200020020202002020202000200200020022000200200020020002002000200220002002000200W0Z00020020002002020002002000200g0j0002002000200200020020002002000200200020020002000200002000002002002002002000200020000200002002002002002002002020020020200200200200200200200200202020020020020020020020020002002002020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020002002002002002002000200200200200200200200200200020202020002000200020002002002002000020200200`),oe=(()=>{let e=new Int32Array(319).fill(-1),t=b(`02422242:222222242224222242442222222422222244442242226224222426222422442462222422622222222626222462242622422622422424242422222222422222222242422222222222222222622442224222222222222224424442262222222222222222222226224222424242422224422422422222`),n=b(`02222222222222222222202222222222222222222222221422222222222222222222222222222222222Y\\222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222221422222222222222222222222222222222222222ฤฟล‚222222222222222222`);for(let r=0;r<t.length;r++)e[t[r]]=n[r];return e})(),se=`container |break-after- all auto avoid avoid-page column left page right|break-before- all auto avoid avoid-page column left page right|break-inside-a uto void void-column void-page|box-decoration- clone slice|box- border content| contents flow-root hidden table table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group| not-sr-only sr-only|float- end left none right start|clear- both end left none right start|isolat e ion-auto|overflow- auto clip hidden scroll visible|overflow-x- auto clip hidden scroll visible|overflow-y- auto clip hidden scroll visible|overscroll- auto contain none|overscroll-x- auto contain none|overscroll-y- auto contain none| absolute fixed relative static sticky| collapse invisible visible|justify- around baseline between center center-safe end end-safe evenly normal start stretch|justify-items- center center-safe end end-safe normal start stretch|justify-self- auto center center-safe end end-safe start stretch|items- baseline baseline-last center center-safe end end-safe start stretch|self- auto baseline baseline-last center center-safe end end-safe start stretch|place-content- around baseline between center center-safe end end-safe evenly start stretch|place-items- baseline center center-safe end end-safe start stretch|place-self- auto center center-safe end end-safe start stretch| antialiased subpixel-antialiased| italic not-italic|normal-nums |ordinal |slashed-zero | lining-nums oldstyle-nums| proportional-nums tabular-nums| diagonal-fractions stacked-fractions| no-underline overline| capitalize lowercase normal-case uppercase|truncate |whitespace- break-spaces normal nowrap pre pre-line pre-wrap|break- all keep normal words|wrap- anywhere break-word normal|hyphens- auto manual none|mix-blend- color color-burn color-dodge darken difference exclusion hard-light hue lighten luminosity multiply normal overlay plus-darker plus-lighter saturation screen soft-light|table- auto fixed|caption- bottom top|backface- hidden visible|appearance- auto none|scheme- dark light light-dark normal only-dark only-light|field-sizing- content fixed|pointer-events- auto none|resize -none -x -y|snap- align-none center end start|snap- always normal|snap- both none x y|snap- mandatory proximity|touch- auto manipulation none|touch-pan- left right x|touch-pan- down up y|touch-pinch-zoom |select- all auto none text|forced-color-adjust- auto none| normal size| baseline bottom middle sub super text-bottom text-top top| bounce none ping pulse spin| auto square video| auto fr max min px|none | auto full px| fixed local scroll|clip- border content padding text|origin- border content padding| bottom bottom-left bottom-right center left left-bottom left-top right right-bottom right-top top top-left top-right| no-repeat repeat repeat-round repeat-space repeat-x repeat-y| auto contain cover|blend- color color-burn color-dodge darken difference exclusion hard-light hue lighten luminosity multiply normal overlay saturation screen soft-light|to- b bl br l r t tl tr| auto dvh fit full lh lvh max min px screen svh| dashed dotted double hidden none solid| collapse separate|px |auto |full | content none strict| inline-size size|layout |paint |style | around baseline between center center-safe end end-safe evenly normal start stretch| alias all-scroll auto cell col-resize context-menu copy crosshair default e-resize ew-resize grab grabbing help move n-resize ne-resize nesw-resize no-drop none not-allowed ns-resize nw-resize nwse-resize pointer progress row-resize s-resize se-resize sw-resize text vertical-text w-resize wait zoom-in zoom-out| dashed dotted double solid wavy| auto from-font|reverse |initial | in in-out initial linear out| col col-reverse row row-reverse| nowrap wrap wrap-reverse| auto initial none| black bold extrabold extralight light medium normal semibold thin| condensed expanded extra-condensed extra-expanded normal semi-condensed semi-expanded ultra-condensed ultra-expanded|flow- col col-dense dense row row-dense| none subgrid| auto dvh dvw fit full lh lvh lvw max min px screen svh svw| block flex grid table| auto dvw fit full lvw max min px screen svw| loose none normal px relaxed snug tight|through |item | inside outside| decimal disc none| auto px| clip-border clip-content clip-fill clip-padding clip-stroke clip-view no-clip| add exclude intersect subtract| alpha luminance match|origin- border content fill padding stroke view|type- alpha luminance| circle ellipse| closest-corner closest-side farthest-corner farthest-side|at- bottom bottom-left bottom-right center left left-bottom left-top right right-bottom right-top top top-left top-right| dvh fit full lh lvh max min none px screen svh| auto dvh dvw fit full lh lvh lvw max min none px screen svh svw| dvw fit full lvw max min none px screen svw| auto dvh dvw fit full lvh lvw max min none prose px svh svw| auto dvh dvw fit full lvh lvw max min none px screen svh svw| contain cover fill none scale-down| first last none| distant dramatic midrange near none normal|inset | full none|3d | auto smooth|gutter- auto both stable| auto none thin| inner none| auto dvh dvw fit full lvh lvw max min px svh svw|base | center end justify left right start| clip ellipsis| balance nowrap pretty wrap| normal tight tighter wide wider widest| cpu gpu none| 3d flat| all colors none opacity shadow transform| discrete normal| full px| auto dvh dvw fit full lvh lvw max min px screen svh svw| auto contents scroll transform`.split(`|`).map(e=>{let t=e.split(` `),n=t.shift();for(let e=0;e<t.length;e++)t[e]=n+t[e];return t}),E=b(`0000000000000000000000000000000000000000000000000000000000000262242:6@200000006:240B428:4422400002046044222426220026642642462026224222824220022400000000\\00N222422242222222224062242222222422226264222422222222222222442804222422222222222222222222220<4<0204260002444020204224422`),D=b(`ษ 222222222222222222222222222222222222222222222222222222222222ห•4222226>6สฐ22สทสบสทสบสท42สด2ส“22>621422ษถ222ษนษผษทษบษทษบ22ษฑ42222ษจ2ษง26622ษ˜ษ“244ฦธฦต222]d24242ว–ว“ฦšร„ศซ2263ศจศฅศจ2222222วฃ222222222222222222ว‚ฦฝ2ฦพฦต2222222422222ฦœฦ‘22222222222222222222144ลฆลฃ22ลขลŸ222222222222222222222ฤธ2ฤฑ68ฤฆฤฃฤฆษกลฐ4ฤ ยซยฎฤ822ฤ”ฤ‘ฤ”2ฤ“2222622`),O=b(`02222222222222222222222222222222222222222222222222222222222222222202021422222222CF2200GJ021042222WZ222IL0ad2c10h2222U00X202[^2w0000120zy|}ย€22ยƒย†ย…:22z22222222222G000qย†OVI00000{ย˜2ย™<40000ยŒย›@00000Gยฆยง000ยช00000000000000ย021Kยฌยซ00ยฎย“000000000000000000000ย–222ย›HGH_1ยธ222ยฝ2ยพ2222ร‡รŠ000ยญยฐ2ยฑ`),ce=new Int32Array(987),k=new Int32Array(987),A=new Int32Array(987),j=``,le=new Int32Array(1022);{let e=new Map,t=0,n=0;for(let r=0;r<E.length;r++)for(let i of se[O[r]]){let a=e.get(i);a===void 0&&(a=t++,e.set(i,a),le[a*2]=j.length,le[a*2+1]=i.length,j+=i),ce[n]=E[r],k[n]=D[r],A[n]=a,n++}}var ue=b(`0b2N:222@R>F@286ยฆ2@H2D266226FB22B2>BD\\6N22222Z222D222p`),de=y(v(`1::24444432:442:44:44>222222:44:4421322511111311111114`)),M=b(`2ยŠ4A;33N=C@H4A;33N=C@<27;83:;8393NQ:3NQสฐ222ห‰ยบลดลฝ2R2=18cฦดร…ล‡ยœ=cฤžร›C1ฦˆวศˆ:ฤง25=11D3A@4=<1;1DEr25;11B3?<6;:371BCn9@7=<8192>2E121@9@EHE@9>2T25511<398454131<=V25511<398454131<=ย„ฦงNลพ2ฤรฅ242L222290000f22500ษ›000ว˜222`),fe=v(`ฤณ`),pe=v(`ย—`),me=v(`1`),he={GROUP_COUNT:ee,customValidatorNames:x,edgeStart:S,labelStart:te,labelText:ne,edgeTarget:C,nodeGroup:w,nodeVlist:oe,vlistPat:re,vlistOps:ie,vlistRef:T,vlistGroup:ae,litAnchor:ce,litGroup:k,litPool:A,poolOffsets:le,poolText:j,adjGid:ue,adjStart:de,adjTgt:M,patGid:fe,patTgt:pe,postfixLookupGroups:me,orderSensitiveModifiers:`* ** after backdrop before details-content file first-letter first-line marker placeholder selection`},ge=`line`in Error(),N=-1,_e=-1,ve=(e,t,n)=>{let r=2166136261;for(let i=t;i<n;i++)r=Math.imul(r^e.charCodeAt(i),16777619);return r},ye=(e,t,n)=>{let r=n-t,i=Math.imul(r,2654435761)^e.charCodeAt(t);if(r>3){let a=r>>2,o=r>>1;i=Math.imul(i^e.charCodeAt(t+1)<<8^e.charCodeAt(t+2)<<16^e.charCodeAt(t+a),2246822507),i=Math.imul(i^e.charCodeAt(t+o)<<8^e.charCodeAt(t+o+a)<<16^e.charCodeAt(n-3),3266489909),i^=e.charCodeAt(n-2)<<8^e.charCodeAt(n-1)<<16;for(let r=t+3,a=n-4;r<t+8&&r<a;r++,a--)i=Math.imul(i^e.charCodeAt(r)^e.charCodeAt(a)<<8,16777619)}return i^i>>>15},be=(e,t,n={})=>{let{GROUP_COUNT:r,edgeStart:i,labelStart:a,labelText:o,edgeTarget:s,nodeGroup:c,nodeVlist:l,vlistPat:u,vlistOps:d,vlistRef:f,vlistGroup:p,litAnchor:m,litGroup:h,litPool:g,poolOffsets:_,poolText:v,adjGid:y,adjStart:b,adjTgt:ee,patGid:x,patTgt:S,postfixLookupGroups:te,customValidatorNames:ne,orderSensitiveModifiers:C}=e,w=new Int32Array(r).fill(-1);for(let e=0;e<y.length;e++)w[y[e]]=e;let re=0;for(let e=0;e+1<b.length;e++){let t=b[e+1]-b[e];t>re&&(re=t)}let ie=32;for(;ie<2*(1+re+x.length);)ie<<=1;let T=new Int32Array(f.length+1);for(let e=0;e<f.length;e++)T[e+1]=T[e]+u[f[e]+1]-u[f[e]];let ae=new Uint8Array(r);for(let e=0;e<te.length;e++)ae[te[e]]=1;let oe=i.length-1,se=new Uint8Array(oe),E=0,D=!0;for(let e=0;e<m.length;e++){se[m[e]]=1;let t=_[g[e]*2+1];t>E&&(E=t);let n=v.charCodeAt(_[g[e]*2]);(n===91||n===40)&&(D=!1)}let O=1;for(;O<m.length*2;)O<<=1;let ce=new Int32Array(O).fill(-1);for(let e=0;e<m.length;e++){let t=_[g[e]*2],n=(ve(v,t,t+_[g[e]*2+1])^Math.imul(m[e],2654435761)|0)&O-1;for(;ce[n]!==-1;)n=n+1&O-1;ce[n]=e}let k=(e,t,n,r)=>{let i=(ve(t,n,r)^Math.imul(e,2654435761)|0)&O-1,a=r-n;for(;;){let r=ce[i];if(r===-1)return-1;if(m[r]===e&&_[g[r]*2+1]===a){let e=_[g[r]*2],i=!0;for(let r=0;r<a;r++)if(v.charCodeAt(e+r)!==t.charCodeAt(n+r)){i=!1;break}if(i)return h[r]}i=i+1&O-1}},A=n.cacheSize??8192,j=n.prefix??e.prefix??``,le=j===``?``:j+`:`,ue=le.length,de=(ne??[]).map(e=>{let n=t&&t[e];if(!n)throw Error(`cn: missing validator `+e);return n}),M=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,fe=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,pe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,me=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,he=0,be=-1,xe=-1,Se=-1,we=-1,P=e=>e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95,Te=e=>/\s/.test(String.fromCharCode(e)),Ee=(e,t,n)=>{if(he=0,be=-1,n-t<3)return;let r=e.charCodeAt(t),i=e.charCodeAt(n-1);if(r===91&&i===93)he=1;else if(r===40&&i===41)he=2;else return;Se=t+1,we=n-1;let a=t+1;if(P(e.charCodeAt(a))){for(a++;a<n-1;){let t=e.charCodeAt(a);if(!P(t)&&t!==45)break;a++}a<n-2&&e.charCodeAt(a)===58&&(be=t+1,xe=a,Se=a+1)}},De=(e,t,n,r)=>{if(n-t!==r.length)return!1;for(let n=0;n<r.length;n++)if(e.charCodeAt(t+n)!==r.charCodeAt(n))return!1;return!0},Oe=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,F=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ke=e=>!!e&&!Number.isNaN(Number(e)),I=(e,t,n)=>{if(n-t<11||!De(e,t,t+10,`@container`))return!1;if(e.charCodeAt(t+10)===47)return n-t>=12;let r=e.charCodeAt(t+11);return r===115&&n-t>=17&&De(e,t+10,t+16,`-size/`)||r===110&&n-t>=19&&De(e,t+10,t+18,`-normal/`)},Ae=[1,1,1,1,1,1,1,1,2,2,2,2,2,2,2],je=`length|number|number weight|family-name|position percentage|length size bg-size|image url|shadow|length|family-name|position percentage|length size bg-size|image url|shadow|number weight`.split(`|`).map(e=>e.split(` `)),Me=[2,3,1,0,0,0,4,5,0,0,0,0,0,1,1],Ne=(e,t,n,r)=>{if(e>=10){if(e>=25)return de[e-25](t.slice(n,r));let i=e-10;if(he!==Ae[i])return!1;if(be>=0){for(let e of je[i])if(De(t,be,xe,e))return!0;return!1}switch(Me[i]){case 0:return!1;case 1:return!0;case 2:{let e=t.slice(Se,we);return M.test(e)&&!fe.test(e)}case 3:return ke(t.slice(Se,we));case 4:return me.test(t.slice(Se,we));default:return pe.test(t.slice(Se,we))}}switch(e){case 0:return!0;case 1:return he===0;case 2:return he===1;case 3:return he===2;case 4:return Oe.test(t.slice(n,r));case 5:return ke(t.slice(n,r));case 6:{let e=t.slice(n,r);return!!e&&Number.isInteger(Number(e))}case 7:return r>n&&t.charCodeAt(r-1)===37&&ke(t.slice(n,r-1));case 8:return F.test(t.slice(n,r));default:return I(t,n,r)}},Pe=new Set(typeof C==`string`?C.split(` `):C),L=(e,t,n,r,i,a)=>{let o=ve(t,n,r)^(i?2654435769:0),s=e.get(o);if(s!==void 0)outer:for(let e=0;e<s.length;e++){let a=s[e];if(a.imp===i&&a.k.length===r-n){for(let e=0;e<a.k.length;e++)if(a.k.charCodeAt(e)!==t.charCodeAt(n+e))continue outer;return a.id}}else e.set(o,s=[]);let c=t.slice(n,r),l=a(c);return s.push({k:c,imp:i,id:l}),l},Fe=new Map,Ie=new Map,R=2,Le=4096,Re=(e,t)=>{let n=[],r=0,i=0,a=0;for(let t=0;t<e.length;t++){let o=e.charCodeAt(t);r===0&&i===0&&o===58?(n.push(e.slice(a,t)),a=t+1):o===91?r++:o===93?r--:o===40?i++:o===41&&i--}n.push(e.slice(a));let o=n[0];if(n.length>1){let e=[],t=[];for(let r of n)r.charCodeAt(0)===91||Pe.has(r)?(t.length&&(e.push(...t.sort()),t=[]),e.push(r)):t.push(r);t.length&&e.push(...t.sort()),o=e.join(`:`)}let s=t?o+` !`:o,c=Ie.get(s);return c===void 0&&Ie.set(s,c=R++),c},ze=new Map,Be=r,Ve=r+4096,He=()=>Be++,Ue=2097152,We=8192,Ge=new Int32Array(We),Ke=Array(We).fill(null),qe=new Int32Array(We),Je=new Int32Array(We),Ye=new Uint8Array(We),Xe=0,Ze=(e,t,n,r,i,a,o,s)=>{let c=e;if(Ke[e]!==null){if(Ke[e|1]===null)c=e|1;else if(!(Xe++&3))c=e|Xe>>2&1;else return}Ke[c]=t.slice(n,r),Ge[c]=i,qe[c]=a,Je[c]=o,Ye[c]=s},Qe=()=>Ke.fill(null),z=256,$e=[new Int32Array(z),new Int32Array(z),new Int32Array(z),new Int32Array(z)],[et,tt,nt,rt]=$e,it=new Uint8Array(z),at=new Uint8Array(z),ot=()=>{z*=2,$e=$e.map(e=>{let t=new Int32Array(z);return t.set(e),t}),[et,tt,nt,rt]=$e;let e=new Uint8Array(z);e.set(it),it=e,at=new Uint8Array(z)},st=64,ct=new Int32Array(st),lt=new Int32Array(st),ut=new Int32Array(r),dt=2048,ft=21,pt=new Float64Array(dt),mt=new Int32Array(dt),ht=0,gt=(e,t)=>{if(e===0&&t<r)return ut[t]===ht?1:(ut[t]=ht,0);let n=e*2097152+t+1,i=Math.imul(n,2654435761)>>>ft;for(;mt[i]===ht;){if(pt[i]===n)return 1;i=i+1&dt-1}return pt[i]=n,mt[i]=ht,0},B=(e,t,n,r,i)=>{if(n-t>=2&&e.charCodeAt(t)===91&&e.charCodeAt(n-1)===93){let r=-1;for(let i=t+1;i<n-1;i++)if(e.charCodeAt(i)===58){r=i;break}return r===-1||r===t+1?N:L(ze,e,t+1,r,0,He)}if(r>=0&&c[r]>=0)return c[r];for(let t=i-1;t>=0;t--){let r=lt[t];if(r>n)continue;let i=ct[t],a=n-r;if(se[i]===1&&a>0&&a<=E){let t=e.charCodeAt(r);if(D===!1||t!==91&&t!==40){let t=k(i,e,r,n);if(t>=0)return t}}let o=l[i];if(o<0)continue;let s=f[o],c=u[s],m=u[s+1];if(c===m)continue;Ee(e,r,n);let h=T[o]-c;for(let t=c;t<m;t++)if(Ne(d[t],e,r,n))return p[h+t]}return N},V=e=>{let t=e.length,n=0,c=0,u=!1;(R>Le||Fe.size>Le)&&(Fe=new Map,Ie=new Map,R=2,Qe()),Be>Ve&&(ze=new Map,Be=r,Qe());let d=0;for(;d<t;){let f=e.charCodeAt(d);if(f===32||f>=9&&f<=13||f>=160&&Te(f)){f!==32&&(u=!0),d++;continue}let p=d,m=0;for(;d<t;){if(f=e.charCodeAt(d),f<=32){if(f===32)break;if(f>=9&&f<=13){u=!0;break}}else if(f>=160&&Te(f)){u=!0;break}m=Math.imul(m^f,16777619),d++}let h=d,g=h-p;n===z&&ot();let _=n++;et[_]=p,tt[_]=h,c+=g,m^=Math.imul(g,2654435761);let v=m^m>>>15,y=v&8190;{let t=-1;if(Ge[y]===v&&Ke[y]!==null&&Ke[y].length===g?t=y:Ge[y|1]===v&&Ke[y|1]!==null&&Ke[y|1].length===g&&(t=y|1),t>=0){let n=Ke[t],r=!0;for(let t=0;t<g;t++)if(n.charCodeAt(t)!==e.charCodeAt(p+t)){r=!1;break}if(r){nt[_]=qe[t],rt[_]=Je[t],it[_]=Ye[t];continue}}}let b=p;if(ue!==0){if(h-p<=ue||!e.startsWith(le,p)){nt[_]=N,Ze(y,e,p,h,v,N,0,0);continue}b=p+ue}let ee=0,x=0,S=-1,te=-1;for(let t=b;t<h;t++){let n=e.charCodeAt(t);if(ee===0&&x===0){if(n===58){S=t;continue}if(n===47){te=t;continue}}n===91?ee++:n===93?ee--:n===40?x++:n===41&&x--}let ne=S>=b?S+1:b,C=ne,w=h,re=!1,ie=0;w>C&&e.charCodeAt(w-1)===33?(re=!0,w--):w>C&&e.charCodeAt(C)===33&&(re=!0,C++,ie=1);let T=-1;te>ne&&(T=te+ie,T>=w&&(T=-1));let oe=C;w-C>1&&e.charCodeAt(C)===45&&(oe=C+1);let E=0,D=0,O=0,ce=-1,k=0;(l[0]>=0||se[0]===1)&&(ct[0]=0,lt[0]=oe,k=1);let A=_e,j=0;for(let t=oe;t<w;t++)if(t===T&&(A=D<O?_e:E,j=k),E!==_e){let n=e.charCodeAt(t),r=-1;if(D<O)o.charCodeAt(D)===n?(D++,D===O&&(r=E=ce)):E=_e;else{let e=i[E],t=i[E+1],c=_e;for(let i=e;i<t;i++){let e=a[i];if(o.charCodeAt(e)===n){a[i+1]-e===1?r=c=s[i]:(D=e+1,O=a[i+1],ce=s[i],c=E);break}}E=c}if(r>=0&&(l[r]>=0||se[r]===1)&&t+1<w&&e.charCodeAt(t+1)===45){if(k===st){st*=2;let e=new Int32Array(st);e.set(ct),ct=e;let t=new Int32Array(st);t.set(lt),lt=t}ct[k]=r,lt[k]=t+2,k++}}T===w&&(A=D<O?_e:E,j=k);let de=D<O?_e:E,M,fe=!1;if(T>=0){if(fe=!0,M=B(e,C,T,A,j),M!==N&&M<r&&ae[M]){let t=B(e,C,w,de,k);t!==N&&t!==M&&(M=t,fe=!1)}else M===N&&(M=B(e,C,w,de,k),fe=!1)}else M=B(e,C,w,de,k);let pe=0,me=0;M===N?nt[_]=N:(me=+!!fe,pe=b>=S?+!!re:L(Fe,e,b,S,+!!re,e=>Re(e,re)),nt[_]=M,it[_]=me,rt[_]=pe),Ze(y,e,p,h,v,M,pe,me)}if(n===0)return``;if(n===1)return et[0]===0&&tt[0]===t?e:e.slice(et[0],tt[0]);if(n*ie>dt){for(;n*ie>dt;)dt<<=1,ft--;pt=new Float64Array(dt),mt=new Int32Array(dt)}if(R>=Ue||Be>=Ue)throw Error(`cn: too many distinct classes in one merge`);ht=ht+1|0,ht===0&&(ut.fill(0),mt.fill(0),ht=1);let f=!1;for(let e=n-1;e>=0;e--){let t=nt[e];if(t===N){at[e]=1;continue}let n=rt[e];if(gt(n,t)===1)at[e]=0,f=!0;else if(at[e]=1,t<r){let r=w[t];if(r>=0)for(let e=b[r];e<b[r+1];e++)gt(n,ee[e]);if(it[e]&1)for(let e=0;e<x.length;e++)x[e]===t&&gt(n,S[e])}}if(!f&&!u&&t===c+n-1)return e;let p=``,m=0;for(;m<n;){if(!at[m]){m++;continue}let t=et[m],r=tt[m],i=m+1;for(;i<n&&at[i]&&et[i]===r+1&&e.charCodeAt(r)===32;)r=tt[i],i++;p.length>0&&(p+=` `),p+=e.slice(t,r),m=i}return p},H=16384,U=new Int32Array(H*2),_t=0,W=1,vt=Object.create(null),yt=Object.create(null),bt=new Map,xt=new Map,G=0,K=0,q=()=>{_t^=H,W=W+1|0,K=0},St=e=>{let t=vt[e];if(t!==void 0)return t;let n=ye(e,0,e.length),r=(n&16383)+_t,i=U[r]===(n^W)||U[r^H]===(n^W-1);return i&&(t=yt[e],t!==void 0)?(vt[e]=t,t):(t=V(e),i?(vt[e]=t,++G>A&&(G=0,yt=vt,vt=Object.create(null),q())):(U[r]=n^W,++K>H&&q()),t)},Ct=e=>{let t=bt.get(e);if(t!==void 0)return t;let n=ye(e,0,e.length),r=(n&16383)+_t,i=U[r]===(n^W)||U[r^H]===(n^W-1);return i&&(t=xt.get(e),t!==void 0)?(bt.set(e,t),t):(t=V(e),i?(bt.set(e,t),++G>A&&(G=0,xt=bt,bt=new Map,q())):(U[r]=n^W,++K>H&&q()),t)},wt=e=>{let t=ye(e,0,e.length),n=(t&16383)+_t;return U[n]===(t^W)||U[n^H]===(t^W-1)||(U[n]=t^W,++K>H&&q(),!1)},Tt=A===0?V:ge?e=>{let t=bt.get(e);return t===void 0?Ct(e):t}:St;return{merge:function(){return arguments.length===1&&typeof arguments[0]==`string`?Tt(arguments[0]):Tt(Ce.apply(null,arguments))},mergeString:Tt,seenBefore:A===0?()=>!1:wt,mergeUncached:V}},xe=(e,t)=>{if(!e)return``;if(typeof e==`string`)return e;let n=``;if(typeof e.length==`number`&&(!t||Array.isArray(e))){let r=e;for(let e=0;e<r.length;e++){let i=r[e];if(!i)continue;let a=typeof i==`string`?i:xe(i,t);a&&(n&&(n+=` `),n+=a)}return n}if(t){if(typeof e==`number`)return``+e;if(typeof e==`object`)for(let t in e)e[t]&&(n&&(n+=` `),n+=t)}return n},Se=(e,t)=>{let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(!i)continue;let a=typeof i==`string`?i:xe(i,t);a&&(n&&(n+=` `),n+=a)}return n},Ce=function(){return Se(arguments,!1)},we=256,P=16,Te=1024,Ee=4096,De=(e,t)=>{let n=t===void 0?()=>!0:t.seenBefore,r=t===void 0?e:t.mergeUncached,i=new Map,a=new Map,o=0,s=null,c=null,l=[],u=[],d=0,f=(t,n,r)=>{c===null&&(c=Array(Ee).fill(``),l=Array(Ee).fill(``),u=Array(Ee).fill(``));let i=ye(t,0,t.length)&4094;if(c[i]===t&&l[i]===n)return u[i];if(c[i|1]===t&&l[i|1]===n)return u[i|1];let a=e(r?n+` `+t:t),o=c[i]===``?i:i|(c[i|1]===``?1:d++&1);return c[o]=t,l[o]=n,u[o]=a,a},p=(e,t,n,r)=>{let i=0;if(t){if(t!==e.a0)return!1;i=1}if(n){if(n!==(i===0?e.a0:e.a1))return!1;i++}if(r){if(r!==(i===0?e.a0:i===1?e.a1:e.a2))return!1;i++}return i===e.t},m=(e,t)=>{let n=e.a,r=0;for(let e=0;e<t.length;e++){let i=t[e];if(i){if(i!==n[r])return!1;r++}}return r===e.t},h=(t,c)=>{let l=t.length,u=s===null?null:s.n;if(!c){if(u!==null&&m(u,t))return s=u,u.r;if(s!==null&&s!==u&&m(s,t))return s.r}let d=``,p=-1,h=0,g=!1;for(let e=0;e<l;e++){let n=t[e];if(n){if(typeof n!=`string`){if(n=t[e]=xe(n,!0),!n)continue;g=!0}p<0&&(d=n,p=e),h++}}if(h===0)return``;if(h===1)return e(d);if(g){if(u!==null&&m(u,t))return s=u,u.r;if(s!==null&&s!==u&&m(s,t))return s.r}let _=i.get(d);_===void 0&&(_=a.get(d),_!==void 0&&i.set(d,_));let v=null;if(_!==void 0){if(_.skip>0){_.skip--,s=null;let e=d;for(let n=p+1;n<l;n++){let r=t[n];r&&(e+=` `+r)}return f(e,``,!1)}let e=_.e;outer:for(let n=0;n<e.length;n++){let r=e[n];if(r.t!==h)continue;let i=r.a,a=1;for(let e=p+1;e<l;e++){let n=t[e];if(n&&n!==i[a++])continue outer}v=r;break}v!==null&&(_.miss=0)}if(v===null){let s=d,c=[d];for(let e=p+1;e<l;e++){let n=t[e];n&&(s+=` `+n,c.push(n))}if(!n(s))return r(s);v={r:e(s),t:c.length,a0:c[0],a1:c[1],a2:c[2]??``,a:c,n:null},_===void 0?i.set(d,_={e:[],miss:0,skip:0,at:0}):++_.miss>P&&(_.miss=P,_.skip=Te,_.e.length=0,_.at=0);let u=_.e;u.length<we?u.push(v):(u[_.at]=v,_.at=_.at+1&255),++o>1e3&&(o=0,a=i,i=new Map)}return s!==null&&s!==v&&(s.n=v),s=v,v.r},g=t=>Array.isArray(t)?h(t.slice(),!1):e(xe(t,!0));return function(t,n,r){let a=arguments.length;if((a|1)==3){let e=s;if(e!==null){let i=e.n;if(i!==null&&p(i,t,n,r))return s=i,i.r;if(e!==i&&p(e,t,n,r))return e.r}if(a===2&&typeof n==`string`&&n!==``){let e=i.get(t);if(e!==void 0&&e.skip>0)return e.skip--,s=null,f(n,t,!0)}return h([t,n,r],!0)}if(a===1)return typeof t==`string`?e(t):g(t);let o=s;if(o!==null){let e=o.n;if(e!==null){let t=e.a,n=0,r=!0;for(let e=0;e<a;e++){let i=arguments[e];if(i){if(i!==t[n]){r=!1;break}n++}}if(r&&n===e.t)return s=e,e.r}if(o!==e){let e=o.a,t=0,n=!0;for(let r=0;r<a;r++){let i=arguments[r];if(i){if(i!==e[t]){n=!1;break}t++}}if(n&&t===o.t)return o.r}}let c=[];for(let e=0;e<a;e++)c.push(arguments[e]);return h(c,!0)}},Oe=be(he),F=De(Oe.mergeString,Oe);Oe.merge;var ke=g(`group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function I({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?l.Slot.Root:`button`;return(0,u.jsx)(a,{"data-slot":`button`,"data-variant":t,"data-size":n,className:F(ke({variant:t,size:n,className:e})),...i})}function Ae({...e}){return(0,u.jsx)(l.DropdownMenu.Root,{"data-slot":`dropdown-menu`,...e})}function je({...e}){return(0,u.jsx)(l.DropdownMenu.Trigger,{"data-slot":`dropdown-menu-trigger`,...e})}function Me({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,u.jsx)(l.DropdownMenu.Portal,{children:(0,u.jsx)(l.DropdownMenu.Content,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:F(`z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function Ne({className:e,inset:t,variant:n=`default`,...r}){return(0,u.jsx)(l.DropdownMenu.Item,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:F(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function Pe({className:e,...t}){return(0,u.jsx)(l.DropdownMenu.Separator,{"data-slot":`dropdown-menu-separator`,className:F(`-mx-1 my-1 h-px bg-border`,e),...t})}function L({className:e,type:t,...n}){return(0,u.jsx)(`input`,{type:t,"data-slot":`input`,className:F(`h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function Fe({className:e,...t}){return(0,u.jsx)(l.Label.Root,{"data-slot":`label`,className:F(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function Ie({...e}){return(0,u.jsx)(l.Popover.Root,{"data-slot":`popover`,...e})}function R({...e}){return(0,u.jsx)(l.Popover.Trigger,{"data-slot":`popover-trigger`,...e})}function Le({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,u.jsx)(l.Popover.Portal,{children:(0,u.jsx)(l.Popover.Content,{"data-slot":`popover-content`,align:t,sideOffset:n,className:F(`z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function Re({...e}){return(0,u.jsx)(l.Select.Root,{"data-slot":`select`,...e})}function ze({...e}){return(0,u.jsx)(l.Select.Value,{"data-slot":`select-value`,...e})}function Be({className:e,size:t=`default`,children:n,...r}){return(0,u.jsxs)(l.Select.Trigger,{"data-slot":`select-trigger`,"data-size":t,className:F(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,u.jsx)(l.Select.Icon,{asChild:!0,children:(0,u.jsx)(d.ChevronDownIcon,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function Ve({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,u.jsx)(l.Select.Portal,{children:(0,u.jsxs)(l.Select.Content,{"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,className:F(`relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,u.jsx)(Ue,{}),(0,u.jsx)(l.Select.Viewport,{"data-position":n,className:F(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,n===`popper`&&``),children:t}),(0,u.jsx)(We,{})]})})}function He({className:e,children:t,...n}){return(0,u.jsxs)(l.Select.Item,{"data-slot":`select-item`,className:F(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,u.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,u.jsx)(l.Select.ItemIndicator,{children:(0,u.jsx)(d.CheckIcon,{className:`pointer-events-none`})})}),(0,u.jsx)(l.Select.ItemText,{children:t})]})}function Ue({className:e,...t}){return(0,u.jsx)(l.Select.ScrollUpButton,{"data-slot":`select-scroll-up-button`,className:F(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,u.jsx)(d.ChevronUpIcon,{})})}function We({className:e,...t}){return(0,u.jsx)(l.Select.ScrollDownButton,{"data-slot":`select-scroll-down-button`,className:F(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,u.jsx)(d.ChevronDownIcon,{})})}function Ge({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,u.jsx)(l.Separator.Root,{"data-slot":`separator`,decorative:n,orientation:t,className:F(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...r})}function Ke({className:e,size:t=`default`,...n}){return(0,u.jsx)(l.Switch.Root,{"data-slot":`switch`,"data-size":t,className:F(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,u.jsx)(l.Switch.Thumb,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}function qe({className:e,orientation:t=`horizontal`,...n}){return(0,u.jsx)(l.Tabs.Root,{"data-slot":`tabs`,"data-orientation":t,className:F(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Je=g(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Ye({className:e,variant:t=`default`,...n}){return(0,u.jsx)(l.Tabs.List,{"data-slot":`tabs-list`,"data-variant":t,className:F(Je({variant:t}),e),...n})}function Xe({className:e,...t}){return(0,u.jsx)(l.Tabs.Trigger,{"data-slot":`tabs-trigger`,className:F(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function Ze({className:e,...t}){return(0,u.jsx)(l.Tabs.Content,{"data-slot":`tabs-content`,className:F(`flex-1 text-sm outline-none`,e),...t})}function Qe({className:e,...t}){return(0,u.jsx)(`textarea`,{"data-slot":`textarea`,className:F(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...t})}function z({delayDuration:e=0,...t}){return(0,u.jsx)(l.Tooltip.Provider,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function $e({...e}){return(0,u.jsx)(l.Tooltip.Root,{"data-slot":`tooltip`,...e})}function et({...e}){return(0,u.jsx)(l.Tooltip.Trigger,{"data-slot":`tooltip-trigger`,...e})}function tt({className:e,sideOffset:t=0,children:n,...r}){return(0,u.jsx)(l.Tooltip.Portal,{children:(0,u.jsxs)(l.Tooltip.Content,{"data-slot":`tooltip-content`,sideOffset:t,className:F(`z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[n,(0,u.jsx)(l.Tooltip.Arrow,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}var nt={bold:!1,italic:!1,underline:!1,strike:!1,sub:!1,sup:!1,ul:!1,ol:!1,check:!1,left:!1,center:!1,right:!1,justify:!1,code:!1,link:!1,inTable:!1,block:`p`,size:``},rt=`<p><br></p>`,it=`img,video,iframe,table,hr`,at=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`BLOCKQUOTE`,`PRE`,`LI`,`TD`,`TH`]),ot=[{value:`p`,label:`Paragraph`},{value:`h1`,label:`Heading 1`},{value:`h2`,label:`Heading 2`},{value:`h3`,label:`Heading 3`},{value:`h4`,label:`Heading 4`},{value:`blockquote`,label:`Quote`},{value:`pre`,label:`Code block`}],st=[`Arial`,`Georgia`,`Verdana`,`Tahoma`,`Trebuchet MS`,`Courier New`],ct=[`12`,`14`,`16`,`18`,`20`,`24`,`30`,`36`,`48`],lt=[`1.2`,`1.5`,`1.7`,`2`,`2.5`],ut=`๐Ÿ˜€.๐Ÿ˜‚.๐Ÿ˜Š.๐Ÿ˜.๐Ÿค”.๐Ÿ˜Ž.๐Ÿ˜ข.๐Ÿ˜ก.๐Ÿ‘.๐Ÿ‘Ž.๐Ÿ‘.๐Ÿ™.๐Ÿ’ช.๐ŸŽ‰.๐Ÿ”ฅ.โญ.โค๏ธ.๐Ÿ’ก.โœ….โŒ.โš ๏ธ.๐Ÿ“Œ.๐Ÿ“Ž.๐Ÿ“….๐Ÿš€.๐ŸŽฏ.๐Ÿ’ฌ.๐Ÿ“.๐Ÿ”—.๐Ÿ”’.๐ŸŒ.โ˜€๏ธ`.split(`.`),dt=`ยฉ.ยฎ.โ„ข.ยง.ยถ.ยฐ.ยฑ.ร—.รท.โ‰ .โ‰ค.โ‰ฅ.โ‰ˆ.โˆž.โˆš.ฯ€.โ‚ฌ.ยฃ.ยฅ.เงณ.โ†.โ†’.โ†‘.โ†“.โ€ข.โ€ฆ.โ€”.โ€“.ยซ.ยป.โœ“.โœ—.โ˜….โ˜†.โ™ฅ.โ™ฆ.โ„–.ยต.ฮฉ.โˆ‘`.split(`.`),ft={display:`grid`,gridTemplateColumns:`repeat(8, 1fr)`,gap:4},pt=[`#000000`,`#4b5563`,`#9ca3af`,`#ffffff`,`#dc2626`,`#ea580c`,`#d97706`,`#16a34a`,`#0891b2`,`#2563eb`,`#7c3aed`,`#db2777`],mt=[`#fef08a`,`#bbf7d0`,`#bfdbfe`,`#fbcfe8`,`#fed7aa`,`#ddd6fe`,`#fecaca`,`#e5e7eb`,`#fde047`,`#86efac`,`#93c5fd`,`#f9a8d4`],ht={left:[`0`,`auto`],center:[`auto`,`auto`],right:[`auto`,`0`]},gt=new Set(`P.BR.DIV.SPAN.B.STRONG.I.EM.U.S.STRIKE.DEL.SUB.SUP.CODE.PRE.BLOCKQUOTE.H1.H2.H3.H4.UL.OL.LI.A.IMG.VIDEO.SOURCE.IFRAME.TABLE.THEAD.TBODY.TR.TH.TD.HR.MARK`.split(`.`)),B=new Set([`SCRIPT`,`STYLE`,`NOSCRIPT`,`OBJECT`,`EMBED`,`FORM`,`META`,`LINK`,`TEMPLATE`,`TITLE`,`HEAD`,`SVG`,`MATH`,`BUTTON`,`TEXTAREA`,`SELECT`,`AUDIO`]),V={A:[`title`],IMG:[`alt`,`title`],VIDEO:[`controls`,`loop`,`muted`,`playsinline`],SOURCE:[`type`],IFRAME:[`allowfullscreen`,`frameborder`,`title`],TD:[`colspan`,`rowspan`],TH:[`colspan`,`rowspan`],UL:[`data-checklist`],LI:[`data-checked`],OL:[`start`]},H=new Set([`color`,`background-color`,`text-align`,`font-size`,`font-family`,`font-weight`,`font-style`,`text-decoration`,`width`,`max-width`,`height`,`margin-left`,`margin-right`,`display`,`aspect-ratio`,`line-height`]),U=[`https://www.youtube.com/embed/`,`https://www.youtube-nocookie.com/embed/`,`https://player.vimeo.com/video/`],_t=`
2
+ .rte-content{line-height:1.7;word-break:break-word}
3
+ .rte-content:focus{outline:none}
4
+ .rte-content>*+*{margin-top:.75em}
5
+ .rte-content h1{font-size:2em;font-weight:700;line-height:1.2}
6
+ .rte-content h2{font-size:1.5em;font-weight:700;line-height:1.3}
7
+ .rte-content h3{font-size:1.25em;font-weight:600;line-height:1.4}
8
+ .rte-content h4{font-size:1.05em;font-weight:600}
9
+ .rte-content blockquote{border-left:4px solid color-mix(in srgb,currentColor 25%,transparent);padding-left:1em;font-style:italic;opacity:.85}
10
+ .rte-content pre{background:color-mix(in srgb,currentColor 8%,transparent);border-radius:.5rem;padding:.75rem 1rem;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.875em;white-space:pre-wrap;overflow-x:auto}
11
+ .rte-content code{background:color-mix(in srgb,currentColor 10%,transparent);border-radius:.3em;padding:.15em .35em;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9em}
12
+ .rte-content pre code{background:none;padding:0}
13
+ .rte-content ul{list-style:disc;padding-left:1.5em}
14
+ .rte-content ol{list-style:decimal;padding-left:1.5em}
15
+ .rte-content li>ul,.rte-content li>ol{margin-top:.25em}
16
+ .rte-content ul[data-checklist]{list-style:none;padding-left:0}
17
+ .rte-content ul[data-checklist] li{position:relative;padding-left:1.8em}
18
+ .rte-content ul[data-checklist] li::before{content:'';position:absolute;left:0;top:.4em;width:1em;height:1em;border:2px solid currentColor;border-radius:.25em;opacity:.65;cursor:pointer;box-sizing:border-box}
19
+ .rte-content ul[data-checklist] li[data-checked='true']::before{content:'\\2713';display:flex;align-items:center;justify-content:center;font-size:.75em;font-weight:700;opacity:1}
20
+ .rte-content ul[data-checklist] li[data-checked='true']{text-decoration:line-through;opacity:.65}
21
+ .rte-content a{color:#2563eb;text-decoration:underline;cursor:pointer}
22
+ .rte-content img,.rte-content video{max-width:100%;border-radius:.5rem}
23
+ .rte-content iframe{max-width:100%;border:0;border-radius:.5rem}
24
+ .rte-content table{border-collapse:collapse;width:100%;table-layout:fixed}
25
+ .rte-content th,.rte-content td{border:1px solid color-mix(in srgb,currentColor 25%,transparent);padding:.5em .75em;vertical-align:top;min-width:2em}
26
+ .rte-content th{background:color-mix(in srgb,currentColor 8%,transparent);font-weight:600;text-align:left}
27
+ .rte-content hr{border:0;border-top:1px solid color-mix(in srgb,currentColor 25%,transparent);margin:1.5em 0}
28
+ .rte-editor iframe{pointer-events:none}
29
+ .rte-editor .rte-selected{outline:2px solid #3b82f6;outline-offset:2px}
30
+ ::highlight(rte-find){background-color:#fde68a;color:#000}
31
+ ::highlight(rte-find-current){background-color:#fb923c;color:#000}
32
+ `,W=`1px solid color-mix(in srgb, currentColor 20%, transparent)`,vt=`color-mix(in srgb, currentColor 5%, transparent)`,yt=`#dc2626`,bt={height:32,width:32},xt={height:28,width:28},G={height:16,width:16},K=e=>({display:`flex`,alignItems:`center`,gap:e}),q=e=>({display:`flex`,flexDirection:`column`,gap:e}),St=e=>({height:32,width:e,fontSize:12}),Ct=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`),wt=e=>{let t=e.trim();return t?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?`mailto:${t}`:/^([a-z][a-z0-9+.-]*:|\/|#)/i.test(t)?t:`https://${t}`:``},Tt=(e,t)=>{let n=(e??``).trim();return n?t===`link`?/^(https?:|mailto:|tel:|\/|#)/i.test(n)?n:null:/^https?:\/\//i.test(n)||n.startsWith(`/`)||(t===`image`?/^data:image\/(png|jpe?g|gif|webp|avif|bmp);base64,/i:/^data:video\/(mp4|webm|ogg);base64,/i).test(n)?n:null:null},Et=e=>e.split(`;`).map(e=>{let t=e.indexOf(`:`);if(t<0)return``;let n=e.slice(0,t).trim().toLowerCase(),r=e.slice(t+1).trim();return H.has(n)&&r&&!/url\(|expression|javascript:|@import|[<>\\]/i.test(r)?`${n}:${r}`:``}).filter(Boolean).join(`;`),Dt=e=>{if(e.nodeType===Node.TEXT_NODE)return document.createTextNode(e.textContent??``);if(!(e instanceof Element))return null;let t=e.tagName;if(B.has(t))return null;let n=t=>e.childNodes.forEach(e=>{let n=Dt(e);n&&t.appendChild(n)}),r=()=>{let e=document.createDocumentFragment();return n(e),e};if(!gt.has(t))return r();let i=document.createElement(t.toLowerCase()),a=Et(e.getAttribute(`style`)??``);if(a&&i.setAttribute(`style`,a),(V[t]??[]).forEach(t=>{let n=e.getAttribute(t);n!==null&&i.setAttribute(t,n)}),t===`A`){let t=Tt(e.getAttribute(`href`),`link`);if(!t)return r();i.setAttribute(`href`,t),e.getAttribute(`target`)===`_blank`&&(i.setAttribute(`target`,`_blank`),i.setAttribute(`rel`,`noopener noreferrer`))}if(t===`IMG`){let t=Tt(e.getAttribute(`src`),`image`);return t?(i.setAttribute(`src`,t),i):null}if(t===`SOURCE`){let t=Tt(e.getAttribute(`src`),`video`);return t?(i.setAttribute(`src`,t),i):null}if(t===`VIDEO`){let t=e.getAttribute(`src`);if(t){let e=Tt(t,`video`);if(!e)return null;i.setAttribute(`src`,e)}}if(t===`IFRAME`){let t=e.getAttribute(`src`)??``;return U.some(e=>t.startsWith(e))?(i.setAttribute(`src`,t),i):null}return t===`BR`||t===`HR`||n(i),i},Ot=e=>{if(typeof window>`u`)return``;let t=new DOMParser().parseFromString(e,`text/html`),n=document.createElement(`div`);return t.body.childNodes.forEach(e=>{let t=Dt(e);t&&n.appendChild(t)}),n.innerHTML},kt=e=>{let t=e.match(/(?:youtube\.com\/(?:watch\?(?:.*&)?v=|embed\/|shorts\/)|youtu\.be\/)([\w-]{11})/);if(t)return{embed:!0,src:`https://www.youtube.com/embed/${t[1]}`};let n=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);if(n)return{embed:!0,src:`https://player.vimeo.com/video/${n[1]}`};let r=Tt(e,`video`);return r?{embed:!1,src:r}:null},At=(e,t)=>`<table><tbody>${Array.from({length:e},(e,n)=>`<tr>${Array.from({length:t},()=>n===0?`<th><br></th>`:`<td><br></td>`).join(``)}</tr>`).join(``)}</tbody></table><p><br></p>`,jt=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)}),J=e=>{try{return document.queryCommandState(e)}catch{return!1}},Mt=()=>{for(let e of[document.body,document.documentElement]){let t=getComputedStyle(e).backgroundColor;if(t&&t!==`rgba(0, 0, 0, 0)`&&t!==`transparent`)return t}return`Canvas`},Nt=[{id:`rowAbove`,label:`Insert row above`},{id:`rowBelow`,label:`Insert row below`},{id:`columnLeft`,label:`Insert column left`},{id:`columnRight`,label:`Insert column right`},{id:`toggleHeader`,label:`Toggle header row`},{id:`deleteRow`,label:`Delete row`,destructive:!0},{id:`deleteColumn`,label:`Delete column`,destructive:!0},{id:`deleteTable`,label:`Delete table`,destructive:!0}],Pt=e=>{let t=document.createElement(e);return t.innerHTML=`<br>`,t},Ft=e=>{let t=e.cloneNode(!1);return Array.from(e.cells).forEach(()=>t.appendChild(Pt(`td`))),t},It=(e,t)=>{let n=e.cell.cellIndex;Array.from(e.table.rows).forEach(e=>{let r=e.cells[n];r&&e.insertBefore(Pt(r.tagName.toLowerCase()),t?r.nextSibling:r)})},Lt={rowAbove:({row:e})=>{e.parentNode?.insertBefore(Ft(e),e)},rowBelow:({row:e})=>{e.parentNode?.insertBefore(Ft(e),e.nextSibling)},columnLeft:e=>It(e,!1),columnRight:e=>It(e,!0),toggleHeader:({table:e})=>{let t=e.rows[0];if(!t)return;let n=t.cells[0]?.tagName===`TH`?`td`:`th`;Array.from(t.cells).forEach(e=>{let t=document.createElement(n);Array.from(e.attributes).forEach(e=>t.setAttribute(e.name,e.value)),t.innerHTML=e.innerHTML,e.replaceWith(t)})},deleteRow:({row:e,table:t})=>{e.remove(),t.rows.length||t.remove()},deleteColumn:({cell:e,table:t})=>{let n=e.cellIndex;Array.from(t.rows).forEach(e=>e.cells[n]?.remove()),t.rows[0]?.cells.length||t.remove()},deleteTable:({table:e})=>e.remove()},Rt=c.createContext(!1);function Y({label:e,icon:t,onClick:n,active:r=!1,disabled:i=!1,ignoreToolbarDisabled:a=!1}){let o=c.useContext(Rt);return(0,u.jsxs)($e,{children:[(0,u.jsx)(et,{asChild:!0,children:(0,u.jsx)(I,{type:`button`,variant:r?`secondary`:`ghost`,size:`icon`,style:bt,"aria-label":e,"aria-pressed":r,disabled:i||o&&!a,onClick:n,children:(0,u.jsx)(t,{style:G})})}),(0,u.jsx)(tt,{children:e})]})}function zt({label:e,icon:t,active:n=!1,width:r=288,open:i,onOpenChange:a,onOpen:o,children:s}){let l=c.useContext(Rt),[d,f]=c.useState(!1),p=i??d,m=e=>{a?a(e):f(e),e&&o?.()};return(0,u.jsxs)(Ie,{open:p,onOpenChange:m,children:[(0,u.jsxs)($e,{children:[(0,u.jsx)(et,{asChild:!0,children:(0,u.jsx)(R,{asChild:!0,children:(0,u.jsx)(I,{type:`button`,variant:n?`secondary`:`ghost`,size:`icon`,style:bt,"aria-label":e,disabled:l,children:(0,u.jsx)(t,{style:G})})})}),(0,u.jsx)(tt,{children:e})]}),(0,u.jsx)(Le,{style:{width:r},align:`start`,onCloseAutoFocus:e=>e.preventDefault(),children:s(()=>m(!1))})]})}function Bt({label:e,icon:t,colors:n,onPick:r,onReset:i}){let[a,o]=c.useState(`#2563eb`),s=/^#[0-9a-f]{6}$/i.test(a);return(0,u.jsx)(zt,{label:e,icon:t,width:256,children:e=>(0,u.jsxs)(`div`,{style:q(12),children:[(0,u.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(6, 28px)`,gap:6},children:n.map(t=>(0,u.jsx)(`button`,{type:`button`,"aria-label":t,style:{height:28,width:28,padding:0,borderRadius:6,border:W,backgroundColor:t,cursor:`pointer`},onClick:()=>{r(t),e()}},t))}),(0,u.jsxs)(`div`,{style:K(8),children:[(0,u.jsx)(`input`,{type:`color`,value:s?a:`#000000`,onChange:e=>o(e.target.value),style:{height:32,width:40,padding:2,borderRadius:4,border:W,background:`transparent`,cursor:`pointer`}}),(0,u.jsx)(L,{value:a,onChange:e=>o(e.target.value),style:{height:32}}),(0,u.jsx)(I,{type:`button`,size:`sm`,disabled:!s,onClick:()=>{r(a),e()},children:`Apply`})]}),(0,u.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,style:{width:`100%`},onClick:()=>{i(),e()},children:`Reset`})]})})}var Vt=(e,t,n)=>{let r=[];if(!t)return r;let i=n?t:t.toLowerCase(),a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=a.nextNode();e;e=a.nextNode()){let t=e.textContent??``,a=n?t:t.toLowerCase();if(a.length!==t.length)continue;let o=a.indexOf(i);for(;o!==-1;){let t=document.createRange();t.setStart(e,o),t.setEnd(e,o+i.length),r.push(t),o=a.indexOf(i,o+i.length)}}return r},Ht=()=>{let e=window.CSS?.highlights,t=window.Highlight;return e&&t?{registry:e,Ctor:t}:null},Ut=e=>{let t=new DOMParser().parseFromString(e,`text/html`);return t.body.querySelectorAll(`br`).forEach(e=>e.replaceWith(`
33
+ `)),t.body.querySelectorAll(`p,div,h1,h2,h3,h4,blockquote,pre,li,tr`).forEach(e=>e.append(`
34
+ `)),t.body.querySelectorAll(`td,th`).forEach(e=>e.append(` `)),(t.body.textContent??``).replace(/\n{3,}/g,`
35
+
36
+ `).trim()},Wt=e=>`<!doctype html><html><head><meta charset="utf-8"><title>Document</title><style>body{font-family:system-ui,-apple-system,Segoe UI,sans-serif;max-width:800px;margin:2rem auto;padding:0 1rem}${_t}</style></head><body><div class="rte-content">${e}</div></body></html>`,Gt=(e,t,n)=>{let r=URL.createObjectURL(new Blob([t],{type:n})),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)};function Kt({label:e,icon:t,items:n,disabled:r=!1,ignoreToolbarDisabled:i=!1}){let a=c.useContext(Rt);return(0,u.jsxs)(Ae,{children:[(0,u.jsxs)($e,{children:[(0,u.jsx)(et,{asChild:!0,children:(0,u.jsx)(je,{asChild:!0,children:(0,u.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,style:bt,"aria-label":e,disabled:r||a&&!i,children:(0,u.jsx)(t,{style:G})})})}),(0,u.jsx)(tt,{children:e})]}),(0,u.jsx)(Me,{onCloseAutoFocus:e=>e.preventDefault(),children:n.map(e=>(0,u.jsxs)(c.Fragment,{children:[e.separatorBefore&&(0,u.jsx)(Pe,{}),(0,u.jsx)(Ne,{onSelect:e.onSelect,children:e.label})]},e.key))})]})}var qt=[{key:`h1`,label:`Heading 1`,hint:`Large section heading`,keywords:`h1 title`},{key:`h2`,label:`Heading 2`,hint:`Medium section heading`,keywords:`h2 subtitle`},{key:`h3`,label:`Heading 3`,hint:`Small section heading`,keywords:`h3`},{key:`bullet`,label:`Bullet list`,hint:`Simple unordered list`,keywords:`ul unordered`},{key:`numbered`,label:`Numbered list`,hint:`Ordered list`,keywords:`ol ordered`},{key:`checklist`,label:`Checklist`,hint:`Track tasks`,keywords:`todo task`},{key:`quote`,label:`Quote`,hint:`Highlight a quote`,keywords:`blockquote`},{key:`code`,label:`Code block`,hint:`Monospaced block`,keywords:`pre`},{key:`divider`,label:`Divider`,hint:`Horizontal line`,keywords:`hr line`},{key:`table`,label:`Table`,hint:`3 ร— 3 table`,keywords:`grid`}];function X({label:e,icon:t,active:n=!1,onClick:r}){return(0,u.jsx)(I,{type:`button`,size:`icon`,variant:n?`secondary`:`ghost`,style:xt,"aria-label":e,"aria-pressed":n,title:e,onClick:r,children:(0,u.jsx)(t,{style:G})})}function Jt(){return(0,u.jsx)(Ge,{orientation:`vertical`,style:{margin:`0 4px`,height:24,width:1}})}function Yt({value:e,onChange:t,placeholder:n=`Write something...`,disabled:r=!1,style:i,minHeight:a=240,maxHeight:o=600,maxFileSizeMB:s=10,maxLength:l,onImageUpload:f,onVideoUpload:p,onError:m,onSuccess:h}){let g=c.useId(),_=c.useRef(null),v=c.useRef(null),y=c.useRef(e),b=c.useRef(e),ee=c.useRef(t);c.useEffect(()=>{ee.current=t});let[x,S]=c.useState(`visual`),[te,ne]=c.useState(``),[C,w]=c.useState(!1),[re,ie]=c.useState(`Canvas`),[T,ae]=c.useState(!e),[oe,se]=c.useState({words:0,chars:0}),[E,D]=c.useState(nt),[O,ce]=c.useState(null),k=c.useRef(null),[,A]=c.useReducer(e=>e+1,0),j=e=>{k.current=e,ce(e)},[le,ue]=c.useState(!1),[de,M]=c.useState(``),[fe,pe]=c.useState(``),[me,he]=c.useState(!0),[ge,N]=c.useState(``),[_e,ve]=c.useState(``),[ye,be]=c.useState(``),[xe,Se]=c.useState({rows:0,cols:0}),[Ce,we]=c.useState(!1),[P,Te]=c.useState(``),[Ee,De]=c.useState(``),[Oe,F]=c.useState(!1),[ke,Ie]=c.useState(0),[R,Le]=c.useState(0),[Ue,We]=c.useState(0),Je=c.useRef([]),[gt,B]=c.useState(null),[V,H]=c.useState(null),[U,Et]=c.useState(0),[Dt,Pt]=c.useState(0),Ft=c.useRef(null),It=c.useRef(!1),Yt=c.useRef(!1),Xt=c.useRef(!1),Zt=c.useRef(()=>{}),Qt=r||x===`source`,$t=(e,t)=>{let n=(e instanceof Element?e:e?.parentElement??null)?.closest(t)??null;return n&&_.current?.contains(n)?n:null},en=e=>{let t=e;for(;t&&t!==_.current;){if(t instanceof Element&&at.has(t.tagName))return t;t=t.parentNode}return null},tn=c.useCallback(()=>{let e=_.current;if(!e)return;let t=e.innerText,n=t.trim();ae(!n&&!e.querySelector(it)),se({words:n?n.split(/\s+/).length:0,chars:t.replace(/\n/g,``).length})},[]),Z=c.useCallback(()=>{let e=_.current;if(!e)return;tn();let t=!e.innerText.trim()&&!e.querySelector(it)?``:Ot(e.innerHTML);t!==y.current&&(y.current=t,ee.current(t))},[tn]),Q=c.useCallback(()=>{let e=_.current,t=document.getSelection();if(!e||!t||!t.rangeCount)return;let n=t.anchorNode;if(!n||!e.contains(n))return;let r=n instanceof Element?n:n.parentElement,i=t=>{let n=r?.closest(t)??null;return n&&e.contains(n)?n:null},a=i(`h1,h2,h3,h4,pre,blockquote`);D({bold:J(`bold`),italic:J(`italic`),underline:J(`underline`),strike:J(`strikeThrough`),sub:J(`subscript`),sup:J(`superscript`),ul:J(`insertUnorderedList`),ol:J(`insertOrderedList`),check:!!i(`ul[data-checklist]`),left:J(`justifyLeft`),center:J(`justifyCenter`),right:J(`justifyRight`),justify:J(`justifyFull`),code:!!i(`code`),link:!!i(`a`),inTable:!!i(`td,th`),block:a?a.tagName.toLowerCase():`p`,size:r?String(Math.round(parseFloat(getComputedStyle(r).fontSize))):``})},[]),nn=()=>{let e=_.current;if(!e)return;let t=document.getSelection();t&&t.rangeCount>0&&e.contains(t.getRangeAt(0).commonAncestorContainer)||(e.focus({preventScroll:!0}),v.current&&t&&(t.removeAllRanges(),t.addRange(v.current)))},$=(e,t,n=!1)=>{nn(),document.execCommand(`styleWithCSS`,!1,String(n)),document.execCommand(e,!1,t),Z(),Q()},rn=e=>{nn(),document.execCommand(`insertHTML`,!1,e),Z()};c.useEffect(()=>{let t=_.current;t&&(e!==y.current||t.innerHTML===``)&&(t.innerHTML=Ot(e)||rt,y.current=e,j(null),tn())},[e,x,tn]),c.useEffect(()=>{x===`visual`&&document.execCommand(`defaultParagraphSeparator`,!1,`p`)},[x]),c.useEffect(()=>{let e=()=>{let e=document.getSelection(),t=_.current;if(!e||!t||!e.rangeCount)return;let n=e.getRangeAt(0);t.contains(n.commonAncestorContainer)&&(v.current=n.cloneRange(),Q())};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},[Q]),c.useEffect(()=>{if(!C)return;let e=e=>{e.key===`Escape`&&w(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C]),c.useEffect(()=>{_.current?.querySelectorAll(`.rte-selected`).forEach(e=>e.classList.remove(`rte-selected`)),O?.classList.add(`rte-selected`)},[O]),c.useEffect(()=>{let e=Ht(),t=()=>{e?.registry.delete(`rte-find`),e?.registry.delete(`rte-find-current`)},n=_.current;if(!Ce||x!==`visual`||!n||!P)return Je.current=[],Le(0),t;let r=Vt(n,P,Oe);if(Je.current=r,Le(r.length),!r.length)return t;let i=Math.min(ke,r.length-1);if(e){let t=new e.Ctor(r[i]);t.priority=1,e.registry.set(`rte-find`,new e.Ctor(...r)),e.registry.set(`rte-find-current`,t)}return r[i].startContainer.parentElement?.scrollIntoView({block:`nearest`}),t},[Ce,P,Oe,ke,Ue,e,x]);let an=e=>$(`formatBlock`,`<${e}>`),on=e=>{nn(),document.execCommand(`styleWithCSS`,!1,`false`),document.execCommand(`fontSize`,!1,`7`),_.current?.querySelectorAll(`font[size="7"]`).forEach(t=>{let n=document.createElement(`span`);for(n.style.fontSize=`${e}px`;t.firstChild;)n.appendChild(t.firstChild);t.replaceWith(n)}),Z(),Q()},sn=()=>{nn();let e=document.getSelection(),t=$t(e?.anchorNode,`code`);if(t&&!t.closest(`pre`)){t.replaceWith(...Array.from(t.childNodes)),Z(),Q();return}let n=e?.toString()??``;n&&(document.execCommand(`insertHTML`,!1,`<code>${Ct(n)}</code>`),Z(),Q())},cn=()=>{nn();let e=()=>document.getSelection()?.anchorNode;if($t(e(),`ul[data-checklist]`)){document.execCommand(`insertUnorderedList`),Z(),Q();return}$t(e(),`ul`)||document.execCommand(`insertUnorderedList`);let t=$t(e(),`ul`);t?.setAttribute(`data-checklist`,``),t?.querySelectorAll(`:scope > li`).forEach(e=>{e.setAttribute(`data-checked`,e.getAttribute(`data-checked`)??`false`)}),Z(),Q()},ln=()=>{$(`removeFormat`),$(`unlink`),$(`formatBlock`,`<p>`)},un=()=>{let e=_.current;e&&(e.innerHTML=Ot(b.current)||rt,j(null),Z(),Q())},dn=()=>{let e=$t(v.current?.startContainer,`a`);M(e?.getAttribute(`href`)??``),pe(e?.textContent??v.current?.toString()??``),he(!e||e.target===`_blank`)},fn=()=>{let e=Tt(wt(de),`link`);if(!e){m?.(`Invalid URL`);return}nn();let t=_.current;if(!t)return;let n=document.getSelection(),r=$t(n?.anchorNode,`a`),i=t=>{t.setAttribute(`href`,e),me?(t.setAttribute(`target`,`_blank`),t.setAttribute(`rel`,`noopener noreferrer`)):(t.removeAttribute(`target`),t.removeAttribute(`rel`))};r?(i(r),fe&&(r.textContent=fe),Z(),Q()):(n?.isCollapsed?document.execCommand(`insertHTML`,!1,`<a href="${Ct(e)}">${Ct(fe||e)}</a>`):document.execCommand(`createLink`,!1,e),Array.from(t.querySelectorAll(`a`)).filter(t=>t.getAttribute(`href`)===e).forEach(i),Z(),Q())},pn=(e,t=``)=>{let n=Tt(wt(e),`image`);n?rn(`<img src="${Ct(n)}" alt="${Ct(t)}" style="max-width:100%;height:auto;display:block">`):m?.(`Invalid image URL`)},mn=e=>{let t=kt(wt(e));if(!t){m?.(`Invalid video URL`);return}let n=t.embed?`<iframe src="${t.src}" allowfullscreen frameborder="0" style="width:100%;aspect-ratio:16/9;display:block"></iframe>`:`<video src="${Ct(t.src)}" controls style="max-width:100%;display:block"></video>`;rn(`${n}<p><br></p>`)},hn=async e=>{for(let t of e){if(t.size>s*1024*1024){m?.(`${t.name} is larger than ${s}MB`);continue}let e=t.type.startsWith(`video/`);try{let n=e?p:f,r=n?await n(t):await jt(t);e?mn(r):pn(r,t.name.replace(/\.[^.]+$/,``))}catch{m?.(`Failed to upload ${t.name}`)}}},gn=()=>{let e=$t(v.current?.startContainer,`td,th`),t=e?.closest(`table`)??null,n=e?.parentElement;return e&&t&&n?{cell:e,table:t,row:n}:null},_n=e=>{let t=gn();t&&(Lt[e]?.(t),Z(),Q())},vn=(e,t)=>{let n=Array.from(e.closest(`table`)?.querySelectorAll(`th,td`)??[]),r=n[n.indexOf(e)+(t?-1:1)],i=document.getSelection();if(!r||!i)return;let a=document.createRange();a.selectNodeContents(r),a.collapse(!0),i.removeAllRanges(),i.addRange(a)},yn=e=>{let t=k.current;t&&(t.style.width=`${e}%`,Z(),A())},bn=e=>{let t=k.current;if(!t)return;let[n,r]=ht[e];t.style.display=`block`,t.style.marginLeft=n,t.style.marginRight=r,Z(),A()},xn=e=>{let t=k.current;t&&(t.setAttribute(`alt`,e),Z(),A())},Sn=()=>{k.current?.remove(),j(null),Z()},Cn=e=>{nn();let t=document.getSelection()?.toString()??``;if(!t)return;let n=e===`upper`?t.toUpperCase():e===`lower`?t.toLowerCase():t.toLowerCase().replace(/(^|\s)(\S)/g,(e,t,n)=>t+n.toUpperCase());document.execCommand(`insertText`,!1,n),Z(),Q()},wn=e=>{nn();let t=_.current,n=document.getSelection();if(!t||!n||!n.rangeCount)return;let r=n.getRangeAt(0);t.querySelectorAll(`p,h1,h2,h3,h4,blockquote,pre,li,td,th,div`).forEach(t=>{r.intersectsNode(t)&&(e?t.style.lineHeight=e:t.style.removeProperty(`line-height`),t.getAttribute(`style`)||t.removeAttribute(`style`))}),Z(),Q()},Tn=e=>$(`insertText`,e),En=e=>(0,u.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,style:{height:32,width:32,fontSize:18},onMouseDown:e=>e.preventDefault(),onClick:()=>Tn(e),children:e},e),Dn=e=>{R&&Ie(t=>(Math.min(t,R-1)+e+R)%R)},On=(e,t)=>{let n=e.startContainer;n.nodeType===Node.TEXT_NODE&&n.replaceData(e.startOffset,e.endOffset-e.startOffset,t)},kn=()=>{let e=Je.current;if(!e.length)return;let t=Math.min(ke,e.length-1);On(e[t],Ee);let n=(Oe?Ee:Ee.toLowerCase()).includes(Oe?P:P.toLowerCase());Ie(n?t+1:t),Z(),We(e=>e+1)},An=()=>{let e=Je.current;e.length&&([...e].reverse().forEach(e=>On(e,Ee)),Ie(0),Z(),We(e=>e+1))},jn=()=>Ot(y.current),Mn=async e=>{try{await navigator.clipboard.writeText(e),h?.(`Copied to clipboard`)}catch{m?.(`Failed to copy`)}},Nn=()=>{let e=window.open(``,`_blank`);e?(e.document.write(Wt(jn())),e.document.close(),e.focus(),setTimeout(()=>e.print(),300)):m?.(`Allow pop-ups to print`)},Pn={"#":()=>$(`formatBlock`,`<h1>`),"##":()=>$(`formatBlock`,`<h2>`),"###":()=>$(`formatBlock`,`<h3>`),"####":()=>$(`formatBlock`,`<h4>`),">":()=>$(`formatBlock`,`<blockquote>`),"-":()=>$(`insertUnorderedList`),"*":()=>$(`insertUnorderedList`),"1.":()=>$(`insertOrderedList`),"[]":cn,"```":()=>$(`formatBlock`,`<pre>`)},Fn=e=>{switch(e){case`h1`:return $(`formatBlock`,`<h1>`);case`h2`:return $(`formatBlock`,`<h2>`);case`h3`:return $(`formatBlock`,`<h3>`);case`bullet`:return $(`insertUnorderedList`);case`numbered`:return $(`insertOrderedList`);case`checklist`:return cn();case`quote`:return $(`formatBlock`,`<blockquote>`);case`code`:return $(`formatBlock`,`<pre>`);case`divider`:return $(`insertHorizontalRule`);case`table`:return rn(At(3,3))}},In=V?qt.filter(e=>!V.query||`${e.label} ${e.keywords}`.toLowerCase().includes(V.query.toLowerCase())):[],Ln=()=>{let e=_.current,t=document.getSelection(),n=!!(e&&t&&t.rangeCount&&t.anchorNode&&t.focusNode&&e.contains(t.anchorNode)&&e.contains(t.focusNode));if(!e||!t||!n||x!==`visual`||r){B(null),H(null),Pt(0);return}if(t.isCollapsed){B(null),Pt(0);let e=en(t.anchorNode);if(e&&(e.tagName===`P`||e.tagName===`DIV`)){let n=document.createRange();n.selectNodeContents(e),n.setEnd(t.anchorNode,t.anchorOffset);let r=/^\/([a-z0-9]*)$/i.exec(n.toString());if(r){if(It.current){H(null);return}let t=r[1].toLowerCase();Ft.current!==t&&(Ft.current=t,Et(0));let n=e.getBoundingClientRect();H(e=>e&&e.query===t&&e.top===n.top&&e.bottom===n.bottom&&e.left===n.left?e:{query:t,top:n.top,bottom:n.bottom,left:n.left});return}}It.current=!1,Ft.current=null,H(null);return}H(null);let i=t.toString().trim();if(Pt(i?i.split(/\s+/).length:0),Yt.current||k.current){B(null);return}let a=t.getRangeAt(0).getBoundingClientRect();if(!a.width&&!a.height){B(null);return}let o=a.left+a.width/2;B(e=>e&&e.top===a.top&&e.bottom===a.bottom&&e.left===o?e:{top:a.top,bottom:a.bottom,left:o})};c.useEffect(()=>{Zt.current=Ln});let Rn=e=>{let t=document.getSelection();if(!t||!t.rangeCount||!t.anchorNode)return;let n=en(t.anchorNode);if(!n)return;let r=document.createRange();if(r.selectNodeContents(n),r.setEnd(t.anchorNode,t.anchorOffset),r.deleteContents(),!n.textContent){n.innerHTML=`<br>`;let e=document.createRange();e.setStart(n,0),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}Ft.current=null,It.current=!1,H(null),Fn(e.key)};c.useEffect(()=>{let e=()=>Zt.current(),t=()=>{Yt.current=!1,e()};return document.addEventListener(`selectionchange`,e),document.addEventListener(`mouseup`,t),window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{document.removeEventListener(`selectionchange`,e),document.removeEventListener(`mouseup`,t),window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[]),c.useEffect(()=>{document.querySelector(`[data-rte-slash-active]`)?.scrollIntoView({block:`nearest`})},[U,V?.query]),c.useEffect(()=>{let e=_.current;if(!e||!l)return;let t=t=>{if(t.inputType!==`insertText`)return;let n=document.getSelection();(!n||n.isCollapsed)&&e.innerText.replace(/\n/g,``).length>=l&&t.preventDefault()};return e.addEventListener(`beforeinput`,t),()=>e.removeEventListener(`beforeinput`,t)},[x,l]);let zn=e=>{let t=document.getSelection();if(!t||!t.rangeCount||!t.isCollapsed||!t.anchorNode)return;let n=en(t.anchorNode);if(!n||n.tagName!==`P`&&n.tagName!==`DIV`)return;let r=document.createRange();r.selectNodeContents(n),r.setEnd(t.anchorNode,t.anchorOffset);let i=Pn[r.toString()];if(i){if(e.preventDefault(),r.deleteContents(),!n.textContent){n.innerHTML=`<br>`;let e=document.createRange();e.setStart(n,0),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}i()}},Bn=e=>{let t=document.getSelection()?.anchorNode;if($t(t,`li`)){e.preventDefault(),$(e.shiftKey?`outdent`:`indent`);return}let n=$t(t,`td,th`);n?(e.preventDefault(),vn(n,e.shiftKey)):$t(t,`pre`)&&(e.preventDefault(),document.execCommand(`insertText`,!1,` `))},Vn=e=>{let t=e.ctrlKey||e.metaKey,n=e.key.toLowerCase();if(Xt.current=t&&e.shiftKey&&n===`v`,V&&In.length){let t=In.length;if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?1:-1;Et(e=>(Math.min(e,t-1)+n+t)%t);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),Rn(In[Math.min(U,t-1)]);return}if(e.key===`Escape`){e.preventDefault(),e.nativeEvent.stopPropagation(),It.current=!0,H(null);return}}t&&n===`k`?(e.preventDefault(),ue(!0),dn()):t&&e.shiftKey&&n===`x`?(e.preventDefault(),$(`strikeThrough`)):e.key===`Tab`?Bn(e):e.key===` `?zn(e):e.key===`Enter`&&!e.shiftKey&&requestAnimationFrame(()=>{let e=$t(document.getSelection()?.anchorNode,`li`);e?.parentElement?.hasAttribute(`data-checklist`)&&(e.setAttribute(`data-checked`,`false`),Z())})},Hn=e=>{let t=Xt.current;Xt.current=!1;let n=Array.from(e.clipboardData.files).filter(e=>/^(image|video)\//.test(e.type));if(e.preventDefault(),n.length){hn(n);return}let r=e.clipboardData.getData(`text/html`);if(r&&!t){document.execCommand(`insertHTML`,!1,Ot(r));return}let i=e.clipboardData.getData(`text/plain`),a=i.trim();if(/^https?:\/\/\S+$/i.test(a)){let e=document.getSelection();if(e&&!e.isCollapsed){document.execCommand(`createLink`,!1,a);return}document.execCommand(`insertHTML`,!1,`<a href="${Ct(a)}">${Ct(a)}</a>&nbsp;`)}else document.execCommand(`insertText`,!1,i)},Un=e=>{let t=Array.from(e.dataTransfer.files).filter(e=>/^(image|video)\//.test(e.type));if(!t.length)return;e.preventDefault();let n=document,r=document.caretRangeFromPoint?.(e.clientX,e.clientY)??null,i=n.caretPositionFromPoint?.(e.clientX,e.clientY);!r&&i&&(r=document.createRange(),r.setStart(i.offsetNode,i.offset));let a=document.getSelection();r&&a&&(a.removeAllRanges(),a.addRange(r),v.current=r.cloneRange()),hn(t)},Wn=e=>{let t=e.target;if([`IMG`,`VIDEO`,`IFRAME`].includes(t.tagName)){let e=document.createRange();e.selectNode(t);let n=document.getSelection();n?.removeAllRanges(),n?.addRange(e),j(t);return}if(j(null),r)return;let n=t.closest(`li`);if(!n||!n.parentElement?.hasAttribute(`data-checklist`))return;let i=e.clientX-n.getBoundingClientRect().left;i<0||i>26||(n.setAttribute(`data-checked`,n.getAttribute(`data-checked`)===`true`?`false`:`true`),Z())},Gn=()=>{k.current&&!_.current?.contains(k.current)&&j(null),Z(),Q()},Kn=()=>{x===`visual`?(ne(y.current),S(`source`)):S(`visual`)},qn=()=>{C||ie(Mt()),w(e=>!e)},Jn=e=>{let t=e.target;e.currentTarget.contains(t)&&!t.closest(`input,textarea`)&&e.preventDefault()},Yn={display:`flex`,flexDirection:`column`,overflow:`hidden`,borderRadius:6,border:W,opacity:r?.6:1,...C?{position:`fixed`,inset:0,zIndex:40,borderRadius:0,backgroundColor:re}:null,...i};return(0,u.jsxs)(z,{delayDuration:300,children:[(0,u.jsx)(`style`,{children:_t}),(0,u.jsxs)(`div`,{style:Yn,children:[(0,u.jsx)(Rt.Provider,{value:Qt,children:(0,u.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:2,padding:6,borderBottom:W,background:vt},onMouseDown:Jn,children:[(0,u.jsx)(Y,{label:`Undo`,icon:d.Undo2,onClick:()=>$(`undo`)}),(0,u.jsx)(Y,{label:`Redo`,icon:d.Redo2,onClick:()=>$(`redo`)}),(0,u.jsx)(Jt,{}),(0,u.jsxs)(Re,{value:E.block,onValueChange:an,disabled:Qt,children:[(0,u.jsx)(Be,{style:St(124),"aria-label":`Block type`,children:(0,u.jsx)(ze,{})}),(0,u.jsx)(Ve,{onCloseAutoFocus:e=>e.preventDefault(),children:ot.map(e=>(0,u.jsx)(He,{value:e.value,children:e.label},e.value))})]}),(0,u.jsxs)(Re,{value:``,onValueChange:e=>$(`fontName`,e,!0),disabled:Qt,children:[(0,u.jsx)(Be,{style:St(104),"aria-label":`Font family`,children:(0,u.jsx)(ze,{placeholder:`Font`})}),(0,u.jsx)(Ve,{onCloseAutoFocus:e=>e.preventDefault(),children:st.map(e=>(0,u.jsx)(He,{value:e,style:{fontFamily:e},children:e},e))})]}),(0,u.jsxs)(Re,{value:ct.includes(E.size)?E.size:``,onValueChange:on,disabled:Qt,children:[(0,u.jsx)(Be,{style:St(76),"aria-label":`Font size`,children:(0,u.jsx)(ze,{placeholder:`Size`})}),(0,u.jsx)(Ve,{onCloseAutoFocus:e=>e.preventDefault(),children:ct.map(e=>(0,u.jsx)(He,{value:e,children:e},e))})]}),(0,u.jsx)(Jt,{}),(0,u.jsx)(Y,{label:`Bold (Ctrl+B)`,icon:d.Bold,active:E.bold,onClick:()=>$(`bold`)}),(0,u.jsx)(Y,{label:`Italic (Ctrl+I)`,icon:d.Italic,active:E.italic,onClick:()=>$(`italic`)}),(0,u.jsx)(Y,{label:`Underline (Ctrl+U)`,icon:d.Underline,active:E.underline,onClick:()=>$(`underline`)}),(0,u.jsx)(Y,{label:`Strikethrough (Ctrl+Shift+X)`,icon:d.Strikethrough,active:E.strike,onClick:()=>$(`strikeThrough`)}),(0,u.jsx)(Y,{label:`Inline code`,icon:d.Code,active:E.code,onClick:sn}),(0,u.jsx)(Y,{label:`Subscript`,icon:d.Subscript,active:E.sub,onClick:()=>$(`subscript`)}),(0,u.jsx)(Y,{label:`Superscript`,icon:d.Superscript,active:E.sup,onClick:()=>$(`superscript`)}),(0,u.jsx)(Jt,{}),(0,u.jsx)(Bt,{label:`Text color`,icon:d.Baseline,colors:pt,onPick:e=>$(`foreColor`,e,!0),onReset:()=>$(`foreColor`,`currentColor`,!0)}),(0,u.jsx)(Bt,{label:`Highlight`,icon:d.Highlighter,colors:mt,onPick:e=>$(`hiliteColor`,e,!0),onReset:()=>$(`hiliteColor`,`transparent`,!0)}),(0,u.jsx)(Jt,{}),(0,u.jsx)(Y,{label:`Align left`,icon:d.AlignLeft,active:E.left,onClick:()=>$(`justifyLeft`,void 0,!0)}),(0,u.jsx)(Y,{label:`Align center`,icon:d.AlignCenter,active:E.center,onClick:()=>$(`justifyCenter`,void 0,!0)}),(0,u.jsx)(Y,{label:`Align right`,icon:d.AlignRight,active:E.right,onClick:()=>$(`justifyRight`,void 0,!0)}),(0,u.jsx)(Y,{label:`Justify`,icon:d.AlignJustify,active:E.justify,onClick:()=>$(`justifyFull`,void 0,!0)}),(0,u.jsx)(Jt,{}),(0,u.jsx)(Y,{label:`Bullet list`,icon:d.List,active:E.ul&&!E.check,onClick:()=>$(`insertUnorderedList`)}),(0,u.jsx)(Y,{label:`Numbered list`,icon:d.ListOrdered,active:E.ol,onClick:()=>$(`insertOrderedList`)}),(0,u.jsx)(Y,{label:`Checklist`,icon:d.ListChecks,active:E.check,onClick:cn}),(0,u.jsx)(Y,{label:`Decrease indent`,icon:d.IndentDecrease,onClick:()=>$(`outdent`,void 0,!0)}),(0,u.jsx)(Y,{label:`Increase indent`,icon:d.IndentIncrease,onClick:()=>$(`indent`,void 0,!0)}),(0,u.jsx)(Jt,{}),(0,u.jsx)(zt,{label:`Link (Ctrl+K)`,icon:d.Link2,active:E.link,open:le,onOpenChange:ue,onOpen:dn,children:e=>(0,u.jsxs)(`div`,{style:q(12),children:[(0,u.jsxs)(`div`,{style:q(6),children:[(0,u.jsx)(Fe,{htmlFor:`${g}-link-url`,children:`URL`}),(0,u.jsx)(L,{id:`${g}-link-url`,value:de,placeholder:`https://example.com`,onChange:e=>M(e.target.value),onKeyDown:t=>{t.key===`Enter`&&(t.preventDefault(),fn(),e())}})]}),(0,u.jsxs)(`div`,{style:q(6),children:[(0,u.jsx)(Fe,{htmlFor:`${g}-link-text`,children:`Text`}),(0,u.jsx)(L,{id:`${g}-link-text`,value:fe,placeholder:`Link text`,onChange:e=>pe(e.target.value)})]}),(0,u.jsxs)(`div`,{style:{...K(8),justifyContent:`space-between`},children:[(0,u.jsx)(Fe,{htmlFor:`${g}-link-tab`,children:`Open in new tab`}),(0,u.jsx)(Ke,{id:`${g}-link-tab`,checked:me,onCheckedChange:he})]}),(0,u.jsxs)(`div`,{style:{...K(8),justifyContent:`flex-end`},children:[E.link&&(0,u.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{$(`unlink`),e()},children:`Remove`}),(0,u.jsx)(I,{type:`button`,size:`sm`,onClick:()=>{fn(),e()},children:`Apply`})]})]})}),(0,u.jsx)(Y,{label:`Remove link`,icon:d.Unlink,disabled:!E.link,onClick:()=>$(`unlink`)}),(0,u.jsx)(zt,{label:`Image`,icon:d.Image,width:320,children:e=>(0,u.jsxs)(qe,{defaultValue:`upload`,style:q(12),children:[(0,u.jsxs)(Ye,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,width:`100%`},children:[(0,u.jsx)(Xe,{value:`upload`,children:`Upload`}),(0,u.jsx)(Xe,{value:`url`,children:`URL`})]}),(0,u.jsx)(Ze,{value:`upload`,children:(0,u.jsx)(L,{type:`file`,accept:`image/*`,multiple:!0,onChange:t=>{let n=Array.from(t.target.files??[]);t.target.value=``,e(),hn(n)}})}),(0,u.jsxs)(Ze,{value:`url`,style:q(12),children:[(0,u.jsx)(L,{value:ge,placeholder:`https://example.com/image.png`,onChange:e=>N(e.target.value)}),(0,u.jsx)(L,{value:_e,placeholder:`Alt text`,onChange:e=>ve(e.target.value)}),(0,u.jsx)(I,{type:`button`,size:`sm`,style:{width:`100%`},disabled:!ge.trim(),onClick:()=>{pn(ge,_e),N(``),ve(``),e()},children:`Insert image`})]})]})}),(0,u.jsx)(zt,{label:`Video`,icon:d.Video,width:320,children:e=>(0,u.jsxs)(qe,{defaultValue:`url`,style:q(12),children:[(0,u.jsxs)(Ye,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,width:`100%`},children:[(0,u.jsx)(Xe,{value:`url`,children:`URL`}),(0,u.jsx)(Xe,{value:`upload`,children:`Upload`})]}),(0,u.jsxs)(Ze,{value:`url`,style:q(12),children:[(0,u.jsx)(L,{value:ye,placeholder:`YouTube, Vimeo or .mp4 link`,onChange:e=>be(e.target.value)}),(0,u.jsx)(I,{type:`button`,size:`sm`,style:{width:`100%`},disabled:!ye.trim(),onClick:()=>{mn(ye),be(``),e()},children:`Insert video`})]}),(0,u.jsx)(Ze,{value:`upload`,children:(0,u.jsx)(L,{type:`file`,accept:`video/*`,onChange:t=>{let n=Array.from(t.target.files??[]);t.target.value=``,e(),hn(n)}})})]})}),(0,u.jsx)(zt,{label:`Table`,icon:d.Table,width:`auto`,children:e=>(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(8, 20px)`,gap:4},onMouseLeave:()=>Se({rows:0,cols:0}),children:Array.from({length:64},(t,n)=>{let r=Math.floor(n/8)+1,i=n%8+1,a=r<=xe.rows&&i<=xe.cols;return(0,u.jsx)(`button`,{type:`button`,"aria-label":`${r} by ${i} table`,style:{height:20,width:20,padding:0,borderRadius:2,border:W,cursor:`pointer`,background:a?`currentColor`:`transparent`},onMouseEnter:()=>Se({rows:r,cols:i}),onClick:()=>{rn(At(r,i)),e()}},n)})}),(0,u.jsxs)(`p`,{style:{marginTop:8,textAlign:`center`,fontSize:12,opacity:.7},children:[xe.rows,` ร— `,xe.cols]})]})}),E.inTable&&(0,u.jsxs)(Ae,{children:[(0,u.jsxs)($e,{children:[(0,u.jsx)(et,{asChild:!0,children:(0,u.jsx)(je,{asChild:!0,children:(0,u.jsx)(I,{type:`button`,variant:`secondary`,size:`icon`,style:bt,"aria-label":`Table options`,children:(0,u.jsx)(d.TableProperties,{style:G})})})}),(0,u.jsx)(tt,{children:`Table options`})]}),(0,u.jsx)(Me,{onCloseAutoFocus:e=>e.preventDefault(),children:Nt.map(e=>(0,u.jsxs)(c.Fragment,{children:[e.label===`Delete row`&&(0,u.jsx)(Pe,{}),(0,u.jsx)(Ne,{style:e.destructive?{color:yt}:void 0,onSelect:()=>_n(e.id),children:e.label})]},e.label))})]}),(0,u.jsx)(Y,{label:`Divider`,icon:d.Minus,onClick:()=>$(`insertHorizontalRule`)}),(0,u.jsx)(Y,{label:`Clear formatting`,icon:d.RemoveFormatting,onClick:ln}),(0,u.jsx)(Jt,{}),(0,u.jsx)(Kt,{label:`Change case`,icon:d.Type,items:[{key:`upper`,label:`UPPERCASE`,onSelect:()=>Cn(`upper`)},{key:`lower`,label:`lowercase`,onSelect:()=>Cn(`lower`)},{key:`title`,label:`Title Case`,onSelect:()=>Cn(`title`)}]}),(0,u.jsx)(Kt,{label:`Line height`,icon:d.ArrowUpDown,items:[...lt.map(e=>({key:e,label:e,onSelect:()=>wn(e)})),{key:`default`,label:`Default`,separatorBefore:!0,onSelect:()=>wn(``)}]}),(0,u.jsx)(zt,{label:`Emoji & symbols`,icon:d.Smile,width:320,children:()=>(0,u.jsxs)(qe,{defaultValue:`emoji`,style:q(12),children:[(0,u.jsxs)(Ye,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,width:`100%`},children:[(0,u.jsx)(Xe,{value:`emoji`,children:`Emoji`}),(0,u.jsx)(Xe,{value:`symbols`,children:`Symbols`})]}),(0,u.jsx)(Ze,{value:`emoji`,children:(0,u.jsx)(`div`,{style:ft,children:ut.map(En)})}),(0,u.jsx)(Ze,{value:`symbols`,children:(0,u.jsx)(`div`,{style:ft,children:dt.map(En)})})]})}),(0,u.jsx)(zt,{label:`Find & replace`,icon:d.Search,width:320,open:Ce,onOpenChange:we,children:()=>(0,u.jsxs)(`div`,{style:q(12),children:[(0,u.jsxs)(`div`,{style:q(6),children:[(0,u.jsx)(Fe,{htmlFor:`${g}-find`,children:`Find`}),(0,u.jsx)(L,{id:`${g}-find`,value:P,placeholder:`Search text`,onChange:e=>{Te(e.target.value),Ie(0)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Dn(e.shiftKey?-1:1))}})]}),(0,u.jsxs)(`div`,{style:q(6),children:[(0,u.jsx)(Fe,{htmlFor:`${g}-replace`,children:`Replace with`}),(0,u.jsx)(L,{id:`${g}-replace`,value:Ee,placeholder:`Replacement`,onChange:e=>De(e.target.value)})]}),(0,u.jsxs)(`div`,{style:{...K(6),justifyContent:`space-between`},children:[(0,u.jsxs)(`div`,{style:K(4),children:[(0,u.jsx)(I,{type:`button`,size:`sm`,variant:Oe?`secondary`:`outline`,"aria-pressed":Oe,"aria-label":`Match case`,style:{height:28,padding:`0 8px`,fontSize:12},onClick:()=>{F(e=>!e),Ie(0)},children:`Aa`}),(0,u.jsx)(I,{type:`button`,size:`icon`,variant:`ghost`,style:xt,"aria-label":`Previous match`,disabled:!R,onClick:()=>Dn(-1),children:(0,u.jsx)(d.ChevronUp,{style:G})}),(0,u.jsx)(I,{type:`button`,size:`icon`,variant:`ghost`,style:xt,"aria-label":`Next match`,disabled:!R,onClick:()=>Dn(1),children:(0,u.jsx)(d.ChevronDown,{style:G})})]}),(0,u.jsx)(`span`,{style:{fontSize:12,opacity:.7},children:P?R?`${Math.min(ke,R-1)+1} / ${R}`:`No matches`:``})]}),(0,u.jsxs)(`div`,{style:{...K(8),justifyContent:`flex-end`},children:[(0,u.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,disabled:!R,onClick:kn,children:`Replace`}),(0,u.jsx)(I,{type:`button`,size:`sm`,disabled:!R,onClick:An,children:`Replace all`})]})]})}),(0,u.jsxs)(`div`,{style:{...K(2),marginLeft:`auto`},children:[(0,u.jsx)(Kt,{label:`Export`,icon:d.Download,ignoreToolbarDisabled:!0,items:[{key:`copy-html`,label:`Copy HTML`,onSelect:()=>void Mn(jn())},{key:`copy-text`,label:`Copy plain text`,onSelect:()=>void Mn(Ut(jn()))},{key:`download`,label:`Download .html`,separatorBefore:!0,onSelect:()=>Gt(`document.html`,Wt(jn()),`text/html`)},{key:`print`,label:`Print`,onSelect:Nn}]}),(0,u.jsx)(zt,{label:`Reset content`,icon:d.RotateCcw,width:240,children:e=>(0,u.jsxs)(`div`,{style:q(12),children:[(0,u.jsx)(`p`,{style:{fontSize:14},children:`Reset the editor to its initial content?`}),(0,u.jsxs)(`div`,{style:{...K(8),justifyContent:`flex-end`},children:[(0,u.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:e,children:`Cancel`}),(0,u.jsx)(I,{type:`button`,size:`sm`,onClick:()=>{un(),e()},children:`Reset`})]})]})}),(0,u.jsx)(Y,{label:`HTML source`,icon:d.CodeXml,active:x===`source`,disabled:r,ignoreToolbarDisabled:!0,onClick:Kn}),(0,u.jsx)(Y,{label:C?`Exit fullscreen`:`Fullscreen`,icon:C?d.Minimize2:d.Maximize2,disabled:!1,ignoreToolbarDisabled:!0,onClick:qn})]})]})}),O&&x===`visual`&&(0,u.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:4,padding:`6px 8px`,borderBottom:W,background:vt},onMouseDown:Jn,children:[(0,u.jsx)(`span`,{style:{marginRight:4,fontSize:12,fontWeight:500,opacity:.7},children:O.tagName===`IMG`?`Image`:`Video`}),[25,50,75,100].map(e=>(0,u.jsxs)(I,{type:`button`,size:`sm`,variant:O.style.width===`${e}%`?`secondary`:`ghost`,style:{height:28,padding:`0 8px`,fontSize:12},onClick:()=>yn(e),children:[e,`%`]},e)),(0,u.jsx)(Ge,{orientation:`vertical`,style:{margin:`0 4px`,height:20,width:1}}),(0,u.jsx)(I,{type:`button`,size:`icon`,variant:`ghost`,style:xt,"aria-label":`Align left`,onClick:()=>bn(`left`),children:(0,u.jsx)(d.AlignLeft,{style:G})}),(0,u.jsx)(I,{type:`button`,size:`icon`,variant:`ghost`,style:xt,"aria-label":`Align center`,onClick:()=>bn(`center`),children:(0,u.jsx)(d.AlignCenter,{style:G})}),(0,u.jsx)(I,{type:`button`,size:`icon`,variant:`ghost`,style:xt,"aria-label":`Align right`,onClick:()=>bn(`right`),children:(0,u.jsx)(d.AlignRight,{style:G})}),O.tagName===`IMG`&&(0,u.jsx)(L,{value:O.getAttribute(`alt`)??``,placeholder:`Alt text`,style:{marginLeft:4,height:28,width:176,fontSize:12},onChange:e=>xn(e.target.value)}),(0,u.jsxs)(`div`,{style:{...K(4),marginLeft:`auto`},children:[(0,u.jsx)(I,{type:`button`,size:`icon`,variant:`ghost`,style:{...xt,color:yt},"aria-label":`Delete`,onClick:Sn,children:(0,u.jsx)(d.Trash2,{style:G})}),(0,u.jsx)(I,{type:`button`,size:`icon`,variant:`ghost`,style:xt,"aria-label":`Close`,onClick:()=>j(null),children:(0,u.jsx)(d.X,{style:G})})]})]}),(0,u.jsx)(`div`,{style:{position:`relative`,overflow:`auto`,flex:C?1:void 0,maxHeight:C?void 0:o},children:x===`visual`?(0,u.jsxs)(u.Fragment,{children:[T&&(0,u.jsx)(`div`,{style:{position:`absolute`,left:16,top:12,pointerEvents:`none`,opacity:.5},children:n}),(0,u.jsx)(`div`,{ref:_,contentEditable:!r,suppressContentEditableWarning:!0,spellCheck:!0,role:`textbox`,"aria-multiline":`true`,"aria-label":`Rich text editor`,className:`rte-content rte-editor`,style:{padding:`12px 16px`,minHeight:a},onInput:Gn,onKeyDown:Vn,onPaste:Hn,onDrop:Un,onMouseDown:()=>{Yt.current=!0,B(null)},onClick:Wn})]}):(0,u.jsx)(Qe,{value:te,spellCheck:!1,style:{width:`100%`,minHeight:a,borderRadius:0,border:0,boxShadow:`none`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:14},onChange:e=>{ne(e.target.value);let n=Ot(e.target.value);y.current=n,t(n)}})}),(0,u.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,justifyContent:`space-between`,gap:8,padding:`6px 12px`,borderTop:W,background:vt,fontSize:12,opacity:.8},children:[(0,u.jsxs)(`span`,{children:[oe.words,` words,`,` `,(0,u.jsxs)(`span`,{style:{color:l&&oe.chars>l?yt:void 0},children:[oe.chars,l?` / ${l}`:``]}),` `,`characters`,oe.words>0&&` ยท ${Math.max(1,Math.ceil(oe.words/200))} min read`,Dt>0&&` ยท ${Dt} selected`]}),(0,u.jsx)(`span`,{children:`Ctrl+K link, / commands, # heading, - list, [] checklist`})]})]}),gt&&x===`visual`&&!r&&(0,u.jsxs)(`div`,{className:`bg-popover text-popover-foreground rounded-md border shadow-md`,role:`toolbar`,"aria-label":`Text formatting`,style:{position:`fixed`,zIndex:60,display:`flex`,alignItems:`center`,gap:2,padding:4,left:Math.min(Math.max(gt.left,200),Math.max(200,window.innerWidth-200)),...gt.top<56?{top:gt.bottom+8,transform:`translateX(-50%)`}:{top:gt.top-8,transform:`translate(-50%, -100%)`}},onMouseDown:Jn,children:[(0,u.jsx)(X,{label:`Bold`,icon:d.Bold,active:E.bold,onClick:()=>$(`bold`)}),(0,u.jsx)(X,{label:`Italic`,icon:d.Italic,active:E.italic,onClick:()=>$(`italic`)}),(0,u.jsx)(X,{label:`Underline`,icon:d.Underline,active:E.underline,onClick:()=>$(`underline`)}),(0,u.jsx)(X,{label:`Strikethrough`,icon:d.Strikethrough,active:E.strike,onClick:()=>$(`strikeThrough`)}),(0,u.jsx)(X,{label:`Inline code`,icon:d.Code,active:E.code,onClick:sn}),(0,u.jsx)(Jt,{}),(0,u.jsx)(X,{label:`Link`,icon:d.Link2,active:E.link,onClick:()=>{ue(!0),dn()}}),(0,u.jsx)(X,{label:`Highlight`,icon:d.Highlighter,onClick:()=>$(`hiliteColor`,mt[0],!0)}),(0,u.jsx)(Jt,{}),(0,u.jsx)(X,{label:`Heading 1`,icon:d.Heading1,active:E.block===`h1`,onClick:()=>an(E.block===`h1`?`p`:`h1`)}),(0,u.jsx)(X,{label:`Heading 2`,icon:d.Heading2,active:E.block===`h2`,onClick:()=>an(E.block===`h2`?`p`:`h2`)}),(0,u.jsx)(X,{label:`Quote`,icon:d.Quote,active:E.block===`blockquote`,onClick:()=>an(E.block===`blockquote`?`p`:`blockquote`)}),(0,u.jsx)(Jt,{}),(0,u.jsx)(X,{label:`Clear formatting`,icon:d.RemoveFormatting,onClick:ln})]}),V&&x===`visual`&&!r&&In.length>0&&(0,u.jsx)(`div`,{className:`bg-popover text-popover-foreground rounded-md border shadow-md`,role:`listbox`,"aria-label":`Commands`,style:{position:`fixed`,zIndex:60,width:232,maxHeight:280,overflowY:`auto`,padding:4,left:Math.max(8,Math.min(V.left,window.innerWidth-240)),...V.bottom+288>window.innerHeight&&V.top>296?{bottom:window.innerHeight-V.top+4}:{top:V.bottom+4}},onMouseDown:e=>e.preventDefault(),children:In.map((e,t)=>{let n=t===Math.min(U,In.length-1);return(0,u.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,"data-rte-slash-active":n?`true`:void 0,onMouseEnter:()=>Et(t),onClick:()=>Rn(e),style:{display:`flex`,flexDirection:`column`,alignItems:`flex-start`,width:`100%`,padding:`6px 8px`,border:0,borderRadius:4,color:`inherit`,textAlign:`left`,cursor:`pointer`,background:n?`color-mix(in srgb, currentColor 10%, transparent)`:`transparent`},children:[(0,u.jsx)(`span`,{style:{fontSize:14},children:e.label}),(0,u.jsx)(`span`,{style:{fontSize:12,opacity:.6},children:e.hint})]},e.key)})})]})}function Xt({value:e,style:t}){let n=c.useRef(null);return c.useEffect(()=>{n.current&&(n.current.innerHTML=Ot(e))},[e]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`style`,{children:_t}),(0,u.jsx)(`div`,{ref:n,className:`rte-content`,style:t})]})}exports.RichTextEditor=Yt,exports.RichTextViewer=Xt;