@scaleflex/crop 2.0.1

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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +452 -0
  3. package/dist/a11y/aria.d.ts +5 -0
  4. package/dist/a11y/keyboard.d.ts +13 -0
  5. package/dist/animation/lerp.d.ts +15 -0
  6. package/dist/animation/spring.d.ts +15 -0
  7. package/dist/canvas/bleed-layer.d.ts +6 -0
  8. package/dist/canvas/crop-frame.d.ts +32 -0
  9. package/dist/canvas/grid-layer.d.ts +7 -0
  10. package/dist/canvas/hit-test.d.ts +10 -0
  11. package/dist/canvas/image-layer.d.ts +28 -0
  12. package/dist/canvas/overlay-layer.d.ts +6 -0
  13. package/dist/canvas/renderer.d.ts +34 -0
  14. package/dist/chunks/sfx-crop-1LGASewd.cjs +353 -0
  15. package/dist/chunks/sfx-crop-CEe6OfTZ.js +2030 -0
  16. package/dist/core/config.d.ts +10 -0
  17. package/dist/core/crop-controller.d.ts +65 -0
  18. package/dist/core/types.d.ts +270 -0
  19. package/dist/define.cjs +1194 -0
  20. package/dist/define.d.ts +1 -0
  21. package/dist/define.js +1746 -0
  22. package/dist/elements/base.d.ts +17 -0
  23. package/dist/elements/icons.d.ts +21 -0
  24. package/dist/elements/parse-shapes.d.ts +13 -0
  25. package/dist/elements/popover-anchor.d.ts +20 -0
  26. package/dist/elements/sfx-crop-canvas.d.ts +24 -0
  27. package/dist/elements/sfx-crop-canvas.styles.d.ts +1 -0
  28. package/dist/elements/sfx-crop-rotate.d.ts +42 -0
  29. package/dist/elements/sfx-crop-rotate.styles.d.ts +5 -0
  30. package/dist/elements/sfx-crop-shapes.d.ts +67 -0
  31. package/dist/elements/sfx-crop-shapes.styles.d.ts +6 -0
  32. package/dist/elements/sfx-crop-toolbar.d.ts +64 -0
  33. package/dist/elements/sfx-crop-toolbar.styles.d.ts +7 -0
  34. package/dist/elements/sfx-crop-zoom.d.ts +66 -0
  35. package/dist/elements/sfx-crop-zoom.styles.d.ts +7 -0
  36. package/dist/elements/sfx-crop.d.ts +134 -0
  37. package/dist/elements/sfx-crop.styles.d.ts +9 -0
  38. package/dist/export/exporter.d.ts +19 -0
  39. package/dist/index.cjs +2 -0
  40. package/dist/index.d.ts +22 -0
  41. package/dist/index.js +65 -0
  42. package/dist/interactions/drag-crop.d.ts +10 -0
  43. package/dist/interactions/pinch-zoom.d.ts +14 -0
  44. package/dist/interactions/pointer-tracker.d.ts +29 -0
  45. package/dist/interactions/resize-handles.d.ts +13 -0
  46. package/dist/interactions/wheel-zoom.d.ts +12 -0
  47. package/dist/react/define-CVJd5aYk.cjs +1545 -0
  48. package/dist/react/define-t4Z6KaLY.js +2590 -0
  49. package/dist/react/index-B-csHwK2.cjs +2 -0
  50. package/dist/react/index-CktjrogS.js +1468 -0
  51. package/dist/react/index.cjs +2 -0
  52. package/dist/react/index.d.ts +21 -0
  53. package/dist/react/index.js +10 -0
  54. package/dist/react/sfx-crop.d.ts +86 -0
  55. package/dist/react/use-sfx-crop-controller.d.ts +74 -0
  56. package/dist/react/use-sfx-crop.d.ts +31 -0
  57. package/dist/styles/shared.css.d.ts +20 -0
  58. package/dist/transforms/constrain.d.ts +68 -0
  59. package/dist/transforms/matrix.d.ts +23 -0
  60. package/dist/transforms/transform-state.d.ts +12 -0
  61. package/dist/utils/events.d.ts +16 -0
  62. package/dist/utils/math.d.ts +12 -0
  63. package/package.json +108 -0
