@8wave/ai-elements 0.125.0-beta.27 → 0.125.0-beta.29

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 +3196 -3114
  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-N5lgU3-k.js → PkChatbot-BjJzskl7.js} +8 -8
  42. package/dist-vue/_chunks/{PkChatbot-N5lgU3-k.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-B3Nr7-kY.js → PkChatbotViewChat-DawyiUjq.js} +322 -344
  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-D-BGFp9C.js → PkFilePreview-DfD48QQ_.js} +48 -48
  66. package/dist-vue/_chunks/{PkFilePreview-D-BGFp9C.js.map → PkFilePreview-DfD48QQ_.js.map} +1 -1
  67. package/dist-vue/_chunks/{PkFilePreviewDialog-By2TQolA.js → PkFilePreviewDialog-DFCBpQf3.js} +2 -2
  68. package/dist-vue/_chunks/{PkFilePreviewDialog-By2TQolA.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-B3Nr7-kY.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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PkImageEditorDialog-Cq8y_PtC.js","names":["_hoisted_1","_hoisted_2","_useModel","__unplugin_components_0","__unplugin_components_1","__unplugin_components_2","_openBlock","_createElementBlock","_createElementVNode","_createVNode","PkEditorRadioButtons","_unref","_withCtx","_createTextVNode","_toDisplayString","_Fragment","_normalizeStyle","_normalizeClass","_createCommentVNode","_sfc_main","_style_0","__unplugin_components_0","__unplugin_components_1","__unplugin_components_2","__unplugin_components_3","__unplugin_components_4","_openBlock","_createBlock","_unref","_withCtx","_createVNode","_createCommentVNode","PkImageEditor","_createElementBlock","_toDisplayString","_sfc_main","_style_0","normalizeClass","nextTick","onBeforeUnmount","useModel","onMounted","mergeModels","normalizeStyle","watch","createVNode","init_shared_esm_bundler","useTemplateRef","createBlock","createBaseVNode","ref","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","useId","withCtx","createCommentVNode","shallowRef","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useI18n","useMediaQuery","useResizeObserver","au","nu","eo","Ce","VvButtonLocalized","_plugin_vue_export_helper_default","PkEditorRadioButtons_default","MAX_CANVAS_AREA","EXPORT_QUALITY","MIN_PIXEL_BLOCK","PIXEL_BLOCK_DIVISOR","EXTENSIONS","fitToArea","area","size","maxArea","scale","sizeAfterEdits","edit","edits","width","height","pixelBlock","dragRect","ax","clamp","from","bounds","ay","dx","to","dy","roomX","roomY","aspect","lead","x","y","pixelateData","blockEnd","start","block","by","bottom","bx","right","r","g","b","a","i","alpha","data","count","color","editedFileName","extension","writtenType","originalType","name","dot","loadEditableImage","bitmap","file","original","image","createCanvas","context","renderEdits","canvas","next","rotate","crop","releaseCanvas","exportCanvas","blob","resolve","reject","type","source","turn","rect","cover","style","pixels","max","min","value","_hoisted_1$1","_hoisted_2$1","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","MIN_DRAG","PkImageEditor_default","\"edits\"","\"editsModifiers\"","__expose","__emit","props","__props","emit","$t","ASPECTS","tool","coverStyle","toolOptions","computed","aspectOptions","coverOptions","aspectLabelId","redoStack","push","undo","last","redo","stageEl","shown","draw","areaEl","room","entry","frameStyle","frameEl","selection","dragFrom","pointOf","box","event","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","pendingCrop","applyCrop","selectionStyle","_component_VvIcon","_component_VvButton","_component_VvButtonGroup","_cache","$event","option","Fragment","_hoisted_1","_hoisted_2","PkImageEditorDialog_default","fullscreen","loaded","failed","exporting","editorEl","scaledDown","changed","useImage","editor","failedLabel","_component_VvAlert","_component_VvDialog"],"sources":["../../../../packages/components/src/chat/imageEdits.ts","../../../../packages/components/src/chat/PkImageEditor.vue","../../../../packages/components/src/chat/PkImageEditor.vue","../../../../packages/components/src/chat/PkImageEditor.vue","../../../../packages/components/src/chat/PkImageEditorDialog.vue","../../../../packages/components/src/chat/PkImageEditorDialog.vue","../../../../packages/components/src/chat/PkImageEditorDialog.vue"],"sourcesContent":["/**\n * The model of the image editor (spec `chat-image-editor.md`): a list of\n * edits applied in order to the original, so every draw starts again from\n * the original and undo drops the last edit. The geometry is pure; the\n * drawing needs a canvas, which only a browser has.\n */\n\n/** A point in the pixels of the image an edit applies to. */\nexport interface ImagePoint {\n x: number\n y: number\n}\n\nexport interface ImageSize {\n width: number\n height: number\n}\n\n/** A rectangle in the pixels of the image an edit applies to. */\nexport interface ImageRect extends ImagePoint, ImageSize {}\n\n/**\n * How a covered area is drawn: a black box, the only cover a text cannot be\n * read back through, or large blocks of its average color, for a face.\n */\nexport type CoverStyle = 'solid' | 'pixelate'\n\n/**\n * One change, in the coordinates of the image the edits before it left: a\n * crop changes the size, a quarter turn swaps the sides.\n */\nexport type ImageEdit =\n /** A quarter turn, `1` clockwise and `-1` counterclockwise. */\n | { kind: 'rotate'; turn: 1 | -1 }\n | { kind: 'crop'; rect: ImageRect }\n | { kind: 'cover'; rect: ImageRect; style: CoverStyle }\n\n/**\n * Safari on iOS refuses a canvas larger than this area: a larger image is\n * scaled down to fit before it is edited.\n */\nexport const MAX_CANVAS_AREA = 4096 * 4096\n\n/** The quality of a JPEG or WebP written back. */\nexport const EXPORT_QUALITY = 0.92\n\n/**\n * The side of a block of a pixelated cover: never under 12 pixels, nor under\n * 1/32 of the short side, so a pixelated cover never turns into a light blur\n * that a face or a word can be guessed through.\n */\nconst MIN_PIXEL_BLOCK = 12\nconst PIXEL_BLOCK_DIVISOR = 32\n\nconst EXTENSIONS: Record<string, string> = {\n 'image/jpeg': 'jpg',\n 'image/png': 'png',\n 'image/webp': 'webp',\n}\n\n/**\n * The size an image is edited at: its own, or the largest with the same\n * proportions whose area fits `maxArea`.\n */\nexport function fitToArea(\n size: ImageSize,\n maxArea = MAX_CANVAS_AREA,\n): ImageSize {\n const area = size.width * size.height\n if (area <= maxArea) {\n return { width: size.width, height: size.height }\n }\n const scale = Math.sqrt(maxArea / area)\n return {\n width: Math.max(1, Math.floor(size.width * scale)),\n height: Math.max(1, Math.floor(size.height * scale)),\n }\n}\n\n/** The size of the image once `edits` are applied to one of `size`. */\nexport function sizeAfterEdits(\n size: ImageSize,\n edits: readonly ImageEdit[],\n): ImageSize {\n let { width, height } = size\n for (const edit of edits) {\n if (edit.kind === 'rotate') {\n ;[width, height] = [height, width]\n } else if (edit.kind === 'crop') {\n ;({ width, height } = edit.rect)\n }\n }\n return { width, height }\n}\n\n/** The side of a block of a pixelated cover on an image of `size`. */\nexport function pixelBlock(size: ImageSize): number {\n return Math.max(\n MIN_PIXEL_BLOCK,\n Math.round(Math.min(size.width, size.height) / PIXEL_BLOCK_DIVISOR),\n )\n}\n\n/**\n * The rectangle a drag from `from` to `to` draws, in any direction, inside\n * `bounds`. With an `aspect` (width over height) the longer side of the drag\n * leads, and both sides shrink together to stay inside the image.\n */\nexport function dragRect(\n from: ImagePoint,\n to: ImagePoint,\n bounds: ImageSize,\n aspect?: number,\n): ImageRect {\n const ax = clamp(from.x, 0, bounds.width)\n const ay = clamp(from.y, 0, bounds.height)\n const dx = to.x - ax\n const dy = to.y - ay\n // The room from the anchor to the edges the drag goes toward\n const roomX = dx < 0 ? ax : bounds.width - ax\n const roomY = dy < 0 ? ay : bounds.height - ay\n let width = Math.min(Math.abs(dx), roomX)\n let height = Math.min(Math.abs(dy), roomY)\n if (aspect) {\n const lead = Math.max(Math.abs(dx), Math.abs(dy) * aspect)\n width = Math.min(lead, roomX, roomY * aspect)\n height = width / aspect\n }\n const x = Math.round(dx < 0 ? ax - width : ax)\n const y = Math.round(dy < 0 ? ay - height : ay)\n return {\n x,\n y,\n width: Math.min(Math.round(width), bounds.width - x),\n height: Math.min(Math.round(height), bounds.height - y),\n }\n}\n\n/**\n * Pixelates RGBA pixels in place: each `block` square takes the average\n * color of the pixels it covers, weighted by their opacity, so the\n * transparent pixels of a PNG do not darken it. The blocks start at the top\n * left corner. What is left on the right and bottom edges, less than a\n * block, joins the last block: a strip of a few pixels would keep a detail\n * finer than the block promises.\n */\nexport function pixelateData(\n data: Uint8ClampedArray,\n width: number,\n height: number,\n block: number,\n): void {\n const blockEnd = (start: number, size: number) =>\n start + 2 * block > size ? size : start + block\n for (let by = 0; by < height; by = blockEnd(by, height)) {\n const bottom = blockEnd(by, height)\n for (let bx = 0; bx < width; bx = blockEnd(bx, width)) {\n const right = blockEnd(bx, width)\n let r = 0\n let g = 0\n let b = 0\n let a = 0\n for (let y = by; y < bottom; y++) {\n for (let x = bx; x < right; x++) {\n const i = (y * width + x) * 4\n const alpha = data[i + 3]\n r += data[i] * alpha\n g += data[i + 1] * alpha\n b += data[i + 2] * alpha\n a += alpha\n }\n }\n const count = (bottom - by) * (right - bx)\n const color =\n a > 0 ? [r / a, g / a, b / a, a / count] : [0, 0, 0, 0]\n for (let y = by; y < bottom; y++) {\n for (let x = bx; x < right; x++) {\n data.set(color, (y * width + x) * 4)\n }\n }\n }\n }\n}\n\n/**\n * The name of the edited file: the original one, with the extension of the\n * type written when the browser could not write the original type (Safari\n * writes no WebP and gives a PNG instead).\n */\nexport function editedFileName(\n name: string,\n originalType: string,\n writtenType: string,\n): string {\n const extension = EXTENSIONS[writtenType]\n if (writtenType === originalType || !extension) {\n return name\n }\n const dot = name.lastIndexOf('.')\n return `${dot > 0 ? name.slice(0, dot) : name}.${extension}`\n}\n\n// --- Canvas ---\n\nexport interface LoadedImage {\n /** The image as it is edited, at most `MAX_CANVAS_AREA` pixels. */\n image: HTMLCanvasElement\n /** The size of the file, larger than `image` when it was scaled down. */\n original: ImageSize\n}\n\n/**\n * Decodes an image file into the canvas the edits start from, upright as\n * the photo's orientation says and scaled down if it is too large for a\n * canvas.\n */\nexport async function loadEditableImage(file: Blob): Promise<LoadedImage> {\n const bitmap = await createImageBitmap(file, {\n imageOrientation: 'from-image',\n })\n try {\n const original = { width: bitmap.width, height: bitmap.height }\n const image = createCanvas(fitToArea(original))\n const g = context(image)\n g.imageSmoothingQuality = 'high'\n g.drawImage(bitmap, 0, 0, image.width, image.height)\n return { image, original }\n } finally {\n bitmap.close()\n }\n}\n\n/**\n * Draws `edits` over a copy of `image`, which stays untouched. The canvas\n * returned is new: the caller releases it with `releaseCanvas` when it\n * draws the next one.\n */\nexport function renderEdits(\n image: HTMLCanvasElement,\n edits: readonly ImageEdit[],\n): HTMLCanvasElement {\n let canvas = createCanvas(image)\n context(canvas).drawImage(image, 0, 0)\n for (const edit of edits) {\n if (edit.kind === 'cover') {\n cover(canvas, edit.rect, edit.style)\n continue\n }\n const next =\n edit.kind === 'rotate'\n ? rotate(canvas, edit.turn)\n : crop(canvas, edit.rect)\n releaseCanvas(canvas)\n canvas = next\n }\n return canvas\n}\n\n/**\n * Writes the canvas as a file of `type`, or as a PNG where the browser\n * cannot write that type. A canvas writes no metadata: the EXIF of a photo,\n * its position included, does not survive.\n */\nexport function exportCanvas(\n canvas: HTMLCanvasElement,\n type: string,\n): Promise<Blob> {\n return new Promise((resolve, reject) => {\n canvas.toBlob(\n (blob) =>\n blob\n ? resolve(blob)\n : reject(new Error('The image could not be written')),\n type,\n EXPORT_QUALITY,\n )\n })\n}\n\n/**\n * Frees the memory of a canvas no longer shown: Safari counts every canvas\n * until it is collected, and refuses new ones past its total.\n */\nexport function releaseCanvas(canvas: HTMLCanvasElement): void {\n canvas.width = 0\n canvas.height = 0\n}\n\nfunction createCanvas(size: ImageSize): HTMLCanvasElement {\n const canvas = document.createElement('canvas')\n canvas.width = size.width\n canvas.height = size.height\n return canvas\n}\n\nfunction context(canvas: HTMLCanvasElement): CanvasRenderingContext2D {\n const g = canvas.getContext('2d')\n if (!g) {\n throw new Error('No 2D canvas in this browser')\n }\n return g\n}\n\nfunction rotate(source: HTMLCanvasElement, turn: 1 | -1): HTMLCanvasElement {\n const canvas = createCanvas({\n width: source.height,\n height: source.width,\n })\n const g = context(canvas)\n g.translate(canvas.width / 2, canvas.height / 2)\n g.rotate((turn * Math.PI) / 2)\n g.drawImage(source, -source.width / 2, -source.height / 2)\n return canvas\n}\n\nfunction crop(source: HTMLCanvasElement, rect: ImageRect): HTMLCanvasElement {\n const canvas = createCanvas(rect)\n context(canvas).drawImage(\n source,\n rect.x,\n rect.y,\n rect.width,\n rect.height,\n 0,\n 0,\n rect.width,\n rect.height,\n )\n return canvas\n}\n\nfunction cover(\n canvas: HTMLCanvasElement,\n rect: ImageRect,\n style: CoverStyle,\n): void {\n const g = context(canvas)\n if (style === 'solid') {\n g.fillStyle = '#000000'\n g.fillRect(rect.x, rect.y, rect.width, rect.height)\n return\n }\n const pixels = g.getImageData(rect.x, rect.y, rect.width, rect.height)\n pixelateData(pixels.data, rect.width, rect.height, pixelBlock(canvas))\n g.putImageData(pixels, rect.x, rect.y)\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value))\n}\n","<script setup lang=\"ts\">\n import {\n computed,\n onBeforeUnmount,\n onMounted,\n ref,\n useId,\n useTemplateRef,\n watch,\n } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useResizeObserver } from '@vueuse/core'\n import PkEditorRadioButtons from '../PkEditorRadioButtons.vue'\n import {\n dragRect,\n releaseCanvas,\n renderEdits,\n sizeAfterEdits,\n type CoverStyle,\n type ImageEdit,\n type ImagePoint,\n type ImageRect,\n } from './imageEdits'\n\n /**\n * The tools of the image editor over the image they change (spec\n * `chat-image-editor.md`, F1): crop and cover by dragging on the image,\n * quarter turns, undo and redo. The edits are the model, the image stays\n * as it was loaded. Dragging needs a mouse, a pen or a finger; the rest\n * works from the keyboard.\n */\n const props = defineProps<{\n /** The image the edits start from. */\n image: HTMLCanvasElement\n }>()\n\n const emit = defineEmits<{\n /** The browser could not draw the image, out of canvas memory. */\n error: []\n }>()\n\n const edits = defineModel<ImageEdit[]>('edits', { required: true })\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n // --- Tools ---\n\n type Tool = 'crop' | 'cover'\n type Aspect = 'free' | '1:1' | '4:3' | '16:9'\n\n const ASPECTS: Record<Aspect, number | undefined> = {\n free: undefined,\n '1:1': 1,\n '4:3': 4 / 3,\n '16:9': 16 / 9,\n }\n\n const tool = ref<Tool>('crop')\n const aspect = ref<Aspect>('free')\n // Every opening starts on the solid box, the only cover safe on a text:\n // the pixels picked for a face yesterday do not cover an IBAN today\n const coverStyle = ref<CoverStyle>('solid')\n\n const toolOptions = computed(() => [\n { value: 'crop', label: $t('imageEditor.crop') },\n { value: 'cover', label: $t('imageEditor.cover') },\n ])\n const aspectOptions = computed(() => [\n { value: 'free', label: $t('imageEditor.aspectFree') },\n { value: '1:1', label: '1:1' },\n { value: '4:3', label: '4:3' },\n { value: '16:9', label: '16:9' },\n ])\n const coverOptions = computed(() => [\n { value: 'solid', label: $t('imageEditor.coverSolid') },\n { value: 'pixelate', label: $t('imageEditor.coverPixelate') },\n ])\n const aspectLabelId = useId()\n\n // --- History ---\n\n const redoStack = ref<ImageEdit[]>([])\n\n function push(edit: ImageEdit) {\n edits.value = [...edits.value, edit]\n redoStack.value = []\n }\n\n function undo() {\n selection.value = undefined\n const last = edits.value[edits.value.length - 1]\n if (!last) {\n return\n }\n edits.value = edits.value.slice(0, -1)\n redoStack.value = [...redoStack.value, last]\n }\n\n function redo() {\n selection.value = undefined\n const next = redoStack.value[redoStack.value.length - 1]\n if (!next) {\n return\n }\n edits.value = [...edits.value, next]\n redoStack.value = redoStack.value.slice(0, -1)\n }\n\n function rotate(turn: 1 | -1) {\n selection.value = undefined\n push({ kind: 'rotate', turn })\n }\n\n // --- Drawing ---\n\n const size = computed(() => sizeAfterEdits(props.image, edits.value))\n const stageEl = useTemplateRef<HTMLDivElement>('stageEl')\n // The canvas on screen, outside Vue: a new one replaces it on each edit\n let shown: HTMLCanvasElement | undefined\n\n function draw() {\n if (!stageEl.value) {\n return\n }\n let canvas: HTMLCanvasElement\n try {\n canvas = renderEdits(props.image, edits.value)\n } catch {\n emit('error')\n return\n }\n canvas.setAttribute('role', 'img')\n canvas.setAttribute('aria-label', $t('imageEditor.canvasLabel'))\n stageEl.value.replaceChildren(canvas)\n if (shown) {\n releaseCanvas(shown)\n }\n shown = canvas\n }\n\n onMounted(draw)\n watch([() => props.image, edits], draw, { flush: 'post' })\n onBeforeUnmount(() => {\n if (shown) {\n releaseCanvas(shown)\n }\n })\n\n // The image fits the room it has, never drawn larger than its pixels\n const areaEl = useTemplateRef<HTMLDivElement>('areaEl')\n const room = ref({ width: 0, height: 0 })\n useResizeObserver(areaEl, ([entry]) => {\n if (entry) {\n room.value = {\n width: entry.contentRect.width,\n height: entry.contentRect.height,\n }\n }\n })\n const scale = computed(() =>\n Math.min(\n 1,\n room.value.width / size.value.width,\n room.value.height / size.value.height,\n ),\n )\n const frameStyle = computed(() => ({\n width: `${Math.max(1, Math.floor(size.value.width * scale.value))}px`,\n height: `${Math.max(1, Math.floor(size.value.height * scale.value))}px`,\n }))\n\n // --- Dragging a rectangle ---\n\n /** A rectangle thinner than this on screen is a click, not a drag. */\n const MIN_DRAG = 6\n\n const frameEl = useTemplateRef<HTMLDivElement>('frameEl')\n const selection = ref<ImageRect>()\n const dragFrom = ref<ImagePoint>()\n\n function pointOf(event: PointerEvent): ImagePoint {\n const box = frameEl.value?.getBoundingClientRect()\n if (!box?.width || !box.height) {\n return { x: 0, y: 0 }\n }\n return {\n x: ((event.clientX - box.left) / box.width) * size.value.width,\n y: ((event.clientY - box.top) / box.height) * size.value.height,\n }\n }\n\n function onPointerDown(event: PointerEvent) {\n if (event.button !== 0) {\n return\n }\n frameEl.value?.setPointerCapture(event.pointerId)\n dragFrom.value = pointOf(event)\n selection.value = undefined\n }\n\n function onPointerMove(event: PointerEvent) {\n if (!dragFrom.value) {\n return\n }\n selection.value = dragRect(\n dragFrom.value,\n pointOf(event),\n size.value,\n tool.value === 'crop' ? ASPECTS[aspect.value] : undefined,\n )\n }\n\n function onPointerUp() {\n if (!dragFrom.value) {\n return\n }\n dragFrom.value = undefined\n const rect = selection.value\n if (\n !rect ||\n rect.width * scale.value < MIN_DRAG ||\n rect.height * scale.value < MIN_DRAG\n ) {\n selection.value = undefined\n return\n }\n // A cover is written as soon as it is drawn; a crop waits for Apply\n if (tool.value === 'cover') {\n selection.value = undefined\n push({ kind: 'cover', rect, style: coverStyle.value })\n }\n }\n\n function onPointerCancel() {\n dragFrom.value = undefined\n selection.value = undefined\n }\n\n const pendingCrop = computed(\n () => tool.value === 'crop' && !dragFrom.value && !!selection.value,\n )\n\n function applyCrop() {\n const rect = selection.value\n if (!pendingCrop.value || !rect) {\n return\n }\n selection.value = undefined\n if (\n rect.width === size.value.width &&\n rect.height === size.value.height\n ) {\n return\n }\n push({ kind: 'crop', rect })\n }\n\n watch(tool, () => {\n selection.value = undefined\n })\n\n // A crop drawn and then given proportions keeps its corner and takes them\n watch(aspect, (value) => {\n const rect = selection.value\n if (rect && tool.value === 'crop') {\n selection.value = dragRect(\n rect,\n { x: rect.x + rect.width, y: rect.y + rect.height },\n size.value,\n ASPECTS[value],\n )\n }\n })\n\n const selectionStyle = computed(() => {\n const rect = selection.value\n if (!rect) {\n return undefined\n }\n return {\n left: `${(rect.x / size.value.width) * 100}%`,\n top: `${(rect.y / size.value.height) * 100}%`,\n width: `${(rect.width / size.value.width) * 100}%`,\n height: `${(rect.height / size.value.height) * 100}%`,\n }\n })\n\n defineExpose({\n /** A crop is drawn and not applied yet. */\n pendingCrop,\n /** Applies the crop drawn, as Apply does: \"Use the image\" calls it first. */\n applyCrop,\n /**\n * The canvas on screen, every edit drawn, which the host writes as\n * the file: it stays the editor's, released when the editor goes.\n */\n shownCanvas: () => shown,\n })\n</script>\n\n<template>\n <div class=\"pk-image-editor\">\n <div class=\"pk-image-editor__toolbar\">\n <PkEditorRadioButtons\n v-model=\"tool\"\n name=\"pk-image-editor-tool\"\n segmented\n class=\"mb-0\"\n :aria-label=\"$t('imageEditor.tool')\"\n :options=\"toolOptions\">\n <template #crop=\"{ option }\">\n <VvIcon name=\"ri:crop-line\" class=\"w-16 h-16\" />\n {{ option.label }}\n </template>\n <template #cover=\"{ option }\">\n <VvIcon name=\"ri:eye-off-line\" class=\"w-16 h-16\" />\n {{ option.label }}\n </template>\n </PkEditorRadioButtons>\n <VvButtonGroup modifiers=\"compact\">\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:anticlockwise-line\"\n :title=\"$t('imageEditor.rotateLeft')\"\n :aria-label=\"$t('imageEditor.rotateLeft')\"\n @click=\"rotate(-1)\" />\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:clockwise-line\"\n :title=\"$t('imageEditor.rotateRight')\"\n :aria-label=\"$t('imageEditor.rotateRight')\"\n @click=\"rotate(1)\" />\n </VvButtonGroup>\n <!-- \"Annulla\" is already the dialog's button: two \"Annulla\"\n doing different things in one window read as one -->\n <VvButtonGroup modifiers=\"compact\" class=\"ml-auto\">\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:arrow-go-back-line\"\n :title=\"$t('imageEditor.undo')\"\n :aria-label=\"$t('imageEditor.undo')\"\n :disabled=\"!edits.length\"\n @click=\"undo\" />\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:arrow-go-forward-line\"\n :title=\"$t('imageEditor.redo')\"\n :aria-label=\"$t('imageEditor.redo')\"\n :disabled=\"!redoStack.length\"\n @click=\"redo\" />\n </VvButtonGroup>\n </div>\n <div class=\"pk-image-editor__options\">\n <template v-if=\"tool === 'crop'\">\n <span :id=\"aspectLabelId\" class=\"pk-image-editor__label\">\n {{ $t('imageEditor.aspect') }}\n </span>\n <PkEditorRadioButtons\n v-model=\"aspect\"\n name=\"pk-image-editor-aspect\"\n segmented\n class=\"mb-0\"\n :aria-labelledby=\"aspectLabelId\"\n :options=\"aspectOptions\" />\n <span class=\"pk-image-editor__hint\">\n {{ $t('imageEditor.cropHint') }}\n </span>\n <VvButton\n class=\"ml-auto\"\n modifiers=\"secondary\"\n :label=\"$t('action.apply')\"\n :disabled=\"!pendingCrop\"\n @click=\"applyCrop\" />\n </template>\n <template v-else>\n <PkEditorRadioButtons\n v-model=\"coverStyle\"\n name=\"pk-image-editor-cover\"\n segmented\n class=\"mb-0\"\n :aria-label=\"$t('imageEditor.coverStyle')\"\n :options=\"coverOptions\" />\n <span class=\"pk-image-editor__hint\">\n {{ $t('imageEditor.coverHint') }}\n </span>\n </template>\n </div>\n <div ref=\"areaEl\" class=\"pk-image-editor__area\">\n <div\n ref=\"frameEl\"\n class=\"pk-image-editor__frame\"\n :style=\"frameStyle\"\n @pointerdown=\"onPointerDown\"\n @pointermove=\"onPointerMove\"\n @pointerup=\"onPointerUp\"\n @pointercancel=\"onPointerCancel\">\n <div ref=\"stageEl\" class=\"pk-image-editor__stage\" />\n <div\n v-if=\"selection\"\n class=\"pk-image-editor__selection\"\n :class=\"`pk-image-editor__selection--${tool}`\"\n :style=\"selectionStyle\" />\n </div>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-image-editor {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n\n &__toolbar,\n &__options {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--spacing-8);\n padding: var(--spacing-8) var(--spacing-md);\n border-bottom: 1px solid var(--color-surface-3);\n }\n\n &__toolbar {\n background-color: var(--color-surface-1);\n }\n\n // A segmented control is as wide as its options, each as wide as its\n // words: with the library's equal segments the longer one was cut\n // (\"Riquadro pien\") and its icon shrank. A row too narrow sends the\n // control to a line of its own.\n &__toolbar > .vv-radio-group,\n &__options > .vv-radio-group {\n flex: none;\n width: auto;\n\n .vv-radio {\n flex: none;\n }\n }\n\n &__label {\n color: var(--color-word-2);\n font-size: var(--text-14);\n }\n\n &__hint {\n color: var(--color-word-3);\n font-size: var(--text-12);\n }\n\n // A checkerboard, as in the lightbox: a transparent PNG shows where\n // it is transparent\n &__area {\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n min-height: 12rem;\n padding: var(--spacing-md);\n overflow: hidden;\n background: repeating-conic-gradient(\n var(--color-surface-2) 0% 25%,\n var(--color-surface) 0% 50%\n )\n 50% / 16px 16px;\n }\n\n &__frame {\n position: relative;\n flex-shrink: 0;\n overflow: hidden;\n box-shadow: var(--shadow-sm);\n cursor: crosshair;\n\n // The drag is the gesture: no scroll or zoom of the page under it\n touch-action: none;\n user-select: none;\n }\n\n &__stage,\n &__stage > canvas {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n // Drawn over a photo, so the same in both themes: white with a dark\n // edge reads on any image\n &__selection {\n position: absolute;\n pointer-events: none;\n border: 2px solid var(--color-white);\n outline: 1px solid\n color-mix(in srgb, var(--color-black) 50%, transparent);\n\n // What a crop leaves out goes dark\n &--crop {\n box-shadow: 0 0 0 100vmax\n color-mix(in srgb, var(--color-black) 55%, transparent);\n }\n\n &--cover {\n border-style: dashed;\n background-color: color-mix(\n in srgb,\n var(--color-black) 30%,\n transparent\n );\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import {\n computed,\n onBeforeUnmount,\n onMounted,\n ref,\n useId,\n useTemplateRef,\n watch,\n } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useResizeObserver } from '@vueuse/core'\n import PkEditorRadioButtons from '../PkEditorRadioButtons.vue'\n import {\n dragRect,\n releaseCanvas,\n renderEdits,\n sizeAfterEdits,\n type CoverStyle,\n type ImageEdit,\n type ImagePoint,\n type ImageRect,\n } from './imageEdits'\n\n /**\n * The tools of the image editor over the image they change (spec\n * `chat-image-editor.md`, F1): crop and cover by dragging on the image,\n * quarter turns, undo and redo. The edits are the model, the image stays\n * as it was loaded. Dragging needs a mouse, a pen or a finger; the rest\n * works from the keyboard.\n */\n const props = defineProps<{\n /** The image the edits start from. */\n image: HTMLCanvasElement\n }>()\n\n const emit = defineEmits<{\n /** The browser could not draw the image, out of canvas memory. */\n error: []\n }>()\n\n const edits = defineModel<ImageEdit[]>('edits', { required: true })\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n // --- Tools ---\n\n type Tool = 'crop' | 'cover'\n type Aspect = 'free' | '1:1' | '4:3' | '16:9'\n\n const ASPECTS: Record<Aspect, number | undefined> = {\n free: undefined,\n '1:1': 1,\n '4:3': 4 / 3,\n '16:9': 16 / 9,\n }\n\n const tool = ref<Tool>('crop')\n const aspect = ref<Aspect>('free')\n // Every opening starts on the solid box, the only cover safe on a text:\n // the pixels picked for a face yesterday do not cover an IBAN today\n const coverStyle = ref<CoverStyle>('solid')\n\n const toolOptions = computed(() => [\n { value: 'crop', label: $t('imageEditor.crop') },\n { value: 'cover', label: $t('imageEditor.cover') },\n ])\n const aspectOptions = computed(() => [\n { value: 'free', label: $t('imageEditor.aspectFree') },\n { value: '1:1', label: '1:1' },\n { value: '4:3', label: '4:3' },\n { value: '16:9', label: '16:9' },\n ])\n const coverOptions = computed(() => [\n { value: 'solid', label: $t('imageEditor.coverSolid') },\n { value: 'pixelate', label: $t('imageEditor.coverPixelate') },\n ])\n const aspectLabelId = useId()\n\n // --- History ---\n\n const redoStack = ref<ImageEdit[]>([])\n\n function push(edit: ImageEdit) {\n edits.value = [...edits.value, edit]\n redoStack.value = []\n }\n\n function undo() {\n selection.value = undefined\n const last = edits.value[edits.value.length - 1]\n if (!last) {\n return\n }\n edits.value = edits.value.slice(0, -1)\n redoStack.value = [...redoStack.value, last]\n }\n\n function redo() {\n selection.value = undefined\n const next = redoStack.value[redoStack.value.length - 1]\n if (!next) {\n return\n }\n edits.value = [...edits.value, next]\n redoStack.value = redoStack.value.slice(0, -1)\n }\n\n function rotate(turn: 1 | -1) {\n selection.value = undefined\n push({ kind: 'rotate', turn })\n }\n\n // --- Drawing ---\n\n const size = computed(() => sizeAfterEdits(props.image, edits.value))\n const stageEl = useTemplateRef<HTMLDivElement>('stageEl')\n // The canvas on screen, outside Vue: a new one replaces it on each edit\n let shown: HTMLCanvasElement | undefined\n\n function draw() {\n if (!stageEl.value) {\n return\n }\n let canvas: HTMLCanvasElement\n try {\n canvas = renderEdits(props.image, edits.value)\n } catch {\n emit('error')\n return\n }\n canvas.setAttribute('role', 'img')\n canvas.setAttribute('aria-label', $t('imageEditor.canvasLabel'))\n stageEl.value.replaceChildren(canvas)\n if (shown) {\n releaseCanvas(shown)\n }\n shown = canvas\n }\n\n onMounted(draw)\n watch([() => props.image, edits], draw, { flush: 'post' })\n onBeforeUnmount(() => {\n if (shown) {\n releaseCanvas(shown)\n }\n })\n\n // The image fits the room it has, never drawn larger than its pixels\n const areaEl = useTemplateRef<HTMLDivElement>('areaEl')\n const room = ref({ width: 0, height: 0 })\n useResizeObserver(areaEl, ([entry]) => {\n if (entry) {\n room.value = {\n width: entry.contentRect.width,\n height: entry.contentRect.height,\n }\n }\n })\n const scale = computed(() =>\n Math.min(\n 1,\n room.value.width / size.value.width,\n room.value.height / size.value.height,\n ),\n )\n const frameStyle = computed(() => ({\n width: `${Math.max(1, Math.floor(size.value.width * scale.value))}px`,\n height: `${Math.max(1, Math.floor(size.value.height * scale.value))}px`,\n }))\n\n // --- Dragging a rectangle ---\n\n /** A rectangle thinner than this on screen is a click, not a drag. */\n const MIN_DRAG = 6\n\n const frameEl = useTemplateRef<HTMLDivElement>('frameEl')\n const selection = ref<ImageRect>()\n const dragFrom = ref<ImagePoint>()\n\n function pointOf(event: PointerEvent): ImagePoint {\n const box = frameEl.value?.getBoundingClientRect()\n if (!box?.width || !box.height) {\n return { x: 0, y: 0 }\n }\n return {\n x: ((event.clientX - box.left) / box.width) * size.value.width,\n y: ((event.clientY - box.top) / box.height) * size.value.height,\n }\n }\n\n function onPointerDown(event: PointerEvent) {\n if (event.button !== 0) {\n return\n }\n frameEl.value?.setPointerCapture(event.pointerId)\n dragFrom.value = pointOf(event)\n selection.value = undefined\n }\n\n function onPointerMove(event: PointerEvent) {\n if (!dragFrom.value) {\n return\n }\n selection.value = dragRect(\n dragFrom.value,\n pointOf(event),\n size.value,\n tool.value === 'crop' ? ASPECTS[aspect.value] : undefined,\n )\n }\n\n function onPointerUp() {\n if (!dragFrom.value) {\n return\n }\n dragFrom.value = undefined\n const rect = selection.value\n if (\n !rect ||\n rect.width * scale.value < MIN_DRAG ||\n rect.height * scale.value < MIN_DRAG\n ) {\n selection.value = undefined\n return\n }\n // A cover is written as soon as it is drawn; a crop waits for Apply\n if (tool.value === 'cover') {\n selection.value = undefined\n push({ kind: 'cover', rect, style: coverStyle.value })\n }\n }\n\n function onPointerCancel() {\n dragFrom.value = undefined\n selection.value = undefined\n }\n\n const pendingCrop = computed(\n () => tool.value === 'crop' && !dragFrom.value && !!selection.value,\n )\n\n function applyCrop() {\n const rect = selection.value\n if (!pendingCrop.value || !rect) {\n return\n }\n selection.value = undefined\n if (\n rect.width === size.value.width &&\n rect.height === size.value.height\n ) {\n return\n }\n push({ kind: 'crop', rect })\n }\n\n watch(tool, () => {\n selection.value = undefined\n })\n\n // A crop drawn and then given proportions keeps its corner and takes them\n watch(aspect, (value) => {\n const rect = selection.value\n if (rect && tool.value === 'crop') {\n selection.value = dragRect(\n rect,\n { x: rect.x + rect.width, y: rect.y + rect.height },\n size.value,\n ASPECTS[value],\n )\n }\n })\n\n const selectionStyle = computed(() => {\n const rect = selection.value\n if (!rect) {\n return undefined\n }\n return {\n left: `${(rect.x / size.value.width) * 100}%`,\n top: `${(rect.y / size.value.height) * 100}%`,\n width: `${(rect.width / size.value.width) * 100}%`,\n height: `${(rect.height / size.value.height) * 100}%`,\n }\n })\n\n defineExpose({\n /** A crop is drawn and not applied yet. */\n pendingCrop,\n /** Applies the crop drawn, as Apply does: \"Use the image\" calls it first. */\n applyCrop,\n /**\n * The canvas on screen, every edit drawn, which the host writes as\n * the file: it stays the editor's, released when the editor goes.\n */\n shownCanvas: () => shown,\n })\n</script>\n\n<template>\n <div class=\"pk-image-editor\">\n <div class=\"pk-image-editor__toolbar\">\n <PkEditorRadioButtons\n v-model=\"tool\"\n name=\"pk-image-editor-tool\"\n segmented\n class=\"mb-0\"\n :aria-label=\"$t('imageEditor.tool')\"\n :options=\"toolOptions\">\n <template #crop=\"{ option }\">\n <VvIcon name=\"ri:crop-line\" class=\"w-16 h-16\" />\n {{ option.label }}\n </template>\n <template #cover=\"{ option }\">\n <VvIcon name=\"ri:eye-off-line\" class=\"w-16 h-16\" />\n {{ option.label }}\n </template>\n </PkEditorRadioButtons>\n <VvButtonGroup modifiers=\"compact\">\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:anticlockwise-line\"\n :title=\"$t('imageEditor.rotateLeft')\"\n :aria-label=\"$t('imageEditor.rotateLeft')\"\n @click=\"rotate(-1)\" />\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:clockwise-line\"\n :title=\"$t('imageEditor.rotateRight')\"\n :aria-label=\"$t('imageEditor.rotateRight')\"\n @click=\"rotate(1)\" />\n </VvButtonGroup>\n <!-- \"Annulla\" is already the dialog's button: two \"Annulla\"\n doing different things in one window read as one -->\n <VvButtonGroup modifiers=\"compact\" class=\"ml-auto\">\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:arrow-go-back-line\"\n :title=\"$t('imageEditor.undo')\"\n :aria-label=\"$t('imageEditor.undo')\"\n :disabled=\"!edits.length\"\n @click=\"undo\" />\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:arrow-go-forward-line\"\n :title=\"$t('imageEditor.redo')\"\n :aria-label=\"$t('imageEditor.redo')\"\n :disabled=\"!redoStack.length\"\n @click=\"redo\" />\n </VvButtonGroup>\n </div>\n <div class=\"pk-image-editor__options\">\n <template v-if=\"tool === 'crop'\">\n <span :id=\"aspectLabelId\" class=\"pk-image-editor__label\">\n {{ $t('imageEditor.aspect') }}\n </span>\n <PkEditorRadioButtons\n v-model=\"aspect\"\n name=\"pk-image-editor-aspect\"\n segmented\n class=\"mb-0\"\n :aria-labelledby=\"aspectLabelId\"\n :options=\"aspectOptions\" />\n <span class=\"pk-image-editor__hint\">\n {{ $t('imageEditor.cropHint') }}\n </span>\n <VvButton\n class=\"ml-auto\"\n modifiers=\"secondary\"\n :label=\"$t('action.apply')\"\n :disabled=\"!pendingCrop\"\n @click=\"applyCrop\" />\n </template>\n <template v-else>\n <PkEditorRadioButtons\n v-model=\"coverStyle\"\n name=\"pk-image-editor-cover\"\n segmented\n class=\"mb-0\"\n :aria-label=\"$t('imageEditor.coverStyle')\"\n :options=\"coverOptions\" />\n <span class=\"pk-image-editor__hint\">\n {{ $t('imageEditor.coverHint') }}\n </span>\n </template>\n </div>\n <div ref=\"areaEl\" class=\"pk-image-editor__area\">\n <div\n ref=\"frameEl\"\n class=\"pk-image-editor__frame\"\n :style=\"frameStyle\"\n @pointerdown=\"onPointerDown\"\n @pointermove=\"onPointerMove\"\n @pointerup=\"onPointerUp\"\n @pointercancel=\"onPointerCancel\">\n <div ref=\"stageEl\" class=\"pk-image-editor__stage\" />\n <div\n v-if=\"selection\"\n class=\"pk-image-editor__selection\"\n :class=\"`pk-image-editor__selection--${tool}`\"\n :style=\"selectionStyle\" />\n </div>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-image-editor {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n\n &__toolbar,\n &__options {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--spacing-8);\n padding: var(--spacing-8) var(--spacing-md);\n border-bottom: 1px solid var(--color-surface-3);\n }\n\n &__toolbar {\n background-color: var(--color-surface-1);\n }\n\n // A segmented control is as wide as its options, each as wide as its\n // words: with the library's equal segments the longer one was cut\n // (\"Riquadro pien\") and its icon shrank. A row too narrow sends the\n // control to a line of its own.\n &__toolbar > .vv-radio-group,\n &__options > .vv-radio-group {\n flex: none;\n width: auto;\n\n .vv-radio {\n flex: none;\n }\n }\n\n &__label {\n color: var(--color-word-2);\n font-size: var(--text-14);\n }\n\n &__hint {\n color: var(--color-word-3);\n font-size: var(--text-12);\n }\n\n // A checkerboard, as in the lightbox: a transparent PNG shows where\n // it is transparent\n &__area {\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n min-height: 12rem;\n padding: var(--spacing-md);\n overflow: hidden;\n background: repeating-conic-gradient(\n var(--color-surface-2) 0% 25%,\n var(--color-surface) 0% 50%\n )\n 50% / 16px 16px;\n }\n\n &__frame {\n position: relative;\n flex-shrink: 0;\n overflow: hidden;\n box-shadow: var(--shadow-sm);\n cursor: crosshair;\n\n // The drag is the gesture: no scroll or zoom of the page under it\n touch-action: none;\n user-select: none;\n }\n\n &__stage,\n &__stage > canvas {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n // Drawn over a photo, so the same in both themes: white with a dark\n // edge reads on any image\n &__selection {\n position: absolute;\n pointer-events: none;\n border: 2px solid var(--color-white);\n outline: 1px solid\n color-mix(in srgb, var(--color-black) 50%, transparent);\n\n // What a crop leaves out goes dark\n &--crop {\n box-shadow: 0 0 0 100vmax\n color-mix(in srgb, var(--color-black) 55%, transparent);\n }\n\n &--cover {\n border-style: dashed;\n background-color: color-mix(\n in srgb,\n var(--color-black) 30%,\n transparent\n );\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import {\n computed,\n onBeforeUnmount,\n onMounted,\n ref,\n useId,\n useTemplateRef,\n watch,\n } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useResizeObserver } from '@vueuse/core'\n import PkEditorRadioButtons from '../PkEditorRadioButtons.vue'\n import {\n dragRect,\n releaseCanvas,\n renderEdits,\n sizeAfterEdits,\n type CoverStyle,\n type ImageEdit,\n type ImagePoint,\n type ImageRect,\n } from './imageEdits'\n\n /**\n * The tools of the image editor over the image they change (spec\n * `chat-image-editor.md`, F1): crop and cover by dragging on the image,\n * quarter turns, undo and redo. The edits are the model, the image stays\n * as it was loaded. Dragging needs a mouse, a pen or a finger; the rest\n * works from the keyboard.\n */\n const props = defineProps<{\n /** The image the edits start from. */\n image: HTMLCanvasElement\n }>()\n\n const emit = defineEmits<{\n /** The browser could not draw the image, out of canvas memory. */\n error: []\n }>()\n\n const edits = defineModel<ImageEdit[]>('edits', { required: true })\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n // --- Tools ---\n\n type Tool = 'crop' | 'cover'\n type Aspect = 'free' | '1:1' | '4:3' | '16:9'\n\n const ASPECTS: Record<Aspect, number | undefined> = {\n free: undefined,\n '1:1': 1,\n '4:3': 4 / 3,\n '16:9': 16 / 9,\n }\n\n const tool = ref<Tool>('crop')\n const aspect = ref<Aspect>('free')\n // Every opening starts on the solid box, the only cover safe on a text:\n // the pixels picked for a face yesterday do not cover an IBAN today\n const coverStyle = ref<CoverStyle>('solid')\n\n const toolOptions = computed(() => [\n { value: 'crop', label: $t('imageEditor.crop') },\n { value: 'cover', label: $t('imageEditor.cover') },\n ])\n const aspectOptions = computed(() => [\n { value: 'free', label: $t('imageEditor.aspectFree') },\n { value: '1:1', label: '1:1' },\n { value: '4:3', label: '4:3' },\n { value: '16:9', label: '16:9' },\n ])\n const coverOptions = computed(() => [\n { value: 'solid', label: $t('imageEditor.coverSolid') },\n { value: 'pixelate', label: $t('imageEditor.coverPixelate') },\n ])\n const aspectLabelId = useId()\n\n // --- History ---\n\n const redoStack = ref<ImageEdit[]>([])\n\n function push(edit: ImageEdit) {\n edits.value = [...edits.value, edit]\n redoStack.value = []\n }\n\n function undo() {\n selection.value = undefined\n const last = edits.value[edits.value.length - 1]\n if (!last) {\n return\n }\n edits.value = edits.value.slice(0, -1)\n redoStack.value = [...redoStack.value, last]\n }\n\n function redo() {\n selection.value = undefined\n const next = redoStack.value[redoStack.value.length - 1]\n if (!next) {\n return\n }\n edits.value = [...edits.value, next]\n redoStack.value = redoStack.value.slice(0, -1)\n }\n\n function rotate(turn: 1 | -1) {\n selection.value = undefined\n push({ kind: 'rotate', turn })\n }\n\n // --- Drawing ---\n\n const size = computed(() => sizeAfterEdits(props.image, edits.value))\n const stageEl = useTemplateRef<HTMLDivElement>('stageEl')\n // The canvas on screen, outside Vue: a new one replaces it on each edit\n let shown: HTMLCanvasElement | undefined\n\n function draw() {\n if (!stageEl.value) {\n return\n }\n let canvas: HTMLCanvasElement\n try {\n canvas = renderEdits(props.image, edits.value)\n } catch {\n emit('error')\n return\n }\n canvas.setAttribute('role', 'img')\n canvas.setAttribute('aria-label', $t('imageEditor.canvasLabel'))\n stageEl.value.replaceChildren(canvas)\n if (shown) {\n releaseCanvas(shown)\n }\n shown = canvas\n }\n\n onMounted(draw)\n watch([() => props.image, edits], draw, { flush: 'post' })\n onBeforeUnmount(() => {\n if (shown) {\n releaseCanvas(shown)\n }\n })\n\n // The image fits the room it has, never drawn larger than its pixels\n const areaEl = useTemplateRef<HTMLDivElement>('areaEl')\n const room = ref({ width: 0, height: 0 })\n useResizeObserver(areaEl, ([entry]) => {\n if (entry) {\n room.value = {\n width: entry.contentRect.width,\n height: entry.contentRect.height,\n }\n }\n })\n const scale = computed(() =>\n Math.min(\n 1,\n room.value.width / size.value.width,\n room.value.height / size.value.height,\n ),\n )\n const frameStyle = computed(() => ({\n width: `${Math.max(1, Math.floor(size.value.width * scale.value))}px`,\n height: `${Math.max(1, Math.floor(size.value.height * scale.value))}px`,\n }))\n\n // --- Dragging a rectangle ---\n\n /** A rectangle thinner than this on screen is a click, not a drag. */\n const MIN_DRAG = 6\n\n const frameEl = useTemplateRef<HTMLDivElement>('frameEl')\n const selection = ref<ImageRect>()\n const dragFrom = ref<ImagePoint>()\n\n function pointOf(event: PointerEvent): ImagePoint {\n const box = frameEl.value?.getBoundingClientRect()\n if (!box?.width || !box.height) {\n return { x: 0, y: 0 }\n }\n return {\n x: ((event.clientX - box.left) / box.width) * size.value.width,\n y: ((event.clientY - box.top) / box.height) * size.value.height,\n }\n }\n\n function onPointerDown(event: PointerEvent) {\n if (event.button !== 0) {\n return\n }\n frameEl.value?.setPointerCapture(event.pointerId)\n dragFrom.value = pointOf(event)\n selection.value = undefined\n }\n\n function onPointerMove(event: PointerEvent) {\n if (!dragFrom.value) {\n return\n }\n selection.value = dragRect(\n dragFrom.value,\n pointOf(event),\n size.value,\n tool.value === 'crop' ? ASPECTS[aspect.value] : undefined,\n )\n }\n\n function onPointerUp() {\n if (!dragFrom.value) {\n return\n }\n dragFrom.value = undefined\n const rect = selection.value\n if (\n !rect ||\n rect.width * scale.value < MIN_DRAG ||\n rect.height * scale.value < MIN_DRAG\n ) {\n selection.value = undefined\n return\n }\n // A cover is written as soon as it is drawn; a crop waits for Apply\n if (tool.value === 'cover') {\n selection.value = undefined\n push({ kind: 'cover', rect, style: coverStyle.value })\n }\n }\n\n function onPointerCancel() {\n dragFrom.value = undefined\n selection.value = undefined\n }\n\n const pendingCrop = computed(\n () => tool.value === 'crop' && !dragFrom.value && !!selection.value,\n )\n\n function applyCrop() {\n const rect = selection.value\n if (!pendingCrop.value || !rect) {\n return\n }\n selection.value = undefined\n if (\n rect.width === size.value.width &&\n rect.height === size.value.height\n ) {\n return\n }\n push({ kind: 'crop', rect })\n }\n\n watch(tool, () => {\n selection.value = undefined\n })\n\n // A crop drawn and then given proportions keeps its corner and takes them\n watch(aspect, (value) => {\n const rect = selection.value\n if (rect && tool.value === 'crop') {\n selection.value = dragRect(\n rect,\n { x: rect.x + rect.width, y: rect.y + rect.height },\n size.value,\n ASPECTS[value],\n )\n }\n })\n\n const selectionStyle = computed(() => {\n const rect = selection.value\n if (!rect) {\n return undefined\n }\n return {\n left: `${(rect.x / size.value.width) * 100}%`,\n top: `${(rect.y / size.value.height) * 100}%`,\n width: `${(rect.width / size.value.width) * 100}%`,\n height: `${(rect.height / size.value.height) * 100}%`,\n }\n })\n\n defineExpose({\n /** A crop is drawn and not applied yet. */\n pendingCrop,\n /** Applies the crop drawn, as Apply does: \"Use the image\" calls it first. */\n applyCrop,\n /**\n * The canvas on screen, every edit drawn, which the host writes as\n * the file: it stays the editor's, released when the editor goes.\n */\n shownCanvas: () => shown,\n })\n</script>\n\n<template>\n <div class=\"pk-image-editor\">\n <div class=\"pk-image-editor__toolbar\">\n <PkEditorRadioButtons\n v-model=\"tool\"\n name=\"pk-image-editor-tool\"\n segmented\n class=\"mb-0\"\n :aria-label=\"$t('imageEditor.tool')\"\n :options=\"toolOptions\">\n <template #crop=\"{ option }\">\n <VvIcon name=\"ri:crop-line\" class=\"w-16 h-16\" />\n {{ option.label }}\n </template>\n <template #cover=\"{ option }\">\n <VvIcon name=\"ri:eye-off-line\" class=\"w-16 h-16\" />\n {{ option.label }}\n </template>\n </PkEditorRadioButtons>\n <VvButtonGroup modifiers=\"compact\">\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:anticlockwise-line\"\n :title=\"$t('imageEditor.rotateLeft')\"\n :aria-label=\"$t('imageEditor.rotateLeft')\"\n @click=\"rotate(-1)\" />\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:clockwise-line\"\n :title=\"$t('imageEditor.rotateRight')\"\n :aria-label=\"$t('imageEditor.rotateRight')\"\n @click=\"rotate(1)\" />\n </VvButtonGroup>\n <!-- \"Annulla\" is already the dialog's button: two \"Annulla\"\n doing different things in one window read as one -->\n <VvButtonGroup modifiers=\"compact\" class=\"ml-auto\">\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:arrow-go-back-line\"\n :title=\"$t('imageEditor.undo')\"\n :aria-label=\"$t('imageEditor.undo')\"\n :disabled=\"!edits.length\"\n @click=\"undo\" />\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:arrow-go-forward-line\"\n :title=\"$t('imageEditor.redo')\"\n :aria-label=\"$t('imageEditor.redo')\"\n :disabled=\"!redoStack.length\"\n @click=\"redo\" />\n </VvButtonGroup>\n </div>\n <div class=\"pk-image-editor__options\">\n <template v-if=\"tool === 'crop'\">\n <span :id=\"aspectLabelId\" class=\"pk-image-editor__label\">\n {{ $t('imageEditor.aspect') }}\n </span>\n <PkEditorRadioButtons\n v-model=\"aspect\"\n name=\"pk-image-editor-aspect\"\n segmented\n class=\"mb-0\"\n :aria-labelledby=\"aspectLabelId\"\n :options=\"aspectOptions\" />\n <span class=\"pk-image-editor__hint\">\n {{ $t('imageEditor.cropHint') }}\n </span>\n <VvButton\n class=\"ml-auto\"\n modifiers=\"secondary\"\n :label=\"$t('action.apply')\"\n :disabled=\"!pendingCrop\"\n @click=\"applyCrop\" />\n </template>\n <template v-else>\n <PkEditorRadioButtons\n v-model=\"coverStyle\"\n name=\"pk-image-editor-cover\"\n segmented\n class=\"mb-0\"\n :aria-label=\"$t('imageEditor.coverStyle')\"\n :options=\"coverOptions\" />\n <span class=\"pk-image-editor__hint\">\n {{ $t('imageEditor.coverHint') }}\n </span>\n </template>\n </div>\n <div ref=\"areaEl\" class=\"pk-image-editor__area\">\n <div\n ref=\"frameEl\"\n class=\"pk-image-editor__frame\"\n :style=\"frameStyle\"\n @pointerdown=\"onPointerDown\"\n @pointermove=\"onPointerMove\"\n @pointerup=\"onPointerUp\"\n @pointercancel=\"onPointerCancel\">\n <div ref=\"stageEl\" class=\"pk-image-editor__stage\" />\n <div\n v-if=\"selection\"\n class=\"pk-image-editor__selection\"\n :class=\"`pk-image-editor__selection--${tool}`\"\n :style=\"selectionStyle\" />\n </div>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-image-editor {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n\n &__toolbar,\n &__options {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--spacing-8);\n padding: var(--spacing-8) var(--spacing-md);\n border-bottom: 1px solid var(--color-surface-3);\n }\n\n &__toolbar {\n background-color: var(--color-surface-1);\n }\n\n // A segmented control is as wide as its options, each as wide as its\n // words: with the library's equal segments the longer one was cut\n // (\"Riquadro pien\") and its icon shrank. A row too narrow sends the\n // control to a line of its own.\n &__toolbar > .vv-radio-group,\n &__options > .vv-radio-group {\n flex: none;\n width: auto;\n\n .vv-radio {\n flex: none;\n }\n }\n\n &__label {\n color: var(--color-word-2);\n font-size: var(--text-14);\n }\n\n &__hint {\n color: var(--color-word-3);\n font-size: var(--text-12);\n }\n\n // A checkerboard, as in the lightbox: a transparent PNG shows where\n // it is transparent\n &__area {\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n min-height: 12rem;\n padding: var(--spacing-md);\n overflow: hidden;\n background: repeating-conic-gradient(\n var(--color-surface-2) 0% 25%,\n var(--color-surface) 0% 50%\n )\n 50% / 16px 16px;\n }\n\n &__frame {\n position: relative;\n flex-shrink: 0;\n overflow: hidden;\n box-shadow: var(--shadow-sm);\n cursor: crosshair;\n\n // The drag is the gesture: no scroll or zoom of the page under it\n touch-action: none;\n user-select: none;\n }\n\n &__stage,\n &__stage > canvas {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n // Drawn over a photo, so the same in both themes: white with a dark\n // edge reads on any image\n &__selection {\n position: absolute;\n pointer-events: none;\n border: 2px solid var(--color-white);\n outline: 1px solid\n color-mix(in srgb, var(--color-black) 50%, transparent);\n\n // What a crop leaves out goes dark\n &--crop {\n box-shadow: 0 0 0 100vmax\n color-mix(in srgb, var(--color-black) 55%, transparent);\n }\n\n &--cover {\n border-style: dashed;\n background-color: color-mix(\n in srgb,\n var(--color-black) 30%,\n transparent\n );\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n shallowRef,\n useTemplateRef,\n } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useMediaQuery } from '@vueuse/core'\n import PkImageEditor from './PkImageEditor.vue'\n import {\n editedFileName,\n exportCanvas,\n loadEditableImage,\n releaseCanvas,\n sizeAfterEdits,\n type ImageEdit,\n type LoadedImage,\n } from './imageEdits'\n\n /**\n * The image editor in a dialog (spec `chat-image-editor.md`, F1): opens\n * on an image file and gives back the edited copy, same name and type.\n * Open while it is mounted: `close` asks the host to drop it. It keeps\n * open on a click outside and on `Esc`, which would throw the edits away.\n */\n const props = defineProps<{\n file: File\n }>()\n\n const emit = defineEmits<{\n close: []\n /** The edited copy, to take the place of `file`. */\n apply: [file: File]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n // The phone breakpoint of the design system: the dialog covers the screen\n const fullscreen = useMediaQuery('(max-width: 575.98px)')\n\n // A canvas is no state to make deeply reactive\n const loaded = shallowRef<LoadedImage>()\n const failed = ref<'load' | 'draw' | 'export'>()\n const edits = ref<ImageEdit[]>([])\n const exporting = ref(false)\n const editorEl =\n useTemplateRef<InstanceType<typeof PkImageEditor>>('editorEl')\n\n onMounted(async () => {\n try {\n loaded.value = await loadEditableImage(props.file)\n } catch {\n failed.value = 'load'\n }\n })\n\n onBeforeUnmount(() => {\n if (loaded.value) {\n releaseCanvas(loaded.value.image)\n }\n })\n\n const size = computed(\n () => loaded.value && sizeAfterEdits(loaded.value.image, edits.value),\n )\n const scaledDown = computed(\n () =>\n !!loaded.value &&\n loaded.value.image.width < loaded.value.original.width,\n )\n const changed = computed(\n () => edits.value.length > 0 || !!editorEl.value?.pendingCrop,\n )\n\n async function useImage() {\n const editor = editorEl.value\n if (!editor) {\n return\n }\n // A crop drawn and not applied is what the user sees: it goes too\n editor.applyCrop()\n // A crop of the whole image changes nothing\n if (!edits.value.length) {\n emit('close')\n return\n }\n failed.value = undefined\n exporting.value = true\n try {\n // The editor draws the crop above in its next update; the file is\n // written from that canvas, not from a second one of full size\n await nextTick()\n const canvas = editor.shownCanvas()\n if (failed.value === 'draw') {\n return\n }\n if (!canvas) {\n throw new Error('No image drawn')\n }\n const blob = await exportCanvas(canvas, props.file.type)\n emit(\n 'apply',\n new File(\n [blob],\n editedFileName(props.file.name, props.file.type, blob.type),\n { type: blob.type, lastModified: Date.now() },\n ),\n )\n } catch {\n failed.value = 'export'\n } finally {\n exporting.value = false\n }\n }\n\n const failedLabel = computed(() => {\n switch (failed.value) {\n case 'export':\n return $t('imageEditor.exportFailed')\n case 'draw':\n return $t('imageEditor.drawFailed')\n default:\n return $t('imageEditor.loadFailed')\n }\n })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :title=\"$t('imageEditor.title')\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n keep-open\n class=\"pk-image-editor-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <VvAlert\n v-if=\"failed\"\n modifiers=\"danger\"\n class=\"m-md\"\n :content=\"failedLabel\" />\n <PkImageEditor\n v-if=\"loaded && failed !== 'draw'\"\n ref=\"editorEl\"\n v-model:edits=\"edits\"\n :image=\"loaded.image\"\n @error=\"failed = 'draw'\" />\n <div\n v-else-if=\"!failed\"\n class=\"pk-image-editor-dialog__loading\"\n role=\"status\"\n :aria-label=\"$t('imageEditor.loading')\">\n <VvIcon name=\"loading-loop\" />\n </div>\n <p v-if=\"size\" class=\"pk-image-editor-dialog__size\">\n {{\n scaledDown\n ? $t('imageEditor.sizeScaledDown', {\n width: size.width,\n height: size.height,\n })\n : $t('imageEditor.size', {\n width: size.width,\n height: size.height,\n })\n }}\n </p>\n <template #footer>\n <VvButtonGroup>\n <VvButton\n modifiers=\"secondary\"\n :label=\"$t('action.cancel')\"\n @click=\"emit('close')\" />\n <VvButton\n :label=\"$t('imageEditor.use')\"\n :loading=\"exporting\"\n :disabled=\"exporting || !changed || failed === 'draw'\"\n @click=\"useImage\" />\n </VvButtonGroup>\n </template>\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Most of the window, as the file viewer: room for a photo and the tools\n .pk-image-editor-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(64rem, 94dvw);\n height: min(48rem, 92dvh);\n }\n\n // The library writes `max-height: auto`, which is no value (see\n // PkFilePreviewDialog)\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 &__loading {\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n color: var(--color-word-3);\n font-size: var(--text-24);\n }\n\n &__size {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-md);\n border-top: 1px solid var(--color-surface-3);\n color: var(--color-word-3);\n font-size: var(--text-12);\n font-variant-numeric: tabular-nums;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n shallowRef,\n useTemplateRef,\n } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useMediaQuery } from '@vueuse/core'\n import PkImageEditor from './PkImageEditor.vue'\n import {\n editedFileName,\n exportCanvas,\n loadEditableImage,\n releaseCanvas,\n sizeAfterEdits,\n type ImageEdit,\n type LoadedImage,\n } from './imageEdits'\n\n /**\n * The image editor in a dialog (spec `chat-image-editor.md`, F1): opens\n * on an image file and gives back the edited copy, same name and type.\n * Open while it is mounted: `close` asks the host to drop it. It keeps\n * open on a click outside and on `Esc`, which would throw the edits away.\n */\n const props = defineProps<{\n file: File\n }>()\n\n const emit = defineEmits<{\n close: []\n /** The edited copy, to take the place of `file`. */\n apply: [file: File]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n // The phone breakpoint of the design system: the dialog covers the screen\n const fullscreen = useMediaQuery('(max-width: 575.98px)')\n\n // A canvas is no state to make deeply reactive\n const loaded = shallowRef<LoadedImage>()\n const failed = ref<'load' | 'draw' | 'export'>()\n const edits = ref<ImageEdit[]>([])\n const exporting = ref(false)\n const editorEl =\n useTemplateRef<InstanceType<typeof PkImageEditor>>('editorEl')\n\n onMounted(async () => {\n try {\n loaded.value = await loadEditableImage(props.file)\n } catch {\n failed.value = 'load'\n }\n })\n\n onBeforeUnmount(() => {\n if (loaded.value) {\n releaseCanvas(loaded.value.image)\n }\n })\n\n const size = computed(\n () => loaded.value && sizeAfterEdits(loaded.value.image, edits.value),\n )\n const scaledDown = computed(\n () =>\n !!loaded.value &&\n loaded.value.image.width < loaded.value.original.width,\n )\n const changed = computed(\n () => edits.value.length > 0 || !!editorEl.value?.pendingCrop,\n )\n\n async function useImage() {\n const editor = editorEl.value\n if (!editor) {\n return\n }\n // A crop drawn and not applied is what the user sees: it goes too\n editor.applyCrop()\n // A crop of the whole image changes nothing\n if (!edits.value.length) {\n emit('close')\n return\n }\n failed.value = undefined\n exporting.value = true\n try {\n // The editor draws the crop above in its next update; the file is\n // written from that canvas, not from a second one of full size\n await nextTick()\n const canvas = editor.shownCanvas()\n if (failed.value === 'draw') {\n return\n }\n if (!canvas) {\n throw new Error('No image drawn')\n }\n const blob = await exportCanvas(canvas, props.file.type)\n emit(\n 'apply',\n new File(\n [blob],\n editedFileName(props.file.name, props.file.type, blob.type),\n { type: blob.type, lastModified: Date.now() },\n ),\n )\n } catch {\n failed.value = 'export'\n } finally {\n exporting.value = false\n }\n }\n\n const failedLabel = computed(() => {\n switch (failed.value) {\n case 'export':\n return $t('imageEditor.exportFailed')\n case 'draw':\n return $t('imageEditor.drawFailed')\n default:\n return $t('imageEditor.loadFailed')\n }\n })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :title=\"$t('imageEditor.title')\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n keep-open\n class=\"pk-image-editor-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <VvAlert\n v-if=\"failed\"\n modifiers=\"danger\"\n class=\"m-md\"\n :content=\"failedLabel\" />\n <PkImageEditor\n v-if=\"loaded && failed !== 'draw'\"\n ref=\"editorEl\"\n v-model:edits=\"edits\"\n :image=\"loaded.image\"\n @error=\"failed = 'draw'\" />\n <div\n v-else-if=\"!failed\"\n class=\"pk-image-editor-dialog__loading\"\n role=\"status\"\n :aria-label=\"$t('imageEditor.loading')\">\n <VvIcon name=\"loading-loop\" />\n </div>\n <p v-if=\"size\" class=\"pk-image-editor-dialog__size\">\n {{\n scaledDown\n ? $t('imageEditor.sizeScaledDown', {\n width: size.width,\n height: size.height,\n })\n : $t('imageEditor.size', {\n width: size.width,\n height: size.height,\n })\n }}\n </p>\n <template #footer>\n <VvButtonGroup>\n <VvButton\n modifiers=\"secondary\"\n :label=\"$t('action.cancel')\"\n @click=\"emit('close')\" />\n <VvButton\n :label=\"$t('imageEditor.use')\"\n :loading=\"exporting\"\n :disabled=\"exporting || !changed || failed === 'draw'\"\n @click=\"useImage\" />\n </VvButtonGroup>\n </template>\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Most of the window, as the file viewer: room for a photo and the tools\n .pk-image-editor-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(64rem, 94dvw);\n height: min(48rem, 92dvh);\n }\n\n // The library writes `max-height: auto`, which is no value (see\n // PkFilePreviewDialog)\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 &__loading {\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n color: var(--color-word-3);\n font-size: var(--text-24);\n }\n\n &__size {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-md);\n border-top: 1px solid var(--color-surface-3);\n color: var(--color-word-3);\n font-size: var(--text-12);\n font-variant-numeric: tabular-nums;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n shallowRef,\n useTemplateRef,\n } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useMediaQuery } from '@vueuse/core'\n import PkImageEditor from './PkImageEditor.vue'\n import {\n editedFileName,\n exportCanvas,\n loadEditableImage,\n releaseCanvas,\n sizeAfterEdits,\n type ImageEdit,\n type LoadedImage,\n } from './imageEdits'\n\n /**\n * The image editor in a dialog (spec `chat-image-editor.md`, F1): opens\n * on an image file and gives back the edited copy, same name and type.\n * Open while it is mounted: `close` asks the host to drop it. It keeps\n * open on a click outside and on `Esc`, which would throw the edits away.\n */\n const props = defineProps<{\n file: File\n }>()\n\n const emit = defineEmits<{\n close: []\n /** The edited copy, to take the place of `file`. */\n apply: [file: File]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n // The phone breakpoint of the design system: the dialog covers the screen\n const fullscreen = useMediaQuery('(max-width: 575.98px)')\n\n // A canvas is no state to make deeply reactive\n const loaded = shallowRef<LoadedImage>()\n const failed = ref<'load' | 'draw' | 'export'>()\n const edits = ref<ImageEdit[]>([])\n const exporting = ref(false)\n const editorEl =\n useTemplateRef<InstanceType<typeof PkImageEditor>>('editorEl')\n\n onMounted(async () => {\n try {\n loaded.value = await loadEditableImage(props.file)\n } catch {\n failed.value = 'load'\n }\n })\n\n onBeforeUnmount(() => {\n if (loaded.value) {\n releaseCanvas(loaded.value.image)\n }\n })\n\n const size = computed(\n () => loaded.value && sizeAfterEdits(loaded.value.image, edits.value),\n )\n const scaledDown = computed(\n () =>\n !!loaded.value &&\n loaded.value.image.width < loaded.value.original.width,\n )\n const changed = computed(\n () => edits.value.length > 0 || !!editorEl.value?.pendingCrop,\n )\n\n async function useImage() {\n const editor = editorEl.value\n if (!editor) {\n return\n }\n // A crop drawn and not applied is what the user sees: it goes too\n editor.applyCrop()\n // A crop of the whole image changes nothing\n if (!edits.value.length) {\n emit('close')\n return\n }\n failed.value = undefined\n exporting.value = true\n try {\n // The editor draws the crop above in its next update; the file is\n // written from that canvas, not from a second one of full size\n await nextTick()\n const canvas = editor.shownCanvas()\n if (failed.value === 'draw') {\n return\n }\n if (!canvas) {\n throw new Error('No image drawn')\n }\n const blob = await exportCanvas(canvas, props.file.type)\n emit(\n 'apply',\n new File(\n [blob],\n editedFileName(props.file.name, props.file.type, blob.type),\n { type: blob.type, lastModified: Date.now() },\n ),\n )\n } catch {\n failed.value = 'export'\n } finally {\n exporting.value = false\n }\n }\n\n const failedLabel = computed(() => {\n switch (failed.value) {\n case 'export':\n return $t('imageEditor.exportFailed')\n case 'draw':\n return $t('imageEditor.drawFailed')\n default:\n return $t('imageEditor.loadFailed')\n }\n })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :title=\"$t('imageEditor.title')\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n keep-open\n class=\"pk-image-editor-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <VvAlert\n v-if=\"failed\"\n modifiers=\"danger\"\n class=\"m-md\"\n :content=\"failedLabel\" />\n <PkImageEditor\n v-if=\"loaded && failed !== 'draw'\"\n ref=\"editorEl\"\n v-model:edits=\"edits\"\n :image=\"loaded.image\"\n @error=\"failed = 'draw'\" />\n <div\n v-else-if=\"!failed\"\n class=\"pk-image-editor-dialog__loading\"\n role=\"status\"\n :aria-label=\"$t('imageEditor.loading')\">\n <VvIcon name=\"loading-loop\" />\n </div>\n <p v-if=\"size\" class=\"pk-image-editor-dialog__size\">\n {{\n scaledDown\n ? $t('imageEditor.sizeScaledDown', {\n width: size.width,\n height: size.height,\n })\n : $t('imageEditor.size', {\n width: size.width,\n height: size.height,\n })\n }}\n </p>\n <template #footer>\n <VvButtonGroup>\n <VvButton\n modifiers=\"secondary\"\n :label=\"$t('action.cancel')\"\n @click=\"emit('close')\" />\n <VvButton\n :label=\"$t('imageEditor.use')\"\n :loading=\"exporting\"\n :disabled=\"exporting || !changed || failed === 'draw'\"\n @click=\"useImage\" />\n </VvButtonGroup>\n </template>\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Most of the window, as the file viewer: room for a photo and the tools\n .pk-image-editor-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(64rem, 94dvw);\n height: min(48rem, 92dvh);\n }\n\n // The library writes `max-height: auto`, which is no value (see\n // PkFilePreviewDialog)\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 &__loading {\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n color: var(--color-word-3);\n font-size: var(--text-24);\n }\n\n &__size {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-md);\n border-top: 1px solid var(--color-surface-3);\n color: var(--color-word-3);\n font-size: var(--text-12);\n font-variant-numeric: tabular-nums;\n }\n }\n</style>\n"],"mappings":";;;;;;;;AAyCA,IAAayE,KAAkB,UAGlBC,KAAiB,KAOxBC,IAAkB,IAClBC,IAAsB,IAEtBC,IAAqC;CACvC,cAAc;CACd,aAAa;CACb,cAAc;AAClB;AAMA,SAAgBC,GACZ,GACA,IAAUL,IACD;CACT,IAAMM,IAAOC,EAAK,QAAQA,EAAK;CAC/B,IAAID,KAAQE,GACR,OAAO;EAAE,OAAOD,EAAK;EAAO,QAAQA,EAAK;CAAO;CAEpD,IAAME,IAAQ,KAAK,KAAKD,IAAUF,CAAI;CACtC,OAAO;EACH,OAAO,KAAK,IAAI,GAAG,KAAK,MAAMC,EAAK,QAAQE,CAAK,CAAC;EACjD,QAAQ,KAAK,IAAI,GAAG,KAAK,MAAMF,EAAK,SAASE,CAAK,CAAC;CACvD;AAC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, kt as g, nt as _, ot as v, pt as y, r as b, u as x, v as S, vt as C, w, wt as T, x as E, y as D, z as O } from "./vue.runtime.esm-bundler-C2U5uTqB.js";
