pixedi 1.0.0 → 1.0.2
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.
- package/README.md +65 -60
- package/README.npm.md +80 -0
- package/dist/lib/index.js +1602 -0
- package/dist/lib/index.umd.js +28 -0
- package/package.json +9 -4
- package/.github/workflows/deploy.yml +0 -54
- package/.prettierr +0 -9
- package/.storybook/main.ts +0 -16
- package/.storybook/preview.ts +0 -53
- package/.vscode/extensions.json +0 -6
- package/eslint.config.js +0 -22
- package/index.html +0 -13
- package/pnpm-workspace.yaml +0 -2
- package/public/favicon.svg +0 -1
- package/src/app/App.tsx +0 -10
- package/src/app/entries/index.ts +0 -145
- package/src/app/providers/RouterProvider.tsx +0 -6
- package/src/app/providers/index.ts +0 -1
- package/src/app/router/AppRouter.tsx +0 -12
- package/src/app/router/index.ts +0 -0
- package/src/app/styles/index.css +0 -4
- package/src/features/gallery/GalleryPage.tsx +0 -33
- package/src/features/gallery/ImageEditPage.tsx +0 -37
- package/src/features/gallery/index.ts +0 -2
- package/src/main.tsx +0 -10
- package/src/shared/components/ImageCard/ImageCard.tsx +0 -54
- package/src/shared/components/ImageCard/index.ts +0 -1
- package/src/shared/components/ImageEditor/ImageEditor.tsx +0 -48
- package/src/shared/components/ImageEditor/assets/icons.tsx +0 -114
- package/src/shared/components/ImageEditor/constants.ts +0 -118
- package/src/shared/components/ImageEditor/crop/Crop.tsx +0 -60
- package/src/shared/components/ImageEditor/crop/CropBorders.tsx +0 -28
- package/src/shared/components/ImageEditor/crop/CropLines.tsx +0 -8
- package/src/shared/components/ImageEditor/crop/CropPointer.tsx +0 -21
- package/src/shared/components/ImageEditor/crop/CropPointers.tsx +0 -44
- package/src/shared/components/ImageEditor/crop/CropTools.tsx +0 -138
- package/src/shared/components/ImageEditor/crop/crop.css +0 -180
- package/src/shared/components/ImageEditor/crop/index.ts +0 -8
- package/src/shared/components/ImageEditor/crop/useCropInteraction.ts +0 -230
- package/src/shared/components/ImageEditor/eventBus.ts +0 -8
- package/src/shared/components/ImageEditor/frame/Frame.tsx +0 -48
- package/src/shared/components/ImageEditor/frame/frame.css +0 -40
- package/src/shared/components/ImageEditor/frame/index.ts +0 -1
- package/src/shared/components/ImageEditor/header/Header.tsx +0 -81
- package/src/shared/components/ImageEditor/header/header.css +0 -27
- package/src/shared/components/ImageEditor/header/index.ts +0 -1
- package/src/shared/components/ImageEditor/hooks/index.ts +0 -5
- package/src/shared/components/ImageEditor/hooks/useAbove.tsx +0 -18
- package/src/shared/components/ImageEditor/hooks/useBellow.tsx +0 -18
- package/src/shared/components/ImageEditor/hooks/useImageLoader.tsx +0 -110
- package/src/shared/components/ImageEditor/hooks/useImageProcessor.test.tsx +0 -147
- package/src/shared/components/ImageEditor/hooks/useImageProcessor.ts +0 -225
- package/src/shared/components/ImageEditor/hooks/useMobile.tsx +0 -33
- package/src/shared/components/ImageEditor/index.css +0 -145
- package/src/shared/components/ImageEditor/index.ts +0 -1
- package/src/shared/components/ImageEditor/provider/ImageEditorProvider.test.tsx +0 -126
- package/src/shared/components/ImageEditor/provider/ImageEditorProvider.tsx +0 -107
- package/src/shared/components/ImageEditor/provider/StoreContext.tsx +0 -20
- package/src/shared/components/ImageEditor/provider/initialState.ts +0 -30
- package/src/shared/components/ImageEditor/provider/useImageEditorContext.tsx +0 -12
- package/src/shared/components/ImageEditor/resize/ResizeTools.tsx +0 -183
- package/src/shared/components/ImageEditor/resize/index.ts +0 -1
- package/src/shared/components/ImageEditor/resize/resize.css +0 -56
- package/src/shared/components/ImageEditor/sidebar/Sidebar.tsx +0 -54
- package/src/shared/components/ImageEditor/sidebar/SidebarCrop.tsx +0 -57
- package/src/shared/components/ImageEditor/sidebar/SidebarPresets.tsx +0 -54
- package/src/shared/components/ImageEditor/sidebar/SidebarResize.tsx +0 -26
- package/src/shared/components/ImageEditor/sidebar/index.ts +0 -1
- package/src/shared/components/ImageEditor/sidebar/sidebar.css +0 -101
- package/src/shared/components/ImageEditor/types.ts +0 -59
- package/src/shared/components/ImageEditor/ui/button/Button.stories.tsx +0 -42
- package/src/shared/components/ImageEditor/ui/button/Button.tsx +0 -21
- package/src/shared/components/ImageEditor/ui/button/button.css +0 -69
- package/src/shared/components/ImageEditor/ui/button-crop/ButtonCrop.stories.tsx +0 -26
- package/src/shared/components/ImageEditor/ui/button-crop/ButtonCrop.tsx +0 -29
- package/src/shared/components/ImageEditor/ui/button-crop/button-crop.css +0 -38
- package/src/shared/components/ImageEditor/ui/index.ts +0 -6
- package/src/shared/components/ImageEditor/ui/input/Input.stories.tsx +0 -45
- package/src/shared/components/ImageEditor/ui/input/Input.tsx +0 -20
- package/src/shared/components/ImageEditor/ui/input/input.css +0 -48
- package/src/shared/components/ImageEditor/ui/input-pixel/InputPixel.stories.tsx +0 -33
- package/src/shared/components/ImageEditor/ui/input-pixel/InputPixel.tsx +0 -23
- package/src/shared/components/ImageEditor/ui/input-pixel/input-pixel.css +0 -24
- package/src/shared/components/ImageEditor/ui/select/Select.stories.tsx +0 -67
- package/src/shared/components/ImageEditor/ui/select/Select.tsx +0 -161
- package/src/shared/components/ImageEditor/ui/select/select.css +0 -147
- package/src/shared/components/ImageEditor/ui/separator/Separator.stories.tsx +0 -37
- package/src/shared/components/ImageEditor/ui/separator/Separator.tsx +0 -27
- package/src/shared/components/ImageEditor/ui/separator/separator.css +0 -19
- package/src/shared/components/ImageEditor/utils.test.ts +0 -136
- package/src/shared/components/ImageEditor/utils.ts +0 -497
- package/src/shared/components/ui/index.ts +0 -1
- package/src/shared/components/ui/preloader.tsx +0 -78
- package/src/shared/config/index.ts +0 -3
- package/src/shared/config/routes.ts +0 -4
- package/src/shared/features/gallery/GalleryPage.tsx +0 -33
- package/src/shared/features/gallery/ImageEditPage.tsx +0 -37
- package/src/shared/features/gallery/index.ts +0 -2
- package/src/shared/hooks/index.ts +0 -1
- package/src/shared/hooks/useImagePreload.tsx +0 -49
- package/src/shared/types/index.ts +0 -11
- package/src/test/setup.ts +0 -14
- package/src/virtual-css-injected-by-js.d.ts +0 -8
- package/src/widget.tsx +0 -119
- package/tsconfig.app.json +0 -29
- package/tsconfig.json +0 -12
- package/tsconfig.lib.json +0 -18
- package/tsconfig.node.json +0 -23
- package/vite-env.d.ts +0 -1
- package/vite.config.ts +0 -24
- package/vite.lib.config.ts +0 -33
- package/vite.widget.config.ts +0 -39
- package/wrangler.json +0 -5
|
@@ -0,0 +1,1602 @@
|
|
|
1
|
+
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`.btn{cursor:pointer;white-space:nowrap;-webkit-user-select:none;user-select:none;box-sizing:border-box;background-color:#0000;border:1px solid #0000;border-radius:4px;justify-content:center;align-items:center;gap:8px;height:32px;padding-left:8px;padding-right:8px;font-family:inherit;font-size:14px;font-weight:500;transition:background-color .2s,border-color .2s,opacity .2s;display:inline-flex}.btn:disabled{pointer-events:none;opacity:.5}.btn:active{transform:translateY(1px)}.btn svg{flex-shrink:0;width:16px;height:16px}.btn-default{background-color:var(--primary);color:var(--primary-foreground)}.btn-default:hover{opacity:.9}.btn-outline{border-color:var(--border);background-color:var(--background);color:var(--foreground)}.btn-outline:hover{background-color:var(--secondary)}.btn-ghost{color:var(--foreground);padding-left:8px;padding-right:8px}.btn-ghost:hover{background-color:var(--secondary)}.btn-rect{width:32px;height:32px}.btn-crop{border:1px solid var(--border);background-color:var(--background);color:var(--foreground);cursor:pointer;-webkit-user-select:none;user-select:none;box-sizing:border-box;border-radius:4px;flex-direction:column;justify-content:center;align-items:center;gap:8px;padding:12px;font-family:inherit;font-size:12px;transition:all .2s;display:inline-flex}.btn-crop:hover:not([aria-pressed=true]){background-color:var(--secondary)}.btn-crop[aria-pressed=true]{border-color:var(--accent-blue);background-color:var(--accent-blue-light);color:var(--foreground)}.btn-crop svg{flex-shrink:0;width:20px;height:20px}.btn-crop span{white-space:nowrap}.separator{background-color:var(--border);box-sizing:border-box;border:none;flex-shrink:0;display:block}.separator[data-orientation=horizontal]{width:100%;height:1px}.separator[data-orientation=vertical]{align-self:stretch;width:1px;height:100%;margin:0}.select-wrapper{box-sizing:border-box;width:100%;position:relative}.select-trigger{width:100%;height:32px;color:var(--foreground);background-color:var(--background);border:1px solid var(--border);cursor:pointer;box-sizing:border-box;-webkit-user-select:none;user-select:none;border-radius:4px;outline:none;justify-content:space-between;align-items:center;padding-left:10px;padding-right:8px;font-family:inherit;font-size:14px;transition:border-color .2s;display:flex}.select-trigger:hover,.select-trigger:focus{border-color:var(--muted-foreground)}.select-trigger-arrow{width:16px;height:16px;color:var(--muted-foreground);transition:transform .2s}.select-wrapper[data-state=open] .select-trigger-arrow{transform:rotate(180deg)}.select-content{background-color:var(--background);border:1px solid var(--border);z-index:50;box-sizing:border-box;border-radius:4px;width:100%;max-height:282px;padding:4px;position:absolute;top:calc(100% + 4px);left:0;overflow-y:auto;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -2px #0000000d}.select-content::-webkit-scrollbar{width:4px}.select-content::-webkit-scrollbar-track{background:0 0}.select-content::-webkit-scrollbar-thumb{background-color:var(--border);border-radius:10px}.select-wrapper[data-state=closed] .select-content{display:none}.select-group-label{color:var(--muted-foreground);-webkit-user-select:none;user-select:none;padding:8px 10px;font-size:12px;font-weight:500}.select-item{width:100%;color:var(--foreground);cursor:pointer;-webkit-user-select:none;user-select:none;box-sizing:border-box;background:0 0;border-radius:4px;justify-content:space-between;align-items:center;padding:4px 10px;display:flex}.select-item:hover{background-color:var(--secondary)}.select-item-left{font-size:14px;font-weight:400}.select-item-addon{align-items:center;gap:8px;display:flex}.select-item-addon>span{color:var(--muted-foreground);font-size:12px}.select-item-addon>svg{font-size:14px}.select-item-addon>b{flex-shrink:0;width:16px;height:16px}.select-item-right-container{align-items:center;gap:8px;display:flex}.select-item-right{color:var(--muted-foreground);font-size:14px}.select-item-check{width:16px;height:16px;color:var(--foreground);flex-shrink:0}.input{width:100%;height:32px;color:var(--foreground);background-color:var(--background);border:1px solid var(--input);box-sizing:border-box;border-radius:4px;outline:none;padding-left:8px;padding-right:8px;font-family:inherit;font-size:14px;line-height:normal;transition:border-color .2s,box-shadow .2s;display:block}.input:hover:not(:disabled):not(:focus){border-color:var(--muted-foreground)}.input:focus{box-shadow:0 0 0 1px var(--ring)}.input:disabled{cursor:not-allowed;opacity:.5;background-color:var(--secondary)}.input::placeholder{color:var(--muted-foreground);opacity:1}.input-number-clean::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.input-number-clean::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.input-number-clean[type=number]{-moz-appearance:textfield}.input-pixel-container{position:relative}.input-pixel-legend{color:var(--muted-foreground);background:var(--background);margin-left:8px;padding-left:4px;padding-right:4px;font-size:12px;position:absolute;top:-9px}.input-pixel-suffix{color:var(--muted-foreground);pointer-events:none;-webkit-user-select:none;user-select:none;font-size:14px;position:absolute;bottom:2px;right:8px}.header{box-sizing:border-box;background-color:var(--background);border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;height:48px;padding-left:8px;padding-right:8px;display:flex}.header-tools{gap:8px;display:flex}.header-history{align-items:center;gap:8px;display:flex}.header-history-text{color:var(--muted-foreground);font-size:14px}.crop-image{width:100%;height:100%;position:absolute;inset:0}.crop-box{cursor:move;position:absolute}.crop-tools{background-color:var(--background);box-sizing:border-box;border:1px solid var(--border);border-radius:4px;align-items:center;height:36px;padding-left:12px;display:flex;position:absolute;bottom:24px;left:50%;transform:translate(-50%);box-shadow:0 4px 6px -1px #0000001a,0 2px 4px -1px #0000000f}.crop-tools-info{min-width:54px;margin-top:-2px;display:inline-block}.crop-tools-info-label{color:var(--muted-foreground);font-size:12px;line-height:12px}.crop-tools-info-value{font-size:14px;line-height:14px}.crop-b{background-color:var(--accent-blue);position:absolute}.crop-b-t{cursor:ns-resize;width:100%;height:2px;top:0;left:0}.crop-b-r{cursor:ew-resize;width:2px;height:100%;top:0;right:0}.crop-b-b{cursor:ns-resize;width:100%;height:2px;bottom:0;left:0;transform:translateY(1px)}.crop-b-l{cursor:ew-resize;width:2px;height:100%;top:0;left:-1px;transform:translate(1px)}.crop-l-box{pointer-events:none;position:absolute;inset:2px}.crop-l{border:1px dashed var(--color-white);opacity:.5;position:absolute}.crop-l-v{border-top:0;border-bottom:0;width:33%;height:100%;top:0;left:33%}.crop-l-h{border-left:0;border-right:0;width:100%;height:33%;top:33%;left:0}.crop-ps{box-sizing:border-box;border:1px solid var(--accent-blue);background-color:var(--overlay-bg-white);border-radius:50%;width:12px;height:12px;position:absolute}.crop-ps-tl{cursor:nwse-resize;top:-5px;left:-5px}.crop-ps-t{cursor:ns-resize;top:-5px;left:50%;transform:translate(-50%)}.crop-ps-tr{cursor:nesw-resize;top:-5px;right:-5px}.crop-ps-r{cursor:ew-resize;top:50%;right:-5px;transform:translateY(-50%)}.crop-ps-br{cursor:nwse-resize;bottom:-5px;right:-5px}.crop-ps-b{cursor:ns-resize;bottom:-5px;left:50%;transform:translate(-50%)}.crop-ps-bl{cursor:nesw-resize;bottom:-5px;left:-5px}.crop-ps-l{cursor:ew-resize;top:50%;left:-5px;transform:translateY(-50%)}.crop-p-b{box-sizing:border-box;border:2px solid var(--accent-blue);position:absolute;inset:0}.crop-p-p{background-color:var(--overlay-bg-white);border:3px solid var(--accent-blue);box-sizing:border-box;border-radius:50%;width:32px;height:32px;position:absolute;bottom:-16px;right:-16px}.frame{box-sizing:border-box;justify-content:center;align-items:center;width:100%;height:100%;min-height:0;padding:16px;display:flex;position:relative;overflow:hidden}.frame--faded{background-color:#00000080}.frame-preview{-webkit-user-select:none;user-select:none;flex-shrink:1;width:auto;min-width:0;max-width:100%;height:auto;min-height:0;max-height:100%;transition:transform .2s;display:block;position:relative}.frame-image{object-fit:contain;width:100%;height:100%}.frame-image--faded{opacity:.4}.resize{background-color:var(--background);border-radius:4px;flex-direction:column;padding:16px;display:flex;position:absolute;bottom:24px;left:50%;transform:translate(-50%);box-shadow:0 2px 8px #0000001a}.resize-text{text-align:center;color:var(--muted-foreground);font-size:14px}.resize-border{border-bottom:1px solid var(--border);width:60px;margin:12px auto 4px;display:inline-block}.resize-tools{align-items:center;gap:6px;margin-top:16px;display:flex}.resize-tools-lock{width:12px;height:12px;color:var(--muted-foreground)}.resize-tools-buttons{margin-left:4px;display:flex}.resize-tools-save{border-top-right-radius:0;border-bottom-right-radius:0;width:36px}.resize-tools-close{border-top-left-radius:0;border-bottom-left-radius:0;width:36px;margin-left:-1px}.sidebar{z-index:10;width:0;transition:transform .15s ease-out;position:relative}@media (width>=768px){.sidebar{width:320px;transition:none}}.sidebar-settings{border-radius:50%;width:40px;height:40px;position:absolute;top:8px;right:8px;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}@media (width>=768px){.sidebar-settings{display:none}}.sidebar-container{box-sizing:border-box;border-left:1px solid var(--border);position:absolute;inset:0}.sidebar-content{background-color:var(--background);box-sizing:border-box;flex-direction:column;width:320px;height:100%;padding:16px;display:flex;position:absolute;top:0;left:0;overflow-y:auto}@media (width<=767px){.sidebar-content{padding-top:48px}}.sidebar-close-btn{position:absolute;top:8px;right:8px}.sidebar-separator{margin-top:20px;margin-bottom:12px}.sidebar-resize{justify-content:space-between;align-items:center;display:flex}.sidebar-resize-icon{align-items:center;gap:8px;display:flex}.sidebar-resize-size{color:var(--muted-foreground);font-size:14px}.sidebar-crop{flex-direction:column;gap:8px;display:flex}.sidebar-crop-ratios{grid-template-columns:repeat(3,1fr);gap:8px;display:grid}.sidebar-preset{flex-direction:column;gap:8px;display:flex}.picedi{font-size:16px;font-family:var(--font-sans);--font-sans:system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Tahoma, Helvetica, Arial, sans-serif;--color-white:#fff;--color-black:#000;--color-transparent:transparent;--color-red:oklch(63.7% .237 25.331);--color-green:oklch(76.8% .188 151.716);--background:oklch(100% 0 0);--foreground:oklch(14.5% 0 0);--card:oklch(100% 0 0);--card-foreground:oklch(14.5% 0 0);--popover:oklch(100% 0 0);--popover-foreground:oklch(14.5% 0 0);--primary:oklch(20.5% 0 0);--primary-foreground:oklch(98.5% 0 0);--secondary:oklch(97% 0 0);--secondary-foreground:oklch(20.5% 0 0);--muted:oklch(97% 0 0);--muted-foreground:oklch(55.6% 0 0);--accent:oklch(97% 0 0);--accent-foreground:oklch(20.5% 0 0);--accent-blue:oklch(60.9% .221 251.687);--accent-blue-light:oklch(96% .02 250);--destructive:oklch(57.7% .245 27.325);--success:oklch(76.8% .188 151.716);--border:oklch(92.2% 0 0);--input:oklch(92.2% 0 0);--ring:oklch(70.8% 0 0);--radius:4px;--sidebar:oklch(98.5% 0 0);--sidebar-foreground:oklch(14.5% 0 0);--sidebar-primary:oklch(20.5% 0 0);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(97% 0 0);--sidebar-accent-foreground:oklch(20.5% 0 0);--sidebar-border:oklch(92.2% 0 0);--sidebar-ring:oklch(70.8% 0 0);--overlay-bg:color-mix(in srgb, var(--color-black) 50%, transparent);--overlay-bg-white:color-mix(in srgb, var(--color-white) 80%, transparent)}:host([data-theme=dark]) .picedi,[data-theme=dark] .picedi,[data-theme=dark].picedi{--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(20.5% 0 0);--card-foreground:oklch(98.5% 0 0);--popover:oklch(20.5% 0 0);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(92.2% 0 0);--primary-foreground:oklch(20.5% 0 0);--secondary:oklch(26.9% 0 0);--secondary-foreground:oklch(98.5% 0 0);--muted:oklch(26.9% 0 0);--muted-foreground:oklch(70.8% 0 0);--accent:oklch(26.9% 0 0);--accent-foreground:oklch(98.5% 0 0);--accent-blue-light:oklch(25% .06 250);--destructive:oklch(70.4% .191 22.216);--border:oklch(100% 0 0/.1);--input:oklch(100% 0 0/.15);--ring:oklch(55.6% 0 0);--sidebar-foreground:oklch(98.5% 0 0);--sidebar-primary:oklch(48.8% .243 264.376);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(26.9% 0 0);--sidebar-accent-foreground:oklch(98.5% 0 0);--sidebar-border:oklch(100% 0 0/.1);--sidebar-ring:oklch(55.6% 0 0);--overlay-bg:color-mix(in srgb, var(--color-black) 75%, transparent)}.picedi h1,.picedi h2,.picedi h3,.picedi h4,.picedi h5,.picedi h6{margin:0;font-weight:600}.text-red{color:var(--color-red)}.bg-red{background-color:var(--color-red)}.bg-green{background-color:var(--color-green)}.text-green{color:var(--color-green)}.mask{background-color:var(--overlay-bg)}.semibold{letter-spacing:.4px;font-weight:600}.bold{letter-spacing:.4px;font-weight:700}.sys{width:100%;height:100%;color:var(--muted-foreground);justify-content:center;align-items:center;display:flex;position:relative}.main{background-color:var(--background);grid-template-rows:auto 1fr;height:100%;display:grid;overflow:hidden}.grid{grid-template-columns:1fr auto;min-height:0;display:grid;position:relative;overflow:hidden}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();
|
|
2
|
+
import { createContext as e, forwardRef as t, useCallback as n, useContext as r, useEffect as i, useLayoutEffect as a, useMemo as o, useRef as s, useState as c } from "react";
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var l = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), u = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
5
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
6
|
+
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
7
|
+
}), d = /* @__PURE__ */ l(((e) => {
|
|
8
|
+
var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
9
|
+
function r(e, n, r) {
|
|
10
|
+
var i = null;
|
|
11
|
+
if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
|
|
12
|
+
else r = n;
|
|
13
|
+
return n = r.ref, {
|
|
14
|
+
$$typeof: t,
|
|
15
|
+
type: e,
|
|
16
|
+
key: i,
|
|
17
|
+
ref: n === void 0 ? null : n,
|
|
18
|
+
props: r
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
e.Fragment = n, e.jsx = r, e.jsxs = r;
|
|
22
|
+
})), f = /* @__PURE__ */ l(((e) => {
|
|
23
|
+
process.env.NODE_ENV !== "production" && (function() {
|
|
24
|
+
function t(e) {
|
|
25
|
+
if (e == null) return null;
|
|
26
|
+
if (typeof e == "function") return e.$$typeof === O ? null : e.displayName || e.name || null;
|
|
27
|
+
if (typeof e == "string") return e;
|
|
28
|
+
switch (e) {
|
|
29
|
+
case v: return "Fragment";
|
|
30
|
+
case b: return "Profiler";
|
|
31
|
+
case y: return "StrictMode";
|
|
32
|
+
case w: return "Suspense";
|
|
33
|
+
case T: return "SuspenseList";
|
|
34
|
+
case ee: return "Activity";
|
|
35
|
+
}
|
|
36
|
+
if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
|
|
37
|
+
case _: return "Portal";
|
|
38
|
+
case S: return e.displayName || "Context";
|
|
39
|
+
case x: return (e._context.displayName || "Context") + ".Consumer";
|
|
40
|
+
case C:
|
|
41
|
+
var n = e.render;
|
|
42
|
+
return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
|
|
43
|
+
case E: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
|
|
44
|
+
case D:
|
|
45
|
+
n = e._payload, e = e._init;
|
|
46
|
+
try {
|
|
47
|
+
return t(e(n));
|
|
48
|
+
} catch {}
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function n(e) {
|
|
53
|
+
return "" + e;
|
|
54
|
+
}
|
|
55
|
+
function r(e) {
|
|
56
|
+
try {
|
|
57
|
+
n(e);
|
|
58
|
+
var t = !1;
|
|
59
|
+
} catch {
|
|
60
|
+
t = !0;
|
|
61
|
+
}
|
|
62
|
+
if (t) {
|
|
63
|
+
t = console;
|
|
64
|
+
var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
65
|
+
return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function i(e) {
|
|
69
|
+
if (e === v) return "<>";
|
|
70
|
+
if (typeof e == "object" && e && e.$$typeof === D) return "<...>";
|
|
71
|
+
try {
|
|
72
|
+
var n = t(e);
|
|
73
|
+
return n ? "<" + n + ">" : "<...>";
|
|
74
|
+
} catch {
|
|
75
|
+
return "<...>";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function a() {
|
|
79
|
+
var e = k.A;
|
|
80
|
+
return e === null ? null : e.getOwner();
|
|
81
|
+
}
|
|
82
|
+
function o() {
|
|
83
|
+
return Error("react-stack-top-frame");
|
|
84
|
+
}
|
|
85
|
+
function s(e) {
|
|
86
|
+
if (A.call(e, "key")) {
|
|
87
|
+
var t = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
88
|
+
if (t && t.isReactWarning) return !1;
|
|
89
|
+
}
|
|
90
|
+
return e.key !== void 0;
|
|
91
|
+
}
|
|
92
|
+
function c(e, t) {
|
|
93
|
+
function n() {
|
|
94
|
+
N || (N = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
|
|
95
|
+
}
|
|
96
|
+
n.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
97
|
+
get: n,
|
|
98
|
+
configurable: !0
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function l() {
|
|
102
|
+
var e = t(this.type);
|
|
103
|
+
return P[e] || (P[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
|
|
104
|
+
}
|
|
105
|
+
function d(e, t, n, r, i, a) {
|
|
106
|
+
var o = n.ref;
|
|
107
|
+
return e = {
|
|
108
|
+
$$typeof: g,
|
|
109
|
+
type: e,
|
|
110
|
+
key: t,
|
|
111
|
+
props: n,
|
|
112
|
+
_owner: r
|
|
113
|
+
}, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
|
|
114
|
+
enumerable: !1,
|
|
115
|
+
value: null
|
|
116
|
+
}) : Object.defineProperty(e, "ref", {
|
|
117
|
+
enumerable: !1,
|
|
118
|
+
get: l
|
|
119
|
+
}), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
120
|
+
configurable: !1,
|
|
121
|
+
enumerable: !1,
|
|
122
|
+
writable: !0,
|
|
123
|
+
value: 0
|
|
124
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
125
|
+
configurable: !1,
|
|
126
|
+
enumerable: !1,
|
|
127
|
+
writable: !0,
|
|
128
|
+
value: null
|
|
129
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
130
|
+
configurable: !1,
|
|
131
|
+
enumerable: !1,
|
|
132
|
+
writable: !0,
|
|
133
|
+
value: i
|
|
134
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
135
|
+
configurable: !1,
|
|
136
|
+
enumerable: !1,
|
|
137
|
+
writable: !0,
|
|
138
|
+
value: a
|
|
139
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
140
|
+
}
|
|
141
|
+
function f(e, n, i, o, l, u) {
|
|
142
|
+
var f = n.children;
|
|
143
|
+
if (f !== void 0) if (o) if (j(f)) {
|
|
144
|
+
for (o = 0; o < f.length; o++) p(f[o]);
|
|
145
|
+
Object.freeze && Object.freeze(f);
|
|
146
|
+
} else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
147
|
+
else p(f);
|
|
148
|
+
if (A.call(n, "key")) {
|
|
149
|
+
f = t(e);
|
|
150
|
+
var m = Object.keys(n).filter(function(e) {
|
|
151
|
+
return e !== "key";
|
|
152
|
+
});
|
|
153
|
+
o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", L[f + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, f, m, f), L[f + o] = !0);
|
|
154
|
+
}
|
|
155
|
+
if (f = null, i !== void 0 && (r(i), f = "" + i), s(n) && (r(n.key), f = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
|
|
156
|
+
else i = n;
|
|
157
|
+
return f && c(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), d(e, f, i, a(), l, u);
|
|
158
|
+
}
|
|
159
|
+
function p(e) {
|
|
160
|
+
m(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? m(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
161
|
+
}
|
|
162
|
+
function m(e) {
|
|
163
|
+
return typeof e == "object" && !!e && e.$$typeof === g;
|
|
164
|
+
}
|
|
165
|
+
var h = u("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), ee = Symbol.for("react.activity"), O = Symbol.for("react.client.reference"), k = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, A = Object.prototype.hasOwnProperty, j = Array.isArray, M = console.createTask ? console.createTask : function() {
|
|
166
|
+
return null;
|
|
167
|
+
};
|
|
168
|
+
h = { react_stack_bottom_frame: function(e) {
|
|
169
|
+
return e();
|
|
170
|
+
} };
|
|
171
|
+
var N, P = {}, F = h.react_stack_bottom_frame.bind(h, o)(), I = M(i(o)), L = {};
|
|
172
|
+
e.Fragment = v, e.jsx = function(e, t, n) {
|
|
173
|
+
var r = 1e4 > k.recentlyCreatedOwnerStacks++;
|
|
174
|
+
return f(e, t, n, !1, r ? Error("react-stack-top-frame") : F, r ? M(i(e)) : I);
|
|
175
|
+
}, e.jsxs = function(e, t, n) {
|
|
176
|
+
var r = 1e4 > k.recentlyCreatedOwnerStacks++;
|
|
177
|
+
return f(e, t, n, !0, r ? Error("react-stack-top-frame") : F, r ? M(i(e)) : I);
|
|
178
|
+
};
|
|
179
|
+
})();
|
|
180
|
+
})), p = (/* @__PURE__ */ l(((e, t) => {
|
|
181
|
+
process.env.NODE_ENV === "production" ? t.exports = d() : t.exports = f();
|
|
182
|
+
})))();
|
|
183
|
+
function m({ size: e = 36, className: t, style: n, color: r = "currentColor" }) {
|
|
184
|
+
return /* @__PURE__ */ (0, p.jsxs)("svg", {
|
|
185
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
186
|
+
x: "0px",
|
|
187
|
+
y: "0px",
|
|
188
|
+
viewBox: "0 0 80 80",
|
|
189
|
+
width: e,
|
|
190
|
+
height: e,
|
|
191
|
+
fill: r,
|
|
192
|
+
className: t,
|
|
193
|
+
style: n,
|
|
194
|
+
children: [/* @__PURE__ */ (0, p.jsx)("path", {
|
|
195
|
+
d: "M10,40c0,0,0-0.4,0-1.1c0-0.3,0-0.8,0-1.3c0-0.3,0-0.5,0-0.8c0-0.3,0.1-0.6,0.1-0.9c0.1-0.6,0.1-1.4,0.2-2.1\n c0.2-0.8,0.3-1.6,0.5-2.5c0.2-0.9,0.6-1.8,0.8-2.8c0.3-1,0.8-1.9,1.2-3c0.5-1,1.1-2,1.7-3.1c0.7-1,1.4-2.1,2.2-3.1\n c1.6-2.1,3.7-3.9,6-5.6c2.3-1.7,5-3,7.9-4.1c0.7-0.2,1.5-0.4,2.2-0.7c0.7-0.3,1.5-0.3,2.3-0.5c0.8-0.2,1.5-0.3,2.3-0.4l1.2-0.1\n l0.6-0.1l0.3,0l0.1,0l0.1,0l0,0c0.1,0-0.1,0,0.1,0c1.5,0,2.9-0.1,4.5,0.2c0.8,0.1,1.6,0.1,2.4,0.3c0.8,0.2,1.5,0.3,2.3,0.5\n c3,0.8,5.9,2,8.5,3.6c2.6,1.6,4.9,3.4,6.8,5.4c1,1,1.8,2.1,2.7,3.1c0.8,1.1,1.5,2.1,2.1,3.2c0.6,1.1,1.2,2.1,1.6,3.1\n c0.4,1,0.9,2,1.2,3c0.3,1,0.6,1.9,0.8,2.7c0.2,0.9,0.3,1.6,0.5,2.4c0.1,0.4,0.1,0.7,0.2,1c0,0.3,0.1,0.6,0.1,0.9\n c0.1,0.6,0.1,1,0.1,1.4C74,39.6,74,40,74,40c0.2,2.2-1.5,4.1-3.7,4.3s-4.1-1.5-4.3-3.7c0-0.1,0-0.2,0-0.3l0-0.4c0,0,0-0.3,0-0.9\n c0-0.3,0-0.7,0-1.1c0-0.2,0-0.5,0-0.7c0-0.2-0.1-0.5-0.1-0.8c-0.1-0.6-0.1-1.2-0.2-1.9c-0.1-0.7-0.3-1.4-0.4-2.2\n c-0.2-0.8-0.5-1.6-0.7-2.4c-0.3-0.8-0.7-1.7-1.1-2.6c-0.5-0.9-0.9-1.8-1.5-2.7c-0.6-0.9-1.2-1.8-1.9-2.7c-1.4-1.8-3.2-3.4-5.2-4.9\n c-2-1.5-4.4-2.7-6.9-3.6c-0.6-0.2-1.3-0.4-1.9-0.6c-0.7-0.2-1.3-0.3-1.9-0.4c-1.2-0.3-2.8-0.4-4.2-0.5l-2,0c-0.7,0-1.4,0.1-2.1,0.1\n c-0.7,0.1-1.4,0.1-2,0.3c-0.7,0.1-1.3,0.3-2,0.4c-2.6,0.7-5.2,1.7-7.5,3.1c-2.2,1.4-4.3,2.9-6,4.7c-0.9,0.8-1.6,1.8-2.4,2.7\n c-0.7,0.9-1.3,1.9-1.9,2.8c-0.5,1-1,1.9-1.4,2.8c-0.4,0.9-0.8,1.8-1,2.6c-0.3,0.9-0.5,1.6-0.7,2.4c-0.2,0.7-0.3,1.4-0.4,2.1\n c-0.1,0.3-0.1,0.6-0.2,0.9c0,0.3-0.1,0.6-0.1,0.8c0,0.5-0.1,0.9-0.1,1.3C10,39.6,10,40,10,40z",
|
|
196
|
+
children: /* @__PURE__ */ (0, p.jsx)("animateTransform", {
|
|
197
|
+
attributeType: "xml",
|
|
198
|
+
attributeName: "transform",
|
|
199
|
+
type: "rotate",
|
|
200
|
+
from: "0 40 40",
|
|
201
|
+
to: "360 40 40",
|
|
202
|
+
dur: "0.8s",
|
|
203
|
+
repeatCount: "indefinite"
|
|
204
|
+
})
|
|
205
|
+
}), /* @__PURE__ */ (0, p.jsx)("path", {
|
|
206
|
+
fill: "currentColor",
|
|
207
|
+
d: "M62,40.1c0,0,0,0.2-0.1,0.7c0,0.2,0,0.5-0.1,0.8c0,0.2,0,0.3,0,0.5c0,0.2-0.1,0.4-0.1,0.7\n c-0.1,0.5-0.2,1-0.3,1.6c-0.2,0.5-0.3,1.1-0.5,1.8c-0.2,0.6-0.5,1.3-0.7,1.9c-0.3,0.7-0.7,1.3-1,2.1c-0.4,0.7-0.9,1.4-1.4,2.1\n c-0.5,0.7-1.1,1.4-1.7,2c-1.2,1.3-2.7,2.5-4.4,3.6c-1.7,1-3.6,1.8-5.5,2.4c-2,0.5-4,0.7-6.2,0.7c-1.9-0.1-4.1-0.4-6-1.1\n c-1.9-0.7-3.7-1.5-5.2-2.6c-1.5-1.1-2.9-2.3-4-3.7c-0.6-0.6-1-1.4-1.5-2c-0.4-0.7-0.8-1.4-1.2-2c-0.3-0.7-0.6-1.3-0.8-2\n c-0.2-0.6-0.4-1.2-0.6-1.8c-0.1-0.6-0.3-1.1-0.4-1.6c-0.1-0.5-0.1-1-0.2-1.4c-0.1-0.9-0.1-1.5-0.1-2c0-0.5,0-0.7,0-0.7\n s0,0.2,0.1,0.7c0.1,0.5,0,1.1,0.2,2c0.1,0.4,0.2,0.9,0.3,1.4c0.1,0.5,0.3,1,0.5,1.6c0.2,0.6,0.4,1.1,0.7,1.8\n c0.3,0.6,0.6,1.2,0.9,1.9c0.4,0.6,0.8,1.3,1.2,1.9c0.5,0.6,1,1.3,1.6,1.8c1.1,1.2,2.5,2.3,4,3.2c1.5,0.9,3.2,1.6,5,2.1\n c1.8,0.5,3.6,0.6,5.6,0.6c1.8-0.1,3.7-0.4,5.4-1c1.7-0.6,3.3-1.4,4.7-2.4c1.4-1,2.6-2.1,3.6-3.3c0.5-0.6,0.9-1.2,1.3-1.8\n c0.4-0.6,0.7-1.2,1-1.8c0.3-0.6,0.6-1.2,0.8-1.8c0.2-0.6,0.4-1.1,0.5-1.7c0.1-0.5,0.2-1,0.3-1.5c0.1-0.4,0.1-0.8,0.1-1.2\n c0-0.2,0-0.4,0.1-0.5c0-0.2,0-0.4,0-0.5c0-0.3,0-0.6,0-0.8c0-0.5,0-0.7,0-0.7c0-1.1,0.9-2,2-2s2,0.9,2,2C62,40,62,40.1,62,40.1z",
|
|
208
|
+
children: /* @__PURE__ */ (0, p.jsx)("animateTransform", {
|
|
209
|
+
attributeType: "xml",
|
|
210
|
+
attributeName: "transform",
|
|
211
|
+
type: "rotate",
|
|
212
|
+
from: "0 40 40",
|
|
213
|
+
to: "-360 40 40",
|
|
214
|
+
dur: "0.6s",
|
|
215
|
+
repeatCount: "indefinite"
|
|
216
|
+
})
|
|
217
|
+
})]
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/shared/components/ImageEditor/provider/initialState.ts
|
|
222
|
+
var h = (e, t, n, r) => ({
|
|
223
|
+
history: {
|
|
224
|
+
pointer: 0,
|
|
225
|
+
items: [{
|
|
226
|
+
name: "Initial",
|
|
227
|
+
base64: r,
|
|
228
|
+
width: t,
|
|
229
|
+
height: n
|
|
230
|
+
}]
|
|
231
|
+
},
|
|
232
|
+
currentAction: null,
|
|
233
|
+
extension: e,
|
|
234
|
+
sidebar: !1
|
|
235
|
+
}), g = e(void 0), _ = ({ children: e, base64: t, width: n, height: r, ext: i }) => {
|
|
236
|
+
let [a, o] = c(h(i, n, r, t)), s = () => a.currentAction, l = (e) => o((t) => ({
|
|
237
|
+
...t,
|
|
238
|
+
currentAction: e
|
|
239
|
+
})), u = (e) => o((t) => {
|
|
240
|
+
let n = t.history.pointer + 1, r = [...t.history.items.slice(0, n), e];
|
|
241
|
+
return {
|
|
242
|
+
...t,
|
|
243
|
+
currentAction: null,
|
|
244
|
+
history: {
|
|
245
|
+
items: r,
|
|
246
|
+
pointer: n
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
}), d = () => a.history.items.at(a.history.pointer), f = () => o((e) => ({
|
|
250
|
+
...e,
|
|
251
|
+
history: h(i, n, r, t).history
|
|
252
|
+
})), m = () => o((e) => {
|
|
253
|
+
let t = e.history.items.at(e.history.pointer);
|
|
254
|
+
return {
|
|
255
|
+
...e,
|
|
256
|
+
history: {
|
|
257
|
+
items: [t],
|
|
258
|
+
pointer: 0
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
}), _ = () => o((e) => e.history.pointer <= 0 ? e : {
|
|
262
|
+
...e,
|
|
263
|
+
history: {
|
|
264
|
+
...e.history,
|
|
265
|
+
pointer: e.history.pointer - 1
|
|
266
|
+
}
|
|
267
|
+
}), v = () => o((e) => e.history.pointer >= e.history.items.length - 1 ? e : {
|
|
268
|
+
...e,
|
|
269
|
+
history: {
|
|
270
|
+
...e.history,
|
|
271
|
+
pointer: e.history.pointer + 1
|
|
272
|
+
}
|
|
273
|
+
}), y = () => a.sidebar, b = (e) => o((t) => ({
|
|
274
|
+
...t,
|
|
275
|
+
sidebar: e
|
|
276
|
+
}));
|
|
277
|
+
return /* @__PURE__ */ (0, p.jsx)(g, {
|
|
278
|
+
value: {
|
|
279
|
+
...a,
|
|
280
|
+
getCurrentAction: s,
|
|
281
|
+
setCurrentAction: l,
|
|
282
|
+
addToHistory: u,
|
|
283
|
+
resetHistory: f,
|
|
284
|
+
resetHistoryAfterSave: m,
|
|
285
|
+
undo: _,
|
|
286
|
+
redo: v,
|
|
287
|
+
getLastHistoryItem: d,
|
|
288
|
+
getSidebar: y,
|
|
289
|
+
setSidebar: b
|
|
290
|
+
},
|
|
291
|
+
children: e
|
|
292
|
+
});
|
|
293
|
+
}, v = {
|
|
294
|
+
"image/jpeg": "jpg",
|
|
295
|
+
"image/jpg": "jpg",
|
|
296
|
+
"image/png": "png",
|
|
297
|
+
"image/gif": "gif",
|
|
298
|
+
"image/webp": "webp"
|
|
299
|
+
}, y = (e) => {
|
|
300
|
+
let [t, n] = c({
|
|
301
|
+
loading: !0,
|
|
302
|
+
error: null,
|
|
303
|
+
width: 0,
|
|
304
|
+
height: 0,
|
|
305
|
+
extension: null,
|
|
306
|
+
base64: null
|
|
307
|
+
});
|
|
308
|
+
return i(() => {
|
|
309
|
+
let t = !0;
|
|
310
|
+
return (async () => {
|
|
311
|
+
try {
|
|
312
|
+
let r = await fetch(e);
|
|
313
|
+
if (!r.ok) throw Error(`HTTP error! Status: ${r.status}`);
|
|
314
|
+
let i = (r.headers.get("content-type") || "").split(";")[0].toLowerCase().trim(), a = i.startsWith("image/"), o = v[i] || "unknown";
|
|
315
|
+
if (!a) {
|
|
316
|
+
t && n((e) => ({
|
|
317
|
+
...e,
|
|
318
|
+
loading: !1,
|
|
319
|
+
error: "The requested resource is not a valid image.",
|
|
320
|
+
extension: o
|
|
321
|
+
}));
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
let s = await r.blob(), c = await new Promise((e, t) => {
|
|
325
|
+
let n = new FileReader();
|
|
326
|
+
n.onloadend = () => e(n.result), n.onerror = () => t(/* @__PURE__ */ Error("Failed to read image data stream")), n.readAsDataURL(s);
|
|
327
|
+
}), l = await new Promise((e, t) => {
|
|
328
|
+
let n = new Image();
|
|
329
|
+
n.src = c, n.onload = () => e({
|
|
330
|
+
width: n.naturalWidth,
|
|
331
|
+
height: n.naturalHeight
|
|
332
|
+
}), n.onerror = () => t(/* @__PURE__ */ Error("Failed to parse image dimensions"));
|
|
333
|
+
});
|
|
334
|
+
t && n({
|
|
335
|
+
loading: !1,
|
|
336
|
+
error: null,
|
|
337
|
+
width: l.width,
|
|
338
|
+
height: l.height,
|
|
339
|
+
extension: o,
|
|
340
|
+
base64: c
|
|
341
|
+
});
|
|
342
|
+
} catch (e) {
|
|
343
|
+
t && n((t) => ({
|
|
344
|
+
...t,
|
|
345
|
+
loading: !1,
|
|
346
|
+
error: e instanceof Error ? e.message : "An error occurred during extraction."
|
|
347
|
+
}));
|
|
348
|
+
}
|
|
349
|
+
})(), () => {
|
|
350
|
+
t = !1;
|
|
351
|
+
};
|
|
352
|
+
}, [e]), t;
|
|
353
|
+
}, b = () => {
|
|
354
|
+
let e = s(null), t = n((e) => {
|
|
355
|
+
let t = e.match(/^data:(image\/[a-zA-Z+.-]+);base64,(.+)$/);
|
|
356
|
+
if (!t) throw Error("Invalid Base64 image format");
|
|
357
|
+
let n = t[1], r = t[2];
|
|
358
|
+
return n === "image/gif" && (n = "image/png"), {
|
|
359
|
+
mimeType: n,
|
|
360
|
+
rawData: r
|
|
361
|
+
};
|
|
362
|
+
}, []), r = n(async (e) => {
|
|
363
|
+
let { mimeType: n, rawData: r } = t(e), i = atob(r), a = new Uint8Array(i.length);
|
|
364
|
+
for (let e = 0; e < i.length; e++) a[e] = i.charCodeAt(e);
|
|
365
|
+
let o = new Blob([a], { type: n });
|
|
366
|
+
return {
|
|
367
|
+
bitmap: await createImageBitmap(o),
|
|
368
|
+
mimeType: n
|
|
369
|
+
};
|
|
370
|
+
}, [t]), i = n((t) => {
|
|
371
|
+
e.current ||= document.createElement("canvas");
|
|
372
|
+
let n = e.current, r = t === "image/png" || t === "image/webp";
|
|
373
|
+
return {
|
|
374
|
+
canvas: n,
|
|
375
|
+
ctx: n.getContext("2d", { alpha: r })
|
|
376
|
+
};
|
|
377
|
+
}, []), a = n((e, t) => t === "image/jpeg" || t === "image/webp" ? e.toDataURL(t, .85) : e.toDataURL(t), []);
|
|
378
|
+
return {
|
|
379
|
+
resize: n(async (e, t, n) => {
|
|
380
|
+
let { bitmap: o, mimeType: s } = await r(e), { canvas: c, ctx: l } = i(s);
|
|
381
|
+
return c.width = t, c.height = n, l && (l.clearRect(0, 0, t, n), l.drawImage(o, 0, 0, t, n)), o.close(), a(c, s);
|
|
382
|
+
}, [
|
|
383
|
+
r,
|
|
384
|
+
i,
|
|
385
|
+
a
|
|
386
|
+
]),
|
|
387
|
+
crop: n(async (e, t, n, o, s) => {
|
|
388
|
+
let { bitmap: c, mimeType: l } = await r(e), { canvas: u, ctx: d } = i(l);
|
|
389
|
+
return u.width = o, u.height = s, d && (d.clearRect(0, 0, o, s), d.drawImage(c, t, n, o, s, 0, 0, o, s)), c.close(), a(u, l);
|
|
390
|
+
}, [
|
|
391
|
+
r,
|
|
392
|
+
i,
|
|
393
|
+
a
|
|
394
|
+
]),
|
|
395
|
+
flip: n(async (e, t, n) => {
|
|
396
|
+
let { bitmap: o, mimeType: s } = await r(e), { canvas: c, ctx: l } = i(s);
|
|
397
|
+
return c.width = o.width, c.height = o.height, l && (l.clearRect(0, 0, c.width, c.height), l.save(), l.translate(t ? o.width : 0, n ? o.height : 0), l.scale(t ? -1 : 1, n ? -1 : 1), l.drawImage(o, 0, 0), l.restore()), o.close(), a(c, s);
|
|
398
|
+
}, [
|
|
399
|
+
r,
|
|
400
|
+
i,
|
|
401
|
+
a
|
|
402
|
+
]),
|
|
403
|
+
rotate: n(async (e, t) => {
|
|
404
|
+
let { bitmap: n, mimeType: o } = await r(e), { canvas: s, ctx: c } = i(o);
|
|
405
|
+
return s.width = n.width, s.height = n.height, c && (c.clearRect(0, 0, s.width, s.height), c.save(), c.translate(n.width / 2, n.height / 2), c.rotate(t * Math.PI / 180), c.drawImage(n, -n.width / 2, -n.height / 2), c.restore()), n.close(), a(s, o);
|
|
406
|
+
}, [
|
|
407
|
+
r,
|
|
408
|
+
i,
|
|
409
|
+
a
|
|
410
|
+
]),
|
|
411
|
+
filter: n(async (e, t) => {
|
|
412
|
+
let { bitmap: n, mimeType: o } = await r(e), { canvas: s, ctx: c } = i(o);
|
|
413
|
+
return s.width = n.width, s.height = n.height, c && (c.filter = Object.entries(t).map(([e, t]) => `${e}(${t}%)`).join(" "), c.drawImage(n, 0, 0)), n.close(), a(s, o);
|
|
414
|
+
}, [
|
|
415
|
+
r,
|
|
416
|
+
i,
|
|
417
|
+
a
|
|
418
|
+
])
|
|
419
|
+
};
|
|
420
|
+
}, x = () => {
|
|
421
|
+
if (typeof window > "u" || !window.navigator) return null;
|
|
422
|
+
let e = window.navigator.userAgent.toLowerCase();
|
|
423
|
+
return /android/.test(e) ? "android" : /iphone|ipad|ipod/.test(e) ? "ios" : /windows phone/.test(e) ? "windows-phone" : /blackberry|bb10/.test(e) ? "blackberry" : /opera mini/.test(e) ? "opera-mini" : /mobile/.test(e) ? "mobile" : null;
|
|
424
|
+
}, S = () => {
|
|
425
|
+
let [e] = c(() => x());
|
|
426
|
+
return e;
|
|
427
|
+
}, C = {
|
|
428
|
+
sm: 640,
|
|
429
|
+
md: 768,
|
|
430
|
+
lg: 1024,
|
|
431
|
+
xl: 1280
|
|
432
|
+
};
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/shared/components/ImageEditor/hooks/useBellow.tsx
|
|
435
|
+
function w(e) {
|
|
436
|
+
let [t, n] = c(() => window.innerWidth < C[e]);
|
|
437
|
+
return i(() => {
|
|
438
|
+
function t() {
|
|
439
|
+
n(window.innerWidth < C[e]);
|
|
440
|
+
}
|
|
441
|
+
return window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
|
|
442
|
+
}, [e]), t;
|
|
443
|
+
}
|
|
444
|
+
//#endregion
|
|
445
|
+
//#region src/shared/components/ImageEditor/assets/icons.tsx
|
|
446
|
+
var T = {
|
|
447
|
+
xmlns: "http://w3.org",
|
|
448
|
+
width: "24",
|
|
449
|
+
height: "24",
|
|
450
|
+
viewBox: "0 0 24 24",
|
|
451
|
+
fill: "none",
|
|
452
|
+
stroke: "currentColor",
|
|
453
|
+
strokeWidth: "2",
|
|
454
|
+
strokeLinecap: "round",
|
|
455
|
+
strokeLinejoin: "round"
|
|
456
|
+
}, E = (e) => /* @__PURE__ */ (0, p.jsx)("svg", {
|
|
457
|
+
...T,
|
|
458
|
+
...e,
|
|
459
|
+
children: /* @__PURE__ */ (0, p.jsx)("path", { d: "M20 6 9 17l-5-5" })
|
|
460
|
+
}), D = (e) => /* @__PURE__ */ (0, p.jsxs)("svg", {
|
|
461
|
+
...T,
|
|
462
|
+
...e,
|
|
463
|
+
children: [/* @__PURE__ */ (0, p.jsx)("path", { d: "M18 6 6 18" }), /* @__PURE__ */ (0, p.jsx)("path", { d: "m6 6 12 12" })]
|
|
464
|
+
}), ee = (e) => /* @__PURE__ */ (0, p.jsxs)("svg", {
|
|
465
|
+
...T,
|
|
466
|
+
...e,
|
|
467
|
+
children: [/* @__PURE__ */ (0, p.jsx)("rect", {
|
|
468
|
+
width: "18",
|
|
469
|
+
height: "11",
|
|
470
|
+
x: "3",
|
|
471
|
+
y: "11",
|
|
472
|
+
rx: "2",
|
|
473
|
+
ry: "2"
|
|
474
|
+
}), /* @__PURE__ */ (0, p.jsx)("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })]
|
|
475
|
+
}), O = (e) => /* @__PURE__ */ (0, p.jsxs)("svg", {
|
|
476
|
+
...T,
|
|
477
|
+
...e,
|
|
478
|
+
children: [/* @__PURE__ */ (0, p.jsx)("path", { d: "m12 19-7-7 7-7" }), /* @__PURE__ */ (0, p.jsx)("path", { d: "M19 12H5" })]
|
|
479
|
+
}), k = (e) => /* @__PURE__ */ (0, p.jsx)("svg", {
|
|
480
|
+
...T,
|
|
481
|
+
...e,
|
|
482
|
+
children: /* @__PURE__ */ (0, p.jsx)("path", { d: "m6 9 6 6 6-6" })
|
|
483
|
+
}), A = (e) => /* @__PURE__ */ (0, p.jsxs)("svg", {
|
|
484
|
+
...T,
|
|
485
|
+
...e,
|
|
486
|
+
children: [/* @__PURE__ */ (0, p.jsx)("path", { d: "M3 7v6h6" }), /* @__PURE__ */ (0, p.jsx)("path", { d: "M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13" })]
|
|
487
|
+
}), j = (e) => /* @__PURE__ */ (0, p.jsxs)("svg", {
|
|
488
|
+
...T,
|
|
489
|
+
...e,
|
|
490
|
+
children: [/* @__PURE__ */ (0, p.jsx)("path", { d: "M21 7v6h-6" }), /* @__PURE__ */ (0, p.jsx)("path", { d: "M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7" })]
|
|
491
|
+
}), M = (e) => /* @__PURE__ */ (0, p.jsxs)("svg", {
|
|
492
|
+
...T,
|
|
493
|
+
...e,
|
|
494
|
+
children: [/* @__PURE__ */ (0, p.jsx)("path", { d: "M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915" }), /* @__PURE__ */ (0, p.jsx)("circle", {
|
|
495
|
+
cx: "12",
|
|
496
|
+
cy: "12",
|
|
497
|
+
r: "3"
|
|
498
|
+
})]
|
|
499
|
+
}), N = (e) => /* @__PURE__ */ (0, p.jsxs)("svg", {
|
|
500
|
+
...T,
|
|
501
|
+
...e,
|
|
502
|
+
children: [/* @__PURE__ */ (0, p.jsx)("path", { d: "M6 2v14a2 2 0 0 0 2 2h14" }), /* @__PURE__ */ (0, p.jsx)("path", { d: "M18 22V8a2 2 0 0 0-2-2H2" })]
|
|
503
|
+
}), P = (e) => /* @__PURE__ */ (0, p.jsxs)("svg", {
|
|
504
|
+
...T,
|
|
505
|
+
...e,
|
|
506
|
+
children: [
|
|
507
|
+
/* @__PURE__ */ (0, p.jsx)("rect", {
|
|
508
|
+
width: "18",
|
|
509
|
+
height: "18",
|
|
510
|
+
x: "3",
|
|
511
|
+
y: "3",
|
|
512
|
+
rx: "2",
|
|
513
|
+
ry: "2"
|
|
514
|
+
}),
|
|
515
|
+
/* @__PURE__ */ (0, p.jsx)("circle", {
|
|
516
|
+
cx: "9",
|
|
517
|
+
cy: "9",
|
|
518
|
+
r: "2"
|
|
519
|
+
}),
|
|
520
|
+
/* @__PURE__ */ (0, p.jsx)("path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" })
|
|
521
|
+
]
|
|
522
|
+
}), F = (e) => /* @__PURE__ */ (0, p.jsx)("svg", {
|
|
523
|
+
...T,
|
|
524
|
+
...e,
|
|
525
|
+
children: /* @__PURE__ */ (0, p.jsx)("rect", {
|
|
526
|
+
width: "18",
|
|
527
|
+
height: "18",
|
|
528
|
+
x: "3",
|
|
529
|
+
y: "3",
|
|
530
|
+
rx: "2"
|
|
531
|
+
})
|
|
532
|
+
}), I = (e) => /* @__PURE__ */ (0, p.jsxs)("svg", {
|
|
533
|
+
...T,
|
|
534
|
+
...e,
|
|
535
|
+
children: [
|
|
536
|
+
/* @__PURE__ */ (0, p.jsx)("path", { d: "M3 7V5a2 2 0 0 1 2-2h2" }),
|
|
537
|
+
/* @__PURE__ */ (0, p.jsx)("path", { d: "M17 3h2a2 2 0 0 1 2 2v2" }),
|
|
538
|
+
/* @__PURE__ */ (0, p.jsx)("path", { d: "M21 17v2a2 2 0 0 1-2 2h-2" }),
|
|
539
|
+
/* @__PURE__ */ (0, p.jsx)("path", { d: "M7 21H5a2 2 0 0 1-2-2v-2" }),
|
|
540
|
+
/* @__PURE__ */ (0, p.jsx)("rect", {
|
|
541
|
+
width: "10",
|
|
542
|
+
height: "8",
|
|
543
|
+
x: "7",
|
|
544
|
+
y: "8",
|
|
545
|
+
rx: "1"
|
|
546
|
+
})
|
|
547
|
+
]
|
|
548
|
+
}), L = (e) => /* @__PURE__ */ (0, p.jsx)("svg", {
|
|
549
|
+
...T,
|
|
550
|
+
...e,
|
|
551
|
+
children: /* @__PURE__ */ (0, p.jsx)("path", {
|
|
552
|
+
d: "M21 12a9 9 0 1 1-6.219-8.56",
|
|
553
|
+
children: /* @__PURE__ */ (0, p.jsx)("animateTransform", {
|
|
554
|
+
attributeType: "xml",
|
|
555
|
+
attributeName: "transform",
|
|
556
|
+
type: "rotate",
|
|
557
|
+
from: "0 12 12",
|
|
558
|
+
to: "360 12 12",
|
|
559
|
+
dur: "0.8s",
|
|
560
|
+
repeatCount: "indefinite"
|
|
561
|
+
})
|
|
562
|
+
})
|
|
563
|
+
}), R = () => {
|
|
564
|
+
let e = r(g);
|
|
565
|
+
if (!e) throw Error("useImageEditorContext must be used within an ImageEditorProvider");
|
|
566
|
+
return e;
|
|
567
|
+
}, z = t(({ className: e = "", variant: t = "default", children: n, ...r }, i) => /* @__PURE__ */ (0, p.jsx)("button", {
|
|
568
|
+
ref: i,
|
|
569
|
+
className: `btn ${`btn-${t}`} ${e}`.trim(),
|
|
570
|
+
...r,
|
|
571
|
+
children: n
|
|
572
|
+
})), B = t(({ className: e = "", active: t = !1, icon: n, label: r, ...i }, a) => /* @__PURE__ */ (0, p.jsxs)("button", {
|
|
573
|
+
ref: a,
|
|
574
|
+
type: "button",
|
|
575
|
+
"aria-pressed": t,
|
|
576
|
+
className: `btn-crop ${e}`.trim(),
|
|
577
|
+
...i,
|
|
578
|
+
children: [n, /* @__PURE__ */ (0, p.jsx)("span", {
|
|
579
|
+
className: "semibold",
|
|
580
|
+
children: r
|
|
581
|
+
})]
|
|
582
|
+
}));
|
|
583
|
+
B.displayName = "ButtonCrop";
|
|
584
|
+
//#endregion
|
|
585
|
+
//#region src/shared/components/ImageEditor/ui/separator/Separator.tsx
|
|
586
|
+
var V = t(({ className: e = "", orientation: t = "horizontal", ...n }, r) => /* @__PURE__ */ (0, p.jsx)("hr", {
|
|
587
|
+
ref: r,
|
|
588
|
+
role: "separator",
|
|
589
|
+
"aria-orientation": t,
|
|
590
|
+
"data-orientation": t,
|
|
591
|
+
className: `separator ${e}`.trim(),
|
|
592
|
+
...n
|
|
593
|
+
}));
|
|
594
|
+
V.displayName = "Separator";
|
|
595
|
+
//#endregion
|
|
596
|
+
//#region src/shared/components/ImageEditor/ui/select/Select.tsx
|
|
597
|
+
var te = ({ items: e, value: t, onChange: n, placeholder: r = "Select an option", className: l = "", renderOption: u }) => {
|
|
598
|
+
let [d, f] = c(!1), m = s(null), h = s(null), g = s(null), _ = o(() => {
|
|
599
|
+
let t = (e) => e.reduce((e, n) => n.options ? [...e, ...t(n.options.map((e) => ({
|
|
600
|
+
...e,
|
|
601
|
+
fullName: `${n.label} ${e.label}`
|
|
602
|
+
})))] : [...e, n], []);
|
|
603
|
+
return t(e);
|
|
604
|
+
}, [e]).find((e) => e.value === t);
|
|
605
|
+
i(() => {
|
|
606
|
+
let e = (e) => {
|
|
607
|
+
m.current && !m.current.contains(e.target) && f(!1);
|
|
608
|
+
};
|
|
609
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
610
|
+
}, []), a(() => {
|
|
611
|
+
if (!d || !h.current || !g.current) return;
|
|
612
|
+
let e = m.current?.closest(".picedi.main")?.getBoundingClientRect(), t = h.current.getBoundingClientRect(), n = g.current.getBoundingClientRect(), r = (e?.bottom ?? window.innerHeight) - 16, i = t.bottom + n.height + 4, a = "calc(100% + 4px)";
|
|
613
|
+
i > r && (a = `calc(100% + 4px - ${i - r}px)`), g.current.style.top = a;
|
|
614
|
+
}, [d, e]);
|
|
615
|
+
let v = (e) => {
|
|
616
|
+
n(e), f(!1);
|
|
617
|
+
};
|
|
618
|
+
return /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
619
|
+
ref: m,
|
|
620
|
+
className: `select-wrapper ${l}`.trim(),
|
|
621
|
+
"data-state": d ? "open" : "closed",
|
|
622
|
+
children: [/* @__PURE__ */ (0, p.jsxs)("button", {
|
|
623
|
+
ref: h,
|
|
624
|
+
type: "button",
|
|
625
|
+
className: "select-trigger",
|
|
626
|
+
onClick: () => f(!d),
|
|
627
|
+
children: [/* @__PURE__ */ (0, p.jsx)("span", { children: _ ? _.fullName : r }), /* @__PURE__ */ (0, p.jsx)(k, { className: "select-trigger-arrow" })]
|
|
628
|
+
}), /* @__PURE__ */ (0, p.jsx)("div", {
|
|
629
|
+
ref: g,
|
|
630
|
+
className: "select-content",
|
|
631
|
+
children: e.map((e, n) => e.options ? /* @__PURE__ */ (0, p.jsxs)("div", { children: [/* @__PURE__ */ (0, p.jsx)("div", {
|
|
632
|
+
className: "select-group-label semibold",
|
|
633
|
+
children: e.label
|
|
634
|
+
}), e.options.map((e) => /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
635
|
+
className: "select-item",
|
|
636
|
+
onClick: () => v(e.value),
|
|
637
|
+
children: [u ? u(e) : /* @__PURE__ */ (0, p.jsx)("span", {
|
|
638
|
+
className: "select-item-left",
|
|
639
|
+
children: e.label
|
|
640
|
+
}), /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
641
|
+
className: "select-item-addon",
|
|
642
|
+
children: [
|
|
643
|
+
e.rightLabel && /* @__PURE__ */ (0, p.jsx)("span", { children: e.rightLabel }),
|
|
644
|
+
t === e.value && /* @__PURE__ */ (0, p.jsx)(E, { className: "select-item-check" }),
|
|
645
|
+
t !== e.value && /* @__PURE__ */ (0, p.jsx)("b", {})
|
|
646
|
+
]
|
|
647
|
+
})]
|
|
648
|
+
}, e.value))] }, `group-${n}`) : /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
649
|
+
className: "select-item",
|
|
650
|
+
onClick: () => v(e.value),
|
|
651
|
+
children: [u ? u(e) : /* @__PURE__ */ (0, p.jsxs)("span", {
|
|
652
|
+
className: "select-item-left",
|
|
653
|
+
children: [e.label, "1"]
|
|
654
|
+
}), t === e.value && /* @__PURE__ */ (0, p.jsx)(E, { className: "select-item-check" })]
|
|
655
|
+
}, e.value))
|
|
656
|
+
})]
|
|
657
|
+
});
|
|
658
|
+
}, ne = t(({ className: e = "", type: t = "text", hideArrows: n = !0, ...r }, i) => /* @__PURE__ */ (0, p.jsx)("input", {
|
|
659
|
+
ref: i,
|
|
660
|
+
type: t,
|
|
661
|
+
className: `input ${t === "number" && n ? "input-number-clean" : ""} ${e}`.trim(),
|
|
662
|
+
...r
|
|
663
|
+
}));
|
|
664
|
+
ne.displayName = "Input";
|
|
665
|
+
//#endregion
|
|
666
|
+
//#region src/shared/components/ImageEditor/ui/input-pixel/InputPixel.tsx
|
|
667
|
+
var H = t(({ label: e, className: t = "", style: n, ...r }, i) => /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
668
|
+
className: `input-pixel-container ${t}`.trim(),
|
|
669
|
+
style: n,
|
|
670
|
+
children: [
|
|
671
|
+
/* @__PURE__ */ (0, p.jsx)("span", {
|
|
672
|
+
className: "input-pixel-legend",
|
|
673
|
+
children: e
|
|
674
|
+
}),
|
|
675
|
+
/* @__PURE__ */ (0, p.jsx)(ne, {
|
|
676
|
+
ref: i,
|
|
677
|
+
type: "number",
|
|
678
|
+
...r
|
|
679
|
+
}),
|
|
680
|
+
/* @__PURE__ */ (0, p.jsx)("span", {
|
|
681
|
+
className: "input-pixel-suffix",
|
|
682
|
+
children: "px"
|
|
683
|
+
})
|
|
684
|
+
]
|
|
685
|
+
})), re = ({ onBack: e, onSave: t }) => {
|
|
686
|
+
let [n, r] = c(!1), { history: i, undo: a, redo: o, resetHistory: s, resetHistoryAfterSave: l, getLastHistoryItem: u } = R(), { base64: d } = u(), f = i.items.length > 1 && !n, m = i.pointer === 0, h = i.pointer === i.items.length - 1, g = i.items.length < 2 || n;
|
|
687
|
+
return /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
688
|
+
className: "header",
|
|
689
|
+
children: [/* @__PURE__ */ (0, p.jsx)(z, {
|
|
690
|
+
variant: "ghost",
|
|
691
|
+
className: "btn-rect",
|
|
692
|
+
onClick: e,
|
|
693
|
+
children: /* @__PURE__ */ (0, p.jsx)(O, {})
|
|
694
|
+
}), /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
695
|
+
className: "header-tools",
|
|
696
|
+
children: [
|
|
697
|
+
f && /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
698
|
+
className: "header-history",
|
|
699
|
+
children: [
|
|
700
|
+
/* @__PURE__ */ (0, p.jsx)(z, {
|
|
701
|
+
variant: "outline",
|
|
702
|
+
disabled: m,
|
|
703
|
+
className: "btn-rect",
|
|
704
|
+
onClick: a,
|
|
705
|
+
children: /* @__PURE__ */ (0, p.jsx)(A, {})
|
|
706
|
+
}),
|
|
707
|
+
/* @__PURE__ */ (0, p.jsxs)("div", {
|
|
708
|
+
className: "header-history-text",
|
|
709
|
+
children: [
|
|
710
|
+
i.pointer + 1,
|
|
711
|
+
"/",
|
|
712
|
+
i.items.length
|
|
713
|
+
]
|
|
714
|
+
}),
|
|
715
|
+
/* @__PURE__ */ (0, p.jsx)(z, {
|
|
716
|
+
variant: "outline",
|
|
717
|
+
disabled: h,
|
|
718
|
+
className: "btn-rect",
|
|
719
|
+
onClick: o,
|
|
720
|
+
children: /* @__PURE__ */ (0, p.jsx)(j, {})
|
|
721
|
+
})
|
|
722
|
+
]
|
|
723
|
+
}),
|
|
724
|
+
/* @__PURE__ */ (0, p.jsx)(z, {
|
|
725
|
+
variant: "outline",
|
|
726
|
+
disabled: n,
|
|
727
|
+
onClick: s,
|
|
728
|
+
children: "Reset"
|
|
729
|
+
}),
|
|
730
|
+
/* @__PURE__ */ (0, p.jsxs)(z, {
|
|
731
|
+
disabled: g,
|
|
732
|
+
onClick: async () => {
|
|
733
|
+
if (d) {
|
|
734
|
+
r(!0);
|
|
735
|
+
try {
|
|
736
|
+
await t(d), l();
|
|
737
|
+
} finally {
|
|
738
|
+
r(!1);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
},
|
|
742
|
+
children: [n ? /* @__PURE__ */ (0, p.jsx)(L, {}) : /* @__PURE__ */ (0, p.jsx)(E, {}), "Save"]
|
|
743
|
+
})
|
|
744
|
+
]
|
|
745
|
+
})]
|
|
746
|
+
});
|
|
747
|
+
}, U = 32, W = (e) => ({
|
|
748
|
+
x: e.offsetLeft,
|
|
749
|
+
y: e.offsetTop,
|
|
750
|
+
w: e.offsetWidth,
|
|
751
|
+
h: e.offsetHeight
|
|
752
|
+
}), ie = (e, t, n, r, i, a, o, s) => {
|
|
753
|
+
let { x: c } = o, { y: l, w: u, h: d } = o;
|
|
754
|
+
if (e) u += r - n, u + c > i && (u = i - c), u < U && (u = U);
|
|
755
|
+
else {
|
|
756
|
+
let e = r - n, o = Math.round(e / t);
|
|
757
|
+
if (u += e, d += o, l -= o / 2, l < 0 || d + l > a || u + c > i || u < U || d < U) return W(s);
|
|
758
|
+
}
|
|
759
|
+
return {
|
|
760
|
+
x: c,
|
|
761
|
+
y: l,
|
|
762
|
+
w: u,
|
|
763
|
+
h: d
|
|
764
|
+
};
|
|
765
|
+
}, ae = (e, t, n, r, i, a, o, s) => {
|
|
766
|
+
let { x: c, y: l, w: u, h: d } = o;
|
|
767
|
+
if (e) {
|
|
768
|
+
let e = i - o.w - o.x;
|
|
769
|
+
c += r - n, c < 0 && (c = 0), u = i - c - e, u < U && (u = U, c = i - e - U);
|
|
770
|
+
} else {
|
|
771
|
+
let e = r - n, i = Math.round(e / t);
|
|
772
|
+
if (u -= e, d -= i, c += e, l += i / 2, l < 0 || c < 0 || d + l > a || u < U || d < U) return W(s);
|
|
773
|
+
}
|
|
774
|
+
return {
|
|
775
|
+
x: c,
|
|
776
|
+
y: l,
|
|
777
|
+
w: u,
|
|
778
|
+
h: d
|
|
779
|
+
};
|
|
780
|
+
}, oe = (e, t, n, r, i, a, o, s) => {
|
|
781
|
+
let { x: c, y: l, w: u, h: d } = o, f = a - d - l;
|
|
782
|
+
if (e) l += r - n, l < 0 && (l = 0), d = a - l - f, d < U && (d = U, l = a - f - U);
|
|
783
|
+
else {
|
|
784
|
+
let e = r - n, a = Math.round(e * t);
|
|
785
|
+
if (d -= e, u -= a, c += a / 2, l += e, l < 0 || c < 0 || u + c > i || u < U || d < U) return W(s);
|
|
786
|
+
}
|
|
787
|
+
return {
|
|
788
|
+
x: c,
|
|
789
|
+
y: l,
|
|
790
|
+
w: u,
|
|
791
|
+
h: d
|
|
792
|
+
};
|
|
793
|
+
}, se = (e, t, n, r, i, a, o, s) => {
|
|
794
|
+
let { y: c } = o, { x: l, w: u, h: d } = o;
|
|
795
|
+
if (e) d += r - n, d + c > a && (d = a - c), d < U && (d = U);
|
|
796
|
+
else {
|
|
797
|
+
let e = r - n, o = Math.round(e * t);
|
|
798
|
+
if (d += e, u += o, l -= o / 2, d + c > a || l < 0 || u + l > i || u < U || d < U) return W(s);
|
|
799
|
+
}
|
|
800
|
+
return {
|
|
801
|
+
x: l,
|
|
802
|
+
y: c,
|
|
803
|
+
w: u,
|
|
804
|
+
h: d
|
|
805
|
+
};
|
|
806
|
+
}, ce = (e, t, n, r, i, a, o, s, c, l) => {
|
|
807
|
+
let { x: u, y: d, w: f, h: p } = c;
|
|
808
|
+
if (e) {
|
|
809
|
+
let e = o - c.w - c.x;
|
|
810
|
+
u += i - n, u < 0 && (u = 0), f = o - u - e, f < U && (f = U, u = o - e - U);
|
|
811
|
+
let t = s - p - d;
|
|
812
|
+
d += a - r, d < 0 && (d = 0), p = s - d - t, p < U && (p = U, d = s - t - U);
|
|
813
|
+
} else {
|
|
814
|
+
if (t >= 1) {
|
|
815
|
+
let e = i - n, r = Math.round(e / t);
|
|
816
|
+
f -= e, p -= r, u += e, d += r;
|
|
817
|
+
} else {
|
|
818
|
+
let e = a - r, n = Math.round(e * t);
|
|
819
|
+
f -= n, p -= e, u += n, d += e;
|
|
820
|
+
}
|
|
821
|
+
if (u < 0 || d < 0 || f < U || p < U) return W(l);
|
|
822
|
+
}
|
|
823
|
+
return {
|
|
824
|
+
x: u,
|
|
825
|
+
y: d,
|
|
826
|
+
w: f,
|
|
827
|
+
h: p
|
|
828
|
+
};
|
|
829
|
+
}, le = (e, t, n, r, i, a, o, s, c, l) => {
|
|
830
|
+
let { x: u } = c, { y: d, w: f, h: p } = c;
|
|
831
|
+
if (e) {
|
|
832
|
+
f += i - n, f + u > o && (f = o - u), f < U && (f = U);
|
|
833
|
+
let e = s - p - d;
|
|
834
|
+
d += a - r, d < 0 && (d = 0), p = s - d - e, p < U && (p = U, d = s - e - U);
|
|
835
|
+
} else {
|
|
836
|
+
if (t > 1) {
|
|
837
|
+
let e = i - n, r = Math.round(e / t);
|
|
838
|
+
f += e, p += r, d -= r;
|
|
839
|
+
} else {
|
|
840
|
+
let e = a - r, n = Math.round(e * t);
|
|
841
|
+
f -= n, p -= e, d += e;
|
|
842
|
+
}
|
|
843
|
+
if (f + u > o || d < 0 || f < U || p < U) return W(l);
|
|
844
|
+
}
|
|
845
|
+
return {
|
|
846
|
+
x: u,
|
|
847
|
+
y: d,
|
|
848
|
+
w: f,
|
|
849
|
+
h: p
|
|
850
|
+
};
|
|
851
|
+
}, ue = (e, t, n, r, i, a, o, s, c, l) => {
|
|
852
|
+
let { y: u } = c, { x: d, w: f, h: p } = c;
|
|
853
|
+
if (e) {
|
|
854
|
+
p += a - r, p + u > s && (p = s - u), p < U && (p = U);
|
|
855
|
+
let e = o - c.w - c.x;
|
|
856
|
+
d += i - n, d < 0 && (d = 0), f = o - d - e, f < U && (f = U, d = o - e - U);
|
|
857
|
+
} else {
|
|
858
|
+
if (t >= 1) {
|
|
859
|
+
let e = i - n, r = Math.round(e / t);
|
|
860
|
+
f -= e, p -= r, d += e;
|
|
861
|
+
} else {
|
|
862
|
+
let e = a - r, n = Math.round(e * t);
|
|
863
|
+
f += n, p += e, d -= n;
|
|
864
|
+
}
|
|
865
|
+
if (p + u > s || d < 0 || f < U || p < U) return W(l);
|
|
866
|
+
}
|
|
867
|
+
return {
|
|
868
|
+
x: d,
|
|
869
|
+
y: u,
|
|
870
|
+
w: f,
|
|
871
|
+
h: p
|
|
872
|
+
};
|
|
873
|
+
}, de = (e, t, n, r, i, a, o, s, c, l) => {
|
|
874
|
+
let { x: u, y: d } = c, { w: f, h: p } = c;
|
|
875
|
+
if (e) f += i - n, f + u > o && (f = o - u), f < U && (f = U), p += a - r, p + d > s && (p = s - d), p < U && (p = U);
|
|
876
|
+
else {
|
|
877
|
+
if (t >= 1) {
|
|
878
|
+
let e = i - n, r = Math.round(e / t);
|
|
879
|
+
f += e, p += r;
|
|
880
|
+
} else {
|
|
881
|
+
let e = a - r, n = Math.round(e * t);
|
|
882
|
+
f += n, p += e;
|
|
883
|
+
}
|
|
884
|
+
if (p + d > s || f + u > o || f < U || p < U) return W(l);
|
|
885
|
+
}
|
|
886
|
+
return {
|
|
887
|
+
x: u,
|
|
888
|
+
y: d,
|
|
889
|
+
w: f,
|
|
890
|
+
h: p
|
|
891
|
+
};
|
|
892
|
+
}, fe = (e, t, n, r, i, a, o, s, c, l, u) => e === "r" ? ie(t, n, r, a, s, c, l, u) : e === "l" ? ae(t, n, r, a, s, c, l, u) : e === "t" ? oe(t, n, i, o, s, c, l, u) : e === "b" ? se(t, n, i, o, s, c, l, u) : e === "tl" ? ce(t, n, r, i, a, o, s, c, l, u) : e === "tr" ? le(t, n, r, i, a, o, s, c, l, u) : e === "bl" ? ue(t, n, r, i, a, o, s, c, l, u) : e === "br" ? de(t, n, r, i, a, o, s, c, l, u) : {
|
|
893
|
+
x: 0,
|
|
894
|
+
y: 0,
|
|
895
|
+
w: 0,
|
|
896
|
+
h: 0
|
|
897
|
+
}, G = (e, t, n) => {
|
|
898
|
+
let r = .1, i = t / n, a = 0, o = 0;
|
|
899
|
+
e === 1 && (a = (i > 1 ? n : t) * (1 - r * 2), o = a), e > 1 && (i > e ? (o = n * (1 - r * 2), a = o * e) : (a = t * (1 - r * 2), o = a / e)), e < 1 && (i > e ? (o = n * (1 - r * 2), a = o * e) : (a = t * (1 - r * 2), o = a / e));
|
|
900
|
+
let s = a / t * 100, c = o / n * 100;
|
|
901
|
+
return {
|
|
902
|
+
x: (t - a) / 2 / t * 100,
|
|
903
|
+
y: (n - o) / 2 / n * 100,
|
|
904
|
+
w: s,
|
|
905
|
+
h: c,
|
|
906
|
+
xPx: Math.round((t - a) / 2),
|
|
907
|
+
yPx: Math.round((n - o) / 2),
|
|
908
|
+
wPx: a,
|
|
909
|
+
hPx: o
|
|
910
|
+
};
|
|
911
|
+
}, pe = () => {
|
|
912
|
+
let { getCurrentAction: e, getLastHistoryItem: t } = R(), n = e(), r = S(), i = s(null), a = s(null), { handleCropStart: o } = be({
|
|
913
|
+
imgRef: i,
|
|
914
|
+
cropRef: a
|
|
915
|
+
});
|
|
916
|
+
if (!n || n.name !== "crop") return null;
|
|
917
|
+
let { width: c, height: l, base64: u } = t(), { x: d, y: f, w: m, h } = G(n.args.ratio, c, l);
|
|
918
|
+
return /* @__PURE__ */ (0, p.jsxs)(p.Fragment, { children: [/* @__PURE__ */ (0, p.jsx)("img", {
|
|
919
|
+
ref: i,
|
|
920
|
+
src: u,
|
|
921
|
+
alt: "Image",
|
|
922
|
+
className: "crop-image",
|
|
923
|
+
style: { clipPath: `xywh(${d}% ${f}% ${m}% ${h}%)` }
|
|
924
|
+
}), /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
925
|
+
ref: a,
|
|
926
|
+
className: "crop-box",
|
|
927
|
+
style: {
|
|
928
|
+
width: `${m}%`,
|
|
929
|
+
height: `${h}%`,
|
|
930
|
+
top: `${f}%`,
|
|
931
|
+
left: `${d}%`
|
|
932
|
+
},
|
|
933
|
+
children: [/* @__PURE__ */ (0, p.jsx)(ge, {}), r ? /* @__PURE__ */ (0, p.jsx)(xe, { onMouseDown: o }) : /* @__PURE__ */ (0, p.jsxs)(p.Fragment, { children: [/* @__PURE__ */ (0, p.jsx)(he, { onMouseDown: o }), /* @__PURE__ */ (0, p.jsx)(_e, { onMouseDown: o })] })]
|
|
934
|
+
})] });
|
|
935
|
+
}, K = new EventTarget(), q = (e) => {
|
|
936
|
+
let t = new CustomEvent("crop-update", { detail: e });
|
|
937
|
+
K.dispatchEvent(t);
|
|
938
|
+
}, me = () => {
|
|
939
|
+
let { setCurrentAction: e, getCurrentAction: t, getLastHistoryItem: n, addToHistory: r, setSidebar: a } = R(), { crop: o, resize: l } = b(), [u, d] = c(!1), f = t(), { base64: m, width: h, height: g } = n(), _ = s(null), v = s(null), y = s(null), x = s(null), S = s(null);
|
|
940
|
+
return i(() => {
|
|
941
|
+
if (f?.name !== "crop") return;
|
|
942
|
+
let { x: e, y: t, w: n, h: r } = G(f.args.ratio, h, g), i = Math.round(e / 100 * h), a = Math.round(t / 100 * g), o = Math.round(n / 100 * h), s = Math.round(r / 100 * g);
|
|
943
|
+
_.current && (_.current.textContent = i.toString()), v.current && (v.current.textContent = a.toString()), y.current && (y.current.textContent = o.toString()), x.current && (x.current.textContent = s.toString()), S.current = {
|
|
944
|
+
x: i,
|
|
945
|
+
y: a,
|
|
946
|
+
w: o,
|
|
947
|
+
h: s
|
|
948
|
+
};
|
|
949
|
+
let c = (e) => {
|
|
950
|
+
let t = e, { x: n, y: r, w: i, h: a } = t.detail;
|
|
951
|
+
S.current = t.detail, _.current && (_.current.textContent = n.toString()), v.current && (v.current.textContent = r.toString()), y.current && (y.current.textContent = i.toString()), x.current && (x.current.textContent = a.toString());
|
|
952
|
+
};
|
|
953
|
+
return K.addEventListener("crop-update", c), () => {
|
|
954
|
+
K.removeEventListener("crop-update", c);
|
|
955
|
+
};
|
|
956
|
+
}, [
|
|
957
|
+
f,
|
|
958
|
+
h,
|
|
959
|
+
g
|
|
960
|
+
]), /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
961
|
+
className: "crop-tools",
|
|
962
|
+
children: [
|
|
963
|
+
/* @__PURE__ */ (0, p.jsxs)("div", {
|
|
964
|
+
className: "crop-tools-info",
|
|
965
|
+
children: [/* @__PURE__ */ (0, p.jsx)("div", {
|
|
966
|
+
className: "crop-tools-info-label",
|
|
967
|
+
children: "left"
|
|
968
|
+
}), /* @__PURE__ */ (0, p.jsx)("div", {
|
|
969
|
+
className: "crop-tools-info-value semibold",
|
|
970
|
+
ref: _
|
|
971
|
+
})]
|
|
972
|
+
}),
|
|
973
|
+
/* @__PURE__ */ (0, p.jsxs)("div", {
|
|
974
|
+
className: "crop-tools-info",
|
|
975
|
+
children: [/* @__PURE__ */ (0, p.jsx)("div", {
|
|
976
|
+
className: "crop-tools-info-label",
|
|
977
|
+
children: "top"
|
|
978
|
+
}), /* @__PURE__ */ (0, p.jsx)("div", {
|
|
979
|
+
className: "crop-tools-info-value semibold",
|
|
980
|
+
ref: v
|
|
981
|
+
})]
|
|
982
|
+
}),
|
|
983
|
+
/* @__PURE__ */ (0, p.jsxs)("div", {
|
|
984
|
+
className: "crop-tools-info",
|
|
985
|
+
children: [/* @__PURE__ */ (0, p.jsx)("div", {
|
|
986
|
+
className: "crop-tools-info-label",
|
|
987
|
+
children: "width"
|
|
988
|
+
}), /* @__PURE__ */ (0, p.jsx)("div", {
|
|
989
|
+
className: "crop-tools-info-value semibold",
|
|
990
|
+
ref: y
|
|
991
|
+
})]
|
|
992
|
+
}),
|
|
993
|
+
/* @__PURE__ */ (0, p.jsxs)("div", {
|
|
994
|
+
className: "crop-tools-info",
|
|
995
|
+
children: [/* @__PURE__ */ (0, p.jsx)("div", {
|
|
996
|
+
className: "crop-tools-info-label",
|
|
997
|
+
children: "height"
|
|
998
|
+
}), /* @__PURE__ */ (0, p.jsx)("div", {
|
|
999
|
+
className: "crop-tools-info-value semibold",
|
|
1000
|
+
ref: x
|
|
1001
|
+
})]
|
|
1002
|
+
}),
|
|
1003
|
+
/* @__PURE__ */ (0, p.jsx)(V, { orientation: "vertical" }),
|
|
1004
|
+
/* @__PURE__ */ (0, p.jsx)(z, {
|
|
1005
|
+
variant: "ghost",
|
|
1006
|
+
className: "text-green",
|
|
1007
|
+
style: {
|
|
1008
|
+
height: "36px",
|
|
1009
|
+
width: "36px"
|
|
1010
|
+
},
|
|
1011
|
+
disabled: u,
|
|
1012
|
+
onClick: async () => {
|
|
1013
|
+
if (!(!f || f.name !== "crop")) try {
|
|
1014
|
+
if (d(!0), !S.current) return;
|
|
1015
|
+
let { x: e, y: t, w: n, h: i } = S.current, { preset: s } = f.args, c = await o(m, e, t, n, i);
|
|
1016
|
+
if (s) {
|
|
1017
|
+
let { w: e, h: t } = s;
|
|
1018
|
+
c = await l(c, e, t);
|
|
1019
|
+
}
|
|
1020
|
+
r({
|
|
1021
|
+
name: "Crop",
|
|
1022
|
+
base64: c,
|
|
1023
|
+
width: s ? s.w : S.current.w,
|
|
1024
|
+
height: s ? s.h : S.current.h
|
|
1025
|
+
}), a(!0);
|
|
1026
|
+
} catch (e) {
|
|
1027
|
+
console.error("Failed to process image:", e);
|
|
1028
|
+
} finally {
|
|
1029
|
+
d(!1);
|
|
1030
|
+
}
|
|
1031
|
+
},
|
|
1032
|
+
children: u ? /* @__PURE__ */ (0, p.jsx)(L, {}) : /* @__PURE__ */ (0, p.jsx)(E, {})
|
|
1033
|
+
}),
|
|
1034
|
+
/* @__PURE__ */ (0, p.jsx)(V, { orientation: "vertical" }),
|
|
1035
|
+
/* @__PURE__ */ (0, p.jsx)(z, {
|
|
1036
|
+
variant: "ghost",
|
|
1037
|
+
style: {
|
|
1038
|
+
height: "36px",
|
|
1039
|
+
width: "36px"
|
|
1040
|
+
},
|
|
1041
|
+
disabled: u,
|
|
1042
|
+
onClick: () => {
|
|
1043
|
+
e(null), a(!0);
|
|
1044
|
+
},
|
|
1045
|
+
children: /* @__PURE__ */ (0, p.jsx)(D, { className: "text-red" })
|
|
1046
|
+
})
|
|
1047
|
+
]
|
|
1048
|
+
});
|
|
1049
|
+
}, he = ({ onMouseDown: e }) => /* @__PURE__ */ (0, p.jsxs)(p.Fragment, { children: [
|
|
1050
|
+
/* @__PURE__ */ (0, p.jsx)("span", {
|
|
1051
|
+
className: "crop-b crop-b-t",
|
|
1052
|
+
onMouseDown: (t) => e(t, "t", "ns")
|
|
1053
|
+
}),
|
|
1054
|
+
/* @__PURE__ */ (0, p.jsx)("span", {
|
|
1055
|
+
className: "crop-b crop-b-r",
|
|
1056
|
+
onMouseDown: (t) => e(t, "r", "ew")
|
|
1057
|
+
}),
|
|
1058
|
+
/* @__PURE__ */ (0, p.jsx)("span", {
|
|
1059
|
+
className: "crop-b crop-b-b",
|
|
1060
|
+
onMouseDown: (t) => e(t, "b", "ns")
|
|
1061
|
+
}),
|
|
1062
|
+
/* @__PURE__ */ (0, p.jsx)("span", {
|
|
1063
|
+
className: "crop-b crop-b-l",
|
|
1064
|
+
onMouseDown: (t) => e(t, "l", "ew")
|
|
1065
|
+
})
|
|
1066
|
+
] }), ge = () => /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1067
|
+
className: "crop-l-box",
|
|
1068
|
+
children: [/* @__PURE__ */ (0, p.jsx)("span", { className: "crop-l crop-l-v" }), /* @__PURE__ */ (0, p.jsx)("span", { className: "crop-l crop-l-h" })]
|
|
1069
|
+
}), _e = ({ onMouseDown: e }) => /* @__PURE__ */ (0, p.jsxs)(p.Fragment, { children: [
|
|
1070
|
+
/* @__PURE__ */ (0, p.jsx)("span", {
|
|
1071
|
+
className: "crop-ps crop-ps-tl",
|
|
1072
|
+
onMouseDown: (t) => e(t, "tl", "nwse")
|
|
1073
|
+
}),
|
|
1074
|
+
/* @__PURE__ */ (0, p.jsx)("span", {
|
|
1075
|
+
className: "crop-ps crop-ps-t",
|
|
1076
|
+
onMouseDown: (t) => e(t, "t", "ns")
|
|
1077
|
+
}),
|
|
1078
|
+
/* @__PURE__ */ (0, p.jsx)("span", {
|
|
1079
|
+
className: "crop-ps crop-ps-tr",
|
|
1080
|
+
onMouseDown: (t) => e(t, "tr", "nesw")
|
|
1081
|
+
}),
|
|
1082
|
+
/* @__PURE__ */ (0, p.jsx)("span", {
|
|
1083
|
+
className: "crop-ps crop-ps-r",
|
|
1084
|
+
onMouseDown: (t) => e(t, "r", "ew")
|
|
1085
|
+
}),
|
|
1086
|
+
/* @__PURE__ */ (0, p.jsx)("span", {
|
|
1087
|
+
className: "crop-ps crop-ps-br",
|
|
1088
|
+
onMouseDown: (t) => e(t, "br", "nwse")
|
|
1089
|
+
}),
|
|
1090
|
+
/* @__PURE__ */ (0, p.jsx)("span", {
|
|
1091
|
+
className: "crop-ps crop-ps-b",
|
|
1092
|
+
onMouseDown: (t) => e(t, "b", "ns")
|
|
1093
|
+
}),
|
|
1094
|
+
/* @__PURE__ */ (0, p.jsx)("span", {
|
|
1095
|
+
className: "crop-ps crop-ps-bl",
|
|
1096
|
+
onMouseDown: (t) => e(t, "bl", "nesw")
|
|
1097
|
+
}),
|
|
1098
|
+
/* @__PURE__ */ (0, p.jsx)("span", {
|
|
1099
|
+
className: "crop-ps crop-ps-l",
|
|
1100
|
+
onMouseDown: (t) => e(t, "l", "ew")
|
|
1101
|
+
})
|
|
1102
|
+
] });
|
|
1103
|
+
//#endregion
|
|
1104
|
+
//#region src/shared/components/ImageEditor/crop/useCropInteraction.ts
|
|
1105
|
+
function J(e, t, n) {
|
|
1106
|
+
return Math.min(Math.max(e, t), n);
|
|
1107
|
+
}
|
|
1108
|
+
function Y(e, t) {
|
|
1109
|
+
return e / t * 100;
|
|
1110
|
+
}
|
|
1111
|
+
function ve(e, t, n, r, i) {
|
|
1112
|
+
e.style.left = `${t}%`, e.style.top = `${n}%`, e.style.width = `${r}%`, e.style.height = `${i}%`;
|
|
1113
|
+
}
|
|
1114
|
+
function ye(e, t, n, r, i) {
|
|
1115
|
+
e.style.clipPath = `xywh(${t}% ${n}% ${r}% ${i}%)`;
|
|
1116
|
+
}
|
|
1117
|
+
var be = ({ imgRef: e, cropRef: t }) => {
|
|
1118
|
+
let { getCurrentAction: n, getLastHistoryItem: r } = R(), a = S(), o = s(null), c = s(""), l = s({
|
|
1119
|
+
xPct: 0,
|
|
1120
|
+
yPct: 0
|
|
1121
|
+
}), u = s({
|
|
1122
|
+
x: 0,
|
|
1123
|
+
y: 0,
|
|
1124
|
+
w: 0,
|
|
1125
|
+
h: 0
|
|
1126
|
+
});
|
|
1127
|
+
return i(() => {
|
|
1128
|
+
let i = (e) => {
|
|
1129
|
+
if (t.current) {
|
|
1130
|
+
let e = t.current.parentElement;
|
|
1131
|
+
e && (l.current = {
|
|
1132
|
+
xPct: Y(t.current.offsetLeft, e.offsetWidth),
|
|
1133
|
+
yPct: Y(t.current.offsetTop, e.offsetHeight)
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
let n = "clientX" in e ? e.clientX : e.touches[0].clientX, r = "clientY" in e ? e.clientY : e.touches[0].clientY;
|
|
1137
|
+
o.current = {
|
|
1138
|
+
x: n,
|
|
1139
|
+
y: r
|
|
1140
|
+
}, document.body.style.cursor = "move";
|
|
1141
|
+
}, a = (n) => {
|
|
1142
|
+
if (!e.current || !t.current || !o.current) return;
|
|
1143
|
+
let r = t.current, i = e.current, a = r.parentElement;
|
|
1144
|
+
if (!a) return;
|
|
1145
|
+
let l = a.offsetWidth, u = a.offsetHeight;
|
|
1146
|
+
if (c.current) {
|
|
1147
|
+
s(n, r, i, l, u);
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
d(n, r, i, l, u);
|
|
1151
|
+
}, s = (e, t, i, a, s) => {
|
|
1152
|
+
let l = n();
|
|
1153
|
+
if (!l || l.name !== "crop" || !o.current) return;
|
|
1154
|
+
let { isFree: d, ratio: f } = l.args, p = "clientX" in e ? e.clientX : e.touches[0].clientX, m = "clientY" in e ? e.clientY : e.touches[0].clientY, { x: h, y: g, w: _, h: v } = fe(c.current, d, f, o.current.x, o.current.y, p, m, a, s, u.current, t), y = Y(h, a), b = Y(g, s), x = Y(_, a), S = Y(v, s);
|
|
1155
|
+
ve(t, y, b, x, S), ye(i, y, b, x, S);
|
|
1156
|
+
let C = r();
|
|
1157
|
+
if (!C) return;
|
|
1158
|
+
let { width: w, height: T } = C;
|
|
1159
|
+
q({
|
|
1160
|
+
x: Math.round(y / 100 * w),
|
|
1161
|
+
y: Math.round(b / 100 * T),
|
|
1162
|
+
w: Math.round(x / 100 * w),
|
|
1163
|
+
h: Math.round(S / 100 * T)
|
|
1164
|
+
});
|
|
1165
|
+
}, d = (e, t, n, i, a) => {
|
|
1166
|
+
if (!o.current) return;
|
|
1167
|
+
console.log("HandleDrag");
|
|
1168
|
+
let s = t.offsetWidth, c = t.offsetHeight, u = "clientX" in e ? e.clientX : e.touches[0].clientX, d = "clientY" in e ? e.clientY : e.touches[0].clientY, f = Y(u - o.current.x, i), p = Y(d - o.current.y, a);
|
|
1169
|
+
o.current = {
|
|
1170
|
+
x: u,
|
|
1171
|
+
y: d
|
|
1172
|
+
};
|
|
1173
|
+
let m = Y(i - s, i), h = Y(a - c, a), g = J(l.current.xPct + f, 0, m), _ = J(l.current.yPct + p, 0, h), v = Y(s, i), y = Y(c, a);
|
|
1174
|
+
l.current = {
|
|
1175
|
+
xPct: g,
|
|
1176
|
+
yPct: _
|
|
1177
|
+
}, ve(t, g, _, v, y), ye(n, g, _, v, y);
|
|
1178
|
+
let { width: b, height: x } = r();
|
|
1179
|
+
q({
|
|
1180
|
+
x: Math.round(g / 100 * b),
|
|
1181
|
+
y: Math.round(_ / 100 * x),
|
|
1182
|
+
w: Math.round(v / 100 * b),
|
|
1183
|
+
h: Math.round(y / 100 * x)
|
|
1184
|
+
});
|
|
1185
|
+
}, f = () => {
|
|
1186
|
+
t.current && (o.current = null, c.current = "", t.current.style.cursor = "move", document.body.style.cursor = "auto");
|
|
1187
|
+
};
|
|
1188
|
+
if (!t.current) return;
|
|
1189
|
+
let p = new AbortController(), { signal: m } = p;
|
|
1190
|
+
return t.current.addEventListener("mousedown", i, { signal: m }), t.current.addEventListener("touchstart", i, { signal: m }), document.addEventListener("mousemove", a, { signal: m }), document.addEventListener("touchmove", a, { signal: m }), document.addEventListener("mouseup", f, { signal: m }), document.addEventListener("touchend", f, { signal: m }), () => p.abort();
|
|
1191
|
+
}, [
|
|
1192
|
+
n,
|
|
1193
|
+
r,
|
|
1194
|
+
e,
|
|
1195
|
+
t
|
|
1196
|
+
]), { handleCropStart: (e, n, r) => {
|
|
1197
|
+
if (!t.current) return;
|
|
1198
|
+
e.stopPropagation(), u.current = {
|
|
1199
|
+
x: t.current.offsetLeft,
|
|
1200
|
+
y: t.current.offsetTop,
|
|
1201
|
+
w: t.current.offsetWidth,
|
|
1202
|
+
h: t.current.offsetHeight
|
|
1203
|
+
};
|
|
1204
|
+
let i = "clientX" in e ? e.clientX : e.touches[0].clientX, s = "clientY" in e ? e.clientY : e.touches[0].clientY;
|
|
1205
|
+
o.current = {
|
|
1206
|
+
x: i,
|
|
1207
|
+
y: s
|
|
1208
|
+
}, c.current = n, a || (t.current.style.cursor = `${r}-resize`, document.body.style.cursor = `${r}-resize`);
|
|
1209
|
+
} };
|
|
1210
|
+
}, xe = ({ onMouseDown: e }) => /* @__PURE__ */ (0, p.jsx)("div", {
|
|
1211
|
+
className: "crop-p-b",
|
|
1212
|
+
children: /* @__PURE__ */ (0, p.jsx)("div", {
|
|
1213
|
+
className: "crop-p-p",
|
|
1214
|
+
onTouchStart: (t) => e(t, "br", "nwse")
|
|
1215
|
+
})
|
|
1216
|
+
}), X = 10, Z = 200, Q = (e, t, n) => (e < X && (e = X), e > Z && (e = Z), {
|
|
1217
|
+
updatedScale: e,
|
|
1218
|
+
updatedWidth: Math.round(e / 100 * t),
|
|
1219
|
+
updatedHeight: Math.round(e / 100 * n)
|
|
1220
|
+
}), Se = ({ onResizing: e }) => {
|
|
1221
|
+
let { getLastHistoryItem: t, setCurrentAction: n, addToHistory: r, setSidebar: a } = R(), { width: o, height: l, base64: u } = t(), [d, f] = c(!1), [m, h] = c(o), [g, _] = c(l), v = s(0), { resize: y } = b(), x = S(), C = (t) => {
|
|
1222
|
+
let { updatedScale: n, updatedWidth: r, updatedHeight: i } = Q(parseInt(t.target.value) / o * 100, o, l);
|
|
1223
|
+
h(r), _(i), e(n);
|
|
1224
|
+
}, w = (t) => {
|
|
1225
|
+
let { updatedScale: n, updatedWidth: r, updatedHeight: i } = Q(parseInt(t.target.value) / l * 100, o, l);
|
|
1226
|
+
_(i), h(r), e(n);
|
|
1227
|
+
}, T = () => {
|
|
1228
|
+
e(100), n(null), a(!0);
|
|
1229
|
+
}, O = async () => {
|
|
1230
|
+
try {
|
|
1231
|
+
f(!0);
|
|
1232
|
+
let t = await y(u, m, g);
|
|
1233
|
+
r({
|
|
1234
|
+
name: "Resize",
|
|
1235
|
+
base64: t,
|
|
1236
|
+
width: m,
|
|
1237
|
+
height: g
|
|
1238
|
+
}), e(100), a(!0);
|
|
1239
|
+
} catch (e) {
|
|
1240
|
+
console.error("Failed to process image:", e);
|
|
1241
|
+
} finally {
|
|
1242
|
+
f(!1);
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1245
|
+
return i(() => {
|
|
1246
|
+
let t = Math.round(m / o * 100), n = (t) => {
|
|
1247
|
+
let { updatedHeight: n, updatedWidth: r } = Q(t, o, l);
|
|
1248
|
+
_(n), h(r), e(t);
|
|
1249
|
+
}, r = (e) => {
|
|
1250
|
+
if (d) return;
|
|
1251
|
+
let r = Math.sign(e.deltaY);
|
|
1252
|
+
t -= r * 2, t <= X && (t = X), t >= Z && (t = Z), n(t);
|
|
1253
|
+
}, i = (e) => {
|
|
1254
|
+
v.current = e.touches[0].clientY;
|
|
1255
|
+
}, a = (e) => {
|
|
1256
|
+
if (d) return;
|
|
1257
|
+
let r = e.touches[0].clientY, i = v.current - r;
|
|
1258
|
+
Math.abs(i) < 10 || (t += Math.sign(i) * 2, t <= X && (t = X), t >= Z && (t = Z), n(t), v.current = r);
|
|
1259
|
+
}, s = new AbortController(), { signal: c } = s;
|
|
1260
|
+
return window.addEventListener("wheel", r, { signal: c }), window.addEventListener("touchstart", i, { signal: c }), window.addEventListener("touchmove", a, { signal: c }), () => s.abort();
|
|
1261
|
+
}, [
|
|
1262
|
+
l,
|
|
1263
|
+
o,
|
|
1264
|
+
d,
|
|
1265
|
+
x,
|
|
1266
|
+
e,
|
|
1267
|
+
m
|
|
1268
|
+
]), /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1269
|
+
className: "resize",
|
|
1270
|
+
children: [
|
|
1271
|
+
/* @__PURE__ */ (0, p.jsx)("div", {
|
|
1272
|
+
className: "resize-text",
|
|
1273
|
+
children: x ? "Slide UP/Down to Resize" : "Scroll UP/Down to Resize"
|
|
1274
|
+
}),
|
|
1275
|
+
/* @__PURE__ */ (0, p.jsx)("div", { className: "resize-border" }),
|
|
1276
|
+
/* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1277
|
+
className: "resize-tools",
|
|
1278
|
+
children: [
|
|
1279
|
+
/* @__PURE__ */ (0, p.jsx)(H, {
|
|
1280
|
+
value: m,
|
|
1281
|
+
name: "width",
|
|
1282
|
+
label: "Width",
|
|
1283
|
+
disabled: d,
|
|
1284
|
+
style: { width: "88px" },
|
|
1285
|
+
onChange: C
|
|
1286
|
+
}),
|
|
1287
|
+
/* @__PURE__ */ (0, p.jsx)(ee, { className: "resize-tools-lock" }),
|
|
1288
|
+
/* @__PURE__ */ (0, p.jsx)(H, {
|
|
1289
|
+
value: g,
|
|
1290
|
+
name: "height",
|
|
1291
|
+
label: "Height",
|
|
1292
|
+
disabled: d,
|
|
1293
|
+
style: { width: "88px" },
|
|
1294
|
+
onChange: w
|
|
1295
|
+
}),
|
|
1296
|
+
/* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1297
|
+
className: "resize-tools-buttons",
|
|
1298
|
+
children: [/* @__PURE__ */ (0, p.jsx)(z, {
|
|
1299
|
+
variant: "outline",
|
|
1300
|
+
className: "resize-tools-save text-green",
|
|
1301
|
+
disabled: m === o || d,
|
|
1302
|
+
onClick: () => O(),
|
|
1303
|
+
children: d ? /* @__PURE__ */ (0, p.jsx)(L, {}) : /* @__PURE__ */ (0, p.jsx)(E, {})
|
|
1304
|
+
}), /* @__PURE__ */ (0, p.jsx)(z, {
|
|
1305
|
+
variant: "outline",
|
|
1306
|
+
className: "resize-tools-close text-red",
|
|
1307
|
+
disabled: d,
|
|
1308
|
+
onClick: T,
|
|
1309
|
+
children: /* @__PURE__ */ (0, p.jsx)(D, {})
|
|
1310
|
+
})]
|
|
1311
|
+
})
|
|
1312
|
+
]
|
|
1313
|
+
})
|
|
1314
|
+
]
|
|
1315
|
+
});
|
|
1316
|
+
}, Ce = () => {
|
|
1317
|
+
let { getLastHistoryItem: e, currentAction: t } = R(), n = s(null), r = s(null), { width: i, height: a, base64: o } = e(), c = t?.name === "crop", l = t?.name === "resize", u = c || l, d = (e) => {
|
|
1318
|
+
n.current && (n.current.style.transform = `scale(${e / 100})`);
|
|
1319
|
+
}, f = `frame ${u ? "mask" : ""}`, m = `frame-image ${u ? "frame-image--faded" : ""}`;
|
|
1320
|
+
return /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1321
|
+
className: f,
|
|
1322
|
+
children: [
|
|
1323
|
+
/* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1324
|
+
ref: n,
|
|
1325
|
+
style: { aspectRatio: `${i} / ${a}` },
|
|
1326
|
+
className: "frame-preview",
|
|
1327
|
+
children: [/* @__PURE__ */ (0, p.jsx)("img", {
|
|
1328
|
+
ref: r,
|
|
1329
|
+
src: o,
|
|
1330
|
+
alt: "Image",
|
|
1331
|
+
className: m
|
|
1332
|
+
}), c && /* @__PURE__ */ (0, p.jsx)(pe, {}, t?.args?.id)]
|
|
1333
|
+
}),
|
|
1334
|
+
l && /* @__PURE__ */ (0, p.jsx)(Se, { onResizing: d }),
|
|
1335
|
+
c && /* @__PURE__ */ (0, p.jsx)(me, {})
|
|
1336
|
+
]
|
|
1337
|
+
});
|
|
1338
|
+
}, we = () => {
|
|
1339
|
+
let { getLastHistoryItem: e, setCurrentAction: t, setSidebar: n } = R(), { width: r, height: i } = e() ?? {
|
|
1340
|
+
width: 0,
|
|
1341
|
+
height: 0
|
|
1342
|
+
};
|
|
1343
|
+
return /* @__PURE__ */ (0, p.jsxs)(z, {
|
|
1344
|
+
variant: "outline",
|
|
1345
|
+
className: "sidebar-resize",
|
|
1346
|
+
onClick: () => {
|
|
1347
|
+
t({
|
|
1348
|
+
name: "resize",
|
|
1349
|
+
args: {
|
|
1350
|
+
width: r,
|
|
1351
|
+
height: i
|
|
1352
|
+
}
|
|
1353
|
+
}), n(!1);
|
|
1354
|
+
},
|
|
1355
|
+
children: [/* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1356
|
+
className: "sidebar-resize-icon",
|
|
1357
|
+
children: [/* @__PURE__ */ (0, p.jsx)(I, {}), "Resize"]
|
|
1358
|
+
}), /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1359
|
+
className: "sidebar-resize-size",
|
|
1360
|
+
children: [
|
|
1361
|
+
r,
|
|
1362
|
+
" x ",
|
|
1363
|
+
i
|
|
1364
|
+
]
|
|
1365
|
+
})]
|
|
1366
|
+
});
|
|
1367
|
+
}, Te = () => {
|
|
1368
|
+
let { currentAction: e, setCurrentAction: t, getLastHistoryItem: n, setSidebar: r } = R(), { name: i, args: a } = e || {}, o = i === "crop" ? a?.id : "", { width: s, height: c } = n(), l = s / c, u = (e) => {
|
|
1369
|
+
e !== o && (t({
|
|
1370
|
+
name: "crop",
|
|
1371
|
+
args: {
|
|
1372
|
+
id: e,
|
|
1373
|
+
ratio: e === "1:1" ? 1 : l,
|
|
1374
|
+
isFree: e === "freeform",
|
|
1375
|
+
preset: null
|
|
1376
|
+
}
|
|
1377
|
+
}), r(!1));
|
|
1378
|
+
};
|
|
1379
|
+
return /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1380
|
+
className: "sidebar-crop",
|
|
1381
|
+
children: [/* @__PURE__ */ (0, p.jsx)("h4", { children: "Crop" }), /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1382
|
+
className: "sidebar-crop-ratios",
|
|
1383
|
+
children: [
|
|
1384
|
+
/* @__PURE__ */ (0, p.jsx)(B, {
|
|
1385
|
+
label: "Freeform",
|
|
1386
|
+
icon: /* @__PURE__ */ (0, p.jsx)(N, {}),
|
|
1387
|
+
active: o === "freeform",
|
|
1388
|
+
onClick: () => u("freeform")
|
|
1389
|
+
}),
|
|
1390
|
+
/* @__PURE__ */ (0, p.jsx)(B, {
|
|
1391
|
+
label: "Original",
|
|
1392
|
+
icon: /* @__PURE__ */ (0, p.jsx)(P, {}),
|
|
1393
|
+
active: o === "original",
|
|
1394
|
+
onClick: () => u("original")
|
|
1395
|
+
}),
|
|
1396
|
+
/* @__PURE__ */ (0, p.jsx)(B, {
|
|
1397
|
+
label: "1:1",
|
|
1398
|
+
icon: /* @__PURE__ */ (0, p.jsx)(F, {}),
|
|
1399
|
+
active: o === "1:1",
|
|
1400
|
+
onClick: () => u("1:1")
|
|
1401
|
+
})
|
|
1402
|
+
]
|
|
1403
|
+
})]
|
|
1404
|
+
});
|
|
1405
|
+
}, $ = [
|
|
1406
|
+
{
|
|
1407
|
+
label: "Facebook",
|
|
1408
|
+
value: "facebook",
|
|
1409
|
+
options: [
|
|
1410
|
+
{
|
|
1411
|
+
value: "facebook-post",
|
|
1412
|
+
label: "Post",
|
|
1413
|
+
w: 1200,
|
|
1414
|
+
h: 630,
|
|
1415
|
+
rightLabel: "1200 x 630"
|
|
1416
|
+
},
|
|
1417
|
+
{
|
|
1418
|
+
value: "facebook-cover",
|
|
1419
|
+
label: "Cover",
|
|
1420
|
+
w: 851,
|
|
1421
|
+
h: 315,
|
|
1422
|
+
rightLabel: "851 x 315"
|
|
1423
|
+
},
|
|
1424
|
+
{
|
|
1425
|
+
value: "facebook-profile",
|
|
1426
|
+
label: "Profile",
|
|
1427
|
+
w: 170,
|
|
1428
|
+
h: 170,
|
|
1429
|
+
rightLabel: "170 x 170"
|
|
1430
|
+
},
|
|
1431
|
+
{
|
|
1432
|
+
value: "facebook-story",
|
|
1433
|
+
label: "Story",
|
|
1434
|
+
w: 1080,
|
|
1435
|
+
h: 1920,
|
|
1436
|
+
rightLabel: "1080 x 1920"
|
|
1437
|
+
}
|
|
1438
|
+
]
|
|
1439
|
+
},
|
|
1440
|
+
{
|
|
1441
|
+
label: "Instagram",
|
|
1442
|
+
value: "instagram",
|
|
1443
|
+
options: [
|
|
1444
|
+
{
|
|
1445
|
+
value: "instagram-landscape",
|
|
1446
|
+
label: "Landscape",
|
|
1447
|
+
w: 1080,
|
|
1448
|
+
h: 566,
|
|
1449
|
+
rightLabel: "1080 x 566"
|
|
1450
|
+
},
|
|
1451
|
+
{
|
|
1452
|
+
value: "instagram-portait",
|
|
1453
|
+
label: "Portait",
|
|
1454
|
+
w: 1080,
|
|
1455
|
+
h: 1350,
|
|
1456
|
+
rightLabel: "1080 x 1350"
|
|
1457
|
+
},
|
|
1458
|
+
{
|
|
1459
|
+
value: "instagram-square",
|
|
1460
|
+
label: "Square",
|
|
1461
|
+
w: 1080,
|
|
1462
|
+
h: 1080,
|
|
1463
|
+
rightLabel: "1080 x 1080"
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
value: "instagram-story",
|
|
1467
|
+
label: "Story",
|
|
1468
|
+
w: 1080,
|
|
1469
|
+
h: 1920,
|
|
1470
|
+
rightLabel: "1080 x 1920"
|
|
1471
|
+
},
|
|
1472
|
+
{
|
|
1473
|
+
value: "instagram-thumbnail",
|
|
1474
|
+
label: "Thumbnail",
|
|
1475
|
+
w: 161,
|
|
1476
|
+
h: 161,
|
|
1477
|
+
rightLabel: "161 x 161"
|
|
1478
|
+
}
|
|
1479
|
+
]
|
|
1480
|
+
},
|
|
1481
|
+
{
|
|
1482
|
+
label: "LinkedIn",
|
|
1483
|
+
value: "linkedin",
|
|
1484
|
+
options: [
|
|
1485
|
+
{
|
|
1486
|
+
value: "linkedin-blog-post",
|
|
1487
|
+
label: "Blog Post",
|
|
1488
|
+
w: 1200,
|
|
1489
|
+
h: 627,
|
|
1490
|
+
rightLabel: "1200 x 627"
|
|
1491
|
+
},
|
|
1492
|
+
{
|
|
1493
|
+
value: "linkedin-cover",
|
|
1494
|
+
label: "Cover",
|
|
1495
|
+
w: 1128,
|
|
1496
|
+
h: 191,
|
|
1497
|
+
rightLabel: "1128 x 191"
|
|
1498
|
+
},
|
|
1499
|
+
{
|
|
1500
|
+
value: "linkedin-profile",
|
|
1501
|
+
label: "Profile",
|
|
1502
|
+
w: 400,
|
|
1503
|
+
h: 400,
|
|
1504
|
+
rightLabel: "400 x 400"
|
|
1505
|
+
}
|
|
1506
|
+
]
|
|
1507
|
+
}
|
|
1508
|
+
], Ee = $.map((e) => e.options).flat(), De = () => {
|
|
1509
|
+
let { setCurrentAction: e, currentAction: t, setSidebar: n } = R(), r = t?.name === "crop" && Ee.some((e) => e.value === t.args.id) ? t.args.id : "";
|
|
1510
|
+
return /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1511
|
+
className: "sidebar-preset",
|
|
1512
|
+
children: [/* @__PURE__ */ (0, p.jsx)("h4", { children: "Presets" }), /* @__PURE__ */ (0, p.jsx)("div", {
|
|
1513
|
+
className: "relative",
|
|
1514
|
+
children: /* @__PURE__ */ (0, p.jsx)(te, {
|
|
1515
|
+
value: r,
|
|
1516
|
+
placeholder: "Select a preset",
|
|
1517
|
+
onChange: (t) => {
|
|
1518
|
+
if (!t) return;
|
|
1519
|
+
let r = $.map((e) => e.options).flat().find((e) => e.value === t);
|
|
1520
|
+
if (!r) return;
|
|
1521
|
+
let i = {
|
|
1522
|
+
id: t,
|
|
1523
|
+
ratio: r.w / r.h,
|
|
1524
|
+
isFree: !1,
|
|
1525
|
+
preset: {
|
|
1526
|
+
w: r.w,
|
|
1527
|
+
h: r.h
|
|
1528
|
+
}
|
|
1529
|
+
};
|
|
1530
|
+
e({
|
|
1531
|
+
name: "crop",
|
|
1532
|
+
args: i
|
|
1533
|
+
}), n(!1);
|
|
1534
|
+
},
|
|
1535
|
+
items: $
|
|
1536
|
+
})
|
|
1537
|
+
})]
|
|
1538
|
+
});
|
|
1539
|
+
}, Oe = () => {
|
|
1540
|
+
let { getSidebar: e, setSidebar: t } = R(), n = e(), r = w("md");
|
|
1541
|
+
return /* @__PURE__ */ (0, p.jsxs)(p.Fragment, { children: [/* @__PURE__ */ (0, p.jsx)(z, {
|
|
1542
|
+
variant: "outline",
|
|
1543
|
+
className: "sidebar-settings",
|
|
1544
|
+
onClick: () => t(!0),
|
|
1545
|
+
children: /* @__PURE__ */ (0, p.jsx)(M, {})
|
|
1546
|
+
}), /* @__PURE__ */ (0, p.jsx)("div", {
|
|
1547
|
+
className: "sidebar",
|
|
1548
|
+
style: { transform: r && n ? "translateX(-320px)" : "translateX(0%)" },
|
|
1549
|
+
children: /* @__PURE__ */ (0, p.jsx)("div", {
|
|
1550
|
+
className: "sidebar-container",
|
|
1551
|
+
children: /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1552
|
+
className: "sidebar-content",
|
|
1553
|
+
children: [
|
|
1554
|
+
r && /* @__PURE__ */ (0, p.jsx)(z, {
|
|
1555
|
+
variant: "ghost",
|
|
1556
|
+
className: "sidebar-close-btn btn-rect",
|
|
1557
|
+
onClick: () => t(!1),
|
|
1558
|
+
children: /* @__PURE__ */ (0, p.jsx)(D, {})
|
|
1559
|
+
}),
|
|
1560
|
+
/* @__PURE__ */ (0, p.jsx)(we, {}),
|
|
1561
|
+
/* @__PURE__ */ (0, p.jsx)(V, { className: "sidebar-separator" }),
|
|
1562
|
+
/* @__PURE__ */ (0, p.jsx)(Te, {}),
|
|
1563
|
+
/* @__PURE__ */ (0, p.jsx)(V, { className: "sidebar-separator" }),
|
|
1564
|
+
/* @__PURE__ */ (0, p.jsx)(De, {})
|
|
1565
|
+
]
|
|
1566
|
+
})
|
|
1567
|
+
})
|
|
1568
|
+
})] });
|
|
1569
|
+
}, ke = ({ image: e, onSave: t, onBack: n }) => {
|
|
1570
|
+
let { loading: r, error: i, width: a, height: o, base64: s, extension: c } = y(e);
|
|
1571
|
+
return r || i || !s || !c ? /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1572
|
+
className: "picedi sys",
|
|
1573
|
+
children: [
|
|
1574
|
+
r && /* @__PURE__ */ (0, p.jsx)(m, { size: 48 }),
|
|
1575
|
+
i && /* @__PURE__ */ (0, p.jsx)("div", {
|
|
1576
|
+
className: "text-red",
|
|
1577
|
+
children: i
|
|
1578
|
+
}),
|
|
1579
|
+
!r && !i && (!s || !c) && /* @__PURE__ */ (0, p.jsx)("div", {
|
|
1580
|
+
className: "text-red",
|
|
1581
|
+
children: "Failed to load image."
|
|
1582
|
+
})
|
|
1583
|
+
]
|
|
1584
|
+
}) : /* @__PURE__ */ (0, p.jsx)(_, {
|
|
1585
|
+
base64: s,
|
|
1586
|
+
width: a,
|
|
1587
|
+
height: o,
|
|
1588
|
+
ext: c,
|
|
1589
|
+
children: /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1590
|
+
className: "picedi main",
|
|
1591
|
+
children: [/* @__PURE__ */ (0, p.jsx)(re, {
|
|
1592
|
+
onSave: t,
|
|
1593
|
+
onBack: n
|
|
1594
|
+
}), /* @__PURE__ */ (0, p.jsxs)("div", {
|
|
1595
|
+
className: "grid",
|
|
1596
|
+
children: [/* @__PURE__ */ (0, p.jsx)(Ce, {}), /* @__PURE__ */ (0, p.jsx)(Oe, {})]
|
|
1597
|
+
})]
|
|
1598
|
+
})
|
|
1599
|
+
});
|
|
1600
|
+
};
|
|
1601
|
+
//#endregion
|
|
1602
|
+
export { ke as ImageEditor };
|