@interware/content-generator 0.4.4 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/README.md +21 -1
  2. package/dist/_chunks/{App-BQr5_g5u.mjs → App-DPVBu7QB.mjs} +37 -726
  3. package/dist/_chunks/{App-CfwvfmvL.js → App-DVTFrZvf.js} +31 -720
  4. package/dist/_chunks/ImageStudioTabs-B2UbKYq7.js +5299 -0
  5. package/dist/_chunks/ImageStudioTabs-mlNL6aQ2.mjs +5298 -0
  6. package/dist/_chunks/Settings-DziRY70a.js +155 -0
  7. package/dist/_chunks/Settings-RrBQdijj.mjs +155 -0
  8. package/dist/_chunks/StudioApp-AUyPNhh2.mjs +17 -0
  9. package/dist/_chunks/StudioApp-Cswkzh7F.js +17 -0
  10. package/dist/_chunks/{getTranslation-DNhP1INv.js → getTranslation-D88uLXGd.js} +1 -1
  11. package/dist/_chunks/{getTranslation-B9ND5RaH.mjs → getTranslation-DfxaP_TC.mjs} +1 -1
  12. package/dist/_chunks/{index-Dyq8dxMX.mjs → index-CqDdi211.mjs} +25 -7
  13. package/dist/_chunks/{index-DGPqyrzz.js → index-Ddp0Qvqo.js} +24 -6
  14. package/dist/admin/index.js +1 -1
  15. package/dist/admin/index.mjs +1 -1
  16. package/dist/admin/src/components/PluginIcon.d.ts +4 -2
  17. package/dist/admin/src/components/PluginProviders.d.ts +8 -0
  18. package/dist/admin/src/components/generate-video/Form.d.ts +1 -1
  19. package/dist/admin/src/components/settings/Form.d.ts +4 -5
  20. package/dist/admin/src/containers/settings/index.d.ts +7 -7
  21. package/dist/admin/src/features/background-removal/RemoveBackgroundButton.d.ts +7 -0
  22. package/dist/admin/src/features/background-removal/RemoveBackgroundDialog.d.ts +15 -0
  23. package/dist/admin/src/features/background-removal/colorKey.d.ts +29 -0
  24. package/dist/admin/src/features/background-removal/imageCanvas.d.ts +20 -0
  25. package/dist/admin/src/features/background-removal/mask.d.ts +10 -0
  26. package/dist/admin/src/features/background-removal/runtime.d.ts +31 -0
  27. package/dist/admin/src/features/generator/EditEmpty.d.ts +13 -0
  28. package/dist/admin/src/features/generator/GeneratorTab.d.ts +7 -0
  29. package/dist/admin/src/features/generator/GroundingSources.d.ts +9 -0
  30. package/dist/admin/src/features/generator/ModeSwitch.d.ts +6 -0
  31. package/dist/admin/src/features/generator/PromptComposer.d.ts +25 -0
  32. package/dist/admin/src/features/generator/ReferencePicker.d.ts +26 -0
  33. package/dist/admin/src/features/generator/VersionHistory.d.ts +13 -0
  34. package/dist/admin/src/features/generator/generatorApi.d.ts +71 -0
  35. package/dist/admin/src/features/generator/model.d.ts +60 -0
  36. package/dist/admin/src/features/generator/useGeneratorApi.d.ts +21 -0
  37. package/dist/admin/src/features/image-studio/ImageStudioTabs.d.ts +26 -0
  38. package/dist/admin/src/features/image-studio/SegmentedSwitch.d.ts +18 -0
  39. package/dist/admin/src/features/image-studio/checkerboard.d.ts +5 -0
  40. package/dist/admin/src/features/library/FileCard.d.ts +17 -0
  41. package/dist/admin/src/features/library/FolderTree.d.ts +14 -0
  42. package/dist/admin/src/features/library/LibraryDialogs.d.ts +46 -0
  43. package/dist/admin/src/features/library/LibraryImagePicker.d.ts +15 -0
  44. package/dist/admin/src/features/library/LibraryTab.d.ts +2 -0
  45. package/dist/admin/src/features/library/SaveToLibraryDialog.d.ts +15 -0
  46. package/dist/admin/src/features/library/model.d.ts +40 -0
  47. package/dist/admin/src/features/library/studioRoot.d.ts +11 -0
  48. package/dist/admin/src/features/library/uploadApi.d.ts +77 -0
  49. package/dist/admin/src/features/library/useLibraryApi.d.ts +34 -0
  50. package/dist/admin/src/features/templates/editor/ColorField.d.ts +11 -0
  51. package/dist/admin/src/features/templates/editor/Editor.d.ts +19 -0
  52. package/dist/admin/src/features/templates/editor/EditorBar.d.ts +9 -0
  53. package/dist/admin/src/features/templates/editor/EditorMenuBar.d.ts +58 -0
  54. package/dist/admin/src/features/templates/editor/EditorToolbar.d.ts +20 -0
  55. package/dist/admin/src/features/templates/editor/ElementPalette.d.ts +10 -0
  56. package/dist/admin/src/features/templates/editor/FloatingPanel.d.ts +17 -0
  57. package/dist/admin/src/features/templates/editor/FullscreenView.d.ts +11 -0
  58. package/dist/admin/src/features/templates/editor/IconPicker.d.ts +9 -0
  59. package/dist/admin/src/features/templates/editor/Inspector.d.ts +17 -0
  60. package/dist/admin/src/features/templates/editor/LayersPanel.d.ts +12 -0
  61. package/dist/admin/src/features/templates/editor/Precision.d.ts +23 -0
  62. package/dist/admin/src/features/templates/editor/RangeField.d.ts +12 -0
  63. package/dist/admin/src/features/templates/editor/SaveTemplateDialog.d.ts +14 -0
  64. package/dist/admin/src/features/templates/editor/Stage.d.ts +29 -0
  65. package/dist/admin/src/features/templates/editor/TemplateFolderSelect.d.ts +9 -0
  66. package/dist/admin/src/features/templates/editor/TemplatePicker.d.ts +23 -0
  67. package/dist/admin/src/features/templates/editor/TemplatesTab.d.ts +5 -0
  68. package/dist/admin/src/features/templates/editor/TypographyControls.d.ts +24 -0
  69. package/dist/admin/src/features/templates/editor/icons.d.ts +7 -0
  70. package/dist/admin/src/features/templates/editor/overlays.d.ts +20 -0
  71. package/dist/admin/src/features/templates/editor/useCanvasNav.d.ts +25 -0
  72. package/dist/admin/src/features/templates/editor/useFitScale.d.ts +3 -0
  73. package/dist/admin/src/features/templates/export/fontEmbed.d.ts +22 -0
  74. package/dist/admin/src/features/templates/export/imageSource.d.ts +21 -0
  75. package/dist/admin/src/features/templates/export/pdf.d.ts +6 -0
  76. package/dist/admin/src/features/templates/export/render.d.ts +22 -0
  77. package/dist/admin/src/features/templates/export/useEditorIO.d.ts +18 -0
  78. package/dist/admin/src/features/templates/fonts/catalog.d.ts +47 -0
  79. package/dist/admin/src/features/templates/fonts/customFonts.d.ts +19 -0
  80. package/dist/admin/src/features/templates/fonts/useCustomFonts.d.ts +9 -0
  81. package/dist/admin/src/features/templates/fonts/useFonts.d.ts +2 -0
  82. package/dist/admin/src/features/templates/model/drag.d.ts +10 -0
  83. package/dist/admin/src/features/templates/model/editorReducer.d.ts +58 -0
  84. package/dist/admin/src/features/templates/model/layers.d.ts +42 -0
  85. package/dist/admin/src/features/templates/model/palette.d.ts +38 -0
  86. package/dist/admin/src/features/templates/model/presets.d.ts +17 -0
  87. package/dist/admin/src/features/templates/model/shortcuts.d.ts +19 -0
  88. package/dist/admin/src/features/templates/model/snap.d.ts +24 -0
  89. package/dist/admin/src/features/templates/model/templates.d.ts +8 -0
  90. package/dist/admin/src/features/templates/model/types.d.ts +154 -0
  91. package/dist/admin/src/features/templates/model/viewport.d.ts +36 -0
  92. package/dist/admin/src/features/templates/render/IWLogo.d.ts +7 -0
  93. package/dist/admin/src/features/templates/render/LayerCanvas.d.ts +13 -0
  94. package/dist/admin/src/features/templates/render/fonts.d.ts +5 -0
  95. package/dist/admin/src/features/templates/render/icons.d.ts +10 -0
  96. package/dist/admin/src/features/templates/render/renderLayer.d.ts +9 -0
  97. package/dist/admin/src/features/templates/store/persist.d.ts +41 -0
  98. package/dist/admin/src/features/templates/store/templatesApi.d.ts +49 -0
  99. package/dist/admin/src/features/templates/store/useMyTemplates.d.ts +19 -0
  100. package/dist/admin/src/features/templates/store/useTemplateSaving.d.ts +14 -0
  101. package/dist/admin/src/features/templates/store/useTemplatesApi.d.ts +23 -0
  102. package/dist/admin/src/hooks/useAdminTheme.d.ts +8 -0
  103. package/dist/admin/src/hooks/useThemeColors.d.ts +9 -0
  104. package/dist/admin/src/lib/dataUrl.d.ts +6 -0
  105. package/dist/admin/src/lib/promptRules.d.ts +23 -0
  106. package/dist/admin/src/lib/use-cases/articles/index.d.ts +12 -1
  107. package/dist/admin/src/lib/use-cases/categories/index.d.ts +12 -1
  108. package/dist/admin/src/lib/use-cases/facebook/index.d.ts +1 -1
  109. package/dist/admin/src/lib/use-cases/generate-content/index.d.ts +2 -2
  110. package/dist/admin/src/lib/use-cases/images/index.d.ts +1 -4
  111. package/dist/admin/src/lib/use-cases/linkedin/index.d.ts +1 -1
  112. package/dist/admin/src/lib/use-cases/settings/index.d.ts +13 -2
  113. package/dist/admin/src/lib/use-cases/users/index.d.ts +12 -1
  114. package/dist/admin/src/pages/ImageStudio.d.ts +3 -0
  115. package/dist/admin/src/pages/StudioApp.d.ts +3 -0
  116. package/dist/admin/src/pluginId.d.ts +6 -0
  117. package/dist/admin/src/test-setup.d.ts +1 -0
  118. package/dist/admin/src/test-utils.d.ts +5 -0
  119. package/dist/server/index.js +2408 -1261
  120. package/dist/server/index.mjs +2415 -1267
  121. package/dist/server/src/bootstrap.d.ts +1 -1
  122. package/dist/server/src/content-types/index.d.ts +66 -1
  123. package/dist/server/src/content-types/template/index.d.ts +65 -0
  124. package/dist/server/src/content-types/template/schema.d.ts +69 -0
  125. package/dist/server/src/controllers/config.d.ts +2 -0
  126. package/dist/server/src/controllers/controller.d.ts +0 -5
  127. package/dist/server/src/controllers/image-studio.d.ts +23 -0
  128. package/dist/server/src/controllers/index.d.ts +128 -5
  129. package/dist/server/src/controllers/templates.d.ts +26 -0
  130. package/dist/server/src/image-studio/geminiConfig.d.ts +40 -0
  131. package/dist/server/src/image-studio/models.d.ts +38 -0
  132. package/dist/server/src/image-studio/prompt.d.ts +7 -0
  133. package/dist/server/src/image-studio/validate.d.ts +41 -0
  134. package/dist/server/src/index.d.ts +229 -75
  135. package/dist/server/src/routes/admin.d.ts +6 -2
  136. package/dist/server/src/routes/content-api.d.ts +4 -9
  137. package/dist/server/src/routes/index.d.ts +7 -11
  138. package/dist/server/src/routes/policies.d.ts +14 -0
  139. package/dist/server/src/services/image-studio.d.ts +62 -0
  140. package/dist/server/src/services/index.d.ts +27 -57
  141. package/dist/server/src/services/service.d.ts +0 -57
  142. package/dist/server/src/services/templates.d.ts +81 -0
  143. package/dist/server/src/templates/folders.d.ts +14 -0
  144. package/dist/server/src/templates/validate.d.ts +23 -0
  145. package/dist/server/src/utils/folders.d.ts +15 -0
  146. package/dist/server/src/utils/secrets.d.ts +9 -0
  147. package/package.json +22 -10
  148. package/static/background-worker.d.mts +15 -0
  149. package/static/background-worker.mjs +87 -0
  150. package/dist/_chunks/Settings-BrqTzJp-.js +0 -262
  151. package/dist/_chunks/Settings-CdZnYLLK.mjs +0 -244
  152. package/dist/admin/src/components/Navigation.d.ts +0 -2
  153. package/dist/admin/src/components/generate-image/Form.d.ts +0 -15
  154. package/dist/admin/src/components/generate-images/Image.d.ts +0 -5
  155. package/dist/admin/src/components/generate-images/Images.d.ts +0 -2
  156. package/dist/admin/src/components/generate-images/Modal.d.ts +0 -9
  157. package/dist/admin/src/containers/generate-image/index.d.ts +0 -2
  158. package/dist/admin/src/containers/generate-images/index.d.ts +0 -2
  159. package/dist/admin/src/hooks/generate-images/useImages.d.ts +0 -12
  160. package/dist/admin/src/pages/GenerateImage.d.ts +0 -2
  161. package/dist/admin/src/pages/GenerateImages.d.ts +0 -2
