chaeditor 0.1.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.
Files changed (40) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.ko.md +250 -0
  3. package/README.md +242 -0
  4. package/dist/core.cjs +1034 -0
  5. package/dist/core.d.mts +347 -0
  6. package/dist/core.d.ts +347 -0
  7. package/dist/core.mjs +988 -0
  8. package/dist/default-host.cjs +243 -0
  9. package/dist/default-host.d.mts +52 -0
  10. package/dist/default-host.d.ts +52 -0
  11. package/dist/default-host.mjs +239 -0
  12. package/dist/default-markdown-primitive-registry-B3PGEkqs.d.mts +12 -0
  13. package/dist/default-markdown-primitive-registry-CqzwhHj2.d.ts +12 -0
  14. package/dist/image-upload-kind-BJqItE_C.d.mts +18 -0
  15. package/dist/image-upload-kind-BJqItE_C.d.ts +18 -0
  16. package/dist/index.cjs +8736 -0
  17. package/dist/index.d.mts +7 -0
  18. package/dist/index.d.ts +7 -0
  19. package/dist/index.mjs +8668 -0
  20. package/dist/markdown-editor-B1qvE40Z.d.mts +460 -0
  21. package/dist/markdown-editor-Ce6DpnQk.d.ts +460 -0
  22. package/dist/markdown-primitive-contract-BXsqbKwY.d.mts +124 -0
  23. package/dist/markdown-primitive-contract-BXsqbKwY.d.ts +124 -0
  24. package/dist/panda-primitives.cjs +1299 -0
  25. package/dist/panda-primitives.d.mts +21127 -0
  26. package/dist/panda-primitives.d.ts +21127 -0
  27. package/dist/panda-primitives.mjs +1285 -0
  28. package/dist/react.cjs +8558 -0
  29. package/dist/react.d.mts +35 -0
  30. package/dist/react.d.ts +35 -0
  31. package/dist/react.mjs +8531 -0
  32. package/dist/toolbar-preset-B9ttTEol.d.ts +236 -0
  33. package/dist/toolbar-preset-DIsQN390.d.mts +236 -0
  34. package/package.json +151 -0
  35. package/recipes/host-presets/README.md +16 -0
  36. package/recipes/host-presets/emotion-host-preset.tsx.template +109 -0
  37. package/recipes/host-presets/styled-components-host-preset.tsx.template +102 -0
  38. package/recipes/host-presets/tailwind-host-preset.tsx.template +116 -0
  39. package/recipes/host-presets/vanilla-extract-host-preset.tsx.template +116 -0
  40. package/styled-system/styles.css +3370 -0
