@drawnagency/primitives 0.1.57 → 0.1.58

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.
@@ -16,6 +16,7 @@ import {
16
16
  safeNextPath
17
17
  } from "../chunk-S2L3BPLS.js";
18
18
  import "../chunk-WKZ7OENC.js";
19
+ import "../chunk-JSBRDJBE.js";
19
20
  export {
20
21
  AUDIENCE_COOKIE,
21
22
  AUDIENCE_MAX_AGE_SECONDS,
@@ -13,77 +13,9 @@ import {
13
13
  blockDepth
14
14
  } from "./chunk-NSCT3AMV.js";
15
15
  import {
16
- getAllSchemas,
17
- getSection
16
+ getAllSchemas
18
17
  } from "./chunk-VKAGMEKE.js";
19
18
 
20
- // src/lib/cn.ts
21
- import { clsx } from "clsx";
22
- import { twMerge } from "tailwind-merge";
23
- function cn(...inputs) {
24
- return twMerge(clsx(inputs));
25
- }
26
-
27
- // src/lib/nav.ts
28
- function toSectionId(text) {
29
- const slug = text.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/^-+|-+$/g, "");
30
- if (slug) return slug;
31
- let hash = 0;
32
- for (let i = 0; i < text.length; i++) {
33
- hash = (hash << 5) - hash + text.charCodeAt(i) | 0;
34
- }
35
- return `section-${Math.abs(hash).toString(36)}`;
36
- }
37
- function generateNavLinks(sections, registry) {
38
- const nav = [];
39
- let currentParent = null;
40
- let currentChild = null;
41
- const lookupRole = (type) => {
42
- const def = registry ? registry.getSection(type) : getSection(type);
43
- return def?.navRole;
44
- };
45
- for (const { section, meta } of sections) {
46
- const content = section.content;
47
- if (!content.heading) continue;
48
- const role = lookupRole(section.type);
49
- if (!role) continue;
50
- if (role === "h1") {
51
- if (content.excludeFromNav) {
52
- currentParent = null;
53
- continue;
54
- }
55
- currentParent = {
56
- href: `#${toSectionId(content.heading)}`,
57
- label: content.heading,
58
- status: meta.status,
59
- children: []
60
- };
61
- currentChild = null;
62
- nav.push(currentParent);
63
- } else if (role === "h2") {
64
- if (content.excludeFromNav) continue;
65
- if (!currentParent) continue;
66
- currentChild = {
67
- href: `#${toSectionId(content.heading)}`,
68
- label: content.heading,
69
- status: meta.status,
70
- children: []
71
- };
72
- currentParent.children.push(currentChild);
73
- } else if (role === "h3") {
74
- if (content.excludeFromNav) continue;
75
- if (!currentChild) continue;
76
- currentChild.children.push({
77
- href: `#${toSectionId(content.heading)}`,
78
- label: content.heading,
79
- status: meta.status,
80
- children: []
81
- });
82
- }
83
- }
84
- return nav;
85
- }
86
-
87
19
  // src/lib/contrast.ts