@@ -2,14 +2,15 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const admin = require("@strapi/strapi/admin");
5
- const designSystem = require("@strapi/design-system");
6
5
  const reactRouterDom = require("react-router-dom");
7
- const index = require("./index-DGPqyrzz.js");
6
+ const ImageStudioTabs = require("./ImageStudioTabs-B2UbKYq7.js");
8
7
  const reactIntl = require("react-intl");
9
8
  const react = require("react");
9
+ const designSystem = require("@strapi/design-system");
10
10
  const reactRedux = require("react-redux");
11
+ const index = require("./index-Ddp0Qvqo.js");
11
12
  const icons = require("@strapi/icons");
12
- const getTranslation = require("./getTranslation-DNhP1INv.js");
13
+ const getTranslation = require("./getTranslation-D88uLXGd.js");
13
14
  const formik = require("formik");
14
15
  const Yup = require("yup");
15
16
  function _interopNamespace(e) {
@@ -30,51 +31,6 @@ function _interopNamespace(e) {
30
31
  return Object.freeze(n);
31
32
  }
32
33
  const Yup__namespace = /* @__PURE__ */ _interopNamespace(Yup);
33
- const links = [
34
- {
35
- label: "Generador de contenido con IA",
36
- required: "access",
37
- subLinks: [
38
- {
39
- id: 1,
40
- label: "Generador de contenido",
41
- to: "/admin/plugins/strapi-content-generator-gemini",
42
- required: "access"
43
- },
44
- {
45
- id: 2,
46
- label: "Generador de imágenes",
47
- to: "/admin/plugins/strapi-content-generator-gemini/generate-images",
48
- required: "access"
49
- }
50
- ]
51
- }
52
- ];
53
- const Navigation = () => {
54
- const location = reactRouterDom.useLocation();
55
- const { allowedActions, isLoading } = admin.useRBAC(index.pluginPermissions);
56
- if (isLoading) return null;
57
- const canAccess = (required) => {
58
- if (!required) return true;
59
- if (required === "access") return allowedActions.canAccess;
60
- return false;
61
- };
62
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SubNav, { "aria-label": "Generador de contenido SubNav", children: [
63
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SubNavHeader, { label: "MKT" }),
64
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SubNavSections, { children: links.filter((section) => canAccess(section.required)).map(({ label, subLinks }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SubNavSection, { label, children: subLinks.filter((subLink) => canAccess(subLink.required)).map((subLink) => {
65
- const active = location.pathname === subLink.to.replace(/^\/admin/, "");
66
- return /* @__PURE__ */ jsxRuntime.jsx(
67
- designSystem.SubNavLink,
68
- {
69
- href: subLink.to,
70
- active,
71
- children: subLink.label
72
- },
73
- subLink.id
74
- );
75
- }) }, label)) })
76
- ] });
77
- };
78
34
  const useDialog = (id) => {
79
35
  const dispatch = reactRedux.useDispatch();
80
36
  const state = reactRedux.useSelector((state2) => state2.content_generator_commonDialog.open[id] ?? false);
@@ -588,7 +544,7 @@ const useUsers = () => {
588
544
  getUsers
589
545
  };
590
546
  };
