@pixerate/editor-react 0.114.2 → 0.115.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 (42) hide show
  1. package/dist/animation-editor/index.cjs +361 -216
  2. package/dist/animation-editor/index.js +2 -2
  3. package/dist/canvas/index.cjs +539 -394
  4. package/dist/canvas/index.js +2 -2
  5. package/dist/{chunk-2INOKIJN.js → chunk-2KXZLZAS.js} +381 -364
  6. package/dist/{chunk-5LFQ2UQZ.js → chunk-5RPB4WGT.js} +240 -102
  7. package/dist/{chunk-BWEARAWR.js → chunk-6BWTJ3EE.js} +40 -18
  8. package/dist/effects/EffectParameters.d.cts +4 -1
  9. package/dist/effects/EffectParameters.d.ts +4 -1
  10. package/dist/effects/index.cjs +367 -222
  11. package/dist/effects/index.js +2 -2
  12. package/dist/image-editor/ImageEffectControls.d.cts +4 -1
  13. package/dist/image-editor/ImageEffectControls.d.ts +4 -1
  14. package/dist/image-editor/ImageProviderEffectsPanel.d.cts +4 -1
  15. package/dist/image-editor/ImageProviderEffectsPanel.d.ts +4 -1
  16. package/dist/image-editor/controls/controls.d.cts +19 -0
  17. package/dist/image-editor/controls/controls.d.ts +19 -0
  18. package/dist/image-editor/controls/parameterControls.d.cts +4 -0
  19. package/dist/image-editor/controls/parameterControls.d.ts +4 -0
  20. package/dist/image-editor/index.cjs +924 -765
  21. package/dist/image-editor/index.d.cts +1 -1
  22. package/dist/image-editor/index.d.ts +1 -1
  23. package/dist/image-editor/index.js +5 -3
  24. package/dist/index.cjs +1444 -1285
  25. package/dist/index.js +5 -3
  26. package/dist/paint-editor/index.cjs +354 -209
  27. package/dist/paint-editor/index.js +2 -2
  28. package/dist/parameters/ParametersPanel.d.cts +4 -1
  29. package/dist/parameters/ParametersPanel.d.ts +4 -1
  30. package/dist/parameters/controls.d.cts +92 -0
  31. package/dist/parameters/controls.d.ts +92 -0
  32. package/dist/parameters/fields.d.cts +20 -7
  33. package/dist/parameters/fields.d.ts +20 -7
  34. package/dist/parameters/index.cjs +369 -184
  35. package/dist/parameters/index.d.cts +1 -0
  36. package/dist/parameters/index.d.ts +1 -0
  37. package/dist/parameters/index.js +70 -14
  38. package/dist/vector/index.cjs +340 -195
  39. package/dist/vector/index.js +2 -2
  40. package/dist/video-editor/index.cjs +437 -292
  41. package/dist/video-editor/index.js +2 -2
  42. package/package.json +3 -3
