@chai-ui/vue 0.0.0-stage → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESIGN.md +235 -0
- package/LICENSE +21 -0
- package/README.md +122 -2
- package/dist/ChaiProvider.vue.d.ts +24 -0
- package/dist/ChaiProvider.vue.d.ts.map +1 -0
- package/dist/Composer.vue.d.ts +94 -0
- package/dist/Composer.vue.d.ts.map +1 -0
- package/dist/EditCard.vue.d.ts +38 -0
- package/dist/EditCard.vue.d.ts.map +1 -0
- package/dist/MediaAnalyzer.vue.d.ts +54 -0
- package/dist/MediaAnalyzer.vue.d.ts.map +1 -0
- package/dist/PageSlide.vue.d.ts +23 -0
- package/dist/PageSlide.vue.d.ts.map +1 -0
- package/dist/ResultCard.vue.d.ts +29 -0
- package/dist/ResultCard.vue.d.ts.map +1 -0
- package/dist/composer/AttachMenu.vue.d.ts +17 -0
- package/dist/composer/AttachMenu.vue.d.ts.map +1 -0
- package/dist/composer/Chip.vue.d.ts +14 -0
- package/dist/composer/Chip.vue.d.ts.map +1 -0
- package/dist/dismiss.d.ts +4 -0
- package/dist/dismiss.d.ts.map +1 -0
- package/dist/edit-card/ExpandedImage.vue.d.ts +12 -0
- package/dist/edit-card/ExpandedImage.vue.d.ts.map +1 -0
- package/dist/edit-card/RegionShape.vue.d.ts +20 -0
- package/dist/edit-card/RegionShape.vue.d.ts.map +1 -0
- package/dist/icons.d.ts +43 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2521 -0
- package/dist/index.js.map +1 -0
- package/dist/page-slide.d.ts +31 -0
- package/dist/page-slide.d.ts.map +1 -0
- package/dist/primitives/Pagination.vue.d.ts +26 -0
- package/dist/primitives/Pagination.vue.d.ts.map +1 -0
- package/dist/primitives/SearchMenu.vue.d.ts +51 -0
- package/dist/primitives/SearchMenu.vue.d.ts.map +1 -0
- package/dist/primitives/Toggle.vue.d.ts +16 -0
- package/dist/primitives/Toggle.vue.d.ts.map +1 -0
- package/dist/primitives/search-menu.d.ts +19 -0
- package/dist/primitives/search-menu.d.ts.map +1 -0
- package/dist/reasoning.d.ts +6 -0
- package/dist/reasoning.d.ts.map +1 -0
- package/dist/result-card/IconButton.vue.d.ts +21 -0
- package/dist/result-card/IconButton.vue.d.ts.map +1 -0
- package/dist/result-card/MoreMenu.vue.d.ts +13 -0
- package/dist/result-card/MoreMenu.vue.d.ts.map +1 -0
- package/dist/result-card/ResultMedia.vue.d.ts +28 -0
- package/dist/result-card/ResultMedia.vue.d.ts.map +1 -0
- package/dist/result-card/ResultText.vue.d.ts +8 -0
- package/dist/result-card/ResultText.vue.d.ts.map +1 -0
- package/dist/result-card/VideoPlayer.vue.d.ts +18 -0
- package/dist/result-card/VideoPlayer.vue.d.ts.map +1 -0
- package/dist/result-card/types.d.ts +9 -0
- package/dist/result-card/types.d.ts.map +1 -0
- package/dist/style.css +2378 -0
- package/dist/useComposer.d.ts +22 -0
- package/dist/useComposer.d.ts.map +1 -0
- package/dist/useMediaAnalyzer.d.ts +17 -0
- package/dist/useMediaAnalyzer.d.ts.map +1 -0
- package/package.json +79 -3
- package/src/ChaiProvider.vue +26 -0
- package/src/Composer.vue +372 -0
- package/src/EditCard.vue +520 -0
- package/src/MediaAnalyzer.vue +216 -0
- package/src/PageSlide.vue +36 -0
- package/src/ResultCard.vue +297 -0
- package/src/composer/AttachMenu.vue +66 -0
- package/src/composer/Chip.vue +26 -0
- package/src/dismiss.ts +22 -0
- package/src/edit-card/ExpandedImage.vue +39 -0
- package/src/edit-card/RegionShape.vue +39 -0
- package/src/icons.ts +55 -0
- package/src/index.ts +77 -0
- package/src/page-slide.ts +32 -0
- package/src/primitives/Pagination.vue +76 -0
- package/src/primitives/SearchMenu.vue +167 -0
- package/src/primitives/Toggle.vue +23 -0
- package/src/primitives/search-menu.ts +20 -0
- package/src/reasoning.ts +10 -0
- package/src/result-card/IconButton.vue +18 -0
- package/src/result-card/MoreMenu.vue +35 -0
- package/src/result-card/ResultMedia.vue +77 -0
- package/src/result-card/ResultText.vue +37 -0
- package/src/result-card/VideoPlayer.vue +90 -0
- package/src/result-card/types.ts +10 -0
- package/src/useComposer.ts +38 -0
- package/src/useMediaAnalyzer.ts +33 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2521 @@
|
|
|
1
|
+
import { inject, computed, defineComponent, provide, renderSlot, watch, onScopeDispose, h, ref, openBlock, createElementBlock, createElementVNode, normalizeClass, createBlock, unref, Fragment, renderList, resolveDynamicComponent, createTextVNode, toDisplayString, createCommentVNode, normalizeStyle, createVNode, nextTick, mergeProps, onMounted, onUnmounted, withModifiers, withCtx, withDirectives, vModelText, reactive, toValue, shallowRef } from "vue";
|
|
2
|
+
import { reasoningEngineFor, createReasoning, regionColor, composerView, composerAttachMenuItems, MAX_ANIMATE_ENHANCE_LENGTH, enhanceRevealDurationMs, composerAttachmentsFromFiles, regionBoxStyle, REGION_CORNERS, DEFAULT_MAX_REGIONS, freeRegionNumber, EDIT_ZOOM_STEPS, regionPopoverPosition, editCardWidth, newRegion, panForZoom, clampPan, fitBox, resizeBox, regionBoxForKey, panForKey, downloadMedia, downloadFilename, shareMedia, resultModelLabel, formatTokens, formatCost, formatDuration, formatAspectRatio, SUGGESTED_ANALYSIS_MODELS, DEFAULT_MAX_ATTACHMENTS_BY_KIND, isMediaAnalyzerAtCap, mediaAnalyzerModelSections, PROMPT_LENGTH_HINT, readMediaFiles, nextMediaAnalyzerAttachments, replacedNote, createComposerStore, pickReasoning, createMediaAnalyzerStore } from "@chai-ui/core";
|
|
3
|
+
import { DEFAULT_MAX_ATTACHMENTS_BY_KIND as DEFAULT_MAX_ATTACHMENTS_BY_KIND2, DEFAULT_MAX_REGIONS as DEFAULT_MAX_REGIONS2, DEFAULT_MEDIA_ANALYSIS_PROMPT_LENGTH, DEFAULT_MODEL_ID, DEFAULT_REASONING_MODEL, DEFAULT_REASONING_MODEL_BY_KIND, EDIT_IMAGE_USE_CASE, GenerationError, MEDIA_ANALYSIS_PROMPTS, MEDIA_ANALYSIS_PROMPT_LENGTHS, PRECISE_EDIT_MODELS, ROUTING_MODEL_ID, SUGGESTED_ANALYSIS_MODELS as SUGGESTED_ANALYSIS_MODELS2, SUGGESTED_EDIT_MODELS, SUGGESTED_IMAGE_MODELS, SUGGESTED_IMAGE_TO_VIDEO_MODELS, SUGGESTED_TEXT_TO_VIDEO_MODELS, TEXT_USE_CASE, buildRegionEditPrompt, checkSuggestedModels, createFalEngine, createMockEngine, createOpenRouterEngine, isMediaAnalyzerAtCap as isMediaAnalyzerAtCap2, mockEngine, nextMediaAnalyzerAttachments as nextMediaAnalyzerAttachments2, reasoningModelFor, suggestedModels } from "@chai-ui/core";
|
|
4
|
+
import "@material/web/fab/fab.js";
|
|
5
|
+
import "@material/web/checkbox/checkbox.js";
|
|
6
|
+
import "@material/web/textfield/outlined-text-field.js";
|
|
7
|
+
import "@material/web/switch/switch.js";
|
|
8
|
+
const reasoningKey = /* @__PURE__ */ Symbol("chai-reasoning");
|
|
9
|
+
function useReasoning() {
|
|
10
|
+
const provided = inject(reasoningKey, null);
|
|
11
|
+
return computed(() => provided?.value);
|
|
12
|
+
}
|
|
13
|
+
const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
14
|
+
__name: "ChaiProvider",
|
|
15
|
+
props: {
|
|
16
|
+
reasoningModel: {},
|
|
17
|
+
reasoningModelByKind: {},
|
|
18
|
+
reasoningEngine: {}
|
|
19
|
+
},
|
|
20
|
+
setup(__props) {
|
|
21
|
+
const props = __props;
|
|
22
|
+
const engine = computed(() => reasoningEngineFor({ reasoningEngine: props.reasoningEngine }));
|
|
23
|
+
provide(
|
|
24
|
+
reasoningKey,
|
|
25
|
+
computed(() => createReasoning(props, engine.value))
|
|
26
|
+
);
|
|
27
|
+
return (_ctx, _cache) => {
|
|
28
|
+
return renderSlot(_ctx.$slots, "default");
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
function useDismiss(root, open, close) {
|
|
33
|
+
function onPointerDown(e) {
|
|
34
|
+
if (!root.value?.contains(e.target)) close();
|
|
35
|
+
}
|
|
36
|
+
function onKeydown(e) {
|
|
37
|
+
if (e.key === "Escape") close();
|
|
38
|
+
}
|
|
39
|
+
function listen(on) {
|
|
40
|
+
if (on) {
|
|
41
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
42
|
+
document.addEventListener("keydown", onKeydown);
|
|
43
|
+
} else {
|
|
44
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
45
|
+
document.removeEventListener("keydown", onKeydown);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
watch(open, listen);
|
|
49
|
+
onScopeDispose(() => listen(false));
|
|
50
|
+
}
|
|
51
|
+
const icon = (viewBox, shapes, traced = false) => () => h(
|
|
52
|
+
"svg",
|
|
53
|
+
{ viewBox, "aria-hidden": "true", ...traced && { fill: "none" } },
|
|
54
|
+
shapes.map(({ tag = "path", ...attrs }) => h(tag, attrs))
|
|
55
|
+
);
|
|
56
|
+
const DownloadIcon = icon("0 0 18 18", [{ "d": "M8.99961 11.9999L5.24961 8.2499L6.29961 7.1624L8.24961 9.1124V2.9999H9.74961V9.1124L11.6996 7.1624L12.7496 8.2499L8.99961 11.9999ZM2.99961 14.9999V11.2499H4.49961V13.4999H13.4996V11.2499H14.9996V14.9999H2.99961Z", "fill": "currentColor" }], true);
|
|
57
|
+
const ShareIcon = icon("0 0 18 18", [{ "d": "M2.99961 16.4999V5.9999H6.74961V7.4999H4.49961V14.9999H13.4996V7.4999H11.2496V5.9999H14.9996V16.4999H2.99961ZM8.24961 11.9999V3.61865L7.04961 4.81865L5.99961 3.7499L8.99961 0.749904L11.9996 3.7499L10.9496 4.81865L9.74961 3.61865V11.9999H8.24961Z", "fill": "currentColor" }], true);
|
|
58
|
+
const ExpandIcon = icon("0 0 18 18", [{ "d": "M2 6V2h4M12 2h4v4M16 12v4h-4M6 16H2v-4", "stroke": "currentColor", "stroke-width": "1.6", "stroke-linecap": "round", "stroke-linejoin": "round" }], true);
|
|
59
|
+
const ZoomInIcon = icon("0 -960 960 960", [{ "d": "M796-121 533-384q-30 26-69.96 40.5Q423.08-329 378-329q-108.16 0-183.08-75Q120-479 120-585t75-181q75-75 181.5-75t181 75Q632-691 632-584.85 632-542 618-502q-14 40-42 75l264 262-44 44ZM377-389q81.25 0 138.13-57.5Q572-504 572-585t-56.87-138.5Q458.25-781 377-781q-82.08 0-139.54 57.5Q180-666 180-585t57.46 138.5Q294.92-389 377-389Zm-31-85v-82h-82v-60h82v-81h60v81h81v60h-81v82h-60Z", "fill": "currentColor" }]);
|
|
60
|
+
const ZoomOutIcon = icon("0 -960 960 960", [{ "d": "M796-121 533-384q-30 26-70 40.5T378-329q-108 0-183-75t-75-181q0-106 75-181t182-75q106 0 180.5 75T632-585q0 43-14 83t-42 75l264 262-44 44ZM377-389q81 0 138-57.5T572-585q0-81-57-138.5T377-781q-82 0-139.5 57.5T180-585q0 81 57.5 138.5T377-389ZM275-556v-60h201v60H275Z", "fill": "currentColor" }]);
|
|
61
|
+
const AddIcon = icon("0 -960 960 960", [{ "d": "M450-450H200v-60h250v-250h60v250h250v60H510v250h-60v-250Z", "fill": "currentColor" }]);
|
|
62
|
+
const DeleteIcon = icon("0 -960 960 960", [{ "d": "M261-120q-24.75 0-42.37-17.63Q201-155.25 201-180v-570h-41v-60h188v-30h264v30h188v60h-41v570q0 24-18 42t-42 18H261Zm438-630H261v570h438v-570ZM367-266h60v-399h-60v399Zm166 0h60v-399h-60v399ZM261-750v570-570Z", "fill": "currentColor" }]);
|
|
63
|
+
const VisibilityIcon = icon("0 -960 960 960", [{ "d": "M600.5-379.5Q650-429 650-500t-49.5-120.5Q551-670 480-670t-120.5 49.5Q310-571 310-500t49.5 120.5Q409-330 480-330t120.5-49.5Zm-200-41Q368-453 368-500t32.5-79.5Q433-612 480-612t79.5 32.5Q592-547 592-500t-32.5 79.5Q527-388 480-388t-79.5-32.5ZM216-283Q98-366 40-500q58-134 176-217t264-83q146 0 264 83t176 217q-58 134-176 217t-264 83q-146 0-264-83Zm264-217Zm222.5 174.5Q804-391 857-500q-53-109-154.5-174.5T480-740q-121 0-222.5 65.5T102-500q54 109 155.5 174.5T480-260q121 0 222.5-65.5Z", "fill": "currentColor" }]);
|
|
64
|
+
const VisibilityOffIcon = icon("0 -960 960 960", [{ "d": "m629-419-44-44q26-71-27-118t-115-24l-44-44q17-11 38-16t43-5q71 0 120.5 49.5T650-500q0 22-5.5 43.5T629-419Zm129 129-40-40q49-36 85.5-80.5T857-500q-50-111-150-175.5T490-740q-42 0-86 8t-69 19l-46-47q35-16 89.5-28T485-800q143 0 261.5 81.5T920-500q-26 64-67 117t-95 93Zm58 226L648-229q-35 14-79 21.5t-89 7.5q-146 0-265-81.5T40-500q20-52 55.5-101.5T182-696L56-822l42-43 757 757-39 44ZM223-654q-37 27-71.5 71T102-500q51 111 153.5 175.5T488-260q33 0 65-4t48-12l-64-64q-11 5-27 7.5t-30 2.5q-70 0-120-49t-50-121q0-15 2.5-30t7.5-27l-97-97Zm305 142Zm-116 58Z", "fill": "currentColor" }]);
|
|
65
|
+
const CheckSymbolIcon = icon("0 -960 960 960", [{ "d": "M378-246 154-470l43-43 181 181 384-384 43 43-427 427Z", "fill": "currentColor" }]);
|
|
66
|
+
const CloseSymbolIcon = icon("0 -960 960 960", [{ "d": "m249-207-42-42 231-231-231-231 42-42 231 231 231-231 42 42-231 231 231 231-42 42-231-231-231 231Z", "fill": "currentColor" }]);
|
|
67
|
+
const StopIcon = icon("0 -960 960 960", [{ "d": "M240-240v-480h480v480H240Z", "fill": "currentColor" }]);
|
|
68
|
+
const ThumbUpIcon = icon("0 0 18 18", [{ "d": "M5.25039 15.7502V6.00019L10.5004 0.750193L11.8879 2.13769L10.9129 6.00019H17.2504V9.30019L14.5129 15.7502H5.25039ZM6.75039 14.2502H13.5004L15.7504 9.00019V7.50019H9.00039L10.0129 3.37519L6.75039 6.63769V14.2502ZM1.50039 15.7502V6.00019H5.25039V7.50019H3.00039V14.2502H5.25039V15.7502H1.50039Z", "fill": "currentColor" }], true);
|
|
69
|
+
const ThumbDownIcon = icon("0 0 18 18", [{ "d": "M2.24961 12C1.84961 12 1.49961 11.85 1.19961 11.55C0.899615 11.25 0.749615 10.9 0.749615 10.5V9C0.749615 8.9125 0.762115 8.81875 0.787115 8.71875C0.812115 8.61875 0.837115 8.525 0.862115 8.4375L3.11211 3.15C3.22461 2.9 3.41211 2.6875 3.67461 2.5125C3.93711 2.3375 4.21211 2.25 4.49961 2.25H12.7496V12L8.24961 16.4625C8.06211 16.65 7.84024 16.7594 7.58399 16.7906C7.32774 16.8219 7.08086 16.775 6.84336 16.65C6.60586 16.525 6.43086 16.35 6.31836 16.125C6.20586 15.9 6.18086 15.6688 6.24336 15.4313L7.08711 12H2.24961ZM11.2496 11.3625V3.75H4.49961L2.24961 9V10.5H8.99961L7.98711 14.625L11.2496 11.3625ZM14.9996 2.25C15.4121 2.25 15.7652 2.39688 16.059 2.69063C16.3527 2.98438 16.4996 3.3375 16.4996 3.75V10.5C16.4996 10.9125 16.3527 11.2656 16.059 11.5594C15.7652 11.8531 15.4121 12 14.9996 12H12.7496V10.5H14.9996V3.75H12.7496V2.25H14.9996Z", "fill": "currentColor" }], true);
|
|
70
|
+
const RefreshIcon = icon("0 0 18 18", [{ "d": "M8.99961 15.0002C7.32461 15.0002 5.90586 14.4189 4.74336 13.2564C3.58086 12.0939 2.99961 10.6752 2.99961 9.00019C2.99961 7.32519 3.58086 5.90644 4.74336 4.74394C5.90586 3.58144 7.32461 3.00019 8.99961 3.00019C9.86211 3.00019 10.6871 3.17832 11.4746 3.53457C12.2621 3.89082 12.9371 4.40019 13.4996 5.06269V3.00019H14.9996V8.25019H9.74961V6.75019H12.8996C12.4996 6.05019 11.9527 5.50019 11.259 5.10019C10.5652 4.70019 9.81211 4.50019 8.99961 4.50019C7.74961 4.50019 6.68711 4.93769 5.81211 5.81269C4.93711 6.68769 4.49961 7.75019 4.49961 9.00019C4.49961 10.2502 4.93711 11.3127 5.81211 12.1877C6.68711 13.0627 7.74961 13.5002 8.99961 13.5002C9.96211 13.5002 10.8309 13.2252 11.6059 12.6752C12.3809 12.1252 12.9246 11.4002 13.2371 10.5002H14.8121C14.4621 11.8252 13.7496 12.9064 12.6746 13.7439C11.5996 14.5814 10.3746 15.0002 8.99961 15.0002Z", "fill": "currentColor" }], true);
|
|
71
|
+
const MoreHorizIcon = icon("0 0 24 24", [{ "d": "M6.41473 14C5.86473 14 5.3939 13.8042 5.00223 13.4125C4.61056 13.0208 4.41473 12.55 4.41473 12C4.41473 11.45 4.61056 10.9792 5.00223 10.5875C5.3939 10.1958 5.86473 10 6.41473 10C6.96473 10 7.43556 10.1958 7.82723 10.5875C8.2189 10.9792 8.41473 11.45 8.41473 12C8.41473 12.55 8.2189 13.0208 7.82723 13.4125C7.43556 13.8042 6.96473 14 6.41473 14ZM12.4147 14C11.8647 14 11.3939 13.8042 11.0022 13.4125C10.6106 13.0208 10.4147 12.55 10.4147 12C10.4147 11.45 10.6106 10.9792 11.0022 10.5875C11.3939 10.1958 11.8647 10 12.4147 10C12.9647 10 13.4356 10.1958 13.8272 10.5875C14.2189 10.9792 14.4147 11.45 14.4147 12C14.4147 12.55 14.2189 13.0208 13.8272 13.4125C13.4356 13.8042 12.9647 14 12.4147 14ZM18.4147 14C17.8647 14 17.3939 13.8042 17.0022 13.4125C16.6106 13.0208 16.4147 12.55 16.4147 12C16.4147 11.45 16.6106 10.9792 17.0022 10.5875C17.3939 10.1958 17.8647 10 18.4147 10C18.9647 10 19.4356 10.1958 19.8272 10.5875C20.2189 10.9792 20.4147 11.45 20.4147 12C20.4147 12.55 20.2189 13.0208 19.8272 13.4125C19.4356 13.8042 18.9647 14 18.4147 14Z", "fill": "currentColor" }], true);
|
|
72
|
+
const InfoIcon = icon("0 0 22 22", [{ "d": "M10.0833 6.41667H11.9167V8.25H10.0833V6.41667ZM10.0833 10.0833H11.9167V15.5833H10.0833V10.0833ZM11 1.83333C5.94 1.83333 1.83333 5.94 1.83333 11C1.83333 16.06 5.94 20.1667 11 20.1667C16.06 20.1667 20.1667 16.06 20.1667 11C20.1667 5.94 16.06 1.83333 11 1.83333ZM11 18.3333C6.9575 18.3333 3.66667 15.0425 3.66667 11C3.66667 6.9575 6.9575 3.66667 11 3.66667C15.0425 3.66667 18.3333 6.9575 18.3333 11C18.3333 15.0425 15.0425 18.3333 11 18.3333Z", "fill": "currentColor" }], true);
|
|
73
|
+
const CloseIcon = icon("0 0 14 14", [{ "d": "M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z", "fill": "currentColor" }], true);
|
|
74
|
+
const CopyIcon = icon("0 0 8.60253 11.6462", [{ "d": "M1.01206 11.6462C0.733745 11.6462 0.495405 11.5323 0.29704 11.3044C0.0990134 11.0761 0 10.8019 0 10.4816V2.32924H1.01206V10.4816H6.57841V11.6462H1.01206ZM3.03619 9.31697C2.75787 9.31697 2.5197 9.20303 2.32167 8.97515C2.12331 8.74689 2.02413 8.47262 2.02413 8.15235V1.16462C2.02413 0.84435 2.12331 0.570082 2.32167 0.341816C2.5197 0.113939 2.75787 0 3.03619 0H7.59047C7.86879 0 8.10713 0.113939 8.30549 0.341816C8.50352 0.570082 8.60253 0.84435 8.60253 1.16462V8.15235C8.60253 8.47262 8.50352 8.74689 8.30549 8.97515C8.10713 9.20303 7.86879 9.31697 7.59047 9.31697H3.03619ZM3.03619 8.15235H7.59047V1.16462H3.03619V8.15235Z", "fill": "currentColor" }], true);
|
|
75
|
+
const CheckIcon = icon("0 0 18 18", [{ "d": "M7.1625 13.5L2.8875 9.225L3.95625 8.15625L7.1625 11.3625L14.0438 4.48125L15.1125 5.55L7.1625 13.5Z", "fill": "currentColor" }], true);
|
|
76
|
+
const PlayIcon = icon("0 -960 960 960", [{ "d": "M320-200v-560l440 280-440 280Z", "fill": "currentColor" }]);
|
|
77
|
+
const ArrowForwardIcon = icon("0 -960 960 960", [{ "d": "M686-450H160v-60h526L438-758l42-42 320 320-320 320-42-42 248-248Z", "fill": "currentColor" }]);
|
|
78
|
+
const RemoveIcon = icon("0 0 16 16", [{ "d": "M3.5 3.5l9 9m0-9-9 9", "stroke": "currentColor", "stroke-width": "3.5", "stroke-linecap": "round" }], true);
|
|
79
|
+
const VideoIcon = icon("0 0 24 24", [{ "tag": "rect", "x": "2.5", "y": "5", "width": "19", "height": "14", "rx": "2", "stroke": "currentColor", "stroke-width": "1.5" }, { "d": "M10 9.5v5l4.5-2.5-4.5-2.5Z", "fill": "currentColor" }], true);
|
|
80
|
+
const AudioIcon = icon("0 0 24 24", [{ "d": "M9 18V5l12-2v13M9 18a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm12-2a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z", "stroke": "currentColor", "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" }], true);
|
|
81
|
+
const MixedMediaIcon = icon("0 0 24.1904 24.3948", [{ "d": "M2.90401 23.3661C3.05621 23.765 3.35538 24.0825 3.7464 24.2557C3.95634 24.3502 4.17678 24.3948 4.39985 24.3948C4.59404 24.3948 4.78561 24.3581 4.97194 24.2872L14.4167 20.6762C15.2407 20.3613 15.6554 19.4323 15.3405 18.6083L12.543 11.2918C12.3908 10.8929 12.0916 10.5753 11.7006 10.4021C11.3096 10.2289 10.8739 10.2158 10.4751 10.368L1.03027 13.9817C0.63138 14.1339 0.313842 14.433 0.14064 14.824C-0.0351869 15.2151 -0.045684 15.6507 0.106524 16.0496L2.90401 23.3661ZM0.859692 15.1442C0.948918 14.9448 1.109 14.7926 1.31107 14.7165L10.7559 11.1054C10.8503 11.0687 10.95 11.0503 11.0471 11.0503C11.16 11.0503 11.2728 11.074 11.3778 11.1212C11.5773 11.2104 11.7295 11.3705 11.8056 11.5752L13.9811 17.262L10.294 14.9474C9.92658 14.7165 9.48308 14.6718 9.07631 14.8293C8.66955 14.9841 8.37038 15.3122 8.24966 15.7294L7.76155 17.43L6.26308 16.4905C5.89568 16.2595 5.45218 16.2149 5.04542 16.3724C4.63865 16.5272 4.33949 16.8552 4.21877 17.2725L3.01685 21.4582L0.843947 15.7688C0.765218 15.5667 0.773091 15.3437 0.862317 15.1468L0.859692 15.1442ZM14.6057 18.8917C14.7657 19.3116 14.5558 19.7839 14.1359 19.944L4.69114 23.555C4.48907 23.6338 4.26601 23.6259 4.06919 23.5367C3.86974 23.4474 3.71753 23.2873 3.64143 23.0827L3.57845 22.9199L7.24194 21.5186L14.5453 18.7263L14.6083 18.8891L14.6057 18.8917ZM7.69594 20.503L9.00546 15.9446C9.05532 15.7662 9.18391 15.6271 9.35711 15.5615C9.42534 15.5352 9.4962 15.5221 9.56705 15.5221C9.67465 15.5221 9.78224 15.551 9.87672 15.6113L13.8945 18.1333L7.69857 20.503H7.69594ZM6.77482 20.8546L3.66505 22.0434L4.97456 17.4851C5.02442 17.3066 5.15301 17.1675 5.32622 17.1019C5.39445 17.0757 5.4653 17.0626 5.53616 17.0626C5.64375 17.0626 5.75135 17.0914 5.84582 17.1518L7.53586 18.212L6.77744 20.852L6.77482 20.8546Z", "fill": "currentColor" }, { "d": "M6.70667 15.8872C6.70667 15.8872 6.71716 15.8872 6.72241 15.8872C7.04782 15.882 7.34961 15.7534 7.57793 15.5198C7.80624 15.2863 7.92695 14.9819 7.92171 14.6565C7.91646 14.331 7.78787 14.0293 7.55431 13.8009C7.32075 13.5753 7.00846 13.4493 6.69092 13.4572C6.36551 13.4624 6.06372 13.591 5.8354 13.8246C5.60709 14.0581 5.48638 14.3625 5.49162 14.6879C5.49687 15.0134 5.62546 15.3152 5.85902 15.5435C6.08734 15.7665 6.38913 15.8872 6.70667 15.8872ZM6.70667 14.2444C6.81951 14.2444 6.92448 14.2864 7.00583 14.3652C7.08719 14.4439 7.13442 14.5515 7.13442 14.667C7.13442 14.7824 7.09243 14.89 7.01371 14.9714C6.93498 15.0527 6.82738 15.1 6.71191 15.1C6.5912 15.1 6.48885 15.058 6.4075 14.9792C6.32614 14.9005 6.27891 14.7929 6.27891 14.6775C6.27891 14.562 6.3209 14.4544 6.39962 14.373C6.47835 14.2917 6.58595 14.2444 6.70142 14.2444H6.70667Z", "fill": "currentColor" }, { "d": "M23.9034 19.6056C23.8981 19.5819 23.885 19.5636 23.8797 19.5399C23.8797 19.5137 23.8745 19.4901 23.8692 19.4638L22.7408 15.0026L22.2894 13.2181C22.2606 13.1052 22.1845 13.0107 22.0821 12.9609C21.9771 12.911 21.8564 12.9084 21.7515 12.953L16.6236 15.1994C16.4478 15.2755 16.3533 15.4697 16.4005 15.656L16.8519 17.4405C16.8519 17.4405 16.8572 17.451 16.8598 17.4589C16.8598 17.4668 16.8598 17.472 16.8624 17.4799L17.794 21.1644C17.4686 21.1565 17.1039 21.2562 16.7417 21.4662C15.8862 21.9569 15.3692 22.836 15.5372 23.5105C15.6106 23.8018 15.8048 24.0275 16.083 24.1456C16.23 24.2085 16.39 24.2374 16.5633 24.2374C16.8808 24.2374 17.2324 24.1351 17.5815 23.933C18.437 23.4422 18.954 22.5631 18.786 21.8887C18.7808 21.8651 18.7676 21.8467 18.7624 21.8231C18.7624 21.7968 18.7571 21.7732 18.7519 21.747L17.6969 17.5717L22.0926 15.6455L22.9114 18.8812C22.586 18.8734 22.2212 18.9731 21.859 19.183C21.0035 19.6738 20.4865 20.5529 20.6545 21.2274C20.728 21.5187 20.9222 21.7443 21.2004 21.8624C21.3473 21.9254 21.51 21.9543 21.6806 21.9543C21.9981 21.9543 22.3498 21.8519 22.6988 21.6499C23.5543 21.1591 24.0713 20.28 23.9007 19.6056H23.9034ZM21.5074 21.1355C21.4549 21.1145 21.4313 21.0856 21.4182 21.0332C21.3552 20.7812 21.6412 20.2144 22.2501 19.8654C22.4967 19.7236 22.7198 19.6685 22.8799 19.6685C22.9481 19.6685 23.0059 19.679 23.0505 19.6974C23.103 19.7184 23.1266 19.7473 23.1397 19.7997C23.2027 20.0517 22.9166 20.6185 22.3078 20.9676C21.9561 21.1696 21.6517 21.1985 21.5074 21.1355ZM17.5001 16.7976L17.2456 15.7872L21.6412 13.861L21.8958 14.8713L17.5001 16.7976ZM16.39 23.4186C16.3376 23.3976 16.3139 23.3688 16.3008 23.3163C16.2378 23.0644 16.5239 22.4975 17.1327 22.1485C17.3794 22.0068 17.6025 21.9517 17.7625 21.9517C17.8308 21.9517 17.8885 21.9622 17.9331 21.9805C17.9856 22.0015 18.0092 22.0304 18.0224 22.0829C18.0853 22.3348 17.7993 22.9016 17.1905 23.2507C16.8388 23.4527 16.5344 23.4816 16.39 23.4186Z", "fill": "currentColor" }, { "d": "M2.04571 7.49995C2.2504 7.54719 2.4551 7.57081 2.65192 7.57081C3.33686 7.57081 3.94831 7.30313 4.19237 6.85438C4.20549 6.83076 4.21074 6.80715 4.22124 6.78353C4.23436 6.76778 4.24748 6.75204 4.25798 6.73367L6.1737 3.23025L10.3489 4.6841L8.88721 7.35562C8.66677 7.15355 8.35973 6.99872 7.9897 6.91212C7.0817 6.70217 6.15796 6.98035 5.84042 7.55769C5.70133 7.80962 5.69083 8.09567 5.80893 8.36072C5.98475 8.75174 6.41251 9.0509 6.98723 9.18212C7.19192 9.22936 7.39662 9.25297 7.59344 9.25297C8.27837 9.25297 8.88983 8.9853 9.13389 8.53655C9.14701 8.51293 9.15226 8.48931 9.16276 8.46569C9.17588 8.44994 9.189 8.4342 9.1995 8.41583L11.2569 4.65261L12.081 3.14628C12.1361 3.04393 12.1439 2.92321 12.1019 2.81562C12.06 2.70802 11.9734 2.62404 11.8631 2.58468L6.94262 0.871025C6.76154 0.808042 6.55947 0.884146 6.46762 1.05472L5.6436 2.56106C5.6436 2.56106 5.63835 2.57156 5.63572 2.57681C5.6331 2.58206 5.62785 2.5873 5.62523 2.59255L3.94044 5.67083C3.72 5.46876 3.41296 5.31393 3.04294 5.22733C2.13494 5.01739 1.21119 5.29556 0.893651 5.8729C0.754565 6.12483 0.744067 6.41088 0.86216 6.67593C1.03799 7.06695 1.46574 7.36612 2.04046 7.49733L2.04571 7.49995ZM1.58909 6.2508C1.67306 6.09859 2.01422 5.94638 2.44722 5.94638C2.58106 5.94638 2.72277 5.96213 2.86973 5.99362C3.22926 6.0776 3.4497 6.24293 3.50743 6.37151C3.52843 6.41613 3.52056 6.445 3.50481 6.47649C3.39459 6.67593 2.84349 6.87538 2.22416 6.73367C1.86463 6.64969 1.6442 6.48436 1.58646 6.35577C1.56547 6.31116 1.57334 6.28229 1.58909 6.25342V6.2508ZM11.173 3.17777L10.7321 3.98342L6.55685 2.52957L6.99773 1.72392L11.173 3.17777ZM7.1683 8.41583C6.80878 8.33185 6.58834 8.16652 6.5306 8.03793C6.50961 7.99332 6.51748 7.96445 6.53323 7.93296C6.61721 7.78075 6.95836 7.62592 7.39137 7.62592C7.52521 7.62592 7.66692 7.64167 7.81388 7.67316C8.1734 7.75713 8.39384 7.92246 8.45158 8.05105C8.47257 8.09567 8.4647 8.12453 8.44895 8.15602C8.33873 8.35547 7.78501 8.55492 7.1683 8.41321V8.41583Z", "fill": "currentColor" }, { "d": "M13.0938 8.46027L18.1771 11.6671C18.4736 11.8535 18.8095 11.9506 19.1507 11.9506C19.2871 11.9506 19.4236 11.9348 19.5574 11.9059C20.0351 11.7983 20.4392 11.5097 20.7016 11.0977L23.9085 6.01444C24.4465 5.16155 24.1919 4.02786 23.3364 3.48988L18.2532 0.283009C17.8385 0.0232057 17.3504 -0.0633955 16.8728 0.0468243C16.3952 0.15442 15.991 0.443091 15.7286 0.855103L12.5217 5.93833C11.9838 6.79122 12.2383 7.92491 13.0938 8.46289V8.46027ZM17.046 0.813114C17.1221 0.794744 17.2008 0.786871 17.2769 0.786871C17.4711 0.786871 17.6627 0.841981 17.8307 0.946952L22.9139 4.15382C23.3994 4.46086 23.5463 5.10644 23.2393 5.59193L20.0324 10.6752C19.8828 10.9113 19.6519 11.074 19.3816 11.1344C19.1087 11.1974 18.8305 11.1475 18.5943 11.0006L13.5111 7.7937C13.0256 7.48666 12.8786 6.84108 13.1857 6.35559L16.3926 1.27236C16.5421 1.03618 16.7731 0.873472 17.0434 0.813114H17.046Z", "fill": "currentColor" }, { "d": "M16.4532 7.53394L19.353 7.78587C19.3845 7.78587 19.4133 7.78849 19.4448 7.78849C19.7991 7.78849 20.1298 7.60742 20.324 7.303C20.5313 6.97234 20.5392 6.5577 20.3397 6.2218L18.8649 3.71299C18.6785 3.39807 18.3505 3.2065 17.9857 3.20125C17.6262 3.196 17.2851 3.37708 17.0909 3.68674L15.6659 5.94625C15.4717 6.25591 15.4507 6.63643 15.6134 6.96447C15.7761 7.2925 16.091 7.50769 16.4558 7.53919L16.4532 7.53394ZM17.7548 4.104C17.8204 3.99903 17.9228 3.98591 17.9674 3.98591H17.97C18.012 3.98591 18.1196 3.99903 18.1826 4.10925L19.6574 6.61806C19.7283 6.73878 19.6784 6.84113 19.6522 6.88049C19.6285 6.91986 19.5524 7.00908 19.416 6.99596L16.5161 6.74403C16.3875 6.73353 16.3298 6.64431 16.3114 6.60494C16.2931 6.56558 16.2563 6.46586 16.3246 6.35826L17.7496 4.09876L17.7548 4.104Z", "fill": "currentColor" }], true);
|
|
82
|
+
const PlusIcon = icon("0 -960 960 960", [{ "d": "M450-450H200v-60h250v-250h60v250h250v60H510v250h-60v-250Z", "fill": "currentColor" }]);
|
|
83
|
+
const RetryIcon = icon("0 -960 960 960", [{ "d": "M480-160q-133 0-226.5-93.5T160-480q0-133 93.5-226.5T480-800q85 0 149 34.5T740-671v-129h60v254H546v-60h168q-38-60-97-97t-137-37q-109 0-184.5 75.5T220-480q0 109 75.5 184.5T480-220q83 0 152-47.5T728-393h62q-29 105-115 169t-195 64Z", "fill": "currentColor" }]);
|
|
84
|
+
const ErrorIcon = icon("0 -960 960 960", [{ "d": "M503.5-289.48q9.5-9.48 9.5-23.5t-9.48-23.52q-9.48-9.5-23.5-9.5t-23.52 9.48q-9.5 9.48-9.5 23.5t9.48 23.52q9.48 9.5 23.5 9.5t23.52-9.48ZM453-433h60v-253h-60v253Zm27.27 353q-82.74 0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66Q143-709 197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5Q709-817 763-763t85.5 127Q880-563 880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80Zm.23-60Q622-140 721-239.5t99-241Q820-622 721.19-721T480-820q-141 0-240.5 98.81T140-480q0 141 99.5 240.5t241 99.5Zm-.5-340Z", "fill": "currentColor" }]);
|
|
85
|
+
const OptimizeIcon = icon("0 0 25 24", [{ "d": "M5 19H6.425L16.2 9.225L14.775 7.8L5 17.575V19ZM3 21V16.75L16.2 3.575C16.4 3.39167 16.6208 3.25 16.8625 3.15C17.1042 3.05 17.3583 3 17.625 3C17.8917 3 18.15 3.05 18.4 3.15C18.65 3.25 18.8667 3.4 19.05 3.6L20.425 5C20.625 5.18333 20.7708 5.4 20.8625 5.65C20.9542 5.9 21 6.15 21 6.4C21 6.66667 20.9542 6.92083 20.8625 7.1625C20.7708 7.40417 20.625 7.625 20.425 7.825L7.25 21H3ZM15.475 8.525L14.775 7.8L16.2 9.225L15.475 8.525Z", "fill": "currentColor" }, { "d": "M20 12L21.5918 15.4082L25 17L21.5918 18.5918L20 22L18.4082 18.5918L15 17L18.4082 15.4082L20 12Z", "fill": "currentColor" }, { "d": "M6 3L7.27345 5.72655L10 7L7.27345 8.27345L6 11L4.72655 8.27345L2 7L4.72655 5.72655L6 3Z", "fill": "currentColor" }], true);
|
|
86
|
+
const UndoIcon = icon("0 -960 960 960", [{ "d": "M259-200v-60h310q70 0 120.5-46.5T740-422q0-69-50.5-115.5T569-584H274l114 114-42 42-186-186 186-186 42 42-114 114h294q95 0 163.5 64T800-422q0 94-68.5 158T568-200H259Z", "fill": "currentColor" }]);
|
|
87
|
+
const AttachFileIcon = icon("0 -960 960 960", [{ "d": "M728-326q0 103-72.18 174.5-72.17 71.5-175 71.5Q378-80 305.5-151.5T233-326v-380q0-72.5 51.5-123.25T408-880q72 0 123.5 50.75T583-706v360q0 42-30 72t-72.5 30q-42.5 0-72.5-29.67-30-29.68-30-72.33v-370h60v370q0 17 12.5 29.5t30.64 12.5q18.14 0 30-12.5T523-346v-360q0-48-33.5-81t-81.71-33q-48.21 0-81.5 33.06T293-706v380q0 78 54.97 132T481-140q77.92 0 132.46-54Q668-248 668-326v-390h60v390Z", "fill": "currentColor" }]);
|
|
88
|
+
const ImageIcon = icon("0 -960 960 960", [{ "d": "M180-120q-24 0-42-18t-18-42v-600q0-24 18-42t42-18h600q24 0 42 18t18 42v600q0 24-18 42t-42 18H180Zm0-60h600v-600H180v600Zm56-97h489L578-473 446-302l-93-127-117 152Zm-56 97v-600 600Z", "fill": "currentColor" }]);
|
|
89
|
+
const VideocamIcon = icon("0 -960 960 960", [{ "d": "M140-160q-24 0-42-18t-18-42v-520q0-24 18-42t42-18h520q24 0 42 18t18 42v215l160-160v410L720-435v215q0 24-18 42t-42 18H140Zm0-60h520v-520H140v520Zm0 0v-520 520Z", "fill": "currentColor" }]);
|
|
90
|
+
const ContentCutIcon = icon("0 -960 960 960", [{ "d": "M782-114 481-415 364-298q11 17 13.5 33t2.5 35q0 64-43 107T230-80q-64 0-107-43T80-230q0-64 43-107t107-43q18 0 35.5 5t36.5 15l116-116-118-118q-17 8-34.5 11t-35.5 3q-64 0-107-43T80-730q0-64 43-107t107-43q64 0 107 43t43 107q0 19-2.5 36T367-662l514 514v34h-99ZM599-527l-66-66 249-249h99v33L599-527ZM294-666q26-26 26-64t-26-64q-26-26-64-26t-64 26q-26 26-26 64t26 64q26 26 64 26t64-26Zm202.5 203.5Q502-468 502-476t-5.5-13.5Q491-495 483-495t-13.5 5.5Q464-484 464-476t5.5 13.5Q475-457 483-457t13.5-5.5ZM294-166q26-26 26-64t-26-64q-26-26-64-26t-64 26q-26 26-26 64t26 64q26 26 64 26t64-26Z", "fill": "currentColor" }]);
|
|
91
|
+
const MusicNoteIcon = icon("0 -960 960 960", [{ "d": "M286.5-163.5Q243-207 243-270t43.5-106.5Q330-420 393-420q28 0 50.5 8t39.5 22v-450h234v135H543v435q0 63-43.5 106.5T393-120q-63 0-106.5-43.5Z", "fill": "currentColor" }]);
|
|
92
|
+
const _hoisted_1$g = ["disabled", "aria-expanded", "aria-label"];
|
|
93
|
+
const _hoisted_2$b = {
|
|
94
|
+
key: 0,
|
|
95
|
+
class: "chai-composer__attach-menu",
|
|
96
|
+
role: "menu"
|
|
97
|
+
};
|
|
98
|
+
const _hoisted_3$9 = ["onClick"];
|
|
99
|
+
const _hoisted_4$7 = { class: "chai-composer__attach-menu-icon" };
|
|
100
|
+
const _hoisted_5$6 = {
|
|
101
|
+
key: 0,
|
|
102
|
+
class: "chai-composer__attach-menu-divider",
|
|
103
|
+
role: "separator"
|
|
104
|
+
};
|
|
105
|
+
const _hoisted_6$6 = ["accept", "multiple", "disabled"];
|
|
106
|
+
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
107
|
+
__name: "AttachMenu",
|
|
108
|
+
props: {
|
|
109
|
+
items: {},
|
|
110
|
+
imagesOnly: { type: Boolean },
|
|
111
|
+
disabled: { type: Boolean }
|
|
112
|
+
},
|
|
113
|
+
emits: ["select", "files"],
|
|
114
|
+
setup(__props, { emit: __emit }) {
|
|
115
|
+
const emit = __emit;
|
|
116
|
+
const ICONS = { "add-media": AttachFileIcon, "create-image": ImageIcon, "create-video": VideocamIcon, "edit-media": ContentCutIcon };
|
|
117
|
+
const open = ref(false);
|
|
118
|
+
const root = ref();
|
|
119
|
+
const input = ref();
|
|
120
|
+
useDismiss(root, open, () => open.value = false);
|
|
121
|
+
function pick(action) {
|
|
122
|
+
open.value = false;
|
|
123
|
+
if (action === "add-media") input.value?.click();
|
|
124
|
+
emit("select", action);
|
|
125
|
+
}
|
|
126
|
+
function onFileChange(e) {
|
|
127
|
+
const el = e.target;
|
|
128
|
+
emit("files", el.files);
|
|
129
|
+
el.value = "";
|
|
130
|
+
}
|
|
131
|
+
return (_ctx, _cache) => {
|
|
132
|
+
return openBlock(), createElementBlock("div", {
|
|
133
|
+
ref_key: "root",
|
|
134
|
+
ref: root,
|
|
135
|
+
class: "chai-composer__attach"
|
|
136
|
+
}, [
|
|
137
|
+
createElementVNode("button", {
|
|
138
|
+
type: "button",
|
|
139
|
+
class: normalizeClass(["chai-composer__attach-toggle", { "chai-composer__attach-toggle--open": open.value }]),
|
|
140
|
+
disabled: __props.disabled,
|
|
141
|
+
"aria-expanded": open.value,
|
|
142
|
+
"aria-haspopup": "menu",
|
|
143
|
+
"aria-label": open.value ? "Close attach menu" : "Add media",
|
|
144
|
+
onClick: _cache[0] || (_cache[0] = ($event) => open.value = !open.value)
|
|
145
|
+
}, [
|
|
146
|
+
open.value ? (openBlock(), createBlock(unref(CloseSymbolIcon), { key: 0 })) : (openBlock(), createBlock(unref(PlusIcon), { key: 1 }))
|
|
147
|
+
], 10, _hoisted_1$g),
|
|
148
|
+
open.value ? (openBlock(), createElementBlock("ul", _hoisted_2$b, [
|
|
149
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item, i) => {
|
|
150
|
+
return openBlock(), createElementBlock("li", {
|
|
151
|
+
key: item.action,
|
|
152
|
+
role: "none"
|
|
153
|
+
}, [
|
|
154
|
+
createElementVNode("button", {
|
|
155
|
+
type: "button",
|
|
156
|
+
role: "menuitem",
|
|
157
|
+
class: "chai-composer__attach-menu-item",
|
|
158
|
+
onClick: ($event) => pick(item.action)
|
|
159
|
+
}, [
|
|
160
|
+
createElementVNode("span", _hoisted_4$7, [
|
|
161
|
+
(openBlock(), createBlock(resolveDynamicComponent(ICONS[item.action])))
|
|
162
|
+
]),
|
|
163
|
+
createTextVNode(toDisplayString(item.label), 1)
|
|
164
|
+
], 8, _hoisted_3$9),
|
|
165
|
+
item.divider && i < __props.items.length - 1 ? (openBlock(), createElementBlock("hr", _hoisted_5$6)) : createCommentVNode("", true)
|
|
166
|
+
]);
|
|
167
|
+
}), 128))
|
|
168
|
+
])) : createCommentVNode("", true),
|
|
169
|
+
createElementVNode("input", {
|
|
170
|
+
ref_key: "input",
|
|
171
|
+
ref: input,
|
|
172
|
+
type: "file",
|
|
173
|
+
accept: __props.imagesOnly ? "image/*" : "image/*,video/*,audio/*",
|
|
174
|
+
multiple: !__props.imagesOnly,
|
|
175
|
+
hidden: "",
|
|
176
|
+
disabled: __props.disabled,
|
|
177
|
+
onChange: onFileChange
|
|
178
|
+
}, null, 40, _hoisted_6$6)
|
|
179
|
+
], 512);
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
const _hoisted_1$f = {
|
|
184
|
+
key: 0,
|
|
185
|
+
class: "chai-composer__region-badge",
|
|
186
|
+
"aria-hidden": "true"
|
|
187
|
+
};
|
|
188
|
+
const _hoisted_2$a = ["disabled", "aria-label"];
|
|
189
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
190
|
+
__name: "Chip",
|
|
191
|
+
props: {
|
|
192
|
+
label: {},
|
|
193
|
+
regionNumber: {},
|
|
194
|
+
removable: { type: Boolean },
|
|
195
|
+
disabled: { type: Boolean }
|
|
196
|
+
},
|
|
197
|
+
emits: ["remove"],
|
|
198
|
+
setup(__props, { emit: __emit }) {
|
|
199
|
+
const emit = __emit;
|
|
200
|
+
return (_ctx, _cache) => {
|
|
201
|
+
return openBlock(), createElementBlock("span", {
|
|
202
|
+
class: normalizeClass(["chai-composer__chip", { "chai-composer__chip--region": __props.regionNumber != null }]),
|
|
203
|
+
style: normalizeStyle(__props.regionNumber != null ? { "--chai-region-color": unref(regionColor)(__props.regionNumber) } : void 0)
|
|
204
|
+
}, [
|
|
205
|
+
__props.regionNumber != null ? (openBlock(), createElementBlock("span", _hoisted_1$f, toDisplayString(__props.regionNumber), 1)) : createCommentVNode("", true),
|
|
206
|
+
createTextVNode(toDisplayString(__props.label), 1),
|
|
207
|
+
__props.removable ? (openBlock(), createElementBlock("button", {
|
|
208
|
+
key: 1,
|
|
209
|
+
type: "button",
|
|
210
|
+
class: "chai-composer__chip-remove",
|
|
211
|
+
disabled: __props.disabled,
|
|
212
|
+
"aria-label": `Remove ${__props.label}`,
|
|
213
|
+
onClick: _cache[0] || (_cache[0] = ($event) => emit("remove"))
|
|
214
|
+
}, [
|
|
215
|
+
createVNode(unref(CloseSymbolIcon))
|
|
216
|
+
], 8, _hoisted_2$a)) : createCommentVNode("", true)
|
|
217
|
+
], 6);
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
const _hoisted_1$e = ["aria-label", ".selected", ".disabled"];
|
|
222
|
+
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
223
|
+
__name: "Toggle",
|
|
224
|
+
props: {
|
|
225
|
+
modelValue: { type: Boolean },
|
|
226
|
+
disabled: { type: Boolean },
|
|
227
|
+
ariaLabel: {}
|
|
228
|
+
},
|
|
229
|
+
emits: ["update:modelValue"],
|
|
230
|
+
setup(__props, { emit: __emit }) {
|
|
231
|
+
const emit = __emit;
|
|
232
|
+
return (_ctx, _cache) => {
|
|
233
|
+
return openBlock(), createElementBlock("md-switch", {
|
|
234
|
+
class: "chai-switch",
|
|
235
|
+
"aria-label": __props.ariaLabel,
|
|
236
|
+
".selected": __props.modelValue,
|
|
237
|
+
".disabled": __props.disabled ?? false,
|
|
238
|
+
"show-only-selected-icon": "",
|
|
239
|
+
onChange: _cache[0] || (_cache[0] = ($event) => emit("update:modelValue", $event.target.selected))
|
|
240
|
+
}, null, 40, _hoisted_1$e);
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
const _hoisted_1$d = ["disabled", "aria-expanded"];
|
|
245
|
+
const _hoisted_2$9 = ["title"];
|
|
246
|
+
const _hoisted_3$8 = ["aria-label"];
|
|
247
|
+
const _hoisted_4$6 = {
|
|
248
|
+
key: 0,
|
|
249
|
+
class: "chai-search-menu__toggle-header"
|
|
250
|
+
};
|
|
251
|
+
const _hoisted_5$5 = { class: "chai-search-menu__toggle-header-label" };
|
|
252
|
+
const _hoisted_6$5 = { class: "chai-search-menu__toggle-header-row" };
|
|
253
|
+
const _hoisted_7$5 = { class: "chai-search-menu__toggle-header-text" };
|
|
254
|
+
const _hoisted_8$5 = ["label", ".value"];
|
|
255
|
+
const _hoisted_9$5 = { class: "chai-search-menu__list" };
|
|
256
|
+
const _hoisted_10$5 = {
|
|
257
|
+
key: 0,
|
|
258
|
+
class: "chai-search-menu__section-label"
|
|
259
|
+
};
|
|
260
|
+
const _hoisted_11$4 = ["aria-label"];
|
|
261
|
+
const _hoisted_12$4 = ["aria-pressed", "disabled", "onClick"];
|
|
262
|
+
const _hoisted_13$4 = [".checked", ".disabled"];
|
|
263
|
+
const _hoisted_14$4 = { class: "chai-search-menu__option-label" };
|
|
264
|
+
const _hoisted_15$4 = {
|
|
265
|
+
key: 1,
|
|
266
|
+
class: "chai-search-menu__divider",
|
|
267
|
+
role: "separator"
|
|
268
|
+
};
|
|
269
|
+
const _hoisted_16$3 = {
|
|
270
|
+
key: 0,
|
|
271
|
+
class: "chai-search-menu__empty"
|
|
272
|
+
};
|
|
273
|
+
const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
274
|
+
__name: "SearchMenu",
|
|
275
|
+
props: {
|
|
276
|
+
options: {},
|
|
277
|
+
sections: {},
|
|
278
|
+
toggleHeader: {},
|
|
279
|
+
value: {},
|
|
280
|
+
multiple: { type: Boolean },
|
|
281
|
+
triggerLabel: {},
|
|
282
|
+
menuLabel: {},
|
|
283
|
+
disabled: { type: Boolean },
|
|
284
|
+
searchable: { type: Boolean, default: true },
|
|
285
|
+
triggerVariant: { default: "outlined" },
|
|
286
|
+
panelWidth: { default: 280 }
|
|
287
|
+
},
|
|
288
|
+
emits: ["select"],
|
|
289
|
+
setup(__props, { emit: __emit }) {
|
|
290
|
+
const props = __props;
|
|
291
|
+
const emit = __emit;
|
|
292
|
+
const open = ref(false);
|
|
293
|
+
const search = ref("");
|
|
294
|
+
const root = ref();
|
|
295
|
+
const panel = ref();
|
|
296
|
+
function close() {
|
|
297
|
+
open.value = false;
|
|
298
|
+
search.value = "";
|
|
299
|
+
}
|
|
300
|
+
watch(open, async (isOpen) => {
|
|
301
|
+
if (!isOpen) return;
|
|
302
|
+
await nextTick();
|
|
303
|
+
const el = panel.value;
|
|
304
|
+
const rect = el.getBoundingClientRect();
|
|
305
|
+
const over = rect.right - (document.documentElement.clientWidth - 16);
|
|
306
|
+
if (over > 0) el.style.left = `${-Math.min(over, Math.max(0, rect.left - 16))}px`;
|
|
307
|
+
});
|
|
308
|
+
useDismiss(root, open, close);
|
|
309
|
+
const groups = computed(() => {
|
|
310
|
+
const q = search.value.trim().toLowerCase();
|
|
311
|
+
const raw = props.sections ?? [{ label: "", options: props.options ?? [] }];
|
|
312
|
+
if (!q) return raw;
|
|
313
|
+
return raw.map((g) => ({ ...g, options: g.options.filter((o) => o.label.toLowerCase().includes(q) || o.rowLabel?.toLowerCase().includes(q)) })).filter((g) => g.options.length > 0);
|
|
314
|
+
});
|
|
315
|
+
const hasAnyOption = computed(() => groups.value.some((g) => g.options.length > 0));
|
|
316
|
+
const isSelected = (id) => Array.isArray(props.value) ? props.value.includes(id) : id === props.value;
|
|
317
|
+
function pick(option) {
|
|
318
|
+
emit("select", option);
|
|
319
|
+
if (!props.multiple) close();
|
|
320
|
+
}
|
|
321
|
+
return (_ctx, _cache) => {
|
|
322
|
+
return openBlock(), createElementBlock("div", {
|
|
323
|
+
ref_key: "root",
|
|
324
|
+
ref: root,
|
|
325
|
+
class: "chai-search-menu"
|
|
326
|
+
}, [
|
|
327
|
+
createElementVNode("button", {
|
|
328
|
+
type: "button",
|
|
329
|
+
class: normalizeClass([
|
|
330
|
+
__props.triggerVariant === "outlined" ? "chai-btn chai-btn--outlined" : "chai-search-menu__trigger--text",
|
|
331
|
+
"chai-search-menu__trigger",
|
|
332
|
+
{ "chai-search-menu__trigger--open": open.value }
|
|
333
|
+
]),
|
|
334
|
+
disabled: __props.disabled,
|
|
335
|
+
"aria-expanded": open.value,
|
|
336
|
+
onClick: _cache[0] || (_cache[0] = ($event) => open.value ? close() : open.value = true)
|
|
337
|
+
}, [
|
|
338
|
+
createElementVNode("span", {
|
|
339
|
+
class: "chai-search-menu__trigger-label",
|
|
340
|
+
title: __props.triggerLabel
|
|
341
|
+
}, toDisplayString(__props.triggerLabel), 9, _hoisted_2$9),
|
|
342
|
+
(openBlock(), createElementBlock("svg", {
|
|
343
|
+
class: normalizeClass(["chai-search-menu__chevron", { "chai-search-menu__chevron--open": open.value }]),
|
|
344
|
+
viewBox: "0 -960 960 960",
|
|
345
|
+
"aria-hidden": "true"
|
|
346
|
+
}, [..._cache[3] || (_cache[3] = [
|
|
347
|
+
createElementVNode("path", {
|
|
348
|
+
d: "M480-344 240-584l43-43 197 197 197-197 43 43-240 240Z",
|
|
349
|
+
fill: "currentColor"
|
|
350
|
+
}, null, -1)
|
|
351
|
+
])], 2))
|
|
352
|
+
], 10, _hoisted_1$d),
|
|
353
|
+
open.value ? (openBlock(), createElementBlock("div", {
|
|
354
|
+
key: 0,
|
|
355
|
+
ref_key: "panel",
|
|
356
|
+
ref: panel,
|
|
357
|
+
class: "chai-search-menu__panel",
|
|
358
|
+
role: "group",
|
|
359
|
+
"aria-label": __props.menuLabel,
|
|
360
|
+
style: normalizeStyle({ width: `${__props.panelWidth}px` })
|
|
361
|
+
}, [
|
|
362
|
+
__props.toggleHeader ? (openBlock(), createElementBlock("div", _hoisted_4$6, [
|
|
363
|
+
createElementVNode("span", _hoisted_5$5, toDisplayString(__props.menuLabel), 1),
|
|
364
|
+
createElementVNode("span", _hoisted_6$5, [
|
|
365
|
+
createElementVNode("span", _hoisted_7$5, toDisplayString(__props.toggleHeader.label), 1),
|
|
366
|
+
createVNode(_sfc_main$e, {
|
|
367
|
+
"model-value": __props.toggleHeader.value,
|
|
368
|
+
"aria-label": __props.toggleHeader.label,
|
|
369
|
+
"onUpdate:modelValue": __props.toggleHeader.onChange
|
|
370
|
+
}, null, 8, ["model-value", "aria-label", "onUpdate:modelValue"])
|
|
371
|
+
])
|
|
372
|
+
])) : createCommentVNode("", true),
|
|
373
|
+
__props.searchable ? (openBlock(), createElementBlock("md-outlined-text-field", {
|
|
374
|
+
key: 1,
|
|
375
|
+
class: "chai-search-menu__search",
|
|
376
|
+
label: __props.menuLabel,
|
|
377
|
+
placeholder: "Input",
|
|
378
|
+
".value": search.value,
|
|
379
|
+
onInput: _cache[2] || (_cache[2] = ($event) => search.value = $event.target.value)
|
|
380
|
+
}, [
|
|
381
|
+
_cache[5] || (_cache[5] = createElementVNode("span", {
|
|
382
|
+
slot: "leading-icon",
|
|
383
|
+
class: "chai-search-menu__search-icon"
|
|
384
|
+
}, [
|
|
385
|
+
createElementVNode("svg", {
|
|
386
|
+
viewBox: "0 0 24 24",
|
|
387
|
+
fill: "none",
|
|
388
|
+
"aria-hidden": "true"
|
|
389
|
+
}, [
|
|
390
|
+
createElementVNode("circle", {
|
|
391
|
+
cx: "11",
|
|
392
|
+
cy: "11",
|
|
393
|
+
r: "6.5",
|
|
394
|
+
stroke: "currentColor",
|
|
395
|
+
"stroke-width": "1.5"
|
|
396
|
+
}),
|
|
397
|
+
createElementVNode("path", {
|
|
398
|
+
d: "m20 20-3.6-3.6",
|
|
399
|
+
stroke: "currentColor",
|
|
400
|
+
"stroke-width": "1.5",
|
|
401
|
+
"stroke-linecap": "round"
|
|
402
|
+
})
|
|
403
|
+
])
|
|
404
|
+
], -1)),
|
|
405
|
+
search.value ? (openBlock(), createElementBlock("button", {
|
|
406
|
+
key: 0,
|
|
407
|
+
type: "button",
|
|
408
|
+
slot: "trailing-icon",
|
|
409
|
+
class: "chai-search-menu__clear",
|
|
410
|
+
"aria-label": "Clear search",
|
|
411
|
+
onClick: _cache[1] || (_cache[1] = ($event) => search.value = "")
|
|
412
|
+
}, [..._cache[4] || (_cache[4] = [
|
|
413
|
+
createElementVNode("svg", {
|
|
414
|
+
viewBox: "0 0 24 24",
|
|
415
|
+
fill: "none",
|
|
416
|
+
"aria-hidden": "true"
|
|
417
|
+
}, [
|
|
418
|
+
createElementVNode("circle", {
|
|
419
|
+
cx: "12",
|
|
420
|
+
cy: "12",
|
|
421
|
+
r: "9",
|
|
422
|
+
stroke: "currentColor",
|
|
423
|
+
"stroke-width": "1.5"
|
|
424
|
+
}),
|
|
425
|
+
createElementVNode("path", {
|
|
426
|
+
d: "m9 9 6 6m0-6-6 6",
|
|
427
|
+
stroke: "currentColor",
|
|
428
|
+
"stroke-width": "1.5",
|
|
429
|
+
"stroke-linecap": "round"
|
|
430
|
+
})
|
|
431
|
+
], -1)
|
|
432
|
+
])])) : createCommentVNode("", true)
|
|
433
|
+
], 40, _hoisted_8$5)) : createCommentVNode("", true),
|
|
434
|
+
createElementVNode("ul", _hoisted_9$5, [
|
|
435
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(groups.value, (group, i) => {
|
|
436
|
+
return openBlock(), createElementBlock("li", {
|
|
437
|
+
key: group.label || i
|
|
438
|
+
}, [
|
|
439
|
+
group.label ? (openBlock(), createElementBlock("p", _hoisted_10$5, toDisplayString(group.label), 1)) : createCommentVNode("", true),
|
|
440
|
+
createElementVNode("ul", {
|
|
441
|
+
class: "chai-search-menu__section-list",
|
|
442
|
+
"aria-label": group.label || void 0
|
|
443
|
+
}, [
|
|
444
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(group.options, (o) => {
|
|
445
|
+
return openBlock(), createElementBlock("li", {
|
|
446
|
+
key: o.id
|
|
447
|
+
}, [
|
|
448
|
+
createElementVNode("button", {
|
|
449
|
+
type: "button",
|
|
450
|
+
"aria-pressed": isSelected(o.id),
|
|
451
|
+
disabled: __props.toggleHeader?.value,
|
|
452
|
+
class: normalizeClass(["chai-search-menu__option", { "chai-search-menu__option--selected": !__props.multiple && isSelected(o.id) }]),
|
|
453
|
+
onClick: ($event) => pick(o)
|
|
454
|
+
}, [
|
|
455
|
+
__props.multiple ? (openBlock(), createElementBlock("md-checkbox", {
|
|
456
|
+
key: 0,
|
|
457
|
+
class: "chai-search-menu__checkbox",
|
|
458
|
+
".checked": isSelected(o.id),
|
|
459
|
+
".disabled": __props.toggleHeader?.value ?? false,
|
|
460
|
+
tabindex: "-1",
|
|
461
|
+
"aria-hidden": "true"
|
|
462
|
+
}, null, 40, _hoisted_13$4)) : createCommentVNode("", true),
|
|
463
|
+
createElementVNode("span", _hoisted_14$4, toDisplayString(o.rowLabel ?? o.label), 1),
|
|
464
|
+
!__props.multiple && isSelected(o.id) ? (openBlock(), createBlock(unref(CheckIcon), { key: 1 })) : createCommentVNode("", true)
|
|
465
|
+
], 10, _hoisted_12$4)
|
|
466
|
+
]);
|
|
467
|
+
}), 128))
|
|
468
|
+
], 8, _hoisted_11$4),
|
|
469
|
+
i < groups.value.length - 1 ? (openBlock(), createElementBlock("hr", _hoisted_15$4)) : createCommentVNode("", true)
|
|
470
|
+
]);
|
|
471
|
+
}), 128)),
|
|
472
|
+
!hasAnyOption.value ? (openBlock(), createElementBlock("li", _hoisted_16$3, "No matches.")) : createCommentVNode("", true)
|
|
473
|
+
])
|
|
474
|
+
], 12, _hoisted_3$8)) : createCommentVNode("", true)
|
|
475
|
+
], 512);
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
const _hoisted_1$c = { class: "chai-composer" };
|
|
480
|
+
const _hoisted_2$8 = {
|
|
481
|
+
key: 0,
|
|
482
|
+
class: "chai-composer__thumbnails"
|
|
483
|
+
};
|
|
484
|
+
const _hoisted_3$7 = ["src"];
|
|
485
|
+
const _hoisted_4$5 = {
|
|
486
|
+
key: 1,
|
|
487
|
+
class: "chai-composer__thumb-icon"
|
|
488
|
+
};
|
|
489
|
+
const _hoisted_5$4 = ["onClick"];
|
|
490
|
+
const _hoisted_6$4 = {
|
|
491
|
+
key: 1,
|
|
492
|
+
class: "chai-composer__regions",
|
|
493
|
+
"aria-label": "Edit regions"
|
|
494
|
+
};
|
|
495
|
+
const _hoisted_7$4 = { class: "chai-composer__field" };
|
|
496
|
+
const _hoisted_8$4 = ["value", "placeholder", "aria-label", "disabled"];
|
|
497
|
+
const _hoisted_9$4 = {
|
|
498
|
+
key: 0,
|
|
499
|
+
class: "chai-composer__reveal chai-composer__type",
|
|
500
|
+
"aria-hidden": "true"
|
|
501
|
+
};
|
|
502
|
+
const _hoisted_10$4 = { class: "chai-composer__reveal-text" };
|
|
503
|
+
const _hoisted_11$3 = ["disabled", "aria-label", "title"];
|
|
504
|
+
const _hoisted_12$3 = {
|
|
505
|
+
key: 2,
|
|
506
|
+
class: "chai-composer__error",
|
|
507
|
+
role: "alert"
|
|
508
|
+
};
|
|
509
|
+
const _hoisted_13$3 = { class: "chai-composer__controls" };
|
|
510
|
+
const _hoisted_14$3 = { class: "chai-composer__controls-start" };
|
|
511
|
+
const _hoisted_15$3 = ["data-ready", "data-error", "data-stop", "aria-label", "aria-disabled"];
|
|
512
|
+
const _hoisted_16$2 = { slot: "icon" };
|
|
513
|
+
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
514
|
+
__name: "Composer",
|
|
515
|
+
props: {
|
|
516
|
+
modelValue: {},
|
|
517
|
+
placeholder: {},
|
|
518
|
+
promptLabel: {},
|
|
519
|
+
attachments: { default: () => [] },
|
|
520
|
+
"onUpdate:attachments": {},
|
|
521
|
+
useCase: { default: null },
|
|
522
|
+
onClearUseCase: {},
|
|
523
|
+
defaultUseCase: {},
|
|
524
|
+
multiSelectUseCases: { type: Boolean },
|
|
525
|
+
useCases: { default: () => [] },
|
|
526
|
+
"onUpdate:useCases": {},
|
|
527
|
+
modelsByKind: {},
|
|
528
|
+
multiSelectModels: { type: Boolean },
|
|
529
|
+
modelIds: { default: () => [] },
|
|
530
|
+
"onUpdate:modelIds": {},
|
|
531
|
+
models: {},
|
|
532
|
+
modelId: { default: null },
|
|
533
|
+
"onUpdate:modelId": {},
|
|
534
|
+
autoSelectModel: { type: Boolean },
|
|
535
|
+
showAutoSelectToggle: { type: Boolean },
|
|
536
|
+
"onUpdate:autoSelectModel": {},
|
|
537
|
+
aspectRatios: {},
|
|
538
|
+
aspectRatio: { default: null },
|
|
539
|
+
"onUpdate:aspectRatio": {},
|
|
540
|
+
onEnhance: {},
|
|
541
|
+
enhancing: { type: Boolean },
|
|
542
|
+
submitError: { default: null },
|
|
543
|
+
submitDisabled: { type: Boolean, default: void 0 },
|
|
544
|
+
submitting: { type: Boolean },
|
|
545
|
+
onAbort: {},
|
|
546
|
+
onAttachMenuSelect: {},
|
|
547
|
+
attachMenuActions: {},
|
|
548
|
+
regions: { default: () => [] },
|
|
549
|
+
"onUpdate:regions": {},
|
|
550
|
+
disabled: { type: Boolean }
|
|
551
|
+
},
|
|
552
|
+
emits: ["update:modelValue", "submit", "unsupportedFile"],
|
|
553
|
+
setup(__props, { emit: __emit }) {
|
|
554
|
+
const props = __props;
|
|
555
|
+
const emit = __emit;
|
|
556
|
+
const view = computed(
|
|
557
|
+
() => composerView({
|
|
558
|
+
...props,
|
|
559
|
+
value: props.modelValue,
|
|
560
|
+
onModelChange: props["onUpdate:modelId"],
|
|
561
|
+
onModelIdsChange: props["onUpdate:modelIds"]
|
|
562
|
+
})
|
|
563
|
+
);
|
|
564
|
+
const menuItems = computed(
|
|
565
|
+
() => composerAttachMenuItems(props.attachMenuActions, {
|
|
566
|
+
canAddMedia: Boolean(props["onUpdate:attachments"]),
|
|
567
|
+
canSelect: Boolean(props.onAttachMenuSelect)
|
|
568
|
+
})
|
|
569
|
+
);
|
|
570
|
+
const modelMenuOptions = computed(
|
|
571
|
+
() => props.multiSelectUseCases ? { sections: view.value.modelSections.map((s) => ({ label: s.label, options: s.options })) } : { options: view.value.modelSections[0]?.options }
|
|
572
|
+
);
|
|
573
|
+
watch(
|
|
574
|
+
() => props.autoSelectModel,
|
|
575
|
+
(on, was) => {
|
|
576
|
+
if (!on || was) return;
|
|
577
|
+
if (view.value.multiModel) props["onUpdate:modelIds"]?.([]);
|
|
578
|
+
else props["onUpdate:modelId"]?.(null);
|
|
579
|
+
}
|
|
580
|
+
);
|
|
581
|
+
watch(
|
|
582
|
+
() => view.value.useCaseKey,
|
|
583
|
+
() => {
|
|
584
|
+
if (props.autoSelectModel && props.showAutoSelectToggle) props["onUpdate:autoSelectModel"]?.(false);
|
|
585
|
+
}
|
|
586
|
+
);
|
|
587
|
+
function toggleModel(id) {
|
|
588
|
+
if (view.value.multiModel) props["onUpdate:modelIds"]?.(view.value.toggledModelIds(id));
|
|
589
|
+
else props["onUpdate:modelId"]?.(id);
|
|
590
|
+
}
|
|
591
|
+
const textarea = ref();
|
|
592
|
+
watch(
|
|
593
|
+
() => props.modelValue,
|
|
594
|
+
() => {
|
|
595
|
+
const el = textarea.value;
|
|
596
|
+
if (!el) return;
|
|
597
|
+
el.style.height = "auto";
|
|
598
|
+
el.style.height = `${el.scrollHeight}px`;
|
|
599
|
+
},
|
|
600
|
+
{ flush: "post", immediate: true }
|
|
601
|
+
);
|
|
602
|
+
const originalValue = ref(null);
|
|
603
|
+
const enhancedValue = ref(null);
|
|
604
|
+
const animatingText = ref(null);
|
|
605
|
+
const revealedLength = ref(0);
|
|
606
|
+
let raf = 0;
|
|
607
|
+
watch(
|
|
608
|
+
() => props.enhancing,
|
|
609
|
+
(now, was) => {
|
|
610
|
+
if (!was || now || originalValue.value == null || props.modelValue === originalValue.value) return;
|
|
611
|
+
const value = props.modelValue;
|
|
612
|
+
enhancedValue.value = value;
|
|
613
|
+
if (value.length > MAX_ANIMATE_ENHANCE_LENGTH || window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
|
|
614
|
+
animatingText.value = value;
|
|
615
|
+
revealedLength.value = 0;
|
|
616
|
+
const duration = enhanceRevealDurationMs(value.length);
|
|
617
|
+
const start = performance.now();
|
|
618
|
+
const tick = (time) => {
|
|
619
|
+
revealedLength.value = Math.min(value.length, Math.floor((time - start) / duration * value.length));
|
|
620
|
+
if (revealedLength.value < value.length) raf = requestAnimationFrame(tick);
|
|
621
|
+
else animatingText.value = null;
|
|
622
|
+
};
|
|
623
|
+
raf = requestAnimationFrame(tick);
|
|
624
|
+
}
|
|
625
|
+
);
|
|
626
|
+
onScopeDispose(() => cancelAnimationFrame(raf));
|
|
627
|
+
const animating = computed(() => animatingText.value != null);
|
|
628
|
+
const isEnhanced = computed(() => !animating.value && enhancedValue.value != null && props.modelValue === enhancedValue.value);
|
|
629
|
+
const enhanceBusy = computed(() => Boolean(props.enhancing) || animating.value);
|
|
630
|
+
function onOptimizeClick() {
|
|
631
|
+
if (isEnhanced.value) {
|
|
632
|
+
const original = originalValue.value;
|
|
633
|
+
enhancedValue.value = null;
|
|
634
|
+
originalValue.value = null;
|
|
635
|
+
if (original != null) emit("update:modelValue", original);
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
originalValue.value = props.modelValue;
|
|
639
|
+
props.onEnhance?.(props.modelValue);
|
|
640
|
+
}
|
|
641
|
+
async function onFiles(files) {
|
|
642
|
+
const onAttachments = props["onUpdate:attachments"];
|
|
643
|
+
if (!files || files.length === 0 || !onAttachments) return;
|
|
644
|
+
const { attachments, unsupported } = await composerAttachmentsFromFiles(files, props.attachments, view.value.editing);
|
|
645
|
+
unsupported.forEach((name) => emit("unsupportedFile", name));
|
|
646
|
+
if (attachments) onAttachments(attachments);
|
|
647
|
+
}
|
|
648
|
+
function removeUseCase(useCase) {
|
|
649
|
+
if (props.multiSelectUseCases) props["onUpdate:useCases"]?.(props.useCases.filter((u) => u.kind !== useCase.kind));
|
|
650
|
+
else props.onClearUseCase?.();
|
|
651
|
+
}
|
|
652
|
+
function onSubmitClick() {
|
|
653
|
+
if (view.value.showStop) props.onAbort?.();
|
|
654
|
+
else if (!view.value.isSubmitDisabled && !props.submitting) emit("submit", view.value.payload());
|
|
655
|
+
}
|
|
656
|
+
return (_ctx, _cache) => {
|
|
657
|
+
return openBlock(), createElementBlock("div", _hoisted_1$c, [
|
|
658
|
+
__props.attachments.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_2$8, [
|
|
659
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.attachments, (a) => {
|
|
660
|
+
return openBlock(), createElementBlock("div", {
|
|
661
|
+
key: a.id,
|
|
662
|
+
class: "chai-composer__thumb"
|
|
663
|
+
}, [
|
|
664
|
+
a.kind === "image" ? (openBlock(), createElementBlock("img", {
|
|
665
|
+
key: 0,
|
|
666
|
+
class: "chai-composer__thumb-img",
|
|
667
|
+
src: a.src,
|
|
668
|
+
alt: ""
|
|
669
|
+
}, null, 8, _hoisted_3$7)) : (openBlock(), createElementBlock("span", _hoisted_4$5, [
|
|
670
|
+
a.kind === "video" ? (openBlock(), createBlock(unref(VideocamIcon), { key: 0 })) : a.kind === "audio" ? (openBlock(), createBlock(unref(MusicNoteIcon), { key: 1 })) : (openBlock(), createBlock(unref(ImageIcon), { key: 2 }))
|
|
671
|
+
])),
|
|
672
|
+
props["onUpdate:attachments"] ? (openBlock(), createElementBlock("button", {
|
|
673
|
+
key: 2,
|
|
674
|
+
type: "button",
|
|
675
|
+
class: "chai-composer__thumb-remove",
|
|
676
|
+
"aria-label": "Remove attachment",
|
|
677
|
+
onClick: ($event) => props["onUpdate:attachments"]?.(__props.attachments.filter((x) => x.id !== a.id))
|
|
678
|
+
}, [
|
|
679
|
+
createVNode(unref(CloseSymbolIcon))
|
|
680
|
+
], 8, _hoisted_5$4)) : createCommentVNode("", true)
|
|
681
|
+
]);
|
|
682
|
+
}), 128))
|
|
683
|
+
])) : createCommentVNode("", true),
|
|
684
|
+
view.value.editing && __props.regions.length > 0 ? (openBlock(), createElementBlock("ul", _hoisted_6$4, [
|
|
685
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.regions, (r) => {
|
|
686
|
+
return openBlock(), createElementBlock("li", {
|
|
687
|
+
key: r.id
|
|
688
|
+
}, [
|
|
689
|
+
createVNode(_sfc_main$f, {
|
|
690
|
+
label: `Region ${r.number}`,
|
|
691
|
+
"region-number": r.number,
|
|
692
|
+
removable: Boolean(props["onUpdate:regions"]),
|
|
693
|
+
disabled: __props.disabled,
|
|
694
|
+
onRemove: ($event) => props["onUpdate:regions"]?.(__props.regions.filter((x) => x.id !== r.id))
|
|
695
|
+
}, null, 8, ["label", "region-number", "removable", "disabled", "onRemove"])
|
|
696
|
+
]);
|
|
697
|
+
}), 128))
|
|
698
|
+
])) : createCommentVNode("", true),
|
|
699
|
+
createElementVNode("div", _hoisted_7$4, [
|
|
700
|
+
createElementVNode("textarea", {
|
|
701
|
+
ref_key: "textarea",
|
|
702
|
+
ref: textarea,
|
|
703
|
+
class: normalizeClass(["chai-composer__input chai-composer__type", { "chai-composer__input--revealing": animating.value }]),
|
|
704
|
+
value: __props.modelValue,
|
|
705
|
+
placeholder: view.value.placeholder,
|
|
706
|
+
"aria-label": __props.promptLabel ?? view.value.placeholder,
|
|
707
|
+
rows: "1",
|
|
708
|
+
disabled: __props.disabled || animating.value,
|
|
709
|
+
onInput: _cache[0] || (_cache[0] = ($event) => emit("update:modelValue", $event.target.value))
|
|
710
|
+
}, null, 42, _hoisted_8$4),
|
|
711
|
+
animating.value ? (openBlock(), createElementBlock("div", _hoisted_9$4, [
|
|
712
|
+
createElementVNode("span", _hoisted_10$4, toDisplayString(animatingText.value.slice(0, revealedLength.value)), 1)
|
|
713
|
+
])) : createCommentVNode("", true),
|
|
714
|
+
__props.onEnhance ? (openBlock(), createElementBlock("button", {
|
|
715
|
+
key: 1,
|
|
716
|
+
type: "button",
|
|
717
|
+
class: normalizeClass(["chai-composer__optimize", { "chai-composer__optimize--active": enhanceBusy.value }]),
|
|
718
|
+
disabled: __props.disabled || (isEnhanced.value ? false : !__props.modelValue.trim() || enhanceBusy.value),
|
|
719
|
+
"aria-label": isEnhanced.value ? "Revert to original prompt" : "Optimize prompt",
|
|
720
|
+
title: isEnhanced.value ? "Revert to original prompt" : "Optimize prompt",
|
|
721
|
+
onClick: onOptimizeClick
|
|
722
|
+
}, [
|
|
723
|
+
isEnhanced.value ? (openBlock(), createBlock(unref(UndoIcon), { key: 0 })) : (openBlock(), createBlock(unref(OptimizeIcon), { key: 1 }))
|
|
724
|
+
], 10, _hoisted_11$3)) : createCommentVNode("", true)
|
|
725
|
+
]),
|
|
726
|
+
__props.submitError ? (openBlock(), createElementBlock("p", _hoisted_12$3, [
|
|
727
|
+
createVNode(unref(ErrorIcon)),
|
|
728
|
+
createTextVNode(toDisplayString(__props.submitError), 1)
|
|
729
|
+
])) : createCommentVNode("", true),
|
|
730
|
+
createElementVNode("div", _hoisted_13$3, [
|
|
731
|
+
createElementVNode("div", _hoisted_14$3, [
|
|
732
|
+
menuItems.value.length > 0 ? (openBlock(), createBlock(_sfc_main$g, {
|
|
733
|
+
key: 0,
|
|
734
|
+
items: menuItems.value,
|
|
735
|
+
"images-only": view.value.editing,
|
|
736
|
+
disabled: __props.disabled,
|
|
737
|
+
onSelect: _cache[1] || (_cache[1] = ($event) => __props.onAttachMenuSelect?.($event)),
|
|
738
|
+
onFiles
|
|
739
|
+
}, null, 8, ["items", "images-only", "disabled"])) : createCommentVNode("", true),
|
|
740
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(view.value.pickedUseCases, (u) => {
|
|
741
|
+
return openBlock(), createBlock(_sfc_main$f, {
|
|
742
|
+
key: u.kind,
|
|
743
|
+
label: u.label,
|
|
744
|
+
removable: Boolean(__props.multiSelectUseCases ? props["onUpdate:useCases"] : __props.onClearUseCase),
|
|
745
|
+
disabled: __props.disabled,
|
|
746
|
+
onRemove: ($event) => removeUseCase(u)
|
|
747
|
+
}, null, 8, ["label", "removable", "disabled", "onRemove"]);
|
|
748
|
+
}), 128)),
|
|
749
|
+
view.value.modelSections.length > 0 && view.value.canPickModel ? (openBlock(), createBlock(_sfc_main$d, mergeProps({ key: 1 }, modelMenuOptions.value, {
|
|
750
|
+
value: view.value.multiModel ? view.value.pickedModelIds : __props.modelId,
|
|
751
|
+
multiple: view.value.multiModel,
|
|
752
|
+
"toggle-header": __props.showAutoSelectToggle ? { label: "Auto-select model", value: __props.autoSelectModel, onChange: (v) => props["onUpdate:autoSelectModel"]?.(v) } : void 0,
|
|
753
|
+
"trigger-label": view.value.modelTriggerLabel,
|
|
754
|
+
"menu-label": view.value.multiModel ? "Select models" : "Select model",
|
|
755
|
+
searchable: false,
|
|
756
|
+
"trigger-variant": "text",
|
|
757
|
+
disabled: __props.disabled || __props.autoSelectModel && !__props.showAutoSelectToggle,
|
|
758
|
+
"panel-width": __props.showAutoSelectToggle ? 320 : void 0,
|
|
759
|
+
onSelect: _cache[2] || (_cache[2] = ($event) => toggleModel($event.id))
|
|
760
|
+
}), null, 16, ["value", "multiple", "toggle-header", "trigger-label", "menu-label", "disabled", "panel-width"])) : createCommentVNode("", true),
|
|
761
|
+
view.value.showAspectRatio && view.value.aspectOptions.length > 0 && props["onUpdate:aspectRatio"] ? (openBlock(), createBlock(_sfc_main$d, {
|
|
762
|
+
key: 2,
|
|
763
|
+
options: view.value.aspectOptions.map((o) => ({ id: o.value, label: o.label })),
|
|
764
|
+
value: view.value.offeredAspect,
|
|
765
|
+
"trigger-label": view.value.selectedAspect?.label ?? "Aspect ratio",
|
|
766
|
+
"menu-label": "Aspect ratio",
|
|
767
|
+
searchable: false,
|
|
768
|
+
"trigger-variant": "text",
|
|
769
|
+
disabled: __props.disabled,
|
|
770
|
+
onSelect: _cache[3] || (_cache[3] = ($event) => props["onUpdate:aspectRatio"]?.($event.id))
|
|
771
|
+
}, null, 8, ["options", "value", "trigger-label", "disabled"])) : createCommentVNode("", true)
|
|
772
|
+
]),
|
|
773
|
+
createElementVNode("md-fab", {
|
|
774
|
+
class: "chai-composer__submit",
|
|
775
|
+
size: "small",
|
|
776
|
+
variant: "secondary",
|
|
777
|
+
label: "",
|
|
778
|
+
"data-ready": view.value.showStop || !view.value.isSubmitDisabled || void 0,
|
|
779
|
+
"data-error": Boolean(__props.submitError) || void 0,
|
|
780
|
+
"data-stop": view.value.showStop || void 0,
|
|
781
|
+
"aria-label": view.value.showStop ? "Stop" : __props.submitError ? "Retry" : "Submit",
|
|
782
|
+
"aria-disabled": view.value.showStop ? "false" : __props.submitting || view.value.isSubmitDisabled ? "true" : "false",
|
|
783
|
+
onClick: onSubmitClick
|
|
784
|
+
}, [
|
|
785
|
+
createElementVNode("span", _hoisted_16$2, [
|
|
786
|
+
view.value.showStop ? (openBlock(), createBlock(unref(StopIcon), { key: 0 })) : __props.submitError ? (openBlock(), createBlock(unref(RetryIcon), { key: 1 })) : (openBlock(), createBlock(unref(ArrowForwardIcon), { key: 2 }))
|
|
787
|
+
])
|
|
788
|
+
], 8, _hoisted_15$3)
|
|
789
|
+
])
|
|
790
|
+
]);
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
const _hoisted_1$b = { class: "chai-result-card__expand-frame" };
|
|
795
|
+
const _hoisted_2$7 = ["src", "alt"];
|
|
796
|
+
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
797
|
+
__name: "ExpandedImage",
|
|
798
|
+
props: {
|
|
799
|
+
src: {},
|
|
800
|
+
alt: {}
|
|
801
|
+
},
|
|
802
|
+
emits: ["close"],
|
|
803
|
+
setup(__props, { emit: __emit }) {
|
|
804
|
+
const emit = __emit;
|
|
805
|
+
const closeButton = ref();
|
|
806
|
+
let opener = null;
|
|
807
|
+
onMounted(() => {
|
|
808
|
+
opener = document.activeElement;
|
|
809
|
+
closeButton.value?.focus();
|
|
810
|
+
});
|
|
811
|
+
onUnmounted(() => opener?.focus());
|
|
812
|
+
function onKeydown(e) {
|
|
813
|
+
if (e.key === "Escape") {
|
|
814
|
+
e.stopPropagation();
|
|
815
|
+
emit("close");
|
|
816
|
+
} else if (e.key === "Tab") {
|
|
817
|
+
e.preventDefault();
|
|
818
|
+
closeButton.value?.focus();
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
return (_ctx, _cache) => {
|
|
822
|
+
return openBlock(), createElementBlock("div", {
|
|
823
|
+
class: "chai-result-card__expand-overlay",
|
|
824
|
+
role: "dialog",
|
|
825
|
+
"aria-modal": "true",
|
|
826
|
+
"aria-label": "Expanded image",
|
|
827
|
+
onKeydown
|
|
828
|
+
}, [
|
|
829
|
+
createElementVNode("div", {
|
|
830
|
+
class: "chai-result-card__expand-scrim",
|
|
831
|
+
role: "presentation",
|
|
832
|
+
onClick: _cache[0] || (_cache[0] = ($event) => emit("close"))
|
|
833
|
+
}),
|
|
834
|
+
createElementVNode("div", _hoisted_1$b, [
|
|
835
|
+
createElementVNode("img", {
|
|
836
|
+
class: "chai-result-card__image",
|
|
837
|
+
src: __props.src,
|
|
838
|
+
alt: __props.alt
|
|
839
|
+
}, null, 8, _hoisted_2$7),
|
|
840
|
+
createElementVNode("button", {
|
|
841
|
+
ref_key: "closeButton",
|
|
842
|
+
ref: closeButton,
|
|
843
|
+
type: "button",
|
|
844
|
+
class: "chai-result-card__collapse",
|
|
845
|
+
"aria-label": "Collapse",
|
|
846
|
+
onClick: _cache[1] || (_cache[1] = ($event) => emit("close"))
|
|
847
|
+
}, [
|
|
848
|
+
createVNode(unref(CloseSymbolIcon))
|
|
849
|
+
], 512)
|
|
850
|
+
])
|
|
851
|
+
], 32);
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
const _hoisted_1$a = ["aria-label", "aria-pressed", "disabled"];
|
|
856
|
+
const _hoisted_2$6 = {
|
|
857
|
+
class: "chai-edit-card__badge",
|
|
858
|
+
"aria-hidden": "true"
|
|
859
|
+
};
|
|
860
|
+
const _hoisted_3$6 = ["onPointerdown"];
|
|
861
|
+
const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
862
|
+
__name: "RegionShape",
|
|
863
|
+
props: {
|
|
864
|
+
region: {},
|
|
865
|
+
selected: { type: Boolean },
|
|
866
|
+
draft: { type: Boolean },
|
|
867
|
+
disabled: { type: Boolean }
|
|
868
|
+
},
|
|
869
|
+
emits: ["dragStart", "select", "keydown"],
|
|
870
|
+
setup(__props, { emit: __emit }) {
|
|
871
|
+
const emit = __emit;
|
|
872
|
+
return (_ctx, _cache) => {
|
|
873
|
+
return openBlock(), createElementBlock("div", {
|
|
874
|
+
class: normalizeClass(["chai-edit-card__region", { "chai-edit-card__region--selected": __props.selected, "chai-edit-card__region--draft": __props.draft }]),
|
|
875
|
+
style: normalizeStyle(unref(regionBoxStyle)(__props.region))
|
|
876
|
+
}, [
|
|
877
|
+
createElementVNode("button", {
|
|
878
|
+
type: "button",
|
|
879
|
+
class: "chai-edit-card__region-body",
|
|
880
|
+
"aria-label": `Region ${__props.region.number}${__props.region.prompt ? `: ${__props.region.prompt}` : ", no instruction yet"}. Arrow keys move it, Shift and arrow keys resize it.`,
|
|
881
|
+
"aria-pressed": __props.selected,
|
|
882
|
+
disabled: __props.disabled,
|
|
883
|
+
onPointerdown: _cache[0] || (_cache[0] = ($event) => emit("dragStart", $event, "move")),
|
|
884
|
+
onClick: _cache[1] || (_cache[1] = ($event) => emit("select")),
|
|
885
|
+
onKeydown: _cache[2] || (_cache[2] = ($event) => emit("keydown", $event))
|
|
886
|
+
}, null, 40, _hoisted_1$a),
|
|
887
|
+
createElementVNode("span", _hoisted_2$6, toDisplayString(__props.region.number), 1),
|
|
888
|
+
__props.selected ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(unref(REGION_CORNERS), (corner) => {
|
|
889
|
+
return openBlock(), createElementBlock("span", {
|
|
890
|
+
key: corner,
|
|
891
|
+
class: normalizeClass(`chai-edit-card__handle chai-edit-card__handle--${corner}`),
|
|
892
|
+
"aria-hidden": "true",
|
|
893
|
+
onPointerdown: ($event) => emit("dragStart", $event, corner)
|
|
894
|
+
}, null, 42, _hoisted_3$6);
|
|
895
|
+
}), 128)) : createCommentVNode("", true)
|
|
896
|
+
], 6);
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
const _hoisted_1$9 = ["src"];
|
|
901
|
+
const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
902
|
+
__name: "PageSlide",
|
|
903
|
+
props: {
|
|
904
|
+
slide: {},
|
|
905
|
+
pageClass: {}
|
|
906
|
+
},
|
|
907
|
+
emits: ["end"],
|
|
908
|
+
setup(__props, { emit: __emit }) {
|
|
909
|
+
const props = __props;
|
|
910
|
+
const emit = __emit;
|
|
911
|
+
const side = computed(() => props.slide?.forward ? "left" : "right");
|
|
912
|
+
const outgoing = computed(() => props.slide?.active ? props.slide.from : void 0);
|
|
913
|
+
return (_ctx, _cache) => {
|
|
914
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
915
|
+
outgoing.value ? (openBlock(), createElementBlock("img", {
|
|
916
|
+
key: `out-${__props.slide.key}`,
|
|
917
|
+
class: normalizeClass(`chai-slide-out chai-slide-out--${side.value}`),
|
|
918
|
+
src: outgoing.value,
|
|
919
|
+
alt: "",
|
|
920
|
+
"aria-hidden": "true",
|
|
921
|
+
draggable: "false"
|
|
922
|
+
}, null, 10, _hoisted_1$9)) : createCommentVNode("", true),
|
|
923
|
+
(openBlock(), createElementBlock("div", {
|
|
924
|
+
key: `in-${__props.slide?.key ?? 0}`,
|
|
925
|
+
class: normalizeClass([__props.pageClass, __props.slide?.active && `chai-slide-in chai-slide-in--${side.value}`, outgoing.value && "chai-slide-in--over"]),
|
|
926
|
+
onAnimationend: _cache[0] || (_cache[0] = withModifiers(($event) => emit("end"), ["self"]))
|
|
927
|
+
}, [
|
|
928
|
+
renderSlot(_ctx.$slots, "default")
|
|
929
|
+
], 34))
|
|
930
|
+
], 64);
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
function usePageSlide(page) {
|
|
935
|
+
const slide = ref(null);
|
|
936
|
+
let shown = page();
|
|
937
|
+
watch(page, (next) => {
|
|
938
|
+
const reduceMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
939
|
+
if (next.id !== shown.id && shown.id !== void 0 && next.id !== void 0 && !reduceMotion) {
|
|
940
|
+
slide.value = { from: shown.image, forward: next.index > shown.index, key: (slide.value?.key ?? 0) + 1, active: true };
|
|
941
|
+
}
|
|
942
|
+
shown = next;
|
|
943
|
+
});
|
|
944
|
+
const endSlide = () => {
|
|
945
|
+
if (slide.value) slide.value = { ...slide.value, active: false, from: void 0 };
|
|
946
|
+
};
|
|
947
|
+
return { slide, endSlide };
|
|
948
|
+
}
|
|
949
|
+
const _hoisted_1$8 = ["aria-label", "aria-valuemax", "aria-valuenow", "aria-valuetext", "aria-disabled", "tabindex"];
|
|
950
|
+
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
951
|
+
__name: "Pagination",
|
|
952
|
+
props: {
|
|
953
|
+
count: {},
|
|
954
|
+
index: {},
|
|
955
|
+
label: {},
|
|
956
|
+
itemLabel: { default: "Result" },
|
|
957
|
+
disabled: { type: Boolean }
|
|
958
|
+
},
|
|
959
|
+
emits: ["update:index"],
|
|
960
|
+
setup(__props, { emit: __emit }) {
|
|
961
|
+
const props = __props;
|
|
962
|
+
const emit = __emit;
|
|
963
|
+
function go(next) {
|
|
964
|
+
const clamped = Math.max(0, Math.min(props.count - 1, next));
|
|
965
|
+
if (clamped !== props.index) emit("update:index", clamped);
|
|
966
|
+
}
|
|
967
|
+
function onClick(e) {
|
|
968
|
+
if (props.disabled) return;
|
|
969
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
970
|
+
go(Math.floor((e.clientX - rect.left) / rect.width * props.count));
|
|
971
|
+
}
|
|
972
|
+
const KEY_STEPS = {
|
|
973
|
+
ArrowRight: (i) => i + 1,
|
|
974
|
+
ArrowUp: (i) => i + 1,
|
|
975
|
+
PageDown: (i) => i + 1,
|
|
976
|
+
ArrowLeft: (i) => i - 1,
|
|
977
|
+
ArrowDown: (i) => i - 1,
|
|
978
|
+
PageUp: (i) => i - 1,
|
|
979
|
+
Home: () => 0,
|
|
980
|
+
End: (_, count) => count - 1
|
|
981
|
+
};
|
|
982
|
+
function onKeydown(e) {
|
|
983
|
+
const step = KEY_STEPS[e.key];
|
|
984
|
+
if (props.disabled || !step) return;
|
|
985
|
+
e.preventDefault();
|
|
986
|
+
go(step(props.index, props.count));
|
|
987
|
+
}
|
|
988
|
+
return (_ctx, _cache) => {
|
|
989
|
+
return openBlock(), createElementBlock("div", {
|
|
990
|
+
class: normalizeClass(["chai-pagination", { "chai-pagination--disabled": __props.disabled }]),
|
|
991
|
+
role: "slider",
|
|
992
|
+
"aria-label": __props.label,
|
|
993
|
+
"aria-valuemin": 1,
|
|
994
|
+
"aria-valuemax": __props.count,
|
|
995
|
+
"aria-valuenow": __props.index + 1,
|
|
996
|
+
"aria-valuetext": `${__props.itemLabel} ${__props.index + 1} of ${__props.count}`,
|
|
997
|
+
"aria-disabled": __props.disabled || void 0,
|
|
998
|
+
tabindex: __props.disabled ? -1 : 0,
|
|
999
|
+
style: normalizeStyle({ "--chai-pagination-fill": `${(__props.index + 1) / __props.count * 100}%` }),
|
|
1000
|
+
onClick,
|
|
1001
|
+
onKeydown
|
|
1002
|
+
}, [
|
|
1003
|
+
_cache[0] || (_cache[0] = createElementVNode("span", {
|
|
1004
|
+
class: "chai-pagination__track",
|
|
1005
|
+
"aria-hidden": "true"
|
|
1006
|
+
}, null, -1)),
|
|
1007
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.count, (i) => {
|
|
1008
|
+
return openBlock(), createElementBlock("span", {
|
|
1009
|
+
key: i,
|
|
1010
|
+
class: normalizeClass(["chai-pagination__dot", { "chai-pagination__dot--filled": i - 1 <= __props.index }]),
|
|
1011
|
+
"aria-hidden": "true"
|
|
1012
|
+
}, null, 2);
|
|
1013
|
+
}), 128))
|
|
1014
|
+
], 46, _hoisted_1$8);
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
const _hoisted_1$7 = ["aria-label", "tabindex"];
|
|
1019
|
+
const _hoisted_2$5 = ["src", "alt"];
|
|
1020
|
+
const _hoisted_3$5 = {
|
|
1021
|
+
key: 1,
|
|
1022
|
+
class: "chai-edit-card__placeholder"
|
|
1023
|
+
};
|
|
1024
|
+
const _hoisted_4$4 = {
|
|
1025
|
+
key: 0,
|
|
1026
|
+
class: "chai-edit-card__status",
|
|
1027
|
+
role: "status"
|
|
1028
|
+
};
|
|
1029
|
+
const _hoisted_5$3 = {
|
|
1030
|
+
key: 0,
|
|
1031
|
+
class: "chai-edit-card__spinner",
|
|
1032
|
+
role: "img",
|
|
1033
|
+
"aria-label": "Editing"
|
|
1034
|
+
};
|
|
1035
|
+
const _hoisted_6$3 = {
|
|
1036
|
+
key: 1,
|
|
1037
|
+
class: "chai-edit-card__status-text"
|
|
1038
|
+
};
|
|
1039
|
+
const _hoisted_7$3 = ["disabled"];
|
|
1040
|
+
const _hoisted_8$3 = {
|
|
1041
|
+
class: "chai-edit-card__zoom-level",
|
|
1042
|
+
"aria-live": "polite"
|
|
1043
|
+
};
|
|
1044
|
+
const _hoisted_9$3 = ["disabled"];
|
|
1045
|
+
const _hoisted_10$3 = ["disabled"];
|
|
1046
|
+
const _hoisted_11$2 = ["aria-label", "title", "disabled"];
|
|
1047
|
+
const _hoisted_12$2 = ["disabled"];
|
|
1048
|
+
const _hoisted_13$2 = {
|
|
1049
|
+
key: 1,
|
|
1050
|
+
class: "chai-card-fade"
|
|
1051
|
+
};
|
|
1052
|
+
const _hoisted_14$2 = { class: "chai-card-actions" };
|
|
1053
|
+
const _hoisted_15$2 = { class: "chai-card-chips" };
|
|
1054
|
+
const _hoisted_16$1 = ["disabled", "title"];
|
|
1055
|
+
const _hoisted_17$1 = ["disabled"];
|
|
1056
|
+
const _hoisted_18$1 = ["aria-label", "title", "disabled"];
|
|
1057
|
+
const _hoisted_19 = ["aria-label"];
|
|
1058
|
+
const _hoisted_20 = { class: "chai-edit-card__popover-header" };
|
|
1059
|
+
const _hoisted_21 = { class: "chai-edit-card__popover-title" };
|
|
1060
|
+
const _hoisted_22 = ["disabled"];
|
|
1061
|
+
const _hoisted_23 = ["disabled"];
|
|
1062
|
+
const _hoisted_24 = ["aria-label", "disabled"];
|
|
1063
|
+
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
1064
|
+
__name: "EditCard",
|
|
1065
|
+
props: {
|
|
1066
|
+
versions: {},
|
|
1067
|
+
activeVersion: {},
|
|
1068
|
+
regions: {},
|
|
1069
|
+
maxRegions: { default: DEFAULT_MAX_REGIONS },
|
|
1070
|
+
width: {},
|
|
1071
|
+
scale: {},
|
|
1072
|
+
maxWidth: { default: 630 },
|
|
1073
|
+
maxHeight: { default: 630 },
|
|
1074
|
+
alt: { default: "Image being edited" },
|
|
1075
|
+
disabled: { type: Boolean }
|
|
1076
|
+
},
|
|
1077
|
+
emits: ["update:activeVersion", "update:regions", "action"],
|
|
1078
|
+
setup(__props, { emit: __emit }) {
|
|
1079
|
+
const props = __props;
|
|
1080
|
+
const emit = __emit;
|
|
1081
|
+
const index = computed(() => Math.min(Math.max(props.activeVersion, 0), Math.max(0, props.versions.length - 1)));
|
|
1082
|
+
const version = computed(() => props.versions[index.value]);
|
|
1083
|
+
const ready = computed(() => version.value?.status === "done" && Boolean(version.value.src));
|
|
1084
|
+
const paginated = computed(() => props.versions.length > 1);
|
|
1085
|
+
const hasImage = computed(() => Boolean(version.value?.src || version.value?.from));
|
|
1086
|
+
const draft = ref(null);
|
|
1087
|
+
const selectedId = ref(null);
|
|
1088
|
+
const text = ref("");
|
|
1089
|
+
const hidden = ref(false);
|
|
1090
|
+
const zoom = ref(1);
|
|
1091
|
+
const pan = ref({ x: 0, y: 0 });
|
|
1092
|
+
const size = ref({ width: 0, height: 0 });
|
|
1093
|
+
const natural = ref(null);
|
|
1094
|
+
const expanded = ref(false);
|
|
1095
|
+
const linkCopied = ref(false);
|
|
1096
|
+
let drag = null;
|
|
1097
|
+
const viewport = ref();
|
|
1098
|
+
const field = ref();
|
|
1099
|
+
const { slide, endSlide } = usePageSlide(() => ({
|
|
1100
|
+
id: version.value?.id,
|
|
1101
|
+
index: index.value,
|
|
1102
|
+
image: version.value?.src ?? version.value?.from
|
|
1103
|
+
}));
|
|
1104
|
+
watch(
|
|
1105
|
+
() => version.value?.id,
|
|
1106
|
+
() => {
|
|
1107
|
+
draft.value = null;
|
|
1108
|
+
selectedId.value = null;
|
|
1109
|
+
zoom.value = 1;
|
|
1110
|
+
pan.value = { x: 0, y: 0 };
|
|
1111
|
+
}
|
|
1112
|
+
);
|
|
1113
|
+
let observer;
|
|
1114
|
+
onMounted(() => {
|
|
1115
|
+
observer = new ResizeObserver(([entry]) => {
|
|
1116
|
+
if (entry) size.value = { width: entry.contentRect.width, height: entry.contentRect.height };
|
|
1117
|
+
});
|
|
1118
|
+
if (viewport.value) observer.observe(viewport.value);
|
|
1119
|
+
});
|
|
1120
|
+
onUnmounted(() => observer?.disconnect());
|
|
1121
|
+
const shownDraft = computed(() => {
|
|
1122
|
+
const d = draft.value;
|
|
1123
|
+
return d && props.regions.some((r) => r.number === d.number) ? { ...d, number: freeRegionNumber(props.regions) } : d;
|
|
1124
|
+
});
|
|
1125
|
+
const all = computed(() => shownDraft.value ? [...props.regions, shownDraft.value] : props.regions);
|
|
1126
|
+
const selected = computed(() => all.value.find((r) => r.id === selectedId.value) ?? null);
|
|
1127
|
+
const isDraft = computed(() => selected.value != null && selected.value.id === draft.value?.id);
|
|
1128
|
+
const canCheck = computed(
|
|
1129
|
+
() => selected.value != null && text.value.trim().length > 0 && (isDraft.value || text.value.trim() !== selected.value.prompt)
|
|
1130
|
+
);
|
|
1131
|
+
const atCap = computed(() => all.value.length >= props.maxRegions);
|
|
1132
|
+
const anyRegions = computed(() => all.value.length > 0 || (version.value?.regions.length ?? 0) > 0);
|
|
1133
|
+
const zoomIndex = computed(() => EDIT_ZOOM_STEPS.indexOf(zoom.value));
|
|
1134
|
+
const popover = computed(
|
|
1135
|
+
() => selected.value && !hidden.value && size.value.width ? regionPopoverPosition(selected.value.box, zoom.value, pan.value, size.value, paginated.value) : null
|
|
1136
|
+
);
|
|
1137
|
+
const cardWidth = computed(
|
|
1138
|
+
() => editCardWidth(natural.value, { width: props.width, scale: props.scale, maxWidth: props.maxWidth, maxHeight: props.maxHeight })
|
|
1139
|
+
);
|
|
1140
|
+
watch(selectedId, (id) => id && field.value?.focus(), { flush: "post" });
|
|
1141
|
+
watch(
|
|
1142
|
+
[text, selectedId],
|
|
1143
|
+
() => {
|
|
1144
|
+
const el = field.value;
|
|
1145
|
+
if (!el) return;
|
|
1146
|
+
el.style.height = "auto";
|
|
1147
|
+
el.style.height = `${el.scrollHeight}px`;
|
|
1148
|
+
},
|
|
1149
|
+
{ flush: "post" }
|
|
1150
|
+
);
|
|
1151
|
+
function select(region) {
|
|
1152
|
+
selectedId.value = region?.id ?? null;
|
|
1153
|
+
text.value = region?.prompt ?? "";
|
|
1154
|
+
}
|
|
1155
|
+
function setBox(id, box) {
|
|
1156
|
+
if (draft.value?.id === id) draft.value = { ...draft.value, box };
|
|
1157
|
+
else emit("update:regions", props.regions.map((r) => r.id === id ? { ...r, box } : r));
|
|
1158
|
+
}
|
|
1159
|
+
function removeRegion(region) {
|
|
1160
|
+
if (region.id === draft.value?.id) draft.value = null;
|
|
1161
|
+
else emit("update:regions", props.regions.filter((r) => r.id !== region.id));
|
|
1162
|
+
select(null);
|
|
1163
|
+
}
|
|
1164
|
+
function addRegion() {
|
|
1165
|
+
const region = newRegion(props.regions, zoom.value, pan.value, size.value);
|
|
1166
|
+
draft.value = region;
|
|
1167
|
+
hidden.value = false;
|
|
1168
|
+
select(region);
|
|
1169
|
+
}
|
|
1170
|
+
function check() {
|
|
1171
|
+
const region = selected.value;
|
|
1172
|
+
if (!region || !canCheck.value) return;
|
|
1173
|
+
const prompt = text.value.trim();
|
|
1174
|
+
if (isDraft.value) {
|
|
1175
|
+
emit("update:regions", [...props.regions, { ...region, prompt }]);
|
|
1176
|
+
draft.value = null;
|
|
1177
|
+
} else {
|
|
1178
|
+
emit("update:regions", props.regions.map((r) => r.id === region.id ? { ...r, prompt } : r));
|
|
1179
|
+
}
|
|
1180
|
+
select(null);
|
|
1181
|
+
}
|
|
1182
|
+
function clearAll() {
|
|
1183
|
+
draft.value = null;
|
|
1184
|
+
select(null);
|
|
1185
|
+
emit("update:regions", []);
|
|
1186
|
+
}
|
|
1187
|
+
function toggleHidden() {
|
|
1188
|
+
hidden.value = !hidden.value;
|
|
1189
|
+
select(null);
|
|
1190
|
+
}
|
|
1191
|
+
function zoomTo(next) {
|
|
1192
|
+
pan.value = panForZoom(pan.value, zoom.value, next, size.value);
|
|
1193
|
+
zoom.value = next;
|
|
1194
|
+
}
|
|
1195
|
+
function startRegionDrag(e, region, kind) {
|
|
1196
|
+
if (props.disabled || e.button !== 0) return;
|
|
1197
|
+
e.stopPropagation();
|
|
1198
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1199
|
+
drag = { kind, id: region.id, x: e.clientX, y: e.clientY, box: region.box, moved: false };
|
|
1200
|
+
if (region.id !== selectedId.value) select(region);
|
|
1201
|
+
}
|
|
1202
|
+
function startPan(e) {
|
|
1203
|
+
if (e.button !== 0) return;
|
|
1204
|
+
if (zoom.value > 1) e.currentTarget.setPointerCapture(e.pointerId);
|
|
1205
|
+
drag = { kind: "pan", x: e.clientX, y: e.clientY, pan: pan.value, moved: false };
|
|
1206
|
+
}
|
|
1207
|
+
function onPointerMove(e) {
|
|
1208
|
+
const d = drag;
|
|
1209
|
+
const { width, height } = size.value;
|
|
1210
|
+
if (!d || !width) return;
|
|
1211
|
+
const dxPx = e.clientX - d.x;
|
|
1212
|
+
const dyPx = e.clientY - d.y;
|
|
1213
|
+
if (Math.abs(dxPx) + Math.abs(dyPx) > 2) d.moved = true;
|
|
1214
|
+
if (d.kind === "pan") {
|
|
1215
|
+
if (zoom.value > 1) pan.value = clampPan({ x: d.pan.x + dxPx, y: d.pan.y + dyPx }, zoom.value, size.value);
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
const dx = dxPx / (width * zoom.value);
|
|
1219
|
+
const dy = dyPx / (height * zoom.value);
|
|
1220
|
+
setBox(d.id, d.kind === "move" ? fitBox({ ...d.box, x: d.box.x + dx, y: d.box.y + dy }) : resizeBox(d.box, d.kind, dx, dy));
|
|
1221
|
+
}
|
|
1222
|
+
function onPointerUp() {
|
|
1223
|
+
const d = drag;
|
|
1224
|
+
drag = null;
|
|
1225
|
+
if (d?.kind === "pan" && !d.moved) select(null);
|
|
1226
|
+
}
|
|
1227
|
+
function onRegionKey(e, region) {
|
|
1228
|
+
const box = regionBoxForKey(region.box, e.key, { shift: e.shiftKey, alt: e.altKey });
|
|
1229
|
+
if (box) {
|
|
1230
|
+
e.preventDefault();
|
|
1231
|
+
e.stopPropagation();
|
|
1232
|
+
setBox(region.id, box);
|
|
1233
|
+
} else if (e.key === "Delete" || e.key === "Backspace") {
|
|
1234
|
+
e.preventDefault();
|
|
1235
|
+
removeRegion(region);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
function onViewportKey(e) {
|
|
1239
|
+
if (e.target !== e.currentTarget || zoom.value <= 1) return;
|
|
1240
|
+
const next = panForKey(pan.value, e.key, zoom.value, size.value);
|
|
1241
|
+
if (!next) return;
|
|
1242
|
+
e.preventDefault();
|
|
1243
|
+
pan.value = next;
|
|
1244
|
+
}
|
|
1245
|
+
function onFieldKey(e) {
|
|
1246
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
1247
|
+
e.preventDefault();
|
|
1248
|
+
check();
|
|
1249
|
+
} else if (e.key === "Escape") {
|
|
1250
|
+
e.preventDefault();
|
|
1251
|
+
if (isDraft.value) draft.value = null;
|
|
1252
|
+
select(null);
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
async function download() {
|
|
1256
|
+
const v = version.value;
|
|
1257
|
+
if (!v?.src) return;
|
|
1258
|
+
await downloadMedia(v.src, downloadFilename(v.id, "image", v.src));
|
|
1259
|
+
emit("action", "download", v);
|
|
1260
|
+
}
|
|
1261
|
+
async function share() {
|
|
1262
|
+
const v = version.value;
|
|
1263
|
+
if (!v?.src) return;
|
|
1264
|
+
if (await shareMedia(v.src) === "copied") {
|
|
1265
|
+
linkCopied.value = true;
|
|
1266
|
+
setTimeout(() => linkCopied.value = false, 1500);
|
|
1267
|
+
}
|
|
1268
|
+
emit("action", "share", v);
|
|
1269
|
+
}
|
|
1270
|
+
function onImageLoad(e) {
|
|
1271
|
+
const img = e.currentTarget;
|
|
1272
|
+
natural.value = { width: img.naturalWidth, height: img.naturalHeight };
|
|
1273
|
+
}
|
|
1274
|
+
return (_ctx, _cache) => {
|
|
1275
|
+
return version.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
1276
|
+
createElementVNode("div", {
|
|
1277
|
+
class: "chai-edit-card",
|
|
1278
|
+
style: normalizeStyle({ "--chai-edit-card-width": `${cardWidth.value}px` })
|
|
1279
|
+
}, [
|
|
1280
|
+
createElementVNode("div", {
|
|
1281
|
+
ref_key: "viewport",
|
|
1282
|
+
ref: viewport,
|
|
1283
|
+
class: normalizeClass(["chai-edit-card__viewport", { "chai-edit-card__viewport--zoomed": zoom.value > 1 }]),
|
|
1284
|
+
role: "group",
|
|
1285
|
+
"aria-label": zoom.value > 1 ? `Image, zoomed to ${Math.round(zoom.value * 100)}%. Arrow keys move around.` : "Image",
|
|
1286
|
+
tabindex: zoom.value > 1 ? 0 : void 0,
|
|
1287
|
+
onPointerdown: startPan,
|
|
1288
|
+
onPointermove: onPointerMove,
|
|
1289
|
+
onPointerup: onPointerUp,
|
|
1290
|
+
onPointercancel: onPointerUp,
|
|
1291
|
+
onKeydown: onViewportKey
|
|
1292
|
+
}, [
|
|
1293
|
+
createVNode(_sfc_main$9, {
|
|
1294
|
+
slide: unref(slide),
|
|
1295
|
+
onEnd: unref(endSlide)
|
|
1296
|
+
}, {
|
|
1297
|
+
default: withCtx(() => [
|
|
1298
|
+
createElementVNode("div", {
|
|
1299
|
+
class: "chai-edit-card__layer",
|
|
1300
|
+
style: normalizeStyle({ transform: `translate(${pan.value.x}px, ${pan.value.y}px) scale(${zoom.value})`, "--chai-edit-zoom": zoom.value })
|
|
1301
|
+
}, [
|
|
1302
|
+
version.value.src || version.value.from ? (openBlock(), createElementBlock("img", {
|
|
1303
|
+
key: 0,
|
|
1304
|
+
class: "chai-edit-card__image",
|
|
1305
|
+
src: version.value.src ?? version.value.from,
|
|
1306
|
+
alt: __props.alt,
|
|
1307
|
+
draggable: "false",
|
|
1308
|
+
onLoad: onImageLoad
|
|
1309
|
+
}, null, 40, _hoisted_2$5)) : (openBlock(), createElementBlock("div", _hoisted_3$5)),
|
|
1310
|
+
!hidden.value ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
1311
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(version.value.regions, (r) => {
|
|
1312
|
+
return openBlock(), createElementBlock("span", {
|
|
1313
|
+
key: `applied-${r.id}`,
|
|
1314
|
+
class: "chai-edit-card__region chai-edit-card__region--applied",
|
|
1315
|
+
style: normalizeStyle(unref(regionBoxStyle)(r)),
|
|
1316
|
+
"aria-hidden": "true"
|
|
1317
|
+
}, null, 4);
|
|
1318
|
+
}), 128)),
|
|
1319
|
+
ready.value ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(all.value, (r) => {
|
|
1320
|
+
return openBlock(), createBlock(_sfc_main$a, {
|
|
1321
|
+
key: r.id,
|
|
1322
|
+
region: r,
|
|
1323
|
+
selected: r.id === selectedId.value,
|
|
1324
|
+
draft: r.id === draft.value?.id,
|
|
1325
|
+
disabled: __props.disabled,
|
|
1326
|
+
onDragStart: (e, kind) => startRegionDrag(e, r, kind),
|
|
1327
|
+
onSelect: ($event) => select(r),
|
|
1328
|
+
onKeydown: ($event) => onRegionKey($event, r)
|
|
1329
|
+
}, null, 8, ["region", "selected", "draft", "disabled", "onDragStart", "onSelect", "onKeydown"]);
|
|
1330
|
+
}), 128)) : createCommentVNode("", true)
|
|
1331
|
+
], 64)) : createCommentVNode("", true)
|
|
1332
|
+
], 4)
|
|
1333
|
+
]),
|
|
1334
|
+
_: 1
|
|
1335
|
+
}, 8, ["slide", "onEnd"]),
|
|
1336
|
+
version.value.status !== "done" ? (openBlock(), createElementBlock("div", _hoisted_4$4, [
|
|
1337
|
+
version.value.status === "queued" || version.value.status === "running" ? (openBlock(), createElementBlock("span", _hoisted_5$3)) : (openBlock(), createElementBlock("p", _hoisted_6$3, toDisplayString(version.value.status === "cancelled" ? "Stopped" : version.value.error ?? "Something went wrong."), 1))
|
|
1338
|
+
])) : createCommentVNode("", true),
|
|
1339
|
+
createElementVNode("div", {
|
|
1340
|
+
class: "chai-card-top chai-card-top--start",
|
|
1341
|
+
onPointerdown: _cache[2] || (_cache[2] = withModifiers(() => {
|
|
1342
|
+
}, ["stop"]))
|
|
1343
|
+
}, [
|
|
1344
|
+
createElementVNode("button", {
|
|
1345
|
+
type: "button",
|
|
1346
|
+
class: "chai-card-top-btn",
|
|
1347
|
+
"aria-label": "Zoom in",
|
|
1348
|
+
title: "Zoom in",
|
|
1349
|
+
disabled: !ready.value || zoomIndex.value >= unref(EDIT_ZOOM_STEPS).length - 1,
|
|
1350
|
+
onClick: _cache[0] || (_cache[0] = ($event) => zoomTo(unref(EDIT_ZOOM_STEPS)[zoomIndex.value + 1]))
|
|
1351
|
+
}, [
|
|
1352
|
+
createVNode(unref(ZoomInIcon))
|
|
1353
|
+
], 8, _hoisted_7$3),
|
|
1354
|
+
createElementVNode("span", _hoisted_8$3, toDisplayString(Math.round(zoom.value * 100)) + "%", 1),
|
|
1355
|
+
createElementVNode("button", {
|
|
1356
|
+
type: "button",
|
|
1357
|
+
class: "chai-card-top-btn",
|
|
1358
|
+
"aria-label": "Zoom out",
|
|
1359
|
+
title: "Zoom out",
|
|
1360
|
+
disabled: !ready.value || zoomIndex.value <= 0,
|
|
1361
|
+
onClick: _cache[1] || (_cache[1] = ($event) => zoomTo(unref(EDIT_ZOOM_STEPS)[zoomIndex.value - 1]))
|
|
1362
|
+
}, [
|
|
1363
|
+
createVNode(unref(ZoomOutIcon))
|
|
1364
|
+
], 8, _hoisted_9$3)
|
|
1365
|
+
], 32),
|
|
1366
|
+
createElementVNode("div", {
|
|
1367
|
+
class: "chai-card-top chai-card-top--end",
|
|
1368
|
+
onPointerdown: _cache[4] || (_cache[4] = withModifiers(() => {
|
|
1369
|
+
}, ["stop"]))
|
|
1370
|
+
}, [
|
|
1371
|
+
createElementVNode("button", {
|
|
1372
|
+
type: "button",
|
|
1373
|
+
class: "chai-card-top-btn",
|
|
1374
|
+
"aria-label": "Download",
|
|
1375
|
+
title: "Download",
|
|
1376
|
+
disabled: __props.disabled || !ready.value,
|
|
1377
|
+
onClick: download
|
|
1378
|
+
}, [
|
|
1379
|
+
createVNode(unref(DownloadIcon))
|
|
1380
|
+
], 8, _hoisted_10$3),
|
|
1381
|
+
createElementVNode("button", {
|
|
1382
|
+
type: "button",
|
|
1383
|
+
class: "chai-card-top-btn",
|
|
1384
|
+
"aria-label": linkCopied.value ? "Link copied" : "Share",
|
|
1385
|
+
title: linkCopied.value ? "Link copied" : "Share",
|
|
1386
|
+
disabled: __props.disabled || !ready.value,
|
|
1387
|
+
onClick: share
|
|
1388
|
+
}, [
|
|
1389
|
+
linkCopied.value ? (openBlock(), createBlock(unref(CheckSymbolIcon), { key: 0 })) : (openBlock(), createBlock(unref(ShareIcon), { key: 1 }))
|
|
1390
|
+
], 8, _hoisted_11$2),
|
|
1391
|
+
createElementVNode("button", {
|
|
1392
|
+
type: "button",
|
|
1393
|
+
class: "chai-card-top-btn",
|
|
1394
|
+
"aria-label": "Expand",
|
|
1395
|
+
title: "Expand",
|
|
1396
|
+
disabled: !ready.value,
|
|
1397
|
+
onClick: _cache[3] || (_cache[3] = ($event) => expanded.value = true)
|
|
1398
|
+
}, [
|
|
1399
|
+
createVNode(unref(ExpandIcon))
|
|
1400
|
+
], 8, _hoisted_12$2)
|
|
1401
|
+
], 32),
|
|
1402
|
+
paginated.value && hasImage.value ? (openBlock(), createElementBlock("div", _hoisted_13$2)) : createCommentVNode("", true),
|
|
1403
|
+
createElementVNode("div", {
|
|
1404
|
+
class: "chai-card-bottom",
|
|
1405
|
+
onPointerdown: _cache[5] || (_cache[5] = withModifiers(() => {
|
|
1406
|
+
}, ["stop"]))
|
|
1407
|
+
}, [
|
|
1408
|
+
createElementVNode("div", _hoisted_14$2, [
|
|
1409
|
+
createElementVNode("div", _hoisted_15$2, [
|
|
1410
|
+
createElementVNode("button", {
|
|
1411
|
+
type: "button",
|
|
1412
|
+
class: "chai-card-chip",
|
|
1413
|
+
disabled: __props.disabled || !ready.value || atCap.value,
|
|
1414
|
+
title: atCap.value ? `This model takes up to ${__props.maxRegions} regions` : void 0,
|
|
1415
|
+
onClick: addRegion
|
|
1416
|
+
}, [
|
|
1417
|
+
createVNode(unref(AddIcon)),
|
|
1418
|
+
_cache[11] || (_cache[11] = createTextVNode("New region ", -1))
|
|
1419
|
+
], 8, _hoisted_16$1),
|
|
1420
|
+
createElementVNode("button", {
|
|
1421
|
+
type: "button",
|
|
1422
|
+
class: "chai-card-chip",
|
|
1423
|
+
disabled: __props.disabled || all.value.length === 0,
|
|
1424
|
+
onClick: clearAll
|
|
1425
|
+
}, [
|
|
1426
|
+
createVNode(unref(CloseSymbolIcon)),
|
|
1427
|
+
_cache[12] || (_cache[12] = createTextVNode("Clear regions ", -1))
|
|
1428
|
+
], 8, _hoisted_17$1)
|
|
1429
|
+
]),
|
|
1430
|
+
createElementVNode("button", {
|
|
1431
|
+
type: "button",
|
|
1432
|
+
class: "chai-card-round",
|
|
1433
|
+
"aria-label": hidden.value ? "Show regions" : "Hide regions",
|
|
1434
|
+
title: hidden.value ? "Show regions" : "Hide regions",
|
|
1435
|
+
disabled: !anyRegions.value,
|
|
1436
|
+
onClick: toggleHidden
|
|
1437
|
+
}, [
|
|
1438
|
+
hidden.value ? (openBlock(), createBlock(unref(VisibilityOffIcon), { key: 0 })) : (openBlock(), createBlock(unref(VisibilityIcon), { key: 1 }))
|
|
1439
|
+
], 8, _hoisted_18$1)
|
|
1440
|
+
])
|
|
1441
|
+
], 32),
|
|
1442
|
+
popover.value && selected.value ? (openBlock(), createElementBlock("div", {
|
|
1443
|
+
key: 2,
|
|
1444
|
+
class: normalizeClass(["chai-edit-card__popover", { "chai-edit-card__popover--above": popover.value.above }]),
|
|
1445
|
+
style: normalizeStyle({ left: `${popover.value.left}px`, top: `${popover.value.top}px` }),
|
|
1446
|
+
role: "dialog",
|
|
1447
|
+
"aria-label": `Region ${selected.value.number}`,
|
|
1448
|
+
onPointerdown: _cache[8] || (_cache[8] = withModifiers(() => {
|
|
1449
|
+
}, ["stop"]))
|
|
1450
|
+
}, [
|
|
1451
|
+
createElementVNode("div", _hoisted_20, [
|
|
1452
|
+
createElementVNode("span", _hoisted_21, "Region " + toDisplayString(selected.value.number), 1),
|
|
1453
|
+
createElementVNode("button", {
|
|
1454
|
+
type: "button",
|
|
1455
|
+
class: "chai-card-top-btn",
|
|
1456
|
+
"aria-label": "Add region to prompt",
|
|
1457
|
+
title: "Add region to prompt",
|
|
1458
|
+
disabled: __props.disabled || !canCheck.value,
|
|
1459
|
+
onClick: check
|
|
1460
|
+
}, [
|
|
1461
|
+
createVNode(unref(CheckSymbolIcon))
|
|
1462
|
+
], 8, _hoisted_22),
|
|
1463
|
+
createElementVNode("button", {
|
|
1464
|
+
type: "button",
|
|
1465
|
+
class: "chai-card-top-btn",
|
|
1466
|
+
"aria-label": "Delete region",
|
|
1467
|
+
title: "Delete region",
|
|
1468
|
+
disabled: __props.disabled,
|
|
1469
|
+
onClick: _cache[6] || (_cache[6] = ($event) => removeRegion(selected.value))
|
|
1470
|
+
}, [
|
|
1471
|
+
createVNode(unref(DeleteIcon))
|
|
1472
|
+
], 8, _hoisted_23)
|
|
1473
|
+
]),
|
|
1474
|
+
withDirectives(createElementVNode("textarea", {
|
|
1475
|
+
ref_key: "field",
|
|
1476
|
+
ref: field,
|
|
1477
|
+
"onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => text.value = $event),
|
|
1478
|
+
class: "chai-edit-card__field",
|
|
1479
|
+
rows: "1",
|
|
1480
|
+
placeholder: "What should change here?",
|
|
1481
|
+
"aria-label": `Instruction for region ${selected.value.number}`,
|
|
1482
|
+
disabled: __props.disabled,
|
|
1483
|
+
onKeydown: onFieldKey
|
|
1484
|
+
}, null, 40, _hoisted_24), [
|
|
1485
|
+
[vModelText, text.value]
|
|
1486
|
+
])
|
|
1487
|
+
], 46, _hoisted_19)) : createCommentVNode("", true)
|
|
1488
|
+
], 42, _hoisted_1$7),
|
|
1489
|
+
paginated.value ? (openBlock(), createElementBlock("div", {
|
|
1490
|
+
key: 0,
|
|
1491
|
+
class: normalizeClass(["chai-card-pager-bar", { "chai-card-pager-bar--over-media": hasImage.value }])
|
|
1492
|
+
}, [
|
|
1493
|
+
createVNode(_sfc_main$8, {
|
|
1494
|
+
count: __props.versions.length,
|
|
1495
|
+
index: index.value,
|
|
1496
|
+
label: "Versions",
|
|
1497
|
+
"item-label": "Version",
|
|
1498
|
+
disabled: __props.disabled,
|
|
1499
|
+
"onUpdate:index": _cache[9] || (_cache[9] = ($event) => emit("update:activeVersion", $event))
|
|
1500
|
+
}, null, 8, ["count", "index", "disabled"])
|
|
1501
|
+
], 2)) : createCommentVNode("", true)
|
|
1502
|
+
], 4),
|
|
1503
|
+
expanded.value && version.value.src ? (openBlock(), createBlock(_sfc_main$b, {
|
|
1504
|
+
key: 0,
|
|
1505
|
+
src: version.value.src,
|
|
1506
|
+
alt: __props.alt,
|
|
1507
|
+
onClose: _cache[10] || (_cache[10] = ($event) => expanded.value = false)
|
|
1508
|
+
}, null, 8, ["src", "alt"])) : createCommentVNode("", true)
|
|
1509
|
+
], 64)) : createCommentVNode("", true);
|
|
1510
|
+
};
|
|
1511
|
+
}
|
|
1512
|
+
});
|
|
1513
|
+
const _hoisted_1$6 = ["aria-label", "aria-pressed", "title", "disabled"];
|
|
1514
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
1515
|
+
__name: "IconButton",
|
|
1516
|
+
props: {
|
|
1517
|
+
variant: {},
|
|
1518
|
+
label: {},
|
|
1519
|
+
active: { type: Boolean },
|
|
1520
|
+
disabled: { type: Boolean }
|
|
1521
|
+
},
|
|
1522
|
+
setup(__props) {
|
|
1523
|
+
const CLASS = { top: "chai-card-top-btn", pill: "chai-card-pill-btn", round: "chai-card-round" };
|
|
1524
|
+
return (_ctx, _cache) => {
|
|
1525
|
+
return openBlock(), createElementBlock("button", {
|
|
1526
|
+
type: "button",
|
|
1527
|
+
class: normalizeClass([CLASS[__props.variant], { "chai-card-pill-btn--active": __props.active }]),
|
|
1528
|
+
"aria-label": __props.label,
|
|
1529
|
+
"aria-pressed": __props.active,
|
|
1530
|
+
title: __props.label,
|
|
1531
|
+
disabled: __props.disabled
|
|
1532
|
+
}, [
|
|
1533
|
+
renderSlot(_ctx.$slots, "default")
|
|
1534
|
+
], 10, _hoisted_1$6);
|
|
1535
|
+
};
|
|
1536
|
+
}
|
|
1537
|
+
});
|
|
1538
|
+
const _hoisted_1$5 = {
|
|
1539
|
+
key: 0,
|
|
1540
|
+
class: "chai-result-card__more-menu",
|
|
1541
|
+
role: "menu"
|
|
1542
|
+
};
|
|
1543
|
+
const _hoisted_2$4 = ["onClick"];
|
|
1544
|
+
const _hoisted_3$4 = {
|
|
1545
|
+
key: 0,
|
|
1546
|
+
class: "chai-result-card__more-menu-icon"
|
|
1547
|
+
};
|
|
1548
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
1549
|
+
__name: "MoreMenu",
|
|
1550
|
+
props: {
|
|
1551
|
+
actions: {},
|
|
1552
|
+
disabled: { type: Boolean }
|
|
1553
|
+
},
|
|
1554
|
+
emits: ["select"],
|
|
1555
|
+
setup(__props, { emit: __emit }) {
|
|
1556
|
+
const emit = __emit;
|
|
1557
|
+
const open = ref(false);
|
|
1558
|
+
const root = ref();
|
|
1559
|
+
useDismiss(root, open, () => open.value = false);
|
|
1560
|
+
function pick(action) {
|
|
1561
|
+
open.value = false;
|
|
1562
|
+
emit("select", action);
|
|
1563
|
+
}
|
|
1564
|
+
return (_ctx, _cache) => {
|
|
1565
|
+
return openBlock(), createElementBlock("div", {
|
|
1566
|
+
ref_key: "root",
|
|
1567
|
+
ref: root,
|
|
1568
|
+
class: "chai-result-card__more"
|
|
1569
|
+
}, [
|
|
1570
|
+
createVNode(_sfc_main$6, {
|
|
1571
|
+
variant: "pill",
|
|
1572
|
+
label: "More",
|
|
1573
|
+
active: open.value,
|
|
1574
|
+
disabled: __props.disabled,
|
|
1575
|
+
onClick: _cache[0] || (_cache[0] = ($event) => open.value = !open.value)
|
|
1576
|
+
}, {
|
|
1577
|
+
default: withCtx(() => [
|
|
1578
|
+
createVNode(unref(MoreHorizIcon))
|
|
1579
|
+
]),
|
|
1580
|
+
_: 1
|
|
1581
|
+
}, 8, ["active", "disabled"]),
|
|
1582
|
+
open.value ? (openBlock(), createElementBlock("ul", _hoisted_1$5, [
|
|
1583
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.actions, (action) => {
|
|
1584
|
+
return openBlock(), createElementBlock("li", {
|
|
1585
|
+
key: action.id,
|
|
1586
|
+
role: "none"
|
|
1587
|
+
}, [
|
|
1588
|
+
createElementVNode("button", {
|
|
1589
|
+
type: "button",
|
|
1590
|
+
role: "menuitem",
|
|
1591
|
+
class: "chai-result-card__more-menu-item",
|
|
1592
|
+
onClick: ($event) => pick(action)
|
|
1593
|
+
}, [
|
|
1594
|
+
action.icon ? (openBlock(), createElementBlock("span", _hoisted_3$4, [
|
|
1595
|
+
(openBlock(), createBlock(resolveDynamicComponent(action.icon)))
|
|
1596
|
+
])) : createCommentVNode("", true),
|
|
1597
|
+
createTextVNode(toDisplayString(action.label), 1)
|
|
1598
|
+
], 8, _hoisted_2$4)
|
|
1599
|
+
]);
|
|
1600
|
+
}), 128))
|
|
1601
|
+
])) : createCommentVNode("", true)
|
|
1602
|
+
], 512);
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
});
|
|
1606
|
+
const _hoisted_1$4 = ["aria-busy"];
|
|
1607
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
1608
|
+
__name: "ResultText",
|
|
1609
|
+
props: {
|
|
1610
|
+
text: {},
|
|
1611
|
+
streaming: { type: Boolean }
|
|
1612
|
+
},
|
|
1613
|
+
setup(__props) {
|
|
1614
|
+
const props = __props;
|
|
1615
|
+
const el = ref();
|
|
1616
|
+
let follow = true;
|
|
1617
|
+
function followNewest() {
|
|
1618
|
+
if (el.value && props.streaming && follow) el.value.scrollTop = el.value.scrollHeight;
|
|
1619
|
+
}
|
|
1620
|
+
onMounted(() => requestAnimationFrame(followNewest));
|
|
1621
|
+
watch(() => [props.text, props.streaming], followNewest, { flush: "post" });
|
|
1622
|
+
function onScroll(e) {
|
|
1623
|
+
const p = e.currentTarget;
|
|
1624
|
+
follow = p.scrollTop + p.clientHeight >= p.scrollHeight - 24;
|
|
1625
|
+
}
|
|
1626
|
+
return (_ctx, _cache) => {
|
|
1627
|
+
return openBlock(), createElementBlock("p", {
|
|
1628
|
+
ref_key: "el",
|
|
1629
|
+
ref: el,
|
|
1630
|
+
class: normalizeClass(["chai-result-card__text-output", { "chai-result-card__text-output--streaming": __props.streaming }]),
|
|
1631
|
+
"aria-busy": __props.streaming,
|
|
1632
|
+
tabindex: "0",
|
|
1633
|
+
onScroll
|
|
1634
|
+
}, toDisplayString(__props.text), 43, _hoisted_1$4);
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
});
|
|
1638
|
+
const _hoisted_1$3 = ["src"];
|
|
1639
|
+
const _hoisted_2$3 = ["aria-label"];
|
|
1640
|
+
const _hoisted_3$3 = {
|
|
1641
|
+
key: 0,
|
|
1642
|
+
class: "chai-result-card__play"
|
|
1643
|
+
};
|
|
1644
|
+
const _hoisted_4$3 = ["aria-valuenow", "aria-valuetext"];
|
|
1645
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
1646
|
+
__name: "VideoPlayer",
|
|
1647
|
+
props: {
|
|
1648
|
+
src: {},
|
|
1649
|
+
expanded: { type: Boolean },
|
|
1650
|
+
time: {},
|
|
1651
|
+
wasPlaying: { type: Boolean }
|
|
1652
|
+
},
|
|
1653
|
+
emits: ["playingChange", "dimensions"],
|
|
1654
|
+
setup(__props, { emit: __emit }) {
|
|
1655
|
+
const props = __props;
|
|
1656
|
+
const emit = __emit;
|
|
1657
|
+
const video = ref();
|
|
1658
|
+
const playing = ref(props.wasPlaying);
|
|
1659
|
+
const progress = ref(0);
|
|
1660
|
+
function togglePlay() {
|
|
1661
|
+
const el = video.value;
|
|
1662
|
+
if (el.paused) el.play();
|
|
1663
|
+
else el.pause();
|
|
1664
|
+
}
|
|
1665
|
+
function onLoadedMetadata() {
|
|
1666
|
+
const el = video.value;
|
|
1667
|
+
el.currentTime = props.time.current;
|
|
1668
|
+
if (props.wasPlaying) el.play().catch(() => {
|
|
1669
|
+
});
|
|
1670
|
+
emit("dimensions", el.videoWidth, el.videoHeight);
|
|
1671
|
+
}
|
|
1672
|
+
function setPlaying(value) {
|
|
1673
|
+
playing.value = value;
|
|
1674
|
+
emit("playingChange", value);
|
|
1675
|
+
}
|
|
1676
|
+
function onTimeUpdate() {
|
|
1677
|
+
const el = video.value;
|
|
1678
|
+
props.time.current = el.currentTime;
|
|
1679
|
+
if (el.duration) progress.value = el.currentTime / el.duration;
|
|
1680
|
+
}
|
|
1681
|
+
function scrub(e) {
|
|
1682
|
+
const el = video.value;
|
|
1683
|
+
if (!el.duration) return;
|
|
1684
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
1685
|
+
el.currentTime = Math.min(1, Math.max(0, (e.clientX - rect.left) / rect.width)) * el.duration;
|
|
1686
|
+
}
|
|
1687
|
+
const STEPS = { ArrowRight: 5, ArrowUp: 5, ArrowLeft: -5, ArrowDown: -5 };
|
|
1688
|
+
function onScrubKey(e) {
|
|
1689
|
+
const el = video.value;
|
|
1690
|
+
if (!el.duration) return;
|
|
1691
|
+
const step = STEPS[e.key];
|
|
1692
|
+
if (step != null) el.currentTime = Math.min(el.duration, Math.max(0, el.currentTime + step));
|
|
1693
|
+
else if (e.key === "Home") el.currentTime = 0;
|
|
1694
|
+
else if (e.key === "End") el.currentTime = el.duration;
|
|
1695
|
+
else return;
|
|
1696
|
+
e.preventDefault();
|
|
1697
|
+
}
|
|
1698
|
+
return (_ctx, _cache) => {
|
|
1699
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
1700
|
+
createElementVNode("video", {
|
|
1701
|
+
ref_key: "video",
|
|
1702
|
+
ref: video,
|
|
1703
|
+
class: "chai-result-card__video",
|
|
1704
|
+
src: __props.src,
|
|
1705
|
+
onLoadedmetadata: onLoadedMetadata,
|
|
1706
|
+
onPlay: _cache[0] || (_cache[0] = ($event) => setPlaying(true)),
|
|
1707
|
+
onPause: _cache[1] || (_cache[1] = ($event) => setPlaying(false)),
|
|
1708
|
+
onTimeupdate: onTimeUpdate
|
|
1709
|
+
}, null, 40, _hoisted_1$3),
|
|
1710
|
+
createElementVNode("button", {
|
|
1711
|
+
type: "button",
|
|
1712
|
+
class: "chai-result-card__video-toggle",
|
|
1713
|
+
"aria-label": playing.value ? "Pause" : "Play",
|
|
1714
|
+
onClick: togglePlay
|
|
1715
|
+
}, [
|
|
1716
|
+
!playing.value ? (openBlock(), createElementBlock("span", _hoisted_3$3, [
|
|
1717
|
+
createVNode(unref(PlayIcon))
|
|
1718
|
+
])) : createCommentVNode("", true)
|
|
1719
|
+
], 8, _hoisted_2$3),
|
|
1720
|
+
createElementVNode("div", {
|
|
1721
|
+
class: normalizeClass(["chai-result-card__scrubber", { "chai-result-card__scrubber--expanded": __props.expanded }]),
|
|
1722
|
+
role: "slider",
|
|
1723
|
+
tabindex: "0",
|
|
1724
|
+
"aria-label": "Seek",
|
|
1725
|
+
"aria-valuemin": 0,
|
|
1726
|
+
"aria-valuemax": 100,
|
|
1727
|
+
"aria-valuenow": Math.round(progress.value * 100),
|
|
1728
|
+
"aria-valuetext": `${Math.round(progress.value * 100)}%`,
|
|
1729
|
+
onClick: scrub,
|
|
1730
|
+
onKeydown: onScrubKey
|
|
1731
|
+
}, [
|
|
1732
|
+
createElementVNode("div", {
|
|
1733
|
+
class: "chai-result-card__scrubber-fill",
|
|
1734
|
+
style: normalizeStyle({ width: `${progress.value * 100}%` })
|
|
1735
|
+
}, null, 4)
|
|
1736
|
+
], 42, _hoisted_4$3)
|
|
1737
|
+
], 64);
|
|
1738
|
+
};
|
|
1739
|
+
}
|
|
1740
|
+
});
|
|
1741
|
+
const _hoisted_1$2 = {
|
|
1742
|
+
key: 0,
|
|
1743
|
+
class: "chai-result-card__media chai-result-card__media--pending"
|
|
1744
|
+
};
|
|
1745
|
+
const _hoisted_2$2 = ["aria-label"];
|
|
1746
|
+
const _hoisted_3$2 = {
|
|
1747
|
+
key: 1,
|
|
1748
|
+
class: "chai-result-card__media chai-result-card__media--cancelled"
|
|
1749
|
+
};
|
|
1750
|
+
const _hoisted_4$2 = {
|
|
1751
|
+
key: 2,
|
|
1752
|
+
class: "chai-result-card__media chai-result-card__media--error"
|
|
1753
|
+
};
|
|
1754
|
+
const _hoisted_5$2 = { class: "chai-result-card__error-text" };
|
|
1755
|
+
const _hoisted_6$2 = {
|
|
1756
|
+
key: 3,
|
|
1757
|
+
class: "chai-result-card__media"
|
|
1758
|
+
};
|
|
1759
|
+
const _hoisted_7$2 = ["src"];
|
|
1760
|
+
const _hoisted_8$2 = ["src"];
|
|
1761
|
+
const _hoisted_9$2 = ["src", "alt"];
|
|
1762
|
+
const _hoisted_10$2 = {
|
|
1763
|
+
key: 4,
|
|
1764
|
+
class: "chai-card-top chai-card-top--end"
|
|
1765
|
+
};
|
|
1766
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
1767
|
+
__name: "ResultMedia",
|
|
1768
|
+
props: {
|
|
1769
|
+
result: {},
|
|
1770
|
+
alt: {},
|
|
1771
|
+
disabled: { type: Boolean },
|
|
1772
|
+
mediaExpanded: { type: Boolean },
|
|
1773
|
+
linkCopied: { type: Boolean },
|
|
1774
|
+
videoTime: {},
|
|
1775
|
+
videoWasPlaying: { type: Boolean }
|
|
1776
|
+
},
|
|
1777
|
+
emits: ["download", "share", "expand", "dimensions", "videoPlayingChange"],
|
|
1778
|
+
setup(__props, { emit: __emit }) {
|
|
1779
|
+
const props = __props;
|
|
1780
|
+
const emit = __emit;
|
|
1781
|
+
const kind = computed(() => props.result.output?.kind);
|
|
1782
|
+
const streaming = computed(() => props.result.status === "running" && kind.value === "text");
|
|
1783
|
+
const pending = computed(() => (props.result.status === "queued" || props.result.status === "running") && !streaming.value);
|
|
1784
|
+
function onImageLoad(e) {
|
|
1785
|
+
const img = e.currentTarget;
|
|
1786
|
+
emit("dimensions", img.naturalWidth, img.naturalHeight);
|
|
1787
|
+
}
|
|
1788
|
+
return (_ctx, _cache) => {
|
|
1789
|
+
return pending.value ? (openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
1790
|
+
createElementVNode("span", {
|
|
1791
|
+
class: "chai-result-card__spinner",
|
|
1792
|
+
role: "img",
|
|
1793
|
+
"aria-label": __props.result.status === "running" ? "Running" : "Queued"
|
|
1794
|
+
}, null, 8, _hoisted_2$2)
|
|
1795
|
+
])) : __props.result.status === "cancelled" && !__props.result.output ? (openBlock(), createElementBlock("div", _hoisted_3$2, [..._cache[5] || (_cache[5] = [
|
|
1796
|
+
createElementVNode("p", { class: "chai-result-card__cancelled-text" }, "Stopped", -1)
|
|
1797
|
+
])])) : __props.result.status === "error" ? (openBlock(), createElementBlock("div", _hoisted_4$2, [
|
|
1798
|
+
createElementVNode("p", _hoisted_5$2, toDisplayString(__props.result.error?.message ?? "Something went wrong."), 1)
|
|
1799
|
+
])) : !__props.result.output ? (openBlock(), createElementBlock("div", _hoisted_6$2)) : (openBlock(), createElementBlock("div", {
|
|
1800
|
+
key: 4,
|
|
1801
|
+
class: normalizeClass(["chai-result-card__media", { "chai-result-card__media--fixed-height": kind.value === "audio" || kind.value === "text" }])
|
|
1802
|
+
}, [
|
|
1803
|
+
kind.value === "video" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
1804
|
+
__props.mediaExpanded ? (openBlock(), createElementBlock("img", {
|
|
1805
|
+
key: 0,
|
|
1806
|
+
class: "chai-result-card__image",
|
|
1807
|
+
src: __props.result.output.src,
|
|
1808
|
+
alt: ""
|
|
1809
|
+
}, null, 8, _hoisted_7$2)) : (openBlock(), createBlock(_sfc_main$3, {
|
|
1810
|
+
key: 1,
|
|
1811
|
+
src: __props.result.output.src,
|
|
1812
|
+
time: __props.videoTime,
|
|
1813
|
+
"was-playing": __props.videoWasPlaying,
|
|
1814
|
+
onPlayingChange: _cache[0] || (_cache[0] = ($event) => emit("videoPlayingChange", $event)),
|
|
1815
|
+
onDimensions: _cache[1] || (_cache[1] = (w, h2) => emit("dimensions", w, h2))
|
|
1816
|
+
}, null, 8, ["src", "time", "was-playing"]))
|
|
1817
|
+
], 64)) : kind.value === "audio" ? (openBlock(), createElementBlock("audio", {
|
|
1818
|
+
key: 1,
|
|
1819
|
+
class: "chai-result-card__audio",
|
|
1820
|
+
src: __props.result.output.src,
|
|
1821
|
+
controls: ""
|
|
1822
|
+
}, null, 8, _hoisted_8$2)) : kind.value === "text" ? (openBlock(), createBlock(_sfc_main$4, {
|
|
1823
|
+
key: 2,
|
|
1824
|
+
text: __props.result.output.src,
|
|
1825
|
+
streaming: streaming.value
|
|
1826
|
+
}, null, 8, ["text", "streaming"])) : (openBlock(), createElementBlock("img", {
|
|
1827
|
+
key: 3,
|
|
1828
|
+
class: "chai-result-card__image",
|
|
1829
|
+
src: __props.result.output.src,
|
|
1830
|
+
alt: __props.alt,
|
|
1831
|
+
onLoad: onImageLoad
|
|
1832
|
+
}, null, 40, _hoisted_9$2)),
|
|
1833
|
+
!__props.mediaExpanded && !streaming.value ? (openBlock(), createElementBlock("div", _hoisted_10$2, [
|
|
1834
|
+
createVNode(_sfc_main$6, {
|
|
1835
|
+
variant: "top",
|
|
1836
|
+
label: "Download",
|
|
1837
|
+
disabled: __props.disabled,
|
|
1838
|
+
onClick: _cache[2] || (_cache[2] = ($event) => emit("download"))
|
|
1839
|
+
}, {
|
|
1840
|
+
default: withCtx(() => [
|
|
1841
|
+
createVNode(unref(DownloadIcon))
|
|
1842
|
+
]),
|
|
1843
|
+
_: 1
|
|
1844
|
+
}, 8, ["disabled"]),
|
|
1845
|
+
createVNode(_sfc_main$6, {
|
|
1846
|
+
variant: "top",
|
|
1847
|
+
label: __props.linkCopied ? "Link copied" : "Share",
|
|
1848
|
+
disabled: __props.disabled,
|
|
1849
|
+
onClick: _cache[3] || (_cache[3] = ($event) => emit("share"))
|
|
1850
|
+
}, {
|
|
1851
|
+
default: withCtx(() => [
|
|
1852
|
+
__props.linkCopied ? (openBlock(), createBlock(unref(CheckSymbolIcon), { key: 0 })) : (openBlock(), createBlock(unref(ShareIcon), { key: 1 }))
|
|
1853
|
+
]),
|
|
1854
|
+
_: 1
|
|
1855
|
+
}, 8, ["label", "disabled"]),
|
|
1856
|
+
kind.value === "video" || kind.value === "image" ? (openBlock(), createBlock(_sfc_main$6, {
|
|
1857
|
+
key: 0,
|
|
1858
|
+
variant: "top",
|
|
1859
|
+
label: "Expand",
|
|
1860
|
+
disabled: __props.disabled,
|
|
1861
|
+
onClick: _cache[4] || (_cache[4] = ($event) => emit("expand"))
|
|
1862
|
+
}, {
|
|
1863
|
+
default: withCtx(() => [
|
|
1864
|
+
createVNode(unref(ExpandIcon))
|
|
1865
|
+
]),
|
|
1866
|
+
_: 1
|
|
1867
|
+
}, 8, ["disabled"])) : createCommentVNode("", true)
|
|
1868
|
+
])) : createCommentVNode("", true)
|
|
1869
|
+
], 2));
|
|
1870
|
+
};
|
|
1871
|
+
}
|
|
1872
|
+
});
|
|
1873
|
+
const _hoisted_1$1 = { class: "chai-result-card__inner" };
|
|
1874
|
+
const _hoisted_2$1 = ["aria-hidden", "inert"];
|
|
1875
|
+
const _hoisted_3$1 = { class: "chai-result-card__media-frame" };
|
|
1876
|
+
const _hoisted_4$1 = {
|
|
1877
|
+
key: 0,
|
|
1878
|
+
class: "chai-card-fade"
|
|
1879
|
+
};
|
|
1880
|
+
const _hoisted_5$1 = { class: "chai-card-pager-label" };
|
|
1881
|
+
const _hoisted_6$1 = { class: "chai-card-bottom" };
|
|
1882
|
+
const _hoisted_7$1 = { class: "chai-card-actions" };
|
|
1883
|
+
const _hoisted_8$1 = { class: "chai-card-pill" };
|
|
1884
|
+
const _hoisted_9$1 = ["aria-hidden", "inert"];
|
|
1885
|
+
const _hoisted_10$1 = { class: "chai-result-card__prompt-box" };
|
|
1886
|
+
const _hoisted_11$1 = { class: "chai-result-card__prompt-text" };
|
|
1887
|
+
const _hoisted_12$1 = ["aria-label", "title"];
|
|
1888
|
+
const _hoisted_13$1 = { class: "chai-result-card__chips" };
|
|
1889
|
+
const _hoisted_14$1 = ["title"];
|
|
1890
|
+
const _hoisted_15$1 = { class: "chai-visually-hidden" };
|
|
1891
|
+
const _hoisted_16 = ["aria-label"];
|
|
1892
|
+
const _hoisted_17 = { class: "chai-result-card__expand-frame" };
|
|
1893
|
+
const _hoisted_18 = ["src", "alt"];
|
|
1894
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
1895
|
+
__name: "ResultCard",
|
|
1896
|
+
props: {
|
|
1897
|
+
results: {},
|
|
1898
|
+
width: {},
|
|
1899
|
+
textMaxHeight: {},
|
|
1900
|
+
prompt: {},
|
|
1901
|
+
altText: { type: Function },
|
|
1902
|
+
models: {},
|
|
1903
|
+
getVote: { type: Function },
|
|
1904
|
+
moreActions: {},
|
|
1905
|
+
disabled: { type: Boolean }
|
|
1906
|
+
},
|
|
1907
|
+
emits: ["action"],
|
|
1908
|
+
setup(__props, { emit: __emit }) {
|
|
1909
|
+
const props = __props;
|
|
1910
|
+
const emit = __emit;
|
|
1911
|
+
const activeIndex = ref(0);
|
|
1912
|
+
const flipped = ref(false);
|
|
1913
|
+
const copied = ref(false);
|
|
1914
|
+
const linkCopied = ref(false);
|
|
1915
|
+
const mediaExpanded = ref(false);
|
|
1916
|
+
const measured = ref(null);
|
|
1917
|
+
const videoTime = reactive({ current: 0 });
|
|
1918
|
+
const videoWasPlaying = ref(false);
|
|
1919
|
+
const front = ref();
|
|
1920
|
+
const back = ref();
|
|
1921
|
+
const overlay = ref();
|
|
1922
|
+
const index = computed(() => Math.min(activeIndex.value, Math.max(0, props.results.length - 1)));
|
|
1923
|
+
const result = computed(() => props.results[index.value]);
|
|
1924
|
+
const kind = computed(() => result.value?.output?.kind);
|
|
1925
|
+
const paginated = computed(() => props.results.length > 1);
|
|
1926
|
+
const overMedia = computed(() => kind.value === "image" || kind.value === "video");
|
|
1927
|
+
const vote = computed(() => (result.value && props.getVote?.(result.value)) ?? null);
|
|
1928
|
+
const modelLabel = computed(() => result.value ? resultModelLabel(result.value, props.models) : "");
|
|
1929
|
+
const alt = computed(() => result.value ? props.altText?.(result.value) ?? props.prompt : "");
|
|
1930
|
+
const chips = computed(() => {
|
|
1931
|
+
const r = result.value;
|
|
1932
|
+
const dims = measured.value?.id === r?.id ? measured.value : null;
|
|
1933
|
+
return [
|
|
1934
|
+
modelLabel.value,
|
|
1935
|
+
formatTokens(r?.usage?.totalTokens),
|
|
1936
|
+
formatCost(r?.usage?.costUsd),
|
|
1937
|
+
formatDuration(r?.durationMs),
|
|
1938
|
+
dims ? formatAspectRatio(dims.width, dims.height) : void 0
|
|
1939
|
+
].filter(Boolean);
|
|
1940
|
+
});
|
|
1941
|
+
const cardStyle = computed(() => ({
|
|
1942
|
+
...props.width != null && { "--chai-result-card-width": `${props.width}px` },
|
|
1943
|
+
...props.textMaxHeight != null && { "--chai-result-card-text-max-height": `${props.textMaxHeight}px` }
|
|
1944
|
+
}));
|
|
1945
|
+
const { slide, endSlide } = usePageSlide(() => ({
|
|
1946
|
+
id: result.value?.id,
|
|
1947
|
+
index: index.value,
|
|
1948
|
+
image: kind.value === "image" ? result.value.output.src : void 0
|
|
1949
|
+
}));
|
|
1950
|
+
const act = (action) => emit("action", action, result.value);
|
|
1951
|
+
function flash(flag) {
|
|
1952
|
+
flag.value = true;
|
|
1953
|
+
setTimeout(() => flag.value = false, 1500);
|
|
1954
|
+
}
|
|
1955
|
+
function copyPrompt() {
|
|
1956
|
+
navigator.clipboard?.writeText(props.prompt).catch(() => {
|
|
1957
|
+
});
|
|
1958
|
+
flash(copied);
|
|
1959
|
+
act("copy-prompt");
|
|
1960
|
+
}
|
|
1961
|
+
async function download() {
|
|
1962
|
+
const r = result.value;
|
|
1963
|
+
if (r.output) await downloadMedia(r.output.src, downloadFilename(r.id, r.output.kind, r.output.src));
|
|
1964
|
+
emit("action", "download", r);
|
|
1965
|
+
}
|
|
1966
|
+
async function share() {
|
|
1967
|
+
const r = result.value;
|
|
1968
|
+
if (r.output && await shareMedia(r.output.src) === "copied") flash(linkCopied);
|
|
1969
|
+
emit("action", "share", r);
|
|
1970
|
+
}
|
|
1971
|
+
watch(
|
|
1972
|
+
flipped,
|
|
1973
|
+
(isFlipped) => {
|
|
1974
|
+
const target = isFlipped ? back.value?.querySelector('[aria-label="Close details"]') : front.value?.querySelector('[aria-label="Show details"]');
|
|
1975
|
+
target?.focus();
|
|
1976
|
+
},
|
|
1977
|
+
{ flush: "post" }
|
|
1978
|
+
);
|
|
1979
|
+
watch(mediaExpanded, async (open) => {
|
|
1980
|
+
await nextTick();
|
|
1981
|
+
if (open) overlay.value?.querySelector(".chai-result-card__collapse")?.focus();
|
|
1982
|
+
else front.value?.querySelector('[aria-label="Expand"]')?.focus();
|
|
1983
|
+
});
|
|
1984
|
+
function onOverlayKeydown(e) {
|
|
1985
|
+
if (e.key === "Escape") {
|
|
1986
|
+
e.stopPropagation();
|
|
1987
|
+
mediaExpanded.value = false;
|
|
1988
|
+
return;
|
|
1989
|
+
}
|
|
1990
|
+
if (e.key !== "Tab") return;
|
|
1991
|
+
const focusable = [
|
|
1992
|
+
...e.currentTarget.querySelectorAll('button, [tabindex="0"], a[href], input, video[controls]')
|
|
1993
|
+
].filter((el) => !el.hasAttribute("disabled"));
|
|
1994
|
+
const first = focusable[0];
|
|
1995
|
+
const last = focusable[focusable.length - 1];
|
|
1996
|
+
if (!first || !last) return;
|
|
1997
|
+
if (e.shiftKey && document.activeElement === first) {
|
|
1998
|
+
e.preventDefault();
|
|
1999
|
+
last.focus();
|
|
2000
|
+
} else if (!e.shiftKey && document.activeElement === last) {
|
|
2001
|
+
e.preventDefault();
|
|
2002
|
+
first.focus();
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
return (_ctx, _cache) => {
|
|
2006
|
+
return result.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
2007
|
+
createElementVNode("div", {
|
|
2008
|
+
class: normalizeClass(["chai-result-card", { "chai-result-card--flipped": flipped.value }]),
|
|
2009
|
+
style: normalizeStyle(cardStyle.value)
|
|
2010
|
+
}, [
|
|
2011
|
+
createElementVNode("div", _hoisted_1$1, [
|
|
2012
|
+
createElementVNode("div", {
|
|
2013
|
+
ref_key: "front",
|
|
2014
|
+
ref: front,
|
|
2015
|
+
class: normalizeClass(["chai-result-card__face chai-result-card__front", { "chai-result-card__front--paginated": paginated.value }]),
|
|
2016
|
+
"aria-hidden": flipped.value,
|
|
2017
|
+
inert: flipped.value
|
|
2018
|
+
}, [
|
|
2019
|
+
createElementVNode("div", _hoisted_3$1, [
|
|
2020
|
+
createVNode(_sfc_main$9, {
|
|
2021
|
+
slide: unref(slide),
|
|
2022
|
+
"page-class": "chai-result-card__media-page",
|
|
2023
|
+
onEnd: unref(endSlide)
|
|
2024
|
+
}, {
|
|
2025
|
+
default: withCtx(() => [
|
|
2026
|
+
createVNode(_sfc_main$2, {
|
|
2027
|
+
result: result.value,
|
|
2028
|
+
alt: alt.value,
|
|
2029
|
+
disabled: __props.disabled,
|
|
2030
|
+
"media-expanded": mediaExpanded.value,
|
|
2031
|
+
"link-copied": linkCopied.value,
|
|
2032
|
+
"video-time": videoTime,
|
|
2033
|
+
"video-was-playing": videoWasPlaying.value,
|
|
2034
|
+
onDownload: download,
|
|
2035
|
+
onShare: share,
|
|
2036
|
+
onExpand: _cache[0] || (_cache[0] = ($event) => mediaExpanded.value = true),
|
|
2037
|
+
onDimensions: _cache[1] || (_cache[1] = (w, h2) => measured.value = { id: result.value.id, width: w, height: h2 }),
|
|
2038
|
+
onVideoPlayingChange: _cache[2] || (_cache[2] = ($event) => videoWasPlaying.value = $event)
|
|
2039
|
+
}, null, 8, ["result", "alt", "disabled", "media-expanded", "link-copied", "video-time", "video-was-playing"])
|
|
2040
|
+
]),
|
|
2041
|
+
_: 1
|
|
2042
|
+
}, 8, ["slide", "onEnd"]),
|
|
2043
|
+
paginated.value && overMedia.value ? (openBlock(), createElementBlock("div", _hoisted_4$1)) : createCommentVNode("", true)
|
|
2044
|
+
]),
|
|
2045
|
+
paginated.value ? (openBlock(), createElementBlock("div", {
|
|
2046
|
+
key: 0,
|
|
2047
|
+
class: normalizeClass(["chai-card-pager-bar", { "chai-card-pager-bar--over-media": overMedia.value }])
|
|
2048
|
+
}, [
|
|
2049
|
+
createElementVNode("span", _hoisted_5$1, toDisplayString(modelLabel.value), 1),
|
|
2050
|
+
createVNode(_sfc_main$8, {
|
|
2051
|
+
count: __props.results.length,
|
|
2052
|
+
index: index.value,
|
|
2053
|
+
label: "Results",
|
|
2054
|
+
disabled: __props.disabled,
|
|
2055
|
+
"onUpdate:index": _cache[3] || (_cache[3] = ($event) => activeIndex.value = $event)
|
|
2056
|
+
}, null, 8, ["count", "index", "disabled"])
|
|
2057
|
+
], 2)) : createCommentVNode("", true),
|
|
2058
|
+
createElementVNode("div", _hoisted_6$1, [
|
|
2059
|
+
createElementVNode("div", _hoisted_7$1, [
|
|
2060
|
+
createElementVNode("div", _hoisted_8$1, [
|
|
2061
|
+
createVNode(_sfc_main$6, {
|
|
2062
|
+
variant: "pill",
|
|
2063
|
+
label: "Like",
|
|
2064
|
+
active: vote.value === "like",
|
|
2065
|
+
disabled: __props.disabled,
|
|
2066
|
+
onClick: _cache[4] || (_cache[4] = ($event) => act("like"))
|
|
2067
|
+
}, {
|
|
2068
|
+
default: withCtx(() => [
|
|
2069
|
+
createVNode(unref(ThumbUpIcon))
|
|
2070
|
+
]),
|
|
2071
|
+
_: 1
|
|
2072
|
+
}, 8, ["active", "disabled"]),
|
|
2073
|
+
createVNode(_sfc_main$6, {
|
|
2074
|
+
variant: "pill",
|
|
2075
|
+
label: "Dislike",
|
|
2076
|
+
active: vote.value === "dislike",
|
|
2077
|
+
disabled: __props.disabled,
|
|
2078
|
+
onClick: _cache[5] || (_cache[5] = ($event) => act("dislike"))
|
|
2079
|
+
}, {
|
|
2080
|
+
default: withCtx(() => [
|
|
2081
|
+
createVNode(unref(ThumbDownIcon))
|
|
2082
|
+
]),
|
|
2083
|
+
_: 1
|
|
2084
|
+
}, 8, ["active", "disabled"]),
|
|
2085
|
+
createVNode(_sfc_main$6, {
|
|
2086
|
+
variant: "pill",
|
|
2087
|
+
label: "Retry",
|
|
2088
|
+
disabled: __props.disabled,
|
|
2089
|
+
onClick: _cache[6] || (_cache[6] = ($event) => act("retry"))
|
|
2090
|
+
}, {
|
|
2091
|
+
default: withCtx(() => [
|
|
2092
|
+
createVNode(unref(RefreshIcon))
|
|
2093
|
+
]),
|
|
2094
|
+
_: 1
|
|
2095
|
+
}, 8, ["disabled"]),
|
|
2096
|
+
__props.moreActions?.length ? (openBlock(), createBlock(_sfc_main$5, {
|
|
2097
|
+
key: 0,
|
|
2098
|
+
actions: __props.moreActions,
|
|
2099
|
+
disabled: __props.disabled,
|
|
2100
|
+
onSelect: _cache[7] || (_cache[7] = ($event) => act($event.id))
|
|
2101
|
+
}, null, 8, ["actions", "disabled"])) : createCommentVNode("", true)
|
|
2102
|
+
]),
|
|
2103
|
+
createVNode(_sfc_main$6, {
|
|
2104
|
+
variant: "round",
|
|
2105
|
+
label: "Show details",
|
|
2106
|
+
disabled: __props.disabled,
|
|
2107
|
+
onClick: _cache[8] || (_cache[8] = ($event) => flipped.value = true)
|
|
2108
|
+
}, {
|
|
2109
|
+
default: withCtx(() => [
|
|
2110
|
+
createVNode(unref(InfoIcon))
|
|
2111
|
+
]),
|
|
2112
|
+
_: 1
|
|
2113
|
+
}, 8, ["disabled"])
|
|
2114
|
+
])
|
|
2115
|
+
])
|
|
2116
|
+
], 10, _hoisted_2$1),
|
|
2117
|
+
createElementVNode("div", {
|
|
2118
|
+
ref_key: "back",
|
|
2119
|
+
ref: back,
|
|
2120
|
+
class: "chai-result-card__face chai-result-card__back",
|
|
2121
|
+
"aria-hidden": !flipped.value,
|
|
2122
|
+
inert: !flipped.value
|
|
2123
|
+
}, [
|
|
2124
|
+
createElementVNode("button", {
|
|
2125
|
+
type: "button",
|
|
2126
|
+
class: "chai-result-card__close",
|
|
2127
|
+
"aria-label": "Close details",
|
|
2128
|
+
onClick: _cache[9] || (_cache[9] = ($event) => flipped.value = false)
|
|
2129
|
+
}, [
|
|
2130
|
+
createVNode(unref(CloseIcon))
|
|
2131
|
+
]),
|
|
2132
|
+
createElementVNode("div", _hoisted_10$1, [
|
|
2133
|
+
createElementVNode("p", _hoisted_11$1, toDisplayString(__props.prompt), 1),
|
|
2134
|
+
createElementVNode("button", {
|
|
2135
|
+
type: "button",
|
|
2136
|
+
class: "chai-result-card__copy",
|
|
2137
|
+
"aria-label": copied.value ? "Copied" : "Copy prompt",
|
|
2138
|
+
title: copied.value ? "Copied" : "Copy prompt",
|
|
2139
|
+
onClick: copyPrompt
|
|
2140
|
+
}, [
|
|
2141
|
+
copied.value ? (openBlock(), createBlock(unref(CheckIcon), { key: 0 })) : (openBlock(), createBlock(unref(CopyIcon), { key: 1 }))
|
|
2142
|
+
], 8, _hoisted_12$1)
|
|
2143
|
+
]),
|
|
2144
|
+
createElementVNode("div", _hoisted_13$1, [
|
|
2145
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(chips.value, (chip, i) => {
|
|
2146
|
+
return openBlock(), createElementBlock("span", {
|
|
2147
|
+
key: i,
|
|
2148
|
+
class: "chai-result-card__chip"
|
|
2149
|
+
}, toDisplayString(chip), 1);
|
|
2150
|
+
}), 128)),
|
|
2151
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(result.value.evaluations, (evaluation) => {
|
|
2152
|
+
return openBlock(), createElementBlock("span", {
|
|
2153
|
+
key: evaluation.id,
|
|
2154
|
+
class: normalizeClass([
|
|
2155
|
+
"chai-result-card__chip chai-result-card__chip--evaluation",
|
|
2156
|
+
`chai-result-card__chip--${evaluation.passed ? "passed" : "failed"}`
|
|
2157
|
+
]),
|
|
2158
|
+
title: `${evaluation.label}: ${evaluation.passed ? "passed" : "failed"}`
|
|
2159
|
+
}, [
|
|
2160
|
+
evaluation.passed ? (openBlock(), createBlock(unref(CheckIcon), { key: 0 })) : (openBlock(), createBlock(unref(CloseIcon), { key: 1 })),
|
|
2161
|
+
createTextVNode(toDisplayString(evaluation.label), 1),
|
|
2162
|
+
createElementVNode("span", _hoisted_15$1, toDisplayString(evaluation.passed ? ", passed" : ", failed"), 1)
|
|
2163
|
+
], 10, _hoisted_14$1);
|
|
2164
|
+
}), 128))
|
|
2165
|
+
])
|
|
2166
|
+
], 8, _hoisted_9$1)
|
|
2167
|
+
])
|
|
2168
|
+
], 6),
|
|
2169
|
+
mediaExpanded.value && result.value.output && overMedia.value ? (openBlock(), createElementBlock("div", {
|
|
2170
|
+
key: 0,
|
|
2171
|
+
ref_key: "overlay",
|
|
2172
|
+
ref: overlay,
|
|
2173
|
+
class: "chai-result-card__expand-overlay",
|
|
2174
|
+
role: "dialog",
|
|
2175
|
+
"aria-modal": "true",
|
|
2176
|
+
"aria-label": kind.value === "video" ? "Expanded video" : "Expanded image",
|
|
2177
|
+
onKeydown: onOverlayKeydown
|
|
2178
|
+
}, [
|
|
2179
|
+
createElementVNode("div", {
|
|
2180
|
+
class: "chai-result-card__expand-scrim",
|
|
2181
|
+
role: "presentation",
|
|
2182
|
+
onClick: _cache[10] || (_cache[10] = ($event) => mediaExpanded.value = false)
|
|
2183
|
+
}),
|
|
2184
|
+
createElementVNode("div", _hoisted_17, [
|
|
2185
|
+
kind.value === "video" ? (openBlock(), createBlock(_sfc_main$3, {
|
|
2186
|
+
key: 0,
|
|
2187
|
+
src: result.value.output.src,
|
|
2188
|
+
expanded: "",
|
|
2189
|
+
time: videoTime,
|
|
2190
|
+
"was-playing": videoWasPlaying.value,
|
|
2191
|
+
onPlayingChange: _cache[11] || (_cache[11] = ($event) => videoWasPlaying.value = $event)
|
|
2192
|
+
}, null, 8, ["src", "time", "was-playing"])) : (openBlock(), createElementBlock("img", {
|
|
2193
|
+
key: 1,
|
|
2194
|
+
class: "chai-result-card__image",
|
|
2195
|
+
src: result.value.output.src,
|
|
2196
|
+
alt: alt.value
|
|
2197
|
+
}, null, 8, _hoisted_18)),
|
|
2198
|
+
createElementVNode("button", {
|
|
2199
|
+
type: "button",
|
|
2200
|
+
class: "chai-result-card__collapse",
|
|
2201
|
+
"aria-label": "Collapse",
|
|
2202
|
+
onClick: _cache[12] || (_cache[12] = ($event) => mediaExpanded.value = false)
|
|
2203
|
+
}, [
|
|
2204
|
+
createVNode(unref(CloseIcon))
|
|
2205
|
+
])
|
|
2206
|
+
])
|
|
2207
|
+
], 40, _hoisted_16)) : createCommentVNode("", true)
|
|
2208
|
+
], 64)) : createCommentVNode("", true);
|
|
2209
|
+
};
|
|
2210
|
+
}
|
|
2211
|
+
});
|
|
2212
|
+
const _hoisted_1 = { class: "chai-media-analyzer" };
|
|
2213
|
+
const _hoisted_2 = {
|
|
2214
|
+
class: "chai-media-analyzer__dropzone-icon",
|
|
2215
|
+
"aria-hidden": "true"
|
|
2216
|
+
};
|
|
2217
|
+
const _hoisted_3 = { class: "chai-media-analyzer__dropzone-hint" };
|
|
2218
|
+
const _hoisted_4 = ["disabled"];
|
|
2219
|
+
const _hoisted_5 = ["disabled"];
|
|
2220
|
+
const _hoisted_6 = {
|
|
2221
|
+
key: 0,
|
|
2222
|
+
class: "chai-media-analyzer__thumbnails"
|
|
2223
|
+
};
|
|
2224
|
+
const _hoisted_7 = ["src"];
|
|
2225
|
+
const _hoisted_8 = {
|
|
2226
|
+
key: 1,
|
|
2227
|
+
class: "chai-media-analyzer__thumb-icon"
|
|
2228
|
+
};
|
|
2229
|
+
const _hoisted_9 = ["aria-label", "onClick"];
|
|
2230
|
+
const _hoisted_10 = {
|
|
2231
|
+
key: 1,
|
|
2232
|
+
class: "chai-media-analyzer__note",
|
|
2233
|
+
role: "status"
|
|
2234
|
+
};
|
|
2235
|
+
const _hoisted_11 = {
|
|
2236
|
+
key: 2,
|
|
2237
|
+
class: "chai-media-analyzer__error",
|
|
2238
|
+
role: "alert"
|
|
2239
|
+
};
|
|
2240
|
+
const _hoisted_12 = { class: "chai-media-analyzer__controls" };
|
|
2241
|
+
const _hoisted_13 = { class: "chai-media-analyzer__controls-start" };
|
|
2242
|
+
const _hoisted_14 = ["data-ready", "data-error", "data-stop", "aria-label", "aria-disabled"];
|
|
2243
|
+
const _hoisted_15 = { slot: "icon" };
|
|
2244
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
2245
|
+
__name: "MediaAnalyzer",
|
|
2246
|
+
props: {
|
|
2247
|
+
attachments: {},
|
|
2248
|
+
maxAttachmentsByKind: { default: () => DEFAULT_MAX_ATTACHMENTS_BY_KIND },
|
|
2249
|
+
models: { default: () => [] },
|
|
2250
|
+
modelsByKind: { default: () => SUGGESTED_ANALYSIS_MODELS },
|
|
2251
|
+
modelId: {},
|
|
2252
|
+
autoSelectModel: { type: Boolean },
|
|
2253
|
+
promptLength: {},
|
|
2254
|
+
promptLengthOptions: {},
|
|
2255
|
+
disabled: { type: Boolean },
|
|
2256
|
+
submitting: { type: Boolean },
|
|
2257
|
+
submitError: {},
|
|
2258
|
+
onAbort: {}
|
|
2259
|
+
},
|
|
2260
|
+
emits: ["update:attachments", "update:modelId", "update:autoSelectModel", "update:promptLength", "unsupportedFile", "submit"],
|
|
2261
|
+
setup(__props, { emit: __emit }) {
|
|
2262
|
+
const props = __props;
|
|
2263
|
+
const emit = __emit;
|
|
2264
|
+
const input = ref();
|
|
2265
|
+
const dragDepth = ref(0);
|
|
2266
|
+
const replaced = ref(null);
|
|
2267
|
+
const idsOf = (list) => list.map((a) => a.id).join();
|
|
2268
|
+
const kind = computed(() => props.attachments[0]?.kind);
|
|
2269
|
+
const atCap = computed(() => isMediaAnalyzerAtCap(props.attachments, props.maxAttachmentsByKind));
|
|
2270
|
+
const sections = computed(() => mediaAnalyzerModelSections(kind.value, props.modelsByKind, props.models));
|
|
2271
|
+
const selectedModel = computed(() => sections.value.flatMap((s) => s.options).find((m) => m.id === props.modelId));
|
|
2272
|
+
const modelTriggerLabel = computed(
|
|
2273
|
+
() => selectedModel.value?.label ?? (props.autoSelectModel ? "Auto-select model" : "Select model")
|
|
2274
|
+
);
|
|
2275
|
+
const lengthOptions = computed(
|
|
2276
|
+
() => (
|
|
2277
|
+
// The clarifying suffix shows only in the list, never on the trigger.
|
|
2278
|
+
props.promptLengthOptions.map((o) => ({ id: o.value, label: o.label, rowLabel: `${o.label} (${PROMPT_LENGTH_HINT[o.value]})` }))
|
|
2279
|
+
)
|
|
2280
|
+
);
|
|
2281
|
+
const lengthLabel = computed(() => props.promptLengthOptions.find((o) => o.value === props.promptLength)?.label ?? "Prompt length");
|
|
2282
|
+
const isSubmitDisabled = computed(() => props.disabled || props.attachments.length === 0);
|
|
2283
|
+
const showStop = computed(() => Boolean(props.submitting && props.onAbort));
|
|
2284
|
+
watch(
|
|
2285
|
+
() => props.autoSelectModel,
|
|
2286
|
+
(on, was) => {
|
|
2287
|
+
if (on && !was) emit("update:modelId", null);
|
|
2288
|
+
}
|
|
2289
|
+
);
|
|
2290
|
+
async function handleFiles(files) {
|
|
2291
|
+
if (!files || files.length === 0) return;
|
|
2292
|
+
const { media, unsupported } = await readMediaFiles(files);
|
|
2293
|
+
unsupported.forEach((name) => emit("unsupportedFile", name));
|
|
2294
|
+
if (media.length === 0) return;
|
|
2295
|
+
const next = media.reduce((acc, m) => nextMediaAnalyzerAttachments(acc, m, props.maxAttachmentsByKind), props.attachments);
|
|
2296
|
+
const note = replacedNote(props.attachments, next);
|
|
2297
|
+
replaced.value = note ? { note, ids: idsOf(next) } : null;
|
|
2298
|
+
emit("update:attachments", next);
|
|
2299
|
+
}
|
|
2300
|
+
function onDrop(e) {
|
|
2301
|
+
dragDepth.value = 0;
|
|
2302
|
+
if (!props.disabled) void handleFiles(e.dataTransfer?.files);
|
|
2303
|
+
}
|
|
2304
|
+
function onFileChange(e) {
|
|
2305
|
+
const el = e.target;
|
|
2306
|
+
void handleFiles(el.files);
|
|
2307
|
+
el.value = "";
|
|
2308
|
+
}
|
|
2309
|
+
function remove(id) {
|
|
2310
|
+
emit(
|
|
2311
|
+
"update:attachments",
|
|
2312
|
+
props.attachments.filter((a) => a.id !== id)
|
|
2313
|
+
);
|
|
2314
|
+
}
|
|
2315
|
+
function onSubmitClick() {
|
|
2316
|
+
if (showStop.value) props.onAbort?.();
|
|
2317
|
+
else if (!isSubmitDisabled.value && !props.submitting) {
|
|
2318
|
+
emit("submit", {
|
|
2319
|
+
attachments: props.attachments,
|
|
2320
|
+
modelId: props.modelId,
|
|
2321
|
+
autoSelectModel: props.autoSelectModel,
|
|
2322
|
+
models: kind.value ? props.modelsByKind[kind.value] ?? props.models : [],
|
|
2323
|
+
promptLength: props.promptLength
|
|
2324
|
+
});
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
return (_ctx, _cache) => {
|
|
2328
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
2329
|
+
createElementVNode("div", {
|
|
2330
|
+
class: normalizeClass([
|
|
2331
|
+
"chai-media-analyzer__dropzone",
|
|
2332
|
+
{ "chai-media-analyzer__dropzone--disabled": atCap.value, "chai-media-analyzer__dropzone--drag-active": dragDepth.value > 0 }
|
|
2333
|
+
]),
|
|
2334
|
+
onDragenter: _cache[1] || (_cache[1] = withModifiers(($event) => dragDepth.value++, ["prevent"])),
|
|
2335
|
+
onDragleave: _cache[2] || (_cache[2] = withModifiers(($event) => dragDepth.value = Math.max(0, dragDepth.value - 1), ["prevent"])),
|
|
2336
|
+
onDragover: _cache[3] || (_cache[3] = withModifiers(() => {
|
|
2337
|
+
}, ["prevent"])),
|
|
2338
|
+
onDrop: withModifiers(onDrop, ["prevent"])
|
|
2339
|
+
}, [
|
|
2340
|
+
createElementVNode("span", _hoisted_2, [
|
|
2341
|
+
createVNode(unref(MixedMediaIcon))
|
|
2342
|
+
]),
|
|
2343
|
+
createElementVNode("p", _hoisted_3, toDisplayString(atCap.value ? "Maximum images added" : "Add media to convert to prompt"), 1),
|
|
2344
|
+
createElementVNode("button", {
|
|
2345
|
+
type: "button",
|
|
2346
|
+
class: "chai-chip-button",
|
|
2347
|
+
disabled: __props.disabled,
|
|
2348
|
+
onClick: _cache[0] || (_cache[0] = ($event) => input.value?.click())
|
|
2349
|
+
}, "Select files", 8, _hoisted_4),
|
|
2350
|
+
createElementVNode("input", {
|
|
2351
|
+
ref_key: "input",
|
|
2352
|
+
ref: input,
|
|
2353
|
+
type: "file",
|
|
2354
|
+
accept: "image/*,video/*,audio/*",
|
|
2355
|
+
multiple: "",
|
|
2356
|
+
hidden: "",
|
|
2357
|
+
disabled: __props.disabled,
|
|
2358
|
+
onChange: onFileChange
|
|
2359
|
+
}, null, 40, _hoisted_5)
|
|
2360
|
+
], 34),
|
|
2361
|
+
__props.attachments.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_6, [
|
|
2362
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.attachments, (a) => {
|
|
2363
|
+
return openBlock(), createElementBlock("div", {
|
|
2364
|
+
key: a.id,
|
|
2365
|
+
class: "chai-media-analyzer__thumb"
|
|
2366
|
+
}, [
|
|
2367
|
+
a.kind === "image" ? (openBlock(), createElementBlock("img", {
|
|
2368
|
+
key: 0,
|
|
2369
|
+
class: "chai-media-analyzer__thumb-img",
|
|
2370
|
+
src: a.src,
|
|
2371
|
+
alt: ""
|
|
2372
|
+
}, null, 8, _hoisted_7)) : (openBlock(), createElementBlock("span", _hoisted_8, [
|
|
2373
|
+
a.kind === "video" ? (openBlock(), createBlock(unref(VideoIcon), { key: 0 })) : (openBlock(), createBlock(unref(AudioIcon), { key: 1 }))
|
|
2374
|
+
])),
|
|
2375
|
+
createElementVNode("button", {
|
|
2376
|
+
type: "button",
|
|
2377
|
+
class: "chai-media-analyzer__thumb-remove",
|
|
2378
|
+
"aria-label": `Remove ${a.name ?? a.kind}`,
|
|
2379
|
+
onClick: ($event) => remove(a.id)
|
|
2380
|
+
}, [
|
|
2381
|
+
createVNode(unref(RemoveIcon))
|
|
2382
|
+
], 8, _hoisted_9)
|
|
2383
|
+
]);
|
|
2384
|
+
}), 128))
|
|
2385
|
+
])) : createCommentVNode("", true),
|
|
2386
|
+
replaced.value && replaced.value.ids === idsOf(__props.attachments) ? (openBlock(), createElementBlock("p", _hoisted_10, toDisplayString(replaced.value.note), 1)) : createCommentVNode("", true),
|
|
2387
|
+
__props.submitError ? (openBlock(), createElementBlock("p", _hoisted_11, toDisplayString(__props.submitError), 1)) : createCommentVNode("", true),
|
|
2388
|
+
createElementVNode("div", _hoisted_12, [
|
|
2389
|
+
createElementVNode("div", _hoisted_13, [
|
|
2390
|
+
createVNode(_sfc_main$d, {
|
|
2391
|
+
options: sections.value.length === 1 ? sections.value[0].options : void 0,
|
|
2392
|
+
sections: sections.value.length > 1 ? sections.value : void 0,
|
|
2393
|
+
"toggle-header": { label: "Auto-select model", value: __props.autoSelectModel, onChange: (next) => emit("update:autoSelectModel", next) },
|
|
2394
|
+
value: __props.modelId,
|
|
2395
|
+
"trigger-label": modelTriggerLabel.value,
|
|
2396
|
+
"menu-label": "Select model",
|
|
2397
|
+
searchable: false,
|
|
2398
|
+
"trigger-variant": "text",
|
|
2399
|
+
disabled: __props.disabled,
|
|
2400
|
+
"panel-width": 320,
|
|
2401
|
+
onSelect: _cache[4] || (_cache[4] = ($event) => emit("update:modelId", $event.id))
|
|
2402
|
+
}, null, 8, ["options", "sections", "toggle-header", "value", "trigger-label", "disabled"]),
|
|
2403
|
+
createVNode(_sfc_main$d, {
|
|
2404
|
+
options: lengthOptions.value,
|
|
2405
|
+
value: __props.promptLength,
|
|
2406
|
+
"trigger-label": lengthLabel.value,
|
|
2407
|
+
"menu-label": "Prompt length",
|
|
2408
|
+
searchable: false,
|
|
2409
|
+
"trigger-variant": "text",
|
|
2410
|
+
disabled: __props.disabled,
|
|
2411
|
+
onSelect: _cache[5] || (_cache[5] = ($event) => emit("update:promptLength", $event.id))
|
|
2412
|
+
}, null, 8, ["options", "value", "trigger-label", "disabled"])
|
|
2413
|
+
]),
|
|
2414
|
+
createElementVNode("md-fab", {
|
|
2415
|
+
class: "chai-media-analyzer__submit",
|
|
2416
|
+
size: "small",
|
|
2417
|
+
variant: "secondary",
|
|
2418
|
+
label: "",
|
|
2419
|
+
"data-ready": showStop.value || !isSubmitDisabled.value || void 0,
|
|
2420
|
+
"data-error": Boolean(__props.submitError) || void 0,
|
|
2421
|
+
"data-stop": showStop.value || void 0,
|
|
2422
|
+
"aria-label": showStop.value ? "Stop" : __props.submitError ? "Retry" : "Analyze media",
|
|
2423
|
+
"aria-disabled": showStop.value ? "false" : __props.submitting || isSubmitDisabled.value ? "true" : "false",
|
|
2424
|
+
onClick: onSubmitClick
|
|
2425
|
+
}, [
|
|
2426
|
+
createElementVNode("span", _hoisted_15, [
|
|
2427
|
+
showStop.value ? (openBlock(), createBlock(unref(StopIcon), { key: 0 })) : (openBlock(), createBlock(unref(ArrowForwardIcon), { key: 1 }))
|
|
2428
|
+
])
|
|
2429
|
+
], 8, _hoisted_14)
|
|
2430
|
+
])
|
|
2431
|
+
]);
|
|
2432
|
+
};
|
|
2433
|
+
}
|
|
2434
|
+
});
|
|
2435
|
+
function useComposer(options = {}) {
|
|
2436
|
+
const provided = useReasoning();
|
|
2437
|
+
const store = createComposerStore(
|
|
2438
|
+
() => toValue(options),
|
|
2439
|
+
() => provided.value
|
|
2440
|
+
);
|
|
2441
|
+
const state = shallowRef(store.getState());
|
|
2442
|
+
onScopeDispose(
|
|
2443
|
+
store.subscribe(() => state.value = store.getState()),
|
|
2444
|
+
true
|
|
2445
|
+
);
|
|
2446
|
+
return {
|
|
2447
|
+
run: computed(() => state.value.runs[0] ?? null),
|
|
2448
|
+
runs: computed(() => state.value.runs),
|
|
2449
|
+
submit: store.submit,
|
|
2450
|
+
cancel: store.cancel,
|
|
2451
|
+
/** `undefined` without reasoning, so the Composer hides its Enhance button. */
|
|
2452
|
+
enhance: computed(() => pickReasoning(toValue(options), provided.value) ? store.enhance : void 0),
|
|
2453
|
+
enhancing: computed(() => state.value.enhancing),
|
|
2454
|
+
routing: computed(() => state.value.routing),
|
|
2455
|
+
/** Props for an `EditCard`, and `regions` for `Composer`. `null` when there's no `editImage`. */
|
|
2456
|
+
edit: computed(() => store.edit(state.value, toValue(options).editImage))
|
|
2457
|
+
};
|
|
2458
|
+
}
|
|
2459
|
+
function useMediaAnalyzer(options = {}) {
|
|
2460
|
+
const provided = useReasoning();
|
|
2461
|
+
const store = createMediaAnalyzerStore(
|
|
2462
|
+
() => toValue(options),
|
|
2463
|
+
() => provided.value
|
|
2464
|
+
);
|
|
2465
|
+
const state = shallowRef(store.getState());
|
|
2466
|
+
onScopeDispose(
|
|
2467
|
+
store.subscribe(() => state.value = store.getState()),
|
|
2468
|
+
true
|
|
2469
|
+
);
|
|
2470
|
+
return {
|
|
2471
|
+
analyzing: computed(() => state.value.analyzing),
|
|
2472
|
+
error: computed(() => state.value.error),
|
|
2473
|
+
prompt: computed(() => state.value.prompt),
|
|
2474
|
+
submit: store.submit,
|
|
2475
|
+
cancel: store.cancel,
|
|
2476
|
+
reset: store.reset
|
|
2477
|
+
};
|
|
2478
|
+
}
|
|
2479
|
+
export {
|
|
2480
|
+
_sfc_main$h as ChaiProvider,
|
|
2481
|
+
_sfc_main$c as Composer,
|
|
2482
|
+
DEFAULT_MAX_ATTACHMENTS_BY_KIND2 as DEFAULT_MAX_ATTACHMENTS_BY_KIND,
|
|
2483
|
+
DEFAULT_MAX_REGIONS2 as DEFAULT_MAX_REGIONS,
|
|
2484
|
+
DEFAULT_MEDIA_ANALYSIS_PROMPT_LENGTH,
|
|
2485
|
+
DEFAULT_MODEL_ID,
|
|
2486
|
+
DEFAULT_REASONING_MODEL,
|
|
2487
|
+
DEFAULT_REASONING_MODEL_BY_KIND,
|
|
2488
|
+
EDIT_IMAGE_USE_CASE,
|
|
2489
|
+
_sfc_main$7 as EditCard,
|
|
2490
|
+
GenerationError,
|
|
2491
|
+
MEDIA_ANALYSIS_PROMPTS,
|
|
2492
|
+
MEDIA_ANALYSIS_PROMPT_LENGTHS,
|
|
2493
|
+
_sfc_main as MediaAnalyzer,
|
|
2494
|
+
PRECISE_EDIT_MODELS,
|
|
2495
|
+
_sfc_main$8 as Pagination,
|
|
2496
|
+
ROUTING_MODEL_ID,
|
|
2497
|
+
_sfc_main$1 as ResultCard,
|
|
2498
|
+
SUGGESTED_ANALYSIS_MODELS2 as SUGGESTED_ANALYSIS_MODELS,
|
|
2499
|
+
SUGGESTED_EDIT_MODELS,
|
|
2500
|
+
SUGGESTED_IMAGE_MODELS,
|
|
2501
|
+
SUGGESTED_IMAGE_TO_VIDEO_MODELS,
|
|
2502
|
+
SUGGESTED_TEXT_TO_VIDEO_MODELS,
|
|
2503
|
+
_sfc_main$d as SearchMenu,
|
|
2504
|
+
TEXT_USE_CASE,
|
|
2505
|
+
_sfc_main$e as Toggle,
|
|
2506
|
+
buildRegionEditPrompt,
|
|
2507
|
+
checkSuggestedModels,
|
|
2508
|
+
createFalEngine,
|
|
2509
|
+
createMockEngine,
|
|
2510
|
+
createOpenRouterEngine,
|
|
2511
|
+
isMediaAnalyzerAtCap2 as isMediaAnalyzerAtCap,
|
|
2512
|
+
mockEngine,
|
|
2513
|
+
nextMediaAnalyzerAttachments2 as nextMediaAnalyzerAttachments,
|
|
2514
|
+
reasoningKey,
|
|
2515
|
+
reasoningModelFor,
|
|
2516
|
+
suggestedModels,
|
|
2517
|
+
useComposer,
|
|
2518
|
+
useMediaAnalyzer,
|
|
2519
|
+
useReasoning
|
|
2520
|
+
};
|
|
2521
|
+
//# sourceMappingURL=index.js.map
|