88
20
  function deriveContrast(hex) {
89
21
  const h = hex.replace("#", "");
@@ -95,36 +27,6 @@ function deriveContrast(hex) {
95
27
  return luminance >= 0.5 ? "#1a1a1a" : "#f0f0f0";
96
28
  }
97
29
 
98
- // src/lib/sanitize.ts
99
- var purifierPromise = null;
100
- var purifier = null;
101
- if (typeof window !== "undefined") {
102
- purifierPromise = import("dompurify").then((mod) => {
103
- const DOMPurify = mod.default ?? mod;
104
- purifier = (html) => DOMPurify.sanitize(html);
105
- return mod;
106
- });
107
- }
108
- var sanitizeCache = /* @__PURE__ */ new Map();
109
- var SANITIZE_CACHE_LIMIT = 500;
110
- function sanitizeHtml(html) {
111
- if (!html) return "";
112
- if (!purifier) return html;
113
- const cached = sanitizeCache.get(html);
114
- if (cached !== void 0) return cached;
115
- const clean = purifier(html);
116
- if (sanitizeCache.size >= SANITIZE_CACHE_LIMIT) {
117
- const oldest = sanitizeCache.keys().next().value;
118
- if (oldest !== void 0) sanitizeCache.delete(oldest);
119
- }
120
- sanitizeCache.set(html, clean);
121
- return clean;
122
- }
123
- async function ensureSanitizer() {
124
- if (typeof window === "undefined") return;
125
- if (!purifier && purifierPromise) await purifierPromise;
126
- }
127
-
128
30
  // src/lib/grid.ts
129
31
  var gridColsClass = {
130
32
  1: "grid-cols-1",
@@ -134,56 +36,6 @@ var gridColsClass = {
134
36
  5: "grid-cols-2 min-sm:grid-cols-3 lg:grid-cols-5"
135
37
  };
136
38
 
137
- // src/lib/icons.ts
138
- import {
139
- Check,
140
- X,
141
- ArrowRight,
142
- Star,
143
- Info,
144
- AlertTriangle,
145
- Heart,
146
- Lightbulb,
147
- Flag,
148
- Shield,
149
- Zap,
150
- Eye,
151
- Lock,
152
- Globe,
153
- Users,
154
- Target,
155
- Bookmark,
156
- Clock,
157
- ThumbsUp,
158
- ThumbsDown
159
- } from "lucide-react";
160
- var curatedIcons = [
161
- { id: "check", label: "Check", icon: Check },
162
- { id: "x", label: "X", icon: X },
163
- { id: "arrow-right", label: "Arrow Right", icon: ArrowRight },
164
- { id: "star", label: "Star", icon: Star },
165
- { id: "info", label: "Info", icon: Info },
166
- { id: "alert-triangle", label: "Warning", icon: AlertTriangle },
167
- { id: "heart", label: "Heart", icon: Heart },
168
- { id: "lightbulb", label: "Lightbulb", icon: Lightbulb },
169
- { id: "flag", label: "Flag", icon: Flag },
170
- { id: "shield", label: "Shield", icon: Shield },
171
- { id: "zap", label: "Zap", icon: Zap },
172
- { id: "eye", label: "Eye", icon: Eye },
173
- { id: "lock", label: "Lock", icon: Lock },
174
- { id: "globe", label: "Globe", icon: Globe },
175
- { id: "users", label: "Users", icon: Users },
176
- { id: "target", label: "Target", icon: Target },
177
- { id: "bookmark", label: "Bookmark", icon: Bookmark },
178
- { id: "clock", label: "Clock", icon: Clock },
179
- { id: "thumbs-up", label: "Thumbs Up", icon: ThumbsUp },
180
- { id: "thumbs-down", label: "Thumbs Down", icon: ThumbsDown }
181
- ];
182
- var iconMap = new Map(curatedIcons.map((e) => [e.id, e]));
183
- function getIcon(id) {
184
- return iconMap.get(id);
185
- }
186
-
187
39
  // src/lib/google-fonts.ts
188
40
  function buildGoogleFontsUrl(headingFont, bodyFont) {
189
41
  const fonts = /* @__PURE__ */ new Set();
@@ -304,15 +156,8 @@ async function loadSiteContent(contentDir) {
304
156
  }
305
157
 
306
158
  export {
307
- cn,
308
- toSectionId,
309
- generateNavLinks,
310
159
  deriveContrast,
311
- sanitizeHtml,
312
- ensureSanitizer,
313
160
  gridColsClass,
314
- curatedIcons,
315
- getIcon,
316
161
  buildGoogleFontsUrl,
317
162
  formatTimestamp,
318
163
  safeRedirect,
@@ -0,0 +1,73 @@
1
+ import {
2
+ __commonJS
3
+ } from "./chunk-JSBRDJBE.js";
4
+
5
+ // ../../node_modules/.pnpm/@babel+runtime@7.29.2/node_modules/@babel/runtime/helpers/typeof.js
6
+ var require_typeof = __commonJS({
7
+ "../../node_modules/.pnpm/@babel+runtime@7.29.2/node_modules/@babel/runtime/helpers/typeof.js"(exports, module) {
8
+ "use strict";
9
+ function _typeof(o) {
10
+ "@babel/helpers - typeof";
11
+ return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
12
+ return typeof o2;
13
+ } : function(o2) {
14
+ return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
15
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
16
+ }
17
+ module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
18
+ }
19
+ });
20
+
21
+ // ../../node_modules/.pnpm/@babel+runtime@7.29.2/node_modules/@babel/runtime/helpers/toPrimitive.js
22
+ var require_toPrimitive = __commonJS({
23
+ "../../node_modules/.pnpm/@babel+runtime@7.29.2/node_modules/@babel/runtime/helpers/toPrimitive.js"(exports, module) {
24
+ "use strict";
25
+ var _typeof = require_typeof()["default"];
26
+ function toPrimitive(t, r) {
27
+ if ("object" != _typeof(t) || !t) return t;
28
+ var e = t[Symbol.toPrimitive];
29
+ if (void 0 !== e) {
30
+ var i = e.call(t, r || "default");
31
+ if ("object" != _typeof(i)) return i;
32
+ throw new TypeError("@@toPrimitive must return a primitive value.");
33
+ }
34
+ return ("string" === r ? String : Number)(t);
35
+ }
36
+ module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
37
+ }
38
+ });
39
+
40
+ // ../../node_modules/.pnpm/@babel+runtime@7.29.2/node_modules/@babel/runtime/helpers/toPropertyKey.js
41
+ var require_toPropertyKey = __commonJS({
42
+ "../../node_modules/.pnpm/@babel+runtime@7.29.2/node_modules/@babel/runtime/helpers/toPropertyKey.js"(exports, module) {
43
+ "use strict";
44
+ var _typeof = require_typeof()["default"];
45
+ var toPrimitive = require_toPrimitive();
46
+ function toPropertyKey(t) {
47
+ var i = toPrimitive(t, "string");
48
+ return "symbol" == _typeof(i) ? i : i + "";
49
+ }
50
+ module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
51
+ }
52
+ });
53
+
54
+ // ../../node_modules/.pnpm/@babel+runtime@7.29.2/node_modules/@babel/runtime/helpers/defineProperty.js
55
+ var require_defineProperty = __commonJS({
56
+ "../../node_modules/.pnpm/@babel+runtime@7.29.2/node_modules/@babel/runtime/helpers/defineProperty.js"(exports, module) {
57
+ "use strict";
58
+ var toPropertyKey = require_toPropertyKey();
59
+ function _defineProperty(e, r, t) {
60
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
61
+ value: t,
62
+ enumerable: true,
63
+ configurable: true,
64
+ writable: true
65
+ }) : e[r] = t, e;
66
+ }
67
+ module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
68
+ }
69
+ });
70
+
71
+ export {
72
+ require_defineProperty
73
+ };
@@ -0,0 +1,30 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ export {
28
+ __commonJS,
29
+ __toESM
30
+ };
@@ -0,0 +1,160 @@
1
+ import {
2
+ getSection
3
+ } from "./chunk-VKAGMEKE.js";
4
+
5
+ // src/lib/cn.ts
6
+ import { clsx } from "clsx";
7
+ import { twMerge } from "tailwind-merge";
8
+ function cn(...inputs) {
9
+ return twMerge(clsx(inputs));
10
+ }
11
+
12
+ // src/lib/nav.ts
13
+ function toSectionId(text) {
14
+ const slug = text.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/^-+|-+$/g, "");
15
+ if (slug) return slug;
16
+ let hash = 0;
17
+ for (let i = 0; i < text.length; i++) {
18
+ hash = (hash << 5) - hash + text.charCodeAt(i) | 0;
19
+ }
20
+ return `section-${Math.abs(hash).toString(36)}`;
21
+ }
22
+ function generateNavLinks(sections, registry) {
23
+ const nav = [];
24
+ let currentParent = null;
25
+ let currentChild = null;
26
+ const lookupRole = (type) => {
27
+ const def = registry ? registry.getSection(type) : getSection(type);
28
+ return def?.navRole;
29
+ };
30
+ for (const { section, meta } of sections) {
31
+ const content = section.content;
32
+ if (!content.heading) continue;
33
+ const role = lookupRole(section.type);
34
+ if (!role) continue;
35
+ if (role === "h1") {
36
+ if (content.excludeFromNav) {
37
+ currentParent = null;
38
+ continue;
39
+ }
40
+ currentParent = {
41
+ href: `#${toSectionId(content.heading)}`,
42
+ label: content.heading,
43
+ status: meta.status,
44
+ children: []
45
+ };
46
+ currentChild = null;
47
+ nav.push(currentParent);
48
+ } else if (role === "h2") {
49
+ if (content.excludeFromNav) continue;
50
+ if (!currentParent) continue;
51
+ currentChild = {
52
+ href: `#${toSectionId(content.heading)}`,
53
+ label: content.heading,
54
+ status: meta.status,
55
+ children: []
56
+ };
57
+ currentParent.children.push(currentChild);
58
+ } else if (role === "h3") {
59
+ if (content.excludeFromNav) continue;
60
+ if (!currentChild) continue;
61
+ currentChild.children.push({
62
+ href: `#${toSectionId(content.heading)}`,
63
+ label: content.heading,
64
+ status: meta.status,
65
+ children: []
66
+ });
67
+ }
68
+ }
69
+ return nav;
70
+ }
71
+
72
+ // src/lib/sanitize.ts
73
+ var purifierPromise = null;
74
+ var purifier = null;
75
+ if (typeof window !== "undefined") {
76
+ purifierPromise = import("dompurify").then((mod) => {
77
+ const DOMPurify = mod.default ?? mod;
78
+ purifier = (html) => DOMPurify.sanitize(html);
79
+ return mod;
80
+ });
81
+ }
82
+ var sanitizeCache = /* @__PURE__ */ new Map();
83
+ var SANITIZE_CACHE_LIMIT = 500;
84
+ function sanitizeHtml(html) {
85
+ if (!html) return "";
86
+ if (!purifier) return html;
87
+ const cached = sanitizeCache.get(html);
88
+ if (cached !== void 0) return cached;
89
+ const clean = purifier(html);
90
+ if (sanitizeCache.size >= SANITIZE_CACHE_LIMIT) {
91
+ const oldest = sanitizeCache.keys().next().value;
92
+ if (oldest !== void 0) sanitizeCache.delete(oldest);
93
+ }
94
+ sanitizeCache.set(html, clean);
95
+ return clean;
96
+ }
97
+ async function ensureSanitizer() {
98
+ if (typeof window === "undefined") return;
99
+ if (!purifier && purifierPromise) await purifierPromise;
100
+ }
101
+
102
+ // src/lib/icons.ts
103
+ import {
104
+ Check,
105
+ X,
106
+ ArrowRight,
107
+ Star,
108
+ Info,
109
+ AlertTriangle,
110
+ Heart,
111
+ Lightbulb,
112
+ Flag,
113
+ Shield,
114
+ Zap,
115
+ Eye,
116
+ Lock,
117
+ Globe,
118
+ Users,
119
+ Target,
120
+ Bookmark,
121
+ Clock,
122
+ ThumbsUp,
123
+ ThumbsDown
124
+ } from "lucide-react";
125
+ var curatedIcons = [
126
+ { id: "check", label: "Check", icon: Check },
127
+ { id: "x", label: "X", icon: X },
128
+ { id: "arrow-right", label: "Arrow Right", icon: ArrowRight },
129
+ { id: "star", label: "Star", icon: Star },
130
+ { id: "info", label: "Info", icon: Info },
131
+ { id: "alert-triangle", label: "Warning", icon: AlertTriangle },
132
+ { id: "heart", label: "Heart", icon: Heart },
133
+ { id: "lightbulb", label: "Lightbulb", icon: Lightbulb },
134
+ { id: "flag", label: "Flag", icon: Flag },
135
+ { id: "shield", label: "Shield", icon: Shield },
136
+ { id: "zap", label: "Zap", icon: Zap },
137
+ { id: "eye", label: "Eye", icon: Eye },
138
+ { id: "lock", label: "Lock", icon: Lock },
139
+ { id: "globe", label: "Globe", icon: Globe },
140
+ { id: "users", label: "Users", icon: Users },
141
+ { id: "target", label: "Target", icon: Target },
142
+ { id: "bookmark", label: "Bookmark", icon: Bookmark },
143
+ { id: "clock", label: "Clock", icon: Clock },
144
+ { id: "thumbs-up", label: "Thumbs Up", icon: ThumbsUp },
145
+ { id: "thumbs-down", label: "Thumbs Down", icon: ThumbsDown }
146
+ ];
147
+ var iconMap = new Map(curatedIcons.map((e) => [e.id, e]));
148
+ function getIcon(id) {
149
+ return iconMap.get(id);
150
+ }
151
+
152
+ export {
153
+ cn,
154
+ toSectionId,
155
+ generateNavLinks,
156
+ sanitizeHtml,
157
+ ensureSanitizer,
158
+ curatedIcons,
159
+ getIcon
160
+ };
@@ -0,0 +1,30 @@
1
+ import {
2
+ HexColorSchema
3
+ } from "./chunk-ICLXLWQ5.js";
4
+
5
+ // src/schemas/audience.ts
6
+ import { z } from "zod";
7
+ var AudienceNameSchema = z.string().min(1).max(32).regex(
8
+ /^[a-z0-9]([a-z0-9_-]*[a-z0-9])?$/,
9
+ "lowercase alphanumeric, dashes and underscores allowed"
10
+ );
11
+ var AudienceColorSchema = HexColorSchema.nullable();
12
+ function slugifyAudienceName(input) {
13
+ return input.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
14
+ }
15
+
16
+ // src/schemas/media-grid-options.ts
17
+ import { z as z2 } from "zod";
18
+ var MediaGridOptionsSchema = z2.object({
19
+ square: z2.boolean().optional(),
20
+ border: z2.boolean().optional(),
21
+ crop: z2.boolean().optional(),
22
+ showCaptions: z2.boolean().optional()
23
+ }).default({});
24
+
25
+ export {
26
+ AudienceNameSchema,
27
+ AudienceColorSchema,
28
+ slugifyAudienceName,
29
+ MediaGridOptionsSchema
30
+ };
@@ -0,0 +1,29 @@
1
+ // src/schemas/link.ts
2
+ import { z } from "zod";
3
+ var LinkTargetSchema = z.enum(["_self", "_blank"]);
4
+ function isSafeHref(href) {
5
+ const normalized = href.replace(/[\t\r\n]/g, "").trimStart();
6
+ if (normalized === "") return true;
7
+ if (normalized.startsWith("//")) return false;
8
+ const scheme = /^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(normalized);
9
+ if (!scheme) return true;
10
+ const s = scheme[1].toLowerCase();
11
+ return s === "http" || s === "https" || s === "mailto";
12
+ }
13
+ var LinkValueSchema = z.discriminatedUnion("kind", [
14
+ z.object({ kind: z.literal("external"), href: z.string().refine(isSafeHref, "Unsafe href scheme"), target: LinkTargetSchema }),
15
+ z.object({
16
+ kind: z.literal("internal"),
17
+ pageId: z.string(),
18
+ anchorSectionId: z.string().nullable().optional(),
19
+ target: LinkTargetSchema
20
+ })
21
+ ]);
22
+ var DEFAULT_LINK = { kind: "external", href: "", target: "_self" };
23
+
24
+ export {
25
+ LinkTargetSchema,
26
+ isSafeHref,
27
+ LinkValueSchema,
28
+ DEFAULT_LINK
29
+ };
@@ -0,0 +1,72 @@
1
+ import {
2
+ require_defineProperty
3
+ } from "./chunk-ESE5UBQI.js";
4
+ import {
5
+ __toESM
6
+ } from "./chunk-JSBRDJBE.js";
7
+
8
+ // ../../node_modules/.pnpm/@atlaskit+pragmatic-drag-and-drop-hitbox@1.1.0/node_modules/@atlaskit/pragmatic-drag-and-drop-hitbox/dist/esm/closest-edge.js
9
+ var import_defineProperty = __toESM(require_defineProperty());
10
+ function ownKeys(e, r) {
11
+ var t = Object.keys(e);
12
+ if (Object.getOwnPropertySymbols) {
13
+ var o = Object.getOwnPropertySymbols(e);
14
+ r && (o = o.filter(function(r2) {
15
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
16
+ })), t.push.apply(t, o);
17
+ }
18
+ return t;
19
+ }
20
+ function _objectSpread(e) {
21
+ for (var r = 1; r < arguments.length; r++) {
22
+ var t = null != arguments[r] ? arguments[r] : {};
23
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
24
+ (0, import_defineProperty.default)(e, r2, t[r2]);
25
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
26
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
27
+ });
28
+ }
29
+ return e;
30
+ }
31
+ var getDistanceToEdge = {
32
+ top: function top(rect, client) {
33
+ return Math.abs(client.y - rect.top);
34
+ },
35
+ right: function right(rect, client) {
36
+ return Math.abs(rect.right - client.x);
37
+ },
38
+ bottom: function bottom(rect, client) {
39
+ return Math.abs(rect.bottom - client.y);
40
+ },
41
+ left: function left(rect, client) {
42
+ return Math.abs(client.x - rect.left);
43
+ }
44
+ };
45
+ var uniqueKey = /* @__PURE__ */ Symbol("closestEdge");
46
+ function attachClosestEdge(userData, _ref) {
47
+ var _entries$sort$0$edge, _entries$sort$;
48
+ var element = _ref.element, input = _ref.input, allowedEdges = _ref.allowedEdges;
49
+ var client = {
50
+ x: input.clientX,
51
+ y: input.clientY
52
+ };
53
+ var rect = element.getBoundingClientRect();
54
+ var entries = allowedEdges.map(function(edge) {
55
+ return {
56
+ edge,
57
+ value: getDistanceToEdge[edge](rect, client)
58
+ };
59
+ });
60
+ var addClosestEdge = (_entries$sort$0$edge = (_entries$sort$ = entries.sort(function(a, b) {
61
+ return a.value - b.value;
62
+ })[0]) === null || _entries$sort$ === void 0 ? void 0 : _entries$sort$.edge) !== null && _entries$sort$0$edge !== void 0 ? _entries$sort$0$edge : null;
63
+ return _objectSpread(_objectSpread({}, userData), {}, (0, import_defineProperty.default)({}, uniqueKey, addClosestEdge));
64
+ }
65
+ function extractClosestEdge(userData) {
66
+ var _ref2;
67
+ return (_ref2 = userData[uniqueKey]) !== null && _ref2 !== void 0 ? _ref2 : null;
68
+ }
69
+ export {
70
+ attachClosestEdge,
71
+ extractClosestEdge
72
+ };