@@ -34,6 +34,7 @@ __export(parameters_exports, {
34
34
  KeyframeDiamond: () => KeyframeDiamond,
35
35
  ParameterColor: () => ParameterColor,
36
36
  ParameterCommitInput: () => ParameterCommitInput,
37
+ ParameterComponentsProvider: () => ParameterComponentsProvider,
37
38
  ParameterFieldControl: () => ParameterFieldControl,
38
39
  ParameterImage: () => ParameterImage,
39
40
  ParameterNumberInput: () => ParameterNumberInput,
@@ -44,8 +45,14 @@ __export(parameters_exports, {
44
45
  ParameterVector: () => ParameterVector,
45
46
  ParametersPanel: () => ParametersPanel,
46
47
  parameterButtonClass: () => parameterButtonClass,
48
+ parameterButtonStyle: () => parameterButtonStyle,
47
49
  parameterInputClass: () => parameterInputClass,
50
+ parameterInputStyle: () => parameterInputStyle,
51
+ parameterRangeStyle: () => parameterRangeStyle,
52
+ parameterSelectStyle: () => parameterSelectStyle,
53
+ resolveParameterComponents: () => resolveParameterComponents,
48
54
  useParameterCommands: () => useParameterCommands,
55
+ useParameterComponents: () => useParameterComponents,
49
56
  useParameters: () => useParameters,
50
57
  useParametersController: () => useParametersController,
51
58
  useParametersState: () => useParametersState
@@ -105,7 +112,7 @@ function useParameterCommands(registry, controller, options = {}) {
105
112
  }
106
113
 
107
114
  // src/parameters/fields.tsx
108
- var import_react5 = require("react");
115
+ var import_react6 = require("react");
109
116
  var import_parameters2 = require("@pixerate/editor/parameters");
110
117
 
111
118
  // src/color/index.ts
@@ -1147,18 +1154,61 @@ function useResolvedColor(value, scheme) {
1147
1154
  // src/color/index.ts
1148
1155
  __reExport(color_exports, require("@pixerate/editor/color"));
1149
1156
 
1150
- // src/parameters/fields.tsx
1157
+ // src/parameters/controls.tsx
1158
+ var import_react5 = require("react");
1151
1159
  var import_jsx_runtime3 = require("react/jsx-runtime");
1160
+ var ParameterComponentsContext = (0, import_react5.createContext)({});
1161
+ function ParameterComponentsProvider({ components, children }) {
1162
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterComponentsContext.Provider, { value: components, children });
1163
+ }
1164
+ function useParameterComponents() {
1165
+ return (0, import_react5.useContext)(ParameterComponentsContext);
1166
+ }
1167
+ function resolveParameterComponents(explicit, context) {
1168
+ return {
1169
+ input: explicit?.input ?? context?.input,
1170
+ slider: explicit?.slider ?? context?.slider,
1171
+ select: explicit?.select ?? context?.select,
1172
+ color: explicit?.color ?? context?.color
1173
+ };
1174
+ }
1175
+
1176
+ // src/parameters/fields.tsx
1177
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1178
+ var parameterInputStyle = import_parameters2.parameterThemeStyles.input;
1179
+ var parameterSelectStyle = import_parameters2.parameterThemeStyles.select;
1180
+ var parameterButtonStyle = import_parameters2.parameterThemeStyles.button;
1181
+ var parameterRangeStyle = import_parameters2.parameterThemeStyles.range;
1152
1182
  var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-background px-2 text-xs text-foreground tabular-nums focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50";
1153
1183
  var parameterButtonClass = "inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50";
1154
1184
  var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
1155
- function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, ...rest }) {
1185
+ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
1186
+ const inputRef = (0, import_react6.useRef)(null);
1187
+ const lastCommitted = (0, import_react6.useRef)(null);
1188
+ (0, import_react6.useLayoutEffect)(() => {
1189
+ lastCommitted.current = null;
1190
+ const el = inputRef.current;
1191
+ if (el && el.value !== value) el.value = value;
1192
+ }, [value]);
1156
1193
  const commit = (el) => {
1157
- if (el.value !== value) onCommit(el.value, el);
1194
+ const text = el.value;
1195
+ if (text === value || text === lastCommitted.current) return;
1196
+ onCommit(text, el);
1197
+ lastCommitted.current = el.value === text ? text : null;
1158
1198
  };
1199
+ const commitRef = (0, import_react6.useRef)(commit);
1200
+ commitRef.current = commit;
1201
+ (0, import_react6.useEffect)(() => {
1202
+ const el = inputRef.current;
1203
+ if (!el) return;
1204
+ const change = () => commitRef.current(el);
1205
+ el.addEventListener("change", change);
1206
+ return () => el.removeEventListener("change", change);
1207
+ }, [multiline]);
1159
1208
  const keyDown = (e) => {
1160
1209
  onKeyDown?.(e);
1161
1210
  if (e.defaultPrevented) return;
1211
+ if (e.key === "Tab") commit(e.currentTarget);
1162
1212
  if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
1163
1213
  e.preventDefault();
1164
1214
  commit(e.currentTarget);
@@ -1168,86 +1218,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
1168
1218
  const props = {
1169
1219
  defaultValue: value,
1170
1220
  className: className ?? parameterInputClass,
1221
+ style: { ...parameterInputStyle, ...style },
1171
1222
  onBlur: (e) => commit(e.currentTarget),
1172
1223
  onKeyDown: keyDown,
1173
1224
  ...rest
1174
1225
  };
1175
- return multiline ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("input", { type: "text", ...props }, value);
1226
+ const forwarded = rest.ref;
1227
+ const setRef = (el) => {
1228
+ inputRef.current = el;
1229
+ if (typeof forwarded === "function") forwarded(el);
1230
+ else if (forwarded) forwarded.current = el;
1231
+ };
1232
+ return multiline ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "text", ...props, ref: setRef });
1176
1233
  }
1177
1234
  var plainNumber = (field, value) => (0, import_parameters2.formatParameterNumber)({ ...field, unit: void 0 }, value);
1178
- function ParameterNumberInput({
1179
- field,
1180
- value,
1181
- onChange,
1182
- disabled,
1183
- id,
1184
- "aria-label": ariaLabel
1185
- }) {
1186
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
1187
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1188
- ParameterCommitInput,
1189
- {
1190
- id,
1191
- inputMode: "decimal",
1192
- "aria-label": ariaLabel ?? (0, import_parameters2.parameterLabel)(field),
1193
- value: plainNumber(field, value),
1194
- disabled: disabled || field.readOnly,
1195
- className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
1196
- onCommit: (text, input) => {
1197
- const n = (0, import_parameters2.parseParameterNumberInput)(field, text);
1198
- if (n === null || n === value) input.value = plainNumber(field, value);
1199
- else onChange(n);
1200
- },
1201
- onKeyDown: (e) => {
1202
- if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
1203
- e.preventDefault();
1204
- const step = (0, import_parameters2.parameterStep)(field) * (e.shiftKey ? 10 : 1);
1205
- onChange((0, import_parameters2.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
1206
- }
1207
- }
1208
- ),
1209
- field.unit && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
1235
+ function ParameterNumberInput(props) {
1236
+ const { field, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
1237
+ const ctx = useParameterComponents();
1238
+ const resolved = resolveParameterComponents(components, ctx);
1239
+ const CustomInput = resolved.input;
1240
+ const plain = plainNumber(field, value);
1241
+ const handleCommit = (text, input) => {
1242
+ const n = (0, import_parameters2.parseParameterNumberInput)(field, text);
1243
+ if (n === null || n === value) {
1244
+ if (input) input.value = plain;
1245
+ } else {
1246
+ onChange(n);
1247
+ }
1248
+ };
1249
+ const handleKeyDown = (e) => {
1250
+ if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
1251
+ e.preventDefault();
1252
+ const step = (0, import_parameters2.parameterStep)(field) * (e.shiftKey ? 10 : 1);
1253
+ onChange((0, import_parameters2.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
1254
+ };
1255
+ const inputProps = {
1256
+ id,
1257
+ inputMode: "decimal",
1258
+ "aria-label": ariaLabel ?? (0, import_parameters2.parameterLabel)(field),
1259
+ value: plain,
1260
+ disabled: disabled || field.readOnly,
1261
+ className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
1262
+ style: parameterInputStyle,
1263
+ onCommit: handleCommit,
1264
+ onKeyDown: handleKeyDown
1265
+ };
1266
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
1267
+ CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters2.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterCommitInput, { ...inputProps }),
1268
+ field.unit && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
1210
1269
  ] });
1211
1270
  }
1212
1271
  function ParameterSlider(props) {
1213
- const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
1214
- const dragging = (0, import_react5.useRef)(false);
1272
+ const { field, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
1273
+ const ctx = useParameterComponents();
1274
+ const resolved = resolveParameterComponents(components, ctx);
1275
+ const CustomSlider = resolved.slider;
1276
+ const dragging = (0, import_react6.useRef)(false);
1277
+ const start = () => {
1278
+ if (dragging.current) return;
1279
+ dragging.current = true;
1280
+ onGestureStart?.();
1281
+ };
1215
1282
  const end = () => {
1216
1283
  if (!dragging.current) return;
1217
1284
  dragging.current = false;
1218
1285
  onGestureEnd?.();
1219
1286
  };
1220
- if (!(0, import_parameters2.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterNumberInput, { ...props });
1287
+ if (!(0, import_parameters2.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterNumberInput, { ...props });
1221
1288
  const step = (0, import_parameters2.parameterStep)(field);
1222
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-2", children: [
1223
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1289
+ const sliderProps = {
1290
+ "aria-label": (0, import_parameters2.parameterLabel)(field),
1291
+ "aria-valuetext": (0, import_parameters2.formatParameterNumber)(field, value),
1292
+ // A `control: 'slider'` field may leave out a bound: the range input's own defaults.
1293
+ min: field.min ?? 0,
1294
+ max: field.max ?? 100,
1295
+ step,
1296
+ value,
1297
+ disabled: disabled || field.readOnly,
1298
+ className: rangeClass,
1299
+ style: parameterRangeStyle
1300
+ };
1301
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-2", children: [
1302
+ CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1303
+ CustomSlider,
1304
+ {
1305
+ ...sliderProps,
1306
+ id: props.id ? `${props.id}-slider` : void 0,
1307
+ label: (0, import_parameters2.parameterLabel)(field),
1308
+ onChange: (v) => onChange((0, import_parameters2.clampParameterNumber)(field, v)),
1309
+ onGestureStart: start,
1310
+ onGestureEnd: end
1311
+ }
1312
+ ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1224
1313
  "input",
1225
1314
  {
1226
1315
  type: "range",
1227
- "aria-label": (0, import_parameters2.parameterLabel)(field),
1228
- "aria-valuetext": (0, import_parameters2.formatParameterNumber)(field, value),
1229
- min: field.min,
1230
- max: field.max,
1231
- step,
1232
- value,
1233
- disabled: disabled || field.readOnly,
1234
- className: rangeClass,
1235
- onPointerDown: () => {
1236
- if (dragging.current) return;
1237
- dragging.current = true;
1238
- onGestureStart?.();
1239
- },
1316
+ ...sliderProps,
1317
+ onPointerDown: start,
1240
1318
  onPointerUp: end,
1241
1319
  onPointerCancel: end,
1242
1320
  onBlur: end,
1243
1321
  onChange: (e) => onChange((0, import_parameters2.clampParameterNumber)(field, Number(e.target.value)))
1244
1322
  }
1245
1323
  ),
1246
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters2.parameterLabel)(field)} value` }) })
1324
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters2.parameterLabel)(field)} value` }) })
1247
1325
  ] });
