@pixerate/editor-react 0.114.1 → 0.114.3

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 (41) hide show
  1. package/dist/animation-editor/index.cjs +342 -215
  2. package/dist/animation-editor/index.js +2 -2
  3. package/dist/canvas/index.cjs +520 -393
  4. package/dist/canvas/index.js +2 -2
  5. package/dist/chart/index.cjs +2 -2
  6. package/dist/chart/index.js +1 -1
  7. package/dist/{chunk-5LFQ2UQZ.js → chunk-354TA5QV.js} +221 -101
  8. package/dist/{chunk-2INOKIJN.js → chunk-SH63DFOO.js} +345 -297
  9. package/dist/{chunk-BWEARAWR.js → chunk-TOGMXZM4.js} +40 -18
  10. package/dist/{chunk-N2F53ESC.js → chunk-VUSYAHIU.js} +2 -2
  11. package/dist/effects/EffectParameters.d.cts +4 -1
  12. package/dist/effects/EffectParameters.d.ts +4 -1
  13. package/dist/effects/index.cjs +348 -221
  14. package/dist/effects/index.js +2 -2
  15. package/dist/image-editor/ImageEffectControls.d.cts +4 -1
  16. package/dist/image-editor/ImageEffectControls.d.ts +4 -1
  17. package/dist/image-editor/ImageProviderEffectsPanel.d.cts +4 -1
  18. package/dist/image-editor/ImageProviderEffectsPanel.d.ts +4 -1
  19. package/dist/image-editor/controls/parameterControls.d.cts +4 -0
  20. package/dist/image-editor/controls/parameterControls.d.ts +4 -0
  21. package/dist/image-editor/index.cjs +868 -697
  22. package/dist/image-editor/index.js +3 -3
  23. package/dist/index.cjs +1390 -1219
  24. package/dist/index.js +4 -4
  25. package/dist/paint-editor/index.cjs +335 -208
  26. package/dist/paint-editor/index.js +2 -2
  27. package/dist/parameters/ParametersPanel.d.cts +4 -1
  28. package/dist/parameters/ParametersPanel.d.ts +4 -1
  29. package/dist/parameters/controls.d.cts +72 -0
  30. package/dist/parameters/controls.d.ts +72 -0
  31. package/dist/parameters/fields.d.cts +19 -6
  32. package/dist/parameters/fields.d.ts +19 -6
  33. package/dist/parameters/index.cjs +350 -183
  34. package/dist/parameters/index.d.cts +1 -0
  35. package/dist/parameters/index.d.ts +1 -0
  36. package/dist/parameters/index.js +70 -14
  37. package/dist/vector/index.cjs +321 -194
  38. package/dist/vector/index.js +2 -2
  39. package/dist/video-editor/index.cjs +418 -291
  40. package/dist/video-editor/index.js +2 -2
  41. package/package.json +3 -3
@@ -1966,7 +1966,7 @@ function useCanvasBrushes(options = {}) {
1966
1966
  }
1967
1967
 
1968
1968
  // src/canvas/CanvasEffects.tsx
1969
- var import_react29 = require("react");
1969
+ var import_react30 = require("react");
1970
1970
  var import_canvas16 = require("@pixerate/editor/canvas");
1971
1971
 
1972
1972
  // src/effects/useEffects.ts
@@ -2100,12 +2100,12 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
2100
2100
  }
2101
2101
 
2102
2102
  // src/effects/EffectParameters.tsx
2103
- var import_react28 = __toESM(require("react"), 1);
2103
+ var import_react29 = __toESM(require("react"), 1);
2104
2104
  var import_effects3 = require("@pixerate/editor/effects");
2105
2105
  var import_parameters2 = require("@pixerate/editor/parameters");
2106
2106
 
2107
2107
  // src/parameters/fields.tsx
2108
- var import_react27 = require("react");
2108
+ var import_react28 = require("react");
2109
2109
  var import_parameters = require("@pixerate/editor/parameters");
2110
2110
 
2111
2111
  // src/color/index.ts
@@ -3147,18 +3147,57 @@ function useResolvedColor(value, scheme) {
3147
3147
  // src/color/index.ts
3148
3148
  __reExport(color_exports, require("@pixerate/editor/color"));
3149
3149
 
3150
- // src/parameters/fields.tsx
3150
+ // src/parameters/controls.tsx
3151
+ var import_react27 = require("react");
3151
3152
  var import_jsx_runtime11 = require("react/jsx-runtime");
3153
+ var ParameterComponentsContext = (0, import_react27.createContext)({});
3154
+ function useParameterComponents() {
3155
+ return (0, import_react27.useContext)(ParameterComponentsContext);
3156
+ }
3157
+ function resolveParameterComponents(explicit, context) {
3158
+ return {
3159
+ input: explicit?.input ?? context?.input,
3160
+ slider: explicit?.slider ?? context?.slider,
3161
+ select: explicit?.select ?? context?.select
3162
+ };
3163
+ }
3164
+
3165
+ // src/parameters/fields.tsx
3166
+ var import_jsx_runtime12 = require("react/jsx-runtime");
3167
+ var parameterInputStyle = import_parameters.parameterThemeStyles.input;
3168
+ var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
3169
+ var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
3170
+ var parameterRangeStyle = import_parameters.parameterThemeStyles.range;
3152
3171
  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";
3153
3172
  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";
3154
3173
  var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
3155
- function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, ...rest }) {
3174
+ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
3175
+ const inputRef = (0, import_react28.useRef)(null);
3176
+ const lastCommitted = (0, import_react28.useRef)(null);
3177
+ (0, import_react28.useLayoutEffect)(() => {
3178
+ lastCommitted.current = null;
3179
+ const el = inputRef.current;
3180
+ if (el && el.value !== value) el.value = value;
3181
+ }, [value]);
3156
3182
  const commit = (el) => {
3157
- if (el.value !== value) onCommit(el.value, el);
3183
+ const text = el.value;
3184
+ if (text === value || text === lastCommitted.current) return;
3185
+ onCommit(text, el);
3186
+ lastCommitted.current = el.value === text ? text : null;
3158
3187
  };
3188
+ const commitRef = (0, import_react28.useRef)(commit);
3189
+ commitRef.current = commit;
3190
+ (0, import_react28.useEffect)(() => {
3191
+ const el = inputRef.current;
3192
+ if (!el) return;
3193
+ const change = () => commitRef.current(el);
3194
+ el.addEventListener("change", change);
3195
+ return () => el.removeEventListener("change", change);
3196
+ }, [multiline]);
3159
3197
  const keyDown = (e) => {
3160
3198
  onKeyDown?.(e);
3161
3199
  if (e.defaultPrevented) return;
3200
+ if (e.key === "Tab") commit(e.currentTarget);
3162
3201
  if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
3163
3202
  e.preventDefault();
3164
3203
  commit(e.currentTarget);
@@ -3168,86 +3207,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
3168
3207
  const props = {
3169
3208
  defaultValue: value,
3170
3209
  className: className ?? parameterInputClass,
3210
+ style: { ...parameterInputStyle, ...style },
3171
3211
  onBlur: (e) => commit(e.currentTarget),
3172
3212
  onKeyDown: keyDown,
3173
3213
  ...rest
3174
3214
  };
3175
- return multiline ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { type: "text", ...props }, value);
3215
+ const forwarded = rest.ref;
3216
+ const setRef = (el) => {
3217
+ inputRef.current = el;
3218
+ if (typeof forwarded === "function") forwarded(el);
3219
+ else if (forwarded) forwarded.current = el;
3220
+ };
3221
+ return multiline ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { type: "text", ...props, ref: setRef });
3176
3222
  }
3177
3223
  var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
3178
- function ParameterNumberInput({
3179
- field,
3180
- value,
3181
- onChange,
3182
- disabled,
3183
- id,
3184
- "aria-label": ariaLabel
3185
- }) {
3186
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
3187
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3188
- ParameterCommitInput,
3189
- {
3190
- id,
3191
- inputMode: "decimal",
3192
- "aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field),
3193
- value: plainNumber(field, value),
3194
- disabled: disabled || field.readOnly,
3195
- className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
3196
- onCommit: (text, input) => {
3197
- const n = (0, import_parameters.parseParameterNumberInput)(field, text);
3198
- if (n === null || n === value) input.value = plainNumber(field, value);
3199
- else onChange(n);
3200
- },
3201
- onKeyDown: (e) => {
3202
- if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
3203
- e.preventDefault();
3204
- const step = (0, import_parameters.parameterStep)(field) * (e.shiftKey ? 10 : 1);
3205
- onChange((0, import_parameters.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
3206
- }
3207
- }
3208
- ),
3209
- field.unit && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
3224
+ function ParameterNumberInput(props) {
3225
+ const { field, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
3226
+ const ctx = useParameterComponents();
3227
+ const resolved = resolveParameterComponents(components, ctx);
3228
+ const CustomInput = resolved.input;
3229
+ const plain = plainNumber(field, value);
3230
+ const handleCommit = (text, input) => {
3231
+ const n = (0, import_parameters.parseParameterNumberInput)(field, text);
3232
+ if (n === null || n === value) {
3233
+ if (input) input.value = plain;
3234
+ } else {
3235
+ onChange(n);
3236
+ }
3237
+ };
3238
+ const handleKeyDown = (e) => {
3239
+ if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
3240
+ e.preventDefault();
3241
+ const step = (0, import_parameters.parameterStep)(field) * (e.shiftKey ? 10 : 1);
3242
+ onChange((0, import_parameters.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
3243
+ };
3244
+ const inputProps = {
3245
+ id,
3246
+ inputMode: "decimal",
3247
+ "aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field),
3248
+ value: plain,
3249
+ disabled: disabled || field.readOnly,
3250
+ className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
3251
+ style: parameterInputStyle,
3252
+ onCommit: handleCommit,
3253
+ onKeyDown: handleKeyDown
3254
+ };
3255
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
3256
+ CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterCommitInput, { ...inputProps }),
3257
+ field.unit && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
3210
3258
  ] });
3211
3259
  }
3212
3260
  function ParameterSlider(props) {
3213
- const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
3214
- const dragging = (0, import_react27.useRef)(false);
3261
+ const { field, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
3262
+ const ctx = useParameterComponents();
3263
+ const resolved = resolveParameterComponents(components, ctx);
3264
+ const CustomSlider = resolved.slider;
3265
+ const dragging = (0, import_react28.useRef)(false);
3266
+ const start = () => {
3267
+ if (dragging.current) return;
3268
+ dragging.current = true;
3269
+ onGestureStart?.();
3270
+ };
3215
3271
  const end = () => {
3216
3272
  if (!dragging.current) return;
3217
3273
  dragging.current = false;
3218
3274
  onGestureEnd?.();
3219
3275
  };
3220
- if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterNumberInput, { ...props });
3276
+ if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterNumberInput, { ...props });
3221
3277
  const step = (0, import_parameters.parameterStep)(field);
3222
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-2", children: [
3223
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3278
+ const sliderProps = {
3279
+ "aria-label": (0, import_parameters.parameterLabel)(field),
3280
+ "aria-valuetext": (0, import_parameters.formatParameterNumber)(field, value),
3281
+ // A `control: 'slider'` field may leave out a bound: the range input's own defaults.
3282
+ min: field.min ?? 0,
3283
+ max: field.max ?? 100,
3284
+ step,
3285
+ value,
3286
+ disabled: disabled || field.readOnly,
3287
+ className: rangeClass,
3288
+ style: parameterRangeStyle
3289
+ };
3290
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
3291
+ CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3292
+ CustomSlider,
3293
+ {
3294
+ ...sliderProps,
3295
+ id: props.id ? `${props.id}-slider` : void 0,
3296
+ label: (0, import_parameters.parameterLabel)(field),
3297
+ onChange: (v) => onChange((0, import_parameters.clampParameterNumber)(field, v)),
3298
+ onGestureStart: start,
3299
+ onGestureEnd: end
3300
+ }
3301
+ ) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3224
3302
  "input",
3225
3303
  {
3226
3304
  type: "range",
3227
- "aria-label": (0, import_parameters.parameterLabel)(field),
3228
- "aria-valuetext": (0, import_parameters.formatParameterNumber)(field, value),
3229
- min: field.min,
3230
- max: field.max,
3231
- step,
3232
- value,
3233
- disabled: disabled || field.readOnly,
3234
- className: rangeClass,
3235
- onPointerDown: () => {
3236
- if (dragging.current) return;
3237
- dragging.current = true;
3238
- onGestureStart?.();
3239
- },
3305
+ ...sliderProps,
3306
+ onPointerDown: start,
3240
3307
  onPointerUp: end,
3241
3308
  onPointerCancel: end,
3242
3309
  onBlur: end,
3243
3310
  onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
3244
3311
  }
3245
3312
  ),
3246
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
3313
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
3247
3314
  ] });
3248
3315
  }
3249
3316
  function ParameterToggle({ field, value, onChange, disabled, id }) {
3250
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3317
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3251
3318
  "button",
3252
3319
  {
3253
3320
  type: "button",
@@ -3258,7 +3325,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
3258
3325
  disabled: disabled || field.readOnly,
3259
3326
  onClick: () => onChange(!value),
3260
3327
  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"}`,
3261
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3328
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3262
3329
  "span",
3263
3330
  {
3264
3331
  className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
@@ -3267,11 +3334,15 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
3267
3334
  }
3268
3335
  );
3269
3336
  }
