@8wave/ai-elements 0.125.0-beta.26 → 0.125.0-beta.28

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 (121) hide show
  1. package/dist/_chunks/{PkChatbotFilePreview-CFGqa-tX.js → PkChatbotFilePreview-CqxtVySb.js} +100 -59
  2. package/dist/_chunks/PkChatbotFilePreview-CqxtVySb.js.map +1 -0
  3. package/dist/_chunks/{PkFilePreview-BPsD2P7s.js → PkFilePreview-DiLMoL-6.js} +32 -32
  4. package/dist/_chunks/{PkFilePreview-BPsD2P7s.js.map → PkFilePreview-DiLMoL-6.js.map} +1 -1
  5. package/dist/_chunks/{PkFilePreviewDialog-BW-Rubk2.js → PkFilePreviewDialog-CHBtxpoB.js} +2 -2
  6. package/dist/_chunks/{PkFilePreviewDialog-BW-Rubk2.js.map → PkFilePreviewDialog-CHBtxpoB.js.map} +1 -1
  7. package/dist/_chunks/PkImageEditorDialog-Cq8y_PtC.js +555 -0
  8. package/dist/_chunks/PkImageEditorDialog-Cq8y_PtC.js.map +1 -0
  9. package/dist/_chunks/{PkSelectionActions-DkETXtSL.js → PkSelectionActions-DFyvcEyl.js} +2 -2
  10. package/dist/_chunks/{PkSelectionActions-DkETXtSL.js.map → PkSelectionActions-DFyvcEyl.js.map} +1 -1
  11. package/dist/_chunks/{PkStreamingMarkdown-CqLpNWQv.js → PkStreamingMarkdown-0hE_Cx4W.js} +2 -2
  12. package/dist/_chunks/{PkStreamingMarkdown-CqLpNWQv.js.map → PkStreamingMarkdown-0hE_Cx4W.js.map} +1 -1
  13. package/dist/_chunks/{PkToolChatFile-iE4ZokYD.js → PkToolChatFile-DtQ9xY4w.js} +3 -3
  14. package/dist/_chunks/{PkToolChatFile-iE4ZokYD.js.map → PkToolChatFile-DtQ9xY4w.js.map} +1 -1
  15. package/dist/_chunks/{PkToolShareDocument-lTHNZodf.js → PkToolShareDocument-BvHklbzb.js} +2 -2
  16. package/dist/_chunks/{PkToolShareDocument-lTHNZodf.js.map → PkToolShareDocument-BvHklbzb.js.map} +1 -1
  17. package/dist/_chunks/{PkToolShowArtifact-BNQrM5fY.js → PkToolShowArtifact-BdkKU6P1.js} +2 -2
  18. package/dist/_chunks/{PkToolShowArtifact-BNQrM5fY.js.map → PkToolShowArtifact-BdkKU6P1.js.map} +1 -1
  19. package/dist/_chunks/{PkToolShowContactForm-CvQoLumn.js → PkToolShowContactForm-BmM2MbOK.js} +2 -2
  20. package/dist/_chunks/{PkToolShowContactForm-CvQoLumn.js.map → PkToolShowContactForm-BmM2MbOK.js.map} +1 -1
  21. package/dist/_chunks/{PkToolShowForm-DcPccCEU.js → PkToolShowForm-CoFlgA-I.js} +3 -3
  22. package/dist/_chunks/{PkToolShowForm-DcPccCEU.js.map → PkToolShowForm-CoFlgA-I.js.map} +1 -1
  23. package/dist/_chunks/{PkToolShowSources-B3VpJBVE.js → PkToolShowSources-DDBlLBt6.js} +2 -2
  24. package/dist/_chunks/{PkToolShowSources-B3VpJBVE.js.map → PkToolShowSources-DDBlLBt6.js.map} +1 -1
  25. package/dist/_chunks/{utils-BZuri2jT.js → utils-ChmRkK0t.js} +12 -5
  26. package/dist/_chunks/utils-ChmRkK0t.js.map +1 -0
  27. package/dist/ai-elements.es.js +3197 -3115
  28. package/dist/ai-elements.es.js.map +1 -1
  29. package/dist-vue/PkChatbot.js +1 -1
  30. package/dist-vue/PkChatbotEmptyState.js +1 -1
  31. package/dist-vue/PkChatbotFilePreview.js +1 -1
  32. package/dist-vue/PkChatbotInput.js +1 -1
  33. package/dist-vue/PkChatbotMessages.js +1 -1
  34. package/dist-vue/PkChatbotStepPayload.js +1 -1
  35. package/dist-vue/PkChatbotStepToolDetail.js +1 -1
  36. package/dist-vue/PkChatbotSteps.js +1 -1
  37. package/dist-vue/PkChatbotViewChat.js +1 -1
  38. package/dist-vue/PkChatbotViewConversations.js +1 -1
  39. package/dist-vue/PkChatbotViewFiles.js +1 -1
  40. package/dist-vue/PkChatbotViewProfile.js +1 -1
  41. package/dist-vue/_chunks/{PkChatbot-DyzEuNED.js → PkChatbot-BjJzskl7.js} +8 -8
  42. package/dist-vue/_chunks/{PkChatbot-DyzEuNED.js.map → PkChatbot-BjJzskl7.js.map} +1 -1
  43. package/dist-vue/_chunks/{PkChatbotEmptyState-COya3H3C.js → PkChatbotEmptyState-CZC2gP3I.js} +2 -2
  44. package/dist-vue/_chunks/{PkChatbotEmptyState-COya3H3C.js.map → PkChatbotEmptyState-CZC2gP3I.js.map} +1 -1
  45. package/dist-vue/_chunks/{PkChatbotFilePreview-BsvT6orx.js → PkChatbotFilePreview-j_8sDZUE.js} +112 -71
  46. package/dist-vue/_chunks/PkChatbotFilePreview-j_8sDZUE.js.map +1 -0
  47. package/dist-vue/_chunks/PkChatbotInput-BmTdIJZ9.js +509 -0
  48. package/dist-vue/_chunks/PkChatbotInput-BmTdIJZ9.js.map +1 -0
  49. package/dist-vue/_chunks/PkChatbotMessages-b2lupEv9.js +1049 -0
  50. package/dist-vue/_chunks/{PkChatbotMessages-BISaZu4z.js.map → PkChatbotMessages-b2lupEv9.js.map} +1 -1
  51. package/dist-vue/_chunks/{PkChatbotStepPayload-cuYclK_2.js → PkChatbotStepPayload-D4w1XlF2.js} +2 -2
  52. package/dist-vue/_chunks/{PkChatbotStepPayload-cuYclK_2.js.map → PkChatbotStepPayload-D4w1XlF2.js.map} +1 -1
  53. package/dist-vue/_chunks/{PkChatbotStepToolDetail-Yd8cUQJP.js → PkChatbotStepToolDetail-DFTcjzoX.js} +3 -3
  54. package/dist-vue/_chunks/{PkChatbotStepToolDetail-Yd8cUQJP.js.map → PkChatbotStepToolDetail-DFTcjzoX.js.map} +1 -1
  55. package/dist-vue/_chunks/{PkChatbotSteps-_Aqft0em.js → PkChatbotSteps-D3zLulMo.js} +5 -5
  56. package/dist-vue/_chunks/{PkChatbotSteps-_Aqft0em.js.map → PkChatbotSteps-D3zLulMo.js.map} +1 -1
  57. package/dist-vue/_chunks/{PkChatbotViewChat-CIfotKyM.js → PkChatbotViewChat-DawyiUjq.js} +323 -345
  58. package/dist-vue/_chunks/PkChatbotViewChat-DawyiUjq.js.map +1 -0
  59. package/dist-vue/_chunks/{PkChatbotViewConversations-DjhiHp8-.js → PkChatbotViewConversations-Bs246dtL.js} +3 -3
  60. package/dist-vue/_chunks/{PkChatbotViewConversations-DjhiHp8-.js.map → PkChatbotViewConversations-Bs246dtL.js.map} +1 -1
  61. package/dist-vue/_chunks/{PkChatbotViewFiles-C4oGN4Xj.js → PkChatbotViewFiles-uzZ5H4Fd.js} +2 -2
  62. package/dist-vue/_chunks/{PkChatbotViewFiles-C4oGN4Xj.js.map → PkChatbotViewFiles-uzZ5H4Fd.js.map} +1 -1
  63. package/dist-vue/_chunks/{PkChatbotViewProfile-NfTamy9j.js → PkChatbotViewProfile-BhIvfT_n.js} +2 -2
  64. package/dist-vue/_chunks/{PkChatbotViewProfile-NfTamy9j.js.map → PkChatbotViewProfile-BhIvfT_n.js.map} +1 -1
  65. package/dist-vue/_chunks/{PkFilePreview-DEKgCMkr.js → PkFilePreview-DfD48QQ_.js} +48 -48
  66. package/dist-vue/_chunks/{PkFilePreview-DEKgCMkr.js.map → PkFilePreview-DfD48QQ_.js.map} +1 -1
  67. package/dist-vue/_chunks/{PkFilePreviewDialog-0qrzDWID.js → PkFilePreviewDialog-DFCBpQf3.js} +2 -2
  68. package/dist-vue/_chunks/{PkFilePreviewDialog-0qrzDWID.js.map → PkFilePreviewDialog-DFCBpQf3.js.map} +1 -1
  69. package/dist-vue/_chunks/PkImageEditorDialog-BLUyILVi.js +550 -0
  70. package/dist-vue/_chunks/PkImageEditorDialog-BLUyILVi.js.map +1 -0
  71. package/dist-vue/_chunks/{PkStreamingMarkdown-2FN4WMQD.js → PkStreamingMarkdown-ChMbSviw.js} +2 -2
  72. package/dist-vue/_chunks/{PkStreamingMarkdown-2FN4WMQD.js.map → PkStreamingMarkdown-ChMbSviw.js.map} +1 -1
  73. package/dist-vue/_chunks/{PkToolChatFile-DAT1tv52.js → PkToolChatFile-DQtABEaI.js} +3 -3
  74. package/dist-vue/_chunks/{PkToolChatFile-DAT1tv52.js.map → PkToolChatFile-DQtABEaI.js.map} +1 -1
  75. package/dist-vue/_chunks/{PkToolShareDocument-Qb2Lu5vh.js → PkToolShareDocument-cMUqik6v.js} +2 -2
  76. package/dist-vue/_chunks/{PkToolShareDocument-Qb2Lu5vh.js.map → PkToolShareDocument-cMUqik6v.js.map} +1 -1
  77. package/dist-vue/_chunks/{PkToolShowArtifact-Bskomw05.js → PkToolShowArtifact-w6SxjLPW.js} +2 -2
  78. package/dist-vue/_chunks/{PkToolShowArtifact-Bskomw05.js.map → PkToolShowArtifact-w6SxjLPW.js.map} +1 -1
  79. package/dist-vue/_chunks/{PkToolShowContactForm-iQrlqv7j.js → PkToolShowContactForm-BQ7bBTQU.js} +2 -2
  80. package/dist-vue/_chunks/{PkToolShowContactForm-iQrlqv7j.js.map → PkToolShowContactForm-BQ7bBTQU.js.map} +1 -1
  81. package/dist-vue/_chunks/{PkToolShowDiagram-C-43uUoh.js → PkToolShowDiagram-D-yQgdOL.js} +2 -2
  82. package/dist-vue/_chunks/{PkToolShowDiagram-C-43uUoh.js.map → PkToolShowDiagram-D-yQgdOL.js.map} +1 -1
  83. package/dist-vue/_chunks/{PkToolShowForm-CKXpqQxy.js → PkToolShowForm-CF00JLpa.js} +3 -3
  84. package/dist-vue/_chunks/{PkToolShowForm-CKXpqQxy.js.map → PkToolShowForm-CF00JLpa.js.map} +1 -1
  85. package/dist-vue/_chunks/{PkToolShowImageGallery-DLTn6JmU.js → PkToolShowImageGallery-ZJMWOWHq.js} +2 -2
  86. package/dist-vue/_chunks/{PkToolShowImageGallery-DLTn6JmU.js.map → PkToolShowImageGallery-ZJMWOWHq.js.map} +1 -1
  87. package/dist-vue/_chunks/{PkToolShowProductList-hhSBAQVC.js → PkToolShowProductList-CeKI9H36.js} +2 -2
  88. package/dist-vue/_chunks/{PkToolShowProductList-hhSBAQVC.js.map → PkToolShowProductList-CeKI9H36.js.map} +1 -1
  89. package/dist-vue/_chunks/{PkToolShowSources-BMo_i8sv.js → PkToolShowSources-CXZqanmw.js} +2 -2
  90. package/dist-vue/_chunks/{PkToolShowSources-BMo_i8sv.js.map → PkToolShowSources-CXZqanmw.js.map} +1 -1
  91. package/dist-vue/_chunks/{PkToolShowVideo-DJhsbDuX.js → PkToolShowVideo-BCs-i6xQ.js} +2 -2
  92. package/dist-vue/_chunks/{PkToolShowVideo-DJhsbDuX.js.map → PkToolShowVideo-BCs-i6xQ.js.map} +1 -1
  93. package/dist-vue/_chunks/{PkToolShowWebPages-BAv66f5H.js → PkToolShowWebPages-Bixa0CjQ.js} +2 -2
  94. package/dist-vue/_chunks/{PkToolShowWebPages-BAv66f5H.js.map → PkToolShowWebPages-Bixa0CjQ.js.map} +1 -1
  95. package/dist-vue/_chunks/{useChatbotStore-BZ1n3Hyx.js → useChatbotStore-BIjCGX0B.js} +858 -835
  96. package/dist-vue/_chunks/useChatbotStore-BIjCGX0B.js.map +1 -0
  97. package/dist-vue/_chunks/{utils-RwaXl9-x.js → utils-CaYEz-0A.js} +11 -4
  98. package/dist-vue/_chunks/utils-CaYEz-0A.js.map +1 -0
  99. package/dist-vue/composables.js +56 -4
  100. package/dist-vue/composables.js.map +1 -1
  101. package/dist-vue/index.js +49 -49
  102. package/dist-vue/index.js.map +1 -1
  103. package/dist-vue/locales.js +56 -0
  104. package/dist-vue/packages/components/src/chat/PkChatbotFilePreview.d.ts +14 -0
  105. package/dist-vue/packages/components/src/chat/PkChatbotInput.d.ts +17 -3
  106. package/dist-vue/packages/components/src/chat/PkImageEditor.d.ts +37 -0
  107. package/dist-vue/packages/components/src/chat/PkImageEditorDialog.d.ts +19 -0
  108. package/dist-vue/packages/components/src/chat/imageEdits.d.ts +106 -0
  109. package/dist-vue/packages/components/src/chat/utils.d.ts +7 -0
  110. package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +7 -1
  111. package/dist-vue/style.css +1 -1
  112. package/package.json +1 -1
  113. package/dist/_chunks/PkChatbotFilePreview-CFGqa-tX.js.map +0 -1
  114. package/dist/_chunks/utils-BZuri2jT.js.map +0 -1
  115. package/dist-vue/_chunks/PkChatbotFilePreview-BsvT6orx.js.map +0 -1
  116. package/dist-vue/_chunks/PkChatbotInput-D0KUEkAs.js +0 -478
  117. package/dist-vue/_chunks/PkChatbotInput-D0KUEkAs.js.map +0 -1
  118. package/dist-vue/_chunks/PkChatbotMessages-BISaZu4z.js +0 -1049
  119. package/dist-vue/_chunks/PkChatbotViewChat-CIfotKyM.js.map +0 -1
  120. package/dist-vue/_chunks/useChatbotStore-BZ1n3Hyx.js.map +0 -1
  121. package/dist-vue/_chunks/utils-RwaXl9-x.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "./rolldown-runtime-CGnMp29N.js";