1248
1326
  }
1249
1327
  function ParameterToggle({ field, value, onChange, disabled, id }) {
1250
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1328
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1251
1329
  "button",
1252
1330
  {
1253
1331
  type: "button",
@@ -1258,7 +1336,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
1258
1336
  disabled: disabled || field.readOnly,
1259
1337
  onClick: () => onChange(!value),
1260
1338
  className: `relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:opacity-50 ${value ? "bg-primary" : "bg-muted"}`,
1261
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1339
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1262
1340
  "span",
1263
1341
  {
1264
1342
  className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
@@ -1267,11 +1345,15 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
1267
1345
  }
1268
1346
  );
1269
1347
  }
1270
- function ParameterSelect({ field, value, onChange, disabled, id }) {
1348
+ function ParameterSelect(props) {
1349
+ const { field, value, onChange, disabled, id, components } = props;
1350
+ const ctx = useParameterComponents();
1351
+ const resolved = resolveParameterComponents(components, ctx);
1352
+ const CustomSelect = resolved.select;
1271
1353
  const options = (0, import_parameters2.getChoiceOptions)(field);
1272
1354
  const off = disabled || field.readOnly;
1273
1355
  if (field.control === "segmented") {
1274
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters2.parameterLabel)(field), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1356
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters2.parameterLabel)(field), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1275
1357
  "button",
1276
1358
  {
1277
1359
  type: "button",
@@ -1286,8 +1368,25 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
1286
1368
  String(o.value)
1287
1369
  )) });
1288
1370
  }
1371
+ if (CustomSelect) {
1372
+ const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters2.choiceOptionLabel)(o), description: o.description }));
1373
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1374
+ CustomSelect,
1375
+ {
1376
+ id,
1377
+ label: (0, import_parameters2.parameterLabel)(field),
1378
+ "aria-label": (0, import_parameters2.parameterLabel)(field),
1379
+ value,
1380
+ options: customOptions,
1381
+ disabled: off,
1382
+ className: parameterInputClass,
1383
+ style: parameterSelectStyle,
1384
+ onChange: (v) => onChange((0, import_parameters2.matchParameterOptionValue)(options, v))
1385
+ }
1386
+ );
1387
+ }
1289
1388
  const index = options.findIndex((o) => o.value === value);
1290
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1389
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1291
1390
  "select",
1292
1391
  {
1293
1392
  id,
@@ -1299,22 +1398,24 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
1299
1398
  if (option) onChange(option.value);
1300
1399
  },
1301
1400
  className: parameterInputClass,
1302
- children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters2.choiceOptionLabel)(o) }, String(o.value)))
1401
+ style: parameterSelectStyle,
1402
+ children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters2.choiceOptionLabel)(o) }, String(o.value)))
1303
1403
  }
1304
1404
  );
1305
1405
  }
1306
- function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
1307
- const [open, setOpen] = (0, import_react5.useState)(false);
1308
- const containerRef = (0, import_react5.useRef)(null);
1309
- const buttonRef = (0, import_react5.useRef)(null);
1310
- const popoverRef = (0, import_react5.useRef)(null);
1406
+ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
1407
+ const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
1408
+ const [open, setOpen] = (0, import_react6.useState)(false);
1409
+ const containerRef = (0, import_react6.useRef)(null);
1410
+ const buttonRef = (0, import_react6.useRef)(null);
1411
+ const popoverRef = (0, import_react6.useRef)(null);
1311
1412
  const alpha = !!field.alpha;