591
- const validationSchema$2 = Yup__namespace.object().shape({
547
+ const validationSchema$1 = Yup__namespace.object().shape({
592
548
  titulo: Yup__namespace.string().notRequired(),
593
549
  autor: Yup__namespace.string().required("Este campo es obligatorio"),
594
550
  categoria: Yup__namespace.string().required("Este campo es obligatorio"),
@@ -602,10 +558,10 @@ const initialValues$1 = {
602
558
  temperatura: "0.5",
603
559
  instrucciones: ""
604
560
  };
605
- const Form$2 = ({ onSubmit, categorias, users }) => {
561
+ const Form$1 = ({ onSubmit, categorias, users }) => {
606
562
  const formik$1 = formik.useFormik({
607
563
  initialValues: initialValues$1,
608
- validationSchema: validationSchema$2,
564
+ validationSchema: validationSchema$1,
609
565
  onSubmit
610
566
  });
611
567
  const { values, errors, touched, isValid, dirty, isSubmitting, handleChange, setFieldValue, handleSubmit } = formik$1;
@@ -863,7 +819,7 @@ const GenerateContentContainer = () => {
863
819
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", children: "Para uso exclusivo de InterWare de México" })
864
820
  ] }) }),
865
821
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { m: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { alignItems: "end", width: "100%", justifyContent: "end", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.LinkButton, { href: "/admin/plugins/strapi-content-generator-gemini", children: "Regresar" }) }) }),
866
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2, { categorias, users, onSubmit }) })
822
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$1, { categorias, users, onSubmit }) })
867
823
  ] })