@@ -0,0 +1,1545 @@
1
+ "use strict";const p=require("lit"),s=require("lit/decorators.js"),rt=require("lit/directives/class-map.js"),u=require("./index-B-csHwK2.cjs"),k=require("lit/directives/unsafe-html.js");class O extends p.LitElement{}function M(i,t){typeof customElements>"u"||customElements.get(i)||customElements.define(i,t)}const ut=p.css`
2
+ :host {
3
+ display: block;
4
+ width: 100%;
5
+ height: 100%;
6
+ min-width: 0;
7
+ min-height: 0;
8
+ /* Single source of clipping is .sfx-cr-container (overflow:hidden +
9
+ border-radius). Don't add a second mask here: this host is sized
10
+ by JS to the full outer rect (displayW×displayH), which is 4px
11
+ wider than the container's content-box, so its own border-radius
12
+ wouldn't align with the container's effective inner radius
13
+ (radius - border-width) and you'd see two stepped curves at the
14
+ corner. Transparent bg lets the container surface show through
15
+ in the rounded corner sliver. */
16
+ background: transparent;
17
+ }
18
+
19
+ canvas {
20
+ display: block;
21
+ width: 100%;
22
+ height: 100%;
23
+ outline: none;
24
+ touch-action: none;
25
+ }
26
+ `;var xt=Object.defineProperty,gt=(i,t,e,o)=>{for(var r=void 0,a=i.length-1,n;a>=0;a--)(n=i[a])&&(r=n(t,e,r)||r);return r&&xt(t,e,r),r};const Z=class Z extends O{render(){return p.html`<canvas part="canvas"></canvas>`}};Z.styles=[ut];let A=Z;gt([s.query("canvas")],A.prototype,"canvasEl");const q=["free","square","16:9","4:3","3:2","5:4","2:1","9:16","3:4","2:3","4:5","1:2"],bt=["free","square","circle","rounded-rect"];function F(i){return typeof i!="string"?!1:bt.includes(i)?!0:u.parseRatio(i)!==null}function at(i){if(i==null)return;if(Array.isArray(i))return i.filter(F);if(typeof i!="string")return;const t=i.trim();if(t){if(t.startsWith("["))try{const e=JSON.parse(t);if(Array.isArray(e))return e.filter(F)}catch{}return t.split(/[\s,]+/).filter(Boolean).filter(F)}}const mt=p.css`
27
+ :host {
28
+ /* Palette — light theme (matches ui-tw :root) */
29
+ --sfx-cr-primary: oklch(0.578 0.198 268.129);
30
+ --sfx-cr-primary-hover: oklch(0.5 0.198 268.129);
31
+ --sfx-cr-primary-mid: oklch(0.62 0.198 268.129);
32
+ --sfx-cr-primary-bg: oklch(0.578 0.198 268.129 / 0.07);
33
+ --sfx-cr-primary-glow: oklch(0.578 0.198 268.129 / 0.18);
34
+
35
+ --sfx-cr-success: oklch(0.637 0.17 151.295);
36
+ --sfx-cr-error: oklch(0.577 0.215 27.325);
37
+
38
+ --sfx-cr-text: oklch(0.37 0.022 248.413);
39
+ --sfx-cr-text-secondary: oklch(53.03% 0.039 249.89);
40
+ --sfx-cr-text-muted: oklch(0.685 0.033 249.82);
41
+ /* Fine-tilt ruler ink + halo. The ruler floats directly over the photo,
42
+ whose brightness is unknown, so its colour can't track the theme. We
43
+ render a bright (near-white) core wrapped in a dark halo: the white core
44
+ reads over dark images, the dark halo reads over bright ones — the same
45
+ trick subtitles use to stay legible over arbitrary footage. */
46
+ --sfx-cr-ruler-ink: oklch(1 0 0);
47
+ --sfx-cr-ruler-halo: oklch(0 0 0 / 0.85);
48
+
49
+ --sfx-cr-border: oklch(92.86% 0.009 247.92);
50
+ --sfx-cr-border-light: oklch(0.974 0.006 239.819);
51
+
52
+ --sfx-cr-bg: oklch(1 0 0);
53
+ --sfx-cr-surface: oklch(0.974 0.006 239.819);
54
+ --sfx-cr-canvas-bg: oklch(0.974 0.006 239.819);
55
+ /* Dimming overlay for pixels outside the crop rect. Light theme uses a
56
+ very soft, near-white tint so the whole surround stays bright; dark
57
+ theme keeps the classic black dim for contrast against the photo. */
58
+ --sfx-cr-overlay-color: oklch(1 0 0 / 0.52);
59
+ /* Crop frame + handle colors, theme-aware so the rectangle reads
60
+ against both a washed-out light background and a dimmed dark one. */
61
+ --sfx-cr-frame-color: oklch(0.37 0.022 248.413);
62
+ --sfx-cr-frame-shadow: oklch(1 0 0 / 0.7);
63
+ --sfx-cr-handle-fill: oklch(0.37 0.022 248.413);
64
+ --sfx-cr-handle-stroke: oklch(1 0 0 / 0.95);
65
+
66
+ --sfx-cr-ring: oklch(0.578 0.198 268.129 / 0.7);
67
+ --sfx-cr-shadow: oklch(26.18% 0.024 256.43 / 0.1);
68
+
69
+ /* Derived — kept for internal reuse */
70
+ --sfx-cr-toolbar-bg: oklch(1 0 0 / 0.85);
71
+ --sfx-cr-toolbar-color: var(--sfx-cr-text);
72
+ --sfx-cr-toolbar-border: oklch(92.86% 0.009 247.92 / 0.6);
73
+ /* shadow-sm + soft primary tint */
74
+ --sfx-cr-toolbar-shadow: 0 1px 3px 0 oklch(0 0 0 / 0.1), 0 1px 2px -1px oklch(0 0 0 / 0.1);
75
+ --sfx-cr-btn-size: 36px;
76
+ --sfx-cr-btn-radius: 6px;
77
+ --sfx-cr-btn-hover-bg: var(--sfx-cr-primary-bg);
78
+ --sfx-cr-btn-active-bg: oklch(0.578 0.198 268.129 / 0.14);
79
+ --sfx-cr-separator-color: var(--sfx-cr-border-light);
80
+ --sfx-cr-slider-track: var(--sfx-cr-border);
81
+ --sfx-cr-slider-fill: var(--sfx-cr-primary);
82
+ --sfx-cr-slider-thumb: var(--sfx-cr-primary);
83
+ /* Translucent so the dropdown picks up whatever sits behind it
84
+ (image, overlay) when paired with backdrop-filter. */
85
+ --sfx-cr-dropdown-bg: oklch(0.974 0.006 239.819 / 0.8);
86
+ --sfx-cr-dropdown-hover: var(--sfx-cr-primary-bg);
87
+ /* shadow-md + shadow-lg blend */
88
+ --sfx-cr-dropdown-shadow: 0 10px 15px -3px oklch(0 0 0 / 0.1), 0 4px 6px -4px oklch(0 0 0 / 0.1);
89
+ --sfx-cr-zoom-bar-bg: oklch(1 0 0 / 0.85);
90
+ --sfx-cr-transition: 0.15s ease;
91
+ --sfx-cr-font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
92
+
93
+ /* Border-radius scale — mirrors ui-tw --radius-sm/md/lg/xl */
94
+ --sfx-cr-radius-sm: 4px;
95
+ --sfx-cr-radius-md: 6px;
96
+ --sfx-cr-radius-lg: 8px;
97
+ --sfx-cr-radius-xl: 12px;
98
+ /* Outer card (when <sfx-crop> fills the host) */
99
+ --sfx-cr-radius: var(--sfx-cr-radius-xl);
100
+ --sfx-cr-card-shadow: 0 28px 80px oklch(0 0 0 / 0.2), 0 4px 16px oklch(0 0 0 / 0.06);
101
+ }
102
+
103
+ /* Dark variant — mirrors ui-tw :root.dark. */
104
+ :host([theme="dark"]) {
105
+ --sfx-cr-primary: oklch(0.6 0.2 268.129);
106
+ --sfx-cr-primary-hover: oklch(0.55 0.2 268.129);
107
+ --sfx-cr-primary-mid: oklch(0.65 0.2 268.129);
108
+ --sfx-cr-primary-bg: oklch(0.6 0.2 268.129 / 0.07);
109
+ --sfx-cr-primary-glow: oklch(0.6 0.2 268.129 / 0.22);
110
+
111
+ --sfx-cr-success: oklch(0.6 0.2 154.83);
112
+ --sfx-cr-error: oklch(0.55 0.2 27.325);
113
+
114
+ --sfx-cr-text: oklch(0.95 0.01 264.55);
115
+ --sfx-cr-text-secondary: oklch(0.9 0.01 264.55);
116
+ --sfx-cr-text-muted: oklch(0.75 0.01 249.82);
117
+ /* Ruler keeps the white core + dark halo over the photo (see light theme);
118
+ --sfx-cr-ruler-halo is inherited from the base :host. */
119
+ --sfx-cr-ruler-ink: oklch(1 0 0);
120
+
121
+ --sfx-cr-border: oklch(0.3 0.01 247.92);
122
+ --sfx-cr-border-light: oklch(0.3 0.01 285);
123
+
124
+ --sfx-cr-bg: oklch(0.13 0.027 261.692);
125
+ --sfx-cr-surface: oklch(0.25 0.01 264.55);
126
+ --sfx-cr-canvas-bg: oklch(0.13 0.027 261.692);
127
+ --sfx-cr-overlay-color: oklch(0 0 0 / 0.35);
128
+ --sfx-cr-frame-color: oklch(0.95 0.01 264.55);
129
+ --sfx-cr-frame-shadow: oklch(0 0 0 / 0.6);
130
+ --sfx-cr-handle-fill: oklch(0.95 0.01 264.55);
131
+ --sfx-cr-handle-stroke: oklch(0 0 0 / 0.25);
132
+
133
+ --sfx-cr-ring: oklch(0.6 0.2 268.129 / 0.7);
134
+ --sfx-cr-shadow: oklch(0 0 0 / 0.2);
135
+
136
+ --sfx-cr-toolbar-bg: oklch(0.13 0.027 261.692 / 0.85);
137
+ --sfx-cr-toolbar-color: oklch(0.95 0.01 264.55);
138
+ --sfx-cr-toolbar-border: oklch(0.3 0.01 247.92 / 0.5);
139
+ --sfx-cr-toolbar-shadow: 0 4px 20px oklch(0 0 0 / 0.4);
140
+
141
+ --sfx-cr-btn-hover-bg: oklch(0.6 0.2 268.129 / 0.22);
142
+ --sfx-cr-btn-active-bg: oklch(0.6 0.2 268.129 / 0.32);
143
+
144
+ --sfx-cr-slider-track: oklch(0.3 0.01 247.92);
145
+
146
+ --sfx-cr-dropdown-bg: oklch(0.13 0.027 261.692 / 0.82);
147
+ --sfx-cr-dropdown-hover: oklch(0.6 0.2 268.129 / 0.22);
148
+ --sfx-cr-dropdown-shadow: 0 10px 15px -3px oklch(0 0 0 / 0.5), 0 4px 6px -4px oklch(0 0 0 / 0.3);
149
+ --sfx-cr-zoom-bar-bg: oklch(0.13 0.027 261.692 / 0.85);
150
+
151
+ --sfx-cr-card-shadow: 0 28px 80px oklch(0 0 0 / 0.55), 0 4px 16px oklch(0 0 0 / 0.2);
152
+ }
153
+ `,B=p.css`
154
+ .sfx-cr-sr-only {
155
+ position: absolute;
156
+ width: 1px;
157
+ height: 1px;
158
+ padding: 0;
159
+ margin: -1px;
160
+ overflow: hidden;
161
+ clip: rect(0, 0, 0, 0);
162
+ white-space: nowrap;
163
+ border: 0;
164
+ }
165
+
166
+ @media (prefers-reduced-motion: reduce) {
167
+ :host, :host *, :host *::before, :host *::after {
168
+ transition-duration: 0.01ms !important;
169
+ animation-duration: 0.01ms !important;
170
+ }
171
+ }
172
+ `,vt=p.css`
173
+ @keyframes sfx-cr-spin { to { transform: rotate(360deg); } }
174
+ `,yt=p.css`
175
+ @keyframes sfx-cr-toolbar-enter {
176
+ from {
177
+ opacity: 0;
178
+ }
179
+ to {
180
+ opacity: 1;
181
+ }
182
+ }
183
+ `;p.css`
184
+ @keyframes sfx-cr-zoom-enter {
185
+ from {
186
+ opacity: 0;
187
+ transform: translateX(-50%) translateY(12px);
188
+ }
189
+ to {
190
+ opacity: 1;
191
+ transform: translateX(-50%) translateY(0);
192
+ }
193
+ }
194
+ `;p.css`
195
+ @keyframes sfx-cr-card-in {
196
+ from {
197
+ opacity: 0;
198
+ transform: translateY(10px) scale(0.98);
199
+ }
200
+ to {
201
+ opacity: 1;
202
+ transform: translateY(0) scale(1);
203
+ }
204
+ }
205
+ `;p.css`
206
+ input[type="range"]::-webkit-slider-thumb {
207
+ -webkit-appearance: none;
208
+ width: 16px;
209
+ height: 16px;
210
+ border-radius: 50%;
211
+ background: var(--sfx-cr-slider-thumb);
212
+ cursor: pointer;
213
+ box-shadow: 0 1px 4px var(--sfx-cr-primary-glow);
214
+ transition: transform 150ms ease, box-shadow 150ms ease;
215
+ }
216
+ input[type="range"]::-webkit-slider-thumb:hover {
217
+ transform: scale(1.15);
218
+ box-shadow: 0 0 0 5px var(--sfx-cr-primary-glow);
219
+ }
220
+ input[type="range"]::-moz-range-thumb {
221
+ width: 16px;
222
+ height: 16px;
223
+ border-radius: 50%;
224
+ background: var(--sfx-cr-slider-thumb);
225
+ border: none;
226
+ cursor: pointer;
227
+ box-shadow: 0 1px 4px var(--sfx-cr-primary-glow);
228
+ }
229
+ `;const wt=p.css`
230
+ :host {
231
+ display: block;
232
+ position: relative;
233
+ width: 100%;
234
+ height: 100%;
235
+ font-family: var(--sfx-cr-font);
236
+ color: var(--sfx-cr-text);
237
+ /* Establish a named inline-size container so the toolbar / shapes /
238
+ zoom / rotate sub-elements can switch to their compact left-rail
239
+ layout based on the editor's own width — independent of the page
240
+ viewport. A narrow column on a wide desktop (sidebar preview,
241
+ split view) gets the same compact UI as a phone. */
242
+ container-type: inline-size;
243
+ container-name: sfxcrop;
244
+ }
245
+
246
+ :host([hidden]) { display: none; }
247
+
248
+ :host(:focus-visible) {
249
+ outline: 2px solid var(--sfx-cr-ring);
250
+ outline-offset: 2px;
251
+ }
252
+
253
+ .sfx-cr-container {
254
+ position: relative;
255
+ overflow: hidden;
256
+ width: 100%;
257
+ height: 100%;
258
+ background: var(--sfx-cr-bg);
259
+ border-radius: var(--sfx-cr-radius);
260
+ /* Editor card frame: shadow-only (no border). A border draws two
261
+ visible curves at the corners (outer + inner padding edge),
262
+ reading as a "double ring"; a slightly stronger shadow gives the
263
+ same elevation feel with a single clean rounded silhouette. */
264
+ /* shadow-xs ring + shadow-md elevation, sourced from ui-tw scale */
265
+ box-shadow:
266
+ 0 0 0 1px oklch(0 0 0 / 0.05),
267
+ 0 4px 6px -1px oklch(0 0 0 / 0.1),
268
+ 0 2px 4px -2px oklch(0 0 0 / 0.1);
269
+ font-family: var(--sfx-cr-font);
270
+ user-select: none;
271
+ -webkit-user-select: none;
272
+ }
273
+
274
+ /* ====== Loading ====== */
275
+ .sfx-cr-loading {
276
+ position: absolute;
277
+ inset: 0;
278
+ display: flex;
279
+ flex-direction: column;
280
+ align-items: center;
281
+ justify-content: center;
282
+ gap: 16px;
283
+ background: var(--sfx-cr-bg);
284
+ z-index: 10;
285
+ transition: opacity 280ms ease;
286
+ }
287
+ .sfx-cr-loading--hidden {
288
+ opacity: 0;
289
+ pointer-events: none;
290
+ }
291
+
292
+ .sfx-cr-loading-spinner {
293
+ width: 36px;
294
+ height: 36px;
295
+ border: 3px solid var(--sfx-cr-border);
296
+ border-top-color: var(--sfx-cr-primary);
297
+ border-radius: 50%;
298
+ animation: sfx-cr-spin 0.8s linear infinite;
299
+ }
300
+
301
+ .sfx-cr-loading-text {
302
+ font-size: 14px;
303
+ font-weight: 500;
304
+ color: var(--sfx-cr-text-secondary);
305
+ letter-spacing: 0.2px;
306
+ }
307
+
308
+ /* ====== Error ====== */
309
+ .sfx-cr-error {
310
+ position: absolute;
311
+ inset: 0;
312
+ display: none;
313
+ flex-direction: column;
314
+ align-items: center;
315
+ justify-content: center;
316
+ gap: 12px;
317
+ padding: 32px;
318
+ background: var(--sfx-cr-bg);
319
+ z-index: 10;
320
+ color: var(--sfx-cr-error);
321
+ font-size: 14px;
322
+ font-weight: 500;
323
+ text-align: center;
324
+ }
325
+ .sfx-cr-error--visible { display: flex; }
326
+ `;var kt=Object.defineProperty,c=(i,t,e,o)=>{for(var r=void 0,a=i.length-1,n;a>=0;a--)(n=i[a])&&(r=n(t,e,r)||r);return r&&kt(t,e,r),r};const St={fromAttribute(i){return i===null?"interaction":i==="true"||i===""?!0:i==="false"?!1:"interaction"},toAttribute(i){return i===!0?"true":i===!1?"false":"interaction"}},K=class K extends O{constructor(){super(...arguments),this.src="",this.cropShape="16:9",this.theme="light",this.initialRotation=0,this.initialScale=1,this.minScale=.5,this.maxScale=5,this.minCropSize=20,this.handleSize=12,this.borderRadius=20,this.outputQuality=.92,this.maxOutputWidth=0,this.maxOutputHeight=0,this.bleedMarginSize=10,this.animationSpeed=1,this.handleColor="#ffffff",this.overlayColor="rgba(0, 0, 0, 0.55)",this.bleedMarginColor="rgba(255, 0, 0, 0.5)",this.outputType="image/png",this.toolbarPosition="top",this.variant="classic",this.showGrid="interaction",this.showToolbar=!0,this.showRotateSlider=!0,this.showZoomSlider=!0,this.showShapeSelector=!0,this.showRotateButton=!0,this.showFlipButton=!0,this.showBleedMargin=!1,this.enableAnimations=!0,this.keyboard=!0,this.pinchZoom=!0,this.wheelZoom=!0,this.availableShapes=[...q],this.initialCrop=null,this.icons={},this.loading=!1,this.errorMessage=null,this.controller=null,this.currentImage=null,this.parentResizeObserver=null,this.onToolbarCommand=t=>{if(!this.controller)return;const e=t.detail;switch(e.type){case"reset":this.controller.reset();break;case"rotate-left":this.controller.rotateLeft();break;case"flip-h":this.controller.flipHorizontal();break;case"rotation":this.controller.setRotation(e.value);break;case"scale":this.controller.setScale(e.value);break;case"shape":this.cropShape=e.value;break;case"save":this.save();break}}}async firstUpdated(){if(u.setupAria(this),!(this.canvasHost instanceof A))throw new Error("<sfx-crop>: custom elements not registered. Import '@scaleflex/crop/define' before using the tag.");if(await this.canvasHost.updateComplete,!this.isConnected)return;const t=this.canvasHost.canvasEl,e=u.mergeConfig(this.buildConfig());this.controller=u.createCropController({canvas:t,host:this,layoutContainer:this.canvasHost,config:e,callbacks:{onReady:()=>this.dispatch("sfx-crop-ready",{element:this}),onImageLoad:r=>{this.currentImage=r,this.fitHostToImage(),this.dispatch("sfx-crop-image-load",{image:r})},onError:r=>this.dispatch("sfx-crop-error",{error:r}),onChange:r=>{this.dispatch("sfx-crop-change",r)},onCropChange:r=>this.dispatch("sfx-crop-crop-change",r),onRotationSync:r=>{var a;return(a=this.toolbarHost)==null?void 0:a.setRotationValue(r)},onShapeSync:r=>{var a;this.cropShape=r,(a=this.toolbarHost)==null||a.setShapeValue(r)},onScaleSync:()=>{},onLoadingChange:(r,a)=>{this.loading=r,this.errorMessage=a}}});const o=this.parentElement;o&&(this.parentResizeObserver=new ResizeObserver(()=>this.fitHostToImage()),this.parentResizeObserver.observe(o)),this.src&&this.controller.loadImage(this.src)}updated(t){if(!this.controller)return;const e={};let o=!1;for(const r of Ct)t.has(r)&&(e[r]=this[r],o=!0);o&&this.controller.update(e),(t.has("variant")||t.has("cropShape"))&&this.fitHostToImage()}disconnectedCallback(){var t,e;super.disconnectedCallback(),(t=this.parentResizeObserver)==null||t.disconnect(),this.parentResizeObserver=null,(e=this.controller)==null||e.destroy(),this.controller=null}render(){return p.html`
327
+ <div class="sfx-cr-container" part="container">
328
+ <sfx-crop-canvas part="canvas-host"></sfx-crop-canvas>
329
+ ${this.showToolbar?p.html`
330
+ <sfx-crop-toolbar
331
+ part="toolbar"
332
+ .shape=${this.cropShape}
333
+ ?show-rotate-button=${this.showRotateButton}
334
+ ?show-flip-button=${this.showFlipButton}
335
+ ?show-rotate-slider=${this.showRotateSlider}
336
+ ?show-shape-selector=${this.showShapeSelector}
337
+ toolbar-position=${this.toolbarPosition}
338
+ variant=${this.variant}
339
+ .availableShapes=${this.availableShapes}
340
+ .icons=${this.icons}
341
+ @sfx-crop-toolbar-command=${this.onToolbarCommand}
342
+ ></sfx-crop-toolbar>
343
+ `:null}
344
+ <div class=${rt.classMap({"sfx-cr-loading":!0,"sfx-cr-loading--hidden":!this.loading})} part="loading">
345
+ <div class="sfx-cr-loading-spinner"></div>
346
+ <div class="sfx-cr-loading-text">Loading…</div>
347
+ </div>
348
+ <div class=${rt.classMap({"sfx-cr-error":!0,"sfx-cr-error--visible":!!this.errorMessage})} part="error">
349
+ ${this.errorMessage??"Failed to load image"}
350
+ </div>
351
+ </div>
352
+ `}loadImage(t){return this.ensure().loadImage(t)}getTransformState(){return this.ensure().getTransformState()}setCropShape(t){this.ensure(),this.cropShape=t}setCropRect(t){this.ensure().setCropRect(t)}getCropRect(){return this.ensure().getCropRect()}rotateLeft(){this.ensure().rotateLeft()}flipHorizontal(){this.ensure().flipHorizontal()}setRotation(t){this.ensure().setRotation(t)}setScale(t){this.ensure().setScale(t)}reset(){this.ensure().reset()}toCanvas(){return this.ensure().toCanvas()}toBlob(t,e){return this.ensure().toBlob(t,e)}toDataURL(t,e){return this.ensure().toDataURL(t,e)}toTransformParams(){return this.ensure().toTransformParams()}async save(t,e){const o=await this.toBlob(t,e),r=this.toDataURL(t,e),a=this.toTransformParams();this.dispatch("sfx-crop-save",{blob:o,dataURL:r,params:a})}cancel(){this.dispatch("sfx-crop-cancel",void 0)}ensure(){if(!this.controller)throw new Error('<sfx-crop> not connected — wait for "sfx-crop-ready" or firstUpdated().');return this.controller}fitHostToImage(){if(!this.currentImage||!this.isConnected||!this.canvasHost)return;const t=this.currentImage.naturalWidth,e=this.currentImage.naturalHeight,o=this.style.width,r=this.style.height;this.style.width="",this.style.height="";const a=v=>{if(!v||v==="none")return Number.POSITIVE_INFINITY;const I=N(v);return Number.isFinite(I)&&I>0?I:Number.POSITIVE_INFINITY},n=getComputedStyle(this);let f=a(n.maxWidth),d=a(n.maxHeight);const h=this.parentElement,b=h?getComputedStyle(h):null;if(h&&b&&(b.display==="none"||h.clientWidth===0)){this.style.width=o,this.style.height=r;return}const C=(()=>{if(!h||!b)return 0;const v=h.clientWidth;return Math.max(0,v-(N(b.paddingLeft)||0)-(N(b.paddingRight)||0))})();C>0?f=Math.min(f,C):Number.isFinite(f)||(f=window.innerWidth),Number.isFinite(d)||(d=window.innerHeight),this.style.width=o,this.style.height=r;const P=f,T=d;if(P<=0||T<=0)return;let H,L;if(this.variant==="fixed"){const v=this.fixedFrameAspect(P/T);let I=P,D=P/v;D>T&&(D=T,I=T*v),H=Math.floor(I),L=Math.floor(D)}else{const v=Math.min(P/t,T/e,1);H=Math.floor(t*v),L=Math.floor(e*v)}const et=N(o),ft=N(r);(Number.isNaN(et)||Math.abs(et-H)>=1||Math.abs(ft-L)>=1)&&(this.style.width=`${H}px`,this.style.height=`${L}px`)}fixedFrameAspect(t){const e=this.cropShape;if(e==="free")return t;if(e==="rounded-rect")return 1;const o=u.getAspectRatio(e);return o&&o>0?o:t}dispatch(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}parseInitialCrop(){const t=this.initialCrop;if(!t)return null;const e=typeof t=="object"?t:$t(t);if(!e||typeof e!="object")return null;const o=e;return typeof o.x!="number"||typeof o.y!="number"||typeof o.width!="number"||typeof o.height!="number"?null:{x:o.x,y:o.y,width:o.width,height:o.height}}buildConfig(){return{src:this.src,variant:this.variant,cropShape:this.cropShape,theme:this.theme,initialRotation:this.initialRotation,initialScale:this.initialScale,initialCrop:this.parseInitialCrop(),minScale:this.minScale,maxScale:this.maxScale,minCropSize:this.minCropSize,availableShapes:at(this.availableShapes)??[...q],handleSize:this.handleSize,handleColor:this.handleColor,borderRadius:this.borderRadius,outputType:this.outputType,outputQuality:this.outputQuality,maxOutputWidth:this.maxOutputWidth,maxOutputHeight:this.maxOutputHeight,overlayColor:this.overlayColor,showGrid:this.showGrid,showToolbar:this.showToolbar,showRotateSlider:this.showRotateSlider,showZoomSlider:this.showZoomSlider,showShapeSelector:this.showShapeSelector,showRotateButton:this.showRotateButton,showFlipButton:this.showFlipButton,toolbarPosition:this.toolbarPosition,showBleedMargin:this.showBleedMargin,bleedMarginSize:this.bleedMarginSize,bleedMarginColor:this.bleedMarginColor,enableAnimations:this.enableAnimations,animationSpeed:this.animationSpeed,keyboard:this.keyboard,pinchZoom:this.pinchZoom,wheelZoom:this.wheelZoom}}};K.styles=[mt,B,vt,wt];let l=K;c([s.property({type:String,reflect:!0})],l.prototype,"src");c([s.property({type:String,attribute:"crop-shape",reflect:!0})],l.prototype,"cropShape");c([s.property({type:String,reflect:!0})],l.prototype,"theme");c([s.property({type:Number,attribute:"initial-rotation"})],l.prototype,"initialRotation");c([s.property({type:Number,attribute:"initial-scale"})],l.prototype,"initialScale");c([s.property({type:Number,attribute:"min-scale"})],l.prototype,"minScale");c([s.property({type:Number,attribute:"max-scale"})],l.prototype,"maxScale");c([s.property({type:Number,attribute:"min-crop-size"})],l.prototype,"minCropSize");c([s.property({type:Number,attribute:"handle-size"})],l.prototype,"handleSize");c([s.property({type:Number,attribute:"border-radius"})],l.prototype,"borderRadius");c([s.property({type:Number,attribute:"output-quality"})],l.prototype,"outputQuality");c([s.property({type:Number,attribute:"max-output-width"})],l.prototype,"maxOutputWidth");c([s.property({type:Number,attribute:"max-output-height"})],l.prototype,"maxOutputHeight");c([s.property({type:Number,attribute:"bleed-margin-size"})],l.prototype,"bleedMarginSize");c([s.property({type:Number,attribute:"animation-speed"})],l.prototype,"animationSpeed");c([s.property({type:String,attribute:"handle-color"})],l.prototype,"handleColor");c([s.property({type:String,attribute:"overlay-color"})],l.prototype,"overlayColor");c([s.property({type:String,attribute:"bleed-margin-color"})],l.prototype,"bleedMarginColor");c([s.property({type:String,attribute:"output-type"})],l.prototype,"outputType");c([s.property({type:String,attribute:"toolbar-position",reflect:!0})],l.prototype,"toolbarPosition");c([s.property({type:String,reflect:!0})],l.prototype,"variant");c([s.property({attribute:"show-grid",converter:St})],l.prototype,"showGrid");c([s.property({type:Boolean,attribute:"show-toolbar"})],l.prototype,"showToolbar");c([s.property({type:Boolean,attribute:"show-rotate-slider"})],l.prototype,"showRotateSlider");c([s.property({type:Boolean,attribute:"show-zoom-slider"})],l.prototype,"showZoomSlider");c([s.property({type:Boolean,attribute:"show-shape-selector"})],l.prototype,"showShapeSelector");c([s.property({type:Boolean,attribute:"show-rotate-button"})],l.prototype,"showRotateButton");c([s.property({type:Boolean,attribute:"show-flip-button"})],l.prototype,"showFlipButton");c([s.property({type:Boolean,attribute:"show-bleed-margin"})],l.prototype,"showBleedMargin");c([s.property({type:Boolean,attribute:"enable-animations"})],l.prototype,"enableAnimations");c([s.property({type:Boolean})],l.prototype,"keyboard");c([s.property({type:Boolean,attribute:"pinch-zoom"})],l.prototype,"pinchZoom");c([s.property({type:Boolean,attribute:"wheel-zoom"})],l.prototype,"wheelZoom");c([s.property({attribute:"available-shapes"})],l.prototype,"availableShapes");c([s.property({attribute:"initial-crop"})],l.prototype,"initialCrop");c([s.property({attribute:!1})],l.prototype,"icons");c([s.state()],l.prototype,"loading");c([s.state()],l.prototype,"errorMessage");c([s.query("sfx-crop-canvas")],l.prototype,"canvasHost");c([s.query("sfx-crop-toolbar")],l.prototype,"toolbarHost");c([s.query(".sfx-cr-container")],l.prototype,"containerEl");const Ct=["src","variant","cropShape","theme","minScale","maxScale","minCropSize","borderRadius","handleSize","handleColor","overlayColor","showGrid","showBleedMargin","bleedMarginSize","bleedMarginColor","enableAnimations","animationSpeed","keyboard","pinchZoom","wheelZoom"];function N(i){if(!i)return NaN;const t=parseFloat(i);return Number.isFinite(t)?/^-?\d*\.?\d+(?:px)?$/.test(i.trim())?t:NaN:NaN}function $t(i){try{return JSON.parse(i)}catch{return null}}const zt='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 9V7a2 2 0 0 0-2-2h-6"/><path d="m15 8-3-3 3-3"/><path d="M4 14a2 2 0 0 0-2 2v3a2 2 0 0 0 2 2h13a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2Z"/></svg>',Rt='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3"/><path d="M16 3h3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-3"/><path d="M12 20v2"/><path d="M12 15v2"/><path d="M12 10v2"/><path d="M12 5v2"/></svg>',nt='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 2v14a2 2 0 0 0 2 2h14"/><path d="M18 22V8a2 2 0 0 0-2-2H2"/></svg>',Pt='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>',Tt='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>',lt='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/></svg>',ct='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="5"/></svg>',It='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="12" height="20" x="6" y="2" rx="2"/><rect width="20" height="12" x="2" y="6" rx="2"/></svg>',Ot='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>',Mt='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 22h20"/><rect x="3" y="6" width="18" height="14" rx="2" transform="rotate(-10 12 13)"/></svg>',Et='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>',Nt='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="8" x2="14" y1="11" y2="11"/></svg>',At='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>',Bt='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/></svg>',g={rotateLeft:"",flipHorizontal:"",tilt:"",loupe:"",zoomIn:"",zoomOut:"",cropAspect:"",cropCustom:"",cropCircle:"",cropRoundedRect:"",orientLandscape:"",orientPortrait:"",chevronDown:"",reset:""};g.rotateLeft=zt;g.flipHorizontal=Rt;g.tilt=Mt;g.loupe=At;g.zoomIn=Et;g.zoomOut=Nt;g.cropAspect=It;g.cropCustom=nt;g.cropCircle=lt;g.cropRoundedRect=ct;g.orientLandscape=Pt;g.orientPortrait=Tt;g.chevronDown=Ot;g.reset=Bt;function y(i,t){const e=t==null?void 0:t[i];return typeof e=="string"&&e.length>0?e:g[i]}const _t=p.css`
353
+ :host {
354
+ /* Inline-flex so the host doesn't take toolbar space — the actual ruler
355
+ below uses position:fixed and anchors to the canvas bottom-center via
356
+ createPopoverAnchor, exactly where the legacy popover lived. */
357
+ position: relative;
358
+ display: inline-flex;
359
+ align-items: center;
360
+ }
361
+
362
+ .sfx-cr-rotate-root {
363
+ position: relative;
364
+ display: flex;
365
+ align-items: center;
366
+ justify-content: center;
367
+ }
368
+
369
+ .sfx-cr-rotate-popover {
370
+ position: fixed;
371
+ top: var(--sfx-cr-popover-top, 50%);
372
+ left: var(--sfx-cr-popover-left, 50%);
373
+ transform: translateX(-50%);
374
+ display: flex;
375
+ flex-direction: column;
376
+ align-items: center;
377
+ gap: 4px;
378
+ padding: 0;
379
+ background: transparent;
380
+ border: none;
381
+ box-shadow: none;
382
+ pointer-events: auto;
383
+ white-space: nowrap;
384
+ z-index: 10;
385
+ }
386
+
387
+ /* Ruler viewport — fixed width, overflow clipped. Ticks scroll inside. */
388
+ .sfx-cr-rotate-ruler {
389
+ position: relative;
390
+ width: var(--ruler-w, 260px);
391
+ height: 30px;
392
+ overflow: hidden;
393
+ cursor: grab;
394
+ touch-action: none;
395
+ user-select: none;
396
+ -webkit-user-select: none;
397
+ }
398
+ .sfx-cr-rotate-ruler.is-dragging { cursor: grabbing; }
399
+ .sfx-cr-rotate-ruler:focus-visible {
400
+ outline: 2px solid var(--sfx-cr-ring);
401
+ outline-offset: 2px;
402
+ border-radius: 4px;
403
+ }
404
+
405
+ /* Tick strip — absolutely positioned ticks, the whole strip is
406
+ translated along X in sync with the current value. */
407
+ .sfx-cr-rotate-ticks {
408
+ position: absolute;
409
+ top: 50%;
410
+ left: 0;
411
+ height: 100%;
412
+ will-change: transform;
413
+ /* Dark halo wrapping every tick so the white ink stays legible over a
414
+ bright photo. Applied to the strip so all ticks share one shadow pass. */
415
+ filter:
416
+ drop-shadow(0 0 1px var(--sfx-cr-ruler-halo, oklch(0 0 0 / 0.85)))
417
+ drop-shadow(0 0 2px var(--sfx-cr-ruler-halo, oklch(0 0 0 / 0.85)));
418
+ }
419
+
420
+ .sfx-cr-rotate-tick {
421
+ position: absolute;
422
+ top: 50%;
423
+ width: 1px;
424
+ height: 8px;
425
+ margin-left: -0.5px;
426
+ margin-top: -4px;
427
+ border-radius: 0.5px;
428
+ background: var(--sfx-cr-ruler-ink, var(--sfx-cr-text));
429
+ opacity: 0.9;
430
+ }
431
+ .sfx-cr-rotate-tick--major {
432
+ width: 1px;
433
+ height: 12px;
434
+ margin-left: -0.5px;
435
+ margin-top: -6px;
436
+ opacity: 1;
437
+ }
438
+
439
+ /* Fixed center indicator — single vertical line, slightly taller than ticks. */
440
+ .sfx-cr-rotate-indicator {
441
+ position: absolute;
442
+ top: calc(50% + 4px);
443
+ height: 16px;
444
+ left: 50%;
445
+ width: 4px;
446
+ margin-left: -2px;
447
+ background: var(--sfx-cr-ruler-ink, var(--sfx-cr-text));
448
+ border-radius: 2px;
449
+ pointer-events: none;
450
+ /* Same dark halo as the ticks so the centre marker stays visible. */
451
+ filter:
452
+ drop-shadow(0 0 1px var(--sfx-cr-ruler-halo, oklch(0 0 0 / 0.85)))
453
+ drop-shadow(0 0 2px var(--sfx-cr-ruler-halo, oklch(0 0 0 / 0.85)));
454
+ }
455
+
456
+ .sfx-cr-rotate-value {
457
+ font-size: 14px;
458
+ font-weight: 400;
459
+ color: var(--sfx-cr-ruler-ink, var(--sfx-cr-text));
460
+ text-align: center;
461
+ font-variant-numeric: tabular-nums;
462
+ letter-spacing: 0.2px;
463
+ /* Dark halo so the degree readout reads over both bright and dark photos. */
464
+ text-shadow:
465
+ 0 0 2px var(--sfx-cr-ruler-halo, oklch(0 0 0 / 0.85)),
466
+ 0 1px 2px var(--sfx-cr-ruler-halo, oklch(0 0 0 / 0.85));
467
+ }
468
+
469
+ @media (max-width: 768px) {
470
+ .sfx-cr-rotate-ruler { width: 220px; height: 22px; }
471
+ .sfx-cr-rotate-tick { height: 6px; margin-top: -3px; }
472
+ .sfx-cr-rotate-tick--major { height: 9px; margin-top: -4.5px; }
473
+ .sfx-cr-rotate-indicator {
474
+ top: calc(50% + 3px);
475
+ height: 12px;
476
+ width: 3px;
477
+ margin-left: -1.5px;
478
+ }
479
+ .sfx-cr-rotate-value { font-size: 12px; }
480
+ .sfx-cr-rotate-popover {
481
+ transform: translateX(-50%) translateY(24px);
482
+ }
483
+ }
484
+ @media (max-width: 480px) {
485
+ .sfx-cr-rotate-ruler { width: 180px; height: 20px; }
486
+ .sfx-cr-rotate-tick { height: 5px; margin-top: -2.5px; }
487
+ .sfx-cr-rotate-tick--major { height: 8px; margin-top: -4px; }
488
+ .sfx-cr-rotate-indicator {
489
+ top: calc(50% + 2px);
490
+ height: 10px;
491
+ }
492
+ .sfx-cr-rotate-value { font-size: 11px; }
493
+ .sfx-cr-rotate-popover {
494
+ transform: translateX(-50%) translateY(30px);
495
+ }
496
+ }
497
+
498
+ /* Narrow editor — make the ruler more compact when the toolbar
499
+ collapses into the vertical left rail. */
500
+ @container sfxcrop (max-width: 760px) {
501
+ .sfx-cr-rotate-ruler { width: 140px; height: 18px; }
502
+ .sfx-cr-rotate-tick { height: 5px; margin-top: -2.5px; }
503
+ .sfx-cr-rotate-tick--major { height: 8px; margin-top: -4px; }
504
+ .sfx-cr-rotate-indicator {
505
+ top: calc(50% + 2px);
506
+ height: 10px;
507
+ width: 3px;
508
+ margin-left: -1.5px;
509
+ }
510
+ .sfx-cr-rotate-value { font-size: 11px; }
511
+ }
512
+ `,Ht=72;function pt(i,t){let e=null,o=!1;const r=()=>{var b;let h=i;for(let z=0;z<6;z++){const C=h.getRootNode();if(!(C instanceof ShadowRoot))break;if(h=C.host,((b=h.tagName)==null?void 0:b.toLowerCase())==="sfx-crop")return h}return null},a=()=>{var C;const h=(C=i.shadowRoot)==null?void 0:C.querySelector(t),b=r();if(!h||!b)return;const z=b.getBoundingClientRect();h.style.setProperty("--sfx-cr-popover-left",`${z.left+z.width/2}px`),h.style.setProperty("--sfx-cr-popover-top",`${z.bottom-Ht}px`)},n=()=>a();return{start:()=>{if(o)return;o=!0,a(),window.addEventListener("resize",n),window.addEventListener("scroll",n,!0);const h=r();h&&typeof ResizeObserver<"u"&&(e=new ResizeObserver(()=>a()),e.observe(h))},stop:()=>{o&&(o=!1,window.removeEventListener("resize",n),window.removeEventListener("scroll",n,!0),e==null||e.disconnect(),e=null)},update:a}}var Lt=Object.defineProperty,_=(i,t,e,o)=>{for(var r=void 0,a=i.length-1,n;a>=0;a--)(n=i[a])&&(r=n(t,e,r)||r);return r&&Lt(t,e,r),r};const j=6,V=260,Y=1,jt=5,G=class G extends O{constructor(){super(...arguments),this.value=0,this.min=-45,this.max=45,this.icons={},this.dragging=!1,this.activePointer=null,this.pointerStartX=0,this.pointerStartValue=0,this.popoverAnchor=pt(this,".sfx-cr-rotate-popover"),this.onKeyDown=t=>{t.key==="ArrowLeft"?(t.preventDefault(),this.emit(u.clamp(this.value-(t.shiftKey?5:1),this.min,this.max))):t.key==="ArrowRight"&&(t.preventDefault(),this.emit(u.clamp(this.value+(t.shiftKey?5:1),this.min,this.max)))},this.onPointerDown=t=>{if(this.activePointer===null){this.activePointer=t.pointerId,this.pointerStartX=t.clientX,this.pointerStartValue=this.value,this.dragging=!0;try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}}},this.onPointerMove=t=>{if(this.activePointer!==t.pointerId)return;const e=t.clientX-this.pointerStartX,o=this.pointerStartValue-e/j;this.emit(u.clamp(o,this.min,this.max))},this.onPointerUp=t=>{if(this.activePointer===t.pointerId){this.activePointer=null,this.dragging=!1;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}Math.abs(this.value)<2&&this.emit(0)}},this.onReset=()=>{this.emit(0)}}connectedCallback(){super.connectedCallback(),this.popoverAnchor.start()}disconnectedCallback(){super.disconnectedCallback(),this.popoverAnchor.stop()}updated(t){(t.has("value")||t.has("dragging"))&&this.popoverAnchor.update()}render(){const t=`${this.value>0?"+":""}${this.value.toFixed(1)}°`,e=V/2-(this.value-this.min)*j,o=V/j,r=4,a=Math.max(this.min,Math.floor(this.value-o/2-r)),n=Math.min(this.max,Math.ceil(this.value+o/2+r)),f=[];for(let d=Math.ceil(a/Y)*Y;d<=n;d+=Y)f.push({deg:d,major:d%jt===0});return p.html`
513
+ <div class="sfx-cr-rotate-root" @keydown=${this.onKeyDown}>
514
+ <div class="sfx-cr-rotate-popover" role="group" aria-label="Fine rotation">
515
+ <div
516
+ class=${`sfx-cr-rotate-ruler${this.dragging?" is-dragging":""}`}
517
+ role="slider"
518
+ aria-valuemin=${String(this.min)}
519
+ aria-valuemax=${String(this.max)}
520
+ aria-valuenow=${String(this.value)}
521
+ aria-valuetext=${t}
522
+ tabindex="0"
523
+ style=${`--ruler-w: ${V}px`}
524
+ @pointerdown=${this.onPointerDown}
525
+ @pointermove=${this.onPointerMove}
526
+ @pointerup=${this.onPointerUp}
527
+ @pointercancel=${this.onPointerUp}
528
+ @dblclick=${this.onReset}
529
+ >
530
+ <div class="sfx-cr-rotate-ticks" style=${`transform: translateX(${e.toFixed(1)}px)`}>
531
+ ${f.map(d=>p.html`
532
+ <span
533
+ class=${`sfx-cr-rotate-tick${d.major?" sfx-cr-rotate-tick--major":""}`}
534
+ style=${`left: ${((d.deg-this.min)*j).toFixed(1)}px`}
535
+ ></span>
536
+ `)}
537
+ </div>
538
+ <div class="sfx-cr-rotate-indicator" aria-hidden="true"></div>
539
+ </div>
540
+ <span class="sfx-cr-rotate-value">${t}</span>
541
+ </div>
542
+ </div>
543
+ `}setValue(t){this.value=u.clamp(t,this.min,this.max)}emit(t){this.value!==t&&(this.value=t,this.dispatchEvent(new CustomEvent("sfx-crop-rotate-change",{detail:{degrees:t},bubbles:!0,composed:!0})))}};G.styles=[B,_t];let $=G;_([s.property({type:Number})],$.prototype,"value");_([s.property({type:Number})],$.prototype,"min");_([s.property({type:Number})],$.prototype,"max");_([s.property({attribute:!1})],$.prototype,"icons");_([s.state()],$.prototype,"dragging");const Dt=p.css`
544
+ :host {
545
+ position: relative;
546
+ display: inline-block;
547
+ }
548
+
549
+ .sfx-cr-shape-trigger {
550
+ display: flex;
551
+ align-items: center;
552
+ gap: 6px;
553
+ padding: 8px 14px;
554
+ min-width: 84px;
555
+ height: 36px;
556
+ background: transparent;
557
+ color: var(--sfx-cr-text-secondary);
558
+ border: 1.5px solid var(--sfx-cr-border);
559
+ border-radius: 50px;
560
+ cursor: pointer;
561
+ font-family: var(--sfx-cr-font);
562
+ font-size: 14px;
563
+ font-weight: 500;
564
+ transition:
565
+ background var(--sfx-cr-transition),
566
+ border-color var(--sfx-cr-transition),
567
+ color var(--sfx-cr-transition),
568
+ transform var(--sfx-cr-transition),
569
+ box-shadow var(--sfx-cr-transition);
570
+ white-space: nowrap;
571
+ letter-spacing: 0.1px;
572
+ }
573
+
574
+ /* Fixed variant: translucent pill so the trigger reads over the photo
575
+ (no dimmed crop mask behind it). Plain background — no filter/transform. */
576
+ :host([variant="fixed"]) .sfx-cr-shape-trigger {
577
+ background: var(--sfx-cr-overlay-color);
578
+ }
579
+
580
+ .sfx-cr-shape-trigger:hover {
581
+ border-color: var(--sfx-cr-primary);
582
+ transform: translateY(-1px);
583
+ }
584
+
585
+ .sfx-cr-shape-trigger:focus-visible {
586
+ outline: 2px solid var(--sfx-cr-ring);
587
+ outline-offset: 2px;
588
+ }
589
+
590
+ .sfx-cr-shape-trigger-icon {
591
+ display: flex;
592
+ width: 20px;
593
+ height: 20px;
594
+ }
595
+ .sfx-cr-shape-trigger-icon svg { width: 100%; height: 100%; display: block; }
596
+
597
+ .sfx-cr-shape-trigger-label { line-height: 1; }
598
+
599
+ .sfx-cr-shape-chevron {
600
+ display: flex;
601
+ width: 14px;
602
+ height: 14px;
603
+ margin-left: auto;
604
+ transition: transform var(--sfx-cr-transition);
605
+ }
606
+ .sfx-cr-shape-chevron svg { width: 100%; height: 100%; display: block; }
607
+
608
+ :host([open]) .sfx-cr-shape-chevron {
609
+ transform: rotate(180deg);
610
+ }
611
+
612
+ .sfx-cr-shape-dropdown {
613
+ position: absolute;
614
+ top: calc(100% + 8px);
615
+ right: 0;
616
+ /* Size to the widest option + orientation toggle. Clamp to avoid
617
+ spilling off the viewport on very narrow screens. */
618
+ width: max-content;
619
+ min-width: 88px;
620
+ max-width: min(92vw, 200px);
621
+ max-height: min(55vh, 360px);
622
+ padding: 4px;
623
+ /* Barely-there grey tint with translucency so the panel picks up
624
+ whatever sits behind it (image, dark overlay, etc.) without reading
625
+ as a solid white box. backdrop-filter blur keeps text crisp on
626
+ busy backgrounds. */
627
+ background: var(--sfx-cr-dropdown-bg);
628
+ border: 1px solid var(--sfx-cr-border);
629
+ border-radius: var(--sfx-cr-radius-lg, 8px);
630
+ box-shadow: var(--sfx-cr-dropdown-shadow);
631
+ backdrop-filter: blur(14px) saturate(160%);
632
+ -webkit-backdrop-filter: blur(14px) saturate(160%);
633
+ display: flex;
634
+ flex-direction: column;
635
+ z-index: 100;
636
+ opacity: 0;
637
+ transform: translateY(6px) scale(0.96);
638
+ pointer-events: none;
639
+ transition: opacity 120ms ease-in, transform 120ms ease-in;
640
+ }
641
+
642
+ /* Orientation toggle — naked icon-only buttons centered at the top.
643
+ No border, no background: only the rectangle SVG is visible. Active
644
+ state is signalled by the icon's color (text) vs. inactive (muted). */
645
+ .sfx-cr-shape-orient {
646
+ display: flex;
647
+ justify-content: center;
648
+ gap: 8px;
649
+ margin-bottom: 4px;
650
+ }
651
+
652
+ .sfx-cr-shape-orient-btn {
653
+ display: flex;
654
+ align-items: center;
655
+ justify-content: center;
656
+ width: 36px;
657
+ height: 32px;
658
+ padding: 0;
659
+ background: transparent;
660
+ color: var(--sfx-cr-text-muted);
661
+ border: none;
662
+ border-radius: 4px;
663
+ cursor: pointer;
664
+ transition: color var(--sfx-cr-transition);
665
+ }
666
+ .sfx-cr-shape-orient-btn:hover {
667
+ color: var(--sfx-cr-text-secondary);
668
+ }
669
+ .sfx-cr-shape-orient-btn.is-active {
670
+ color: var(--sfx-cr-text-secondary);
671
+ }
672
+ .sfx-cr-shape-orient-btn svg {
673
+ width: 24px;
674
+ height: 24px;
675
+ /* display:block kills SVG's default baseline drop (inline elements sit
676
+ on the text baseline, leaving a few sub-pixels of descender space at
677
+ the bottom — enough to push a tightly-fitted icon visibly off-center).
678
+ The -1px translate is optical correction: both Lucide monitor (stand
679
+ under the screen) and smartphone (home-indicator dot near the bottom)
680
+ carry visual weight below their geometric centre. */
681
+ display: block;
682
+ transform: translateY(-1px);
683
+ }
684
+
685
+ .sfx-cr-shape-list {
686
+ flex: 1 1 auto;
687
+ display: flex;
688
+ flex-direction: column;
689
+ gap: 1px;
690
+ overflow-y: auto;
691
+ scrollbar-width: thin;
692
+ }
693
+ .sfx-cr-shape-list::-webkit-scrollbar {
694
+ width: 4px;
695
+ }
696
+ .sfx-cr-shape-list::-webkit-scrollbar-thumb {
697
+ background: var(--sfx-cr-border);
698
+ border-radius: 2px;
699
+ }
700
+
701
+ :host([open]) .sfx-cr-shape-dropdown {
702
+ opacity: 1;
703
+ transform: translateY(0) scale(1);
704
+ pointer-events: auto;
705
+ transition: opacity 220ms cubic-bezier(0.34, 1.2, 0.64, 1),
706
+ transform 220ms cubic-bezier(0.34, 1.2, 0.64, 1);
707
+ }
708
+
709
+ .sfx-cr-shape-option {
710
+ display: flex;
711
+ align-items: center;
712
+ gap: 8px;
713
+ /* Stretch to the dropdown's resolved (content-sized) width so all
714
+ rows share the same left edge + hover highlight. */
715
+ width: 100%;
716
+ padding: 5px 10px;
717
+ height: 30px;
718
+ background: transparent;
719
+ color: var(--sfx-cr-text-secondary);
720
+ border: none;
721
+ border-radius: var(--sfx-cr-radius-sm, 4px);
722
+ cursor: pointer;
723
+ font-family: var(--sfx-cr-font);
724
+ font-size: 14px;
725
+ font-weight: 500;
726
+ text-align: left;
727
+ transition: background var(--sfx-cr-transition), color var(--sfx-cr-transition);
728
+ }
729
+
730
+ .sfx-cr-shape-option:hover {
731
+ background: var(--sfx-cr-dropdown-hover);
732
+ color: var(--sfx-cr-primary);
733
+ }
734
+
735
+ .sfx-cr-shape-option:focus-visible {
736
+ outline: 2px solid var(--sfx-cr-ring);
737
+ outline-offset: -2px;
738
+ }
739
+
740
+ .sfx-cr-shape-option--active {
741
+ background: var(--sfx-cr-primary-bg);
742
+ color: var(--sfx-cr-primary);
743
+ }
744
+
745
+ .sfx-cr-shape-option-icon {
746
+ display: flex;
747
+ align-items: center;
748
+ justify-content: center;
749
+ width: 18px;
750
+ height: 18px;
751
+ color: var(--sfx-cr-text-secondary);
752
+ flex-shrink: 0;
753
+ }
754
+ .sfx-cr-shape-option-icon svg { width: 100%; height: 100%; display: block; }
755
+ .sfx-cr-shape-option--active .sfx-cr-shape-option-icon { color: var(--sfx-cr-primary); }
756
+
757
+ @media (max-width: 768px) {
758
+ /* Drop label + chevron and shrink to a square icon-only pill so
759
+ the shape icon sits dead-center. The base 84px min-width was
760
+ sized for the desktop "[icon] Aspect 16:9 ▾" layout and leaves
761
+ empty pill space on the right once those pieces are hidden. */
762
+ .sfx-cr-shape-trigger-label { display: none; }
763
+ .sfx-cr-shape-chevron { display: none; }
764
+ .sfx-cr-shape-trigger {
765
+ min-width: 0;
766
+ width: 36px;
767
+ padding: 0;
768
+ gap: 0;
769
+ justify-content: center;
770
+ }
771
+ }
772
+
773
+ /* Narrow editor: drop the textual label + chevron so the trigger
774
+ reduces to an icon-only 30×30 capsule that matches the rest of
775
+ the compact left-rail toolbar. Anchor the dropdown to the left
776
+ edge since the trigger now lives in the left column. Container
777
+ query keyed off the sfxcrop named container so a narrow editor on
778
+ a wide desktop also collapses. */
779
+ @container sfxcrop (max-width: 760px) {
780
+ /* Label/chevron also need hiding when only the editor (not viewport)
781
+ is narrow — the 768px @media above only triggers on small viewports. */
782
+ .sfx-cr-shape-trigger-label { display: none; }
783
+ .sfx-cr-shape-chevron { display: none; }
784
+ .sfx-cr-shape-trigger {
785
+ min-width: 0;
786
+ width: 30px;
787
+ height: 30px;
788
+ padding: 0;
789
+ gap: 0;
790
+ justify-content: center;
791
+ }
792
+ /* Shrink the icon SLOT (not just the SVG) and center its contents,
793
+ so the 16×16 SVG sits dead-center inside the 30×30 trigger. The
794
+ base .sfx-cr-shape-trigger-icon is 20×20 with display:flex but
795
+ no justify/align — leaving a 16×16 SVG inside top-left aligned. */
796
+ .sfx-cr-shape-trigger-icon {
797
+ width: 16px;
798
+ height: 16px;
799
+ align-items: center;
800
+ justify-content: center;
801
+ }
802
+ .sfx-cr-shape-trigger svg {
803
+ width: 16px;
804
+ height: 16px;
805
+ }
806
+ /* Fixed variant: match the toolbar's uniform 40×40 round icon buttons. */
807
+ :host([variant="fixed"]) .sfx-cr-shape-trigger {
808
+ width: 40px;
809
+ height: 40px;
810
+ }
811
+ /* Classic left-rail only: the trigger sits in the vertical rail, so the
812
+ dropdown opens to the SIDE (right of the trigger). Excluded from the
813
+ fixed variant — there the toolbar is a horizontal top bar, so the menu
814
+ must keep the default downward opening (below the trigger) to avoid
815
+ running off the screen edge. */
816
+ :host(:not([variant="fixed"])) .sfx-cr-shape-dropdown {
817
+ right: auto;
818
+ left: calc(100% + 6px);
819
+ top: auto;
820
+ bottom: -30px;
821
+ transform: translateY(6px) scale(0.96);
822
+ }
823
+ :host(:not([variant="fixed"])[open]) .sfx-cr-shape-dropdown {
824
+ transform: translateY(0) scale(1);
825
+ }
826
+ }
827
+ `;var Ft=Object.defineProperty,R=(i,t,e,o)=>{for(var r=void 0,a=i.length-1,n;a>=0;a--)(n=i[a])&&(r=n(t,e,r)||r);return r&&Ft(t,e,r),r};function ht(i){let r,a;i>=1?(r=18,a=18/i):(a=18,r=18*i);const n=Math.max(0,r-1.5),f=Math.max(0,a-1.5),d=(22-n)/2,h=(22-f)/2,b=Math.min(3.5,Math.min(n,f)/4);return`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22" fill="none" stroke="currentColor" stroke-width="${1.5}"><rect x="${d.toFixed(2)}" y="${h.toFixed(2)}" width="${n.toFixed(2)}" height="${f.toFixed(2)}" rx="${b.toFixed(2)}"/></svg>`}function Vt(){return{free:{value:"free",label:"Custom",icon:nt,show:"both"},circle:{value:"circle",label:"Circle",icon:lt,show:"both"},"rounded-rect":{value:"rounded-rect",label:"Rounded",icon:ct,show:"both"},square:{value:"square",label:"1:1",icon:ht(1),show:"both"}}}const dt=Vt();function W(i){const t=dt[i];if(t)return t;const e=u.parseRatio(i);return e===null?null:{value:i,label:i,icon:ht(e),show:e>1?"landscape":e<1?"portrait":"both"}}const J=class J extends O{constructor(){super(...arguments),this.value="free",this.shapes=["free","square","16:9","4:3","3:2","5:4","2:1","9:16","3:4","2:3","4:5","1:2"],this.open=!1,this.variant="classic",this.icons={},this.orientation="landscape",this.focusedIndex=-1,this.focusRafId=null,this.docClickHandler=()=>{this.open&&this.close()},this.onTriggerClick=t=>{if(t.stopPropagation(),this.open)this.close();else{const e=this.getVisibleOptions();this.focusedIndex=Math.max(0,e.findIndex(o=>o.value===this.value)),this.open=!0,this.dispatchEvent(new CustomEvent("sfx-crop-popover-open",{detail:{source:"shapes"},bubbles:!0,composed:!0}))}},this.onKeyDown=t=>{if(!this.open)return;const e=this.getVisibleOptions();switch(t.key){case"Escape":t.preventDefault(),t.stopPropagation(),this.close();break;case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.focusOption(Math.min(this.focusedIndex+1,e.length-1));break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),this.focusOption(Math.max(this.focusedIndex-1,0));break;case"ArrowLeft":t.preventDefault(),t.stopPropagation(),this.setOrientation("landscape");break;case"ArrowRight":t.preventDefault(),t.stopPropagation(),this.setOrientation("portrait");break;case"Enter":case" ":if(t.preventDefault(),t.stopPropagation(),this.focusedIndex>=0&&this.focusedIndex<e.length){const o=e[this.focusedIndex].value;this.value=o,this.close(),this.emit(o)}break}}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.docClickHandler)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.docClickHandler),this.focusRafId!==null&&(cancelAnimationFrame(this.focusRafId),this.focusRafId=null)}updated(t){if(t.has("open")&&this.open){const e=W(this.value);e&&e.show!=="both"&&(this.orientation=e.show),this.focusRafId=requestAnimationFrame(()=>{this.focusRafId=null;const r=this.getVisibleOptions().findIndex(a=>a.value===this.value);this.focusOption(r>=0?r:0)})}}render(){const t=this.getVisibleOptions(),e=W(this.value)??dt.free;return p.html`
828
+ <div
829
+ @keydown=${this.onKeyDown}
830
+ @click=${o=>o.stopPropagation()}
831
+ >
832
+ <button
833
+ type="button"
834
+ class="sfx-cr-shape-trigger"
835
+ aria-label="Select crop shape"
836
+ aria-haspopup="listbox"
837
+ aria-expanded=${this.open?"true":"false"}
838
+ @click=${this.onTriggerClick}
839
+ >
840
+ <span class="sfx-cr-shape-trigger-icon">${k.unsafeHTML(y("cropAspect",this.icons))}</span>
841
+ <span class="sfx-cr-shape-trigger-label">${e.label}</span>
842
+ <span class="sfx-cr-shape-chevron">${k.unsafeHTML(y("chevronDown",this.icons))}</span>
843
+ </button>
844
+ <div class="sfx-cr-shape-dropdown" role="listbox">
845
+ <div class="sfx-cr-shape-orient" role="tablist" aria-label="Orientation">
846
+ <button
847
+ type="button"
848
+ class=${`sfx-cr-shape-orient-btn${this.orientation==="landscape"?" is-active":""}`}
849
+ role="tab"
850
+ aria-selected=${this.orientation==="landscape"?"true":"false"}
851
+ aria-label="Landscape orientations"
852
+ @click=${()=>this.setOrientation("landscape")}
853
+ >${k.unsafeHTML(y("orientLandscape",this.icons))}</button>
854
+ <button
855
+ type="button"
856
+ class=${`sfx-cr-shape-orient-btn${this.orientation==="portrait"?" is-active":""}`}
857
+ role="tab"
858
+ aria-selected=${this.orientation==="portrait"?"true":"false"}
859
+ aria-label="Portrait orientations"
860
+ @click=${()=>this.setOrientation("portrait")}
861
+ >${k.unsafeHTML(y("orientPortrait",this.icons))}</button>
862
+ </div>
863
+ <div class="sfx-cr-shape-list" role="presentation">
864
+ ${t.map((o,r)=>p.html`
865
+ <button
866
+ type="button"
867
+ class=${`sfx-cr-shape-option${o.value===this.value?" sfx-cr-shape-option--active":""}`}
868
+ role="option"
869
+ aria-selected=${o.value===this.value?"true":"false"}
870
+ @click=${a=>this.onOptionClick(a,o.value)}
871
+ data-index=${String(r)}
872
+ >
873
+ <span class="sfx-cr-shape-option-icon">${k.unsafeHTML(this.optionIcon(o))}</span>
874
+ <span class="sfx-cr-shape-option-label">${o.label}</span>
875
+ </button>
876
+ `)}
877
+ </div>
878
+ </div>
879
+ </div>
880
+ `}optionIcon(t){switch(t.value){case"free":return y("cropCustom",this.icons);case"circle":return y("cropCircle",this.icons);case"rounded-rect":return y("cropRoundedRect",this.icons);default:return t.icon}}setValue(t){this.value=t}setOrientation(t){this.orientation!==t&&(this.orientation=t,this.focusedIndex=-1)}getVisibleOptions(){const t=[];for(const e of this.shapes){const o=W(e);o&&(o.show!=="both"&&o.show!==this.orientation||t.push(o))}return t.sort((e,o)=>{const r={free:0,circle:1,"rounded-rect":2,square:3},a=r[e.value],n=r[o.value];if(a!==void 0&&n!==void 0)return a-n;if(a!==void 0)return-1;if(n!==void 0)return 1;const f=u.getAspectRatio(e.value)??1,d=u.getAspectRatio(o.value)??1;return this.orientation==="portrait"?d-f:f-d})}emit(t){this.dispatchEvent(new CustomEvent("sfx-crop-shape-change",{detail:{shape:t},bubbles:!0,composed:!0}))}close(){this.open=!1}onOptionClick(t,e){t.stopPropagation(),this.value=e,this.close(),this.emit(e)}focusOption(t){this.focusedIndex=t;const e=this.renderRoot.querySelector(`.sfx-cr-shape-option[data-index="${t}"]`);e==null||e.focus()}};J.styles=[B,Dt];let w=J;R([s.property({type:String})],w.prototype,"value");R([s.property({attribute:!1})],w.prototype,"shapes");R([s.property({type:Boolean,reflect:!0})],w.prototype,"open");R([s.property({type:String,reflect:!0})],w.prototype,"variant");R([s.property({attribute:!1})],w.prototype,"icons");R([s.state()],w.prototype,"orientation");R([s.state()],w.prototype,"focusedIndex");const Yt=p.css`
881
+ :host {
882
+ position: absolute;
883
+ top: 16px;
884
+ left: 0;
885
+ right: 0;
886
+ display: flex;
887
+ justify-content: center;
888
+ z-index: 5;
889
+ animation: sfx-cr-toolbar-enter 300ms ease forwards;
890
+ pointer-events: none;
891
+ }
892
+
893
+ :host([toolbar-position="bottom"]) {
894
+ top: auto;
895
+ bottom: 16px;
896
+ }
897
+
898
+ /* Fixed variant: the editor box IS the crop frame, so the floating bar sits
899
+ directly over the photo. Classic gets its button contrast for free from
900
+ the dimmed crop mask; fixed has none, so give each control its own
901
+ translucent pill to stay legible over arbitrary image content.
902
+
903
+ IMPORTANT: backgrounds only — no backdrop-filter / transform / filter
904
+ here or on any ancestor. Those create a containing block for
905
+ position:fixed descendants, which would re-anchor the canvas-bottom ruler
906
+ + shape popover (both fixed-positioned) to the bar and knock the 45-deg
907
+ tilt ruler off-screen. A plain background is safe. */
908
+ :host([variant="fixed"]) .sfx-cr-toolbar,
909
+ :host([variant="fixed"]) .sfx-cr-toolbar-group {
910
+ /* Fixed variant runs a slightly tighter uniform gap than classic. */
911
+ gap: 12px;
912
+ }
913
+ :host([variant="fixed"]) .sfx-cr-reset-btn,
914
+ :host([variant="fixed"]) .sfx-cr-toolbar-btn {
915
+ background: var(--sfx-cr-overlay-color);
916
+ }
917
+
918
+ /* Primary "Done" action — pinned to the right edge of the toolbar strip,
919
+ away from the centered control cluster. The host spans the full block
920
+ width (left:0/right:0), so right:16px sits near the block's edge. */
921
+ .sfx-cr-done-btn {
922
+ position: absolute;
923
+ right: 16px;
924
+ top: 50%;
925
+ transform: translateY(-50%);
926
+ pointer-events: auto;
927
+ display: inline-flex;
928
+ align-items: center;
929
+ justify-content: center;
930
+ height: 36px;
931
+ padding: 0 18px;
932
+ background: var(--sfx-cr-primary);
933
+ color: #fff;
934
+ border: none;
935
+ border-radius: 50px;
936
+ cursor: pointer;
937
+ font-family: var(--sfx-cr-font);
938
+ font-size: 14px;
939
+ font-weight: 600;
940
+ letter-spacing: 0.1px;
941
+ white-space: nowrap;
942
+ box-shadow: var(--sfx-cr-toolbar-shadow);
943
+ transition:
944
+ background var(--sfx-cr-transition),
945
+ transform var(--sfx-cr-transition);
946
+ }
947
+ .sfx-cr-done-btn:hover {
948
+ background: var(--sfx-cr-primary-hover);
949
+ transform: translateY(-50%) scale(1.02);
950
+ }
951
+ .sfx-cr-done-btn:active {
952
+ transform: translateY(-50%) scale(0.97);
953
+ }
954
+ .sfx-cr-done-btn:focus-visible {
955
+ outline: 2px solid var(--sfx-cr-ring);
956
+ outline-offset: 2px;
957
+ }
958
+
959
+ /* Hole-punch pattern: the toolbar host is pointer-transparent and
960
+ individual interactive children below opt back in. Gaps between
961
+ buttons fall through to the canvas — important when a crop handle
962
+ ends up under the floating toolbar and the user wants to grab it.
963
+ The rotate / zoom / shapes sub-elements already follow the same
964
+ pattern in their own stylesheets. */
965
+ .sfx-cr-toolbar {
966
+ display: flex;
967
+ flex-direction: row;
968
+ align-items: center;
969
+ gap: 16px;
970
+ padding: 4px 8px;
971
+ background: transparent;
972
+ color: var(--sfx-cr-toolbar-color);
973
+ border: none;
974
+ border-radius: 0;
975
+ box-shadow: none;
976
+ pointer-events: none;
977
+ }
978
+
979
+ .sfx-cr-toolbar-group {
980
+ display: flex;
981
+ flex-direction: row;
982
+ align-items: center;
983
+ /* Match the toolbar's own gap so spacing is uniform across every button
984
+ (Reset, rotate, flip, shapes), not tighter inside the group. */
985
+ gap: 16px;
986
+ }
987
+
988
+ /* Sub-element hosts — same hole-punch opt-in as the plain buttons.
989
+ Their hosts are tight inline-flex wrappers around a single trigger,
990
+ so re-enabling them adds no extra dead zone. */
991
+ sfx-crop-rotate,
992
+ sfx-crop-shapes {
993
+ pointer-events: auto;
994
+ }
995
+
996
+ /* The fine-tilt ruler renders as a canvas-anchored fixed popover, but its
997
+ inline host still occupies a zero-width slot in the toolbar row — which
998
+ doubles the gap between the flip button and the shape selector. Pull the
999
+ host out of flow so every visible button stays evenly spaced (both
1000
+ variants). The popover is position:fixed, so this doesn't move it. */
1001
+ sfx-crop-rotate {
1002
+ position: absolute;
1003
+ }
1004
+
1005
+ .sfx-cr-toolbar-btn {
1006
+ pointer-events: auto;
1007
+ width: 52px;
1008
+ height: 36px;
1009
+ display: flex;
1010
+ align-items: center;
1011
+ justify-content: center;
1012
+ background: transparent;
1013
+ color: var(--sfx-cr-text-secondary);
1014
+ /* Transparent default border → hover swaps in a colored ring without
1015
+ the layout shifting from 0 → 1 px. */
1016
+ border: 1px solid transparent;
1017
+ border-radius: 999px;
1018
+ cursor: pointer;
1019
+ padding: 0;
1020
+ transition:
1021
+ border-color var(--sfx-cr-transition),
1022
+ color var(--sfx-cr-transition),
1023
+ transform var(--sfx-cr-transition);
1024
+ }
1025
+
1026
+ .sfx-cr-toolbar-btn:hover {
1027
+ border-color: var(--sfx-cr-primary);
1028
+ transform: translateY(-1px);
1029
+ }
1030
+
1031
+ .sfx-cr-toolbar-btn:active {
1032
+ transform: translateY(0) scale(0.96);
1033
+ }
1034
+
1035
+ .sfx-cr-toolbar-btn:disabled {
1036
+ opacity: 0.45;
1037
+ cursor: not-allowed;
1038
+ }
1039
+
1040
+ .sfx-cr-toolbar-btn:disabled:hover {
1041
+ border-color: transparent;
1042
+ color: var(--sfx-cr-text-muted);
1043
+ transform: none;
1044
+ }
1045
+
1046
+ .sfx-cr-toolbar-btn:focus-visible {
1047
+ outline: 2px solid var(--sfx-cr-ring);
1048
+ outline-offset: 2px;
1049
+ }
1050
+
1051
+ .sfx-cr-toolbar-btn svg {
1052
+ width: 20px;
1053
+ height: 20px;
1054
+ display: block;
1055
+ }
1056
+
1057
+ /* Reset pill — mirrors the shape-selector trigger visual language:
1058
+ capsule border, transparent fill, primary-blue tint on hover. Lives
1059
+ before every other control so the user can wipe back to the initial
1060
+ state in one click. */
1061
+ .sfx-cr-reset-btn {
1062
+ pointer-events: auto;
1063
+ display: flex;
1064
+ align-items: center;
1065
+ gap: 6px;
1066
+ padding: 8px 14px;
1067
+ min-width: 84px;
1068
+ height: 36px;
1069
+ background: transparent;
1070
+ color: var(--sfx-cr-text-secondary);
1071
+ border: 1.5px solid var(--sfx-cr-border);
1072
+ border-radius: 50px;
1073
+ cursor: pointer;
1074
+ font-family: var(--sfx-cr-font);
1075
+ font-size: 14px;
1076
+ font-weight: 500;
1077
+ letter-spacing: 0.1px;
1078
+ white-space: nowrap;
1079
+ transition:
1080
+ background var(--sfx-cr-transition),
1081
+ border-color var(--sfx-cr-transition),
1082
+ color var(--sfx-cr-transition),
1083
+ transform var(--sfx-cr-transition),
1084
+ box-shadow var(--sfx-cr-transition);
1085
+ }
1086
+ .sfx-cr-reset-btn:hover {
1087
+ border-color: var(--sfx-cr-primary);
1088
+ transform: translateY(-1px);
1089
+ }
1090
+ .sfx-cr-reset-btn:focus-visible {
1091
+ outline: 2px solid var(--sfx-cr-ring);
1092
+ outline-offset: 2px;
1093
+ }
1094
+ .sfx-cr-reset-btn svg {
1095
+ width: 18px;
1096
+ height: 18px;
1097
+ display: block;
1098
+ }
1099
+
1100
+ @media (max-width: 768px) {
1101
+ .sfx-cr-toolbar {
1102
+ flex-wrap: wrap;
1103
+ justify-content: center;
1104
+ }
1105
+ }
1106
+
1107
+ @media (max-width: 480px) {
1108
+ .sfx-cr-toolbar {
1109
+ padding: 6px 8px;
1110
+ gap: 8px;
1111
+ }
1112
+ .sfx-cr-toolbar-group {
1113
+ gap: 8px;
1114
+ }
1115
+ .sfx-cr-toolbar-btn {
1116
+ width: 40px;
1117
+ height: 32px;
1118
+ }
1119
+ .sfx-cr-toolbar-btn svg {
1120
+ width: 18px;
1121
+ height: 18px;
1122
+ display: block;
1123
+ }
1124
+ }
1125
+
1126
+ /* Narrow editor (component itself is small, regardless of viewport):
1127
+ stack the toolbar vertically along the LEFT edge, icons only.
1128
+ Tucked tight against the edge with a compact 30×30 footprint so
1129
+ the photo behind keeps maximum breathing room. Triggered by the
1130
+ sfxcrop container set on the sfx-crop host — matches editor
1131
+ width, not viewport width, so a narrow column on a wide desktop
1132
+ gets the same compact layout.
1133
+
1134
+ EXCLUDED from the fixed variant via :not([variant="fixed"]): a fixed
1135
+ frame is often portrait/phone-shaped (narrow but tall), where the left
1136
+ rail looks wrong — fixed keeps the horizontal top bar at any width. */
1137
+ @container sfxcrop (max-width: 760px) {
1138
+ :host(:not([variant="fixed"])) {
1139
+ top: 8px;
1140
+ bottom: 8px;
1141
+ /* Stay full-width (don't collapse to a left-hugging strip): the Done
1142
+ button is absolutely positioned against this host, so the host must
1143
+ keep spanning to the container's right edge for Done to stay in the
1144
+ top-right corner. The button column is tucked left with padding
1145
+ instead of by repositioning the whole host. */
1146
+ left: 0;
1147
+ right: 0;
1148
+ padding-left: 4px;
1149
+ justify-content: flex-start;
1150
+ /* Cross-axis centers the stacked button column vertically inside
1151
+ the full-height host strip — toolbar floats in the middle of
1152
+ the photo regardless of its content height. */
1153
+ align-items: center;
1154
+ }
1155
+ :host(:not([variant="fixed"])[toolbar-position="bottom"]) {
1156
+ top: 8px;
1157
+ bottom: 8px;
1158
+ }
1159
+ /* Keep Done pinned to the editor's top-right corner — exactly where the
1160
+ desktop bar puts it — even though the host now spans the full photo
1161
+ height (top:50% would otherwise drop it to the vertical middle). A bit
1162
+ smaller and tucked tighter into the corner to free up the photo. */
1163
+ :host(:not([variant="fixed"])) .sfx-cr-done-btn {
1164
+ top: 6px;
1165
+ right: 8px;
1166
+ height: 28px;
1167
+ padding: 0 12px;
1168
+ font-size: 12px;
1169
+ transform: none;
1170
+ }
1171
+ :host(:not([variant="fixed"])) .sfx-cr-done-btn:hover { transform: scale(1.02); }
1172
+ :host(:not([variant="fixed"])) .sfx-cr-done-btn:active { transform: scale(0.97); }
1173
+ :host(:not([variant="fixed"])) .sfx-cr-toolbar {
1174
+ flex-direction: column;
1175
+ flex-wrap: nowrap;
1176
+ align-items: center;
1177
+ justify-content: flex-start;
1178
+ gap: 4px;
1179
+ padding: 3px;
1180
+ }
1181
+ :host(:not([variant="fixed"])) .sfx-cr-toolbar-group {
1182
+ flex-direction: column;
1183
+ gap: 4px;
1184
+ }
1185
+ :host(:not([variant="fixed"])) .sfx-cr-toolbar-btn {
1186
+ width: 30px;
1187
+ height: 30px;
1188
+ }
1189
+ :host(:not([variant="fixed"])) .sfx-cr-toolbar-btn svg {
1190
+ width: 16px;
1191
+ height: 16px;
1192
+ }
1193
+ :host(:not([variant="fixed"])) .sfx-cr-reset-btn {
1194
+ width: 30px;
1195
+ height: 30px;
1196
+ min-width: 0;
1197
+ padding: 0;
1198
+ gap: 0;
1199
+ justify-content: center;
1200
+ }
1201
+ :host(:not([variant="fixed"])) .sfx-cr-reset-btn svg {
1202
+ width: 16px;
1203
+ height: 16px;
1204
+ }
1205
+ :host(:not([variant="fixed"])) .sfx-cr-reset-btn span {
1206
+ display: none;
1207
+ }
1208
+ }
1209
+
1210
+ /* Fixed + narrow (portrait/phone frame): keep the horizontal top bar, but
1211
+ render every control as a uniform 40×40 round icon button, centered in
1212
+ the frame. (Reset / shapes labels are dropped — icon only.) */
1213
+ @container sfxcrop (max-width: 760px) {
1214
+ :host([variant="fixed"]) .sfx-cr-toolbar {
1215
+ flex-wrap: wrap;
1216
+ justify-content: center;
1217
+ gap: 10px;
1218
+ }
1219
+ :host([variant="fixed"]) .sfx-cr-toolbar-group {
1220
+ gap: 10px;
1221
+ }
1222
+ :host([variant="fixed"]) .sfx-cr-reset-btn,
1223
+ :host([variant="fixed"]) .sfx-cr-toolbar-btn {
1224
+ width: 40px;
1225
+ height: 40px;
1226
+ min-width: 0;
1227
+ padding: 0;
1228
+ gap: 0;
1229
+ justify-content: center;
1230
+ }
1231
+ :host([variant="fixed"]) .sfx-cr-reset-btn span {
1232
+ display: none;
1233
+ }
1234
+ :host([variant="fixed"]) .sfx-cr-done-btn {
1235
+ /* Stay in the top-right corner when the bar wraps to multiple rows
1236
+ (top:50% would otherwise centre Done over the taller wrapped bar),
1237
+ a bit smaller and tucked tighter into the corner. */
1238
+ top: 6px;
1239
+ right: 8px;
1240
+ height: 28px;
1241
+ padding: 0 12px;
1242
+ font-size: 12px;
1243
+ transform: none;
1244
+ }
1245
+ :host([variant="fixed"]) .sfx-cr-done-btn:hover { transform: scale(1.02); }
1246
+ :host([variant="fixed"]) .sfx-cr-done-btn:active { transform: scale(0.97); }
1247
+ }
1248
+ `;var Wt=Object.defineProperty,m=(i,t,e,o)=>{for(var r=void 0,a=i.length-1,n;a>=0;a--)(n=i[a])&&(r=n(t,e,r)||r);return r&&Wt(t,e,r),r};const Q=class Q extends O{constructor(){super(...arguments),this.shape="free",this.rotation=0,this.showRotateButton=!0,this.showFlipButton=!0,this.showRotateSlider=!0,this.showShapeSelector=!0,this.toolbarPosition="top",this.variant="classic",this.availableShapes=null,this.icons={},this.onPopoverOpen=t=>{var o;((o=t.detail)==null?void 0:o.source)!=="shapes"&&this.shapesEl&&(this.shapesEl.open=!1)}}render(){const t=this.showRotateButton||this.showFlipButton,e=at(this.availableShapes)??[...q];return p.html`
1249
+ <div class="sfx-cr-toolbar" @sfx-crop-popover-open=${this.onPopoverOpen}>
1250
+ <button
1251
+ type="button"
1252
+ class="sfx-cr-reset-btn"
1253
+ aria-label="Reset all changes"
1254
+ @click=${()=>this.emit({type:"reset"})}
1255
+ >
1256
+ ${k.unsafeHTML(y("reset",this.icons))}
1257
+ <span>Reset</span>
1258
+ </button>
1259
+
1260
+ ${t?p.html`
1261
+ <div class="sfx-cr-toolbar-group">
1262
+ ${this.showRotateButton?p.html`
1263
+ <button
1264
+ type="button"
1265
+ class="sfx-cr-toolbar-btn"
1266
+ aria-label="Rotate left 90°"
1267
+ @click=${()=>this.emit({type:"rotate-left"})}
1268
+ >${k.unsafeHTML(y("rotateLeft",this.icons))}</button>
1269
+ `:null}
1270
+ ${this.showFlipButton?p.html`
1271
+ <button
1272
+ type="button"
1273
+ class="sfx-cr-toolbar-btn"
1274
+ aria-label="Flip horizontal"
1275
+ @click=${()=>this.emit({type:"flip-h"})}
1276
+ >${k.unsafeHTML(y("flipHorizontal",this.icons))}</button>
1277
+ `:null}
1278
+ </div>
1279
+ `:null}
1280
+
1281
+ ${this.showRotateSlider?p.html`
1282
+ <sfx-crop-rotate
1283
+ .value=${this.rotation}
1284
+ .icons=${this.icons}
1285
+ @sfx-crop-rotate-change=${o=>this.emit({type:"rotation",value:o.detail.degrees})}
1286
+ ></sfx-crop-rotate>
1287
+ `:null}
1288
+
1289
+ ${this.showShapeSelector?p.html`
1290
+ <sfx-crop-shapes
1291
+ .value=${this.shape}
1292
+ .shapes=${e}
1293
+ variant=${this.variant}
1294
+ .icons=${this.icons}
1295
+ @sfx-crop-shape-change=${o=>this.emit({type:"shape",value:o.detail.shape})}
1296
+ ></sfx-crop-shapes>
1297
+ `:null}
1298
+ </div>
1299
+
1300
+ <button
1301
+ type="button"
1302
+ class="sfx-cr-done-btn"
1303
+ part="done"
1304
+ aria-label="Done"
1305
+ @click=${()=>this.emit({type:"save"})}
1306
+ >Done</button>
1307
+ `}setRotationValue(t){var e;this.rotation=t,(e=this.rotateEl)==null||e.setValue(t)}setShapeValue(t){var e;this.shape=t,(e=this.shapesEl)==null||e.setValue(t)}emit(t){this.dispatchEvent(new CustomEvent("sfx-crop-toolbar-command",{detail:t,bubbles:!0,composed:!0}))}};Q.styles=[B,yt,Yt];let x=Q;m([s.property({type:String})],x.prototype,"shape");m([s.property({type:Number})],x.prototype,"rotation");m([s.property({type:Boolean,attribute:"show-rotate-button"})],x.prototype,"showRotateButton");m([s.property({type:Boolean,attribute:"show-flip-button"})],x.prototype,"showFlipButton");m([s.property({type:Boolean,attribute:"show-rotate-slider"})],x.prototype,"showRotateSlider");m([s.property({type:Boolean,attribute:"show-shape-selector"})],x.prototype,"showShapeSelector");m([s.property({type:String,attribute:"toolbar-position",reflect:!0})],x.prototype,"toolbarPosition");m([s.property({type:String,reflect:!0})],x.prototype,"variant");m([s.property({attribute:"available-shapes"})],x.prototype,"availableShapes");m([s.property({attribute:!1})],x.prototype,"icons");m([s.query("sfx-crop-rotate")],x.prototype,"rotateEl");m([s.query("sfx-crop-shapes")],x.prototype,"shapesEl");const Xt=p.css`
1308
+ :host {
1309
+ position: relative;
1310
+ display: inline-flex;
1311
+ align-items: center;
1312
+ }
1313
+
1314
+ .sfx-cr-zoom-root {
1315
+ position: relative;
1316
+ display: flex;
1317
+ align-items: center;
1318
+ justify-content: center;
1319
+ }
1320
+
1321
+ /* Trigger — visually matches the other toolbar icon buttons. */
1322
+ .sfx-cr-zoom-trigger {
1323
+ width: 44px;
1324
+ height: 36px;
1325
+ display: flex;
1326
+ align-items: center;
1327
+ justify-content: center;
1328
+ padding: 0;
1329
+ background: transparent;
1330
+ color: var(--sfx-cr-text-secondary);
1331
+ border: 1px solid transparent;
1332
+ border-radius: 999px;
1333
+ cursor: pointer;
1334
+ transition:
1335
+ border-color var(--sfx-cr-transition),
1336
+ color var(--sfx-cr-transition),
1337
+ transform var(--sfx-cr-transition);
1338
+ }
1339
+ .sfx-cr-zoom-trigger:hover {
1340
+ border-color: var(--sfx-cr-primary);
1341
+ color: var(--sfx-cr-primary);
1342
+ transform: translateY(-1px);
1343
+ }
1344
+ .sfx-cr-zoom-trigger:active {
1345
+ transform: translateY(0) scale(0.96);
1346
+ }
1347
+ .sfx-cr-zoom-trigger:focus-visible {
1348
+ outline: 2px solid var(--sfx-cr-ring);
1349
+ outline-offset: 2px;
1350
+ }
1351
+ .sfx-cr-zoom-trigger svg {
1352
+ width: 20px;
1353
+ height: 20px;
1354
+ display: block;
1355
+ }
1356
+
1357
+ :host([open]) .sfx-cr-zoom-trigger {
1358
+ color: var(--sfx-cr-primary);
1359
+ }
1360
+
1361
+ /* Popover — transparent, floats above the trigger. */
1362
+ .sfx-cr-zoom-popover {
1363
+ position: fixed;
1364
+ top: var(--sfx-cr-popover-top, 50%);
1365
+ left: var(--sfx-cr-popover-left, 50%);
1366
+ transform: translateX(-50%) translateY(6px) scale(0.98);
1367
+ display: flex;
1368
+ flex-direction: column;
1369
+ align-items: center;
1370
+ gap: 4px;
1371
+ padding: 0;
1372
+ background: transparent;
1373
+ border: none;
1374
+ box-shadow: none;
1375
+ opacity: 0;
1376
+ pointer-events: none;
1377
+ transition: opacity 120ms ease-in, transform 120ms ease-in;
1378
+ white-space: nowrap;
1379
+ z-index: 10;
1380
+ }
1381
+
1382
+ :host([open]) .sfx-cr-zoom-popover {
1383
+ opacity: 1;
1384
+ transform: translateX(-50%) translateY(0) scale(1);
1385
+ pointer-events: auto;
1386
+ transition: opacity 220ms cubic-bezier(0.34, 1.2, 0.64, 1),
1387
+ transform 220ms cubic-bezier(0.34, 1.2, 0.64, 1);
1388
+ }
1389
+
1390
+ .sfx-cr-zoom-ruler {
1391
+ position: relative;
1392
+ width: var(--ruler-w, 260px);
1393
+ height: 30px;
1394
+ overflow: hidden;
1395
+ cursor: grab;
1396
+ touch-action: none;
1397
+ user-select: none;
1398
+ -webkit-user-select: none;
1399
+ }
1400
+ .sfx-cr-zoom-ruler.is-dragging { cursor: grabbing; }
1401
+ .sfx-cr-zoom-ruler:focus-visible {
1402
+ outline: 2px solid var(--sfx-cr-ring);
1403
+ outline-offset: 2px;
1404
+ border-radius: 4px;
1405
+ }
1406
+
1407
+ .sfx-cr-zoom-ticks {
1408
+ position: absolute;
1409
+ top: 50%;
1410
+ left: 0;
1411
+ height: 100%;
1412
+ will-change: transform;
1413
+ }
1414
+
1415
+ .sfx-cr-zoom-tick {
1416
+ position: absolute;
1417
+ top: 50%;
1418
+ width: 1px;
1419
+ height: 8px;
1420
+ margin-left: -0.5px;
1421
+ margin-top: -4px;
1422
+ border-radius: 0.5px;
1423
+ background: var(--sfx-cr-text);
1424
+ opacity: 0.55;
1425
+ }
1426
+ .sfx-cr-zoom-tick--major {
1427
+ width: 1px;
1428
+ height: 12px;
1429
+ margin-left: -0.5px;
1430
+ margin-top: -6px;
1431
+ opacity: 0.9;
1432
+ }
1433
+
1434
+ .sfx-cr-zoom-indicator {
1435
+ position: absolute;
1436
+ top: calc(50% + 4px);
1437
+ height: 16px;
1438
+ left: 50%;
1439
+ width: 4px;
1440
+ margin-left: -2px;
1441
+ background: var(--sfx-cr-text);
1442
+ border-radius: 2px;
1443
+ pointer-events: none;
1444
+ }
1445
+
1446
+ .sfx-cr-zoom-value {
1447
+ font-size: 14px;
1448
+ font-weight: 400;
1449
+ color: var(--sfx-cr-text);
1450
+ text-align: center;
1451
+ font-variant-numeric: tabular-nums;
1452
+ letter-spacing: 0.2px;
1453
+ }
1454
+
1455
+ @media (max-width: 768px) {
1456
+ /* Slimmer ruler + smaller readout on phones, mirroring the rotate
1457
+ popover. Push the popover down toward the canvas bottom edge so
1458
+ it doesn't sit in the middle of the photo. */
1459
+ .sfx-cr-zoom-ruler { width: 220px; height: 22px; }
1460
+ .sfx-cr-zoom-tick { height: 6px; margin-top: -3px; }
1461
+ .sfx-cr-zoom-tick--major { height: 9px; margin-top: -4.5px; }
1462
+ .sfx-cr-zoom-indicator {
1463
+ top: calc(50% + 3px);
1464
+ height: 12px;
1465
+ width: 3px;
1466
+ margin-left: -1.5px;
1467
+ }
1468
+ .sfx-cr-zoom-value { font-size: 12px; }
1469
+ :host([open]) .sfx-cr-zoom-popover {
1470
+ transform: translateX(-50%) translateY(24px) scale(1);
1471
+ }
1472
+ }
1473
+ @media (max-width: 480px) {
1474
+ .sfx-cr-zoom-ruler { width: 180px; height: 20px; }
1475
+ .sfx-cr-zoom-tick { height: 5px; margin-top: -2.5px; }
1476
+ .sfx-cr-zoom-tick--major { height: 8px; margin-top: -4px; }
1477
+ .sfx-cr-zoom-indicator {
1478
+ top: calc(50% + 2px);
1479
+ height: 10px;
1480
+ }
1481
+ .sfx-cr-zoom-value { font-size: 11px; }
1482
+ :host([open]) .sfx-cr-zoom-popover {
1483
+ transform: translateX(-50%) translateY(30px) scale(1);
1484
+ }
1485
+ }
1486
+
1487
+ /* Narrow editor — match the compact 30×30 trigger sizing of the
1488
+ rest of the vertical left-rail toolbar. Container query so a
1489
+ narrow editor on a wide desktop also collapses. */
1490
+ @container sfxcrop (max-width: 600px) {
1491
+ .sfx-cr-zoom-trigger {
1492
+ width: 30px;
1493
+ height: 30px;
1494
+ }
1495
+ .sfx-cr-zoom-trigger svg {
1496
+ width: 16px;
1497
+ height: 16px;
1498
+ }
1499
+ }
1500
+ `;var Ut=Object.defineProperty,E=(i,t,e,o)=>{for(var r=void 0,a=i.length-1,n;a>=0;a--)(n=i[a])&&(r=n(t,e,r)||r);return r&&Ut(t,e,r),r};function X(i,t,e){return Math.log(i/t)/Math.log(e/t)}function ot(i,t,e){return t*Math.pow(e/t,i)}const U=260,st=260,it=40,qt=5,tt=class tt extends O{constructor(){super(...arguments),this.min=.5,this.max=5,this.value=1,this.open=!1,this.icons={},this.dragging=!1,this.activePointer=null,this.pointerStartX=0,this.pointerStartSlider=0,this.autoCloseTimer=null,this.docClickHandler=()=>{this.open&&(this.clearAutoClose(),this.open=!1)},this.popoverAnchor=pt(this,".sfx-cr-zoom-popover"),this.onTriggerClick=t=>{t.stopPropagation(),this.clearAutoClose(),this.open=!this.open,this.open&&this.dispatchEvent(new CustomEvent("sfx-crop-popover-open",{detail:{source:"zoom"},bubbles:!0,composed:!0}))},this.onKeyDown=t=>{if(this.open){if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),this.open=!1;return}if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();const e=t.key==="ArrowRight"?1:-1,o=t.shiftKey?.05:.01,r=X(this.value,this.min,this.max),a=u.clamp(r+e*o,0,1);this.emit(ot(a,this.min,this.max))}}},this.onPointerDown=t=>{if(this.activePointer===null){this.clearAutoClose(),this.activePointer=t.pointerId,this.pointerStartX=t.clientX,this.pointerStartSlider=X(this.value,this.min,this.max),this.dragging=!0;try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}}},this.onPointerMove=t=>{if(this.activePointer!==t.pointerId)return;const e=t.clientX-this.pointerStartX,o=u.clamp(this.pointerStartSlider-e/U,0,1);this.emit(ot(o,this.min,this.max))},this.onPointerUp=t=>{if(this.activePointer===t.pointerId){this.activePointer=null,this.dragging=!1;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}},this.onReset=()=>{this.emit(1)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.docClickHandler)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.docClickHandler),this.popoverAnchor.stop(),this.clearAutoClose()}updated(t){t.has("open")&&(this.open?this.popoverAnchor.start():this.popoverAnchor.stop()),this.open&&(t.has("value")||t.has("dragging"))&&this.popoverAnchor.update()}render(){const t=X(this.value,this.min,this.max),e=Math.round(this.value*100),o=st/2-t*U,r=[],a=1/it;for(let n=0;n<=it;n++)r.push({pos:n*a,major:n%qt===0});return p.html`
1501
+ <div
1502
+ class="sfx-cr-zoom-root"
1503
+ @click=${n=>n.stopPropagation()}
1504
+ @keydown=${this.onKeyDown}
1505
+ >
1506
+ <button
1507
+ type="button"
1508
+ class="sfx-cr-zoom-trigger"
1509
+ aria-label=${`Zoom — ${e}%`}
1510
+ aria-haspopup="dialog"
1511
+ aria-expanded=${this.open?"true":"false"}
1512
+ @click=${this.onTriggerClick}
1513
+ >${k.unsafeHTML(y("loupe",this.icons))}</button>
1514
+
1515
+ <div class="sfx-cr-zoom-popover" role="group" aria-label="Zoom controls">
1516
+ <div
1517
+ class=${`sfx-cr-zoom-ruler${this.dragging?" is-dragging":""}`}
1518
+ role="slider"
1519
+ aria-valuemin=${String(this.min)}
1520
+ aria-valuemax=${String(this.max)}
1521
+ aria-valuenow=${this.value.toFixed(2)}
1522
+ aria-valuetext=${`${e}%`}
1523
+ tabindex="0"
1524
+ style=${`--ruler-w: ${st}px`}
1525
+ @pointerdown=${this.onPointerDown}
1526
+ @pointermove=${this.onPointerMove}
1527
+ @pointerup=${this.onPointerUp}
1528
+ @pointercancel=${this.onPointerUp}
1529
+ @dblclick=${this.onReset}
1530
+ >
1531
+ <div class="sfx-cr-zoom-ticks" style=${`transform: translateX(${o.toFixed(1)}px)`}>
1532
+ ${r.map(n=>p.html`
1533
+ <span
1534
+ class=${`sfx-cr-zoom-tick${n.major?" sfx-cr-zoom-tick--major":""}`}
1535
+ style=${`left: ${(n.pos*U).toFixed(1)}px`}
1536
+ ></span>
1537
+ `)}
1538
+ </div>
1539
+ <div class="sfx-cr-zoom-indicator" aria-hidden="true"></div>
1540
+ </div>
1541
+ <span class="sfx-cr-zoom-value">${e}%</span>
1542
+ </div>
1543
+ </div>
1544
+ `}setValue(t){this.value=u.clamp(t,this.min,this.max)}showTemporarily(t=1500){if(this.open&&this.autoCloseTimer===null)return;const e=this.open;this.open=!0,e||this.dispatchEvent(new CustomEvent("sfx-crop-popover-open",{detail:{source:"zoom"},bubbles:!0,composed:!0})),this.clearAutoClose(),this.autoCloseTimer=setTimeout(()=>{this.autoCloseTimer=null,this.open=!1},t)}clearAutoClose(){this.autoCloseTimer!==null&&(clearTimeout(this.autoCloseTimer),this.autoCloseTimer=null)}emit(t){this.value!==t&&(this.value=t,this.dispatchEvent(new CustomEvent("sfx-crop-zoom-change",{detail:{scale:t},bubbles:!0,composed:!0})))}};tt.styles=[B,Xt];let S=tt;E([s.property({type:Number})],S.prototype,"min");E([s.property({type:Number})],S.prototype,"max");E([s.property({type:Number})],S.prototype,"value");E([s.property({type:Boolean,reflect:!0})],S.prototype,"open");E([s.property({attribute:!1})],S.prototype,"icons");E([s.state()],S.prototype,"dragging");M("sfx-crop-zoom",S);M("sfx-crop-rotate",$);M("sfx-crop-shapes",w);M("sfx-crop-canvas",A);M("sfx-crop-toolbar",x);M("sfx-crop",l);
1545
+ //# sourceMappingURL=define-CVJd5aYk.cjs.map