1312
1413
  const hex = (0, import_parameters2.normalizeHexColor)(value, true) ?? "#000000ff";
1313
1414
  const rgb = hex.slice(0, 7);
1314
1415
  const shown = alpha ? hex : rgb;
1315
1416
  const off = disabled || field.readOnly;
1316
1417
  const name = (0, import_parameters2.parameterLabel)(field);
1317
- (0, import_react5.useEffect)(() => {
1418
+ (0, import_react6.useEffect)(() => {
1318
1419
  if (!open) return;
1319
1420
  const onPointerDown = (e) => {
1320
1421
  if (containerRef.current && !containerRef.current.contains(e.target)) {
@@ -1335,9 +1436,25 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
1335
1436
  window.removeEventListener("keydown", onKeyDown, true);
1336
1437
  };
1337
1438
  }, [open]);
1338
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
1339
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-2", children: [
1340
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1439
+ if (CustomColor) {
1440
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1441
+ CustomColor,
1442
+ {
1443
+ id,
1444
+ value: shown,
1445
+ alpha,
1446
+ swatches: field.swatches,
1447
+ disabled: off,
1448
+ label: name,
1449
+ onChange,
1450
+ onGestureStart,
1451
+ onGestureEnd
1452
+ }
1453
+ );
1454
+ }
1455
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
1456
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-2", children: [
1457
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1341
1458
  "button",
1342
1459
  {
1343
1460
  ref: buttonRef,
@@ -1348,10 +1465,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
1348
1465
  disabled: off,
1349
1466
  onClick: () => setOpen((prev) => !prev),
1350
1467
  className: "relative h-7 w-9 shrink-0 overflow-hidden rounded-md border border-input bg-[repeating-conic-gradient(#d4d4d8_0_25%,#fff_0_50%)] bg-[length:8px_8px] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50",
1351
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
1468
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
1352
1469
  }
1353
1470
  ),
1354
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1471
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1355
1472
  ParameterCommitInput,
1356
1473
  {
1357
1474
  id,
@@ -1367,7 +1484,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
1367
1484
  }
1368
1485
  )
1369
1486
  ] }),
1370
- open && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1487
+ open && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1371
1488
  "div",
1372
1489
  {
1373
1490
  ref: popoverRef,
@@ -1381,7 +1498,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
1381
1498
  },
1382
1499
  className: "absolute left-0 top-full z-50 mt-1 w-64 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-xl",
1383
1500
  style: { background: "var(--popover, var(--background, #fff))" },
1384
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1501
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1385
1502
  ColorPicker,
1386
1503
  {
1387
1504
  value: shown,
@@ -1397,13 +1514,13 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
1397
1514
  )
1398
1515
  ] });
1399
1516
  }
1400
- function ParameterVector({ field, value, onChange, disabled, id }) {
1517
+ function ParameterVector({ field, value, onChange, disabled, id, components }) {
1401
1518
  const size = (0, import_parameters2.vectorSize)(field);
1402
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
1519
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
1403
1520
  const component = (0, import_parameters2.vectorComponentField)(field, i);
1404
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
1405
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
1406
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1521
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
1522
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
1523
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1407
1524
  ParameterNumberInput,
1408
1525
  {
1409
1526
  field: component,
@@ -1411,6 +1528,7 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
1411
1528
  id: i === 0 ? id : void 0,
1412
1529
  "aria-label": `${(0, import_parameters2.parameterLabel)(field)} ${component.label}`,
1413
1530
  disabled: disabled || field.readOnly,
1531
+ components,
1414
1532
  onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
1415
1533
  }
1416
1534
  )
@@ -1420,11 +1538,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
1420
1538
  function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
1421
1539
  const off = disabled || field.readOnly;
1422
1540
  const name = (0, import_parameters2.parameterLabel)(field);
1423
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "space-y-1.5", children: [
1424
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-2", children: [
1425
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "flex h-12 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input bg-muted", children: value ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
1426
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
1427
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1541
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "space-y-1.5", children: [
1542
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-2", children: [
1543
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex h-12 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input bg-muted", children: value ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
1544
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
1545
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1428
1546
  ParameterCommitInput,
1429
1547
  {
1430
1548
  id,
@@ -1435,30 +1553,48 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
1435
1553
  onCommit: (text) => onChange(text.trim())
1436
1554
  }
1437
1555
  ),
1438
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex gap-1", children: [
1439
- resolveFile && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
1440
- "Choose file\u2026",
1441
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1442
- "input",
1443
- {
1444
- type: "file",
1445
- className: "sr-only",
1446
- accept: field.accept ?? "image/*",
1447
- disabled: off,
1448
- "aria-label": `${name} file`,
1449
- onChange: async (e) => {
1450
- const file = e.target.files?.[0];
1451
- e.target.value = "";
1452
- if (file) onChange(await resolveFile(file));
1453
- }
1454
- }
1455
- )
1456
- ] }),
1457
- value && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
1556
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex gap-1", children: [
1557
+ resolveFile && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1558
+ "label",
1559
+ {
1560
+ style: parameterButtonStyle,
1561
+ className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
1562
+ children: [
1563
+ "Choose file\u2026",
1564
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1565
+ "input",
1566
+ {
1567
+ type: "file",
1568
+ className: "sr-only",
1569
+ accept: field.accept ?? "image/*",
1570
+ disabled: off,
1571
+ "aria-label": `${name} file`,
1572
+ onChange: async (e) => {
1573
+ const file = e.target.files?.[0];
1574
+ e.target.value = "";
1575
+ if (file) onChange(await resolveFile(file));
1576
+ }
1577
+ }
1578
+ )
1579
+ ]
1580
+ }
1581
+ ),
1582
+ value && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1583
+ "button",
1584
+ {
1585
+ type: "button",
1586
+ style: parameterButtonStyle,
1587
+ className: parameterButtonClass,
1588
+ disabled: off,
1589
+ onClick: () => onChange(""),
1590
+ "aria-label": `Clear ${name}`,
1591
+ children: "Clear"
1592
+ }
1593
+ )
1458
1594
  ] })
