baseline-kit 2.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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +334 -0
  3. package/dist/README.md +334 -0
  4. package/dist/components/Baseline/Baseline.d.ts +48 -0
  5. package/dist/components/Baseline/index.d.ts +6 -0
  6. package/dist/components/Box/Box.d.ts +62 -0
  7. package/dist/components/Box/index.d.ts +6 -0
  8. package/dist/components/Config/Config.d.ts +136 -0
  9. package/dist/components/Config/defaults.d.ts +25 -0
  10. package/dist/components/Config/index.d.ts +11 -0
  11. package/dist/components/Guide/Guide.d.ts +60 -0
  12. package/dist/components/Guide/index.d.ts +12 -0
  13. package/dist/components/Guide/types.d.ts +144 -0
  14. package/dist/components/Guide/validation.d.ts +82 -0
  15. package/dist/components/Layout/Layout.d.ts +69 -0
  16. package/dist/components/Layout/index.d.ts +10 -0
  17. package/dist/components/Padder/Padder.d.ts +61 -0
  18. package/dist/components/Padder/index.d.ts +10 -0
  19. package/dist/components/Spacer/Spacer.d.ts +55 -0
  20. package/dist/components/Spacer/index.d.ts +10 -0
  21. package/dist/components/Stack/Stack.d.ts +77 -0
  22. package/dist/components/Stack/index.d.ts +10 -0
  23. package/dist/components/index.d.ts +15 -0
  24. package/dist/components/types.d.ts +102 -0
  25. package/dist/hooks/index.d.ts +11 -0
  26. package/dist/hooks/useBaseline.d.ts +72 -0
  27. package/dist/hooks/useConfig.d.ts +46 -0
  28. package/dist/hooks/useDebug.d.ts +54 -0
  29. package/dist/hooks/useGuide.d.ts +66 -0
  30. package/dist/hooks/useMeasure.d.ts +49 -0
  31. package/dist/hooks/useVirtual.d.ts +65 -0
  32. package/dist/index.cjs +32 -0
  33. package/dist/index.cjs.map +1 -0
  34. package/dist/index.d.ts +10 -0
  35. package/dist/index.mjs +1592 -0
  36. package/dist/index.mjs.map +1 -0
  37. package/dist/styles.css +1 -0
  38. package/dist/utils/convert.d.ts +46 -0
  39. package/dist/utils/index.d.ts +13 -0
  40. package/dist/utils/math.d.ts +64 -0
  41. package/dist/utils/merge.d.ts +68 -0
  42. package/dist/utils/normalize.d.ts +65 -0
  43. package/dist/utils/padding.d.ts +11 -0
  44. package/dist/utils/parse.d.ts +52 -0
  45. package/dist/utils/snapping.d.ts +33 -0
  46. package/dist/utils/timing.d.ts +50 -0
  47. package/package.json +113 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,1592 @@