3270
- function ParameterSelect({ field, value, onChange, disabled, id }) {
3337
+ function ParameterSelect(props) {
3338
+ const { field, value, onChange, disabled, id, components } = props;
3339
+ const ctx = useParameterComponents();
3340
+ const resolved = resolveParameterComponents(components, ctx);
3341
+ const CustomSelect = resolved.select;
3271
3342
  const options = (0, import_parameters.getChoiceOptions)(field);
3272
3343
  const off = disabled || field.readOnly;
3273
3344
  if (field.control === "segmented") {
3274
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.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_runtime11.jsx)(
3345
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.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_runtime12.jsx)(
3275
3346
  "button",
3276
3347
  {
3277
3348
  type: "button",
@@ -3286,8 +3357,25 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
3286
3357
  String(o.value)
3287
3358
  )) });
3288
3359
  }
3360
+ if (CustomSelect) {
3361
+ const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
3362
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3363
+ CustomSelect,
3364
+ {
3365
+ id,
3366
+ label: (0, import_parameters.parameterLabel)(field),
3367
+ "aria-label": (0, import_parameters.parameterLabel)(field),
3368
+ value,
3369
+ options: customOptions,
3370
+ disabled: off,
3371
+ className: parameterInputClass,
3372
+ style: parameterSelectStyle,
3373
+ onChange: (v) => onChange((0, import_parameters.matchParameterOptionValue)(options, v))
3374
+ }
3375
+ );
3376
+ }
3289
3377
  const index = options.findIndex((o) => o.value === value);
3290
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3378
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3291
3379
  "select",
3292
3380
  {
3293
3381
  id,
@@ -3299,22 +3387,23 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
3299
3387
  if (option) onChange(option.value);
3300
3388
  },
3301
3389
  className: parameterInputClass,
3302
- children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
3390
+ style: parameterSelectStyle,
3391
+ children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
3303
3392
  }
3304
3393
  );
3305
3394
  }
3306
3395
  function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
3307
- const [open, setOpen] = (0, import_react27.useState)(false);
3308
- const containerRef = (0, import_react27.useRef)(null);
3309
- const buttonRef = (0, import_react27.useRef)(null);
3310
- const popoverRef = (0, import_react27.useRef)(null);
3396
+ const [open, setOpen] = (0, import_react28.useState)(false);
3397
+ const containerRef = (0, import_react28.useRef)(null);
3398
+ const buttonRef = (0, import_react28.useRef)(null);
3399
+ const popoverRef = (0, import_react28.useRef)(null);
3311
3400
  const alpha = !!field.alpha;
3312
3401
  const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
3313
3402
  const rgb = hex.slice(0, 7);
3314
3403
  const shown = alpha ? hex : rgb;
3315
3404
  const off = disabled || field.readOnly;
3316
3405
  const name = (0, import_parameters.parameterLabel)(field);
3317
- (0, import_react27.useEffect)(() => {
3406
+ (0, import_react28.useEffect)(() => {
3318
3407
  if (!open) return;
3319
3408
  const onPointerDown = (e) => {
3320
3409
  if (containerRef.current && !containerRef.current.contains(e.target)) {
@@ -3335,9 +3424,9 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
3335
3424
  window.removeEventListener("keydown", onKeyDown, true);
3336
3425
  };
3337
3426
  }, [open]);
3338
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
3339
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-2", children: [
3340
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3427
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
3428
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
3429
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3341
3430
  "button",
3342
3431
  {
3343
3432
  ref: buttonRef,
@@ -3348,10 +3437,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
3348
3437
  disabled: off,
3349
3438
  onClick: () => setOpen((prev) => !prev),
3350
3439
  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",
3351
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
3440
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
3352
3441
  }
3353
3442
  ),
3354
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3443
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3355
3444
  ParameterCommitInput,
3356
3445
  {
3357
3446
  id,
@@ -3367,7 +3456,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
3367
3456
  }
3368
3457
  )
3369
3458
  ] }),
3370
- open && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3459
+ open && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3371
3460
  "div",
3372
3461
  {
3373
3462
  ref: popoverRef,
@@ -3381,7 +3470,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
3381
3470
  },
3382
3471
  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",
3383
3472
  style: { background: "var(--popover, var(--background, #fff))" },
3384
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3473
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3385
3474
  ColorPicker,
3386
3475
  {
3387
3476
  value: shown,
@@ -3397,13 +3486,13 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
3397
3486
  )
3398
3487
  ] });
3399
3488
  }
3400
- function ParameterVector({ field, value, onChange, disabled, id }) {
3489
+ function ParameterVector({ field, value, onChange, disabled, id, components }) {
3401
3490
  const size = (0, import_parameters.vectorSize)(field);
3402
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
3491
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
3403
3492
  const component = (0, import_parameters.vectorComponentField)(field, i);
3404
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
3405
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
3406
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3493
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
3494
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
3495
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3407
3496
  ParameterNumberInput,
3408
3497
  {
3409
3498
  field: component,
@@ -3411,6 +3500,7 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
3411
3500
  id: i === 0 ? id : void 0,
3412
3501
  "aria-label": `${(0, import_parameters.parameterLabel)(field)} ${component.label}`,
3413
3502
  disabled: disabled || field.readOnly,
3503
+ components,
3414
3504
  onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
3415
3505
  }
3416
3506
  )
@@ -3420,11 +3510,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
3420
3510
  function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
3421
3511
  const off = disabled || field.readOnly;
3422
3512
  const name = (0, import_parameters.parameterLabel)(field);
3423
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "space-y-1.5", children: [
3424
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-2", children: [
3425
- /* @__PURE__ */ (0, import_jsx_runtime11.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_runtime11.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
3426
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
3427
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3513
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "space-y-1.5", children: [
3514
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
3515
+ /* @__PURE__ */ (0, import_jsx_runtime12.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_runtime12.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
3516
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
3517
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3428
3518
  ParameterCommitInput,
3429
3519
  {
3430
3520
  id,
@@ -3435,30 +3525,48 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
3435
3525
  onCommit: (text) => onChange(text.trim())
3436
3526
  }
3437
3527
  ),
3438
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex gap-1", children: [
3439
- resolveFile && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
3440
- "Choose file\u2026",
3441
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3442
- "input",
3443
- {
3444
- type: "file",
3445
- className: "sr-only",
3446
- accept: field.accept ?? "image/*",
3447
- disabled: off,
3448
- "aria-label": `${name} file`,
3449
- onChange: async (e) => {
3450
- const file = e.target.files?.[0];
3451
- e.target.value = "";
3452
- if (file) onChange(await resolveFile(file));
3453
- }
3454
- }
3455
- )
3456
- ] }),
3457
- value && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
3528
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex gap-1", children: [
3529
+ resolveFile && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
3530
+ "label",
3531
+ {
3532
+ style: parameterButtonStyle,
3533
+ className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
3534
+ children: [
3535
+ "Choose file\u2026",
3536
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3537
+ "input",
3538
+ {
3539
+ type: "file",
3540
+ className: "sr-only",
3541
+ accept: field.accept ?? "image/*",
3542
+ disabled: off,
3543
+ "aria-label": `${name} file`,
3544
+ onChange: async (e) => {
3545
+ const file = e.target.files?.[0];
3546
+ e.target.value = "";
3547
+ if (file) onChange(await resolveFile(file));
3548
+ }
3549
+ }
3550
+ )
3551
+ ]
3552
+ }
3553
+ ),
3554
+ value && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3555
+ "button",
3556
+ {
3557
+ type: "button",
3558
+ style: parameterButtonStyle,
3559
+ className: parameterButtonClass,
3560
+ disabled: off,
3561
+ onClick: () => onChange(""),
3562
+ "aria-label": `Clear ${name}`,
3563
+ children: "Clear"
3564
+ }
3565
+ )
3458
3566
  ] })
3459
3567
  ] })
3460
3568
  ] }),
3461
- field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3569
+ field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3462
3570
  "button",
3463
3571
  {
3464
3572
  type: "button",
@@ -3468,14 +3576,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
3468
3576
  disabled: off,
3469
3577
  onClick: () => onChange(o.url),
3470
3578
  className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
3471
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
3579
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
3472
3580
  },
3473
3581
  o.url
3474
3582
  )) })
3475
3583
  ] });
3476
3584
  }
3477
3585
  function ParameterText({ field, value, onChange, disabled, id }) {
3478
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3586
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3479
3587
  ParameterCommitInput,
3480
3588
  {
3481
3589
  id,
@@ -3494,24 +3602,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
3494
3602
  switch (field.type) {
3495
3603
  case "number":
3496
3604
  case "int":
3497
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
3605
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
3498
3606
  case "boolean":
3499
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
3607
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
3500
3608
  case "choice":
3501
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
3609
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
3502
3610
  case "color":
3503
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
3611
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
3504
3612
  case "vector":
3505
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
3613
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
3506
3614
  case "image":
3507
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
3615
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
3508
3616
  case "text":
3509
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParameterText, { field, value, onChange: set, ...rest });
3617
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterText, { field, value, onChange: set, ...rest });
3510
3618
  }
3511
3619
  }
3512
3620
 
3513
3621
  // src/effects/EffectParameters.tsx
3514
- var import_jsx_runtime12 = require("react/jsx-runtime");
3622
+ var import_jsx_runtime13 = require("react/jsx-runtime");
3515
3623
  function EffectParameters({
3516
3624
  description,
3517
3625
  values,
@@ -3523,56 +3631,75 @@ function EffectParameters({
3523
3631
  renderControlAddon,
3524
3632
  fonts,
3525
3633
  disabled = false,
3526
- className = ""
3634
+ className = "",
3635
+ components
3527
3636
  }) {
3528
- const fields = (0, import_react28.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
3529
- const idBase = (0, import_react28.useId)();
3530
- const gesture = import_react28.default.useRef(null);
3531
- const count = import_react28.default.useRef(0);
3532
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
3533
- (onPreset || onPresetName) && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
3637
+ const fields = (0, import_react29.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
3638
+ const idBase = (0, import_react29.useId)();
3639
+ const gesture = import_react29.default.useRef(null);
3640
+ const count = import_react29.default.useRef(0);
3641
+ const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
3642
+ const handlePresetSelect = (name) => {
3643
+ if (!name) return;
3644
+ if (onPresetName) {
3645
+ onPresetName(name);
3646
+ } else if (onPreset) {
3647
+ const preset = description.presets.find((p) => p.name === name);
3648
+ if (preset) onPreset({ ...description.defaults, ...preset.values });
3649
+ }
3650
+ };
3651
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
3652
+ (onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3653
+ CustomPresetSelect,
3654
+ {
3655
+ "aria-label": `${description.name} presets`,
3656
+ label: `${description.name} presets`,
3657
+ value: "",
3658
+ disabled,
3659
+ className: "w-full rounded border border-border px-1 py-0.5 text-xs",
3660
+ style: parameterSelectStyle,
3661
+ options: [
3662
+ { value: "", label: "Presets\u2026" },
3663
+ ...description.presets.map((p) => ({ value: p.name, label: p.name }))
3664
+ ],
3665
+ onChange: (name) => handlePresetSelect(String(name))
3666
+ }
3667
+ ) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
3534
3668
  "select",
3535
3669
  {
3536
- className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
3670
+ className: "w-full rounded border border-border px-1 py-0.5 text-xs",
3671
+ style: parameterSelectStyle,
3537
3672
  "aria-label": `${description.name} presets`,
3538
3673
  value: "",
3539
3674
  disabled,
3540
- onChange: (e) => {
3541
- const name = e.currentTarget.value;
3542
- if (!name) return;
3543
- if (onPresetName) {
3544
- onPresetName(name);
3545
- } else if (onPreset) {
3546
- const preset = description.presets.find((p) => p.name === name);
3547
- if (preset) onPreset({ ...description.defaults, ...preset.values });
3548
- }
3549
- },
3675
+ onChange: (e) => handlePresetSelect(e.currentTarget.value),
3550
3676
  children: [
3551
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: "", children: "Presets\u2026" }),
3552
- description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: p.name, children: p.name }, p.name))
3677
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
3678
+ description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
3553
3679
  ]
3554
3680
  }
3555
- ),
3681
+ )),
3556
3682
  fields.map((field) => {
3557
3683
  const label = (0, import_parameters2.parameterLabel)(field);
3558
3684
  const inputId = `${idBase}-${field.id}`;
3559
3685
  const keyed = keyframed?.has(field.id) ?? false;
3560
3686
  const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
3561
3687
  const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
3562
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
3563
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-1.5", children: [
3564
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
3565
- keyed && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
3688
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
3689
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-1.5", children: [
3690
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
3691
+ keyed && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
3566
3692
  renderControlAddon?.(field.id),
3567
- onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
3693
+ onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
3568
3694
  ] }),
3569
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3695
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3570
3696
  ParameterFieldControl,