2
- import { t } from "./PkFilePreview-DEKgCMkr.js";
2
+ import { t } from "./PkFilePreview-DfD48QQ_.js";
3
3
  import { VvDialog as n } from "@volverjs/ui-vue/components";
4
4
  import { createBlock as r, createVNode as i, defineComponent as a, mergeModels as o, openBlock as s, useModel as c, withCtx as l } from "vue";
5
5
  // ../../packages/components/src/chat/PkFilePreviewDialog.vue?vue&type=script&setup=true&lang.ts
@@ -108,4 +108,4 @@ var u = /*@__PURE__*/ a({
108
108
  }), d = /* @__PURE__ */ e({ default: () => f }), f = u;
109
109
  export { d as n, f as t };
110
110
 
111
- //# sourceMappingURL=PkFilePreviewDialog-0qrzDWID.js.map
111
+ //# sourceMappingURL=PkFilePreviewDialog-DFCBpQf3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PkFilePreviewDialog-0qrzDWID.js","names":["_useModel","__unplugin_components_0","_openBlock","_createBlock","_withCtx","_createVNode","PkFilePreview","_sfc_main","__exportAll","PkFilePreviewDialog_vue_vue_type_script_setup_true_lang_default","\"mode\"","\"modeModifiers\"","\"sheet\"","\"sheetModifiers\"","\"zoom\"","\"zoomModifiers\"","\"fit\"","\"fitModifiers\"","__emit","emit","mode","useModel","__props","sheet","zoom","fit","_component_VvDialog","VvDialog","openBlock","createBlock","_cache","$event","withCtx","createVNode","PkFilePreview_default","text","pointer","action","PkFilePreviewDialog_exports","PkFilePreviewDialog_default"],"sources":["../../../../packages/components/src/chat/PkFilePreviewDialog.vue","../../../../packages/components/src/chat/PkFilePreviewDialog.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import type {\n ChatFilePreview,\n FilePointer,\n SelectionGroupCapability,\n } from 'models'\n import PkFilePreview from './PkFilePreview.vue'\n import type { ChatFilePreviewChanges } from './previewChanges'\n import type { ChatFilePreviewTarget, WordPreviewMode } from './utils'\n\n /**\n * The viewer of a file stored in a chat in a dialog over the page: the\n * chat's when it has no room for the panel beside it or the reader\n * expands it, the chat log's always. Open while it is mounted: `close`\n * asks the host to drop it. The viewer draws its own head, with the file\n * and the close button, so the dialog has no title and takes its name.\n */\n defineProps<{\n target: ChatFilePreviewTarget\n /** The authenticated download URL of the same version. */\n downloadUrl: string\n preview?: ChatFilePreview\n /** What the version changed from the one shown before, for a moment. */\n changes?: ChatFilePreviewChanges\n loading?: boolean\n error?: boolean\n /** Covers the screen, for a phone. */\n fullscreen?: boolean\n /** The versions of the file in the conversation, from 1. */\n versions?: number[]\n /** The shown version can be written again as the newest one. */\n restorable?: boolean\n /** Offers to go back to the panel beside the chat. */\n resize?: 'shrink'\n /** The selection bar's actions for this format: absent in the chat logs. */\n selectionActions?: SelectionGroupCapability\n }>()\n\n const emit = defineEmits<{\n close: []\n version: [version: number]\n restore: []\n resize: []\n selectionSend: [\n text: string,\n pointer: FilePointer,\n action: { id: string; size: number },\n ]\n }>()\n\n // How the file is shown, kept by the host across panel and dialog\n const mode = defineModel<WordPreviewMode>('mode')\n const sheet = defineModel<number>('sheet')\n const zoom = defineModel<number>('zoom')\n // A boolean prop left out is false, not the viewer's default: the chat\n // logs keep no zoom, and their pages opened at 100% instead of fitted\n const fit = defineModel<boolean>('fit', { default: true })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :aria-label=\"target.filename\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n class=\"pk-file-preview-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <PkFilePreview\n v-model:mode=\"mode\"\n v-model:sheet=\"sheet\"\n v-model:zoom=\"zoom\"\n v-model:fit=\"fit\"\n :kind=\"target.kind\"\n :filename=\"target.filename\"\n :version=\"target.version\"\n :versions\n :download-url\n :preview\n :changes\n :loading\n :error\n :restorable\n :resize\n :file-id=\"target.fileId\"\n :stored-file-name=\"target.storedFileName\"\n :selection-actions\n @version=\"emit('version', $event)\"\n @restore=\"emit('restore')\"\n @resize=\"emit('resize')\"\n @selection-send=\"\n (text, pointer, action) =>\n emit('selectionSend', text, pointer, action)\n \"\n @close=\"emit('close')\" />\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Almost the whole window, room for a page of Word and a grid of Excel;\n // the viewer scrolls in its own box, so the content does not pad it.\n .pk-file-preview-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(90rem, 94dvw);\n height: 92dvh;\n }\n\n // The library writes `max-height: auto`, which is no value: the\n // wrapper kept its 90dvh and the phone saw the chat around it\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import type {\n ChatFilePreview,\n FilePointer,\n SelectionGroupCapability,\n } from 'models'\n import PkFilePreview from './PkFilePreview.vue'\n import type { ChatFilePreviewChanges } from './previewChanges'\n import type { ChatFilePreviewTarget, WordPreviewMode } from './utils'\n\n /**\n * The viewer of a file stored in a chat in a dialog over the page: the\n * chat's when it has no room for the panel beside it or the reader\n * expands it, the chat log's always. Open while it is mounted: `close`\n * asks the host to drop it. The viewer draws its own head, with the file\n * and the close button, so the dialog has no title and takes its name.\n */\n defineProps<{\n target: ChatFilePreviewTarget\n /** The authenticated download URL of the same version. */\n downloadUrl: string\n preview?: ChatFilePreview\n /** What the version changed from the one shown before, for a moment. */\n changes?: ChatFilePreviewChanges\n loading?: boolean\n error?: boolean\n /** Covers the screen, for a phone. */\n fullscreen?: boolean\n /** The versions of the file in the conversation, from 1. */\n versions?: number[]\n /** The shown version can be written again as the newest one. */\n restorable?: boolean\n /** Offers to go back to the panel beside the chat. */\n resize?: 'shrink'\n /** The selection bar's actions for this format: absent in the chat logs. */\n selectionActions?: SelectionGroupCapability\n }>()\n\n const emit = defineEmits<{\n close: []\n version: [version: number]\n restore: []\n resize: []\n selectionSend: [\n text: string,\n pointer: FilePointer,\n action: { id: string; size: number },\n ]\n }>()\n\n // How the file is shown, kept by the host across panel and dialog\n const mode = defineModel<WordPreviewMode>('mode')\n const sheet = defineModel<number>('sheet')\n const zoom = defineModel<number>('zoom')\n // A boolean prop left out is false, not the viewer's default: the chat\n // logs keep no zoom, and their pages opened at 100% instead of fitted\n const fit = defineModel<boolean>('fit', { default: true })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :aria-label=\"target.filename\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n class=\"pk-file-preview-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <PkFilePreview\n v-model:mode=\"mode\"\n v-model:sheet=\"sheet\"\n v-model:zoom=\"zoom\"\n v-model:fit=\"fit\"\n :kind=\"target.kind\"\n :filename=\"target.filename\"\n :version=\"target.version\"\n :versions\n :download-url\n :preview\n :changes\n :loading\n :error\n :restorable\n :resize\n :file-id=\"target.fileId\"\n :stored-file-name=\"target.storedFileName\"\n :selection-actions\n @version=\"emit('version', $event)\"\n @restore=\"emit('restore')\"\n @resize=\"emit('resize')\"\n @selection-send=\"\n (text, pointer, action) =>\n emit('selectionSend', text, pointer, action)\n \"\n @close=\"emit('close')\" />\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Almost the whole window, room for a page of Word and a grid of Excel;\n // the viewer scrolls in its own box, so the content does not pad it.\n .pk-file-preview-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(90rem, 94dvw);\n height: 92dvh;\n }\n\n // The library writes `max-height: auto`, which is no value: the\n // wrapper kept its 90dvh and the phone saw the chat around it\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCI,IAAMmB,IAAOD,GAaPE,IAAOpB,EAA4BsB,GAAC,MAAM,GAC1CC,IAAQvB,EAAmBsB,GAAC,OAAO,GACnCE,IAAOxB,EAAmBsB,GAAC,MAAM,GAGjCG,IAAMzB,EAAoBsB,GAAC,KAAwB;;;GAIzD,OAAApB,EAAA,GAAAC,EAiCWuB,GAAA;IAhCN,eAAa;IACb,cAAYJ,EAAA,OAAO;IACnB,WAAWA,EAAA,aAAU,eAAkB,KAAA;IACxC,OAAM;IACL,uBAAkB,AAAAQ,EAAA,QAAA,MAAA,CAAGC,KAAUZ,EAAI,OAAA;;IACpC,SAAAf,QA0B6B,CA1B7BC,EA0B6BC,GAAA;KAzBjB,MAAMc,EAAA;KAAA,iBAAA,AAAAU,EAAA,QAAA,MAAA,EAAI,QAAAC;KACV,OAAOR,EAAA;KAAA,kBAAA,AAAAO,EAAA,QAAA,MAAA,EAAK,QAAAC;KACZ,MAAMP,EAAA;KAAA,iBAAA,AAAAM,EAAA,QAAA,MAAA,EAAI,QAAAC;KACV,KAAKN,EAAA;KAAA,gBAAA,AAAAK,EAAA,QAAA,MAAA,EAAG,QAAAC;KACf,MAAMT,EAAA,OAAO;KACb,UAAUA,EAAA,OAAO;KACjB,SAASA,EAAA,OAAO;KAChB,UAAAA,EAAA;KACA,gBAAAA,EAAA;KACA,SAAAA,EAAA;KACA,SAAAA,EAAA;KACA,SAAAA,EAAA;KACA,OAAAA,EAAA;KACA,YAAAA,EAAA;KACA,QAAAA,EAAA;KACA,WAASA,EAAA,OAAO;KAChB,oBAAkBA,EAAA,OAAO;KACzB,qBAAAA,EAAA;KACA,WAAO,AAAAQ,EAAA,QAAA,MAAEX,EAAI,WAAYY,CAAM;KAC/B,WAAO,AAAAD,EAAA,QAAA,MAAEX,EAAI,SAAA;KACb,UAAM,AAAAW,EAAA,QAAA,MAAEX,EAAI,QAAA;KACZ,iBAAc,AAAAW,EAAA,QAAoB,GAAM,GAAS,MAA+BX,EAAI,iBAAkBgB,GAAMC,GAASC,CAAM;KAI3H,SAAK,AAAAP,EAAA,QAAA,MAAEX,EAAI,OAAA"}
1
+ {"version":3,"file":"PkFilePreviewDialog-DFCBpQf3.js","names":["_useModel","__unplugin_components_0","_openBlock","_createBlock","_withCtx","_createVNode","PkFilePreview","_sfc_main","__exportAll","PkFilePreviewDialog_vue_vue_type_script_setup_true_lang_default","\"mode\"","\"modeModifiers\"","\"sheet\"","\"sheetModifiers\"","\"zoom\"","\"zoomModifiers\"","\"fit\"","\"fitModifiers\"","__emit","emit","mode","useModel","__props","sheet","zoom","fit","_component_VvDialog","VvDialog","openBlock","createBlock","_cache","$event","withCtx","createVNode","PkFilePreview_default","text","pointer","action","PkFilePreviewDialog_exports","PkFilePreviewDialog_default"],"sources":["../../../../packages/components/src/chat/PkFilePreviewDialog.vue","../../../../packages/components/src/chat/PkFilePreviewDialog.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import type {\n ChatFilePreview,\n FilePointer,\n SelectionGroupCapability,\n } from 'models'\n import PkFilePreview from './PkFilePreview.vue'\n import type { ChatFilePreviewChanges } from './previewChanges'\n import type { ChatFilePreviewTarget, WordPreviewMode } from './utils'\n\n /**\n * The viewer of a file stored in a chat in a dialog over the page: the\n * chat's when it has no room for the panel beside it or the reader\n * expands it, the chat log's always. Open while it is mounted: `close`\n * asks the host to drop it. The viewer draws its own head, with the file\n * and the close button, so the dialog has no title and takes its name.\n */\n defineProps<{\n target: ChatFilePreviewTarget\n /** The authenticated download URL of the same version. */\n downloadUrl: string\n preview?: ChatFilePreview\n /** What the version changed from the one shown before, for a moment. */\n changes?: ChatFilePreviewChanges\n loading?: boolean\n error?: boolean\n /** Covers the screen, for a phone. */\n fullscreen?: boolean\n /** The versions of the file in the conversation, from 1. */\n versions?: number[]\n /** The shown version can be written again as the newest one. */\n restorable?: boolean\n /** Offers to go back to the panel beside the chat. */\n resize?: 'shrink'\n /** The selection bar's actions for this format: absent in the chat logs. */\n selectionActions?: SelectionGroupCapability\n }>()\n\n const emit = defineEmits<{\n close: []\n version: [version: number]\n restore: []\n resize: []\n selectionSend: [\n text: string,\n pointer: FilePointer,\n action: { id: string; size: number },\n ]\n }>()\n\n // How the file is shown, kept by the host across panel and dialog\n const mode = defineModel<WordPreviewMode>('mode')\n const sheet = defineModel<number>('sheet')\n const zoom = defineModel<number>('zoom')\n // A boolean prop left out is false, not the viewer's default: the chat\n // logs keep no zoom, and their pages opened at 100% instead of fitted\n const fit = defineModel<boolean>('fit', { default: true })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :aria-label=\"target.filename\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n class=\"pk-file-preview-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <PkFilePreview\n v-model:mode=\"mode\"\n v-model:sheet=\"sheet\"\n v-model:zoom=\"zoom\"\n v-model:fit=\"fit\"\n :kind=\"target.kind\"\n :filename=\"target.filename\"\n :version=\"target.version\"\n :versions\n :download-url\n :preview\n :changes\n :loading\n :error\n :restorable\n :resize\n :file-id=\"target.fileId\"\n :stored-file-name=\"target.storedFileName\"\n :selection-actions\n @version=\"emit('version', $event)\"\n @restore=\"emit('restore')\"\n @resize=\"emit('resize')\"\n @selection-send=\"\n (text, pointer, action) =>\n emit('selectionSend', text, pointer, action)\n \"\n @close=\"emit('close')\" />\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Almost the whole window, room for a page of Word and a grid of Excel;\n // the viewer scrolls in its own box, so the content does not pad it.\n .pk-file-preview-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(90rem, 94dvw);\n height: 92dvh;\n }\n\n // The library writes `max-height: auto`, which is no value: the\n // wrapper kept its 90dvh and the phone saw the chat around it\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import type {\n ChatFilePreview,\n FilePointer,\n SelectionGroupCapability,\n } from 'models'\n import PkFilePreview from './PkFilePreview.vue'\n import type { ChatFilePreviewChanges } from './previewChanges'\n import type { ChatFilePreviewTarget, WordPreviewMode } from './utils'\n\n /**\n * The viewer of a file stored in a chat in a dialog over the page: the\n * chat's when it has no room for the panel beside it or the reader\n * expands it, the chat log's always. Open while it is mounted: `close`\n * asks the host to drop it. The viewer draws its own head, with the file\n * and the close button, so the dialog has no title and takes its name.\n */\n defineProps<{\n target: ChatFilePreviewTarget\n /** The authenticated download URL of the same version. */\n downloadUrl: string\n preview?: ChatFilePreview\n /** What the version changed from the one shown before, for a moment. */\n changes?: ChatFilePreviewChanges\n loading?: boolean\n error?: boolean\n /** Covers the screen, for a phone. */\n fullscreen?: boolean\n /** The versions of the file in the conversation, from 1. */\n versions?: number[]\n /** The shown version can be written again as the newest one. */\n restorable?: boolean\n /** Offers to go back to the panel beside the chat. */\n resize?: 'shrink'\n /** The selection bar's actions for this format: absent in the chat logs. */\n selectionActions?: SelectionGroupCapability\n }>()\n\n const emit = defineEmits<{\n close: []\n version: [version: number]\n restore: []\n resize: []\n selectionSend: [\n text: string,\n pointer: FilePointer,\n action: { id: string; size: number },\n ]\n }>()\n\n // How the file is shown, kept by the host across panel and dialog\n const mode = defineModel<WordPreviewMode>('mode')\n const sheet = defineModel<number>('sheet')\n const zoom = defineModel<number>('zoom')\n // A boolean prop left out is false, not the viewer's default: the chat\n // logs keep no zoom, and their pages opened at 100% instead of fitted\n const fit = defineModel<boolean>('fit', { default: true })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :aria-label=\"target.filename\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n class=\"pk-file-preview-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <PkFilePreview\n v-model:mode=\"mode\"\n v-model:sheet=\"sheet\"\n v-model:zoom=\"zoom\"\n v-model:fit=\"fit\"\n :kind=\"target.kind\"\n :filename=\"target.filename\"\n :version=\"target.version\"\n :versions\n :download-url\n :preview\n :changes\n :loading\n :error\n :restorable\n :resize\n :file-id=\"target.fileId\"\n :stored-file-name=\"target.storedFileName\"\n :selection-actions\n @version=\"emit('version', $event)\"\n @restore=\"emit('restore')\"\n @resize=\"emit('resize')\"\n @selection-send=\"\n (text, pointer, action) =>\n emit('selectionSend', text, pointer, action)\n \"\n @close=\"emit('close')\" />\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Almost the whole window, room for a page of Word and a grid of Excel;\n // the viewer scrolls in its own box, so the content does not pad it.\n .pk-file-preview-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(90rem, 94dvw);\n height: 92dvh;\n }\n\n // The library writes `max-height: auto`, which is no value: the\n // wrapper kept its 90dvh and the phone saw the chat around it\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCI,IAAMmB,IAAOD,GAaPE,IAAOpB,EAA4BsB,GAAC,MAAM,GAC1CC,IAAQvB,EAAmBsB,GAAC,OAAO,GACnCE,IAAOxB,EAAmBsB,GAAC,MAAM,GAGjCG,IAAMzB,EAAoBsB,GAAC,KAAwB;;;GAIzD,OAAApB,EAAA,GAAAC,EAiCWuB,GAAA;IAhCN,eAAa;IACb,cAAYJ,EAAA,OAAO;IACnB,WAAWA,EAAA,aAAU,eAAkB,KAAA;IACxC,OAAM;IACL,uBAAkB,AAAAQ,EAAA,QAAA,MAAA,CAAGC,KAAUZ,EAAI,OAAA;;IACpC,SAAAf,QA0B6B,CA1B7BC,EA0B6BC,GAAA;KAzBjB,MAAMc,EAAA;KAAA,iBAAA,AAAAU,EAAA,QAAA,MAAA,EAAI,QAAAC;KACV,OAAOR,EAAA;KAAA,kBAAA,AAAAO,EAAA,QAAA,MAAA,EAAK,QAAAC;KACZ,MAAMP,EAAA;KAAA,iBAAA,AAAAM,EAAA,QAAA,MAAA,EAAI,QAAAC;KACV,KAAKN,EAAA;KAAA,gBAAA,AAAAK,EAAA,QAAA,MAAA,EAAG,QAAAC;KACf,MAAMT,EAAA,OAAO;KACb,UAAUA,EAAA,OAAO;KACjB,SAASA,EAAA,OAAO;KAChB,UAAAA,EAAA;KACA,gBAAAA,EAAA;KACA,SAAAA,EAAA;KACA,SAAAA,EAAA;KACA,SAAAA,EAAA;KACA,OAAAA,EAAA;KACA,YAAAA,EAAA;KACA,QAAAA,EAAA;KACA,WAASA,EAAA,OAAO;KAChB,oBAAkBA,EAAA,OAAO;KACzB,qBAAAA,EAAA;KACA,WAAO,AAAAQ,EAAA,QAAA,MAAEX,EAAI,WAAYY,CAAM;KAC/B,WAAO,AAAAD,EAAA,QAAA,MAAEX,EAAI,SAAA;KACb,UAAM,AAAAW,EAAA,QAAA,MAAEX,EAAI,QAAA;KACZ,iBAAc,AAAAW,EAAA,QAAoB,GAAM,GAAS,MAA+BX,EAAI,iBAAkBgB,GAAMC,GAASC,CAAM;KAI3H,SAAK,AAAAP,EAAA,QAAA,MAAEX,EAAI,OAAA"}
@@ -0,0 +1,550 @@
1
+ import { t as e } from "./PkEditorRadioButtons-Bw576DPQ.js";
2
+ import { t } from "./VvButtonLocalized-C-vx25u4.js";
3
+ import { VvAlert as n, VvButtonGroup as r, VvDialog as i, VvIcon as a } from "@volverjs/ui-vue/components";
4
+ import { Fragment as o, computed as s, createBlock as c, createCommentVNode as l, createElementBlock as u, createElementVNode as d, createTextVNode as f, createVNode as p, defineComponent as m, mergeModels as h, nextTick as g, normalizeClass as _, normalizeStyle as v, onBeforeUnmount as y, onMounted as b, openBlock as x, ref as S, shallowRef as C, toDisplayString as w, unref as T, useId as E, useModel as D, useTemplateRef as O, watch as k, withCtx as A } from "vue";
5
+ import { useI18n as ee } from "vue-i18n";
6
+ import { useMediaQuery as j, useResizeObserver as M } from "@vueuse/core";
7
+ // ../../packages/components/src/chat/imageEdits.ts
8
+ var N = 16777216, P = .92, F = 12, I = 32, L = {
9
+ "image/jpeg": "jpg",
10
+ "image/png": "png",
11
+ "image/webp": "webp"
12
+ };
13
+ function te(e, t = N) {
14
+ let n = e.width * e.height;
15
+ if (n <= t) return {
16
+ width: e.width,
17
+ height: e.height
18
+ };
19
+ let r = Math.sqrt(t / n);
20
+ return {
21
+ width: Math.max(1, Math.floor(e.width * r)),
22
+ height: Math.max(1, Math.floor(e.height * r))
23
+ };
24
+ }
25
+ function ne(e, t) {
26
+ let { width: n, height: r } = e;
27
+ for (let e of t) e.kind === "rotate" ? [n, r] = [r, n] : e.kind === "crop" && ({width: n, height: r} = e.rect);
28
+ return {
29
+ width: n,
30
+ height: r
31
+ };
32
+ }
33
+ function R(e) {
34
+ return Math.max(F, Math.round(Math.min(e.width, e.height) / I));
35
+ }
36
+ function re(e, t, n, r) {
37
+ let i = q(e.x, 0, n.width), a = q(e.y, 0, n.height), o = t.x - i, s = t.y - a, c = o < 0 ? i : n.width - i, l = s < 0 ? a : n.height - a, u = Math.min(Math.abs(o), c), d = Math.min(Math.abs(s), l);
38
+ if (r) {
39
+ let e = Math.max(Math.abs(o), Math.abs(s) * r);
40
+ u = Math.min(e, c, l * r), d = u / r;
41
+ }
42
+ let f = Math.round(o < 0 ? i - u : i), p = Math.round(s < 0 ? a - d : a);
43
+ return {
44
+ x: f,
45
+ y: p,
46
+ width: Math.min(Math.round(u), n.width - f),
47
+ height: Math.min(Math.round(d), n.height - p)
48
+ };
49
+ }
50
+ function z(e, t, n, r) {
51
+ let i = (e, t) => e + 2 * r > t ? t : e + r;
52
+ for (let r = 0; r < n; r = i(r, n)) {
53
+ let a = i(r, n);
54
+ for (let n = 0; n < t; n = i(n, t)) {
55
+ let o = i(n, t), s = 0, c = 0, l = 0, u = 0;
56
+ for (let i = r; i < a; i++) for (let r = n; r < o; r++) {
57
+ let n = (i * t + r) * 4, a = e[n + 3];
58
+ s += e[n] * a, c += e[n + 1] * a, l += e[n + 2] * a, u += a;
59
+ }
60
+ let d = (a - r) * (o - n), f = u > 0 ? [
61
+ s / u,
62
+ c / u,
63
+ l / u,
64
+ u / d
65
+ ] : [
66
+ 0,
67
+ 0,
68
+ 0,
69
+ 0
70
+ ];
71
+ for (let i = r; i < a; i++) for (let r = n; r < o; r++) e.set(f, (i * t + r) * 4);
72
+ }
73
+ }
74
+ }
75
+ function B(e, t, n) {
76
+ let r = L[n];
77
+ if (n === t || !r) return e;
78
+ let i = e.lastIndexOf(".");
79
+ return `${i > 0 ? e.slice(0, i) : e}.${r}`;
80
+ }
81
+ async function ie(e) {
82
+ let t = await createImageBitmap(e, { imageOrientation: "from-image" });
83
+ try {
84
+ let e = {
85
+ width: t.width,
86
+ height: t.height
87
+ }, n = H(te(e)), r = U(n);
88
+ return r.imageSmoothingQuality = "high", r.drawImage(t, 0, 0, n.width, n.height), {
89
+ image: n,
90
+ original: e
91
+ };
92
+ } finally {
93
+ t.close();
94
+ }
95
+ }
96
+ function ae(e, t) {
97
+ let n = H(e);
98
+ U(n).drawImage(e, 0, 0);
99
+ for (let e of t) {
100
+ if (e.kind === "cover") {
101
+ K(n, e.rect, e.style);
102
+ continue;
103
+ }
104
+ let t = e.kind === "rotate" ? W(n, e.turn) : G(n, e.rect);
105
+ V(n), n = t;
106
+ }
107
+ return n;
108
+ }
109
+ function oe(e, t) {
110
+ return new Promise((n, r) => {
111
+ e.toBlob((e) => e ? n(e) : r(/* @__PURE__ */ Error("The image could not be written")), t, P);
112
+ });
113
+ }
114
+ function V(e) {
115
+ e.width = 0, e.height = 0;
116
+ }
117
+ function H(e) {
118
+ let t = document.createElement("canvas");
119
+ return t.width = e.width, t.height = e.height, t;
120
+ }
121
+ function U(e) {
122
+ let t = e.getContext("2d");
123
+ if (!t) throw Error("No 2D canvas in this browser");
124
+ return t;
125
+ }
126
+ function W(e, t) {
127
+ let n = H({
128
+ width: e.height,
129
+ height: e.width
130
+ }), r = U(n);
131
+ return r.translate(n.width / 2, n.height / 2), r.rotate(t * Math.PI / 2), r.drawImage(e, -e.width / 2, -e.height / 2), n;
132
+ }
133
+ function G(e, t) {
134
+ let n = H(t);
135
+ return U(n).drawImage(e, t.x, t.y, t.width, t.height, 0, 0, t.width, t.height), n;
136
+ }
137
+ function K(e, t, n) {
138
+ let r = U(e);
139
+ if (n === "solid") {
140
+ r.fillStyle = "#000000", r.fillRect(t.x, t.y, t.width, t.height);
141
+ return;
142
+ }
143
+ let i = r.getImageData(t.x, t.y, t.width, t.height);
144
+ z(i.data, t.width, t.height, R(e)), r.putImageData(i, t.x, t.y);
145
+ }
146
+ function q(e, t, n) {
147
+ return Math.min(n, Math.max(t, e));
148
+ }
149
+ // ../../packages/components/src/chat/PkImageEditor.vue?vue&type=script&setup=true&lang.ts
150
+ var se = { class: "pk-image-editor" }, ce = { class: "pk-image-editor__toolbar" }, le = { class: "pk-image-editor__options" }, ue = ["id"], de = { class: "pk-image-editor__hint" }, fe = { class: "pk-image-editor__hint" }, pe = 6, J = /* @__PURE__ */ m({
151
+ __name: "PkImageEditor",
152
+ props: /*@__PURE__*/ h({ image: {} }, {
153
+ edits: { required: !0 },
154
+ editsModifiers: {}
155
+ }),
156
+ emits: /*@__PURE__*/ h(["error"], ["update:edits"]),
157
+ setup(n, { expose: i, emit: c }) {
158
+ let m = n, h = c, g = D(n, "edits"), { t: C } = ee({ useScope: "global" }), j = {
159
+ free: void 0,
160
+ "1:1": 1,
161
+ "4:3": 4 / 3,
162
+ "16:9": 16 / 9
163
+ }, N = S("crop"), P = S("free"), F = S("solid"), I = s(() => [{
164
+ value: "crop",
165
+ label: C("imageEditor.crop")
166
+ }, {
167
+ value: "cover",
168
+ label: C("imageEditor.cover")
169
+ }]), L = s(() => [
170
+ {
171
+ value: "free",
172
+ label: C("imageEditor.aspectFree")
173
+ },
174
+ {
175
+ value: "1:1",
176
+ label: "1:1"
177
+ },
178
+ {
179
+ value: "4:3",
180
+ label: "4:3"
181
+ },
182
+ {
183
+ value: "16:9",
184
+ label: "16:9"
185
+ }
186
+ ]), te = s(() => [{
187
+ value: "solid",
188
+ label: C("imageEditor.coverSolid")
189
+ }, {
190
+ value: "pixelate",
191
+ label: C("imageEditor.coverPixelate")
192
+ }]), R = E(), z = S([]);
193
+ function B(e) {
194
+ g.value = [...g.value, e], z.value = [];
195
+ }
196
+ function ie() {
197
+ Z.value = void 0;
198
+ let e = g.value[g.value.length - 1];
199
+ e && (g.value = g.value.slice(0, -1), z.value = [...z.value, e]);
200
+ }
201
+ function oe() {
202
+ Z.value = void 0;
203
+ let e = z.value[z.value.length - 1];
204
+ e && (g.value = [...g.value, e], z.value = z.value.slice(0, -1));
205
+ }
206
+ function H(e) {
207
+ Z.value = void 0, B({
208
+ kind: "rotate",
209
+ turn: e
210
+ });
211
+ }
212
+ let U = s(() => ne(m.image, g.value)), W = O("stageEl"), G;
213
+ function K() {
214
+ if (!W.value) return;
215
+ let e;
216
+ try {
217
+ e = ae(m.image, g.value);
218
+ } catch {
219
+ h("error");
220
+ return;
221
+ }
222
+ e.setAttribute("role", "img"), e.setAttribute("aria-label", C("imageEditor.canvasLabel")), W.value.replaceChildren(e), G && V(G), G = e;
223
+ }
224
+ b(K), k([() => m.image, g], K, { flush: "post" }), y(() => {
225
+ G && V(G);
226
+ });
227
+ let q = O("areaEl"), J = S({
228
+ width: 0,
229
+ height: 0
230
+ });
231
+ M(q, ([e]) => {
232
+ e && (J.value = {
233
+ width: e.contentRect.width,
234
+ height: e.contentRect.height
235
+ });
236
+ });
237
+ let Y = s(() => Math.min(1, J.value.width / U.value.width, J.value.height / U.value.height)), me = s(() => ({
238
+ width: `${Math.max(1, Math.floor(U.value.width * Y.value))}px`,
239
+ height: `${Math.max(1, Math.floor(U.value.height * Y.value))}px`
240
+ })), X = O("frameEl"), Z = S(), Q = S();
241
+ function he(e) {
242
+ let t = X.value?.getBoundingClientRect();
243
+ return !t?.width || !t.height ? {
244
+ x: 0,
245
+ y: 0
246
+ } : {
247
+ x: (e.clientX - t.left) / t.width * U.value.width,
248
+ y: (e.clientY - t.top) / t.height * U.value.height
249
+ };
250
+ }
251
+ function ge(e) {
252
+ e.button === 0 && (X.value?.setPointerCapture(e.pointerId), Q.value = he(e), Z.value = void 0);
253
+ }
254
+ function _e(e) {
255
+ Q.value && (Z.value = re(Q.value, he(e), U.value, N.value === "crop" ? j[P.value] : void 0));
256
+ }
257
+ function ve() {
258
+ if (!Q.value) return;
259
+ Q.value = void 0;
260
+ let e = Z.value;
261
+ !e || e.width * Y.value < pe || e.height * Y.value < pe ? Z.value = void 0 : N.value === "cover" && (Z.value = void 0, B({
262
+ kind: "cover",
263
+ rect: e,
264
+ style: F.value
265
+ }));
266
+ }
267
+ function ye() {
268
+ Q.value = void 0, Z.value = void 0;
269
+ }
270
+ let $ = s(() => N.value === "crop" && !Q.value && !!Z.value);
271
+ function be() {
272
+ let e = Z.value;
273
+ $.value && e && (Z.value = void 0, (e.width !== U.value.width || e.height !== U.value.height) && B({
274
+ kind: "crop",
275
+ rect: e
276
+ }));
277
+ }
278
+ k(N, () => {
279
+ Z.value = void 0;
280
+ }), k(P, (e) => {
281
+ let t = Z.value;
282
+ t && N.value === "crop" && (Z.value = re(t, {
283
+ x: t.x + t.width,
284
+ y: t.y + t.height
285
+ }, U.value, j[e]));
286
+ });
287
+ let xe = s(() => {
288
+ let e = Z.value;
289
+ if (e) return {
290
+ left: `${e.x / U.value.width * 100}%`,
291
+ top: `${e.y / U.value.height * 100}%`,
292
+ width: `${e.width / U.value.width * 100}%`,
293
+ height: `${e.height / U.value.height * 100}%`
294
+ };
295
+ });
296
+ return i({
297
+ pendingCrop: $,
298
+ applyCrop: be,
299
+ shownCanvas: () => G
300
+ }), (n, i) => {
301
+ let s = a, c = t, m = r;
302
+ return x(), u("div", se, [
303
+ d("div", ce, [
304
+ p(e, {
305
+ modelValue: N.value,
306
+ "onUpdate:modelValue": i[0] ||= (e) => N.value = e,
307
+ name: "pk-image-editor-tool",
308
+ segmented: "",
309
+ class: "mb-0",
310
+ "aria-label": T(C)("imageEditor.tool"),
311
+ options: I.value
312
+ }, {
313
+ crop: A(({ option: e }) => [p(s, {
314
+ name: "ri:crop-line",
315
+ class: "w-16 h-16"
316
+ }), f(" " + w(e.label), 1)]),
317
+ cover: A(({ option: e }) => [p(s, {
318
+ name: "ri:eye-off-line",
319
+ class: "w-16 h-16"
320
+ }), f(" " + w(e.label), 1)]),
321
+ _: 1
322
+ }, 8, [
323
+ "modelValue",
324
+ "aria-label",
325
+ "options"
326
+ ]),
327
+ p(m, { modifiers: "compact" }, {
328
+ default: A(() => [p(c, {
329
+ modifiers: "action-quiet",
330
+ icon: "ri:anticlockwise-line",
331
+ title: T(C)("imageEditor.rotateLeft"),
332
+ "aria-label": T(C)("imageEditor.rotateLeft"),
333
+ onClick: i[1] ||= (e) => H(-1)
334
+ }, null, 8, ["title", "aria-label"]), p(c, {
335
+ modifiers: "action-quiet",
336
+ icon: "ri:clockwise-line",
337
+ title: T(C)("imageEditor.rotateRight"),
338
+ "aria-label": T(C)("imageEditor.rotateRight"),
339
+ onClick: i[2] ||= (e) => H(1)
340
+ }, null, 8, ["title", "aria-label"])]),
341
+ _: 1
342
+ }),
343
+ p(m, {
344
+ modifiers: "compact",
345
+ class: "ml-auto"
346
+ }, {
347
+ default: A(() => [p(c, {
348
+ modifiers: "action-quiet",
349
+ icon: "ri:arrow-go-back-line",
350
+ title: T(C)("imageEditor.undo"),
351
+ "aria-label": T(C)("imageEditor.undo"),
352
+ disabled: !g.value.length,
353
+ onClick: ie
354
+ }, null, 8, [
355
+ "title",
356
+ "aria-label",
357
+ "disabled"
358
+ ]), p(c, {
359
+ modifiers: "action-quiet",
360
+ icon: "ri:arrow-go-forward-line",
361
+ title: T(C)("imageEditor.redo"),
362
+ "aria-label": T(C)("imageEditor.redo"),
363
+ disabled: !z.value.length,
364
+ onClick: oe
365
+ }, null, 8, [
366
+ "title",
367
+ "aria-label",
368
+ "disabled"
369
+ ])]),
370
+ _: 1
371
+ })
372
+ ]),
373
+ d("div", le, [N.value === "crop" ? (x(), u(o, { key: 0 }, [
374
+ d("span", {
375
+ id: T(R),
376
+ class: "pk-image-editor__label"
377
+ }, w(T(C)("imageEditor.aspect")), 9, ue),
378
+ p(e, {
379
+ modelValue: P.value,
380
+ "onUpdate:modelValue": i[3] ||= (e) => P.value = e,
381
+ name: "pk-image-editor-aspect",
382
+ segmented: "",
383
+ class: "mb-0",
384
+ "aria-labelledby": T(R),
385
+ options: L.value
386
+ }, null, 8, [
387
+ "modelValue",
388
+ "aria-labelledby",
389
+ "options"
390
+ ]),
391
+ d("span", de, w(T(C)("imageEditor.cropHint")), 1),
392
+ p(c, {
393
+ class: "ml-auto",
394
+ modifiers: "secondary",
395
+ label: T(C)("action.apply"),
396
+ disabled: !$.value,
397
+ onClick: be
398
+ }, null, 8, ["label", "disabled"])
399
+ ], 64)) : (x(), u(o, { key: 1 }, [p(e, {
400
+ modelValue: F.value,
401
+ "onUpdate:modelValue": i[4] ||= (e) => F.value = e,
402
+ name: "pk-image-editor-cover",
403
+ segmented: "",
404
+ class: "mb-0",
405
+ "aria-label": T(C)("imageEditor.coverStyle"),
406
+ options: te.value
407
+ }, null, 8, [
408
+ "modelValue",
409
+ "aria-label",
410
+ "options"
411
+ ]), d("span", fe, w(T(C)("imageEditor.coverHint")), 1)], 64))]),
412
+ d("div", {
413
+ ref_key: "areaEl",
414
+ ref: q,
415
+ class: "pk-image-editor__area"
416
+ }, [d("div", {
417
+ ref_key: "frameEl",
418
+ ref: X,
419
+ class: "pk-image-editor__frame",
420
+ style: v(me.value),
421
+ onPointerdown: ge,
422
+ onPointermove: _e,
423
+ onPointerup: ve,
424
+ onPointercancel: ye
425
+ }, [d("div", {
426
+ ref_key: "stageEl",
427
+ ref: W,
428
+ class: "pk-image-editor__stage"
429
+ }, null, 512), Z.value ? (x(), u("div", {
430
+ key: 0,
431
+ class: _(["pk-image-editor__selection", `pk-image-editor__selection--${N.value}`]),
432
+ style: v(xe.value)
433
+ }, null, 6)) : l("", !0)], 36)], 512)
434
+ ]);
435
+ };
436
+ }
437
+ }), Y = ["aria-label"], me = {
438
+ key: 3,
439
+ class: "pk-image-editor-dialog__size"
440
+ }, X = /* @__PURE__ */ m({
441
+ __name: "PkImageEditorDialog",
442
+ props: { file: {} },
443
+ emits: ["close", "apply"],
444
+ setup(e, { emit: o }) {
445
+ let d = e, f = o, { t: m } = ee({ useScope: "global" }), h = j("(max-width: 575.98px)"), _ = C(), v = S(), E = S([]), D = S(!1), k = O("editorEl");
446
+ b(async () => {
447
+ try {
448
+ _.value = await ie(d.file);
449
+ } catch {
450
+ v.value = "load";
451
+ }
452
+ }), y(() => {
453
+ _.value && V(_.value.image);
454
+ });
455
+ let M = s(() => _.value && ne(_.value.image, E.value)), N = s(() => !!_.value && _.value.image.width < _.value.original.width), P = s(() => E.value.length > 0 || !!k.value?.pendingCrop);
456
+ async function F() {
457
+ let e = k.value;
458
+ if (e) {
459
+ if (e.applyCrop(), !E.value.length) f("close");
460
+ else {
461
+ v.value = void 0, D.value = !0;
462
+ try {
463
+ await g();
464
+ let t = e.shownCanvas();
465
+ if (v.value === "draw") return;
466
+ if (!t) throw Error("No image drawn");
467
+ let n = await oe(t, d.file.type);
468
+ f("apply", new File([n], B(d.file.name, d.file.type, n.type), {
469
+ type: n.type,
470
+ lastModified: Date.now()
471
+ }));
472
+ } catch {
473
+ v.value = "export";
474
+ } finally {
475
+ D.value = !1;
476
+ }
477
+ }
478
+ }
479
+ }
480
+ let I = s(() => {
481
+ switch (v.value) {
482
+ case "export": return m("imageEditor.exportFailed");
483
+ case "draw": return m("imageEditor.drawFailed");
484
+ default: return m("imageEditor.loadFailed");
485
+ }
486
+ });
487
+ return (e, o) => {
488
+ let s = n, d = a, g = t, y = r, b = i;
489
+ return x(), c(b, {
490
+ "model-value": !0,
491
+ title: T(m)("imageEditor.title"),
492
+ modifiers: T(h) ? "fullscreen" : void 0,
493
+ "keep-open": "",
494
+ class: "pk-image-editor-dialog",
495
+ "onUpdate:modelValue": o[3] ||= (e) => !e && f("close")
496
+ }, {
497
+ footer: A(() => [p(y, null, {
498
+ default: A(() => [p(g, {
499
+ modifiers: "secondary",
500
+ label: T(m)("action.cancel"),
501
+ onClick: o[2] ||= (e) => f("close")
502
+ }, null, 8, ["label"]), p(g, {
503
+ label: T(m)("imageEditor.use"),
504
+ loading: D.value,
505
+ disabled: D.value || !P.value || v.value === "draw",
506
+ onClick: F
507
+ }, null, 8, [
508
+ "label",
509
+ "loading",
510
+ "disabled"
511
+ ])]),
512
+ _: 1
513
+ })]),
514
+ default: A(() => [
515
+ v.value ? (x(), c(s, {
516
+ key: 0,
517
+ modifiers: "danger",
518
+ class: "m-md",
519
+ content: I.value
520
+ }, null, 8, ["content"])) : l("", !0),
521
+ _.value && v.value !== "draw" ? (x(), c(J, {
522
+ key: 1,
523
+ ref_key: "editorEl",
524
+ ref: k,
525
+ edits: E.value,
526
+ "onUpdate:edits": o[0] ||= (e) => E.value = e,
527
+ image: _.value.image,
528
+ onError: o[1] ||= (e) => v.value = "draw"
529
+ }, null, 8, ["edits", "image"])) : v.value ? l("", !0) : (x(), u("div", {
530
+ key: 2,
531
+ class: "pk-image-editor-dialog__loading",
532
+ role: "status",
533
+ "aria-label": T(m)("imageEditor.loading")
534
+ }, [p(d, { name: "loading-loop" })], 8, Y)),
535
+ M.value ? (x(), u("p", me, w(N.value ? T(m)("imageEditor.sizeScaledDown", {
536
+ width: M.value.width,
537
+ height: M.value.height
538
+ }) : T(m)("imageEditor.size", {
539
+ width: M.value.width,
540
+ height: M.value.height
541
+ })), 1)) : l("", !0)
542
+ ]),
543
+ _: 1
544
+ }, 8, ["title", "modifiers"]);
545
+ };
546
+ }
547
+ });
548
+ export { X as default };
549
+
550
+ //# sourceMappingURL=PkImageEditorDialog-BLUyILVi.js.map