2
2
  import { r as k } from "./vue-i18n-POtLvOl1.js";
3
- import { I as A } from "./utils-BZuri2jT.js";
3
+ import { L as A } from "./utils-ChmRkK0t.js";
4
4
  import { l as j } from "./dist-D6oUr4J_.js";
5
5
  import { t as M } from "./index.es-D-aOuzzp.js";
6
6
  import { t as N } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
@@ -261,4 +261,4 @@ var q = ["onKeydown"], J = ["placeholder", "aria-label"], Y = ["disabled"], X =
261
261
  }), [["styles", [".pk-selection-actions{z-index:10;max-width:min(20rem, 100% - var(--spacing-16));position:absolute}.pk-selection-actions--fixed{z-index:2147483647;position:fixed}.pk-selection-actions--asking{width:min(var(--spacing-384), 100% - var(--spacing-16));max-width:none}.pk-selection-actions__menu{width:max-content;min-width:11rem;max-width:100%;padding:var(--spacing-4);border:var(--spacing-1) solid var(--color-surface-5);border-radius:var(--rounded-lg);background-color:var(--color-surface);color:var(--color-word-2);font-family:var(--font-sans);font-size:var(--text-12);box-shadow:var(--shadow-lg);flex-direction:column;display:flex}.pk-selection-actions__menu--field{align-items:center;gap:var(--spacing-4);flex-direction:row;width:100%}.pk-selection-actions__text{max-width:16rem;padding:var(--spacing-4) var(--spacing-8) var(--spacing-6);color:var(--color-word-3);font-size:var(--text-12);margin:0}.pk-selection-actions__button{align-items:center;gap:var(--spacing-8);border-radius:var(--rounded);padding:var(--spacing-6) var(--spacing-12) var(--spacing-6) var(--spacing-8);color:inherit;font:inherit;text-align:start;white-space:nowrap;cursor:pointer;background-color:#0000;border:0;flex-shrink:0;display:flex}.pk-selection-actions__button:hover{background-color:var(--color-surface-1);color:var(--color-word-1)}.pk-selection-actions__button:focus-visible{outline:var(--spacing-2) solid var(--color-brand);outline-offset:calc(-1 * var(--spacing-2))}.pk-selection-actions__button--send{padding:var(--spacing-6) var(--spacing-10);background-color:var(--color-word-1);color:var(--color-surface);font-weight:var(--font-medium)}.pk-selection-actions__button--send:hover{background-color:var(--color-word-1);color:var(--color-surface)}.pk-selection-actions__button--send:disabled{opacity:.5;cursor:default}.pk-selection-actions__icon{width:var(--spacing-16);height:var(--spacing-16);color:var(--color-word-3);flex-shrink:0}.pk-selection-actions__rule{margin:var(--spacing-4) 0;border:0;border-top:var(--spacing-1) solid var(--color-surface-3)}.pk-selection-actions__input{border-radius:var(--rounded);min-width:0;padding:var(--spacing-6) var(--spacing-8);background-color:var(--color-surface-1);color:var(--color-word-1);font:inherit;border:0;flex:1}.pk-selection-actions__input::placeholder{color:var(--color-word-3)}.pk-selection-actions__input:focus-visible{outline:var(--spacing-2) solid var(--color-brand);outline-offset:calc(-1 * var(--spacing-2))}"]]]);
262
262
  export { I as i, G as n, K as r, te as t };
263
263
 
264
- //# sourceMappingURL=PkSelectionActions-DkETXtSL.js.map
264
+ //# sourceMappingURL=PkSelectionActions-DFyvcEyl.js.map