1459
1595
  ] })
1460
1596
  ] }),
1461
- field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1597
+ field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1462
1598
  "button",
1463
1599
  {
1464
1600
  type: "button",
@@ -1468,14 +1604,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
1468
1604
  disabled: off,
1469
1605
  onClick: () => onChange(o.url),
1470
1606
  className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
1471
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
1607
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
1472
1608
  },
1473
1609
  o.url
1474
1610
  )) })
1475
1611
  ] });
1476
1612
  }
1477
1613
  function ParameterText({ field, value, onChange, disabled, id }) {
1478
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1614
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1479
1615
  ParameterCommitInput,
1480
1616
  {
1481
1617
  id,
@@ -1491,7 +1627,7 @@ function ParameterText({ field, value, onChange, disabled, id }) {
1491
1627
  }
1492
1628
  function KeyframeDiamond({ state, onToggle, label, disabled, className = "" }) {
1493
1629
  const keyed = state === "keyed";
1494
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1630
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1495
1631
  "button",
1496
1632
  {
1497
1633
  type: "button",
@@ -1502,7 +1638,7 @@ function KeyframeDiamond({ state, onToggle, label, disabled, className = "" }) {
1502
1638
  disabled,
1503
1639
  onClick: onToggle,
1504
1640
  className: `inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:opacity-40 ${state === "none" ? "text-muted-foreground hover:text-foreground" : "text-amber-500"} ${className}`,
1505
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { viewBox: "0 0 10 10", className: "h-2.5 w-2.5", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1641
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { viewBox: "0 0 10 10", className: "h-2.5 w-2.5", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1506
1642
  "path",
1507
1643
  {
1508
1644
  d: "M5 0.8 9.2 5 5 9.2 0.8 5Z",
@@ -1520,48 +1656,48 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
1520
1656
  switch (field.type) {
1521
1657
  case "number":
1522
1658
  case "int":
1523
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
1659
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
1524
1660
  case "boolean":
1525
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
1661
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
1526
1662
  case "choice":
1527
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
1663
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
1528
1664
  case "color":
1529
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
1665
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
1530
1666
  case "vector":
1531
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
1667
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
1532
1668
  case "image":
1533
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
1669
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
1534
1670
  case "text":
1535
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterText, { field, value, onChange: set, ...rest });
1671
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterText, { field, value, onChange: set, ...rest });
1536
1672
  }
1537
1673
  }
1538
1674
 
1539
1675
  // src/parameters/ParametersPanel.tsx
1540
- var import_react10 = require("react");
1676
+ var import_react11 = require("react");
1541
1677
 
1542
1678
  // src/playback/AgentPlaybackContext.tsx
1543
- var import_react6 = require("react");
1544
- var import_jsx_runtime4 = require("react/jsx-runtime");
1545
- var AgentPlaybackContext = (0, import_react6.createContext)(null);
1679
+ var import_react7 = require("react");
1680
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1681
+ var AgentPlaybackContext = (0, import_react7.createContext)(null);
1546
1682
  function useAgentPlayback() {
1547
- return (0, import_react6.useContext)(AgentPlaybackContext);
1683
+ return (0, import_react7.useContext)(AgentPlaybackContext);
1548
1684
  }
1549
1685
 
1550
1686
  // src/playback/useElementPlaybackSurface.ts
1551
- var import_react8 = require("react");
1687
+ var import_react9 = require("react");
1552
1688
  var import_tools2 = require("@pixerate/editor/tools");
1553
1689
 
1554
1690
  // src/playback/usePlaybackSurface.ts
1555
- var import_react7 = require("react");
1691
+ var import_react8 = require("react");
1556
1692
  var import_tools = require("@pixerate/editor/tools");
1557
1693
  function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
1558
1694
  const ambient = useAgentPlayback();
1559
1695
  const target = playback === void 0 ? ambient : playback;
1560
- const [ownPresence] = (0, import_react7.useState)(() => new import_tools.PresenceStore());
1696
+ const [ownPresence] = (0, import_react8.useState)(() => new import_tools.PresenceStore());
1561
1697
  const presence = sharedPresence ?? ownPresence;
1562
- const latest = (0, import_react7.useRef)(options);
1698
+ const latest = (0, import_react8.useRef)(options);
1563
1699
  latest.current = options;
1564
- (0, import_react7.useEffect)(() => {
1700
+ (0, import_react8.useEffect)(() => {
1565
1701
  if (!target || !id) return;
1566
1702
  const o = () => latest.current;
1567
1703
  const surface = {
@@ -1594,7 +1730,7 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
1594
1730
 
1595
1731
  // src/playback/useElementPlaybackSurface.ts
1596
1732
  function useElementPlaybackSurface(playback, id, element, options) {
1597
- const latest = (0, import_react8.useRef)(options);
1733
+ const latest = (0, import_react9.useRef)(options);
1598
1734
  latest.current = options;
1599
1735
  const box = () => element.current?.getBoundingClientRect() ?? null;
1600
1736
  const fromViewport = (p) => {
@@ -1633,13 +1769,13 @@ function useElementPlaybackSurface(playback, id, element, options) {
1633
1769
  }
1634
1770
 
1635
1771
  // src/playback/PresenceLayer.tsx
1636
- var import_react9 = __toESM(require("react"), 1);
1637
- var import_jsx_runtime5 = require("react/jsx-runtime");
1772
+ var import_react10 = __toESM(require("react"), 1);
1773
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1638
1774
  function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
1639
- const { actors } = (0, import_react9.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
1775
+ const { actors } = (0, import_react10.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
1640
1776
  if (!actors.length) return null;
1641
1777
  const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
1642
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1778
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1643
1779
  "div",
1644
1780
  {
1645
1781
  className: `pixerate-presence ${className}`.trim(),
@@ -1653,19 +1789,19 @@ function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
1653
1789
  const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
1654
1790
  return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
1655
1791
  })();
1656
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react9.default.Fragment, { children: [
1657
- ring && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1792
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react10.default.Fragment, { children: [
1793
+ ring && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1658
1794
  "div",
1659
1795
  {
1660
1796
  "data-actor-focus": a.id,
1661
1797
  style: { position: "absolute", ...ring, borderRadius: 8, border: `2px solid ${a.color}`, background: `${a.color}14`, transition: "all 160ms ease-out" }
1662
1798
  }
1663
1799
  ),
1664
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${at.x}px, ${at.y}px)` }, children: [
1665
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "18", height: "20", viewBox: "0 0 12 18", style: { display: "block", transform: a.pressed ? "scale(0.85)" : void 0, transformOrigin: "0 0", filter: "drop-shadow(0 1px 2px rgba(0,0,0,.35))" }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 } }) }),
1666
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { style: { position: "absolute", left: 14, top: 16, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 4 }, children: [
1667
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { whiteSpace: "nowrap", borderRadius: 999, padding: "1px 7px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.name }),
1668
- a.message && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-actor-message": a.id, style: { width: "max-content", maxWidth: 240, borderRadius: 8, borderTopLeftRadius: 0, padding: "4px 8px", fontSize: 12, color: "#1e293b", background: "#ffffff", boxShadow: "0 4px 12px rgba(15,23,42,.18)" }, children: a.message })
1800
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${at.x}px, ${at.y}px)` }, children: [
1801
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { width: "18", height: "20", viewBox: "0 0 12 18", style: { display: "block", transform: a.pressed ? "scale(0.85)" : void 0, transformOrigin: "0 0", filter: "drop-shadow(0 1px 2px rgba(0,0,0,.35))" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 } }) }),
1802
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { style: { position: "absolute", left: 14, top: 16, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 4 }, children: [
1803
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { whiteSpace: "nowrap", borderRadius: 999, padding: "1px 7px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.name }),
1804
+ a.message && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "data-actor-message": a.id, style: { width: "max-content", maxWidth: 240, borderRadius: 8, borderTopLeftRadius: 0, padding: "4px 8px", fontSize: 12, color: "#1e293b", background: "#ffffff", boxShadow: "0 4px 12px rgba(15,23,42,.18)" }, children: a.message })
1669
1805
  ] })
1670
1806
  ] })
1671
1807
  ] }, a.id);
@@ -1676,7 +1812,7 @@ function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
1676
1812
 
1677
1813
  // src/parameters/ParametersPanel.tsx
1678
1814
  var import_parameters3 = require("@pixerate/editor/parameters");
1679
- var import_jsx_runtime6 = require("react/jsx-runtime");
1815
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1680
1816
  function FieldRow({
1681
1817
  controller,
1682
1818
  state,
@@ -1684,18 +1820,19 @@ function FieldRow({
1684
1820
  idBase,
1685
1821
  showKeyframes,
1686
1822
  showFieldReset,
1687
- resolveFile
1823
+ resolveFile,
1824
+ components
1688
1825
  }) {
1689
1826
  const label = (0, import_parameters3.parameterLabel)(field);
1690
1827
  const inputId = `${idBase}-${field.id}`;
1691
1828
  const value = state.values[field.id];
1692
1829
  const error = state.errors[field.id];
1693
1830
  const changed = !(0, import_parameters3.parameterValuesEqual)(value, state.defaults[field.id]);
1694
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { "data-parameter-id": field.id, "data-parameter-type": field.type, className: "space-y-1", children: [
1695
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex min-h-[1.25rem] items-center gap-1.5", children: [
1696
- showKeyframes && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(KeyframeDiamond, { state: state.keys[field.id] ?? "none", label, onToggle: () => controller.toggleKeyframe(field.id) }),
1697
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium text-foreground", title: field.description, children: label }),
1698
- showFieldReset && changed && !field.readOnly && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1831
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-parameter-id": field.id, "data-parameter-type": field.type, className: "space-y-1", children: [
1832
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex min-h-[1.25rem] items-center gap-1.5", children: [
1833
+ showKeyframes && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(KeyframeDiamond, { state: state.keys[field.id] ?? "none", label, onToggle: () => controller.toggleKeyframe(field.id) }),
1834
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium text-foreground", title: field.description, children: label }),
1835
+ showFieldReset && changed && !field.readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1699
1836
  "button",
1700
1837
  {
1701
1838
  type: "button",
@@ -1707,27 +1844,29 @@ function FieldRow({
1707
1844
  }
1708
1845
  )
1709
1846
  ] }),
1710
- field.description && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-[11px] leading-snug text-muted-foreground", children: field.description }),
1711
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1847
+ field.description && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-[11px] leading-snug text-muted-foreground", children: field.description }),
1848
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1712
1849
  ParameterFieldControl,
1713
1850
  {
1714
1851
  field,
1715
1852
  value,
1716
1853
  id: inputId,
1717
1854
  resolveFile,
1855
+ components,
1718
1856
  onChange: (v) => controller.setValue(field.id, v),
1719
1857
  onGestureStart: () => controller.beginGesture(field.id),
1720
1858
  onGestureEnd: () => controller.endGesture()
1721
1859
  }
1722
1860
  ),
1723
- error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error })
1861
+ error && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error })
1724
1862
  ] });