1
+ import * as E from "react";
2
+ import st, { useState as Je, useRef as ie, useCallback as le, useLayoutEffect as ye, useMemo as P, memo as De } from "react";
3
+ var ae = { exports: {} }, re = {};
4
+ /**
5
+ * @license React
6
+ * react-jsx-runtime.production.js
7
+ *
8
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
13
+ var Be;
14
+ function at() {
15
+ if (Be) return re;
16
+ Be = 1;
17
+ var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
18
+ function r(s, i, o) {
19
+ var a = null;
20
+ if (o !== void 0 && (a = "" + o), i.key !== void 0 && (a = "" + i.key), "key" in i) {
21
+ o = {};
22
+ for (var f in i)
23
+ f !== "key" && (o[f] = i[f]);
24
+ } else o = i;
25
+ return i = o.ref, {
26
+ $$typeof: t,
27
+ type: s,
28
+ key: a,
29
+ ref: i !== void 0 ? i : null,
30
+ props: o
31
+ };
32
+ }
33
+ return re.Fragment = n, re.jsx = r, re.jsxs = r, re;
34
+ }
35
+ var oe = {};
36
+ /**
37
+ * @license React
38
+ * react-jsx-runtime.development.js
39
+ *
40
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
41
+ *
42
+ * This source code is licensed under the MIT license found in the
43
+ * LICENSE file in the root directory of this source tree.
44
+ */
45
+ var Ue;
46
+ function lt() {
47
+ return Ue || (Ue = 1, process.env.NODE_ENV !== "production" && function() {
48
+ function t(e) {
49
+ if (e == null) return null;
50
+ if (typeof e == "function")
51
+ return e.$$typeof === rt ? null : e.displayName || e.name || null;
52
+ if (typeof e == "string") return e;
53
+ switch (e) {
54
+ case O:
55
+ return "Fragment";
56
+ case w:
57
+ return "Portal";
58
+ case A:
59
+ return "Profiler";
60
+ case $:
61
+ return "StrictMode";
62
+ case G:
63
+ return "Suspense";
64
+ case F:
65
+ return "SuspenseList";
66
+ }
67
+ if (typeof e == "object")
68
+ switch (typeof e.tag == "number" && console.error(
69
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
70
+ ), e.$$typeof) {
71
+ case z:
72
+ return (e.displayName || "Context") + ".Provider";
73
+ case W:
74
+ return (e._context.displayName || "Context") + ".Consumer";
75
+ case N:
76
+ var c = e.render;
77
+ return e = e.displayName, e || (e = c.displayName || c.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
78
+ case L:
79
+ return c = e.displayName || null, c !== null ? c : t(e.type) || "Memo";
80
+ case de:
81
+ c = e._payload, e = e._init;
82
+ try {
83
+ return t(e(c));
84
+ } catch {
85
+ }
86
+ }
87
+ return null;
88
+ }
89
+ function n(e) {
90
+ return "" + e;
91
+ }
92
+ function r(e) {
93
+ try {
94
+ n(e);
95
+ var c = !1;
96
+ } catch {
97
+ c = !0;
98
+ }
99
+ if (c) {
100
+ c = console;
101
+ var u = c.error, v = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
102
+ return u.call(
103
+ c,
104
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
105
+ v
106
+ ), n(e);
107
+ }
108
+ }
109
+ function s() {
110
+ }
111
+ function i() {
112
+ if (te === 0) {
113
+ Te = console.log, $e = console.info, je = console.warn, Ae = console.error, Oe = console.group, Ne = console.groupCollapsed, Me = console.groupEnd;
114
+ var e = {
115
+ configurable: !0,
116
+ enumerable: !0,
117
+ value: s,
118
+ writable: !0
119
+ };
120
+ Object.defineProperties(console, {
121
+ info: e,
122
+ log: e,
123
+ warn: e,
124
+ error: e,
125
+ group: e,
126
+ groupCollapsed: e,
127
+ groupEnd: e
128
+ });
129
+ }
130
+ te++;
131
+ }
132
+ function o() {
133
+ if (te--, te === 0) {
134
+ var e = { configurable: !0, enumerable: !0, writable: !0 };
135
+ Object.defineProperties(console, {
136
+ log: X({}, e, { value: Te }),
137
+ info: X({}, e, { value: $e }),
138
+ warn: X({}, e, { value: je }),
139
+ error: X({}, e, { value: Ae }),
140
+ group: X({}, e, { value: Oe }),
141
+ groupCollapsed: X({}, e, { value: Ne }),
142
+ groupEnd: X({}, e, { value: Me })
143
+ });
144
+ }
145
+ 0 > te && console.error(
146
+ "disabledDepth fell below zero. This is a bug in React. Please file an issue."
147
+ );
148
+ }
149
+ function a(e) {
150
+ if (me === void 0)
151
+ try {
152
+ throw Error();
153
+ } catch (u) {
154
+ var c = u.stack.trim().match(/\n( *(at )?)/);
155
+ me = c && c[1] || "", Ve = -1 < u.stack.indexOf(`
156
+ at`) ? " (<anonymous>)" : -1 < u.stack.indexOf("@") ? "@unknown:0:0" : "";
157
+ }
158
+ return `
159
+ ` + me + e + Ve;
160
+ }
161
+ function f(e, c) {
162
+ if (!e || ge) return "";
163
+ var u = he.get(e);
164
+ if (u !== void 0) return u;
165
+ ge = !0, u = Error.prepareStackTrace, Error.prepareStackTrace = void 0;
166
+ var v = null;
167
+ v = H.H, H.H = null, i();
168
+ try {
169
+ var M = {
170
+ DetermineComponentFrameRoot: function() {
171
+ try {
172
+ if (c) {
173
+ var I = function() {
174
+ throw Error();
175
+ };
176
+ if (Object.defineProperty(I.prototype, "props", {
177
+ set: function() {
178
+ throw Error();
179
+ }
180
+ }), typeof Reflect == "object" && Reflect.construct) {
181
+ try {
182
+ Reflect.construct(I, []);
183
+ } catch (U) {
184
+ var se = U;
185
+ }
186
+ Reflect.construct(e, [], I);
187
+ } else {
188
+ try {
189
+ I.call();
190
+ } catch (U) {
191
+ se = U;
192
+ }
193
+ e.call(I.prototype);
194
+ }
195
+ } else {
196
+ try {
197
+ throw Error();
198
+ } catch (U) {
199
+ se = U;
200
+ }
201
+ (I = e()) && typeof I.catch == "function" && I.catch(function() {
202
+ });
203
+ }
204
+ } catch (U) {
205
+ if (U && se && typeof U.stack == "string")
206
+ return [U.stack, se.stack];
207
+ }
208
+ return [null, null];
209
+ }
210
+ };
211
+ M.DetermineComponentFrameRoot.displayName = "DetermineComponentFrameRoot";
212
+ var j = Object.getOwnPropertyDescriptor(
213
+ M.DetermineComponentFrameRoot,
214
+ "name"
215
+ );
216
+ j && j.configurable && Object.defineProperty(
217
+ M.DetermineComponentFrameRoot,
218
+ "name",
219
+ { value: "DetermineComponentFrameRoot" }
220
+ );
221
+ var m = M.DetermineComponentFrameRoot(), B = m[0], K = m[1];
222
+ if (B && K) {
223
+ var V = B.split(`
224
+ `), q = K.split(`
225
+ `);
226
+ for (m = j = 0; j < V.length && !V[j].includes(
227
+ "DetermineComponentFrameRoot"
228
+ ); )
229
+ j++;
230
+ for (; m < q.length && !q[m].includes(
231
+ "DetermineComponentFrameRoot"
232
+ ); )
233
+ m++;
234
+ if (j === V.length || m === q.length)
235
+ for (j = V.length - 1, m = q.length - 1; 1 <= j && 0 <= m && V[j] !== q[m]; )
236
+ m--;
237
+ for (; 1 <= j && 0 <= m; j--, m--)
238
+ if (V[j] !== q[m]) {
239
+ if (j !== 1 || m !== 1)
240
+ do
241
+ if (j--, m--, 0 > m || V[j] !== q[m]) {
242
+ var ne = `
243
+ ` + V[j].replace(
244
+ " at new ",
245
+ " at "
246
+ );
247
+ return e.displayName && ne.includes("<anonymous>") && (ne = ne.replace("<anonymous>", e.displayName)), typeof e == "function" && he.set(e, ne), ne;
248
+ }
249
+ while (1 <= j && 0 <= m);
250
+ break;
251
+ }
252
+ }
253
+ } finally {
254
+ ge = !1, H.H = v, o(), Error.prepareStackTrace = u;
255
+ }
256
+ return V = (V = e ? e.displayName || e.name : "") ? a(V) : "", typeof e == "function" && he.set(e, V), V;
257
+ }
258
+ function d(e) {
259
+ if (e == null) return "";
260
+ if (typeof e == "function") {
261
+ var c = e.prototype;
262
+ return f(
263
+ e,
264
+ !(!c || !c.isReactComponent)
265
+ );
266
+ }
267
+ if (typeof e == "string") return a(e);
268
+ switch (e) {
269
+ case G:
270
+ return a("Suspense");
271
+ case F:
272
+ return a("SuspenseList");
273
+ }
274
+ if (typeof e == "object")
275
+ switch (e.$$typeof) {
276
+ case N:
277
+ return e = f(e.render, !1), e;
278
+ case L:
279
+ return d(e.type);
280
+ case de:
281
+ c = e._payload, e = e._init;
282
+ try {
283
+ return d(e(c));
284
+ } catch {
285
+ }
286
+ }
287
+ return "";
288
+ }
289
+ function l() {
290
+ var e = H.A;
291
+ return e === null ? null : e.getOwner();
292
+ }
293
+ function g(e) {
294
+ if (Re.call(e, "key")) {
295
+ var c = Object.getOwnPropertyDescriptor(e, "key").get;
296
+ if (c && c.isReactWarning) return !1;
297
+ }
298
+ return e.key !== void 0;
299
+ }
300
+ function x(e, c) {
301
+ function u() {
302
+ We || (We = !0, console.error(
303
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
304
+ c
305
+ ));
306
+ }
307
+ u.isReactWarning = !0, Object.defineProperty(e, "key", {
308
+ get: u,
309
+ configurable: !0
310
+ });
311
+ }
312
+ function b() {
313
+ var e = t(this.type);
314
+ return Ge[e] || (Ge[e] = !0, console.error(
315
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
316
+ )), e = this.props.ref, e !== void 0 ? e : null;
317
+ }
318
+ function h(e, c, u, v, M, j) {
319
+ return u = j.ref, e = {
320
+ $$typeof: _,
321
+ type: e,
322
+ key: c,
323
+ props: j,
324
+ _owner: M
325
+ }, (u !== void 0 ? u : null) !== null ? Object.defineProperty(e, "ref", {
326
+ enumerable: !1,
327
+ get: b
328
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
329
+ configurable: !1,
330
+ enumerable: !1,
331
+ writable: !0,
332
+ value: 0
333
+ }), Object.defineProperty(e, "_debugInfo", {
334
+ configurable: !1,
335
+ enumerable: !1,
336
+ writable: !0,
337
+ value: null
338
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
339
+ }
340
+ function T(e, c, u, v, M, j) {
341
+ if (typeof e == "string" || typeof e == "function" || e === O || e === A || e === $ || e === G || e === F || e === nt || typeof e == "object" && e !== null && (e.$$typeof === de || e.$$typeof === L || e.$$typeof === z || e.$$typeof === W || e.$$typeof === N || e.$$typeof === ot || e.getModuleId !== void 0)) {
342
+ var m = c.children;
343
+ if (m !== void 0)
344
+ if (v)
345
+ if (be(m)) {
346
+ for (v = 0; v < m.length; v++)
347
+ y(m[v], e);
348
+ Object.freeze && Object.freeze(m);
349
+ } else
350
+ console.error(
351
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
352
+ );
353
+ else y(m, e);
354
+ } else
355
+ m = "", (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (m += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."), e === null ? v = "null" : be(e) ? v = "array" : e !== void 0 && e.$$typeof === _ ? (v = "<" + (t(e.type) || "Unknown") + " />", m = " Did you accidentally export a JSX literal instead of a component?") : v = typeof e, console.error(
356
+ "React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",
357
+ v,
358
+ m
359
+ );
360
+ if (Re.call(c, "key")) {
361
+ m = t(e);
362
+ var B = Object.keys(c).filter(function(V) {
363
+ return V !== "key";
364
+ });
365
+ v = 0 < B.length ? "{key: someKey, " + B.join(": ..., ") + ": ...}" : "{key: someKey}", Pe[m + v] || (B = 0 < B.length ? "{" + B.join(": ..., ") + ": ...}" : "{}", console.error(
366
+ `A props object containing a "key" prop is being spread into JSX:
367
+ let props = %s;
368
+ <%s {...props} />
369
+ React keys must be passed directly to JSX without using spread:
370
+ let props = %s;
371
+ <%s key={someKey} {...props} />`,
372
+ v,
373
+ m,
374
+ B,
375
+ m
376
+ ), Pe[m + v] = !0);
377
+ }
378
+ if (m = null, u !== void 0 && (r(u), m = "" + u), g(c) && (r(c.key), m = "" + c.key), "key" in c) {
379
+ u = {};
380
+ for (var K in c)
381
+ K !== "key" && (u[K] = c[K]);
382
+ } else u = c;
383
+ return m && x(
384
+ u,
385
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
386
+ ), h(e, m, j, M, l(), u);
387
+ }
388
+ function y(e, c) {
389
+ if (typeof e == "object" && e && e.$$typeof !== it) {
390
+ if (be(e))
391
+ for (var u = 0; u < e.length; u++) {
392
+ var v = e[u];
393
+ p(v) && S(v, c);
394
+ }
395
+ else if (p(e))
396
+ e._store && (e._store.validated = 1);
397
+ else if (e === null || typeof e != "object" ? u = null : (u = _e && e[_e] || e["@@iterator"], u = typeof u == "function" ? u : null), typeof u == "function" && u !== e.entries && (u = u.call(e), u !== e))
398
+ for (; !(e = u.next()).done; )
399
+ p(e.value) && S(e.value, c);
400
+ }
401
+ }
402
+ function p(e) {
403
+ return typeof e == "object" && e !== null && e.$$typeof === _;
404
+ }
405
+ function S(e, c) {
406
+ if (e._store && !e._store.validated && e.key == null && (e._store.validated = 1, c = C(c), !Ye[c])) {
407
+ Ye[c] = !0;
408
+ var u = "";
409
+ e && e._owner != null && e._owner !== l() && (u = null, typeof e._owner.tag == "number" ? u = t(e._owner.type) : typeof e._owner.name == "string" && (u = e._owner.name), u = " It was passed a child from " + u + ".");
410
+ var v = H.getCurrentStack;
411
+ H.getCurrentStack = function() {
412
+ var M = d(e.type);
413
+ return v && (M += v() || ""), M;
414
+ }, console.error(
415
+ 'Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',
416
+ c,
417
+ u
418
+ ), H.getCurrentStack = v;
419
+ }
420
+ }
421
+ function C(e) {
422
+ var c = "", u = l();
423
+ return u && (u = t(u.type)) && (c = `
424
+
425
+ Check the render method of \`` + u + "`."), c || (e = t(e)) && (c = `
426
+
427
+ Check the top-level render call using <` + e + ">."), c;
428
+ }
429
+ var k = st, _ = Symbol.for("react.transitional.element"), w = Symbol.for("react.portal"), O = Symbol.for("react.fragment"), $ = Symbol.for("react.strict_mode"), A = Symbol.for("react.profiler"), W = Symbol.for("react.consumer"), z = Symbol.for("react.context"), N = Symbol.for("react.forward_ref"), G = Symbol.for("react.suspense"), F = Symbol.for("react.suspense_list"), L = Symbol.for("react.memo"), de = Symbol.for("react.lazy"), nt = Symbol.for("react.offscreen"), _e = Symbol.iterator, rt = Symbol.for("react.client.reference"), H = k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Re = Object.prototype.hasOwnProperty, X = Object.assign, ot = Symbol.for("react.client.reference"), be = Array.isArray, te = 0, Te, $e, je, Ae, Oe, Ne, Me;
430
+ s.__reactDisabledLog = !0;
431
+ var me, Ve, ge = !1, he = new (typeof WeakMap == "function" ? WeakMap : Map)(), it = Symbol.for("react.client.reference"), We, Ge = {}, Pe = {}, Ye = {};
432
+ oe.Fragment = O, oe.jsx = function(e, c, u, v, M) {
433
+ return T(e, c, u, !1, v, M);
434
+ }, oe.jsxs = function(e, c, u, v, M) {
435
+ return T(e, c, u, !0, v, M);
436
+ };
437
+ }()), oe;
438
+ }
439
+ var ze;
440
+ function ct() {
441
+ return ze || (ze = 1, process.env.NODE_ENV === "production" ? ae.exports = at() : ae.exports = lt()), ae.exports;
442
+ }
443
+ var R = ct();
444
+ function ut(t) {
445
+ const n = t.trim().match(/^([+-]?[\d.]+)([a-zA-Z%]+)$/);
446
+ if (!n) return null;
447
+ const r = parseFloat(n[1]), s = n[2];
448
+ return { value: r, unit: s };
449
+ }
450
+ function ve(t, n) {
451
+ return t === void 0 && n !== void 0 ? `${n}px` : t === "auto" || typeof t == "string" && /^(auto|100%|0|.*(fr|vh|vw|vmin|vmax|rem))$/.test(t) ? String(t) : typeof t == "number" ? `${t}px` : t ?? "";
452
+ }
453
+ const ft = {
454
+ parentSize: 0,
455
+ viewportWidth: typeof window < "u" ? window.innerWidth : 1920,
456
+ viewportHeight: typeof window < "u" ? window.innerHeight : 1080,
457
+ rootFontSize: 16,
458
+ parentFontSize: 16
459
+ }, xe = {
460
+ px: 1,
461
+ in: 96,
462
+ // 1in = 96px
463
+ cm: 37.8,
464
+ // 1cm = 37.8px
465
+ mm: 3.78,
466
+ // 1mm = 3.78px
467
+ pt: 1.33,
468
+ // 1pt = 1.33px
469
+ pc: 16
470
+ // 1pc = 16px
471
+ }, Qe = ["em", "rem", "vh", "vw", "vmin", "vmax", "%"];
472
+ function ke(t, n) {
473
+ if (typeof t == "number") return t;
474
+ if (typeof t != "string") return null;
475
+ const r = ut(t);
476
+ if (!r) return null;
477
+ const { value: s, unit: i } = r;
478
+ if (i in xe)
479
+ return s * xe[i];
480
+ if (i === "auto") return null;
481
+ if (Qe.includes(i)) {
482
+ const o = { ...ft, ...n };
483
+ switch (i) {
484
+ case "em":
485
+ return s * o.parentFontSize;
486
+ case "rem":
487
+ return s * o.rootFontSize;
488
+ case "vh":
489
+ return s / 100 * o.viewportHeight;
490
+ case "vw":
491
+ return s / 100 * o.viewportWidth;
492
+ case "vmin":
493
+ return s / 100 * Math.min(o.viewportWidth, o.viewportHeight);
494
+ case "vmax":
495
+ return s / 100 * Math.max(o.viewportWidth, o.viewportHeight);
496
+ case "%":
497
+ return s / 100 * o.parentSize;
498
+ default:
499
+ return null;
500
+ }
501
+ }
502
+ return null;
503
+ }
504
+ function Zt(t, n, r) {
505
+ const s = (r == null ? void 0 : r.round) ?? !0, i = t === void 0 ? 0 : typeof t == "number" ? t : ke(t) ?? 0;
506
+ return `${(s ? Math.round(i) : i) % n}px`;
507
+ }
508
+ function dt(t, n, r) {
509
+ return Math.min(Math.max(t, n), r);
510
+ }
511
+ function Kt(t, n = 0) {
512
+ if (n >= 0)
513
+ return Number((Math.round(t * 10 ** n) / 10 ** n).toFixed(n));
514
+ {
515
+ const r = 10 ** Math.abs(n);
516
+ return Math.round(t / r) * r;
517
+ }
518
+ }
519
+ function ce(t, n = {}) {
520
+ const {
521
+ base: r = 8,
522
+ round: s = !0,
523
+ clamp: i,
524
+ suppressWarnings: o = !1
525
+ } = n;
526
+ if (t === "auto") return r;
527
+ let a = null;
528
+ if (typeof t == "number")
529
+ a = t;
530
+ else if (typeof t == "string") {
531
+ const l = ke(t);
532
+ l === null ? (o || console.error(`Failed to convert "${t}" to pixels. Falling back to base ${r}.`), a = r) : a = l;
533
+ }
534
+ a === null && (a = r);
535
+ const f = s ? Math.round(a / r) * r : a, d = i !== void 0 ? dt(f, i.min ?? -1 / 0, i.max ?? 1 / 0) : f;
536
+ return !o && d !== a && console.warn(`Normalized ${a} to ${d} to match base ${r}px.`), d;
537
+ }
538
+ function Ze(t, n, r) {
539
+ if (!t) return n;
540
+ const s = t[0] !== void 0 ? ce(t[0], r) : n[0], i = t[1] !== void 0 ? ce(t[1], r) : n[1];
541
+ return [s, i];
542
+ }
543
+ function J(t) {
544
+ if ("padding" in t && t.padding != null)
545
+ return bt(t.padding);
546
+ const n = "block" in t && t.block != null ? mt(t.block) : { top: 0, bottom: 0 }, r = "inline" in t && t.inline != null ? gt(t.inline) : { left: 0, right: 0 };
547
+ return {
548
+ top: n.top,
549
+ right: r.right,
550
+ bottom: n.bottom,
551
+ left: r.left
552
+ };
553
+ }
554
+ function bt(t) {
555
+ if (typeof t == "number")
556
+ return { top: t, right: t, bottom: t, left: t };
557
+ if (Array.isArray(t)) {
558
+ if (t.length === 2) {
559
+ const [n, r] = t;
560
+ return { top: n, right: r, bottom: n, left: r };
561
+ }
562
+ if (t.length >= 4) {
563
+ const [n, r, s, i] = t;
564
+ return {
565
+ top: n ?? 0,
566
+ right: r ?? 0,
567
+ bottom: s ?? 0,
568
+ left: i ?? 0
569
+ };
570
+ }
571
+ }
572
+ if (typeof t == "object" && !Array.isArray(t)) {
573
+ const n = t.top ?? 0, r = t.bottom ?? 0, s = t.left ?? 0, i = t.right ?? 0;
574
+ return { top: n, right: i, bottom: r, left: s };
575
+ }
576
+ return { top: 0, right: 0, bottom: 0, left: 0 };
577
+ }
578
+ function mt(t) {
579
+ if (typeof t == "number")
580
+ return { top: t, bottom: t };
581
+ if (Array.isArray(t)) {
582
+ const [n, r] = t;
583
+ return {
584
+ top: n ?? 0,
585
+ bottom: r ?? 0
586
+ };
587
+ }
588
+ return typeof t == "object" ? {
589
+ top: t.start ?? 0,
590
+ bottom: t.end ?? 0
591
+ } : { top: 0, bottom: 0 };
592
+ }
593
+ function gt(t) {
594
+ if (typeof t == "number")
595
+ return { left: t, right: t };
596
+ if (Array.isArray(t)) {
597
+ const [n, r] = t;
598
+ return {
599
+ left: n ?? 0,
600
+ right: r ?? 0
601
+ };
602
+ }
603
+ return typeof t == "object" ? {
604
+ left: t.start ?? 0,
605
+ right: t.end ?? 0
606
+ } : { left: 0, right: 0 };
607
+ }
608
+ function ht(t, n, r, s) {
609
+ const i = J({ padding: r });
610
+ if (s === "none")
611
+ return i;
612
+ if (s === "height") {
613
+ const o = t % n;
614
+ o !== 0 && (i.bottom += n - o);
615
+ }
616
+ if (s === "clamp") {
617
+ i.top = i.top % n;
618
+ const o = t % n;
619
+ o !== 0 && (i.bottom += n - o), i.bottom = i.bottom % n;
620
+ }
621
+ return i;
622
+ }
623
+ const D = (...t) => t.filter(Boolean).join(" ").trim(), Y = (...t) => Object.assign({}, ...t.filter((n) => n !== void 0));
624
+ function pt(t, n) {
625
+ if (t)
626
+ if (typeof t == "function")
627
+ t(n);
628
+ else
629
+ try {
630
+ Object.assign(t, { current: n });
631
+ } catch (r) {
632
+ console.error("Error assigning ref:", r);
633
+ }
634
+ }
635
+ function Ke(...t) {
636
+ return (n) => {
637
+ t.forEach((r) => {
638
+ pt(r, n);
639
+ });
640
+ };
641
+ }
642
+ const en = (t, n) => {
643
+ let r = null;
644
+ return (...s) => {
645
+ r && clearTimeout(r), r = setTimeout(() => t(...s), n);
646
+ };
647
+ }, et = (t) => {
648
+ let n = null;
649
+ return (...r) => {
650
+ n || (n = requestAnimationFrame(() => {
651
+ t(...r), n = null;
652
+ }));
653
+ };
654
+ };
655
+ function ue(t) {
656
+ const [n, r] = Je({ width: 0, height: 0 }), s = ie({ width: 0, height: 0 }), i = ie(!1), o = le(() => {
657
+ if (!(!t.current || i.current))
658
+ try {
659
+ const d = t.current.getBoundingClientRect(), l = {
660
+ width: Math.round(d.width),
661
+ height: Math.round(d.height)
662
+ };
663
+ (s.current.width !== l.width || s.current.height !== l.height) && (s.current = l, r(l));
664
+ } catch (d) {
665
+ i.current = !0, console.error("Error measuring element:", d), (n.width !== 0 || n.height !== 0) && r({ width: 0, height: 0 });
666
+ }
667
+ }, [t, n]), a = ie(et(o));
668
+ ye(() => {
669
+ if (typeof window > "u" || !t.current) return;
670
+ const d = new ResizeObserver(() => {
671
+ a.current();
672
+ });
673
+ return d.observe(t.current), o(), () => {
674
+ d.disconnect(), i.current = !1;
675
+ };
676
+ }, [t, o]);
677
+ const f = le(() => {
678
+ i.current = !1, o();
679
+ }, [o]);
680
+ return { ...n, refresh: f };
681
+ }
682
+ function vt({
683
+ totalLines: t,
684
+ lineHeight: n,
685
+ containerRef: r,
686
+ buffer: s = 0
687
+ }) {
688
+ const i = typeof s == "number" ? s : parseInt(s, 10) || 0, o = le(() => {
689
+ const l = r.current;
690
+ if (!l) return { start: 0, end: t };
691
+ if (l.closest(".content-block"))
692
+ return { start: 0, end: t };
693
+ const x = l.getBoundingClientRect().top + window.scrollY, b = Math.max(0, window.scrollY - x - i), h = b + window.innerHeight + i * 2, T = Math.max(0, Math.floor(b / n)), y = Math.min(t, Math.ceil(h / n));
694
+ return { start: T, end: y };
695
+ }, [t, n, r, i]), [a, f] = Je(o);
696
+ xt(["scroll", "resize"], () => {
697
+ d();
698
+ });
699
+ const d = et(() => f(o()));
700
+ return ye(() => {
701
+ const l = r.current;
702
+ if (!l) return;
703
+ const g = new IntersectionObserver(d, { threshold: 0 });
704
+ return g.observe(l), d(), () => {
705
+ g.disconnect();
706
+ };
707
+ }, [r, o, d]), a;
708
+ }
709
+ function xt(t, n) {
710
+ ye(() => (t.forEach((r) => window.addEventListener(r, n, { passive: !0 })), () => {
711
+ t.forEach((r) => window.removeEventListener(r, n));
712
+ }), [t, n]);
713
+ }
714
+ function fe(t, {
715
+ base: n = 8,
716
+ snapping: r = "none",
717
+ spacing: s = {},
718
+ warnOnMisalignment: i = !1
719
+ } = {}) {
720
+ if (n < 1)
721
+ throw new Error("Base must be >= 1 for baseline alignment.");
722
+ const { height: o } = ue(t);
723
+ return P(() => {
724
+ const a = typeof s == "number" ? { top: s, right: s, bottom: s, left: s } : {
725
+ top: s.top ?? 0,
726
+ right: s.right ?? 0,
727
+ bottom: s.bottom ?? 0,
728
+ left: s.left ?? 0
729
+ }, f = o % n === 0;
730
+ if (r === "none")
731
+ return !f && i && process.env.NODE_ENV === "development" && console.warn(`Element height (${o}px) is not a multiple of base (${n}px).`), { padding: a, isAligned: f, height: o };
732
+ const d = r === "height" || r === "clamp" ? ht(o, n, a, r) : a;
733
+ return !f && i && process.env.NODE_ENV === "development" && console.warn(`[useBaseline] Element height (${o}px) is not aligned with base (${n}px).`), { padding: d, isAligned: f, height: o };
734
+ }, [n, r, s, o, i]);
735
+ }
736
+ function yt(t, n) {
737
+ const { width: r } = ue(t);
738
+ return P(() => {
739
+ const s = n.variant ?? "line", i = ce(n.gap ?? 0, { base: 1 });
740
+ if (!r)
741
+ return {
742
+ template: "none",
743
+ columnsCount: 0,
744
+ calculatedGap: 0,
745
+ isValid: !1
746
+ };
747
+ try {
748
+ switch (s) {
749
+ case "line": {
750
+ const o = Math.max(1, Math.floor(r / (i + 1)) + 1);
751
+ return {
752
+ template: `repeat(${o}, 1px)`,
753
+ columnsCount: o,
754
+ calculatedGap: i,
755
+ isValid: !0
756
+ };
757
+ }
758
+ case "pattern": {
759
+ if (!qt(n.columns))
760
+ throw new Error('Invalid "pattern" columns array');
761
+ const o = n.columns.map((a) => typeof a == "number" ? `${a}px` : a);
762
+ return o.some((a) => a === "0" || a === "0px") ? {
763
+ template: "none",
764
+ columnsCount: 0,
765
+ calculatedGap: 0,
766
+ isValid: !1
767
+ } : {
768
+ template: o.join(" "),
769
+ columnsCount: o.length,
770
+ calculatedGap: i,
771
+ isValid: !0
772
+ };
773
+ }
774
+ case "fixed": {
775
+ const o = typeof n.columns == "number" ? n.columns : 0;
776
+ if (o < 1)
777
+ throw new Error(`Invalid columns count: ${o}`);
778
+ const a = n.columnWidth ? ve(n.columnWidth) : "1fr";
779
+ return {
780
+ template: `repeat(${o}, ${a})`,
781
+ columnsCount: o,
782
+ calculatedGap: i,
783
+ isValid: !0
784
+ };
785
+ }
786
+ case "auto": {
787
+ const o = n.columnWidth ?? "auto";
788
+ if (o === "auto")
789
+ return {
790
+ template: "repeat(auto-fit, minmax(0, 1fr))",
791
+ columnsCount: 1,
792
+ calculatedGap: i,
793
+ isValid: !0
794
+ };
795
+ const a = typeof o == "number" ? `${o}px` : o.toString(), f = ke(a) ?? 0, d = f > 0 ? Math.max(1, Math.floor((r + i) / (f + i))) : 1;
796
+ return {
797
+ template: `repeat(auto-fit, minmax(${a}, 1fr))`,
798
+ columnsCount: d,
799
+ calculatedGap: i,
800
+ isValid: !0
801
+ };
802
+ }
803
+ default: {
804
+ console.warn(
805
+ `[useGuide] Unknown variant "${s}". Falling back to "line".`
806
+ );
807
+ const o = Math.max(1, Math.floor(r / (i + 1)) + 1);
808
+ return {
809
+ template: `repeat(${o}, 1px)`,
810
+ columnsCount: o,
811
+ calculatedGap: i,
812
+ isValid: !0
813
+ };
814
+ }
815
+ }
816
+ } catch (o) {
817
+ return console.warn("Error in useGuide:", o), {
818
+ template: "none",
819
+ columnsCount: 0,
820
+ calculatedGap: 0,
821
+ isValid: !1
822
+ };
823
+ }
824
+ }, [n, r]);
825
+ }
826
+ function Q(t) {
827
+ const n = tt();
828
+ return P(() => Object.assign(
829
+ { base: n.base },
830
+ n[t]
831
+ ), [n, t]);
832
+ }
833
+ function Z(t, n) {
834
+ return P(() => {
835
+ const r = t ?? n;
836
+ return {
837
+ isShown: r === "visible",
838
+ isHidden: r === "hidden",
839
+ isNone: r === "none",
840
+ debugging: r
841
+ };
842
+ }, [t, n]);
843
+ }
844
+ const kt = {
845
+ /** Color for single-line guides */
846
+ line: "var(--bk-guide-color-line-theme)",
847
+ /** Color for pattern-based guides */
848
+ pattern: "var(--bk-guide-color-pattern-theme)",
849
+ /** Color for auto-calculated guides */
850
+ auto: "var(--bk-guide-color-auto-theme)",
851
+ /** Color for fixed-column guides */
852
+ fixed: "var(--bk-guide-color-fixed-theme)"
853
+ }, Et = {
854
+ /** Color for line variant */
855
+ line: "var(--bk-baseline-color-line-theme)",
856
+ /** Color for flat/block variant */
857
+ flat: "var(--bk-baseline-color-flat-theme)"
858
+ }, wt = {
859
+ /** Color for line-style spacers */
860
+ line: "var(--bk-spacer-color-line-theme)",
861
+ /** Color for flat/block spacers */
862
+ flat: "var(--bk-spacer-color-flat-theme)",
863
+ /** Color for measurement indicators */
864
+ indice: "var(--bk-spacer-color-indice-theme)"
865
+ }, St = {
866
+ /** Border color for debug outline */
867
+ line: "var(--bk-box-color-line-theme)",
868
+ /** Background color for debug mode */
869
+ flat: "var(--bk-box-color-flat-theme)",
870
+ /** Color for measurement indicators */
871
+ indice: "var(--bk-box-color-indice-theme)"
872
+ }, Ct = {
873
+ /** Border color for debug outline */
874
+ line: "var(--bk-stack-color-line-theme)",
875
+ /** Background color for debug mode */
876
+ flat: "var(--bk-stack-color-flat-theme)",
877
+ /** Color for measurement indicators */
878
+ indice: "var(--bk-stack-color-indice-theme)"
879
+ }, _t = {
880
+ /** Border color for debug outline */
881
+ line: "var(--bk-layout-color-line-theme)",
882
+ /** Background color for debug mode */
883
+ flat: "var(--bk-layout-color-flat-theme)",
884
+ /** Color for measurement indicators */
885
+ indice: "var(--bk-layout-color-indice-theme)"
886
+ }, Rt = "var(--bk-padder-color-theme)", Tt = {
887
+ /** Base unit for spacing calculations (in pixels) */
888
+ base: 8,
889
+ /** Baseline grid configuration */
890
+ baseline: {
891
+ variant: "line",
892
+ debugging: "hidden",
893
+ colors: Et
894
+ },
895
+ /** Guide overlay configuration */
896
+ guide: {
897
+ variant: "line",
898
+ debugging: "hidden",
899
+ colors: kt
900
+ },
901
+ /** Spacer component configuration */
902
+ spacer: {
903
+ variant: "line",
904
+ debugging: "hidden",
905
+ colors: wt
906
+ },
907
+ /** Box component configuration */
908
+ box: {
909
+ debugging: "hidden",
910
+ colors: St
911
+ },
912
+ /** Stack/Flex component configuration */
913
+ stack: {
914
+ debugging: "hidden",
915
+ colors: Ct
916
+ },
917
+ /** Layout component configuration */
918
+ layout: {
919
+ debugging: "hidden",
920
+ colors: _t
921
+ },
922
+ /** Padder component configuration */
923
+ padder: {
924
+ debugging: "hidden",
925
+ color: Rt
926
+ }
927
+ }, Ee = E.createContext(null);
928
+ Ee.displayName = "ConfigContext";
929
+ const tt = () => E.use(Ee) ?? Tt, $t = ({
930
+ base: t,
931
+ baseline: n,
932
+ guide: r,
933
+ stack: s,
934
+ spacer: i,
935
+ layout: o,
936
+ box: a,
937
+ padder: f
938
+ }) => ({
939
+ "--bk-base": `${t}px`,
940
+ // Baseline Colors
941
+ "--bk-baseline-color-line": n.colors.line,
942
+ "--bk-baseline-color-flat": n.colors.flat,
943
+ // Guide Colors
944
+ "--bk-guide-color-line": r.colors.line,
945
+ "--bk-guide-color-pattern": r.colors.pattern,
946
+ "--bk-guide-color-auto": r.colors.auto,
947
+ "--bk-guide-color-fixed": r.colors.fixed,
948
+ // Spacer Colors
949
+ "--bk-spacer-color-line": i.colors.line,
950
+ "--bk-spacer-color-flat": i.colors.flat,
951
+ "--bk-spacer-color-indice": i.colors.indice,
952
+ // Box Colors
953
+ "--bk-box-color-line": a.colors.line,
954
+ "--bk-box-color-flat": a.colors.flat,
955
+ "--bk-box-color-indice": a.colors.indice,
956
+ // Flex Colors
957
+ "--bk-stack-color-line": s.colors.line,
958
+ "--bk-stack-color-flat": s.colors.flat,
959
+ "--bk-stack-color-indice": s.colors.indice,
960
+ // Layout Colors
961
+ "--bk-layout-color-line": o.colors.line,
962
+ "--bk-layout-color-flat": o.colors.flat,
963
+ "--bk-layout-color-indice": o.colors.indice,
964
+ // Padder Color
965
+ "--bk-padder-color": f.color
966
+ });
967
+ function we({
968
+ children: t,
969
+ base: n,
970
+ stack: r,
971
+ baseline: s,
972
+ guide: i,
973
+ layout: o,
974
+ spacer: a,
975
+ box: f,
976
+ padder: d
977
+ }) {
978
+ const l = tt(), g = E.useMemo(() => {
979
+ const x = {
980
+ base: n ?? l.base,
981
+ baseline: { ...l.baseline, ...s },
982
+ guide: { ...l.guide, ...i },
983
+ spacer: { ...l.spacer, ...a },
984
+ box: { ...l.box, ...f },
985
+ stack: { ...l.stack, ...r },
986
+ layout: { ...l.layout, ...o },
987
+ padder: { ...l.padder, ...d }
988
+ };
989
+ return {
990
+ ...x,
991
+ cssVariables: $t(x)
992
+ };
993
+ }, [
994
+ n,
995
+ l.base,
996
+ l.baseline,
997
+ l.guide,
998
+ l.spacer,
999
+ l.box,
1000
+ l.stack,
1001
+ l.layout,
1002
+ l.padder,
1003
+ s,
1004
+ i,
1005
+ a,
1006
+ f,
1007
+ r,
1008
+ o,
1009
+ d
1010
+ ]);
1011
+ return /* @__PURE__ */ R.jsx(Ee, { value: g, children: t });
1012
+ }
1013
+ const jt = "spacer_Wdw6F", At = "line_lUa33", Ot = "flat_zXVQF", Ie = {
1014
+ spacer: jt,
1015
+ line: At,
1016
+ flat: Ot
1017
+ }, Nt = E.memo(function({
1018
+ height: n,
1019
+ width: r,
1020
+ indicatorNode: s,
1021
+ debugging: i,
1022
+ variant: o,
1023
+ base: a,
1024
+ color: f,
1025
+ className: d,
1026
+ style: l,
1027
+ ...g
1028
+ }) {
1029
+ const x = E.useRef(null), b = Q("spacer"), { isShown: h } = Z(i, b.debugging), T = o ?? b.variant, y = a ?? b.base, [p, S] = Ze(
1030
+ [r, n],
1031
+ [0, 0],
1032
+ { base: y, suppressWarnings: !0 }
1033
+ ), C = ve(p || "100%"), k = ve(S || "100%"), _ = E.useMemo(() => !h || !s ? null : [
1034
+ S !== 0 && /* @__PURE__ */ R.jsx("span", { children: s(S, "height") }, "height"),
1035
+ p !== 0 && /* @__PURE__ */ R.jsx("span", { children: s(p, "width") }, "width")
1036
+ ].filter(Boolean), [h, s, S, p]), w = E.useMemo(() => {
1037
+ const O = {
1038
+ "--bk-spacer-height": k,
1039
+ "--bk-spacer-width": C,
1040
+ "--bk-spacer-base": `${y}px`,
1041
+ "--bk-spacer-color-indice": f ?? b.colors.indice,
1042
+ "--bk-spacer-color-line": f ?? b.colors.line,
1043
+ "--bk-spacer-color-flat": f ?? b.colors.flat
1044
+ };
1045
+ return Y(O, l);
1046
+ }, [k, C, y, f, b.colors, l]);
1047
+ return /* @__PURE__ */ R.jsx(
1048
+ "div",
1049
+ {
1050
+ ref: x,
1051
+ className: D(
1052
+ Ie.spacer,
1053
+ h && Ie[T],
1054
+ d
1055
+ ),
1056
+ "data-testid": "spacer",
1057
+ "data-variant": T,
1058
+ style: w,
1059
+ ...g,
1060
+ children: _
1061
+ }
1062
+ );
1063
+ }), Mt = "padder_HhtrA", Vt = "visible_PJmPU", Fe = {
1064
+ padder: Mt,
1065
+ visible: Vt
1066
+ }, Se = E.memo(
1067
+ E.forwardRef(function({
1068
+ children: n,
1069
+ className: r,
1070
+ debugging: s,
1071
+ height: i,
1072
+ indicatorNode: o,
1073
+ style: a,
1074
+ width: f,
1075
+ ...d
1076
+ }, l) {
1077
+ const g = Q("padder"), x = E.useMemo(
1078
+ () => J(d),
1079
+ [d]
1080
+ ), { isShown: b, isNone: h, debugging: T } = Z(s, g.debugging), y = !h, p = E.useRef(null), { padding: { top: S, left: C, bottom: k, right: _ } } = fe(p, {
1081
+ base: g.base,
1082
+ snapping: "height",
1083
+ spacing: x,
1084
+ warnOnMisalignment: !h
1085
+ }), w = Ke(l, p), O = E.useMemo(
1086
+ () => Y(
1087
+ {
1088
+ "--bk-padder-width": f ?? "fit-content",
1089
+ "--bk-padder-height": i ?? "fit-content",
1090
+ "--bk-padder-base": `${g.base}px`,
1091
+ "--bk-padder-color": g.color,
1092
+ ...y ? {} : {
1093
+ paddingBlock: `${S}px ${k}px`,
1094
+ paddingInline: `${C}px ${_}px`
1095
+ }
1096
+ },
1097
+ a
1098
+ ),
1099
+ [f, i, g.base, g.color, y, S, _, k, C, a]
1100
+ ), $ = (A, W) => /* @__PURE__ */ R.jsx(
1101
+ Nt,
1102
+ {
1103
+ debugging: T,
1104
+ indicatorNode: o,
1105
+ height: W,
1106
+ width: A
1107
+ }
1108
+ );
1109
+ return /* @__PURE__ */ R.jsxs(
1110
+ "div",
1111
+ {
1112
+ ref: w,
1113
+ className: D(
1114
+ Fe.padder,
1115
+ b && Fe.visible,
1116
+ r
1117
+ ),
1118
+ "data-testid": "padder",
1119
+ style: O,
1120
+ children: [
1121
+ y && /* @__PURE__ */ R.jsxs(R.Fragment, { children: [
1122
+ S > 0 && $("100%", S),
1123
+ C > 0 && $(C, "100%")
1124
+ ] }),
1125
+ n,
1126
+ y && /* @__PURE__ */ R.jsxs(R.Fragment, { children: [
1127
+ k > 0 && $("100%", k),
1128
+ _ > 0 && $(_, "100%")
1129
+ ] })
1130
+ ]
1131
+ }
1132
+ );
1133
+ })
1134
+ ), Wt = "layout_Re9ui", Gt = "visible_plo0X", Le = {
1135
+ layout: Wt,
1136
+ visible: Gt
1137
+ };
1138
+ function He(t) {
1139
+ return typeof t == "number" ? `repeat(${t}, 1fr)` : typeof t == "string" ? t : Array.isArray(t) ? t.map((n) => typeof n == "number" ? `${n}px` : n).join(" ") : "repeat(auto-fit, minmax(100px, 1fr))";
1140
+ }
1141
+ const tn = E.memo(
1142
+ function({
1143
+ children: n,
1144
+ columns: r,
1145
+ rows: s,
1146
+ rowGap: i,
1147
+ columnGap: o,
1148
+ gap: a,
1149
+ height: f,
1150
+ width: d,
1151
+ indicatorNode: l,
1152
+ justifyItems: g,
1153
+ alignItems: x,
1154
+ justifyContent: b,
1155
+ alignContent: h,
1156
+ className: T,
1157
+ variant: y,
1158
+ style: p,
1159
+ debugging: S,
1160
+ ...C
1161
+ }) {
1162
+ const k = Q("layout"), { isShown: _ } = Z(S, k.debugging), w = E.useRef(null), O = E.useMemo(
1163
+ () => J(C),
1164
+ [C]
1165
+ ), { padding: $ } = fe(w, {
1166
+ base: k.base,
1167
+ snapping: "height",
1168
+ spacing: O,
1169
+ warnOnMisalignment: !0
1170
+ }), A = E.useMemo(
1171
+ () => He(r),
1172
+ [r]
1173
+ ), W = E.useMemo(
1174
+ () => s ? He(s) : "auto",
1175
+ [s]
1176
+ ), z = E.useMemo(() => ({
1177
+ rowGap: i,
1178
+ columnGap: o,
1179
+ ...a !== void 0 && { gap: a }
1180
+ }), [i, o, a]), N = E.useMemo(() => Y(
1181
+ {
1182
+ display: "grid",
1183
+ gridTemplateColumns: A,
1184
+ gridTemplateRows: W,
1185
+ rowGap: i,
1186
+ columnGap: o,
1187
+ justifyItems: g,
1188
+ alignItems: x,
1189
+ justifyContent: b,
1190
+ alignContent: h,
1191
+ width: d,
1192
+ height: f,
1193
+ "--bk-layout-color-line": k.colors.line,
1194
+ "--bk-layout-color-flat": k.colors.flat,
1195
+ "--bk-layout-color-indice": k.colors.indice
1196
+ },
1197
+ p
1198
+ ), [A, W, i, o, g, x, b, h, d, f, k.colors.line, k.colors.flat, k.colors.indice, p]);
1199
+ return /* @__PURE__ */ R.jsx(we, { spacer: { variant: y }, children: /* @__PURE__ */ R.jsx(
1200
+ Se,
1201
+ {
1202
+ ref: w,
1203
+ "data-testid": "layout",
1204
+ block: [$.top, $.bottom],
1205
+ indicatorNode: l,
1206
+ inline: [$.left, $.right],
1207
+ debugging: S,
1208
+ width: d,
1209
+ height: f,
1210
+ children: /* @__PURE__ */ R.jsx(
1211
+ "div",
1212
+ {
1213
+ className: D(
1214
+ T,
1215
+ Le.layout,
1216
+ _ && Le.visible
1217
+ ),
1218
+ style: Y(N, z),
1219
+ children: n
1220
+ }
1221
+ )
1222
+ }
1223
+ ) });
1224
+ }
1225
+ ), Pt = "box_LHy8B", Yt = "visible_VOFS8", Xe = {
1226
+ box: Pt,
1227
+ visible: Yt
1228
+ }, nn = E.memo(
1229
+ E.forwardRef(function({
1230
+ children: n,
1231
+ snapping: r = "clamp",
1232
+ debugging: s,
1233
+ className: i,
1234
+ colSpan: o,
1235
+ rowSpan: a,
1236
+ span: f,
1237
+ width: d,
1238
+ height: l,
1239
+ style: g,
1240
+ ...x
1241
+ }, b) {
1242
+ const h = Q("box"), { isShown: T, debugging: y } = Z(s, h.debugging), p = E.useRef(null), { top: S, bottom: C, left: k, right: _ } = J(x), { padding: w } = fe(p, {
1243
+ base: h.base,
1244
+ snapping: r,
1245
+ spacing: { top: S, bottom: C, left: k, right: _ },
1246
+ warnOnMisalignment: y !== "none"
1247
+ }), O = E.useMemo(() => {
1248
+ const A = {};
1249
+ return f !== void 0 ? (A.gridColumn = `span ${f}`, A.gridRow = `span ${f}`) : (o !== void 0 && (A.gridColumn = `span ${o}`), a !== void 0 && (A.gridRow = `span ${a}`)), A;
1250
+ }, [o, a, f]), $ = E.useMemo(
1251
+ () => Y({
1252
+ "--bk-box-width": d,
1253
+ "--bk-box-height": l,
1254
+ "--bk-box-base": `${h.base}px`,
1255
+ "--bk-box-color-line": h.colors.line
1256
+ }, g),
1257
+ [h.base, h.colors.line, l, g, d]
1258
+ );
1259
+ return /* @__PURE__ */ R.jsx(
1260
+ "div",
1261
+ {
1262
+ ref: Ke(b, p),
1263
+ "data-testid": "box",
1264
+ className: D(Xe.box, T && Xe.visible, i),
1265
+ style: Y($, O),
1266
+ children: /* @__PURE__ */ R.jsx(
1267
+ we,
1268
+ {
1269
+ base: 1,
1270
+ spacer: {
1271
+ variant: "flat",
1272
+ colors: {
1273
+ flat: "var(--bk-box-color-flat-theme)",
1274
+ line: "var(--bk-box-color-line-theme)",
1275
+ indice: "var(--bk-box-color-indice-theme)"
1276
+ }
1277
+ },
1278
+ children: /* @__PURE__ */ R.jsx(
1279
+ Se,
1280
+ {
1281
+ block: [w.top, w.bottom],
1282
+ inline: [w.left, w.right],
1283
+ width: d,
1284
+ height: l,
1285
+ debugging: y,
1286
+ children: n
1287
+ }
1288
+ )
1289
+ }
1290
+ )
1291
+ }
1292
+ );
1293
+ })
1294
+ ), Bt = "stack_sXiLu", Ut = "visible_0IBG0", qe = {
1295
+ stack: Bt,
1296
+ visible: Ut
1297
+ }, rn = E.memo(function({
1298
+ align: n = "stretch",
1299
+ children: r,
1300
+ className: s,
1301
+ columnGap: i,
1302
+ debugging: o,
1303
+ direction: a = "row",
1304
+ gap: f,
1305
+ height: d,
1306
+ indicatorNode: l,
1307
+ justify: g = "flex-start",
1308
+ rowGap: x,
1309
+ style: b,
1310
+ variant: h,
1311
+ width: T,
1312
+ ...y
1313
+ }) {
1314
+ const p = Q("stack"), { isShown: S, debugging: C } = Z(o, p.debugging), k = E.useRef(null), _ = E.useMemo(() => J(y), [y]), { padding: w } = fe(k, {
1315
+ base: p.base,
1316
+ snapping: "height",
1317
+ spacing: _,
1318
+ warnOnMisalignment: !0
1319
+ }), O = E.useMemo(() => ({
1320
+ rowGap: x,
1321
+ columnGap: i,
1322
+ ...f !== void 0 && { gap: f }
1323
+ }), [x, i, f]), $ = E.useMemo(() => Y(
1324
+ {
1325
+ display: "flex",
1326
+ flexDirection: a,
1327
+ justifyContent: g,
1328
+ alignItems: n,
1329
+ width: T || "fit-content",
1330
+ height: d || "fit-content",
1331
+ "--bk-stack-color-line": p.colors.line,
1332
+ "--bk-stack-color-flat": p.colors.flat,
1333
+ "--bk-stack-color-indice": p.colors.indice
1334
+ },
1335
+ O,
1336
+ b
1337
+ ), [a, g, n, T, d, p.colors.line, p.colors.flat, p.colors.indice, O, b]), A = C === "none" ? {
1338
+ ...$,
1339
+ paddingBlock: `${w.top}px ${w.bottom}px`,
1340
+ paddingInline: `${w.left}px ${w.right}px`
1341
+ } : $;
1342
+ return /* @__PURE__ */ R.jsx(we, { spacer: { variant: h }, children: /* @__PURE__ */ R.jsx(
1343
+ Se,
1344
+ {
1345
+ ref: k,
1346
+ "data-testid": "padder",
1347
+ block: [w.top, w.bottom],
1348
+ inline: [w.left, w.right],
1349
+ debugging: C,
1350
+ indicatorNode: l,
1351
+ width: T,
1352
+ height: d,
1353
+ children: /* @__PURE__ */ R.jsx(
1354
+ "div",
1355
+ {
1356
+ "data-testid": "stack",
1357
+ className: D(
1358
+ s,
1359
+ qe.stack,
1360
+ S && qe.visible
1361
+ ),
1362
+ style: A,
1363
+ ...y,
1364
+ children: r
1365
+ }
1366
+ )
1367
+ }
1368
+ ) });
1369
+ }), zt = "guide_gY3kY", It = "line_xcGxq", Ft = "columns_eQm6d", Lt = "column_mYoBn", ee = {
1370
+ guide: zt,
1371
+ line: It,
1372
+ columns: Ft,
1373
+ column: Lt
1374
+ }, on = De(function({
1375
+ className: n,
1376
+ debugging: r,
1377
+ style: s,
1378
+ variant: i,
1379
+ align: o = "start",
1380
+ gap: a,
1381
+ height: f,
1382
+ width: d,
1383
+ columns: l,
1384
+ columnWidth: g,
1385
+ ...x
1386
+ }) {
1387
+ const b = Q("guide"), h = i ?? b.variant, { isShown: T } = Z(r, b.debugging), y = ie(null), { width: p, height: S } = ue(y), { top: C, right: k, bottom: _, left: w } = P(() => J(x), [x]), O = P(() => {
1388
+ const N = ce(a);
1389
+ return {
1390
+ line: {
1391
+ variant: "line",
1392
+ gap: N - 1,
1393
+ base: b.base
1394
+ },
1395
+ auto: g ? {
1396
+ variant: "auto",
1397
+ columnWidth: g,
1398
+ gap: N,
1399
+ base: b.base
1400
+ } : null,
1401
+ pattern: Array.isArray(l) ? {
1402
+ variant: "pattern",
1403
+ columns: l,
1404
+ gap: N,
1405
+ base: b.base
1406
+ } : null,
1407
+ fixed: typeof l == "number" ? {
1408
+ variant: "fixed",
1409
+ columns: l,
1410
+ columnWidth: g,
1411
+ gap: N,
1412
+ base: b.base
1413
+ } : null
1414
+ }[h] ?? {
1415
+ variant: "line",
1416
+ gap: N - 1,
1417
+ base: b.base
1418
+ };
1419
+ }, [a, b.base, g, l, h]), {
1420
+ template: $,
1421
+ columnsCount: A,
1422
+ calculatedGap: W
1423
+ } = yt(y, O), z = P(() => {
1424
+ const N = {
1425
+ "--bk-guide-gap": `${W}px`,
1426
+ "--bk-guide-justify": o,
1427
+ "--bk-guide-color-line": b.colors.line,
1428
+ "--bk-guide-color-pattern": b.colors.pattern,
1429
+ "--bk-guide-padding-block": `${C}px ${_}px`,
1430
+ "--bk-guide-padding-inline": `${w}px ${k}px`,
1431
+ "--bk-guide-template": $,
1432
+ "--bk-guide-width": (d ?? p) || "100vw",
1433
+ "--bk-guide-height": (f ?? S) || "100vh"
1434
+ };
1435
+ return Y(N, s);
1436
+ }, [
1437
+ W,
1438
+ o,
1439
+ b.colors.line,
1440
+ b.colors.pattern,
1441
+ C,
1442
+ _,
1443
+ w,
1444
+ k,
1445
+ $,
1446
+ d,
1447
+ p,
1448
+ f,
1449
+ S,
1450
+ s
1451
+ ]);
1452
+ return /* @__PURE__ */ R.jsx(
1453
+ "div",
1454
+ {
1455
+ ref: y,
1456
+ className: D(
1457
+ ee.guide,
1458
+ n,
1459
+ T ? ee.visible : ee.hidden,
1460
+ h === "line" && ee.line
1461
+ ),
1462
+ "data-testid": "guide",
1463
+ "data-variant": h,
1464
+ style: z,
1465
+ ...x,
1466
+ children: T && /* @__PURE__ */ R.jsx("div", { className: ee.columns, "data-variant": h, children: Array.from({ length: A }, (N, G) => {
1467
+ const F = b.colors[h] ?? b.colors.line;
1468
+ return /* @__PURE__ */ R.jsx(
1469
+ "div",
1470
+ {
1471
+ className: ee.column,
1472
+ "data-column-index": G,
1473
+ "data-variant": h,
1474
+ style: { backgroundColor: F }
1475
+ },
1476
+ G
1477
+ );
1478
+ }) })
1479
+ }
1480
+ );
1481
+ }), Ht = /^\d*\.?\d+(?:fr|px|%|em|rem|vh|vw|vmin|vmax|pt|pc|in|cm|mm)$/, Xt = (t) => typeof t == "number" ? Number.isFinite(t) && t >= 0 : typeof t != "string" ? !1 : t === "auto" || t === "100%" || Ht.test(t), qt = (t) => Array.isArray(t) && t.length > 0 && t.every(Xt), sn = (t) => {
1482
+ const n = [...Object.keys(xe), ...Qe];
1483
+ return typeof t == "number" || typeof t == "string" && n.some((r) => t.endsWith(r));
1484
+ }, an = (t) => typeof t == "string" && Dt.includes(t), Ce = (t) => typeof t == "object" && t !== null, ln = (t) => Ce(t) && t.variant === "line", cn = (t) => Ce(t) && "columns" in t && !("variant" in t), un = (t) => Ce(t) && "columnWidth" in t && !("variant" in t) && !("columns" in t), Jt = "baseline_CUi4a", pe = {
1485
+ baseline: Jt
1486
+ }, fn = De(function({
1487
+ className: n,
1488
+ debugging: r,
1489
+ style: s,
1490
+ variant: i,
1491
+ height: o,
1492
+ width: a,
1493
+ base: f,
1494
+ ...d
1495
+ }) {
1496
+ const l = Q("baseline"), g = i ?? l.variant, x = f ?? l.base, { isShown: b } = Z(r, l.debugging), h = ie(null), { width: T, height: y } = ue(h), [p, S] = P(
1497
+ () => Ze([a, o], [T, y]),
1498
+ [a, o, T, y]
1499
+ ), { top: C, right: k, bottom: _, left: w } = P(() => J(d), [d]), O = P(() => {
1500
+ const G = (S ?? 0) - (C + _);
1501
+ return Math.max(1, Math.floor(G / x));
1502
+ }, [S, C, _, x]), { start: $, end: A } = vt({
1503
+ totalLines: O,
1504
+ lineHeight: x,
1505
+ containerRef: h,
1506
+ buffer: 160
1507
+ }), W = g === "line" ? l.colors.line : l.colors.flat, z = P(
1508
+ () => Y(
1509
+ {
1510
+ "--bk-baseline-width": p,
1511
+ padding: `${C}px ${k}px ${_}px ${w}px`,
1512
+ position: "absolute",
1513
+ inset: 0,
1514
+ pointerEvents: "none",
1515
+ overflow: "hidden",
1516
+ height: `${S}px`
1517
+ },
1518
+ s
1519
+ ),
1520
+ [p, C, k, _, w, S, s]
1521
+ ), N = le(
1522
+ (G) => Y({
1523
+ top: `${G * x}px`,
1524
+ left: 0,
1525
+ right: 0,
1526
+ height: g === "line" ? "1px" : `${x}px`,
1527
+ backgroundColor: W,
1528
+ position: "absolute"
1529
+ }),
1530
+ [x, g, W]
1531
+ );
1532
+ return /* @__PURE__ */ R.jsx(
1533
+ "div",
1534
+ {
1535
+ ref: h,
1536
+ "data-testid": "baseline",
1537
+ className: D(pe.baseline, b ? pe.visible : pe.hidden, n),
1538
+ style: z,
1539
+ ...d,
1540
+ children: b && Array.from({ length: A - $ }, (G, F) => {
1541
+ const L = F + $;
1542
+ return /* @__PURE__ */ R.jsx("div", { "data-row-index": L, style: N(L) }, L);
1543
+ })
1544
+ }
1545
+ );
1546
+ }), Dt = ["start", "center", "end"], dn = ["line", "flat"];
1547
+ export {
1548
+ xe as ABSOLUTE_UNIT_CONVERSIONS,
1549
+ fn as Baseline,
1550
+ nn as Box,
1551
+ we as Config,
1552
+ Tt as DEFAULT_CONFIG,
1553
+ Dt as GRID_ALIGNMENTS,
1554
+ on as Guide,
1555
+ tn as Layout,
1556
+ dn as PADD_VARIANTS,
1557
+ Se as Padder,
1558
+ Qe as RELATIVE_UNITS,
1559
+ Nt as Spacer,
1560
+ rn as Stack,
1561
+ ht as calculateSnappedSpacing,
1562
+ dt as clamp,
1563
+ ke as convertValue,
1564
+ $t as createCSSVariables,
1565
+ en as debounce,
1566
+ ve as formatValue,
1567
+ un as isAutoCalculatedGuide,
1568
+ an as isGuideAlignment,
1569
+ cn as isGuideColumnConfig,
1570
+ ln as isGuideLineConfig,
1571
+ sn as isGuideValue,
1572
+ Xt as isValidGuideColumnValue,
1573
+ qt as isValidGuidePattern,
1574
+ D as mergeClasses,
1575
+ Ke as mergeRefs,
1576
+ Y as mergeStyles,
1577
+ Zt as moduloize,
1578
+ ce as normalizeValue,
1579
+ Ze as normalizeValuePair,
1580
+ J as parsePadding,
1581
+ ut as parseUnit,
1582
+ et as rafThrottle,
1583
+ Kt as round,
1584
+ fe as useBaseline,
1585
+ Q as useConfig,
1586
+ Z as useDebug,
1587
+ tt as useDefaultConfig,
1588
+ yt as useGuide,
1589
+ ue as useMeasure,
1590
+ vt as useVirtual
1591
+ };
1592
+ //# sourceMappingURL=index.mjs.map