@@ -0,0 +1,1285 @@
1
+ import React, { forwardRef, useRef, useLayoutEffect, useState, useEffect, useId, isValidElement, cloneElement, useCallback } from 'react';
2
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
+ import { createPortal } from 'react-dom';
4
+
5
+ // src/shared/ui/button/button.tsx
6
+
7
+ // styled-system/helpers.mjs
8
+ function isObject(value) {
9
+ return typeof value === "object" && value != null && !Array.isArray(value);
10
+ }
11
+ var isObjectOrArray = (obj) => typeof obj === "object" && obj !== null;
12
+ function compact(value) {
13
+ return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));
14
+ }
15
+ var isBaseCondition = (v) => v === "base";
16
+ function filterBaseConditions(c) {
17
+ return c.slice().filter((v) => !isBaseCondition(v));
18
+ }
19
+ function toChar(code) {
20
+ return String.fromCharCode(code + (code > 25 ? 39 : 97));
21
+ }
22
+ function toName(code) {
23
+ let name = "";
24
+ let x;
25
+ for (x = Math.abs(code); x > 52; x = x / 52 | 0) name = toChar(x % 52) + name;
26
+ return toChar(x % 52) + name;
27
+ }
28
+ function toPhash(h, x) {
29
+ let i = x.length;
30
+ while (i) h = h * 33 ^ x.charCodeAt(--i);
31
+ return h;
32
+ }
33
+ function toHash(value) {
34
+ return toName(toPhash(5381, value) >>> 0);
35
+ }
36
+ var importantRegex = /\s*!(important)?/i;
37
+ function isImportant(value) {
38
+ return typeof value === "string" ? importantRegex.test(value) : false;
39
+ }
40
+ function withoutImportant(value) {
41
+ return typeof value === "string" ? value.replace(importantRegex, "").trim() : value;
42
+ }
43
+ function withoutSpace(str) {
44
+ return typeof str === "string" ? str.replaceAll(" ", "_") : str;
45
+ }
46
+ var memo = (fn) => {
47
+ const cache = /* @__PURE__ */ new Map();
48
+ const get = (...args) => {
49
+ const key = JSON.stringify(args);
50
+ if (cache.has(key)) {
51
+ return cache.get(key);
52
+ }
53
+ const result = fn(...args);
54
+ cache.set(key, result);
55
+ return result;
56
+ };
57
+ return get;
58
+ };
59
+ var MERGE_OMIT = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
60
+ function mergeProps(...sources) {
61
+ return sources.reduce((prev, obj) => {
62
+ if (!obj) return prev;
63
+ Object.keys(obj).forEach((key) => {
64
+ if (MERGE_OMIT.has(key)) return;
65
+ const prevValue = prev[key];
66
+ const value = obj[key];
67
+ if (isObject(prevValue) && isObject(value)) {
68
+ prev[key] = mergeProps(prevValue, value);
69
+ } else {
70
+ prev[key] = value;
71
+ }
72
+ });
73
+ return prev;
74
+ }, {});
75
+ }
76
+ var isNotNullish = (element) => element != null;
77
+ function walkObject(target, predicate, options = {}) {
78
+ const { stop, getKey } = options;
79
+ function inner(value, path = []) {
80
+ if (isObjectOrArray(value)) {
81
+ const result = {};
82
+ for (const [prop, child] of Object.entries(value)) {
83
+ const key = getKey?.(prop, child) ?? prop;
84
+ const childPath = [...path, key];
85
+ if (stop?.(value, childPath)) {
86
+ return predicate(value, path);
87
+ }
88
+ const next = inner(child, childPath);
89
+ if (isNotNullish(next)) {
90
+ result[key] = next;
91
+ }
92
+ }
93
+ return result;
94
+ }
95
+ return predicate(value, path);
96
+ }
97
+ return inner(target);
98
+ }
99
+ function toResponsiveObject(values, breakpoints) {
100
+ return values.reduce(
101
+ (acc, current, index) => {
102
+ const key = breakpoints[index];
103
+ if (current != null) {
104
+ acc[key] = current;
105
+ }
106
+ return acc;
107
+ },
108
+ {}
109
+ );
110
+ }
111
+ function normalizeStyleObject(styles, context2, shorthand = true) {
112
+ const { utility, conditions: conditions2 } = context2;
113
+ const { hasShorthand, resolveShorthand: resolveShorthand2 } = utility;
114
+ return walkObject(
115
+ styles,
116
+ (value) => {
117
+ return Array.isArray(value) ? toResponsiveObject(value, conditions2.breakpoints.keys) : value;
118
+ },
119
+ {
120
+ stop: (value) => Array.isArray(value),
121
+ getKey: shorthand ? (prop) => hasShorthand ? resolveShorthand2(prop) : prop : void 0
122
+ }
123
+ );
124
+ }
125
+ var fallbackCondition = {
126
+ shift: (v) => v,
127
+ finalize: (v) => v,
128
+ breakpoints: { keys: [] }
129
+ };
130
+ var sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\n\s]+/g, " ") : value;
131
+ function createCss(context2) {
132
+ const { utility, hash, conditions: conds = fallbackCondition } = context2;
133
+ const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");
134
+ const hashFn = (conditions2, className) => {
135
+ let result;
136
+ if (hash) {
137
+ const baseArray = [...conds.finalize(conditions2), className];
138
+ result = formatClassName(utility.toHash(baseArray, toHash));
139
+ } else {
140
+ const baseArray = [...conds.finalize(conditions2), formatClassName(className)];
141
+ result = baseArray.join(":");
142
+ }
143
+ return result;
144
+ };
145
+ return memo(({ base, ...styles } = {}) => {
146
+ const styleObject = Object.assign(styles, base);
147
+ const normalizedObject = normalizeStyleObject(styleObject, context2);
148
+ const classNames = /* @__PURE__ */ new Set();
149
+ walkObject(normalizedObject, (value, paths) => {
150
+ if (value == null) return;
151
+ const important = isImportant(value);
152
+ const [prop, ...allConditions] = conds.shift(paths);
153
+ const conditions2 = filterBaseConditions(allConditions);
154
+ const transformed = utility.transform(prop, withoutImportant(sanitize(value)));
155
+ let className = hashFn(conditions2, transformed.className);
156
+ if (important) className = `${className}!`;
157
+ classNames.add(className);
158
+ });
159
+ return Array.from(classNames).join(" ");
160
+ });
161
+ }
162
+ function compactStyles(...styles) {
163
+ return styles.flat().filter((style) => isObject(style) && Object.keys(compact(style)).length > 0);
164
+ }
165
+ function createMergeCss(context2) {
166
+ function resolve(styles) {
167
+ const allStyles = compactStyles(...styles);
168
+ if (allStyles.length === 1) return allStyles;
169
+ return allStyles.map((style) => normalizeStyleObject(style, context2));
170
+ }
171
+ function mergeCss2(...styles) {
172
+ return mergeProps(...resolve(styles));
173
+ }
174
+ function assignCss2(...styles) {
175
+ return Object.assign({}, ...resolve(styles));
176
+ }
177
+ return { mergeCss: memo(mergeCss2), assignCss: assignCss2 };
178
+ }
179
+ var wordRegex = /([A-Z])/g;
180
+ var msRegex = /^ms-/;
181
+ var hypenateProperty = memo((property) => {
182
+ if (property.startsWith("--")) return property;
183
+ return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
184
+ });
185
+ var lengthUnits = "cm,mm,Q,in,pc,pt,px,em,ex,ch,rem,lh,rlh,vw,vh,vmin,vmax,vb,vi,svw,svh,lvw,lvh,dvw,dvh,cqw,cqh,cqi,cqb,cqmin,cqmax,%";
186
+ `(?:${lengthUnits.split(",").join("|")})`;
187
+ var getSlotRecipes = (recipe = {}) => {
188
+ const init = (slot) => ({
189
+ className: [recipe.className, slot].filter(Boolean).join("__"),
190
+ base: recipe.base?.[slot] ?? {},
191
+ variants: {},
192
+ defaultVariants: recipe.defaultVariants ?? {},
193
+ compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []
194
+ });
195
+ const slots = recipe.slots ?? [];
196
+ const recipeParts = slots.map((slot) => [slot, init(slot)]);
197
+ for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) {
198
+ for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) {
199
+ recipeParts.forEach(([slot, slotRecipe]) => {
200
+ slotRecipe.variants[variantsKey] ??= {};
201
+ slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};
202
+ });
203
+ }
204
+ }
205
+ return Object.fromEntries(recipeParts);
206
+ };
207
+ var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
208
+ function splitProps(props, ...keys) {
209
+ const descriptors = Object.getOwnPropertyDescriptors(props);
210
+ const dKeys = Object.keys(descriptors);
211
+ const split = (k) => {
212
+ const clone = {};
213
+ for (let i = 0; i < k.length; i++) {
214
+ const key = k[i];
215
+ if (descriptors[key]) {
216
+ Object.defineProperty(clone, key, descriptors[key]);
217
+ delete descriptors[key];
218
+ }
219
+ }
220
+ return clone;
221
+ };
222
+ const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));
223
+ return keys.map(fn).concat(split(dKeys));
224
+ }
225
+ var uniq = (...items) => {
226
+ const set = items.reduce((acc, currItems) => {
227
+ if (currItems) {
228
+ currItems.forEach((item) => acc.add(item));
229
+ }
230
+ return acc;
231
+ }, /* @__PURE__ */ new Set([]));
232
+ return Array.from(set);
233
+ };
234
+
235
+ // styled-system/css/conditions.mjs
236
+ var conditionsStr = "_hover,_focus,_focusWithin,_focusVisible,_disabled,_active,_visited,_target,_readOnly,_readWrite,_empty,_checked,_enabled,_expanded,_highlighted,_complete,_incomplete,_dragging,_before,_after,_firstLetter,_firstLine,_marker,_selection,_file,_backdrop,_first,_last,_only,_even,_odd,_firstOfType,_lastOfType,_onlyOfType,_peerFocus,_peerHover,_peerActive,_peerFocusWithin,_peerFocusVisible,_peerDisabled,_peerChecked,_peerInvalid,_peerExpanded,_peerPlaceholderShown,_groupFocus,_groupHover,_groupActive,_groupFocusWithin,_groupFocusVisible,_groupDisabled,_groupChecked,_groupExpanded,_groupInvalid,_indeterminate,_required,_valid,_invalid,_autofill,_inRange,_outOfRange,_placeholder,_placeholderShown,_pressed,_selected,_grabbed,_underValue,_overValue,_atValue,_default,_optional,_open,_closed,_fullscreen,_loading,_hidden,_current,_currentPage,_currentStep,_today,_unavailable,_rangeStart,_rangeEnd,_now,_topmost,_motionReduce,_motionSafe,_print,_landscape,_portrait,_dark,_light,_osDark,_osLight,_highContrast,_lessContrast,_moreContrast,_ltr,_rtl,_scrollbar,_scrollbarThumb,_scrollbarTrack,_horizontal,_vertical,_icon,_starting,_noscript,_invertedColors,sm,smOnly,smDown,md,mdOnly,mdDown,lg,lgOnly,lgDown,xl,xlOnly,xlDown,2xl,2xlOnly,2xlDown,smToMd,smToLg,smToXl,smTo2xl,mdToLg,mdToXl,mdTo2xl,lgToXl,lgTo2xl,xlTo2xl,@/xs,@/sm,@/md,@/lg,@/xl,@/2xl,@/3xl,@/4xl,@/5xl,@/6xl,@/7xl,@/8xl,base";
237
+ var conditions = new Set(conditionsStr.split(","));
238
+ var conditionRegex = /^@|&|&$/;
239
+ function isCondition(value) {
240
+ return conditions.has(value) || conditionRegex.test(value);
241
+ }
242
+ var underscoreRegex = /^_/;
243
+ var conditionsSelectorRegex = /&|@/;
244
+ function finalizeConditions(paths) {
245
+ return paths.map((path) => {
246
+ if (conditions.has(path)) {
247
+ return path.replace(underscoreRegex, "");
248
+ }
249
+ if (conditionsSelectorRegex.test(path)) {
250
+ return `[${withoutSpace(path.trim())}]`;
251
+ }
252
+ return path;
253
+ });
254
+ }
255
+ function sortConditions(paths) {
256
+ return paths.sort((a, b) => {
257
+ const aa = isCondition(a);
258
+ const bb = isCondition(b);
259
+ if (aa && !bb) return 1;
260
+ if (!aa && bb) return -1;
261
+ return 0;
262
+ });
263
+ }
264
+
265
+ // styled-system/css/css.mjs
266
+ var utilities = "aspectRatio:asp,boxDecorationBreak:bx-db,zIndex:z,boxSizing:bx-s,objectPosition:obj-p,objectFit:obj-f,overscrollBehavior:ovs-b,overscrollBehaviorX:ovs-bx,overscrollBehaviorY:ovs-by,position:pos/1,top:top,left:left,inset:inset,insetInline:inset-x/insetX,insetBlock:inset-y/insetY,insetBlockEnd:inset-be,insetBlockStart:inset-bs,insetInlineEnd:inset-e/insetEnd/end,insetInlineStart:inset-s/insetStart/start,right:right,bottom:bottom,float:float,visibility:vis,display:d,hideFrom:hide,hideBelow:show,flexBasis:flex-b,flex:flex,flexDirection:flex-d/flexDir,flexGrow:flex-g,flexShrink:flex-sh,gridTemplateColumns:grid-tc,gridTemplateRows:grid-tr,gridColumn:grid-c,gridRow:grid-r,gridColumnStart:grid-cs,gridColumnEnd:grid-ce,gridAutoFlow:grid-af,gridAutoColumns:grid-ac,gridAutoRows:grid-ar,gap:gap,gridGap:grid-g,gridRowGap:grid-rg,gridColumnGap:grid-cg,rowGap:rg,columnGap:cg,justifyContent:jc,alignContent:ac,alignItems:ai,alignSelf:as,padding:p/1,paddingLeft:pl/1,paddingRight:pr/1,paddingTop:pt/1,paddingBottom:pb/1,paddingBlock:py/1/paddingY,paddingBlockEnd:pbe,paddingBlockStart:pbs,paddingInline:px/paddingX/1,paddingInlineEnd:pe/1/paddingEnd,paddingInlineStart:ps/1/paddingStart,marginLeft:ml/1,marginRight:mr/1,marginTop:mt/1,marginBottom:mb/1,margin:m/1,marginBlock:my/1/marginY,marginBlockEnd:mbe,marginBlockStart:mbs,marginInline:mx/1/marginX,marginInlineEnd:me/1/marginEnd,marginInlineStart:ms/1/marginStart,spaceX:sx,spaceY:sy,outlineWidth:ring-w/ringWidth,outlineColor:ring-c/ringColor,outline:ring/1,outlineOffset:ring-o/ringOffset,focusRing:focus-ring,focusVisibleRing:focus-v-ring,focusRingColor:focus-ring-c,focusRingOffset:focus-ring-o,focusRingWidth:focus-ring-w,focusRingStyle:focus-ring-s,divideX:dvd-x,divideY:dvd-y,divideColor:dvd-c,divideStyle:dvd-s,width:w/1,inlineSize:w-is,minWidth:min-w/minW,minInlineSize:min-w-is,maxWidth:max-w/maxW,maxInlineSize:max-w-is,height:h/1,blockSize:h-bs,minHeight:min-h/minH,minBlockSize:min-h-bs,maxHeight:max-h/maxH,maxBlockSize:max-b,boxSize:size,color:c,fontFamily:ff,fontSize:fs,fontSizeAdjust:fs-a,fontPalette:fp,fontKerning:fk,fontFeatureSettings:ff-s,fontWeight:fw,fontSmoothing:fsmt,fontVariant:fv,fontVariantAlternates:fv-alt,fontVariantCaps:fv-caps,fontVariationSettings:fv-s,fontVariantNumeric:fv-num,letterSpacing:ls,lineHeight:lh,textAlign:ta,textDecoration:td,textDecorationColor:td-c,textEmphasisColor:te-c,textDecorationStyle:td-s,textDecorationThickness:td-t,textUnderlineOffset:tu-o,textTransform:tt,textIndent:ti,textShadow:tsh,textShadowColor:tsh-c/textShadowColor,WebkitTextFillColor:wktf-c,textOverflow:tov,verticalAlign:va,wordBreak:wb,textWrap:tw,truncate:trunc,lineClamp:lc,listStyleType:li-t,listStylePosition:li-pos,listStyleImage:li-img,listStyle:li-s,backgroundPosition:bg-p/bgPosition,backgroundPositionX:bg-p-x/bgPositionX,backgroundPositionY:bg-p-y/bgPositionY,backgroundAttachment:bg-a/bgAttachment,backgroundClip:bg-cp/bgClip,background:bg/1,backgroundColor:bg-c/bgColor,backgroundOrigin:bg-o/bgOrigin,backgroundImage:bg-i/bgImage,backgroundRepeat:bg-r/bgRepeat,backgroundBlendMode:bg-bm/bgBlendMode,backgroundSize:bg-s/bgSize,backgroundGradient:bg-grad/bgGradient,backgroundLinear:bg-linear/bgLinear,backgroundRadial:bg-radial/bgRadial,backgroundConic:bg-conic/bgConic,textGradient:txt-grad,gradientFromPosition:grad-from-pos,gradientToPosition:grad-to-pos,gradientFrom:grad-from,gradientTo:grad-to,gradientVia:grad-via,gradientViaPosition:grad-via-pos,borderRadius:bdr/rounded,borderTopLeftRadius:bdr-tl/roundedTopLeft,borderTopRightRadius:bdr-tr/roundedTopRight,borderBottomRightRadius:bdr-br/roundedBottomRight,borderBottomLeftRadius:bdr-bl/roundedBottomLeft,borderTopRadius:bdr-t/roundedTop,borderRightRadius:bdr-r/roundedRight,borderBottomRadius:bdr-b/roundedBottom,borderLeftRadius:bdr-l/roundedLeft,borderStartStartRadius:bdr-ss/roundedStartStart,borderStartEndRadius:bdr-se/roundedStartEnd,borderStartRadius:bdr-s/roundedStart,borderEndStartRadius:bdr-es/roundedEndStart,borderEndEndRadius:bdr-ee/roundedEndEnd,borderEndRadius:bdr-e/roundedEnd,border:bd,borderWidth:bd-w,borderTopWidth:bd-t-w,borderLeftWidth:bd-l-w,borderRightWidth:bd-r-w,borderBottomWidth:bd-b-w,borderBlockStartWidth:bd-bs-w,borderBlockEndWidth:bd-be-w,borderColor:bd-c,borderInline:bd-x/borderX,borderInlineWidth:bd-x-w/borderXWidth,borderInlineColor:bd-x-c/borderXColor,borderBlock:bd-y/borderY,borderBlockWidth:bd-y-w/borderYWidth,borderBlockColor:bd-y-c/borderYColor,borderLeft:bd-l,borderLeftColor:bd-l-c,borderInlineStart:bd-s/borderStart,borderInlineStartWidth:bd-s-w/borderStartWidth,borderInlineStartColor:bd-s-c/borderStartColor,borderRight:bd-r,borderRightColor:bd-r-c,borderInlineEnd:bd-e/borderEnd,borderInlineEndWidth:bd-e-w/borderEndWidth,borderInlineEndColor:bd-e-c/borderEndColor,borderTop:bd-t,borderTopColor:bd-t-c,borderBottom:bd-b,borderBottomColor:bd-b-c,borderBlockEnd:bd-be,borderBlockEndColor:bd-be-c,borderBlockStart:bd-bs,borderBlockStartColor:bd-bs-c,opacity:op,boxShadow:bx-sh/shadow,boxShadowColor:bx-sh-c/shadowColor,mixBlendMode:mix-bm,filter:filter,brightness:brightness,contrast:contrast,grayscale:grayscale,hueRotate:hue-rotate,invert:invert,saturate:saturate,sepia:sepia,dropShadow:drop-shadow,blur:blur,backdropFilter:bkdp,backdropBlur:bkdp-blur,backdropBrightness:bkdp-brightness,backdropContrast:bkdp-contrast,backdropGrayscale:bkdp-grayscale,backdropHueRotate:bkdp-hue-rotate,backdropInvert:bkdp-invert,backdropOpacity:bkdp-opacity,backdropSaturate:bkdp-saturate,backdropSepia:bkdp-sepia,borderCollapse:bd-cl,borderSpacing:bd-sp,borderSpacingX:bd-sx,borderSpacingY:bd-sy,tableLayout:tbl,transitionTimingFunction:trs-tmf,transitionDelay:trs-dly,transitionDuration:trs-dur,transitionProperty:trs-prop,transition:trs,animation:anim,animationName:anim-n,animationTimingFunction:anim-tmf,animationDuration:anim-dur,animationDelay:anim-dly,animationPlayState:anim-ps,animationComposition:anim-comp,animationFillMode:anim-fm,animationDirection:anim-dir,animationIterationCount:anim-ic,animationRange:anim-r,animationState:anim-s,animationRangeStart:anim-rs,animationRangeEnd:anim-re,animationTimeline:anim-tl,transformOrigin:trf-o,transformBox:trf-b,transformStyle:trf-s,transform:trf,rotate:rotate,rotateX:rotate-x,rotateY:rotate-y,rotateZ:rotate-z,scale:scale,scaleX:scale-x,scaleY:scale-y,translate:translate,translateX:translate-x/x,translateY:translate-y/y,translateZ:translate-z/z,accentColor:ac-c,caretColor:ca-c,scrollBehavior:scr-bhv,scrollbar:scr-bar,scrollbarColor:scr-bar-c,scrollbarGutter:scr-bar-g,scrollbarWidth:scr-bar-w,scrollMargin:scr-m,scrollMarginLeft:scr-ml,scrollMarginRight:scr-mr,scrollMarginTop:scr-mt,scrollMarginBottom:scr-mb,scrollMarginBlock:scr-my/scrollMarginY,scrollMarginBlockEnd:scr-mbe,scrollMarginBlockStart:scr-mbt,scrollMarginInline:scr-mx/scrollMarginX,scrollMarginInlineEnd:scr-me,scrollMarginInlineStart:scr-ms,scrollPadding:scr-p,scrollPaddingBlock:scr-py/scrollPaddingY,scrollPaddingBlockStart:scr-pbs,scrollPaddingBlockEnd:scr-pbe,scrollPaddingInline:scr-px/scrollPaddingX,scrollPaddingInlineEnd:scr-pe,scrollPaddingInlineStart:scr-ps,scrollPaddingLeft:scr-pl,scrollPaddingRight:scr-pr,scrollPaddingTop:scr-pt,scrollPaddingBottom:scr-pb,scrollSnapAlign:scr-sa,scrollSnapStop:scrs-s,scrollSnapType:scrs-t,scrollSnapStrictness:scrs-strt,scrollSnapMargin:scrs-m,scrollSnapMarginTop:scrs-mt,scrollSnapMarginBottom:scrs-mb,scrollSnapMarginLeft:scrs-ml,scrollSnapMarginRight:scrs-mr,scrollSnapCoordinate:scrs-c,scrollSnapDestination:scrs-d,scrollSnapPointsX:scrs-px,scrollSnapPointsY:scrs-py,scrollSnapTypeX:scrs-tx,scrollSnapTypeY:scrs-ty,scrollTimeline:scrtl,scrollTimelineAxis:scrtl-a,scrollTimelineName:scrtl-n,touchAction:tch-a,userSelect:us,overflow:ov,overflowWrap:ov-wrap,overflowX:ov-x,overflowY:ov-y,overflowAnchor:ov-a,overflowBlock:ov-b,overflowInline:ov-i,overflowClipBox:ovcp-bx,overflowClipMargin:ovcp-m,overscrollBehaviorBlock:ovs-bb,overscrollBehaviorInline:ovs-bi,fill:fill,stroke:stk,strokeWidth:stk-w,strokeDasharray:stk-dsh,strokeDashoffset:stk-do,strokeLinecap:stk-lc,strokeLinejoin:stk-lj,strokeMiterlimit:stk-ml,strokeOpacity:stk-op,srOnly:sr,debug:debug,appearance:ap,backfaceVisibility:bfv,clipPath:cp-path,hyphens:hy,mask:msk,maskImage:msk-i,maskSize:msk-s,textSizeAdjust:txt-adj,container:cq,containerName:cq-n,containerType:cq-t,cursor:cursor,textStyle:textStyle";
267
+ var classNameByProp = /* @__PURE__ */ new Map();
268
+ var shorthands = /* @__PURE__ */ new Map();
269
+ utilities.split(",").forEach((utility) => {
270
+ const [prop, meta] = utility.split(":");
271
+ const [className, ...shorthandList] = meta.split("/");
272
+ classNameByProp.set(prop, className);
273
+ if (shorthandList.length) {
274
+ shorthandList.forEach((shorthand) => {
275
+ shorthands.set(shorthand === "1" ? className : shorthand, prop);
276
+ });
277
+ }
278
+ });
279
+ var resolveShorthand = (prop) => shorthands.get(prop) || prop;
280
+ var context = {
281
+ conditions: {
282
+ shift: sortConditions,
283
+ finalize: finalizeConditions,
284
+ breakpoints: { keys: ["base", "sm", "md", "lg", "xl", "2xl"] }
285
+ },
286
+ utility: {
287
+ transform: (prop, value) => {
288
+ const key = resolveShorthand(prop);
289
+ const propKey = classNameByProp.get(key) || hypenateProperty(key);
290
+ return { className: `${propKey}_${withoutSpace(value)}` };
291
+ },
292
+ hasShorthand: true,
293
+ toHash: (path, hashFn) => hashFn(path.join(":")),
294
+ resolveShorthand
295
+ }
296
+ };
297
+ var cssFn = createCss(context);
298
+ var css = (...styles) => cssFn(mergeCss(...styles));
299
+ css.raw = (...styles) => mergeCss(...styles);
300
+ var { mergeCss} = createMergeCss(context);
301
+
302
+ // styled-system/css/cx.mjs
303
+ function cx() {
304
+ let str = "", i = 0, arg;
305
+ for (; i < arguments.length; ) {
306
+ if ((arg = arguments[i++]) && typeof arg === "string") {
307
+ str && (str += " ");
308
+ str += arg;
309
+ }
310
+ }
311
+ return str;
312
+ }
313
+
314
+ // styled-system/css/cva.mjs
315
+ var defaults = (conf) => ({
316
+ base: {},
317
+ variants: {},
318
+ defaultVariants: {},
319
+ compoundVariants: [],
320
+ ...conf
321
+ });
322
+ function cva(config) {
323
+ const { base, variants, defaultVariants, compoundVariants } = defaults(config);
324
+ const getVariantProps = (variants2) => ({ ...defaultVariants, ...compact(variants2) });
325
+ function resolve(props = {}) {
326
+ const computedVariants = getVariantProps(props);
327
+ let variantCss = { ...base };
328
+ for (const [key, value] of Object.entries(computedVariants)) {
329
+ if (variants[key]?.[value]) {
330
+ variantCss = mergeCss(variantCss, variants[key][value]);
331
+ }
332
+ }
333
+ const compoundVariantCss = getCompoundVariantCss(compoundVariants, computedVariants);
334
+ return mergeCss(variantCss, compoundVariantCss);
335
+ }
336
+ function merge(__cva) {
337
+ const override = defaults(__cva.config);
338
+ const variantKeys2 = uniq(__cva.variantKeys, Object.keys(variants));
339
+ return cva({
340
+ base: mergeCss(base, override.base),
341
+ variants: Object.fromEntries(
342
+ variantKeys2.map((key) => [key, mergeCss(variants[key], override.variants[key])])
343
+ ),
344
+ defaultVariants: mergeProps(defaultVariants, override.defaultVariants),
345
+ compoundVariants: [...compoundVariants, ...override.compoundVariants]
346
+ });
347
+ }
348
+ function cvaFn(props) {
349
+ return css(resolve(props));
350
+ }
351
+ const variantKeys = Object.keys(variants);
352
+ function splitVariantProps(props) {
353
+ return splitProps(props, variantKeys);
354
+ }
355
+ const variantMap = Object.fromEntries(Object.entries(variants).map(([key, value]) => [key, Object.keys(value)]));
356
+ return Object.assign(memo(cvaFn), {
357
+ __cva__: true,
358
+ variantMap,
359
+ variantKeys,
360
+ raw: resolve,
361
+ config,
362
+ merge,
363
+ splitVariantProps,
364
+ getVariantProps
365
+ });
366
+ }
367
+ function getCompoundVariantCss(compoundVariants, variantMap) {
368
+ let result = {};
369
+ compoundVariants.forEach((compoundVariant) => {
370
+ const isMatching = Object.entries(compoundVariant).every(([key, value]) => {
371
+ if (key === "css") return true;
372
+ const values = Array.isArray(value) ? value : [value];
373
+ return values.some((value2) => variantMap[key] === value2);
374
+ });
375
+ if (isMatching) {
376
+ result = mergeCss(result, compoundVariant.css);
377
+ }
378
+ });
379
+ return result;
380
+ }
381
+
382
+ // styled-system/css/sva.mjs
383
+ function sva(config) {
384
+ const slots = Object.entries(getSlotRecipes(config)).map(([slot, slotCva]) => [slot, cva(slotCva)]);
385
+ const defaultVariants = config.defaultVariants ?? {};
386
+ const classNameMap = slots.reduce((acc, [slot, cvaFn]) => {
387
+ if (config.className) acc[slot] = cvaFn.config.className;
388
+ return acc;
389
+ }, {});
390
+ function svaFn(props) {
391
+ const result = slots.map(([slot, cvaFn]) => [slot, cx(cvaFn(props), classNameMap[slot])]);
392
+ return Object.fromEntries(result);
393
+ }
394
+ function raw(props) {
395
+ const result = slots.map(([slot, cvaFn]) => [slot, cvaFn.raw(props)]);
396
+ return Object.fromEntries(result);
397
+ }
398
+ const variants = config.variants ?? {};
399
+ const variantKeys = Object.keys(variants);
400
+ function splitVariantProps(props) {
401
+ return splitProps(props, variantKeys);
402
+ }
403
+ const getVariantProps = (variants2) => ({ ...defaultVariants, ...compact(variants2) });
404
+ const variantMap = Object.fromEntries(
405
+ Object.entries(variants).map(([key, value]) => [key, Object.keys(value)])
406
+ );
407
+ return Object.assign(memo(svaFn), {
408
+ __cva__: false,
409
+ raw,
410
+ config,
411
+ variantMap,
412
+ variantKeys,
413
+ classNameMap,
414
+ splitVariantProps,
415
+ getVariantProps
416
+ });
417
+ }
418
+
419
+ // src/entities/editor-core/model/theme-contract.ts
420
+ var CHAEDITOR_THEME_VARIABLES = {
421
+ overlayBackdrop: "--chaeditor-color-overlay-backdrop",
422
+ primaryHover: "--chaeditor-color-primary-hover"};
423
+ var CHAEDITOR_THEME_DEFAULTS = {
424
+ light: {
425
+ overlayBackdrop: "rgb(15 23 42 / 0.86)"}
426
+ };
427
+
428
+ // src/shared/ui/styles/primitive-theme.ts
429
+ var focusVisibleRingStyles = {
430
+ outlineColor: "focusRing",
431
+ outlineOffset: "[2px]",
432
+ outlineStyle: "solid",
433
+ outlineWidth: "[2px]"
434
+ };
435
+ var disabledFieldStyles = {
436
+ cursor: "not-allowed",
437
+ opacity: 0.56
438
+ };
439
+ var disabledButtonStyles = {
440
+ cursor: "not-allowed",
441
+ opacity: 0.48,
442
+ pointerEvents: "none"
443
+ };
444
+ var primaryHoverBackground = `[var(${CHAEDITOR_THEME_VARIABLES.primaryHover},var(--colors-primary))]`;
445
+ var overlayBackdropColor = `[var(${CHAEDITOR_THEME_VARIABLES.overlayBackdrop},${CHAEDITOR_THEME_DEFAULTS.light.overlayBackdrop})]`;
446
+ var overlayBackdropStyleValue = `var(${CHAEDITOR_THEME_VARIABLES.overlayBackdrop},${CHAEDITOR_THEME_DEFAULTS.light.overlayBackdrop})`;
447
+ var buttonRecipe = sva({
448
+ slots: ["root", "label", "visual"],
449
+ base: {
450
+ root: {
451
+ appearance: "none",
452
+ display: "inline-flex",
453
+ alignItems: "center",
454
+ justifyContent: "center",
455
+ gap: "2",
456
+ userSelect: "none",
457
+ cursor: "pointer",
458
+ transition: "colors",
459
+ letterSpacing: "[-0.01em]",
460
+ _focusVisible: {
461
+ ...focusVisibleRingStyles
462
+ },
463
+ _disabled: disabledButtonStyles,
464
+ '&[aria-disabled="true"]': {
465
+ ...disabledButtonStyles
466
+ }
467
+ },
468
+ label: {
469
+ display: "inline-flex",
470
+ alignItems: "center",
471
+ minWidth: "0"
472
+ },
473
+ visual: {
474
+ display: "inline-flex",
475
+ alignItems: "center",
476
+ justifyContent: "center",
477
+ flex: "none"
478
+ }
479
+ },
480
+ variants: {
481
+ fullWidth: {
482
+ true: { root: { width: "full" } },
483
+ false: { root: { width: "auto" } }
484
+ },
485
+ size: {
486
+ xs: { root: { fontSize: "xs" } },
487
+ sm: { root: { fontSize: "sm" } },
488
+ md: { root: { fontSize: "sm" } }
489
+ },
490
+ variant: {
491
+ solid: {
492
+ root: {
493
+ borderStyle: "solid",
494
+ borderWidth: "1px",
495
+ borderRadius: "full"
496
+ }
497
+ },
498
+ ghost: {
499
+ root: {
500
+ borderStyle: "solid",
501
+ borderWidth: "1px",
502
+ borderRadius: "full",
503
+ background: "transparent"
504
+ }
505
+ },
506
+ underline: {
507
+ root: {
508
+ minHeight: "auto",
509
+ p: "0",
510
+ textDecoration: "underline",
511
+ textUnderlineOffset: "[0.18em]"
512
+ }
513
+ }
514
+ },
515
+ tone: {
516
+ white: {},
517
+ primary: {},
518
+ black: {}
519
+ }
520
+ },
521
+ compoundVariants: [
522
+ /* Layout rules for the solid and ghost variants. */
523
+ {
524
+ variant: ["solid", "ghost"],
525
+ size: "xs",
526
+ css: { root: { minHeight: "8", px: "2" } }
527
+ },
528
+ {
529
+ variant: ["solid", "ghost"],
530
+ size: "sm",
531
+ css: { root: { minHeight: "[2.375rem]", px: "3" } }
532
+ },
533
+ {
534
+ variant: ["solid", "ghost"],
535
+ size: "md",
536
+ css: { root: { minHeight: "[2.75rem]", px: "4" } }
537
+ },
538
+ /* Colors for the solid variant. */
539
+ {
540
+ tone: "white",
541
+ variant: "solid",
542
+ css: {
543
+ root: {
544
+ background: "surface",
545
+ borderColor: "border",
546
+ color: "text",
547
+ _hover: { borderColor: "borderStrong" }
548
+ }
549
+ }
550
+ },
551
+ {
552
+ tone: "primary",
553
+ variant: "solid",
554
+ css: {
555
+ root: {
556
+ background: "primary",
557
+ color: "primaryContrast",
558
+ borderColor: "transparent",
559
+ _hover: { background: primaryHoverBackground }
560
+ }
561
+ }
562
+ },
563
+ {
564
+ tone: "black",
565
+ variant: "solid",
566
+ css: {
567
+ root: {
568
+ background: "text",
569
+ color: "surface",
570
+ borderColor: "transparent"
571
+ }
572
+ }
573
+ },
574
+ /* Colors for the ghost and underline variants. */
575
+ {
576
+ tone: "white",
577
+ variant: ["ghost", "underline"],
578
+ css: { root: { color: "text", borderColor: "transparent" } }
579
+ },
580
+ {
581
+ tone: "primary",
582
+ variant: ["ghost", "underline"],
583
+ css: { root: { color: "primary", borderColor: "transparent" } }
584
+ },
585
+ {
586
+ tone: "black",
587
+ variant: ["ghost", "underline"],
588
+ css: { root: { color: "text", borderColor: "transparent" } }
589
+ }
590
+ ],
591
+ defaultVariants: {
592
+ fullWidth: false,
593
+ size: "md",
594
+ tone: "white",
595
+ variant: "solid"
596
+ }
597
+ });
598
+ var Button = forwardRef(
599
+ ({
600
+ asChild = false,
601
+ children,
602
+ className,
603
+ fullWidth,
604
+ labelClassName,
605
+ leadingVisual,
606
+ leadingVisualClassName,
607
+ size,
608
+ tone,
609
+ trailingVisual,
610
+ trailingVisualClassName,
611
+ type = "button",
612
+ variant,
613
+ ...props
614
+ }, ref) => {
615
+ const styles = buttonRecipe({ fullWidth, size, tone, variant });
616
+ const isDisabled = props.disabled || props["aria-disabled"] === "true";
617
+ const renderContent = (labelContent) => /* @__PURE__ */ jsxs(Fragment, { children: [
618
+ leadingVisual && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cx(styles.visual, leadingVisualClassName), children: leadingVisual }),
619
+ /* @__PURE__ */ jsx("span", { className: cx(styles.label, labelClassName), children: labelContent }),
620
+ trailingVisual && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cx(styles.visual, trailingVisualClassName), children: trailingVisual })
621
+ ] });
622
+ if (asChild) {
623
+ if (!React.isValidElement(children)) {
624
+ throw new Error("Button with asChild requires a single React element child.");
625
+ }
626
+ const child = children;
627
+ const isNativeButtonElement = typeof child.type === "string" && child.type === "button";
628
+ const nextProps = {
629
+ ...props,
630
+ className: cx(styles.root, className, child.props.className),
631
+ children: renderContent(child.props.children)
632
+ };
633
+ if (isNativeButtonElement) {
634
+ nextProps.type = type;
635
+ }
636
+ if (isDisabled && !isNativeButtonElement) {
637
+ delete nextProps.disabled;
638
+ nextProps["aria-disabled"] = "true";
639
+ nextProps.tabIndex = -1;
640
+ nextProps.onClick = (event) => {
641
+ event.preventDefault();
642
+ event.stopPropagation();
643
+ };
644
+ }
645
+ return React.cloneElement(child, nextProps);
646
+ }
647
+ return /* @__PURE__ */ jsx(
648
+ "button",
649
+ {
650
+ ...props,
651
+ ref,
652
+ className: cx(styles.root, className),
653
+ type,
654
+ disabled: props.disabled,
655
+ children: renderContent(children)
656
+ }
657
+ );
658
+ }
659
+ );
660
+ Button.displayName = "Button";
661
+ var Input = React.forwardRef(
662
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("input", { ...props, className: cx(inputRecipe(), className), ref })
663
+ );
664
+ Input.displayName = "Input";
665
+ var inputRecipe = cva({
666
+ base: {
667
+ width: "full",
668
+ minHeight: "[2.75rem]",
669
+ px: "3",
670
+ py: "2",
671
+ borderRadius: "md",
672
+ borderWidth: "1px",
673
+ borderStyle: "solid",
674
+ borderColor: "border",
675
+ backgroundColor: "transparent",
676
+ color: "text",
677
+ transition: "colors",
678
+ _placeholder: {
679
+ color: "muted"
680
+ },
681
+ _hover: {
682
+ borderColor: "borderStrong"
683
+ },
684
+ _focusVisible: {
685
+ ...focusVisibleRingStyles,
686
+ borderColor: "primary"
687
+ },
688
+ _disabled: disabledFieldStyles
689
+ }
690
+ });
691
+
692
+ // src/shared/lib/a11y/get-focusable-elements.ts
693
+ var FOCUSABLE_SELECTOR = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
694
+ var getFocusableElements = (container) => Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR)).filter(
695
+ (element) => !element.hasAttribute("hidden") && element.getAttribute("aria-hidden") !== "true"
696
+ );
697
+
698
+ // src/shared/lib/react/use-dialog-focus-management.ts
699
+ var useDialogFocusManagement = ({
700
+ containerRef,
701
+ initialFocusRef,
702
+ isEnabled,
703
+ onEscape,
704
+ restoreFocusRef
705
+ }) => {
706
+ const previousActiveElementRef = useRef(null);
707
+ const onEscapeRef = useRef(onEscape);
708
+ useEffect(() => {
709
+ onEscapeRef.current = onEscape;
710
+ }, [onEscape]);
711
+ useEffect(() => {
712
+ if (!isEnabled) return;
713
+ previousActiveElementRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
714
+ const requestFocus = () => {
715
+ const container = containerRef.current;
716
+ if (!container) return;
717
+ const fallbackTarget = initialFocusRef?.current ?? getFocusableElements(container)[0] ?? container;
718
+ fallbackTarget.focus();
719
+ };
720
+ const rafId = window.requestAnimationFrame(requestFocus);
721
+ const handleKeydown = (event) => {
722
+ if (event.key === "Escape") {
723
+ event.preventDefault();
724
+ event.stopPropagation();
725
+ onEscapeRef.current();
726
+ return;
727
+ }
728
+ if (event.key !== "Tab") return;
729
+ const container = containerRef.current;
730
+ if (!container) return;
731
+ const focusableElements = getFocusableElements(container);
732
+ if (focusableElements.length === 0) {
733
+ event.preventDefault();
734
+ container.focus();
735
+ return;
736
+ }
737
+ const activeElement = document.activeElement;
738
+ const activeIndex = activeElement ? focusableElements.indexOf(activeElement) : -1;
739
+ if (event.shiftKey && (activeIndex <= 0 || activeIndex === -1)) {
740
+ event.preventDefault();
741
+ focusableElements[focusableElements.length - 1]?.focus();
742
+ return;
743
+ }
744
+ if (!event.shiftKey && (activeIndex === -1 || activeIndex === focusableElements.length - 1)) {
745
+ event.preventDefault();
746
+ focusableElements[0]?.focus();
747
+ }
748
+ };
749
+ window.addEventListener("keydown", handleKeydown);
750
+ return () => {
751
+ window.cancelAnimationFrame(rafId);
752
+ window.removeEventListener("keydown", handleKeydown);
753
+ if (restoreFocusRef?.current !== false) {
754
+ previousActiveElementRef.current?.focus();
755
+ }
756
+ if (restoreFocusRef) {
757
+ restoreFocusRef.current = true;
758
+ }
759
+ };
760
+ }, [containerRef, initialFocusRef, isEnabled, restoreFocusRef]);
761
+ };
762
+ var XButton = React.forwardRef(
763
+ ({
764
+ ariaLabel,
765
+ className,
766
+ glyphClassName,
767
+ size = "sm",
768
+ tone = "black",
769
+ type = "button",
770
+ variant = "ghost",
771
+ ...props
772
+ }, ref) => /* @__PURE__ */ jsx(
773
+ Button,
774
+ {
775
+ "aria-label": ariaLabel,
776
+ className,
777
+ ref,
778
+ size,
779
+ tone,
780
+ type,
781
+ variant,
782
+ ...props,
783
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cx(glyphClass, glyphClassName), children: "+" })
784
+ }
785
+ )
786
+ );
787
+ XButton.displayName = "XButton";
788
+ var glyphClass = css({
789
+ display: "inline-block",
790
+ fontSize: "3xl",
791
+ lineHeight: "none",
792
+ transform: "rotate(45deg)"
793
+ });
794
+ var Modal = ({
795
+ ariaDescribedBy,
796
+ ariaLabel,
797
+ ariaLabelledBy,
798
+ backdropClassName,
799
+ children,
800
+ closeAriaLabel,
801
+ closeButtonClassName,
802
+ frameClassName,
803
+ initialFocusRef,
804
+ isOpen,
805
+ onClose
806
+ }) => {
807
+ const [isMounted, setIsMounted] = useState(false);
808
+ const frameRef = useRef(null);
809
+ useEffect(() => {
810
+ setIsMounted(true);
811
+ }, []);
812
+ useEffect(() => {
813
+ if (!isOpen || !isMounted) return;
814
+ const bodyOverflow = document.body.style.overflow;
815
+ document.body.style.overflow = "hidden";
816
+ return () => {
817
+ document.body.style.overflow = bodyOverflow;
818
+ };
819
+ }, [isMounted, isOpen]);
820
+ useDialogFocusManagement({
821
+ containerRef: frameRef,
822
+ initialFocusRef,
823
+ isEnabled: isOpen && isMounted,
824
+ onEscape: onClose
825
+ });
826
+ if (!isMounted || !isOpen) return null;
827
+ return createPortal(
828
+ /* @__PURE__ */ jsx(
829
+ "div",
830
+ {
831
+ onClick: (event) => {
832
+ if (event.target === event.currentTarget) onClose();
833
+ },
834
+ className: cx(backdropClass, backdropClassName),
835
+ style: { background: overlayBackdropStyleValue },
836
+ children: /* @__PURE__ */ jsxs(
837
+ "div",
838
+ {
839
+ "aria-describedby": ariaDescribedBy,
840
+ "aria-label": ariaLabel,
841
+ "aria-labelledby": ariaLabelledBy,
842
+ "aria-modal": "true",
843
+ ref: frameRef,
844
+ role: "dialog",
845
+ tabIndex: -1,
846
+ className: cx(frameBaseClass, frameClassName),
847
+ children: [
848
+ /* @__PURE__ */ jsx(
849
+ XButton,
850
+ {
851
+ ariaLabel: closeAriaLabel,
852
+ className: cx(closeButtonClass, closeButtonClassName),
853
+ onClick: onClose
854
+ }
855
+ ),
856
+ children
857
+ ]
858
+ }
859
+ )
860
+ }
861
+ ),
862
+ document.body
863
+ );
864
+ };
865
+ var backdropClass = css({
866
+ position: "fixed",
867
+ inset: "0",
868
+ zIndex: "1200",
869
+ backgroundColor: overlayBackdropColor,
870
+ p: "4",
871
+ display: "grid",
872
+ placeItems: "center",
873
+ overflow: "hidden"
874
+ });
875
+ var frameBaseClass = css({
876
+ position: "relative",
877
+ borderRadius: "3xl",
878
+ maxWidth: "full",
879
+ display: "flex",
880
+ flexDirection: "column",
881
+ maxHeight: "full",
882
+ minWidth: "0",
883
+ minHeight: "0",
884
+ overflow: "hidden"
885
+ });
886
+ var closeButtonClass = css({
887
+ position: "absolute",
888
+ top: "[0.6rem]",
889
+ right: "[0.5rem]",
890
+ zIndex: "10",
891
+ lineHeight: "none"
892
+ });
893
+
894
+ // src/shared/ui/styles/sr-only-style.ts
895
+ var srOnlyClass = css({
896
+ srOnly: true
897
+ });
898
+ var Tooltip = ({
899
+ children,
900
+ className,
901
+ content,
902
+ contentClassName,
903
+ forceOpen = false,
904
+ openOnFocus = true,
905
+ portalClassName,
906
+ preferredPlacement = "top"
907
+ }) => {
908
+ const [isFocused, setIsFocused] = useState(false);
909
+ const [isHovering, setIsHovering] = useState(false);
910
+ const [tooltipStyle, setTooltipStyle] = useState();
911
+ const rootRef = useRef(null);
912
+ const tooltipId = useId();
913
+ const isOpen = forceOpen || isHovering || openOnFocus && isFocused;
914
+ if (!isValidElement(children)) {
915
+ throw new Error("Tooltip requires a single React element child.");
916
+ }
917
+ const triggerElement = children;
918
+ const childProps = triggerElement.props;
919
+ const describedBy = [childProps["aria-describedby"], isOpen ? tooltipId : null].filter(Boolean).join(" ");
920
+ useLayoutEffect(() => {
921
+ if (!isOpen) {
922
+ setTooltipStyle(void 0);
923
+ return;
924
+ }
925
+ const updateTooltipPosition = () => {
926
+ if (!rootRef.current) return;
927
+ const triggerRect = rootRef.current.getBoundingClientRect();
928
+ const availableSpaceAbove = triggerRect.top;
929
+ const availableSpaceBelow = window.innerHeight - triggerRect.bottom;
930
+ const shouldPlaceBelow = preferredPlacement === "bottom" ? true : preferredPlacement === "top" ? false : availableSpaceAbove < 40 && availableSpaceBelow >= availableSpaceAbove;
931
+ setTooltipStyle({
932
+ left: triggerRect.left + triggerRect.width / 2,
933
+ position: "fixed",
934
+ top: shouldPlaceBelow ? triggerRect.bottom + 8 : triggerRect.top - 8,
935
+ transform: shouldPlaceBelow ? "translate(-50%, 0)" : "translate(-50%, -100%)"
936
+ });
937
+ };
938
+ updateTooltipPosition();
939
+ window.addEventListener("resize", updateTooltipPosition);
940
+ window.addEventListener("scroll", updateTooltipPosition, true);
941
+ return () => {
942
+ window.removeEventListener("resize", updateTooltipPosition);
943
+ window.removeEventListener("scroll", updateTooltipPosition, true);
944
+ };
945
+ }, [isOpen, preferredPlacement]);
946
+ return /* @__PURE__ */ jsxs(
947
+ "span",
948
+ {
949
+ className: cx(rootClass, className),
950
+ ref: rootRef,
951
+ onBlurCapture: () => {
952
+ if (!openOnFocus) return;
953
+ setIsFocused(false);
954
+ },
955
+ onFocusCapture: () => {
956
+ if (!openOnFocus) return;
957
+ setIsFocused(true);
958
+ },
959
+ onMouseEnter: () => setIsHovering(true),
960
+ onMouseLeave: () => setIsHovering(false),
961
+ children: [
962
+ cloneElement(triggerElement, {
963
+ "aria-describedby": describedBy || void 0
964
+ }),
965
+ isOpen ? createPortal(
966
+ /* @__PURE__ */ jsx(
967
+ "span",
968
+ {
969
+ className: cx(tooltipPortalClass, portalClassName),
970
+ id: tooltipId,
971
+ role: "tooltip",
972
+ style: {
973
+ ...tooltipStyle,
974
+ visibility: tooltipStyle ? "visible" : "hidden"
975
+ },
976
+ children: /* @__PURE__ */ jsx("span", { className: cx(tooltipClass, contentClassName), children: content })
977
+ }
978
+ ),
979
+ document.body
980
+ ) : null
981
+ ]
982
+ }
983
+ );
984
+ };
985
+ var rootClass = css({
986
+ display: "inline-flex",
987
+ flex: "none"
988
+ });
989
+ var tooltipClass = css({
990
+ px: "2",
991
+ py: "1",
992
+ borderRadius: "md",
993
+ backgroundColor: "[rgba(15,23,42,0.92)]",
994
+ color: "white",
995
+ borderWidth: "1px",
996
+ borderStyle: "solid",
997
+ borderColor: "[rgba(255,255,255,0.08)]",
998
+ fontSize: "xs",
999
+ lineHeight: "tight",
1000
+ whiteSpace: "nowrap",
1001
+ boxShadow: "[0_12px_28px_rgba(15,23,42,0.28)]"
1002
+ });
1003
+ var tooltipPortalClass = css({
1004
+ zIndex: "[9999]",
1005
+ pointerEvents: "none"
1006
+ });
1007
+ var Popover = ({
1008
+ children,
1009
+ isOpen: controlledIsOpen,
1010
+ label,
1011
+ onOpenChange,
1012
+ onTriggerMouseDown,
1013
+ panelClassName,
1014
+ panelLabel,
1015
+ portalPlacement = "end",
1016
+ renderInPortal = false,
1017
+ rootClassName,
1018
+ triggerAriaLabel,
1019
+ triggerClassName,
1020
+ triggerContent,
1021
+ triggerLabelClassName,
1022
+ triggerSize = "sm",
1023
+ triggerTone = "white",
1024
+ triggerTooltip,
1025
+ triggerValueClassName,
1026
+ triggerVariant = "ghost",
1027
+ value
1028
+ }) => {
1029
+ const [uncontrolledIsOpen, setUncontrolledIsOpen] = useState(false);
1030
+ const isControlled = typeof controlledIsOpen === "boolean";
1031
+ const isOpen = isControlled ? controlledIsOpen : uncontrolledIsOpen;
1032
+ const rootRef = useRef(null);
1033
+ const triggerRef = useRef(null);
1034
+ const panelRef = useRef(null);
1035
+ const restoreFocusRef = useRef(true);
1036
+ const [portalStyle, setPortalStyle] = useState();
1037
+ const panelId = useId();
1038
+ const panelLabelId = useId();
1039
+ const triggerLabelId = useId();
1040
+ const valueId = useId();
1041
+ const resolvedTriggerLabel = triggerAriaLabel ?? panelLabel;
1042
+ const usesSharedLabel = resolvedTriggerLabel === panelLabel;
1043
+ const setOpen = useCallback(
1044
+ (nextOpen) => {
1045
+ if (!isControlled) {
1046
+ setUncontrolledIsOpen(nextOpen);
1047
+ }
1048
+ onOpenChange?.(nextOpen);
1049
+ },
1050
+ [isControlled, onOpenChange]
1051
+ );
1052
+ useEffect(() => {
1053
+ if (!isOpen) return;
1054
+ const handleOutsideInteraction = (event) => {
1055
+ const eventTarget = event.target;
1056
+ if (!rootRef.current?.contains(eventTarget) && !panelRef.current?.contains(eventTarget)) {
1057
+ setOpen(false);
1058
+ }
1059
+ };
1060
+ window.addEventListener("click", handleOutsideInteraction);
1061
+ window.addEventListener("pointerdown", handleOutsideInteraction);
1062
+ return () => {
1063
+ window.removeEventListener("click", handleOutsideInteraction);
1064
+ window.removeEventListener("pointerdown", handleOutsideInteraction);
1065
+ };
1066
+ }, [isOpen, setOpen]);
1067
+ useLayoutEffect(() => {
1068
+ if (!isOpen || !renderInPortal) return;
1069
+ const updatePortalPosition = () => {
1070
+ if (!triggerRef.current) return;
1071
+ const triggerRect = triggerRef.current.getBoundingClientRect();
1072
+ const baseTop = triggerRect.bottom + 9;
1073
+ if (portalPlacement === "start") {
1074
+ setPortalStyle({
1075
+ left: triggerRect.left,
1076
+ position: "fixed",
1077
+ top: baseTop
1078
+ });
1079
+ return;
1080
+ }
1081
+ setPortalStyle({
1082
+ position: "fixed",
1083
+ right: Math.max(window.innerWidth - triggerRect.right, 0),
1084
+ top: baseTop
1085
+ });
1086
+ };
1087
+ updatePortalPosition();
1088
+ window.addEventListener("resize", updatePortalPosition);
1089
+ window.addEventListener("scroll", updatePortalPosition, true);
1090
+ return () => {
1091
+ window.removeEventListener("resize", updatePortalPosition);
1092
+ window.removeEventListener("scroll", updatePortalPosition, true);
1093
+ };
1094
+ }, [isOpen, portalPlacement, renderInPortal]);
1095
+ useDialogFocusManagement({
1096
+ containerRef: panelRef,
1097
+ initialFocusRef: void 0,
1098
+ isEnabled: isOpen,
1099
+ onEscape: () => {
1100
+ setOpen(false);
1101
+ },
1102
+ restoreFocusRef
1103
+ });
1104
+ const closePopover = (options) => {
1105
+ restoreFocusRef.current = options?.restoreFocus ?? true;
1106
+ setOpen(false);
1107
+ };
1108
+ const triggerButton = /* @__PURE__ */ jsx(
1109
+ Button,
1110
+ {
1111
+ "aria-controls": isOpen ? panelId : void 0,
1112
+ "aria-describedby": !triggerContent && value ? valueId : void 0,
1113
+ "aria-expanded": isOpen,
1114
+ "aria-haspopup": "dialog",
1115
+ "aria-labelledby": usesSharedLabel ? panelLabelId : triggerLabelId,
1116
+ className: cx(triggerButtonClass, triggerClassName),
1117
+ onClick: () => setOpen(!isOpen),
1118
+ onMouseDown: onTriggerMouseDown,
1119
+ ref: triggerRef,
1120
+ size: triggerSize,
1121
+ tone: triggerTone,
1122
+ type: "button",
1123
+ variant: triggerVariant,
1124
+ children: triggerContent ? triggerContent : /* @__PURE__ */ jsxs(Fragment, { children: [
1125
+ /* @__PURE__ */ jsx("span", { className: cx(triggerLabelClass, triggerLabelClassName), children: label }),
1126
+ /* @__PURE__ */ jsx("span", { className: cx(triggerValueClass, triggerValueClassName), id: valueId, children: value })
1127
+ ] })
1128
+ }
1129
+ );
1130
+ const panel = isOpen ? /* @__PURE__ */ jsx(
1131
+ "div",
1132
+ {
1133
+ "aria-labelledby": panelLabelId,
1134
+ className: cx(panelClass, renderInPortal ? portaledPanelClass : void 0, panelClassName),
1135
+ id: panelId,
1136
+ ref: panelRef,
1137
+ role: "dialog",
1138
+ style: renderInPortal ? portalStyle : void 0,
1139
+ tabIndex: -1,
1140
+ children: typeof children === "function" ? children({ closePopover }) : children
1141
+ }
1142
+ ) : null;
1143
+ return /* @__PURE__ */ jsxs("div", { className: cx(rootClass2, rootClassName), ref: rootRef, children: [
1144
+ /* @__PURE__ */ jsx("span", { className: srOnlyClass, id: panelLabelId, children: panelLabel }),
1145
+ !usesSharedLabel ? /* @__PURE__ */ jsx("span", { className: srOnlyClass, id: triggerLabelId, children: resolvedTriggerLabel }) : null,
1146
+ triggerTooltip ? /* @__PURE__ */ jsx(Tooltip, { content: triggerTooltip, children: triggerButton }) : triggerButton,
1147
+ renderInPortal && panel ? createPortal(panel, document.body) : panel
1148
+ ] });
1149
+ };
1150
+ var rootClass2 = css({
1151
+ position: "relative"
1152
+ });
1153
+ var triggerButtonClass = css({
1154
+ _hover: {
1155
+ color: "primary"
1156
+ },
1157
+ _focusVisible: {
1158
+ ...focusVisibleRingStyles,
1159
+ color: "primary"
1160
+ }
1161
+ });
1162
+ var triggerLabelClass = css({
1163
+ fontSize: "xs",
1164
+ fontWeight: "bold",
1165
+ letterSpacing: "[0.12em]",
1166
+ textTransform: "uppercase",
1167
+ color: "muted"
1168
+ });
1169
+ var triggerValueClass = css({
1170
+ fontSize: "sm",
1171
+ color: "text"
1172
+ });
1173
+ var panelClass = css({
1174
+ position: "absolute",
1175
+ top: "[calc(100% + 0.55rem)]",
1176
+ right: "0",
1177
+ minWidth: "48",
1178
+ p: "2",
1179
+ borderRadius: "2xl",
1180
+ border: "[1px solid var(--colors-border)]",
1181
+ backgroundColor: "surface",
1182
+ boxShadow: "floating",
1183
+ display: "grid",
1184
+ gap: "1",
1185
+ zIndex: "30"
1186
+ });
1187
+ var portaledPanelClass = css({
1188
+ top: "[auto]",
1189
+ right: "[auto]"
1190
+ });
1191
+ var resizeTextarea = (element) => {
1192
+ element.style.height = "0px";
1193
+ element.style.height = `${element.scrollHeight}px`;
1194
+ };
1195
+ var Textarea = React.forwardRef(
1196
+ ({ autoResize = true, className, onChange, rows = 1, style, ...props }, ref) => {
1197
+ const innerRef = useRef(null);
1198
+ useLayoutEffect(() => {
1199
+ if (!autoResize || !innerRef.current) return;
1200
+ resizeTextarea(innerRef.current);
1201
+ }, [autoResize, props.value]);
1202
+ const handleRef = (node) => {
1203
+ innerRef.current = node;
1204
+ if (!ref) return;
1205
+ if (typeof ref === "function") {
1206
+ ref(node);
1207
+ return;
1208
+ }
1209
+ ref.current = node;
1210
+ };
1211
+ const handleChange = (event) => {
1212
+ if (autoResize) {
1213
+ resizeTextarea(event.currentTarget);
1214
+ }
1215
+ onChange?.(event);
1216
+ };
1217
+ return /* @__PURE__ */ jsx(
1218
+ "textarea",
1219
+ {
1220
+ ...props,
1221
+ className: cx(textareaRecipe({ autoResize }), className),
1222
+ onChange: handleChange,
1223
+ ref: handleRef,
1224
+ rows,
1225
+ style
1226
+ }
1227
+ );
1228
+ }
1229
+ );
1230
+ Textarea.displayName = "Textarea";
1231
+ var textareaRecipe = cva({
1232
+ base: {
1233
+ width: "full",
1234
+ px: "3",
1235
+ py: "2",
1236
+ borderRadius: "md",
1237
+ borderWidth: "1px",
1238
+ borderStyle: "solid",
1239
+ borderColor: "border",
1240
+ backgroundColor: "transparent",
1241
+ color: "text",
1242
+ resize: "vertical",
1243
+ transition: "colors",
1244
+ _placeholder: {
1245
+ color: "muted"
1246
+ },
1247
+ _hover: {
1248
+ borderColor: "borderStrong"
1249
+ },
1250
+ _focusVisible: {
1251
+ ...focusVisibleRingStyles,
1252
+ borderColor: "primary"
1253
+ },
1254
+ _disabled: disabledFieldStyles,
1255
+ '&[aria-disabled="true"]': {
1256
+ ...disabledFieldStyles
1257
+ }
1258
+ },
1259
+ variants: {
1260
+ autoResize: {
1261
+ true: {
1262
+ resize: "none",
1263
+ overflow: "hidden"
1264
+ },
1265
+ false: {}
1266
+ }
1267
+ },
1268
+ defaultVariants: {
1269
+ autoResize: true
1270
+ }
1271
+ });
1272
+
1273
+ // src/shared/ui/primitive-registry/default-markdown-primitive-registry.ts
1274
+ var defaultMarkdownPrimitiveRegistry = {
1275
+ Button,
1276
+ Input,
1277
+ Modal,
1278
+ Popover,
1279
+ Textarea,
1280
+ Tooltip
1281
+ };
1282
+ var createDefaultMarkdownPrimitiveRegistry = () => defaultMarkdownPrimitiveRegistry;
1283
+ var createPandaMarkdownPrimitiveRegistry = () => defaultMarkdownPrimitiveRegistry;
1284
+
1285
+ export { Button, Input, Modal, Popover, Textarea, Tooltip, buttonRecipe, createDefaultMarkdownPrimitiveRegistry, createPandaMarkdownPrimitiveRegistry };