1725
1863
  }
1726
- function PresetBar({ controller, state }) {
1727
- const [saving, setSaving] = (0, import_react10.useState)(false);
1728
- const [name, setName] = (0, import_react10.useState)("");
1729
- const [message, setMessage] = (0, import_react10.useState)(null);
1864
+ function PresetBar({ controller, state, components }) {
1865
+ const [saving, setSaving] = (0, import_react11.useState)(false);
1866
+ const [name, setName] = (0, import_react11.useState)("");
1867
+ const [message, setMessage] = (0, import_react11.useState)(null);
1730
1868
  const active = state.presets.find((p) => p.name === state.activePreset);
1869
+ const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
1731
1870
  const save = (e) => {
1732
1871
  e.preventDefault();
1733
1872
  const result = controller.savePreset(name);
@@ -1737,39 +1876,55 @@ function PresetBar({ controller, state }) {
1737
1876
  setMessage(null);
1738
1877
  } else setMessage(result.message);
1739
1878
  };
1740
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "space-y-1.5", "data-parameter-presets": "", children: [
1741
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-1.5", children: [
1742
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1879
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-1.5", "data-parameter-presets": "", children: [
1880
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-1.5", children: [
1881
+ CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1882
+ CustomPresetSelect,
1883
+ {
1884
+ "aria-label": "Preset",
1885
+ label: "Preset",
1886
+ className: parameterInputClass,
1887
+ style: parameterSelectStyle,
1888
+ value: state.activePreset ?? "",
1889
+ options: [
1890
+ { value: "", label: state.presets.length ? "Presets\u2026" : "No presets" },
1891
+ ...state.presets.map((p) => ({ value: p.name, label: p.name, description: p.description }))
1892
+ ],
1893
+ onChange: (val) => val && controller.applyPreset(String(val))
1894
+ }
1895
+ ) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1743
1896
  "select",
1744
1897
  {
1745
1898
  "aria-label": "Preset",
1746
1899
  className: parameterInputClass,
1900
+ style: parameterSelectStyle,
1747
1901
  value: state.activePreset ?? "",
1748
1902
  onChange: (e) => e.target.value && controller.applyPreset(e.target.value),
1749
1903
  children: [
1750
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "", children: state.presets.length ? "Presets\u2026" : "No presets" }),
1751
- state.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: p.name, title: p.description, children: p.name }, p.name))
1904
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "", style: parameterSelectStyle, children: state.presets.length ? "Presets\u2026" : "No presets" }),
1905
+ state.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: p.name, title: p.description, style: parameterSelectStyle, children: p.name }, p.name))
1752
1906
  ]