868
824
  ] });
869
825
  };
@@ -873,649 +829,6 @@ const GenerateContent = () => {
873
829
  /* @__PURE__ */ jsxRuntime.jsx(GenerateContentContainer, {})
874
830
  ] });
875
831
  };
876
- const useImages$1 = () => {
877
- const { get, del, post } = admin.useFetchClient();
878
- const getImages = react.useCallback(
879
- async () => {
880
- return await get("/strapi-content-generator-gemini/images");
881
- },
882
- [get]
883
- );
884
- const deleteImage = react.useCallback(
885
- async (config) => {
886
- return await del("/strapi-content-generator-gemini/delete-image", config);
887
- },
888
- [del]
889
- );
890
- const generateImageWithConfig = react.useCallback(
891
- async (data, config) => {
892
- return await post("/strapi-content-generator-gemini/generate-image-with-config", data, config);
893
- },
894
- [post]
895
- );
896
- const generateVideoWithScenes = react.useCallback(
897
- async (data, config) => {
898
- return await post("/strapi-content-generator-gemini/generate-video-with-scenes", data, config);
899
- },
900
- [post]
901
- );
902
- return {
903
- getImages,
904
- deleteImage,
905
- generateImageWithConfig,
906
- generateVideoWithScenes
907
- };
908
- };
909
- const PRINCIPAL_KEY = "principal";
910
- const ModalImagesSizes = ({
911
- open,
912
- setOpen,
913
- image,
914
- handleDownload
915
- }) => {
916
- const [selectedImages, setSelectedImages] = react.useState(
917
- () => /* @__PURE__ */ new Set()
918
- );
919
- const formats = react.useMemo(
920
- () => Object.entries(image?.formats ?? {}),
921
- [image?.formats]
922
- );
923
- const toggleImageSelection = react.useCallback((key) => {
924
- setSelectedImages((prev) => {
925
- const next = new Set(prev);
926
- next.has(key) ? next.delete(key) : next.add(key);
927
- return next;
928
- });
929
- }, []);
930
- const isPrincipalSelected = react.useMemo(
931
- () => selectedImages.has(PRINCIPAL_KEY),
932
- [selectedImages]
933
- );
934
- const isDownloadDisabled = react.useMemo(
935
- () => selectedImages.size === 0,
936
- [selectedImages]
937
- );
938
- const handleClose = react.useCallback(() => {
939
- setOpen(false);
940
- }, [setOpen]);
941
- react.useEffect(() => {
942
- if (!open) {
943
- setSelectedImages(/* @__PURE__ */ new Set());
944
- }
945
- }, [open]);
946
- if (!image) return null;
947
- return /* @__PURE__ */ jsxRuntime.jsx(
948
- designSystem.Modal.Root,
949
- {
950
- id: "modal-image-formats",
951
- open,
952
- onOpenChange: handleClose,
953
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
954
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: "Descargar imágenes" }) }),
955
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 3, children: [
956
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { m: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(
957
- designSystem.Card,
958
- {
959
- id: "modal-principal",
960
- onClick: () => toggleImageSelection(PRINCIPAL_KEY),
961
- children: [
962
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardHeader, { children: [
963
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardCheckbox, { checked: isPrincipalSelected }),
964
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardAsset, { src: image.url })
965
- ] }),
966
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardBody, { children: [
967
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardContent, { children: [
968
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardTitle, { children: "Principal" }),
969
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardSubtitle, { children: `${image.width}x${image.height}` })
970
- ] }),
971
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardBadge, { children: image.mime })
972
- ] })
973
- ]
974
- }
975
- ) }),
976
- formats.map(([format, img]) => {
977
- const isSelected = selectedImages.has(format);
978
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { m: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(
979
- designSystem.Card,
980
- {
981
- id: `modal-${format}`,
982
- onClick: () => toggleImageSelection(format),
983
- children: [
984
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardHeader, { children: [
985
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardCheckbox, { checked: isSelected }),
986
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardAsset, { src: img.url })
987
- ] }),
988
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardBody, { children: [
989
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardContent, { children: [
990
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardTitle, { children: format }),
991
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardSubtitle, { children: `${img.width}x${img.height}` })
992
- ] }),
993
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardBadge, { children: image.mime })
994
- ] })
995
- ]
996
- }
997
- ) }, format);
998
- })
999
- ] }) }),
1000
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
1001
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: handleClose, children: "Cancelar" }) }),
1002
- /* @__PURE__ */ jsxRuntime.jsx(
1003
- designSystem.Button,
1004
- {
1005
- disabled: isDownloadDisabled,
1006
- onClick: () => {
1007
- handleDownload(selectedImages);
1008
- },
1009
- children: "Descargar"
1010
- }
1011
- )
1012
- ] })
1013
- ] })
1014
- }
1015
- );
1016
- };
1017
- const ImagesContext = react.createContext(void 0);
1018
- const ImagesProvider = ({ children }) => {
1019
- const { getImages, deleteImage } = useImages$1();
1020
- const { openDialog, closeDialog } = useDialog("dialog-delete-image");
1021
- const { formatMessage } = reactIntl.useIntl();
1022
- const { toggleNotification } = admin.useNotification();
1023
- const { post } = admin.useFetchClient();
1024
- const [images, setImages] = react.useState([]);
1025
- const [downloadingId, setDownloadingId] = react.useState(null);
1026
- const [open, setOpen] = react.useState(false);
1027
- const currentImageRef = react.useRef();
1028
- const fetchImages = react.useCallback(async () => {
1029
- let isMounted = true;
1030
- try {
1031
- const { data } = await getImages();
1032
- if (isMounted) {
1033
- setImages(data);
1034
- }
1035
- } catch (error) {
1036
- console.error("Error fetching images:", error);
1037
- }
1038
- return () => {
1039
- isMounted = false;
1040
- };
1041
- }, [getImages]);
1042
- const handleDeleteImage = async () => {
1043
- closeDialog();
1044
- try {
1045
- await deleteImage({ params: { documentId: currentImageRef.current?.documentId } });
1046
- toggleNotification({
1047
- type: "success",
1048
- message: formatMessage({
1049
- id: `${index.PLUGIN_ID}.config.load.error`,
1050
- defaultMessage: "Imagen eliminada con éxito"
1051
- })
1052
- });
1053
- fetchImages();
1054
- } catch (err) {
1055
- toggleNotification({
1056
- type: "danger",
1057
- message: formatMessage({
1058
- id: `${index.PLUGIN_ID}.config.load.error`,
1059
- defaultMessage: "Ocurrió un error al eliminar la imagen"
1060
- })
1061
- });
1062
- }
1063
- };
1064
- const onCancelAction = react.useCallback((action) => {
1065
- switch (action) {
1066
- case "delete":
1067
- closeDialog();
1068
- break;
1069
- case "download":
1070
- setOpen(false);
1071
- break;
1072
- default:
1073
- return;
1074
- }
1075
- currentImageRef.current = void 0;
1076
- closeDialog();
1077
- }, [openDialog]);
1078
- const onClickAction = react.useCallback((image, action) => {
1079
- currentImageRef.current = image;
1080
- switch (action) {
1081
- case "delete":
1082
- openDialog();
1083
- break;
1084
- case "download":
1085
- setOpen(true);
1086
- break;
1087
- default:
1088
- return;
1089
- }
1090
- }, [openDialog, setOpen]);
1091
- const downloadImage = async (url, filename) => {
1092
- if (!url) return;
1093
- const absoluteUrl = url.startsWith("/uploads") ? `${window.location.origin}${url}` : url;
1094
- try {
1095
- const { data } = await post(
1096
- "/strapi-content-generator-gemini/download-file",
1097
- { url: absoluteUrl }
1098
- );
1099
- const { base64, contentType } = data;
1100
- const binary = atob(base64);
1101
- const bytes = new Uint8Array(binary.length);
1102
- for (let i = 0; i < binary.length; i++) {
1103
- bytes[i] = binary.charCodeAt(i);
1104
- }
1105
- const blob = new Blob([bytes], { type: contentType });
1106
- const blobUrl = window.URL.createObjectURL(blob);
1107
- const link = document.createElement("a");
1108
- link.href = blobUrl;
1109
- link.download = filename;
1110
- document.body.appendChild(link);
1111
- link.click();
1112
- document.body.removeChild(link);
1113
- window.URL.revokeObjectURL(blobUrl);
1114
- } catch (error) {
1115
- console.error("Download error:", error);
1116
- const link = document.createElement("a");
1117
- link.href = absoluteUrl;
1118
- link.target = "_blank";
1119
- link.rel = "noopener noreferrer";
1120
- document.body.appendChild(link);
1121
- link.click();
1122
- document.body.removeChild(link);
1123
- }
1124
- };
1125
- const handleDownload = async (selectedKeys) => {
1126
- const image = currentImageRef.current;
1127
- if (!image) return;
1128
- setOpen(false);
1129
- setDownloadingId(image.documentId);
1130
- try {
1131
- const keys = Array.isArray(selectedKeys) ? selectedKeys : Array.from(selectedKeys);
1132
- const extension = image.ext?.replace(".", "") ?? "jpg";
1133
- const formats = image.formats;
1134
- const items = keys.map((key) => {
1135
- if (key === "principal") {
1136
- return {
1137
- url: image.url,
1138
- filename: `image-principal-${image.documentId}.${extension}`
1139
- };
1140
- }
1141
- const formatImage = formats?.[key];
1142
- if (!formatImage) return null;
1143
- return {
1144
- url: formatImage.url,
1145
- filename: `image-${key}-${image.documentId}.${extension}`
1146
- };
1147
- }).filter(Boolean);
1148
- for (const item of items) {
1149
- await downloadImage(item.url, item.filename);
1150
- }
1151
- } finally {
1152
- setDownloadingId(null);
1153
- }
1154
- };
1155
- react.useEffect(() => {
1156
- fetchImages();
1157
- }, [fetchImages]);
1158
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1159
- currentImageRef.current && /* @__PURE__ */ jsxRuntime.jsx(
1160
- ModalImagesSizes,
1161
- {
1162
- open,
1163
- setOpen,
1164
- image: currentImageRef.current,
1165
- handleDownload
1166
- }
1167
- ),
1168
- /* @__PURE__ */ jsxRuntime.jsx(
1169
- DialogCommon,
1170
- {
1171
- title: "Eliminar imagen",
1172
- id: "dialog-delete-image",
1173
- onConfirmAction: handleDeleteImage,
1174
- onCancelAction: () => onCancelAction("delete"),
1175
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", justifyContent: "center", children: [
1176
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: "¿Seguro que deseas eliminar esta imagen?" }),
1177
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", children: "Esta acción es irreversible" })
1178
- ] })
1179
- }
1180
- ),
1181
- /* @__PURE__ */ jsxRuntime.jsx(ImagesContext.Provider, { value: { images, downloadingId, onClickAction }, children })
1182
- ] });
1183
- };
1184
- const useImages = () => {
1185
- const context = react.useContext(ImagesContext);
1186
- if (!context) {
1187
- throw new Error("useImages must be used within an ImagesProvider");
1188
- }
1189
- return context;
1190
- };
1191
- const Image = ({ image }) => {
1192
- const { onClickAction, downloadingId } = useImages();
1193
- const isDownloading = downloadingId === image.documentId;
1194
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Card, { id: image.id, children: [
1195
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardHeader, { children: [
1196
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardAction, { position: "end", children: [
1197
- /* @__PURE__ */ jsxRuntime.jsx(
1198
- designSystem.IconButton,
1199
- {
1200
- label: "Descargar",
1201
- disabled: isDownloading,
1202
- onClick: () => {
1203
- onClickAction(image, "download");
1204
- },
1205
- children: isDownloading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true }) : /* @__PURE__ */ jsxRuntime.jsx(icons.Download, {})
1206
- }
1207
- ),
1208
- /* @__PURE__ */ jsxRuntime.jsx(
1209
- designSystem.IconButton,
1210
- {
1211
- label: "Eliminar",
1212
- onClick: () => {
1213
- onClickAction(image, "delete");
1214
- },
1215
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {})
1216
- }
1217
- )
1218
- ] }),
1219
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardAsset, { src: image.url, style: { borderTopLeftRadius: "4px", borderTopRightRadius: "4px" } })
1220
- ] }),
1221
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardBody, { children: [
1222
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardContent, { children: [
1223
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardTitle, { children: `${image.caption?.replace("generada por IA", "").slice(0, 80)}...` }),
1224
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardSubtitle, { children: `${image.width}X${image.height}` })
1225
- ] }),
1226
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardBadge, { children: image.mime })
1227
- ] })
1228
- ] });
1229
- };
1230
- const Images = () => {
1231
- const { images } = useImages();
1232
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral0", padding: 6, margin: 6, width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 3, children: images.map((image) => {
1233
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { m: 3, children: /* @__PURE__ */ jsxRuntime.jsx(Image, { image }) }, image.id);
1234
- }) }) });
1235
- };
1236
- const GenerateImagesContainer = () => {
1237
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(ImagesProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { padding: 6, children: [
1238
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "start", children: [
1239
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", children: "Generar imagenes y videos con IA" }),
1240
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", children: "Para uso exclusivo de InterWare de México" })
1241
- ] }) }),
1242
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { m: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "end", alignItems: "end", gap: 3, width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.LinkButton, { href: "/admin/plugins/strapi-content-generator-gemini/generate-image", children: "Generar nueva imagen" }) }) }),
1243
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Images, {}) })
1244
- ] }) }) });
1245
- };
1246
- const GenerateImages = () => {
1247
- return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
1248
- /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Title, { children: "Generar imagenes con IA" }),
1249
- /* @__PURE__ */ jsxRuntime.jsx(GenerateImagesContainer, {})
1250
- ] });
1251
- };
1252
- const aspectRatioOptions = [
1253
- { value: "1:1", label: "1:1 (Cuadrado)" },
1254
- { value: "2:3", label: "2:3 Rectangular (vertical)" },
1255
- { value: "3:2", label: "3:2 Rectangular (horizontal)" },
1256
- { value: "3:4", label: "3:4 Rectangular (vertical)" },
1257
- { value: "4:3", label: "4:3 Rectangular (horizontal)" },
1258
- { value: "9:16", label: "9:16 Rectangular (vertical)" },
1259
- { value: "16:9", label: "16:9 Rectangular (horizontal)" },
1260
- { value: "21:9", label: "21:9 Rectangular (horizontal)" }
1261
- ];
1262
- const validationSchema$1 = Yup__namespace.object({
1263
- prompt: Yup__namespace.string().required("El prompt es requerido"),
1264
- aspectRatio: Yup__namespace.string().required("La relación de aspecto es requerida"),
1265
- imageSize: Yup__namespace.string().required("El tamaño de la imagen es requerido")
1266
- });
1267
- const Form$1 = ({ onSubmit }) => {
1268
- const [referenceImages, setReferenceImages] = react.useState([]);
1269
- const individualFileInputRefs = react.useRef({});
1270
- const newImageFileInputRef = react.useRef(null);
1271
- const formik$1 = formik.useFormik({
1272
- initialValues: {
1273
- prompt: "",
1274
- aspectRatio: "16:9",
1275
- imageSize: "1K"
1276
- },
1277
- validationSchema: validationSchema$1,
1278
- onSubmit: (values, formikHelpers) => onSubmit({ ...values }, formikHelpers, referenceImages)
1279
- });
1280
- const handleAddImage = () => {
1281
- newImageFileInputRef.current?.click();
1282
- };
1283
- const handleRemoveImage = (id) => {
1284
- const imageToRemove = referenceImages.find((img) => img.id === id);
1285
- if (imageToRemove?.previewUrl) {
1286
- URL.revokeObjectURL(imageToRemove.previewUrl);
1287
- }
1288
- setReferenceImages(referenceImages.filter((image) => image.id !== id));
1289
- };
1290
- const handleNewImageFileChange = (e) => {
1291
- const selectedFile = e.target.files?.[0];
1292
- if (selectedFile) {
1293
- setReferenceImages((prevImages) => [
1294
- ...prevImages,
1295
- { id: Date.now(), file: selectedFile, previewUrl: URL.createObjectURL(selectedFile) }
1296
- ]);
1297
- }
1298
- e.target.value = "";
1299
- };
1300
- const handleIndividualFileChange = (id, selectedFile) => {
1301
- setReferenceImages((prevImages) => prevImages.map((image) => {
1302
- if (image.id === id) {
1303
- if (image.previewUrl) {
1304
- URL.revokeObjectURL(image.previewUrl);
1305
- }
1306
- if (selectedFile) {
1307
- return { ...image, file: selectedFile, previewUrl: URL.createObjectURL(selectedFile) };
1308
- } else {
1309
- const { file, previewUrl, ...rest } = image;
1310
- return rest;
1311
- }
1312
- }
1313
- return image;
1314
- }));
1315
- };
1316
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral0", padding: 6, hasRadius: true, width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit: formik$1.handleSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 4, children: [
1317
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { m: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(
1318
- designSystem.Field.Root,
1319
- {
1320
- id: "prompt",
1321
- width: "100%",
1322
- required: true,
1323
- error: formik$1.touched.prompt && formik$1.errors.prompt ? formik$1.errors.prompt : void 0,
1324
- children: [
1325
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Descripción de la imagen" }),
1326
- /* @__PURE__ */ jsxRuntime.jsx(
1327
- designSystem.Textarea,
1328
- {
1329
- name: "prompt",
1330
- placeholder: "Ej: Una superficie paramétrica 3D con forma de cinta que se tuerce sobre sí misma, flotando sobre un fondo gradiente oscuro. Evoca integración y continuidad de sistemas.",
1331
- onChange: formik$1.handleChange,
1332
- onBlur: formik$1.handleBlur,
1333
- value: formik$1.values.prompt,
1334
- rows: 5
1335
- }
1336
- ),
1337
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, { children: "Describe qué quieres ver — forma, movimiento, atmósfera. El estilo de marca (colores, materiales, iluminación) se aplica automáticamente." }),
1338
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
1339
- ]
1340
- }
1341
- ) }),
1342
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { m: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(
1343
- designSystem.Field.Root,
1344
- {
1345
- id: "imagen-referencia",
1346
- width: "100%",
1347
- children: [
1348
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Imagen(es) de referencia" }),
1349
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, width: "100%", children: [
1350
- referenceImages.map((image) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral100", padding: 3, hasRadius: true, width: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 3, width: "100%", children: [
1351
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "primary100", padding: 1, children: image.previewUrl ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: image.previewUrl, alt: "preview", style: { width: "50px", height: "50px", objectFit: "cover" } }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: { width: "50px", height: "50px", backgroundColor: "#ccc" } }) }),
1352
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { flexGrow: 2 }, children: [
1353
- /* @__PURE__ */ jsxRuntime.jsx(
1354
- "input",
1355
- {
1356
- type: "file",
1357
- accept: "image/*",
1358
- "aria-label": `Reemplazar imagen de referencia ${image.id}`,
1359
- ref: (el) => individualFileInputRefs.current[image.id] = el,
1360
- style: { display: "none" },
1361
- onChange: (e) => handleIndividualFileChange(image.id, e.target.files?.[0])
1362
- }
1363
- ),
1364
- /* @__PURE__ */ jsxRuntime.jsx(
1365
- designSystem.Button,
1366
- {
1367
- onClick: () => individualFileInputRefs.current[image.id]?.click(),
1368
- startIcon: image.file ? void 0 : /* @__PURE__ */ jsxRuntime.jsx(icons.PlusCircle, {}),
1369
- variant: "secondary",
1370
- fullWidth: true,
1371
- children: image.file ? image.file.name : "Seleccionar archivo"
1372
- }
1373
- )
1374
- ] }),
1375
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { onClick: () => handleRemoveImage(image.id), label: "Eliminar imagen", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}) })
1376
- ] }) }, image.id)),
1377
- /* @__PURE__ */ jsxRuntime.jsx(
1378
- "input",
1379
- {
1380
- type: "file",
1381
- accept: "image/*",
1382
- "aria-label": "Añadir imagen de referencia",
1383
- ref: newImageFileInputRef,
1384
- style: { display: "none" },
1385
- onChange: handleNewImageFileChange
1386
- }
1387
- ),
1388
- /* @__PURE__ */ jsxRuntime.jsx(
1389
- designSystem.Button,
1390
- {
1391
- startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusCircle, {}),
1392
- variant: "secondary",
1393
- fullWidth: true,
1394
- onClick: handleAddImage,
1395
- disabled: referenceImages.length >= 5,
1396
- children: "Añadir imagen de referencia"
1397
- }
1398
- )
1399
- ] }),
1400
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {}),
1401
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
1402
- ]
1403
- }
1404
- ) }),
1405
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { m: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(
1406
- designSystem.Field.Root,
1407
- {
1408
- id: "aspectRatio",
1409
- width: "100%",
1410
- required: true,
1411
- children: [
1412
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Relación de aspecto" }),
1413
- /* @__PURE__ */ jsxRuntime.jsx(
1414
- designSystem.Combobox,
1415
- {
1416
- name: "aspectRatio",
1417
- onChange: (value) => formik$1.setFieldValue("aspectRatio", value),
1418
- onBlur: () => formik$1.setFieldTouched("aspectRatio", true),
1419
- value: formik$1.values.aspectRatio,
1420
- onClear: () => formik$1.setFieldValue("aspectRatio", ""),
1421
- children: aspectRatioOptions.map((option) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: option.value, children: option.label }, option.value))
1422
- }
1423
- )
1424
- ]
1425
- }
1426
- ) }),
1427
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { m: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(
1428
- designSystem.Field.Root,
1429
- {
1430
- id: "imageSize",
1431
- error: formik$1.touched.imageSize && formik$1.errors.imageSize ? formik$1.errors.imageSize : void 0,
1432
- width: "100%",
1433
- required: true,
1434
- children: [
1435
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Tamaño de la imagen" }),
1436
- /* @__PURE__ */ jsxRuntime.jsxs(
1437
- designSystem.Combobox,
1438
- {
1439
- name: "imageSize",
1440
- onChange: (value) => formik$1.setFieldValue("imageSize", value),
1441
- onBlur: () => formik$1.setFieldTouched("imageSize", true),
1442
- value: formik$1.values.imageSize,
1443
- onClear: () => formik$1.setFieldValue("imageSize", ""),
1444
- children: [
1445
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: "1K", children: "1K" }),
1446
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: "2K", children: "2K" }),
1447
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: "4K", children: "4K" })
1448
- ]
1449
- }
1450
- ),
1451
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, { children: formik$1.errors.imageSize })
1452
- ]
1453
- }
1454
- ) }),
1455
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { width: "100%", justifyContent: "end", alignItems: "end", children: /* @__PURE__ */ jsxRuntime.jsx(
1456
- designSystem.Button,
1457
- {
1458
- type: "submit",
1459
- fullWidth: true,
1460
- disabled: !(formik$1.isValid && formik$1.dirty) || formik$1.isSubmitting,
1461
- loading: formik$1.isSubmitting,
1462
- children: "Generar imagen"
1463
- }
1464
- ) }) })
1465
- ] }) }) });
1466
- };
1467
- const GenerateImageContainer = () => {
1468
- const { toggleNotification } = admin.useNotification();
1469
- const { generateImageWithConfig } = useImages$1();
1470
- const { formatMessage } = reactIntl.useIntl();
1471
- const handleSubmit = async (values, { setSubmitting }, referenceImages) => {
1472
- try {
1473
- const formData = new FormData();
1474
- formData.append("prompt", values.prompt);
1475
- formData.append("aspectRatio", values.aspectRatio);
1476
- formData.append("imageSize", values.imageSize);
1477
- referenceImages.forEach((img, index2) => {
1478
- if (img.file) {
1479
- formData.append(`referenceImages[${index2}]`, img.file);
1480
- }
1481
- });
1482
- const response = await generateImageWithConfig(formData);
1483
- toggleNotification({
1484
- type: "success",
1485
- message: formatMessage({
1486
- id: `${index.PLUGIN_ID}.config.load.success`,
1487
- defaultMessage: "Imagen generada con éxito"
1488
- })
1489
- });
1490
- } catch (error) {
1491
- toggleNotification({
1492
- type: "danger",
1493
- message: formatMessage({
1494
- id: `${index.PLUGIN_ID}.config.load.error`,
1495
- defaultMessage: "Ocurrió un error al generar la imagen"
1496
- })
1497
- });
1498
- } finally {
1499
- setSubmitting(false);
1500
- }
1501
- };
1502
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1503
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { padding: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "start", children: [
1504
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", children: "Generar imagen con IA" }),
1505
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", children: "Para uso exclusivo de InterWare de México" })
1506
- ] }) }) }),
1507
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { padding: 6, children: [
1508
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { m: 2 }),
1509
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { m: 8, children: /* @__PURE__ */ jsxRuntime.jsx(Form$1, { onSubmit: handleSubmit }) })
1510
- ] })
1511
- ] });
1512
- };
1513
- const GenerateImage = () => {
1514
- return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
1515
- /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Title, { children: "Generar imagen con IA" }),
1516
- /* @__PURE__ */ jsxRuntime.jsx(GenerateImageContainer, {})
1517
- ] });
1518
- };
1519
832
  const sceneSchema = Yup__namespace.object().shape({
1520
833
  prompt: Yup__namespace.string().trim().required("El prompt es obligatorio para esta escena"),
1521
834
  durationSeconds: Yup__namespace.number().min(1, "La duración mínima es 1 segundo").max(90, "La duración máxima es 90 segundos").required("La duración es obligatoria"),
@@ -1704,9 +1017,21 @@ const Form = ({ onSubmit }) => {
1704
1017
  ) }) })