3571
3697
  {
3572
3698
  field,
3573
3699
  value,
3574
3700
  id: inputId,
3575
3701
  disabled: disabled || keyed,
3702
+ components,
3576
3703
  onChange: (v) => onChange(field.id, v, gesture.current),
3577
3704
  onGestureStart: () => gesture.current = `${idBase}:${field.id}:${++count.current}`,
3578
3705
  onGestureEnd: () => gesture.current = null
@@ -3580,46 +3707,46 @@ function EffectParameters({
3580
3707
  )
3581
3708
  ] }, field.id);
3582
3709
  }),
3583
- !fields.length && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
3710
+ !fields.length && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
3584
3711
  ] });
3585
3712
  }
3586
3713
 
3587
3714
  // src/canvas/CanvasEffects.tsx
3588
- var import_jsx_runtime13 = require("react/jsx-runtime");
3589
- var ProviderContext = (0, import_react29.createContext)(null);
3715
+ var import_jsx_runtime14 = require("react/jsx-runtime");
3716
+ var ProviderContext = (0, import_react30.createContext)(null);
3590
3717
  function CanvasEffectsProvider({ provider, children }) {
3591
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ProviderContext.Provider, { value: provider ?? null, children });
3718
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ProviderContext.Provider, { value: provider ?? null, children });
3592
3719
  }
3593
- var useCanvasEffectsProviderContext = () => (0, import_react29.useContext)(ProviderContext);
3720
+ var useCanvasEffectsProviderContext = () => (0, import_react30.useContext)(ProviderContext);
3594
3721
  function CanvasNodeEffectLayer({ effect, width, height, clipPath, clipTransform }) {
3595
3722
  const provider = useCanvasEffectsProviderContext();
3596
- const ref = (0, import_react29.useRef)(null);
3597
- const [failed, setFailed] = (0, import_react29.useState)(false);
3723
+ const ref = (0, import_react30.useRef)(null);
3724
+ const [failed, setFailed] = (0, import_react30.useState)(false);
3598
3725
  const dpr = typeof window !== "undefined" ? Math.min(2, window.devicePixelRatio || 1) : 1;
3599
3726
  const pw = Math.max(1, Math.round(width * dpr));
3600
3727
  const ph = Math.max(1, Math.round(height * dpr));
3601
3728
  const key = JSON.stringify(effect);
3602
- (0, import_react29.useEffect)(() => {
3729
+ (0, import_react30.useEffect)(() => {
3603
3730
  const canvas2 = ref.current;
3604
3731
  if (!provider || !canvas2) return;
3605
3732
  setFailed(false);
3606
3733
  const run = (0, import_canvas16.runCanvasNodeEffect)({ provider, effect, target: canvas2, onError: () => setFailed(true) });
3607
3734
  return () => run.stop();
3608
3735
  }, [provider, key, pw, ph]);
3609
- const clipId = (0, import_react29.useMemo)(() => `pixerate-effect-clip-${Math.random().toString(36).slice(2)}`, []);
3736
+ const clipId = (0, import_react30.useMemo)(() => `pixerate-effect-clip-${Math.random().toString(36).slice(2)}`, []);
3610
3737
  if (!provider || failed || !(width > 0 && height > 0)) return null;
3611
3738
  const style = { position: "absolute", inset: 0, width: "100%", height: "100%", pointerEvents: "none", opacity: effect.opacity ?? 1 };
3612
- const canvas = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("canvas", { ref, width: pw, height: ph, style: { width: "100%", height: "100%", display: "block" }, "data-canvas-effect": effect.effect });
3613
- if (effect.mode === "overlay" || !clipPath) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { style, children: canvas });
3614
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("svg", { style, viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "none", "aria-hidden": "true", children: [
3615
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("clipPath", { id: clipId, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: clipPath, transform: clipTransform }) }) }),
3616
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("foreignObject", { x: 0, y: 0, width, height, clipPath: `url(#${clipId})`, children: canvas })
3739
+ const canvas = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("canvas", { ref, width: pw, height: ph, style: { width: "100%", height: "100%", display: "block" }, "data-canvas-effect": effect.effect });
3740
+ if (effect.mode === "overlay" || !clipPath) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style, children: canvas });
3741
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("svg", { style, viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "none", "aria-hidden": "true", children: [
3742
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("clipPath", { id: clipId, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: clipPath, transform: clipTransform }) }) }),
3743
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("foreignObject", { x: 0, y: 0, width, height, clipPath: `url(#${clipId})`, children: canvas })
3617
3744
  ] });
3618
3745
  }
3619
3746
  function useCanvasEffects(options) {
3620
- const opts = (0, import_react29.useRef)(options);
3747
+ const opts = (0, import_react30.useRef)(options);
3621
3748
  opts.current = options;
3622
- const controller = (0, import_react29.useMemo)(
3749
+ const controller = (0, import_react30.useMemo)(
3623
3750
  () => (0, import_canvas16.createCanvasEffectsController)({
3624
3751
  getNodes: () => opts.current.getNodes(),
3625
3752
  setNodes: (n) => opts.current.setNodes(n),
@@ -3630,7 +3757,7 @@ function useCanvasEffects(options) {
3630
3757
  }),
3631
3758
  []
3632
3759
  );
3633
- (0, import_react29.useEffect)(() => {
3760
+ (0, import_react30.useEffect)(() => {
3634
3761
  if (!options.effects) return;
3635
3762
  return controller.useEffects(options.effects);
3636
3763
  }, [controller, options.effects]);
@@ -3638,7 +3765,7 @@ function useCanvasEffects(options) {
3638
3765
  }
3639
3766
  function useCanvasEffectsTools(registry, controller, options = {}) {
3640
3767
  const { id, namespace, readOnly, subscribe } = options;
3641
- (0, import_react29.useEffect)(() => {
3768
+ (0, import_react30.useEffect)(() => {
3642
3769
  if (!registry) return;
3643
3770
  return registry.register((0, import_canvas16.createCanvasEffectsToolProvider)(controller, { id, namespace, readOnly, subscribe }));
3644
3771
  }, [registry, controller, id, namespace, readOnly, subscribe]);
@@ -3646,12 +3773,12 @@ function useCanvasEffectsTools(registry, controller, options = {}) {
3646
3773
  var btn = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
3647
3774
  function Controls({ controller, nodeId, effect }) {
3648
3775
  const { description, error } = useEffectDescription(controller.effectsProvider, effect.effect);
3649
- const [message, setMessage] = (0, import_react29.useState)(null);
3776
+ const [message, setMessage] = (0, import_react30.useState)(null);
3650
3777
  const run = (work) => void work.then(() => setMessage(null), (e) => setMessage(e instanceof Error ? e.message : String(e)));
3651
- if (error) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
3652
- if (!description) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
3653
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
3654
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3778
+ if (error) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
3779
+ if (!description) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
3780
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
3781
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3655
3782
  EffectParameters,
3656
3783
  {
3657
3784
  description,
@@ -3661,75 +3788,75 @@ function Controls({ controller, nodeId, effect }) {
3661
3788
  onPreset: (v) => run(controller.updateNodeEffect(nodeId, { values: v }))
3662
3789
  }
3663
3790
  ),
3664
- message && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
3791
+ message && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
3665
3792
  ] });
3666
3793
  }
3667
3794
  function CanvasEffectsPanel({ controller, nodeId, shape, sceneId, className = "" }) {
3668
- const [, setTick] = (0, import_react29.useState)(0);
3669
- (0, import_react29.useEffect)(() => controller.effects.subscribe(() => setTick((n) => n + 1)), [controller]);
3795
+ const [, setTick] = (0, import_react30.useState)(0);
3796
+ (0, import_react30.useEffect)(() => controller.effects.subscribe(() => setTick((n) => n + 1)), [controller]);
3670
3797
  const provider = controller.effectsProvider;
3671
- const [browse, setBrowse] = (0, import_react29.useState)(null);
3672
- const [message, setMessage] = (0, import_react29.useState)(null);
3798
+ const [browse, setBrowse] = (0, import_react30.useState)(null);
3799
+ const [message, setMessage] = (0, import_react30.useState)(null);
3673
3800
  const run = (work) => {
3674
3801
  setMessage(null);
3675
3802
  Promise.resolve().then(work).then(() => setTick((n) => n + 1), (e) => setMessage(e instanceof Error ? e.message : String(e)));
3676
3803
  };
3677
3804
  const effect = (0, import_canvas16.isShapeDescription)(shape) ? shape.effect : void 0;
3678
3805
  const transition = sceneId ? controller.sceneTransition(sceneId) : void 0;
3679
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Canvas effects", "data-canvas-effects": "", children: [
3680
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
3681
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "flex-1 font-semibold", children: "Effects" }),
3682
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: btn, disabled: !provider || !nodeId || !shape, "aria-pressed": browse === "fill", onClick: () => setBrowse(browse === "fill" ? null : "fill"), children: "Fill\u2026" }),
3683
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: btn, disabled: !provider || !nodeId || !shape, "aria-pressed": browse === "overlay", onClick: () => setBrowse(browse === "overlay" ? null : "overlay"), children: "Overlay\u2026" }),
3684
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: btn, disabled: !provider || !sceneId, "aria-pressed": browse === "transition", onClick: () => setBrowse(browse === "transition" ? null : "transition"), children: "Scene transition\u2026" })
3806
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Canvas effects", "data-canvas-effects": "", children: [
3807
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
3808
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "flex-1 font-semibold", children: "Effects" }),
3809
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn, disabled: !provider || !nodeId || !shape, "aria-pressed": browse === "fill", onClick: () => setBrowse(browse === "fill" ? null : "fill"), children: "Fill\u2026" }),
3810
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn, disabled: !provider || !nodeId || !shape, "aria-pressed": browse === "overlay", onClick: () => setBrowse(browse === "overlay" ? null : "overlay"), children: "Overlay\u2026" }),
3811
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn, disabled: !provider || !sceneId, "aria-pressed": browse === "transition", onClick: () => setBrowse(browse === "transition" ? null : "transition"), children: "Scene transition\u2026" })
3685
3812
  ] }),
3686
- !provider && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effects on the canvas are kept." }),
3687
- browse === "fill" && nodeId && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EffectsBrowser, { provider, uses: ["generator", "interactive"], title: "Fills", onPick: (e) => (setBrowse(null), run(() => controller.applyNodeEffect(nodeId, e.id, { mode: "fill" }))) }),
3688
- browse === "overlay" && nodeId && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EffectsBrowser, { provider, uses: ["overlay", "title", "interactive", "generator"], title: "Overlays", onPick: (e) => (setBrowse(null), run(() => controller.applyNodeEffect(nodeId, e.id, { mode: "overlay" }))) }),
3689
- browse === "transition" && sceneId && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EffectsBrowser, { provider, uses: ["transition"], title: "Transitions", onPick: (e) => (setBrowse(null), run(() => controller.setSceneTransition(sceneId, e.id))) }),
3690
- effect && nodeId && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "space-y-1 rounded border border-border p-1", "data-canvas-node-effect": nodeId, children: [
3691
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-1", children: [
3692
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "min-w-0 flex-1 truncate font-medium", children: [
3813
+ !provider && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effects on the canvas are kept." }),
3814
+ browse === "fill" && nodeId && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EffectsBrowser, { provider, uses: ["generator", "interactive"], title: "Fills", onPick: (e) => (setBrowse(null), run(() => controller.applyNodeEffect(nodeId, e.id, { mode: "fill" }))) }),
3815
+ browse === "overlay" && nodeId && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EffectsBrowser, { provider, uses: ["overlay", "title", "interactive", "generator"], title: "Overlays", onPick: (e) => (setBrowse(null), run(() => controller.applyNodeEffect(nodeId, e.id, { mode: "overlay" }))) }),
3816
+ browse === "transition" && sceneId && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EffectsBrowser, { provider, uses: ["transition"], title: "Transitions", onPick: (e) => (setBrowse(null), run(() => controller.setSceneTransition(sceneId, e.id))) }),
3817
+ effect && nodeId && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "space-y-1 rounded border border-border p-1", "data-canvas-node-effect": nodeId, children: [
3818
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1", children: [
3819
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "min-w-0 flex-1 truncate font-medium", children: [
3693
3820
  effect.name ?? effect.effect,
3694
3821
  " ",
3695
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "text-muted-foreground", children: [
3822
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "text-muted-foreground", children: [
3696
3823
  "\xB7 ",
3697
3824
  effect.mode
3698
3825
  ] })
3699
3826
  ] }),
3700
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "flex items-center gap-1", children: [
3701
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { type: "checkbox", checked: effect.playing !== false, "aria-label": "Play", onChange: (e) => {
3827
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex items-center gap-1", children: [
3828
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "checkbox", checked: effect.playing !== false, "aria-label": "Play", onChange: (e) => {
3702
3829
  const playing = e.currentTarget.checked;
3703
3830
  run(() => controller.updateNodeEffect(nodeId, { playing }));
3704
3831
  } }),
3705
3832
  " Play"
3706
3833
  ] }),