1753
1907
  }
1754
1908
  ),
1755
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: parameterButtonClass, onClick: () => setSaving((s) => !s), "aria-expanded": saving, children: "Save\u2026" }),
1756
- active && !active.builtIn && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: parameterButtonClass, "aria-label": `Delete preset ${active.name}`, onClick: () => controller.deletePreset(active.name), children: "Delete" })
1909
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: parameterButtonClass, style: parameterButtonStyle, onClick: () => setSaving((s) => !s), "aria-expanded": saving, children: "Save\u2026" }),
1910
+ active && !active.builtIn && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: parameterButtonClass, style: parameterButtonStyle, "aria-label": `Delete preset ${active.name}`, onClick: () => controller.deletePreset(active.name), children: "Delete" })
1757
1911
  ] }),
1758
- saving && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { className: "flex items-center gap-1.5", onSubmit: save, children: [
1759
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1912
+ saving && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("form", { className: "flex items-center gap-1.5", onSubmit: save, children: [
1913
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1760
1914
  "input",
1761
1915
  {
1762
1916
  autoFocus: true,
1763
1917
  "aria-label": "Preset name",
1764
1918
  placeholder: "Preset name",
1765
1919
  className: parameterInputClass,
1920
+ style: parameterInputStyle,
1766
1921
  value: name,
1767
1922
  onChange: (e) => setName(e.target.value)
1768
1923
  }
1769
1924
  ),
1770
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "submit", className: parameterButtonClass, children: "Save" })
1925
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "submit", className: parameterButtonClass, style: parameterButtonStyle, children: "Save" })
1771
1926
  ] }),
1772
- message && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
1927
+ message && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
1773
1928
  ] });
1774
1929
  }