1705
1018
  ] }) }) });
1706
1019
  };
1020
+ const useImages = () => {
1021
+ const { post } = admin.useFetchClient();
1022
+ const generateVideoWithScenes = react.useCallback(
1023
+ async (data, config) => {
1024
+ return await post("/strapi-content-generator-gemini/generate-video-with-scenes", data, config);
1025
+ },
1026
+ [post]
1027
+ );
1028
+ return {
1029
+ generateVideoWithScenes
1030
+ };
1031
+ };
1707
1032
  const GenerateVideoContainer = () => {
1708
1033
  const { toggleNotification } = admin.useNotification();
1709
- const { generateVideoWithScenes } = useImages$1();
1034
+ const { generateVideoWithScenes } = useImages();
1710
1035
  const { formatMessage } = reactIntl.useIntl();
1711
1036
  const handleSubmit = async (values, { setSubmitting }) => {
1712
1037
  try {
@@ -1765,29 +1090,15 @@ const App = () => {
1765
1090
  if (isLoading) {
1766
1091
  return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {});
1767
1092
  }
1768
- return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: [...index.pluginPermissions.access], children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.DesignSystemProvider, { locale: "es-MX", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
1769
- "div",
1770
- {
1771
- style: {
1772
- display: "grid",
1773
- gridTemplateColumns: "auto 1fr",
1774
- width: "100%",
1775
- height: "100vh"
1776
- },
1777
- children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1778
- /* @__PURE__ */ jsxRuntime.jsx(Navigation, {}),
1779
- /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
1780
- allowedActions.canAccess && /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { index: true, element: /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) }),
1781
- allowedActions.canAccess && /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/generate-content", element: /* @__PURE__ */ jsxRuntime.jsx(GenerateContent, {}) }),
1782
- allowedActions.canAccess && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1783
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/generate-images", element: /* @__PURE__ */ jsxRuntime.jsx(GenerateImages, {}) }),
1784
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/generate-image", element: /* @__PURE__ */ jsxRuntime.jsx(GenerateImage, {}) }),
1785
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/generate-video", element: /* @__PURE__ */ jsxRuntime.jsx(GenerateVideo, {}) })
1786
- ] }),
1787
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "*", element: /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {}) })
1788
- ] })
1789
- ] })
1790
- }
1791
- ) }) }) });
1093
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: [...index.pluginPermissions.access], children: /* @__PURE__ */ jsxRuntime.jsx(ImageStudioTabs.PluginProviders, { children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
1094
+ allowedActions.canAccess && /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { index: true, element: /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) }),
1095
+ allowedActions.canAccess && /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/generate-content", element: /* @__PURE__ */ jsxRuntime.jsx(GenerateContent, {}) }),
1096
+ allowedActions.canAccess && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1097
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/image-studio", element: /* @__PURE__ */ jsxRuntime.jsx(ImageStudioTabs.StudioRedirect, {}) }),
1098
+ ImageStudioTabs.LEGACY_ROUTES.map((r) => /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: r.path, element: ImageStudioTabs.legacyRedirect(r.tab) }, r.path)),
1099
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/generate-video", element: /* @__PURE__ */ jsxRuntime.jsx(GenerateVideo, {}) })
1100
+ ] }),
1101
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "*", element: /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {}) })
1102
+ ] }) }) });
1792
1103
  };
1793
1104
  exports.App = App;