3707
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: btn, "aria-label": "Remove effect", onClick: () => run(() => controller.removeNodeEffect(nodeId)), children: "\u2715" })
3834
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn, "aria-label": "Remove effect", onClick: () => run(() => controller.removeNodeEffect(nodeId)), children: "\u2715" })
3708
3835
  ] }),
3709
- provider && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Controls, { controller, nodeId, effect })
3836
+ provider && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Controls, { controller, nodeId, effect })
3710
3837
  ] }),
3711
- sceneId && transition && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-1", "data-canvas-scene-transition": sceneId, children: [
3712
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "min-w-0 flex-1 truncate", children: [
3838
+ sceneId && transition && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1", "data-canvas-scene-transition": sceneId, children: [
3839
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "min-w-0 flex-1 truncate", children: [
3713
3840
  "Into scene: ",
3714
3841
  transition.name ?? transition.effect,
3715
3842
  " (",
3716
3843
  transition.duration ?? 600,
3717
3844
  " ms)"
3718
3845
  ] }),
3719
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: btn, "aria-label": "Remove transition", onClick: () => run(() => controller.setSceneTransition(sceneId, null)), children: "\u2715" })
3846
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn, "aria-label": "Remove transition", onClick: () => run(() => controller.setSceneTransition(sceneId, null)), children: "\u2715" })
3720
3847
  ] }),
3721
- message && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
3848
+ message && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
3722
3849
  ] });
3723
3850
  }
3724
3851
 
3725
3852
  // src/canvas/ShapeNode.tsx