1775
1930
  function ParametersPanel({
@@ -1782,12 +1937,13 @@ function ParametersPanel({
1782
1937
  resolveFile,
1783
1938
  emptyMessage = "No parameters.",
1784
1939
  className = "",
1940
+ components,
1785
1941
  playback,
1786
1942
  playbackId = "parameters",
1787
1943
  onPlaybackReveal
1788
1944
  }) {
1789
1945
  const state = useParametersState(controller);
1790
- const rootRef = (0, import_react10.useRef)(null);
1946
+ const rootRef = (0, import_react11.useRef)(null);
1791
1947
  const ambientPlayback = useAgentPlayback();
1792
1948
  const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
1793
1949
  const agentPresence = useElementPlaybackSurface(playing, playbackId, rootRef, {
@@ -1795,13 +1951,13 @@ function ParametersPanel({
1795
1951
  selectors: { parameter: (id) => `[data-parameter-id="${CSS.escape(id)}"]` },
1796
1952
  reveal: onPlaybackReveal
1797
1953
  });
1798
- const idBase = (0, import_react10.useId)();
1954
+ const idBase = (0, import_react11.useId)();
1799
1955
  const keys = showKeyframes ?? state.keyframesEnabled;
1800
1956
  const heading = title === void 0 ? state.schema.title : title;
1801
1957
  const renderItems = (items) => items.map((item) => {
1802
1958
  if (state.visible[item.id] === false) return null;
1803
1959
  if ((0, import_parameters3.isParameterGroup)(item)) return renderGroup(item);
1804
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1960
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1805
1961
  FieldRow,
1806
1962
  {
1807
1963
  controller,
@@ -1810,7 +1966,8 @@ function ParametersPanel({
1810
1966
  idBase,
1811
1967
  showKeyframes: keys,
1812
1968
  showFieldReset,
1813
- resolveFile
1969
+ resolveFile,
1970
+ components
1814
1971
  },
1815
1972
  item.id
1816
1973
  );
@@ -1818,8 +1975,8 @@ function ParametersPanel({
1818
1975
  const renderGroup = (group) => {
1819
1976
  const collapsed = !!state.collapsed[group.id];
1820
1977
  const bodyId = `${idBase}-group-${group.id}`;
1821
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { "data-parameter-group": group.id, className: "rounded-md border border-border", children: [
1822
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1978
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { "data-parameter-group": group.id, className: "rounded-md border border-border", children: [
1979
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1823
1980
  "button",
1824
1981
  {
1825
1982
  type: "button",
@@ -1828,50 +1985,71 @@ function ParametersPanel({
1828
1985
  onClick: () => controller.toggleCollapsed(group.id),
1829
1986
  className: "flex w-full items-center gap-1.5 px-2 py-1.5 text-left text-xs font-semibold text-foreground hover:bg-muted",
1830
1987
  children: [
1831
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "aria-hidden": "true", className: `inline-block text-[10px] text-muted-foreground transition-transform ${collapsed ? "" : "rotate-90"}`, children: "\u25B6" }),
1988
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-hidden": "true", className: `inline-block text-[10px] text-muted-foreground transition-transform ${collapsed ? "" : "rotate-90"}`, children: "\u25B6" }),
1832
1989
  (0, import_parameters3.parameterLabel)(group)
1833
1990
  ]
1834
1991
  }
1835
1992
  ),
1836
- !collapsed && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { id: bodyId, className: "space-y-3 border-t border-border px-2 py-2", children: [
1837
- group.description && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-[11px] text-muted-foreground", children: group.description }),
1993
+ !collapsed && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { id: bodyId, className: "space-y-3 border-t border-border px-2 py-2", children: [
1994
+ group.description && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-[11px] text-muted-foreground", children: group.description }),
1838
1995
  renderItems(group.fields)
1839
1996
  ] })
1840
1997
  ] }, group.id);
1841
1998
  };
1842
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ref: rootRef, className: `relative space-y-3 text-foreground ${className}`, "data-parameters-panel": "", children: [
1843
- (heading || showToolbar) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-wrap items-center gap-1.5", children: [
1844
- heading && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: "mr-auto text-sm font-semibold", children: heading }),
1845
- showToolbar && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-wrap gap-1", role: "toolbar", "aria-label": "Parameter actions", children: [
1846
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1999
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { ref: rootRef, className: `relative space-y-3 text-foreground ${className}`, "data-parameters-panel": "", children: [
2000
+ (heading || showToolbar) && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-wrap items-center gap-1.5", children: [
2001
+ heading && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h3", { className: "mr-auto text-sm font-semibold", children: heading }),
2002
+ showToolbar && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-wrap gap-1", role: "toolbar", "aria-label": "Parameter actions", children: [
2003
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1847
2004
  "button",
1848
2005
  {
1849
2006
  type: "button",
1850
2007
  className: parameterButtonClass,
2008
+ style: parameterButtonStyle,
1851
2009
  disabled: !state.canUndo,
1852
2010
  title: state.canUndo ? `Undo ${state.undoLabel}` : "Nothing to undo",
1853
2011
  onClick: () => controller.undo(),
1854
2012
  children: "Undo"
1855
2013
  }
1856
2014
  ),
1857
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2015
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1858
2016
  "button",
1859
2017
  {
1860
2018
  type: "button",
1861
2019
  className: parameterButtonClass,
2020
+ style: parameterButtonStyle,
1862
2021
  disabled: !state.canRedo,
1863
2022
  title: state.canRedo ? `Redo ${state.redoLabel}` : "Nothing to redo",
1864
2023
  onClick: () => controller.redo(),
1865
2024
  children: "Redo"
1866
2025
  }
1867
2026
  ),
1868
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: parameterButtonClass, disabled: !state.modified, onClick: () => controller.reset(), children: "Reset" }),
1869
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: parameterButtonClass, onClick: () => controller.randomize(), children: "Randomize" })
2027
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2028
+ "button",
2029
+ {
2030
+ type: "button",
2031
+ className: parameterButtonClass,
2032
+ style: parameterButtonStyle,
2033
+ disabled: !state.modified,
2034
+ onClick: () => controller.reset(),
2035
+ children: "Reset"
2036
+ }
2037
+ ),
2038
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2039
+ "button",
2040
+ {
2041
+ type: "button",
2042
+ className: parameterButtonClass,
2043
+ style: parameterButtonStyle,
2044
+ onClick: () => controller.randomize(),
2045
+ children: "Randomize"
2046
+ }
2047
+ )
1870
2048
  ] })
1871
2049
  ] }),
1872
- showPresets && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PresetBar, { controller, state }),
1873
- state.fields.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyMessage }) : renderItems(state.schema.fields),
1874
- playing && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PresenceLayer, { presence: agentPresence })
2050
+ showPresets && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PresetBar, { controller, state, components }),
2051
+ state.fields.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyMessage }) : renderItems(state.schema.fields),
2052
+ playing && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PresenceLayer, { presence: agentPresence })
1875
2053
  ] });
1876
2054
  }
1877
2055
  // Annotate the CommonJS export names for ESM import in node:
@@ -1879,6 +2057,7 @@ function ParametersPanel({
1879
2057
  KeyframeDiamond,
1880
2058
  ParameterColor,
1881
2059
  ParameterCommitInput,
2060
+ ParameterComponentsProvider,
1882
2061
  ParameterFieldControl,
1883
2062
  ParameterImage,
1884
2063
  ParameterNumberInput,
@@ -1889,8 +2068,14 @@ function ParametersPanel({
1889
2068
  ParameterVector,
1890
2069
  ParametersPanel,
1891
2070
  parameterButtonClass,
2071
+ parameterButtonStyle,
1892
2072
  parameterInputClass,
2073
+ parameterInputStyle,
2074
+ parameterRangeStyle,
2075
+ parameterSelectStyle,
2076
+ resolveParameterComponents,
1893
2077
  useParameterCommands,
2078
+ useParameterComponents,
1894
2079
  useParameters,
1895
2080
  useParametersController,
1896
2081
  useParametersState