3726
- var import_jsx_runtime14 = require("react/jsx-runtime");
3853
+ var import_jsx_runtime15 = require("react/jsx-runtime");
3727
3854
  function ShapeNode({ id, data, width, height, selected, className = "", children, positionAbsoluteX, positionAbsoluteY }) {
3728
3855
  const shape = data?.shape;
3729
3856
  const brushImage = useShapeBrushstroke((0, import_canvas17.isShapeDescription)(shape) ? shape : null, width, height, { x: positionAbsoluteX ?? 0, y: positionAbsoluteY ?? 0 });
3730
3857
  if (!(0, import_canvas17.isShapeDescription)(shape)) return null;
3731
3858
  const render = (0, import_canvas17.getShapeRenderData)(shape, { width, height }, { id: id || data?.id });
3732
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
3859
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
3733
3860
  "div",
3734
3861
  {
3735
3862
  className: `pixerate-shape-node ${className}`.trim(),
@@ -3737,7 +3864,7 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
3737
3864
  "data-selected": selected ? "true" : void 0,
3738
3865
  style: { position: "relative", width: "100%", height: "100%" },
3739
3866
  children: [
3740
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
3867
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
3741
3868
  "svg",
3742
3869
  {
3743
3870
  viewBox: render.viewBox,
@@ -3747,13 +3874,13 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
3747
3874
  style: { display: "block", overflow: "visible" },
3748
3875
  "aria-hidden": "true",
3749
3876
  children: [
3750
- (render.fillGradient || render.strokeGradient) && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("defs", { children: [
3751
- render.fillGradient && render.fillGradient.type === "linear" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("linearGradient", { id: render.fillGradient.id, ...render.fillGradient.attrs, children: render.fillGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
3752
- render.fillGradient && render.fillGradient.type === "radial" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("radialGradient", { id: render.fillGradient.id, ...render.fillGradient.attrs, children: render.fillGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
3753
- render.strokeGradient && render.strokeGradient.type === "linear" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("linearGradient", { id: render.strokeGradient.id, ...render.strokeGradient.attrs, children: render.strokeGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
3754
- render.strokeGradient && render.strokeGradient.type === "radial" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("radialGradient", { id: render.strokeGradient.id, ...render.strokeGradient.attrs, children: render.strokeGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) })
3877
+ (render.fillGradient || render.strokeGradient) && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("defs", { children: [
3878
+ render.fillGradient && render.fillGradient.type === "linear" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("linearGradient", { id: render.fillGradient.id, ...render.fillGradient.attrs, children: render.fillGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
3879
+ render.fillGradient && render.fillGradient.type === "radial" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("radialGradient", { id: render.fillGradient.id, ...render.fillGradient.attrs, children: render.fillGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
3880
+ render.strokeGradient && render.strokeGradient.type === "linear" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("linearGradient", { id: render.strokeGradient.id, ...render.strokeGradient.attrs, children: render.strokeGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
3881
+ render.strokeGradient && render.strokeGradient.type === "radial" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("radialGradient", { id: render.strokeGradient.id, ...render.strokeGradient.attrs, children: render.strokeGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) })
3755
3882
  ] }),
3756
- brushImage ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("g", { transform: render.transform, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3883
+ brushImage ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("g", { transform: render.transform, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3757
3884
  "image",
3758
3885
  {
3759
3886
  className: "pixerate-shape-brushstroke",
@@ -3765,7 +3892,7 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
3765
3892
  preserveAspectRatio: "none",
3766
3893
  opacity: render.opacity
3767
3894
  }
3768
- ) }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3895
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3769
3896
  "path",
3770
3897
  {
3771
3898
  d: render.d,
@@ -3783,7 +3910,7 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
3783
3910
  ]
3784
3911
  }
3785
3912
  ),
3786
- shape.effect && width && height ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CanvasNodeEffectLayer, { effect: shape.effect, width, height, clipPath: render.d, clipTransform: render.transform }) : null,
3913
+ shape.effect && width && height ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CanvasNodeEffectLayer, { effect: shape.effect, width, height, clipPath: render.d, clipTransform: render.transform }) : null,
3787
3914
  children
3788
3915
  ]
3789
3916
  }
@@ -3797,15 +3924,15 @@ var import_canvas34 = require("@pixerate/editor/canvas");
3797
3924
  var import_canvas35 = require("@pixerate/editor/canvas");
3798
3925
 
3799
3926
  // src/canvas/useCanvasAutoLayout.ts
3800
- var import_react30 = require("react");
3927
+ var import_react31 = require("react");
3801
3928
  var import_canvas18 = require("@pixerate/editor/canvas");
3802
3929
  function useCanvasAutoLayout(options) {
3803
- const [guides, setGuides] = (0, import_react30.useState)([]);
3804
- const nodesRef = (0, import_react30.useRef)(options.nodes);
3930
+ const [guides, setGuides] = (0, import_react31.useState)([]);
3931
+ const nodesRef = (0, import_react31.useRef)(options.nodes);
3805
3932
  nodesRef.current = options.nodes;
3806
- const optionsRef = (0, import_react30.useRef)(options);
3933
+ const optionsRef = (0, import_react31.useRef)(options);
3807
3934
  optionsRef.current = options;
3808
- const controller = (0, import_react30.useMemo)(
3935
+ const controller = (0, import_react31.useMemo)(
3809
3936
  () => (0, import_canvas18.createCanvasAutoLayoutController)({
3810
3937
  getNodes: () => nodesRef.current,
3811
3938
  setNodes: (next) => {
@@ -3831,10 +3958,10 @@ function useCanvasAutoLayout(options) {
3831
3958
  }),
3832
3959
  []
3833
3960
  );
3834
- (0, import_react30.useLayoutEffect)(() => {
3961
+ (0, import_react31.useLayoutEffect)(() => {
3835
3962
  if (controller.hasPending) controller.flush();
3836
3963
  }, [options.nodes, controller]);
3837
- return (0, import_react30.useMemo)(
3964
+ return (0, import_react31.useMemo)(
3838
3965
  () => ({
3839
3966
  ...controller,
3840
3967
  /** Drop marker of the active reorder drag (flow coordinates). */
@@ -3848,15 +3975,15 @@ function useCanvasAutoLayout(options) {
3848
3975
  }
3849
3976
 
3850
3977
  // src/canvas/useCanvasTokens.ts
3851
- var import_react31 = require("react");
3978
+ var import_react32 = require("react");
3852
3979
  var import_canvas19 = require("@pixerate/editor/canvas");
3853
3980
  function useCanvasTokens(options) {
3854
3981
  const { store, nodes, setNodes, modes, properties } = options;
3855
- const state = (0, import_react31.useSyncExternalStore)(store.subscribe, store.getState, store.getState);
3856
- const latest = (0, import_react31.useRef)({ nodes, setNodes, modes, properties });
3982
+ const state = (0, import_react32.useSyncExternalStore)(store.subscribe, store.getState, store.getState);
3983
+ const latest = (0, import_react32.useRef)({ nodes, setNodes, modes, properties });
3857
3984
  latest.current = { nodes, setNodes, modes, properties };
3858
3985
  const opts = () => ({ modes: latest.current.modes, properties: latest.current.properties });
3859
- (0, import_react31.useEffect)(
3986
+ (0, import_react32.useEffect)(
3860
3987
  () => store.subscribe((event) => {
3861
3988
  if (event.deletedVariableIds.length === 0) return;
3862
3989
  latest.current.setNodes((prev) => (0, import_canvas19.detachTokenBindings)(prev, event.previous, event.deletedVariableIds, opts()));
@@ -3865,11 +3992,11 @@ function useCanvasTokens(options) {
3865
3992
  [store]
3866
3993
  );
3867
3994
  const modesKey = JSON.stringify(modes ?? {});
3868
- (0, import_react31.useEffect)(() => {
3995
+ (0, import_react32.useEffect)(() => {
3869
3996
  const next = (0, import_canvas19.resolveCanvasTokens)(nodes, state, opts());
3870
3997
  if (next !== nodes) setNodes(next);
3871
3998
  }, [nodes, state, modesKey, properties]);
3872
- const bind = (0, import_react31.useCallback)(
3999
+ const bind = (0, import_react32.useCallback)(
3873
4000
  (ids, propertyKey, variableId) => {
3874
4001
  const next = (0, import_canvas19.bindCanvasToken)(latest.current.nodes, ids, propertyKey, variableId, store.getState(), opts());
3875
4002
  if (next !== latest.current.nodes) latest.current.setNodes(next);
@@ -3877,7 +4004,7 @@ function useCanvasTokens(options) {
3877
4004
  // eslint-disable-next-line react-hooks/exhaustive-deps
3878
4005
  [store]
3879
4006
  );
3880
- const setMode = (0, import_react31.useCallback)(
4007
+ const setMode = (0, import_react32.useCallback)(
3881
4008
  (ids, collectionId, modeId) => {
3882
4009
  const next = (0, import_canvas19.setCanvasTokenMode)(latest.current.nodes, ids, collectionId, modeId, store.getState(), opts());
3883
4010
  if (next !== latest.current.nodes) latest.current.setNodes(next);
@@ -3885,7 +4012,7 @@ function useCanvasTokens(options) {
3885
4012
  // eslint-disable-next-line react-hooks/exhaustive-deps
3886
4013
  [store]
3887
4014
  );
3888
- const modesOf = (0, import_react31.useCallback)(
4015
+ const modesOf = (0, import_react32.useCallback)(
3889
4016
  (nodeId) => {
3890
4017
  const node = latest.current.nodes.find((n) => n.id === nodeId);
3891
4018
  return node ? (0, import_canvas19.getEffectiveTokenModes)(node, latest.current.nodes, store.getState(), opts()) : {};
@@ -3899,7 +4026,7 @@ function useCanvasTokens(options) {
3899
4026
  // src/canvas/TokenBindingPicker.tsx
3900
4027
  var import_canvas20 = require("@pixerate/editor/canvas");
3901
4028
  var import_tokens = require("@pixerate/editor/tokens");
3902
- var import_jsx_runtime15 = require("react/jsx-runtime");
4029
+ var import_jsx_runtime16 = require("react/jsx-runtime");
3903
4030
  function TokenBindingPicker({
3904
4031
  state,
3905
4032
  nodes,
@@ -3916,15 +4043,15 @@ function TokenBindingPicker({
3916
4043
  let rows = (0, import_canvas20.getBindableTokenProperties)(first, options);
3917
4044
  if (properties) rows = properties.map((key) => rows.find((p) => p.key === key)).filter((p) => !!p);
3918
4045
  const modes = (0, import_canvas20.getEffectiveTokenModes)(first, nodes, state, options);
3919
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { "data-token-binding-picker": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, children: [
4046
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { "data-token-binding-picker": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, children: [
3920
4047
  rows.map((property) => {
3921
4048
  const ids = new Set(selected.map((n) => (0, import_canvas20.getNodeTokenBindings)(n)[property.key] ?? ""));
3922
4049
  const value = ids.size === 1 ? [...ids][0] : "__mixed";
3923
4050
  const candidates = (0, import_canvas20.getTokensForProperty)(state, property, first);
3924
4051
  const resolved = value && value !== "__mixed" ? (0, import_tokens.resolveToken)(state, value, modes) : null;
3925
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-2", "data-token-property": property.key, children: [
3926
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "w-28 shrink-0 text-muted-foreground", children: property.label }),
3927
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
4052
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-2", "data-token-property": property.key, children: [
4053
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-28 shrink-0 text-muted-foreground", children: property.label }),
4054
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
3928
4055
  "select",
3929
4056
  {
3930
4057
  "aria-label": `${property.label} variable`,
@@ -3939,11 +4066,11 @@ function TokenBindingPicker({
3939
4066
  }
3940
4067
  },
3941
4068
  children: [
3942
- value === "__mixed" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "__mixed", children: "Mixed" }) : null,
3943
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "", children: "None" }),
4069
+ value === "__mixed" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "__mixed", children: "Mixed" }) : null,
4070
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "", children: "None" }),
3944
4071
  candidates.map((v) => {
3945
4072
  const collection = state.collections.find((c) => c.id === v.collectionId);
3946
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("option", { value: v.id, children: [
4073
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("option", { value: v.id, children: [
3947
4074
  v.name,
3948
4075
  collection && state.collections.length > 1 ? ` (${collection.name})` : ""
3949
4076
  ] }, v.id);
@@ -3951,17 +4078,17 @@ function TokenBindingPicker({
3951
4078
  ]
3952
4079
  }
3953
4080
  ),
3954
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "w-16 shrink-0 truncate text-right text-muted-foreground", "data-token-resolved": "", children: resolved?.ok ? property.type === "color" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4081
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-16 shrink-0 truncate text-right text-muted-foreground", "data-token-resolved": "", children: resolved?.ok ? property.type === "color" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3955
4082
  "span",
3956
4083
  {
3957
4084
  className: "inline-block h-3 w-3 rounded border border-border align-middle",
3958
4085
  style: { background: String(resolved.value) },
3959
4086
  title: String(resolved.value)
3960
4087
  }
3961
- ) : String(resolved.value) : resolved ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { title: resolved.message, children: "\u26A0" }) : null })
4088
+ ) : String(resolved.value) : resolved ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { title: resolved.message, children: "\u26A0" }) : null })
3962
4089
  ] }, property.key);
3963
4090
  }),
3964
- state.collections.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-muted-foreground", children: "No variables yet." }) : null
4091
+ state.collections.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-muted-foreground", children: "No variables yet." }) : null
3965
4092
  ] });
3966
4093
  }
3967
4094
  function TokenModeSwitcher({
@@ -3979,12 +4106,12 @@ function TokenModeSwitcher({
3979
4106
  const parent = first.parentId ? nodes.find((n) => n.id === first.parentId) : void 0;
3980
4107
  const inherited = parent ? (0, import_canvas20.getEffectiveTokenModes)(parent, nodes, state, options) : { ...options.modes };
3981
4108
  const collections = state.collections.filter((c) => showSingleMode || c.modes.length > 1);
3982
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { "data-token-mode-switcher": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, children: collections.map((collection) => {
4109
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { "data-token-mode-switcher": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, children: collections.map((collection) => {
3983
4110
  const auto = (0, import_tokens.getCurrentMode)(collection, inherited);
3984
4111
  const explicit = collection.modes.some((m) => m.id === own[collection.id]) ? own[collection.id] : "";
3985
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { className: "flex items-center gap-2", "data-token-collection": collection.id, children: [
3986
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "w-28 shrink-0 truncate text-muted-foreground", children: collection.name }),
3987
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
4112
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-2", "data-token-collection": collection.id, children: [
4113
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-28 shrink-0 truncate text-muted-foreground", children: collection.name }),
4114
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
3988
4115
  "select",
3989
4116
  {
3990
4117
  "aria-label": `${collection.name} mode`,
@@ -3992,12 +4119,12 @@ function TokenModeSwitcher({
3992
4119
  value: explicit,
3993
4120
  onChange: (e) => onChange((0, import_canvas20.setCanvasTokenMode)(nodes, nodeIds, collection.id, e.currentTarget.value || null, state, options)),
3994
4121
  children: [
3995
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("option", { value: "", children: [
4122
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("option", { value: "", children: [
3996
4123
  "Auto (",
3997
4124
  auto.name,
3998
4125
  ")"
3999
4126
  ] }),
4000
- collection.modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: m.id, children: m.name }, m.id))
4127
+ collection.modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: m.id, children: m.name }, m.id))
4001
4128
  ]
4002
4129
  }
4003
4130
  )
@@ -4009,14 +4136,14 @@ function TokenModeSwitcher({
4009
4136
  var import_canvas36 = require("@pixerate/editor/canvas");
4010
4137
 
4011
4138
  // src/canvas/useCanvasAnimation.ts
4012
- var import_react32 = require("react");
4139
+ var import_react33 = require("react");
4013
4140
  var import_canvas21 = require("@pixerate/editor/canvas");
4014
4141
  function useCanvasAnimation(options) {
4015
- const nodesRef = (0, import_react32.useRef)(options.nodes);
4142
+ const nodesRef = (0, import_react33.useRef)(options.nodes);
4016
4143
  nodesRef.current = options.nodes;
4017
- const optionsRef = (0, import_react32.useRef)(options);
4144
+ const optionsRef = (0, import_react33.useRef)(options);
4018
4145
  optionsRef.current = options;
4019
- const controller = (0, import_react32.useMemo)(
4146
+ const controller = (0, import_react33.useMemo)(
4020
4147
  () => (0, import_canvas21.createCanvasAnimationController)({
4021
4148
  getNodes: () => nodesRef.current,
4022
4149
  setNodes: (next) => {
@@ -4043,26 +4170,26 @@ function useCanvasAnimation(options) {
4043
4170
  }),
4044
4171
  []
4045
4172
  );
4046
- (0, import_react32.useEffect)(() => () => controller.destroy(), [controller]);
4047
- (0, import_react32.useEffect)(() => {
4173
+ (0, import_react33.useEffect)(() => () => controller.destroy(), [controller]);
4174
+ (0, import_react33.useEffect)(() => {
4048
4175
  if (options.loop !== void 0) controller.setLoop(options.loop);
4049
4176
  }, [controller, options.loop]);
4050
- (0, import_react32.useEffect)(() => {
4177
+ (0, import_react33.useEffect)(() => {
4051
4178
  if (options.playbackRate !== void 0) controller.setPlaybackRate(options.playbackRate);
4052
4179
  }, [controller, options.playbackRate]);
4053
- (0, import_react32.useEffect)(() => {
4180
+ (0, import_react33.useEffect)(() => {
4054
4181
  if (options.recording !== void 0) controller.setRecording(options.recording);
4055
4182
  }, [controller, options.recording]);
4056
- const state = (0, import_react32.useSyncExternalStore)(
4183
+ const state = (0, import_react33.useSyncExternalStore)(
4057
4184
  (listener) => controller.subscribe(listener),
4058
4185
  () => controller.getState(),
4059
4186
  () => controller.getState()
4060
4187
  );
4061
- (0, import_react32.useEffect)(() => {
4188
+ (0, import_react33.useEffect)(() => {
4062
4189
  controller.refresh();
4063
4190
  }, [controller, options.nodes]);
4064
- const displayNodes = (0, import_react32.useMemo)(() => controller.display(options.nodes), [controller, options.nodes, state.time]);
4065
- return (0, import_react32.useMemo)(
4191
+ const displayNodes = (0, import_react33.useMemo)(() => controller.display(options.nodes), [controller, options.nodes, state.time]);
4192
+ return (0, import_react33.useMemo)(
4066
4193
  () => ({
4067
4194
  ...controller,
4068
4195
  state,
@@ -4083,9 +4210,9 @@ function useCanvasAnimation(options) {
4083
4210
  }
4084
4211
 
4085
4212
  // src/canvas/AnimationTimeline.tsx
4086
- var import_react33 = require("react");
4213
+ var import_react34 = require("react");
4087
4214
  var import_canvas22 = require("@pixerate/editor/canvas");
4088
- var import_jsx_runtime16 = require("react/jsx-runtime");
4215
+ var import_jsx_runtime17 = require("react/jsx-runtime");
4089
4216
  var LOOP_LABELS = { none: "Once", loop: "Loop", "ping-pong": "Ping-pong" };
4090
4217
  var easingValue = (easing) => typeof easing === "string" ? easing : easing ? "custom" : "linear";
4091
4218
  function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8, labelOf, className = "" }) {
@@ -4099,8 +4226,8 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
4099
4226
  for (const row of rows) for (const k of row.keyframes) if (k.selected && k.ref.property === first.property && k.ref.nodeId === first.nodeId) return easingValue(k.easing);
4100
4227
  return "";
4101
4228
  })();
4102
- const dragRef = (0, import_react33.useRef)(null);
4103
- (0, import_react33.useEffect)(() => {
4229
+ const dragRef = (0, import_react34.useRef)(null);
4230
+ (0, import_react34.useEffect)(() => {
4104
4231
  const onKey = (event) => {
4105
4232
  if (event.key === "Escape" && dragRef.current) {
4106
4233
  dragRef.current = null;
@@ -4156,10 +4283,10 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
4156
4283
  const btn2 = "rounded border border-border px-2 py-0.5 text-xs hover:bg-muted disabled:opacity-50";
4157
4284
  const playheadX = (0, import_canvas22.timeToX)(state.time, duration, width);
4158
4285
  const labelWidth = 120;
4159
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { "data-animation-timeline": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, tabIndex: 0, onKeyDown: onTimelineKey, children: [
4160
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-wrap items-center gap-2", role: "toolbar", "aria-label": "Animation", children: [
4161
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: btn2, "data-action": "toggle-play", "aria-label": state.playing ? "Pause" : "Play", onClick: () => animation.toggle(), children: state.playing ? "\u275A\u275A" : "\u25B6" }),
4162
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4286
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { "data-animation-timeline": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, tabIndex: 0, onKeyDown: onTimelineKey, children: [
4287
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-wrap items-center gap-2", role: "toolbar", "aria-label": "Animation", children: [
4288
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: btn2, "data-action": "toggle-play", "aria-label": state.playing ? "Pause" : "Play", onClick: () => animation.toggle(), children: state.playing ? "\u275A\u275A" : "\u25B6" }),
4289
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4163
4290
  "button",
4164
4291
  {
4165
4292
  type: "button",
@@ -4171,13 +4298,13 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
4171
4298
  children: "\u25CF Rec"
4172
4299
  }
4173
4300
  ),
4174
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: btn2, "data-action": "add-keyframe", onClick: () => animation.addKeyframe(), children: "\u25C6 Key" }),
4175
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { "data-time": "", className: "tabular-nums text-muted-foreground", children: [
4301
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: btn2, "data-action": "add-keyframe", onClick: () => animation.addKeyframe(), children: "\u25C6 Key" }),
4302
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { "data-time": "", className: "tabular-nums text-muted-foreground", children: [
4176
4303
  (0, import_canvas22.formatAnimationTime)(state.time),
4177
4304
  " / ",
4178
4305
  (0, import_canvas22.formatAnimationTime)(duration)
4179
4306
  ] }),
4180
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
4307
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
4181
4308
  "select",
4182
4309
  {
4183
4310
  "aria-label": "Easing",
@@ -4187,13 +4314,13 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
4187
4314
  disabled: state.selection.length === 0,
4188
4315
  onChange: (e) => e.target.value && e.target.value !== "custom" && animation.setEasing(e.target.value),
4189
4316
  children: [
4190
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "", children: "Easing\u2026" }),
4191
- import_canvas22.ANIMATION_EASING_PRESETS.map((preset) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: preset, children: import_canvas22.ANIMATION_EASING_LABELS[preset] }, preset)),
4192
- selectedEasing === "custom" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "custom", children: "Custom" }) : null
4317
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "", children: "Easing\u2026" }),
4318
+ import_canvas22.ANIMATION_EASING_PRESETS.map((preset) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: preset, children: import_canvas22.ANIMATION_EASING_LABELS[preset] }, preset)),
4319
+ selectedEasing === "custom" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "custom", children: "Custom" }) : null
4193
4320
  ]
4194
4321
  }
4195
4322
  ),
4196
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4323
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4197
4324
  "select",
4198
4325
  {
4199
4326
  "aria-label": "Loop",
@@ -4201,13 +4328,13 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
4201
4328
  className: "rounded border border-border bg-background px-1 py-0.5",
4202
4329
  value: state.loop,
4203
4330
  onChange: (e) => animation.setLoop(e.target.value),
4204
- children: Object.keys(LOOP_LABELS).map((mode) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: mode, children: LOOP_LABELS[mode] }, mode))
4331
+ children: Object.keys(LOOP_LABELS).map((mode) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: mode, children: LOOP_LABELS[mode] }, mode))
4205
4332
  }
4206
4333
  )
4207
4334
  ] }),
4208
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex", children: [
4209
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { style: { width: labelWidth }, className: "shrink-0" }),
4210
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
4335
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex", children: [
4336
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { width: labelWidth }, className: "shrink-0" }),
4337
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
4211
4338
  "div",
4212
4339
  {
4213
4340
  "data-timeline-ruler": "",
@@ -4215,15 +4342,15 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
4215
4342
  style: { width },
4216
4343
  onPointerDown: onRulerDown,
4217
4344
  children: [
4218
- ticks.map((tick) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "absolute top-0 -translate-x-1/2 text-[10px] text-muted-foreground", style: { left: tick.x }, children: tick.label }, tick.time)),
4219
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { "data-playhead": "", className: "absolute top-0 h-5 w-px bg-red-500", style: { left: playheadX } })
4345
+ ticks.map((tick) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "absolute top-0 -translate-x-1/2 text-[10px] text-muted-foreground", style: { left: tick.x }, children: tick.label }, tick.time)),
4346
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { "data-playhead": "", className: "absolute top-0 h-5 w-px bg-red-500", style: { left: playheadX } })
4220
4347
  ]
4221
4348
  }
4222
4349
  )
4223
4350
  ] }),
4224
- rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-muted-foreground", "data-timeline-empty": "", children: "Select an animated node, or press \u25C6 Key to add a keyframe." }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center", "data-track": row.id, children: [
4225
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex shrink-0 items-center gap-1 truncate pr-2", style: { width: labelWidth }, title: `${row.nodeLabel} \xB7 ${row.label}`, children: [
4226
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4351
+ rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-muted-foreground", "data-timeline-empty": "", children: "Select an animated node, or press \u25C6 Key to add a keyframe." }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center", "data-track": row.id, children: [
4352
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex shrink-0 items-center gap-1 truncate pr-2", style: { width: labelWidth }, title: `${row.nodeLabel} \xB7 ${row.label}`, children: [
4353
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4227
4354
  "input",
4228
4355
  {
4229
4356
  type: "checkbox",
@@ -4232,15 +4359,15 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
4232
4359
  onChange: (e) => animation.setTrackEnabled(row.nodeId, row.property, e.target.checked)
4233
4360
  }
4234
4361
  ),
4235
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "truncate", children: [
4362
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "truncate", children: [
4236
4363
  rows.filter((r) => r.nodeId === row.nodeId).length < rows.length ? `${row.nodeLabel} \xB7 ` : "",
4237
4364
  row.label
4238
4365
  ] })
4239
4366
  ] }),
4240
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { "data-lane": "", className: `relative h-5 rounded bg-muted/40 ${row.enabled ? "" : "opacity-50"}`, style: { width }, children: [
4241
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "pointer-events-none absolute top-0 h-5 w-px bg-red-500/60", style: { left: playheadX } }),
4242
- state.drag?.target != null ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { "data-snap-target": "", className: "pointer-events-none absolute top-0 h-5 w-px bg-sky-400", style: { left: (0, import_canvas22.timeToX)(state.drag.target, duration, width) } }) : null,
4243
- row.keyframes.map((k) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4367
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { "data-lane": "", className: `relative h-5 rounded bg-muted/40 ${row.enabled ? "" : "opacity-50"}`, style: { width }, children: [
4368
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "pointer-events-none absolute top-0 h-5 w-px bg-red-500/60", style: { left: playheadX } }),
4369
+ state.drag?.target != null ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { "data-snap-target": "", className: "pointer-events-none absolute top-0 h-5 w-px bg-sky-400", style: { left: (0, import_canvas22.timeToX)(state.drag.target, duration, width) } }) : null,
4370
+ row.keyframes.map((k) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4244
4371
  "button",
4245
4372
  {
4246
4373
  type: "button",
@@ -4263,14 +4390,14 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
4263
4390
  var import_canvas37 = require("@pixerate/editor/canvas");
4264
4391
 
4265
4392
  // src/canvas/useCanvasComponents.ts
4266
- var import_react34 = require("react");
4393
+ var import_react35 = require("react");
4267
4394
  var import_canvas23 = require("@pixerate/editor/canvas");
4268
4395
  function useCanvasComponents(options) {
4269
- const nodesRef = (0, import_react34.useRef)(options.nodes);
4396
+ const nodesRef = (0, import_react35.useRef)(options.nodes);
4270
4397
  nodesRef.current = options.nodes;
4271
- const optionsRef = (0, import_react34.useRef)(options);
4398
+ const optionsRef = (0, import_react35.useRef)(options);
4272
4399
  optionsRef.current = options;
4273
- const controller = (0, import_react34.useMemo)(
4400
+ const controller = (0, import_react35.useMemo)(
4274
4401
  () => (0, import_canvas23.createCanvasComponentsController)({
4275
4402
  getNodes: () => nodesRef.current,
4276
4403
  setNodes: (next) => {
@@ -4299,18 +4426,18 @@ function useCanvasComponents(options) {
4299
4426
  }),
4300
4427
  []
4301
4428
  );
4302
- (0, import_react34.useLayoutEffect)(() => {
4429
+ (0, import_react35.useLayoutEffect)(() => {
4303
4430
  if (optionsRef.current.autoSync !== false) controller.sync();
4304
4431
  }, [options.nodes, controller]);
4305
4432
  return controller;
4306
4433
  }
4307
4434
 
4308
4435
  // src/canvas/CanvasComponentsPanel.tsx
4309
- var import_react35 = require("react");
4436
+ var import_react36 = require("react");
4310
4437
  var import_canvas24 = require("@pixerate/editor/canvas");
4311
- var import_jsx_runtime17 = require("react/jsx-runtime");
4438
+ var import_jsx_runtime18 = require("react/jsx-runtime");
4312
4439
  function InlineField({ value, label, onCommit }) {
4313
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4440
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4314
4441
  "input",
4315
4442
  {
4316
4443
  type: "text",
@@ -4341,10 +4468,10 @@ function CanvasComponentsPanel({
4341
4468
  search = true,
4342
4469
  className = ""
4343
4470
  }) {
4344
- const [query, setQuery] = (0, import_react35.useState)("");
4345
- const [propsOpen, setPropsOpen] = (0, import_react35.useState)(null);
4346
- const [menuFor, setMenuFor] = (0, import_react35.useState)(null);
4347
- const [editing, setEditing] = (0, import_react35.useState)(null);
4471
+ const [query, setQuery] = (0, import_react36.useState)("");
4472
+ const [propsOpen, setPropsOpen] = (0, import_react36.useState)(null);
4473
+ const [menuFor, setMenuFor] = (0, import_react36.useState)(null);
4474
+ const [editing, setEditing] = (0, import_react36.useState)(null);
4348
4475
  const { components: all, sets } = (0, import_canvas24.listCanvasComponents)(nodes);
4349
4476
  const q = query.trim().toLowerCase();
4350
4477
  const match = (name) => !q || name.toLowerCase().includes(q);
@@ -4356,7 +4483,7 @@ function CanvasComponentsPanel({
4356
4483
  };
4357
4484
  const small = "shrink-0 rounded px-1 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-40";
4358
4485
  const menuItem = "rounded px-2 py-0.5 text-left hover:bg-muted disabled:opacity-40";
4359
- const item = (id, name, count, extra = {}, onContextMenu) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
4486
+ const item = (id, name, count, extra = {}, onContextMenu) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
4360
4487
  "button",
4361
4488
  {
4362
4489
  type: "button",
@@ -4373,17 +4500,17 @@ function CanvasComponentsPanel({
4373
4500
  e.dataTransfer.effectAllowed = "copy";
4374
4501
  },
4375
4502
  children: [
4376
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "truncate", children: [
4377
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { "aria-hidden": true, className: "mr-1 text-muted-foreground", children: "\u25C7" }),
4503
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "truncate", children: [
4504
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { "aria-hidden": true, className: "mr-1 text-muted-foreground", children: "\u25C7" }),
4378
4505
  name
4379
4506
  ] }),
4380
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-[10px] text-muted-foreground", "data-instance-count": "", children: count })
4507
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-[10px] text-muted-foreground", "data-instance-count": "", children: count })
4381
4508
  ]
4382
4509
  },
4383
4510
  id
4384
4511
  );
4385
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { "data-components-panel": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, children: [
4386
- search ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4512
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { "data-components-panel": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, children: [
4513
+ search ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4387
4514
  "input",
4388
4515
  {
4389
4516
  type: "search",
@@ -4393,11 +4520,11 @@ function CanvasComponentsPanel({
4393
4520
  onInput: (e) => setQuery(e.target.value)
4394
4521
  }
4395
4522
  ) : null,
4396
- shownSets.map((set) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { "data-component-set": set.id, className: "flex flex-col", children: [
4397
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-1", children: [
4523
+ shownSets.map((set) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { "data-component-set": set.id, className: "flex flex-col", children: [
4524
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-1", children: [
4398
4525
  item(set.id, set.name, set.variants.reduce((sum, v) => sum + v.instanceCount, 0), { "data-kind": "set" }),
4399
- components ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
4400
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4526
+ components ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
4527
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4401
4528
  "button",
4402
4529
  {
4403
4530
  type: "button",
@@ -4409,7 +4536,7 @@ function CanvasComponentsPanel({
4409
4536
  children: "+\xA0Variant"
4410
4537
  }
4411
4538
  ),
4412
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4539
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4413
4540
  "button",
4414
4541
  {
4415
4542
  type: "button",
@@ -4424,8 +4551,8 @@ function CanvasComponentsPanel({
4424
4551
  )
4425
4552
  ] }) : null
4426
4553
  ] }),
4427
- components && propsOpen === set.id ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { "data-variant-properties": set.id, className: "ml-3 flex flex-col gap-1 border-l border-border py-1 pl-2", children: set.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { "data-variant-option": option.name, className: "flex flex-col gap-0.5", children: [
4428
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4554
+ components && propsOpen === set.id ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { "data-variant-properties": set.id, className: "ml-3 flex flex-col gap-1 border-l border-border py-1 pl-2", children: set.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { "data-variant-option": option.name, className: "flex flex-col gap-0.5", children: [
4555
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4429
4556
  InlineField,
4430
4557
  {
4431
4558
  value: option.name,
@@ -4433,7 +4560,7 @@ function CanvasComponentsPanel({
4433
4560
  onCommit: (next) => report(components.renameVariantProperty(option.name, next, set.id))
4434
4561
  }
4435
4562
  ),
4436
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "ml-2 flex flex-wrap gap-1", children: option.values.map((value) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4563
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "ml-2 flex flex-wrap gap-1", children: option.values.map((value) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4437
4564
  InlineField,
4438
4565
  {
4439
4566
  value,
@@ -4443,8 +4570,8 @@ function CanvasComponentsPanel({
4443
4570
  value
4444
4571
  )) })
4445
4572
  ] }, option.name)) }) : null,
4446
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "ml-3 flex flex-col border-l border-border pl-1", children: set.variants.map((v) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { "data-variant-row": v.id, className: "flex flex-col", children: [
4447
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-1", children: [
4573
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "ml-3 flex flex-col border-l border-border pl-1", children: set.variants.map((v) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { "data-variant-row": v.id, className: "flex flex-col", children: [
4574
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-1", children: [
4448
4575
  item(
4449
4576
  v.id,
4450
4577
  v.name,
@@ -4455,7 +4582,7 @@ function CanvasComponentsPanel({
4455
4582
  setMenuFor(v.id);
4456
4583
  } : void 0
4457
4584
  ),
4458
- components ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4585
+ components ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4459
4586
  "button",
4460
4587
  {
4461
4588
  type: "button",
@@ -4469,8 +4596,8 @@ function CanvasComponentsPanel({
4469
4596
  }
4470
4597
  ) : null
4471
4598
  ] }),
4472
- components && menuFor === v.id ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { role: "menu", "data-variant-menu": v.id, className: "ml-2 flex flex-col rounded border border-border bg-background p-1 shadow", children: [
4473
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4599
+ components && menuFor === v.id ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { role: "menu", "data-variant-menu": v.id, className: "ml-2 flex flex-col rounded border border-border bg-background p-1 shadow", children: [
4600
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4474
4601
  "button",
4475
4602
  {
4476
4603
  type: "button",
@@ -4484,7 +4611,7 @@ function CanvasComponentsPanel({
4484
4611
  children: "Edit values\u2026"
4485
4612
  }
4486
4613
  ),
4487
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4614
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4488
4615
  "button",
4489
4616
  {
4490
4617
  type: "button",
@@ -4498,7 +4625,7 @@ function CanvasComponentsPanel({
4498
4625
  children: "Duplicate"
4499
4626
  }
4500
4627
  ),
4501
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4628
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4502
4629
  "button",
4503
4630
  {
4504
4631
  type: "button",
@@ -4515,7 +4642,7 @@ function CanvasComponentsPanel({
4515
4642
  }
4516
4643
  )
4517
4644
  ] }) : null,
4518
- components && editing === v.id ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
4645
+ components && editing === v.id ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
4519
4646
  "form",
4520
4647
  {
4521
4648
  "data-variant-editor": v.id,
@@ -4529,9 +4656,9 @@ function CanvasComponentsPanel({
4529
4656
  if (report(components.setVariantProperties(values, v.id))) setEditing(null);
4530
4657
  },
4531
4658
  children: [
4532
- set.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex items-center gap-2", children: [
4533
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "w-16 shrink-0 truncate text-muted-foreground", children: option.name }),
4534
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4659
+ set.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-2", children: [
4660
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "w-16 shrink-0 truncate text-muted-foreground", children: option.name }),
4661
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4535
4662
  "input",
4536
4663
  {
4537
4664
  type: "text",
@@ -4542,9 +4669,9 @@ function CanvasComponentsPanel({
4542
4669
  }
4543
4670
  )
4544
4671
  ] }, option.name)),
4545
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex gap-1", children: [
4546
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "submit", className: "rounded border border-border px-2 py-0.5 hover:bg-muted", "data-action": "save-variant", children: "Save" }),
4547
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: "rounded px-2 py-0.5 hover:bg-muted", "data-action": "cancel-variant", onClick: () => setEditing(null), children: "Cancel" })
4672
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex gap-1", children: [
4673
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "submit", className: "rounded border border-border px-2 py-0.5 hover:bg-muted", "data-action": "save-variant", children: "Save" }),
4674
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: "rounded px-2 py-0.5 hover:bg-muted", "data-action": "cancel-variant", onClick: () => setEditing(null), children: "Cancel" })
4548
4675
  ] })
4549
4676
  ]
4550
4677
  }
@@ -4552,7 +4679,7 @@ function CanvasComponentsPanel({
4552
4679
  ] }, v.id)) })
4553
4680
  ] }, set.id)),
4554
4681
  lone.map((c) => item(c.id, c.name, c.instanceCount, { "data-kind": "component" })),
4555
- all.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-muted-foreground", children: "No components yet. Select a frame and choose Create Component." }) : null
4682
+ all.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "text-muted-foreground", children: "No components yet. Select a frame and choose Create Component." }) : null
4556
4683
  ] });
4557
4684
  }
4558
4685
  function CanvasInstanceInspector({
@@ -4571,27 +4698,27 @@ function CanvasInstanceInspector({
4571
4698
  const allComponents = (0, import_canvas24.listCanvasComponents)(nodes).components;
4572
4699
  const linked = info.status === "linked";
4573
4700
  const btn2 = "rounded border border-border px-2 py-0.5 text-xs hover:bg-muted disabled:opacity-40";
4574
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { "data-instance-inspector": "", "data-instance-id": info.id, className: `flex flex-col gap-2 text-xs text-foreground ${className}`, children: [
4575
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
4576
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "truncate font-medium", "data-instance-main": "", children: linked ? info.componentName : "Main component missing" }),
4577
- info.nested ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-muted-foreground", children: "Nested" }) : null
4701
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { "data-instance-inspector": "", "data-instance-id": info.id, className: `flex flex-col gap-2 text-xs text-foreground ${className}`, children: [
4702
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
4703
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "truncate font-medium", "data-instance-main": "", children: linked ? info.componentName : "Main component missing" }),
4704
+ info.nested ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-muted-foreground", children: "Nested" }) : null
4578
4705
  ] }),
4579
- info.variantOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex items-center gap-2", "data-variant-property": option.name, children: [
4580
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "w-24 shrink-0 truncate text-muted-foreground", children: option.name }),
4581
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4706
+ info.variantOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-2", "data-variant-property": option.name, children: [
4707
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "w-24 shrink-0 truncate text-muted-foreground", children: option.name }),
4708
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4582
4709
  "select",
4583
4710
  {
4584
4711
  "aria-label": `${option.name} variant`,
4585
4712
  className: "min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs",
4586
4713
  value: info.variant[option.name] ?? "",
4587
4714
  onChange: (e) => setProp(option.name, e.currentTarget.value),
4588
- children: option.values.map((v) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: v, children: v }, v))
4715
+ children: option.values.map((v) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: v, children: v }, v))
4589
4716
  }
4590
4717
  )
4591
4718
  ] }, option.name)),
4592
- info.properties.map((p) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex items-center gap-2", "data-component-property": p.name, children: [
4593
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "w-24 shrink-0 truncate text-muted-foreground", children: p.name }),
4594
- p.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("input", { type: "checkbox", "aria-label": p.name, checked: p.value === true, onChange: (e) => setProp(p.name, e.currentTarget.checked) }) : p.type === "text" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4719
+ info.properties.map((p) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-2", "data-component-property": p.name, children: [
4720
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "w-24 shrink-0 truncate text-muted-foreground", children: p.name }),
4721
+ p.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("input", { type: "checkbox", "aria-label": p.name, checked: p.value === true, onChange: (e) => setProp(p.name, e.currentTarget.checked) }) : p.type === "text" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4595
4722
  "input",
4596
4723
  {
4597
4724
  type: "text",
@@ -4606,22 +4733,22 @@ function CanvasInstanceInspector({
4606
4733
  }
4607
4734
  },
4608
4735
  String(p.value)
4609
- ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4736
+ ) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4610
4737
  "select",
4611
4738
  {
4612
4739
  "aria-label": p.name,
4613
4740
  className: "min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs",
4614
4741
  value: String(p.value),
4615
4742
  onChange: (e) => setProp(p.name, e.currentTarget.value),
4616
- children: allComponents.filter((c) => !p.preferred?.length || p.preferred.includes(c.id) || c.id === p.value).map((c) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: c.id, children: c.name }, c.id))
4743
+ children: allComponents.filter((c) => !p.preferred?.length || p.preferred.includes(c.id) || c.id === p.value).map((c) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: c.id, children: c.name }, c.id))
4617
4744
  }
4618
4745
  )
4619
4746
  ] }, p.name)),
4620
- info.overrides.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col gap-1", "data-instance-overrides": "", children: [
4621
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-muted-foreground", children: "Overrides" }),
4622
- info.overrides.map((o) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-wrap items-center gap-1", "data-override-layer": o.id, children: [
4623
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "mr-1 truncate", children: o.name }),
4624
- o.groups.map((g) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
4747
+ info.overrides.length ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-1", "data-instance-overrides": "", children: [
4748
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-muted-foreground", children: "Overrides" }),
4749
+ info.overrides.map((o) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-wrap items-center gap-1", "data-override-layer": o.id, children: [
4750
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "mr-1 truncate", children: o.name }),
4751
+ o.groups.map((g) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
4625
4752
  "button",
4626
4753
  {
4627
4754
  type: "button",
@@ -4638,11 +4765,11 @@ function CanvasInstanceInspector({
4638
4765
  ))
4639
4766
  ] }, o.id))
4640
4767
  ] }) : null,
4641
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
4642
- linked ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
4643
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: btn2, "data-action": "reset", onClick: () => report(components.resetOverrides(info.id)), children: "Reset all" }),
4644
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: btn2, "data-action": "go-to-main", onClick: () => components.goToMainComponent(info.id), children: "Go to main" }),
4645
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4768
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
4769
+ linked ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
4770
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: btn2, "data-action": "reset", onClick: () => report(components.resetOverrides(info.id)), children: "Reset all" }),
4771
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: btn2, "data-action": "go-to-main", onClick: () => components.goToMainComponent(info.id), children: "Go to main" }),
4772
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4646
4773
  "button",
4647
4774
  {
4648
4775
  type: "button",
@@ -4653,8 +4780,8 @@ function CanvasInstanceInspector({
4653
4780
  children: "Push changes"
4654
4781
  }
4655
4782
  )
4656
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: btn2, "data-action": "restore", onClick: () => report(components.restoreMainComponent(info.rootId)), children: "Restore main component" }),
4657
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4783
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: btn2, "data-action": "restore", onClick: () => report(components.restoreMainComponent(info.rootId)), children: "Restore main component" }),
4784
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4658
4785
  "button",
4659
4786
  {
4660
4787
  type: "button",
@@ -4674,9 +4801,9 @@ function CanvasInstanceInspector({
4674
4801
  var import_canvas38 = require("@pixerate/editor/canvas");
4675
4802
 
4676
4803
  // src/canvas/MermaidFamilyScene.tsx
4677
- var import_react36 = require("react");
4804
+ var import_react37 = require("react");
4678
4805
  var import_canvas25 = require("@pixerate/editor/canvas");
4679
- var import_jsx_runtime18 = require("react/jsx-runtime");
4806
+ var import_jsx_runtime19 = require("react/jsx-runtime");
4680
4807
  function MermaidFamilyScene({
4681
4808
  scene,
4682
4809
  padding = 16,
@@ -4689,7 +4816,7 @@ function MermaidFamilyScene({
4689
4816
  style,
4690
4817
  title
4691
4818
  }) {
4692
- const uid = (0, import_react36.useId)().replace(/:/g, "");
4819
+ const uid = (0, import_react37.useId)().replace(/:/g, "");
4693
4820
  const marker = (kind) => kind ? `url(#${uid}-${kind})` : void 0;
4694
4821
  const x = scene.x - padding;
4695
4822
  const y = scene.y - padding;
@@ -4707,7 +4834,7 @@ function MermaidFamilyScene({
4707
4834
  cursor: "pointer"
4708
4835
  } : { pointerEvents: "none" };
4709
4836
  const stroke = (mark) => mark.selected ? { stroke: selectionColor, strokeWidth: Math.max(2, mark.strokeWidth ?? 0) } : { stroke: mark.stroke, strokeWidth: mark.strokeWidth };
4710
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
4837
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
4711
4838
  "svg",
4712
4839
  {
4713
4840
  className: `pixerate-diagram-scene ${className}`.trim(),
@@ -4720,15 +4847,15 @@ function MermaidFamilyScene({
4720
4847
  style: { display: "block", maxWidth: "100%", height: "auto", overflow: "visible", ...style },
4721
4848
  onClick: interactive ? (event) => onSelect?.(null, event) : void 0,
4722
4849
  children: [
4723
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("defs", { children: [
4724
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("marker", { id: `${uid}-arrowclosed`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "8", markerHeight: "8", orient: "auto-start-reverse", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M0,0 L10,5 L0,10 Z", style: { fill: markerColor } }) }),
4725
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("marker", { id: `${uid}-arrow`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "8", markerHeight: "8", orient: "auto-start-reverse", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M0,0 L10,5 L0,10", style: { fill: "none", stroke: markerColor, strokeWidth: 1.5 } }) })
4850
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("defs", { children: [
4851
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("marker", { id: `${uid}-arrowclosed`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "8", markerHeight: "8", orient: "auto-start-reverse", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M0,0 L10,5 L0,10 Z", style: { fill: markerColor } }) }),
4852
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("marker", { id: `${uid}-arrow`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "8", markerHeight: "8", orient: "auto-start-reverse", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M0,0 L10,5 L0,10", style: { fill: "none", stroke: markerColor, strokeWidth: 1.5 } }) })
4726
4853
  ] }),
4727
4854
  scene.marks.map((mark) => {
4728
4855
  const common = { "data-role": mark.role, "data-target": mark.target, "data-selected": mark.selected ? "" : void 0, opacity: mark.opacity, ...handlers(mark) };
4729
4856
  switch (mark.kind) {
4730
4857
  case "rect":
4731
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4858
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4732
4859
  "rect",
4733
4860
  {
4734
4861
  ...common,
@@ -4743,9 +4870,9 @@ function MermaidFamilyScene({
4743
4870
  mark.key
4744
4871
  );
4745
4872
  case "circle":
4746
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("circle", { ...common, cx: mark.cx, cy: mark.cy, r: mark.r, style: { fill: mark.fill, ...stroke(mark) } }, mark.key);
4873
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { ...common, cx: mark.cx, cy: mark.cy, r: mark.r, style: { fill: mark.fill, ...stroke(mark) } }, mark.key);
4747
4874
  case "line":
4748
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4875
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4749
4876
  "line",
4750
4877
  {
4751
4878
  ...common,
@@ -4761,7 +4888,7 @@ function MermaidFamilyScene({
4761
4888
  mark.key
4762
4889
  );
4763
4890
  case "path":
4764
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4891
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4765
4892
  "path",
4766
4893
  {
4767
4894
  ...common,
@@ -4775,7 +4902,7 @@ function MermaidFamilyScene({
4775
4902
  mark.key
4776
4903
  );
4777
4904
  case "text":
4778
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4905
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4779
4906
  "text",
4780
4907
  {
4781
4908
  ...common,
@@ -4803,14 +4930,14 @@ function MermaidFamilyScene({
4803
4930
  }
4804
4931
 
4805
4932
  // src/canvas/useMermaidDiagram.ts
4806
- var import_react37 = require("react");
4933
+ var import_react38 = require("react");
4807
4934
  var import_diagram = require("@pixerate/editor/diagram");
4808
4935
  var import_canvas26 = require("@pixerate/editor/canvas");
4809
4936
  function useDiagramState(controller) {
4810
- return (0, import_react37.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
4937
+ return (0, import_react38.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
4811
4938
  }
4812
4939
  function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
4813
- const own = (0, import_react37.useRef)(null);
4940
+ const own = (0, import_react38.useRef)(null);
4814
4941
  let controller;
4815
4942
  if (controllerOrOptions instanceof import_diagram.DiagramController) controller = controllerOrOptions;
4816
4943
  else {
@@ -4820,21 +4947,21 @@ function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
4820
4947
  const layoutOptions = (controllerOrOptions instanceof import_diagram.DiagramController ? void 0 : controllerOrOptions.layoutOptions) ?? view.layoutOptions;
4821
4948
  const sceneTheme = (controllerOrOptions instanceof import_diagram.DiagramController ? void 0 : controllerOrOptions.sceneTheme) ?? view.sceneTheme;
4822
4949
  const state = useDiagramState(controller);
4823
- const editorDocument = (0, import_react37.useMemo)(() => (0, import_diagram.createDiagramEditorDocument)(controller), [controller]);
4824
- (0, import_react37.useEffect)(() => () => editorDocument.destroy(), [editorDocument]);
4825
- const canvas = (0, import_react37.useMemo)(
4950
+ const editorDocument = (0, import_react38.useMemo)(() => (0, import_diagram.createDiagramEditorDocument)(controller), [controller]);
4951
+ (0, import_react38.useEffect)(() => () => editorDocument.destroy(), [editorDocument]);
4952
+ const canvas = (0, import_react38.useMemo)(
4826
4953
  () => (0, import_canvas26.mermaidToCanvas)(state.document, { ...layoutOptions, editable: state.editable }),
4827
4954
  // eslint-disable-next-line react-hooks/exhaustive-deps
4828
4955
  [state.document, state.editable]
4829
4956
  );
4830
- const scene = (0, import_react37.useMemo)(
4957
+ const scene = (0, import_react38.useMemo)(
4831
4958
  () => state.document.tier === "editable" ? (0, import_canvas26.familySceneFromLayout)(state.document.family, state.document.graph, canvas.layout, { theme: { ...import_canvas26.CSS_VARIABLE_DIAGRAM_SCENE_THEME, ...sceneTheme }, selection: state.selection }) : null,
4832
4959
  // eslint-disable-next-line react-hooks/exhaustive-deps
4833
4960
  [state.document, canvas.layout, state.selection]
4834
4961
  );
4835
- const layoutRef = (0, import_react37.useRef)(canvas.layout);
4962
+ const layoutRef = (0, import_react38.useRef)(canvas.layout);
4836
4963
  layoutRef.current = canvas.layout;
4837
- const actions = (0, import_react37.useMemo)(
4964
+ const actions = (0, import_react38.useMemo)(
4838
4965
  () => ({
4839
4966
  apply: (ops, label) => controller.apply(ops, label),
4840
4967
  load: (source, options) => controller.load(source, options),
@@ -4871,13 +4998,13 @@ function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
4871
4998
  }
4872
4999
  function useMermaidStream(source, options = {}) {
4873
5000
  const { complete = false, duration = 300, ...layoutOptions } = options;
4874
- const stream = (0, import_react37.useRef)(null);
5001
+ const stream = (0, import_react38.useRef)(null);
4875
5002
  if (!stream.current) stream.current = new import_canvas26.DiagramStream(layoutOptions);
4876
- const result = (0, import_react37.useMemo)(() => stream.current.update(source, complete), [source, complete]);
4877
- const [shown, setShown] = (0, import_react37.useState)({ layout: result.layout, settled: true });
4878
- const shownRef = (0, import_react37.useRef)(shown.layout);
5003
+ const result = (0, import_react38.useMemo)(() => stream.current.update(source, complete), [source, complete]);
5004
+ const [shown, setShown] = (0, import_react38.useState)({ layout: result.layout, settled: true });
5005
+ const shownRef = (0, import_react38.useRef)(shown.layout);
4879
5006
  shownRef.current = shown.layout;
4880
- (0, import_react37.useEffect)(() => {
5007
+ (0, import_react38.useEffect)(() => {
4881
5008
  const target = result.layout;
4882
5009
  if (!target) return setShown({ layout: null, settled: true });
4883
5010
  const from = shownRef.current;
@@ -4894,7 +5021,7 @@ function useMermaidStream(source, options = {}) {
4894
5021
  return () => cancelAnimationFrame(frame);
4895
5022
  }, [result.layout, duration]);
4896
5023
  const doc = result.document.tier === "editable" ? result.document : null;
4897
- const canvas = (0, import_react37.useMemo)(() => {
5024
+ const canvas = (0, import_react38.useMemo)(() => {
4898
5025
  if (!doc || !shown.layout) return { nodes: [], edges: [] };
4899
5026
  const placed = new Set(Object.keys(shown.layout.positions));
4900
5027
  const graph = {
@@ -4910,7 +5037,7 @@ function useMermaidStream(source, options = {}) {
4910
5037
 
4911
5038
  // src/canvas/MermaidDiagramNode.tsx
4912
5039
  var import_canvas27 = require("@pixerate/editor/canvas");
4913
- var import_jsx_runtime19 = require("react/jsx-runtime");
5040
+ var import_jsx_runtime20 = require("react/jsx-runtime");
4914
5041
  function mermaidNodeStyle(styles = {}, selected = false) {
4915
5042
  const paint = (0, import_canvas27.mermaidNodePaint)(styles, selected);
4916
5043
  const { color, "stroke-width": strokeWidth, "stroke-dasharray": strokeDasharray, ...vars } = paint;
@@ -4920,7 +5047,7 @@ function MermaidDiagramNode({ data, width = 160, height = 56, selected, classNam
4920
5047
  const node = data.node;
4921
5048
  if (!node) return null;
4922
5049
  const members = (0, import_canvas27.mermaidNodeMembers)(node.data);
4923
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
5050
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
4924
5051
  "div",
4925
5052
  {
4926
5053
  className: `pixerate-diagram-node ${className}`.trim(),
@@ -4928,14 +5055,14 @@ function MermaidDiagramNode({ data, width = 160, height = 56, selected, classNam
4928
5055
  "data-selected": selected ? "true" : void 0,
4929
5056
  style: { position: "relative", width: "100%", height: "100%", ...mermaidNodeStyle(data.resolvedStyles, selected) },
4930
5057
  children: [
4931
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "none", width: "100%", height: "100%", style: { position: "absolute", inset: 0, overflow: "visible" }, "aria-hidden": "true", children: (0, import_canvas27.mermaidShapePaths)(node.shape, width, height).map((path, i) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: path.d, style: { ...import_canvas27.MERMAID_SHAPE_PAINT[path.paint], vectorEffect: "non-scaling-stroke" } }, i)) }),
4932
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
5058
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("svg", { viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "none", width: "100%", height: "100%", style: { position: "absolute", inset: 0, overflow: "visible" }, "aria-hidden": "true", children: (0, import_canvas27.mermaidShapePaths)(node.shape, width, height).map((path, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: path.d, style: { ...import_canvas27.MERMAID_SHAPE_PAINT[path.paint], vectorEffect: "non-scaling-stroke" } }, i)) }),
5059
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
4933
5060
  "div",
4934
5061
  {
4935
5062
  style: { position: "relative", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: members.length ? "flex-start" : "center", height: "100%", padding: "6px 10px", boxSizing: "border-box", fontSize: 13, lineHeight: 1.3, textAlign: "center", pointerEvents: "none" },
4936
5063
  children: [
4937
- (0, import_canvas27.mermaidLabelLines)(node.label).map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { style: { fontWeight: members.length ? 600 : void 0 }, children: line }, i)),
4938
- members.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { style: { alignSelf: "stretch", marginTop: 4, paddingTop: 4, borderTop: "1px solid var(--pixerate-diagram-node-border)", textAlign: "left", fontSize: 12 }, children: members.map((m, i) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: m }, i)) })
5064
+ (0, import_canvas27.mermaidLabelLines)(node.label).map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { style: { fontWeight: members.length ? 600 : void 0 }, children: line }, i)),
5065
+ members.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { style: { alignSelf: "stretch", marginTop: 4, paddingTop: 4, borderTop: "1px solid var(--pixerate-diagram-node-border)", textAlign: "left", fontSize: 12 }, children: members.map((m, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { children: m }, i)) })
4939
5066
  ]
4940
5067
  }
4941
5068
  ),
@@ -4947,7 +5074,7 @@ function MermaidDiagramNode({ data, width = 160, height = 56, selected, classNam
4947
5074
  function MermaidDiagramGroup({ data, selected, className = "", children }) {
4948
5075
  const group = data.group;
4949
5076
  if (!group) return null;
4950
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
5077
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
4951
5078
  "div",
4952
5079
  {
4953
5080
  className: `pixerate-diagram-group ${className}`.trim(),
@@ -4962,7 +5089,7 @@ function MermaidDiagramGroup({ data, selected, className = "", children }) {
4962
5089
  color: data.resolvedStyles?.color ?? "var(--muted-foreground, #475569)"
4963
5090
  },
4964
5091
  children: [
4965
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { style: { padding: "6px 10px", fontSize: 12, fontWeight: 600 }, children: (0, import_canvas27.mermaidLabelLines)(group.label).join(" ") }),
5092
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { style: { padding: "6px 10px", fontSize: 12, fontWeight: 600 }, children: (0, import_canvas27.mermaidLabelLines)(group.label).join(" ") }),
4966
5093
  children
4967
5094
  ]
4968
5095
  }
@@ -4970,29 +5097,29 @@ function MermaidDiagramGroup({ data, selected, className = "", children }) {
4970
5097
  }
4971
5098
 
4972
5099
  // src/canvas/MermaidThumbnail.tsx
4973
- var import_react38 = require("react");
5100
+ var import_react39 = require("react");
4974
5101
  var import_diagram2 = require("@pixerate/editor/diagram");
4975
5102
  var import_canvas28 = require("@pixerate/editor/canvas");
4976
- var import_jsx_runtime20 = require("react/jsx-runtime");
5103
+ var import_jsx_runtime21 = require("react/jsx-runtime");
4977
5104
  function MermaidThumbnail({ source, className = "", fallback = null, ...options }) {
4978
- const doc = (0, import_react38.useMemo)(() => typeof source === "string" ? (0, import_diagram2.parseMermaid)(source) : source, [source]);
5105
+ const doc = (0, import_react39.useMemo)(() => typeof source === "string" ? (0, import_diagram2.parseMermaid)(source) : source, [source]);
4979
5106
  const key = JSON.stringify(options);
4980
- const drawn = (0, import_react38.useMemo)(
5107
+ const drawn = (0, import_react39.useMemo)(
4981
5108
  () => doc.tier === "editable" && doc.graph.nodes.length ? (0, import_canvas28.mermaidThumbnailSvg)(doc, options) : null,
4982
5109
  // eslint-disable-next-line react-hooks/exhaustive-deps
4983
5110
  [doc, key]
4984
5111
  );
4985
- if (!drawn) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: fallback });
4986
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: `pixerate-diagram-thumbnail ${className}`.trim(), style: { display: "inline-block", lineHeight: 0 }, dangerouslySetInnerHTML: { __html: drawn.svg } });
5112
+ if (!drawn) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: fallback });
5113
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: `pixerate-diagram-thumbnail ${className}`.trim(), style: { display: "inline-block", lineHeight: 0 }, dangerouslySetInnerHTML: { __html: drawn.svg } });
4987
5114
  }
4988
5115
 
4989
5116
  // src/canvas/useDiagramDirector.ts
4990
- var import_react39 = require("react");
5117
+ var import_react40 = require("react");
4991
5118
  var import_diagram3 = require("@pixerate/editor/diagram");
4992
5119
  function useDiagramDirector(controller, options) {
4993
- const placement = (0, import_react39.useRef)(options.placement);
5120
+ const placement = (0, import_react40.useRef)(options.placement);
4994
5121
  placement.current = options.placement;
4995
- const ref = (0, import_react39.useRef)(null);
5122
+ const ref = (0, import_react40.useRef)(null);
4996
5123
  if (!ref.current) {
4997
5124
  const presence = new import_diagram3.PresenceStore();
4998
5125
  ref.current = {
@@ -5003,17 +5130,17 @@ function useDiagramDirector(controller, options) {
5003
5130
  return ref.current;
5004
5131
  }
5005
5132
  function usePresenceState(presence) {
5006
- return (0, import_react39.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
5133
+ return (0, import_react40.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
5007
5134
  }
5008
5135
 
5009
5136
  // src/canvas/DiagramPresenceLayer.tsx
5010
- var import_jsx_runtime21 = require("react/jsx-runtime");
5137
+ var import_jsx_runtime22 = require("react/jsx-runtime");
5011
5138
  function DiagramPresenceLayer({ presence, viewport, className = "" }) {
5012
5139
  const { actors } = usePresenceState(presence);
5013
5140
  if (!actors.length) return null;
5014
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: `pixerate-diagram-presence ${className}`.trim(), "aria-hidden": "true", style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 }, children: actors.map((a) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${a.x * viewport.zoom + viewport.x}px, ${a.y * viewport.zoom + viewport.y}px)` }, children: [
5015
- /* @__PURE__ */ (0, import_jsx_runtime21.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" }, children: /* @__PURE__ */ (0, import_jsx_runtime21.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 } }) }),
5016
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { position: "absolute", left: 14, top: 16, whiteSpace: "nowrap", borderRadius: 4, padding: "1px 6px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.message ?? a.name })
5141
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: `pixerate-diagram-presence ${className}`.trim(), "aria-hidden": "true", style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 }, children: actors.map((a) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${a.x * viewport.zoom + viewport.x}px, ${a.y * viewport.zoom + viewport.y}px)` }, children: [
5142
+ /* @__PURE__ */ (0, import_jsx_runtime22.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" }, children: /* @__PURE__ */ (0, import_jsx_runtime22.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 } }) }),
5143
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { style: { position: "absolute", left: 14, top: 16, whiteSpace: "nowrap", borderRadius: 4, padding: "1px 6px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.message ?? a.name })
5017
5144
  ] }, a.id)) });
5018
5145
  }
5019
5146
  // Annotate the CommonJS export names for ESM import in node: