@histoire/controls 0.17.17 → 1.0.0-alpha.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.
Files changed (96) hide show
  1. package/.histoire/dist/__sandbox.html +16 -0
  2. package/.histoire/dist/assets/BaseEmpty.d30f3079.js +11 -0
  3. package/.histoire/dist/assets/HomeView.8e044be6.js +24 -0
  4. package/.histoire/dist/assets/HstCheckbox.story.3d04d85b.js +144 -0
  5. package/.histoire/dist/assets/HstColorShades.story.68cf74d1.js +532 -0
  6. package/.histoire/dist/assets/HstCopyIcon.e40e725e.js +51 -0
  7. package/.histoire/dist/assets/HstNumber.story.1e1964ff.js +160 -0
  8. package/.histoire/dist/assets/HstSelect.story.04860383.js +277 -0
  9. package/.histoire/dist/assets/HstText.story.c915d831.js +137 -0
  10. package/.histoire/dist/assets/HstTextarea.story.802b9c26.js +105 -0
  11. package/.histoire/dist/assets/HstTokenGrid.story.025819d6.js +148 -0
  12. package/.histoire/dist/assets/HstTokenList.story.d3aa6575.js +176 -0
  13. package/.histoire/dist/assets/HstWrapper.246b6982.js +56 -0
  14. package/.histoire/dist/assets/SearchPane.daa2675c.js +426 -0
  15. package/.histoire/dist/assets/StoryView.2f64dad1.js +2260 -0
  16. package/.histoire/dist/assets/bundle-main.784e5bf7.js +1156 -0
  17. package/.histoire/dist/assets/bundle-sandbox.5e153933.js +84 -0
  18. package/.histoire/dist/assets/const.268165fd.js +658 -0
  19. package/.histoire/dist/assets/global-components.6736b2a9.js +5722 -0
  20. package/.histoire/dist/assets/search-docs-data.b9a75539.js +6 -0
  21. package/.histoire/dist/assets/style.04507241.css +2504 -0
  22. package/.histoire/dist/assets/vendor.2833ae3d.js +28970 -0
  23. package/.histoire/dist/index.html +16 -0
  24. package/dist/components/HstCopyIcon.vue.d.ts +3 -12
  25. package/dist/components/HstWrapper.vue.d.ts +4 -27
  26. package/dist/components/button/HstButton.story.vue.d.ts +1 -1
  27. package/dist/components/button/HstButton.vue.d.ts +5 -145
  28. package/dist/components/button/HstButtonGroup.story.vue.d.ts +1 -1
  29. package/dist/components/button/HstButtonGroup.vue.d.ts +6 -15
  30. package/dist/components/checkbox/HstCheckbox.story.vue.d.ts +1 -1
  31. package/dist/components/checkbox/HstCheckbox.vue.d.ts +5 -14
  32. package/dist/components/checkbox/HstCheckboxList.story.vue.d.ts +1 -1
  33. package/dist/components/checkbox/HstCheckboxList.vue.d.ts +6 -15
  34. package/dist/components/checkbox/HstSimpleCheckbox.story.vue.d.ts +1 -1
  35. package/dist/components/checkbox/HstSimpleCheckbox.vue.d.ts +5 -14
  36. package/dist/components/colorselect/HstColorSelect.story.vue.d.ts +1 -1
  37. package/dist/components/colorselect/HstColorSelect.vue.d.ts +5 -14
  38. package/dist/components/design-tokens/HstColorShades.story.vue.d.ts +1 -1
  39. package/dist/components/design-tokens/HstColorShades.vue.d.ts +3 -12
  40. package/dist/components/design-tokens/HstTokenGrid.story.vue.d.ts +1 -1
  41. package/dist/components/design-tokens/HstTokenGrid.vue.d.ts +4 -27
  42. package/dist/components/design-tokens/HstTokenList.story.vue.d.ts +1 -1
  43. package/dist/components/design-tokens/HstTokenList.vue.d.ts +3 -12
  44. package/dist/components/json/HstJson.story.vue.d.ts +1 -1
  45. package/dist/components/json/HstJson.vue.d.ts +5 -14
  46. package/dist/components/number/HstNumber.story.vue.d.ts +1 -1
  47. package/dist/components/number/HstNumber.vue.d.ts +5 -14
  48. package/dist/components/radio/HstRadio.story.vue.d.ts +1 -1
  49. package/dist/components/radio/HstRadio.vue.d.ts +6 -15
  50. package/dist/components/select/CustomSelect.vue.d.ts +6 -15
  51. package/dist/components/select/HstSelect.story.vue.d.ts +1 -1
  52. package/dist/components/select/HstSelect.vue.d.ts +6 -15
  53. package/dist/components/slider/HstSlider.story.vue.d.ts +1 -1
  54. package/dist/components/slider/HstSlider.vue.d.ts +5 -14
  55. package/dist/components/text/HstText.story.vue.d.ts +1 -1
  56. package/dist/components/text/HstText.vue.d.ts +5 -14
  57. package/dist/components/textarea/HstTextarea.story.vue.d.ts +1 -1
  58. package/dist/components/textarea/HstTextarea.vue.d.ts +5 -14
  59. package/dist/index.d.ts +732 -2488
  60. package/dist/index.es.css +1 -0
  61. package/dist/index.es.js +5279 -4823
  62. package/dist/style-standalone.css +74 -66
  63. package/dist/utils.d.ts +1 -1
  64. package/package.json +25 -25
  65. package/src/components/HstCopyIcon.vue +1 -1
  66. package/src/components/HstWrapper.vue +1 -1
  67. package/src/components/button/HstButtonGroup.vue +1 -1
  68. package/src/components/checkbox/HstCheckboxList.vue +1 -1
  69. package/src/components/design-tokens/HstColorShades.vue +2 -2
  70. package/src/components/design-tokens/HstTokenGrid.vue +1 -1
  71. package/src/components/json/HstJson.vue +12 -12
  72. package/src/components/radio/HstRadio.vue +1 -1
  73. package/src/components/select/CustomSelect.vue +3 -3
  74. package/src/components/select/HstSelect.vue +1 -1
  75. package/src/components/slider/HstSlider.vue +1 -1
  76. package/src/index.ts +8 -8
  77. package/tsconfig.json +1 -0
  78. package/vite.config.ts +1 -1
  79. package/dist/style.css +0 -1
  80. package/histoire-dist/__sandbox.html +0 -15
  81. package/histoire-dist/assets/BaseEmpty.a84c14c8.js +0 -1
  82. package/histoire-dist/assets/HomeView.f524bd4b.js +0 -1
  83. package/histoire-dist/assets/HstCheckbox.story.9f622545.js +0 -1
  84. package/histoire-dist/assets/HstInput.story.945401ce.js +0 -1
  85. package/histoire-dist/assets/SearchModal.76c035f2.js +0 -1
  86. package/histoire-dist/assets/StoryView.e4c41518.js +0 -15
  87. package/histoire-dist/assets/global-components.84d0ab22.js +0 -1
  88. package/histoire-dist/assets/histoire-text-dark.a529813a.svg +0 -89
  89. package/histoire-dist/assets/histoire-text.1d4474b5.svg +0 -89
  90. package/histoire-dist/assets/index.58f51dd0.js +0 -1
  91. package/histoire-dist/assets/preview-settings.a634d101.js +0 -1
  92. package/histoire-dist/assets/sandbox.2c60450a.js +0 -1
  93. package/histoire-dist/assets/style.7657d2ac.css +0 -1
  94. package/histoire-dist/assets/vendor.70a554f6.js +0 -9
  95. package/histoire-dist/index.html +0 -15
  96. /package/{histoire-dist/assets/histoire.8af7bd1f.svg → .histoire/dist/histoire.svg} +0 -0
@@ -0,0 +1,2260 @@
1
+ import { A as defineStore, S as reactive, r as ref, w as watch, d as defineComponent, al as useRouter, U as useRoute, i as unref, a as openBlock, j as createBlock, k as withCtx, b as createElementBlock, l as createVNode, am as watchEffect, I as Icon, H as useStorage, R as createTextVNode, c as computed, e as createBaseVNode, C as resolveDynamicComponent, Q as useCssVars, m as createCommentVNode, F as Fragment, J as renderList, p as onMounted, $ as nextTick, t as toDisplayString, an as useResizeObserver, h as normalizeStyle, ao as useTimeoutFn, ap as onClickOutside, L as resolveDirective, M as withDirectives, Z as vModelText, g as withModifiers, P as isRef, v as withKeys, n as normalizeClass, q as resolveComponent, aq as shallowRef, ar as getHighlighter, f as renderSlot, ak as toRefs, x as mergeProps, as as Dropdown, V as pushScopeId, W as popScopeId, T as Transition, _ as h, at as setCDN, au as onBeforeUnmount, K as useEventListener, av as toRaw, o as onUnmounted, aw as createStaticVNode } from "./vendor.2833ae3d.js";
2
+ import { u as useStoryStore, i as isMobile, b as BaseSplitPane, _ as _export_sfc, c as _sfc_main$v, a as useScrollOnActive, B as BaseListItemLink, d as base } from "./bundle-main.784e5bf7.js";
3
+ import { B as BaseEmpty } from "./BaseEmpty.d30f3079.js";
4
+ import { _ as _sfc_main$w, u as unindent, g as generateSourceCode, a as SANDBOX_READY, E as EVENT_SEND, S as STATE_SYNC, P as PREVIEW_SETTINGS_SYNC } from "./const.268165fd.js";
5
+ import { e as clone, o as omit, b as toRawDeep, i as isDark, H as HstCopyIcon, d as applyStateToVariant, h as histoireConfig } from "./global-components.6736b2a9.js";
6
+ const useEventsStore = defineStore("events", () => {
7
+ const storyStore = useStoryStore();
8
+ const events = reactive([]);
9
+ const unseen = ref(0);
10
+ function addEvent(event) {
11
+ events.push(event);
12
+ unseen.value++;
13
+ }
14
+ function reset() {
15
+ events.length = 0;
16
+ unseen.value = 0;
17
+ }
18
+ watch(() => {
19
+ var _a;
20
+ return (_a = storyStore.currentVariant) == null ? void 0 : _a.id;
21
+ }, () => {
22
+ reset();
23
+ });
24
+ return {
25
+ addEvent,
26
+ reset,
27
+ events,
28
+ unseen
29
+ };
30
+ });
31
+ var __defProp = Object.defineProperty;
32
+ var __defProps = Object.defineProperties;
33
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
34
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
35
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
36
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
37
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
38
+ var __spreadValues = (a, b) => {
39
+ for (var prop in b || (b = {}))
40
+ if (__hasOwnProp.call(b, prop))
41
+ __defNormalProp(a, prop, b[prop]);
42
+ if (__getOwnPropSymbols)
43
+ for (var prop of __getOwnPropSymbols(b)) {
44
+ if (__propIsEnum.call(b, prop))
45
+ __defNormalProp(a, prop, b[prop]);
46
+ }
47
+ return a;
48
+ };
49
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
50
+ function useCurrentVariantRoute(variant) {
51
+ const route = useRoute();
52
+ const isActive = computed(() => route.query.variantId === variant.value.id);
53
+ const targetRoute = computed(() => __spreadProps(__spreadValues({}, route), {
54
+ query: __spreadProps(__spreadValues({}, route.query), {
55
+ variantId: variant.value.id
56
+ })
57
+ }));
58
+ return {
59
+ isActive,
60
+ targetRoute
61
+ };
62
+ }
63
+ const _hoisted_1$r = { class: "htw-truncate" };
64
+ const _sfc_main$u = /* @__PURE__ */ defineComponent({
65
+ name: "StoryVariantListItem",
66
+ props: {
67
+ variant: {
68
+ type: Object,
69
+ required: true
70
+ }
71
+ },
72
+ setup(__props) {
73
+ const props = __props;
74
+ useCssVars((_ctx) => ({
75
+ "3c4190ff": unref(variant).iconColor
76
+ }));
77
+ const { variant } = toRefs(props);
78
+ const { isActive, targetRoute } = useCurrentVariantRoute(variant);
79
+ const el = ref();
80
+ useScrollOnActive(isActive, el);
81
+ return (_ctx, _cache) => {
82
+ return openBlock(), createElementBlock("div", {
83
+ ref_key: "el",
84
+ ref: el,
85
+ "data-test-id": "story-variant-list-item"
86
+ }, [
87
+ createVNode(BaseListItemLink, {
88
+ to: unref(targetRoute),
89
+ "is-active": unref(isActive),
90
+ class: "htw-px-2 htw-py-2 md:htw-py-1.5 htw-m-1 htw-rounded-sm htw-flex htw-items-center htw-gap-2"
91
+ }, {
92
+ default: withCtx(({ active }) => {
93
+ var _a;
94
+ return [
95
+ createVNode(unref(Icon), {
96
+ icon: (_a = unref(variant).icon) != null ? _a : "carbon:cube",
97
+ class: normalizeClass(["base-list-item-link-icon htw-w-5 htw-h-5 sm:htw-w-4 sm:htw-h-4 htw-flex-none", {
98
+ "htw-text-gray-500": !active && !unref(variant).iconColor,
99
+ "bind-icon-color": !active && unref(variant).iconColor
100
+ }])
101
+ }, null, 8, ["icon", "class"]),
102
+ createBaseVNode("span", _hoisted_1$r, toDisplayString(unref(variant).title), 1)
103
+ ];
104
+ }),
105
+ _: 1
106
+ }, 8, ["to", "is-active"])
107
+ ], 512);
108
+ };
109
+ }
110
+ });
111
+ var StoryVariantListItem = /* @__PURE__ */ _export_sfc(_sfc_main$u, [["__scopeId", "data-v-2cdc2ac0"]]);
112
+ const _hoisted_1$q = { class: "htw-flex-none htw-flex htw-items-center" };
113
+ const _sfc_main$t = /* @__PURE__ */ defineComponent({
114
+ name: "StoryVariantGridItem",
115
+ props: {
116
+ variant: {
117
+ type: Object,
118
+ required: true
119
+ },
120
+ story: {
121
+ type: Object,
122
+ required: true
123
+ }
124
+ },
125
+ emits: {
126
+ resize: (width, height) => true
127
+ },
128
+ setup(__props, { emit }) {
129
+ const props = __props;
130
+ useCssVars((_ctx) => ({
131
+ "4b330766": unref(variant).iconColor
132
+ }));
133
+ const { variant } = toRefs(props);
134
+ const { isActive, targetRoute } = useCurrentVariantRoute(variant);
135
+ Object.assign(props.variant, {
136
+ previewReady: false
137
+ });
138
+ function onReady() {
139
+ Object.assign(props.variant, {
140
+ previewReady: true
141
+ });
142
+ }
143
+ const router = useRouter();
144
+ function selectVariant() {
145
+ router.push(targetRoute.value);
146
+ }
147
+ const el = ref();
148
+ const { autoScroll } = useScrollOnActive(isActive, el);
149
+ useResizeObserver(el, () => {
150
+ if (props.variant.previewReady) {
151
+ emit("resize", el.value.clientWidth, el.value.clientHeight);
152
+ if (isActive.value) {
153
+ autoScroll();
154
+ }
155
+ }
156
+ });
157
+ return (_ctx, _cache) => {
158
+ const _component_RouterLink = resolveComponent("RouterLink");
159
+ return openBlock(), createElementBlock("div", {
160
+ ref_key: "el",
161
+ ref: el,
162
+ class: "htw-cursor-default htw-flex htw-flex-col htw-gap-y-1"
163
+ }, [
164
+ createBaseVNode("div", _hoisted_1$q, [
165
+ createVNode(_component_RouterLink, {
166
+ to: unref(targetRoute),
167
+ class: normalizeClass(["htw-rounded htw-w-max htw-px-2 htw-py-0.5 htw-min-w-16 htw-cursor-pointer htw-flex htw-items-center htw-gap-1", {
168
+ "hover:htw-bg-gray-200 htw-text-gray-500 dark:hover:htw-bg-gray-800": !unref(isActive),
169
+ "htw-bg-primary-200 hover:htw-bg-primary-300 htw-text-primary-800 dark:htw-bg-primary-700 dark:hover:htw-bg-primary-800 dark:htw-text-primary-200": unref(isActive)
170
+ }])
171
+ }, {
172
+ default: withCtx(() => {
173
+ var _a;
174
+ return [
175
+ createVNode(unref(Icon), {
176
+ icon: (_a = unref(variant).icon) != null ? _a : "carbon:cube",
177
+ class: normalizeClass(["base-list-item-link-icon htw-w-4 htw-h-4 htw-opacity-50", {
178
+ "htw-text-gray-500": !unref(isActive) && !unref(variant).iconColor,
179
+ "bind-icon-color": !unref(isActive) && unref(variant).iconColor
180
+ }])
181
+ }, null, 8, ["icon", "class"]),
182
+ createBaseVNode("span", null, toDisplayString(unref(variant).title), 1)
183
+ ];
184
+ }),
185
+ _: 1
186
+ }, 8, ["to", "class"])
187
+ ]),
188
+ createBaseVNode("div", {
189
+ class: normalizeClass(["htw-border htw-bg-white dark:htw-bg-gray-700 htw-rounded-lg htw-flex-1 htw-p-4", {
190
+ "htw-border-gray-100 dark:htw-border-gray-800": !unref(isActive),
191
+ "htw-border-primary-200 dark:htw-border-primary-900": unref(isActive)
192
+ }]),
193
+ onClick: _cache[0] || (_cache[0] = withModifiers(($event) => selectVariant(), ["stop", "prevent"])),
194
+ onKeyup: _cache[1] || (_cache[1] = ($event) => selectVariant())
195
+ }, [
196
+ createVNode(_sfc_main$w, {
197
+ variant: unref(variant),
198
+ story: __props.story,
199
+ onReady
200
+ }, null, 8, ["variant", "story"])
201
+ ], 34)
202
+ ], 512);
203
+ };
204
+ }
205
+ });
206
+ var StoryVariantGridItem = /* @__PURE__ */ _export_sfc(_sfc_main$t, [["__scopeId", "data-v-5c057bcc"]]);
207
+ const _sfc_main$s = /* @__PURE__ */ defineComponent({
208
+ name: "StoryVariantGrid",
209
+ setup(__props) {
210
+ const storyStore = useStoryStore();
211
+ const gridTemplateWidth = computed(() => {
212
+ if (storyStore.currentStory.layout.type !== "grid") {
213
+ return;
214
+ }
215
+ const layoutWidth = storyStore.currentStory.layout.width;
216
+ if (!layoutWidth) {
217
+ return "200px";
218
+ }
219
+ if (typeof layoutWidth === "number") {
220
+ return layoutWidth + "px";
221
+ }
222
+ return layoutWidth;
223
+ });
224
+ const margin = 16;
225
+ const gap = 16;
226
+ const itemWidth = ref(16);
227
+ const maxItemHeight = ref(0);
228
+ const maxCount = ref(10);
229
+ const countPerRow = ref(0);
230
+ const visibleRows = ref(0);
231
+ const el = ref(null);
232
+ useResizeObserver(el, () => {
233
+ updateMaxCount();
234
+ });
235
+ function updateMaxCount() {
236
+ if (!maxItemHeight.value)
237
+ return;
238
+ const width = el.value.clientWidth - margin * 2;
239
+ const height = el.value.clientHeight;
240
+ const scrollTop = el.value.scrollTop;
241
+ countPerRow.value = Math.floor((width + gap) / (itemWidth.value + gap));
242
+ visibleRows.value = Math.ceil((height + scrollTop + gap) / (maxItemHeight.value + gap));
243
+ const newMaxCount = countPerRow.value * visibleRows.value;
244
+ if (maxCount.value < newMaxCount) {
245
+ maxCount.value = newMaxCount;
246
+ }
247
+ if (storyStore.currentVariant) {
248
+ const index = storyStore.currentStory.variants.indexOf(storyStore.currentVariant);
249
+ if (index + 1 > maxCount.value) {
250
+ maxCount.value = index + 1;
251
+ }
252
+ }
253
+ }
254
+ function onItemResize(w, h2) {
255
+ itemWidth.value = w;
256
+ if (maxItemHeight.value < h2) {
257
+ maxItemHeight.value = h2;
258
+ updateMaxCount();
259
+ }
260
+ }
261
+ watch(() => storyStore.currentVariant, () => {
262
+ updateMaxCount();
263
+ });
264
+ return (_ctx, _cache) => {
265
+ return openBlock(), createElementBlock("div", {
266
+ ref_key: "el",
267
+ ref: el,
268
+ class: "htw-h-full htw-overflow-y-auto",
269
+ onScroll: _cache[0] || (_cache[0] = ($event) => updateMaxCount())
270
+ }, [
271
+ createBaseVNode("div", {
272
+ style: normalizeStyle({
273
+ minHeight: `${unref(storyStore).currentStory.variants.length / countPerRow.value * (maxItemHeight.value + gap) - gap}px`
274
+ })
275
+ }, [
276
+ createBaseVNode("div", {
277
+ class: "htw-grid htw-gap-4 htw-m-4",
278
+ style: normalizeStyle({
279
+ gridTemplateColumns: `repeat(auto-fill, ${unref(gridTemplateWidth)})`
280
+ })
281
+ }, [
282
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(storyStore).currentStory.variants.slice(0, maxCount.value), (variant, index) => {
283
+ return openBlock(), createBlock(StoryVariantGridItem, {
284
+ key: index,
285
+ variant,
286
+ story: unref(storyStore).currentStory,
287
+ onResize: onItemResize
288
+ }, null, 8, ["variant", "story"]);
289
+ }), 128))
290
+ ], 4)
291
+ ], 4)
292
+ ], 544);
293
+ };
294
+ }
295
+ });
296
+ const _hoisted_1$p = { class: "htw-flex htw-items-center htw-gap-1 htw-text-gray-500 htw-flex-1 htw-truncate htw-min-w-0" };
297
+ const _sfc_main$r = /* @__PURE__ */ defineComponent({
298
+ name: "StoryVariantTitle",
299
+ props: {
300
+ variant: null
301
+ },
302
+ setup(__props) {
303
+ return (_ctx, _cache) => {
304
+ var _a;
305
+ return openBlock(), createElementBlock("div", _hoisted_1$p, [
306
+ createVNode(unref(Icon), {
307
+ icon: (_a = __props.variant.icon) != null ? _a : "carbon:cube",
308
+ class: normalizeClass(["base-list-item-link-icon htw-w-4 htw-h-4 htw-opacity-50", [
309
+ __props.variant.iconColor ? "bind-icon-color" : "htw-text-gray-500"
310
+ ]])
311
+ }, null, 8, ["icon", "class"]),
312
+ createBaseVNode("span", null, toDisplayString(__props.variant.title), 1)
313
+ ]);
314
+ };
315
+ }
316
+ });
317
+ const usePreviewSettingsStore = defineStore("preview-settings", () => {
318
+ const currentSettings = useStorage("_histoire-sandbox-settings-v2", {
319
+ responsiveWidth: 720,
320
+ responsiveHeight: null,
321
+ rotate: false,
322
+ backgroundColor: "transparent",
323
+ checkerboard: false
324
+ });
325
+ return {
326
+ currentSettings
327
+ };
328
+ });
329
+ const _hoisted_1$o = { class: "htw-text-white htw-w-[16px] htw-h-[16px] htw-relative" };
330
+ const _hoisted_2$k = {
331
+ width: "16",
332
+ height: "16",
333
+ viewBox: "0 0 24 24",
334
+ class: "htw-relative htw-z-10"
335
+ };
336
+ const _hoisted_3$d = ["stroke-dasharray", "stroke-dashoffset"];
337
+ const _sfc_main$q = /* @__PURE__ */ defineComponent({
338
+ name: "BaseCheckbox",
339
+ props: {
340
+ modelValue: {
341
+ type: Boolean,
342
+ default: false
343
+ }
344
+ },
345
+ emits: {
346
+ "update:modelValue": (newValue) => true
347
+ },
348
+ setup(__props, { emit }) {
349
+ const props = __props;
350
+ function toggle() {
351
+ emit("update:modelValue", !props.modelValue);
352
+ animationEnabled.value = true;
353
+ }
354
+ const path = ref();
355
+ const dasharray = ref(0);
356
+ const progress = computed(() => props.modelValue ? 1 : 0);
357
+ const dashoffset = computed(() => (1 - progress.value) * dasharray.value);
358
+ const animationEnabled = ref(false);
359
+ watch(path, (value) => {
360
+ var _a, _b, _c;
361
+ dasharray.value = (_c = (_b = (_a = path.value).getTotalLength) == null ? void 0 : _b.call(_a)) != null ? _c : 21.21;
362
+ });
363
+ return (_ctx, _cache) => {
364
+ return openBlock(), createElementBlock("div", {
365
+ role: "checkbox",
366
+ tabindex: "0",
367
+ class: "htw-flex htw-items-center htw-gap-2 htw-select-none htw-px-4 htw-py-3 htw-cursor-pointer hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700",
368
+ onClick: _cache[0] || (_cache[0] = ($event) => toggle()),
369
+ onKeydown: [
370
+ _cache[1] || (_cache[1] = withKeys(withModifiers(($event) => toggle(), ["prevent"]), ["enter"])),
371
+ _cache[2] || (_cache[2] = withKeys(withModifiers(($event) => toggle(), ["prevent"]), ["space"]))
372
+ ]
373
+ }, [
374
+ createBaseVNode("div", _hoisted_1$o, [
375
+ createBaseVNode("div", {
376
+ class: normalizeClass(["htw-border group-active:htw-bg-gray-500/20 htw-rounded-sm htw-box-border htw-absolute htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out", [
377
+ __props.modelValue ? "htw-border-primary-500 htw-border-8" : "htw-border-black/25 dark:htw-border-white/25 htw-delay-150"
378
+ ]])
379
+ }, null, 2),
380
+ (openBlock(), createElementBlock("svg", _hoisted_2$k, [
381
+ createBaseVNode("path", {
382
+ ref_key: "path",
383
+ ref: path,
384
+ d: "m 4 12 l 5 5 l 10 -10",
385
+ fill: "none",
386
+ class: normalizeClass(["htw-stroke-white htw-stroke-2 htw-duration-200 htw-ease-in-out", [
387
+ animationEnabled.value ? "htw-transition-all" : "htw-transition-none",
388
+ {
389
+ "htw-delay-150": __props.modelValue
390
+ }
391
+ ]]),
392
+ "stroke-dasharray": dasharray.value,
393
+ "stroke-dashoffset": unref(dashoffset)
394
+ }, null, 10, _hoisted_3$d)
395
+ ]))
396
+ ]),
397
+ renderSlot(_ctx.$slots, "default")
398
+ ], 32);
399
+ };
400
+ }
401
+ });
402
+ const _hoisted_1$n = { class: "htw-flex htw-flex-col htw-items-stretch" };
403
+ const _hoisted_2$j = /* @__PURE__ */ createTextVNode(" Rotate ");
404
+ const _hoisted_3$c = { class: "htw-flex htw-gap-2 htw-px-4 htw-py-3" };
405
+ const _hoisted_4$9 = /* @__PURE__ */ createBaseVNode("span", { class: "htw-opacity-50" }, "x", -1);
406
+ const _hoisted_5$6 = ["onClick"];
407
+ const _hoisted_6$6 = { class: "htw-ml-auto htw-opacity-70 htw-flex htw-gap-1" };
408
+ const _hoisted_7$3 = { key: 0 };
409
+ const _hoisted_8$2 = { key: 0 };
410
+ const _hoisted_9 = { key: 1 };
411
+ const _hoisted_10 = { key: 2 };
412
+ const _hoisted_11 = { key: 0 };
413
+ const _sfc_main$p = /* @__PURE__ */ defineComponent({
414
+ name: "StoryVariantResponsiveSize",
415
+ setup(__props) {
416
+ const settings = usePreviewSettingsStore().currentSettings;
417
+ return (_ctx, _cache) => {
418
+ var _a;
419
+ const _component_VDropdown = resolveComponent("VDropdown");
420
+ const _directive_tooltip = resolveDirective("tooltip");
421
+ return openBlock(), createBlock(_component_VDropdown, {
422
+ placement: "bottom-end",
423
+ skidding: 6,
424
+ disabled: !((_a = unref(histoireConfig).responsivePresets) == null ? void 0 : _a.length),
425
+ class: "htw-h-full htw-flex-none"
426
+ }, {
427
+ popper: withCtx(({ hide }) => [
428
+ createBaseVNode("div", _hoisted_1$n, [
429
+ createVNode(_sfc_main$q, {
430
+ modelValue: unref(settings).rotate,
431
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(settings).rotate = $event)
432
+ }, {
433
+ default: withCtx(() => [
434
+ _hoisted_2$j
435
+ ]),
436
+ _: 1
437
+ }, 8, ["modelValue"]),
438
+ createBaseVNode("div", _hoisted_3$c, [
439
+ withDirectives(createBaseVNode("input", {
440
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => unref(settings).responsiveWidth = $event),
441
+ type: "number",
442
+ class: "htw-bg-transparent htw-border htw-border-gray-200 dark:htw-border-gray-850 htw-rounded htw-w-20 htw-opacity-50 focus:htw-opacity-100 htw-flex-1 htw-min-w-0",
443
+ step: "16",
444
+ placeholder: "Auto"
445
+ }, null, 512), [
446
+ [
447
+ vModelText,
448
+ unref(settings).responsiveWidth,
449
+ void 0,
450
+ { number: true }
451
+ ],
452
+ [_directive_tooltip, "Responsive width (px)"]
453
+ ]),
454
+ _hoisted_4$9,
455
+ withDirectives(createBaseVNode("input", {
456
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => unref(settings).responsiveHeight = $event),
457
+ type: "number",
458
+ class: "htw-bg-transparent htw-border htw-border-gray-200 dark:htw-border-gray-850 htw-rounded htw-w-20 htw-opacity-50 focus:htw-opacity-100 htw-flex-1 htw-min-w-0",
459
+ step: "16",
460
+ placeholder: "Auto"
461
+ }, null, 512), [
462
+ [
463
+ vModelText,
464
+ unref(settings).responsiveHeight,
465
+ void 0,
466
+ { number: true }
467
+ ],
468
+ [_directive_tooltip, "Responsive height (px)"]
469
+ ])
470
+ ]),
471
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(histoireConfig).responsivePresets, (preset, index) => {
472
+ return openBlock(), createElementBlock("button", {
473
+ key: index,
474
+ class: normalizeClass(["htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-4", [
475
+ unref(settings).responsiveWidth === preset.width && unref(settings).responsiveHeight === preset.height ? "htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black" : "htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700"
476
+ ]]),
477
+ onClick: ($event) => {
478
+ unref(settings).responsiveWidth = preset.width;
479
+ unref(settings).responsiveHeight = preset.height;
480
+ hide();
481
+ }
482
+ }, [
483
+ createTextVNode(toDisplayString(preset.label) + " ", 1),
484
+ createBaseVNode("span", _hoisted_6$6, [
485
+ preset.width ? (openBlock(), createElementBlock("span", _hoisted_7$3, [
486
+ createTextVNode(toDisplayString(preset.width), 1),
487
+ !preset.height ? (openBlock(), createElementBlock("span", _hoisted_8$2, "px")) : createCommentVNode("", true)
488
+ ])) : createCommentVNode("", true),
489
+ preset.width && preset.height ? (openBlock(), createElementBlock("span", _hoisted_9, "x")) : createCommentVNode("", true),
490
+ preset.height ? (openBlock(), createElementBlock("span", _hoisted_10, [
491
+ createTextVNode(toDisplayString(preset.height), 1),
492
+ !preset.width ? (openBlock(), createElementBlock("span", _hoisted_11, "px")) : createCommentVNode("", true)
493
+ ])) : createCommentVNode("", true)
494
+ ])
495
+ ], 10, _hoisted_5$6);
496
+ }), 128))
497
+ ])
498
+ ]),
499
+ default: withCtx(() => {
500
+ var _a2;
501
+ return [
502
+ withDirectives((openBlock(), createElementBlock("div", {
503
+ class: normalizeClass(["htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 htw-group", {
504
+ "htw-cursor-pointer hover:htw-text-primary-500": (_a2 = unref(histoireConfig).responsivePresets) == null ? void 0 : _a2.length
505
+ }])
506
+ }, [
507
+ createVNode(unref(Icon), {
508
+ icon: "carbon:devices",
509
+ class: "htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
510
+ }),
511
+ createVNode(unref(Icon), {
512
+ icon: "carbon:caret-down",
513
+ class: "htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
514
+ })
515
+ ], 2)), [
516
+ [_directive_tooltip, "Responsive sizes"]
517
+ ])
518
+ ];
519
+ }),
520
+ _: 1
521
+ }, 8, ["disabled"]);
522
+ };
523
+ }
524
+ });
525
+ const _withScopeId$5 = (n) => (pushScopeId("data-v-bde73868"), n = n(), popScopeId(), n);
526
+ const _hoisted_1$m = { class: "htw-cursor-pointer hover:htw-text-primary-500 htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 htw-group" };
527
+ const _hoisted_2$i = /* @__PURE__ */ _withScopeId$5(() => /* @__PURE__ */ createBaseVNode("div", { class: "bind-preview-bg htw-w-4 htw-h-4 htw-rounded-full htw-border htw-border-black/50 dark:htw-border-white/50" }, null, -1));
528
+ const _hoisted_3$b = { class: "htw-flex htw-flex-col htw-items-stretch" };
529
+ const _hoisted_4$8 = /* @__PURE__ */ createTextVNode(" Checkerboard ");
530
+ const _hoisted_5$5 = ["onClick"];
531
+ const _hoisted_6$5 = { class: "htw-mr-auto" };
532
+ const _hoisted_7$2 = { class: "htw-ml-auto htw-opacity-70" };
533
+ const _sfc_main$o = /* @__PURE__ */ defineComponent({
534
+ name: "StoryVariantBackground",
535
+ setup(__props) {
536
+ useCssVars((_ctx) => ({
537
+ "b797c7ca": unref(settings).backgroundColor
538
+ }));
539
+ const settings = usePreviewSettingsStore().currentSettings;
540
+ return (_ctx, _cache) => {
541
+ const _component_VDropdown = resolveComponent("VDropdown");
542
+ const _directive_tooltip = resolveDirective("tooltip");
543
+ return unref(histoireConfig).backgroundPresets.length ? (openBlock(), createBlock(_component_VDropdown, {
544
+ key: 0,
545
+ placement: "bottom-end",
546
+ skidding: 6,
547
+ class: "htw-h-full htw-flex-none"
548
+ }, {
549
+ popper: withCtx(({ hide }) => [
550
+ createBaseVNode("div", _hoisted_3$b, [
551
+ createVNode(_sfc_main$q, {
552
+ modelValue: unref(settings).checkerboard,
553
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(settings).checkerboard = $event)
554
+ }, {
555
+ default: withCtx(() => [
556
+ _hoisted_4$8
557
+ ]),
558
+ _: 1
559
+ }, 8, ["modelValue"]),
560
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(histoireConfig).backgroundPresets, (option, index) => {
561
+ return openBlock(), createElementBlock("button", {
562
+ key: index,
563
+ class: normalizeClass(["htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-4", [
564
+ unref(settings).backgroundColor === option.color ? "htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black" : "htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700"
565
+ ]]),
566
+ onClick: ($event) => {
567
+ unref(settings).backgroundColor = option.color;
568
+ hide();
569
+ }
570
+ }, [
571
+ createBaseVNode("span", _hoisted_6$5, toDisplayString(option.label), 1),
572
+ option.color !== "$checkerboard" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
573
+ createBaseVNode("span", _hoisted_7$2, toDisplayString(option.color), 1),
574
+ createBaseVNode("div", {
575
+ class: "htw-w-4 htw-h-4 htw-rounded-full htw-border htw-border-black/20 dark:htw-border-white/20",
576
+ style: normalizeStyle({
577
+ backgroundColor: option.color
578
+ })
579
+ }, null, 4)
580
+ ], 64)) : createCommentVNode("", true)
581
+ ], 10, _hoisted_5$5);
582
+ }), 128))
583
+ ])
584
+ ]),
585
+ default: withCtx(() => [
586
+ withDirectives((openBlock(), createElementBlock("div", _hoisted_1$m, [
587
+ _hoisted_2$i,
588
+ createVNode(unref(Icon), {
589
+ icon: "carbon:caret-down",
590
+ class: "htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
591
+ })
592
+ ])), [
593
+ [_directive_tooltip, "Background color"]
594
+ ])
595
+ ]),
596
+ _: 1
597
+ })) : createCommentVNode("", true);
598
+ };
599
+ }
600
+ });
601
+ var StoryVariantBackground = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["__scopeId", "data-v-bde73868"]]);
602
+ function getSandboxUrl(story, variant) {
603
+ const url = new URLSearchParams();
604
+ url.append("storyId", story.id);
605
+ url.append("variantId", variant.id);
606
+ return `${base}__sandbox?${url.toString()}`;
607
+ }
608
+ const _hoisted_1$l = ["href"];
609
+ const _sfc_main$n = /* @__PURE__ */ defineComponent({
610
+ name: "StoryVariantNewTab",
611
+ props: {
612
+ variant: null,
613
+ story: null
614
+ },
615
+ setup(__props) {
616
+ const props = __props;
617
+ const sandboxUrl = computed(() => {
618
+ return getSandboxUrl(props.story, props.variant);
619
+ });
620
+ return (_ctx, _cache) => {
621
+ const _directive_tooltip = resolveDirective("tooltip");
622
+ return withDirectives((openBlock(), createElementBlock("a", {
623
+ href: unref(sandboxUrl),
624
+ target: "_blank",
625
+ class: "htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100"
626
+ }, [
627
+ createVNode(unref(Icon), {
628
+ icon: "carbon:launch",
629
+ class: "base-list-item-link-icon htw-w-4 htw-h-4"
630
+ })
631
+ ], 8, _hoisted_1$l)), [
632
+ [_directive_tooltip, "Open variant in new tab"]
633
+ ]);
634
+ };
635
+ }
636
+ });
637
+ const _sfc_main$m = {};
638
+ const _hoisted_1$k = { class: "__histoire-hatched-pattern" };
639
+ function _sfc_render$3(_ctx, _cache) {
640
+ return openBlock(), createElementBlock("div", _hoisted_1$k);
641
+ }
642
+ var HatchedPattern = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$3], ["__scopeId", "data-v-250960ac"]]);
643
+ const _sfc_main$l = {};
644
+ const _hoisted_1$j = { fill: "none" };
645
+ const _hoisted_2$h = /* @__PURE__ */ createBaseVNode("pattern", {
646
+ id: "checkerboard",
647
+ width: "64",
648
+ height: "64",
649
+ patternUnits: "userSpaceOnUse"
650
+ }, [
651
+ /* @__PURE__ */ createBaseVNode("rect", {
652
+ x: "0",
653
+ y: "0",
654
+ width: "32",
655
+ height: "32",
656
+ fill: "currentColor"
657
+ }),
658
+ /* @__PURE__ */ createBaseVNode("rect", {
659
+ x: "32",
660
+ y: "32",
661
+ width: "32",
662
+ height: "32",
663
+ fill: "currentColor"
664
+ })
665
+ ], -1);
666
+ const _hoisted_3$a = /* @__PURE__ */ createBaseVNode("rect", {
667
+ x: "0",
668
+ y: "0",
669
+ width: "100%",
670
+ height: "100%",
671
+ fill: "url(#checkerboard)"
672
+ }, null, -1);
673
+ const _hoisted_4$7 = [
674
+ _hoisted_2$h,
675
+ _hoisted_3$a
676
+ ];
677
+ function _sfc_render$2(_ctx, _cache) {
678
+ return openBlock(), createElementBlock("svg", _hoisted_1$j, _hoisted_4$7);
679
+ }
680
+ var CheckerboardPattern = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$2]]);
681
+ const _withScopeId$3 = (n) => (pushScopeId("data-v-769a585e"), n = n(), popScopeId(), n);
682
+ const _hoisted_1$i = { class: "htw-w-full htw-h-full htw-flex-1 htw-border htw-border-gray-100 dark:htw-border-gray-800 htw-rounded-lg htw-relative htw-overflow-hidden" };
683
+ const _hoisted_2$g = {
684
+ key: 0,
685
+ class: "htw-absolute htw-inset-0 htw-w-full htw-h-full htw-bg-gray-200 dark:htw-bg-gray-850 htw-rounded-r-lg htw-border-l-2 htw-border-gray-500/10 dark:htw-border-gray-700/30 htw-overflow-hidden"
686
+ };
687
+ const _hoisted_3$9 = { class: "htw-p-4 htw-h-full htw-relative" };
688
+ const _hoisted_4$6 = { class: "htw-w-full htw-h-full htw-border htw-border-gray-100 dark:htw-border-gray-800 htw-rounded-sm htw-relative" };
689
+ const _hoisted_5$4 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ createBaseVNode("div", { class: "bind-preview-bg htw-absolute htw-inset-0" }, null, -1));
690
+ const _hoisted_6$4 = /* @__PURE__ */ createStaticVNode('<div class="htw-absolute htw-top-1 htw-left-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-top-1 htw-right-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-bottom-1 htw-left-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-bottom-1 htw-right-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-left-1 htw-top-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-left-1 htw-bottom-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-right-1 htw-top-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div><div class="htw-absolute htw-right-1 htw-bottom-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" data-v-769a585e></div>', 8);
691
+ const _sfc_main$k = /* @__PURE__ */ defineComponent({
692
+ name: "StoryResponsivePreview",
693
+ props: {
694
+ variant: null
695
+ },
696
+ setup(__props) {
697
+ const props = __props;
698
+ useCssVars((_ctx) => ({
699
+ "700caecc": unref(settings).backgroundColor
700
+ }));
701
+ const settings = usePreviewSettingsStore().currentSettings;
702
+ const resizing = ref(false);
703
+ const onUnmountedCleanupFns = [];
704
+ onUnmounted(() => {
705
+ onUnmountedCleanupFns.forEach((fn) => fn());
706
+ });
707
+ function addWindowListener(event, listener) {
708
+ window.addEventListener(event, listener);
709
+ const removeListener = () => window.removeEventListener(event, listener);
710
+ onUnmountedCleanupFns.push(removeListener);
711
+ return () => {
712
+ removeListener();
713
+ onUnmountedCleanupFns.splice(onUnmountedCleanupFns.indexOf(removeListener), 1);
714
+ };
715
+ }
716
+ function useDragger(el, value, min, max, axis) {
717
+ function onMouseDown(event) {
718
+ event.preventDefault();
719
+ event.stopPropagation();
720
+ const start = axis === "x" ? event.clientX : event.clientY;
721
+ const startValue = value.value;
722
+ resizing.value = true;
723
+ const removeListeners = [
724
+ addWindowListener("mousemove", onMouseMove),
725
+ addWindowListener("mouseup", onMouseUp)
726
+ ];
727
+ function onMouseMove(event2) {
728
+ const snapTarget = axis === "x" ? previewWrapper.value.clientWidth : previewWrapper.value.clientHeight;
729
+ const delta = (axis === "x" ? event2.clientX : event2.clientY) - start;
730
+ value.value = Math.max(min, Math.min(max, startValue + delta));
731
+ if (Math.abs(value.value - (snapTarget - 67)) < 16) {
732
+ value.value = null;
733
+ }
734
+ }
735
+ function onMouseUp() {
736
+ removeListeners.forEach((fn) => fn());
737
+ resizing.value = false;
738
+ }
739
+ }
740
+ useEventListener(el, "mousedown", onMouseDown);
741
+ function onTouchStart(event) {
742
+ event.preventDefault();
743
+ event.stopPropagation();
744
+ const start = axis === "x" ? event.touches[0].clientX : event.touches[0].clientY;
745
+ const startValue = value.value;
746
+ resizing.value = true;
747
+ const removeListeners = [
748
+ addWindowListener("touchmove", onTouchMove),
749
+ addWindowListener("touchend", onTouchEnd),
750
+ addWindowListener("touchcancel", onTouchEnd)
751
+ ];
752
+ function onTouchMove(event2) {
753
+ const delta = (axis === "x" ? event2.touches[0].clientX : event2.touches[0].clientY) - start;
754
+ value.value = Math.max(min, Math.min(max, startValue + delta));
755
+ }
756
+ function onTouchEnd() {
757
+ removeListeners.forEach((fn) => fn());
758
+ resizing.value = false;
759
+ }
760
+ }
761
+ useEventListener(el, "touchstart", onTouchStart);
762
+ }
763
+ const responsiveWidth = computed({
764
+ get: () => settings[settings.rotate ? "responsiveHeight" : "responsiveWidth"],
765
+ set: (value) => {
766
+ settings[settings.rotate ? "responsiveHeight" : "responsiveWidth"] = value;
767
+ }
768
+ });
769
+ const responsiveHeight = computed({
770
+ get: () => settings[settings.rotate ? "responsiveWidth" : "responsiveHeight"],
771
+ set: (value) => {
772
+ settings[settings.rotate ? "responsiveWidth" : "responsiveHeight"] = value;
773
+ }
774
+ });
775
+ const horizontalDragger = ref();
776
+ const verticalDragger = ref();
777
+ const cornerDragger = ref();
778
+ const previewWrapper = ref();
779
+ useDragger(horizontalDragger, responsiveWidth, 32, 2e4, "x");
780
+ useDragger(verticalDragger, responsiveHeight, 32, 2e4, "y");
781
+ useDragger(cornerDragger, responsiveWidth, 32, 2e4, "x");
782
+ useDragger(cornerDragger, responsiveHeight, 32, 2e4, "y");
783
+ const finalWidth = computed(() => settings.rotate ? settings.responsiveHeight : settings.responsiveWidth);
784
+ const finalHeight = computed(() => settings.rotate ? settings.responsiveWidth : settings.responsiveHeight);
785
+ const isResponsiveEnabled = computed(() => !props.variant.responsiveDisabled);
786
+ return (_ctx, _cache) => {
787
+ return openBlock(), createElementBlock("div", _hoisted_1$i, [
788
+ unref(isResponsiveEnabled) ? (openBlock(), createElementBlock("div", _hoisted_2$g, [
789
+ createVNode(HatchedPattern, { class: "htw-w-full htw-h-full htw-text-black/[2%] dark:htw-text-white/[2%]" })
790
+ ])) : createCommentVNode("", true),
791
+ createBaseVNode("div", {
792
+ ref_key: "previewWrapper",
793
+ ref: previewWrapper,
794
+ class: "htw-h-full htw-overflow-auto htw-relative"
795
+ }, [
796
+ createBaseVNode("div", {
797
+ class: normalizeClass(["htw-h-full htw-p-4 htw-overflow-hidden htw-bg-white dark:htw-bg-gray-700 htw-rounded-lg htw-relative", unref(isResponsiveEnabled) ? {
798
+ "htw-w-fit": !!unref(finalWidth),
799
+ "htw-h-fit": !!unref(finalHeight)
800
+ } : void 0])
801
+ }, [
802
+ createBaseVNode("div", _hoisted_3$9, [
803
+ createBaseVNode("div", _hoisted_4$6, [
804
+ _hoisted_5$4,
805
+ unref(settings).checkerboard ? (openBlock(), createBlock(CheckerboardPattern, {
806
+ key: 0,
807
+ class: "htw-absolute htw-inset-0 htw-w-full htw-h-full htw-text-gray-500/20"
808
+ })) : createCommentVNode("", true),
809
+ renderSlot(_ctx.$slots, "default", {
810
+ isResponsiveEnabled: unref(isResponsiveEnabled),
811
+ finalWidth: unref(finalWidth),
812
+ finalHeight: unref(finalHeight),
813
+ resizing: resizing.value
814
+ }, void 0, true)
815
+ ]),
816
+ _hoisted_6$4
817
+ ]),
818
+ unref(isResponsiveEnabled) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
819
+ createBaseVNode("div", {
820
+ ref_key: "horizontalDragger",
821
+ ref: horizontalDragger,
822
+ class: "htw-absolute htw-w-4 htw-top-0 htw-bottom-4 htw-right-0 hover:htw-bg-primary-100 dark:hover:htw-bg-primary-800 htw-flex htw-items-center htw-justify-center htw-cursor-ew-resize htw-group hover:htw-text-primary-500"
823
+ }, [
824
+ createVNode(unref(Icon), {
825
+ icon: "mdi:drag-vertical-variant",
826
+ class: "htw-w-4 htw-h-4 htw-opacity-20 group-hover:htw-opacity-90"
827
+ })
828
+ ], 512),
829
+ createBaseVNode("div", {
830
+ ref_key: "verticalDragger",
831
+ ref: verticalDragger,
832
+ class: "htw-absolute htw-h-4 htw-left-0 htw-right-4 htw-bottom-0 hover:htw-bg-primary-100 dark:hover:htw-bg-primary-800 htw-flex htw-items-center htw-justify-center htw-cursor-ns-resize htw-group hover:htw-text-primary-500"
833
+ }, [
834
+ createVNode(unref(Icon), {
835
+ icon: "mdi:drag-horizontal-variant",
836
+ class: "htw-w-4 htw-h-4 htw-opacity-20 group-hover:htw-opacity-90"
837
+ })
838
+ ], 512),
839
+ createBaseVNode("div", {
840
+ ref_key: "cornerDragger",
841
+ ref: cornerDragger,
842
+ class: "htw-absolute htw-w-4 htw-h-4 htw-right-0 htw-bottom-0 hover:htw-bg-primary-100 dark:hover:htw-bg-primary-800 htw-flex htw-items-center htw-justify-center htw-cursor-nwse-resize htw-group hover:htw-text-primary-500"
843
+ }, null, 512)
844
+ ], 64)) : createCommentVNode("", true)
845
+ ], 2)
846
+ ], 512)
847
+ ]);
848
+ };
849
+ }
850
+ });
851
+ var StoryResponsivePreview = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-769a585e"]]);
852
+ const _sfc_main$j = /* @__PURE__ */ defineComponent({
853
+ name: "StoryVariantSinglePreviewNative",
854
+ props: {
855
+ story: null,
856
+ variant: null
857
+ },
858
+ setup(__props) {
859
+ const props = __props;
860
+ Object.assign(props.variant, {
861
+ previewReady: false
862
+ });
863
+ function onReady() {
864
+ Object.assign(props.variant, {
865
+ previewReady: true
866
+ });
867
+ }
868
+ return (_ctx, _cache) => {
869
+ return openBlock(), createBlock(StoryResponsivePreview, { variant: __props.variant }, {
870
+ default: withCtx(({ isResponsiveEnabled, finalWidth, finalHeight }) => [
871
+ createBaseVNode("div", {
872
+ style: normalizeStyle(isResponsiveEnabled ? {
873
+ width: finalWidth ? `${finalWidth}px` : "100%",
874
+ height: finalHeight ? `${finalHeight}px` : "100%"
875
+ } : { width: "100%", height: "100%" })
876
+ }, [
877
+ (openBlock(), createBlock(_sfc_main$w, {
878
+ key: `${__props.story.id}-${__props.variant.id}`,
879
+ variant: __props.variant,
880
+ story: __props.story,
881
+ class: "htw-h-full",
882
+ onReady
883
+ }, null, 8, ["variant", "story"]))
884
+ ], 4)
885
+ ]),
886
+ _: 1
887
+ }, 8, ["variant"]);
888
+ };
889
+ }
890
+ });
891
+ const _hoisted_1$h = ["src"];
892
+ const _sfc_main$i = /* @__PURE__ */ defineComponent({
893
+ name: "StoryVariantSinglePreviewRemote",
894
+ props: {
895
+ story: null,
896
+ variant: null
897
+ },
898
+ setup(__props) {
899
+ const props = __props;
900
+ const settings = usePreviewSettingsStore().currentSettings;
901
+ const iframe = ref();
902
+ function syncState() {
903
+ if (iframe.value && props.variant.previewReady) {
904
+ iframe.value.contentWindow.postMessage({
905
+ type: STATE_SYNC,
906
+ state: toRawDeep(props.variant.state)
907
+ });
908
+ }
909
+ }
910
+ let synced = false;
911
+ watch(() => props.variant.state, () => {
912
+ if (synced) {
913
+ synced = false;
914
+ return;
915
+ }
916
+ syncState();
917
+ }, {
918
+ deep: true,
919
+ immediate: true
920
+ });
921
+ Object.assign(props.variant, {
922
+ previewReady: false
923
+ });
924
+ useEventListener(window, "message", (event) => {
925
+ switch (event.data.type) {
926
+ case STATE_SYNC:
927
+ updateVariantState(event.data.state);
928
+ break;
929
+ case EVENT_SEND:
930
+ logEvent(event.data.event);
931
+ break;
932
+ case SANDBOX_READY:
933
+ setPreviewReady();
934
+ break;
935
+ }
936
+ });
937
+ function updateVariantState(state) {
938
+ synced = true;
939
+ applyStateToVariant(props.variant, state);
940
+ }
941
+ function logEvent(event) {
942
+ const eventsStore = useEventsStore();
943
+ eventsStore.addEvent(event);
944
+ }
945
+ function setPreviewReady() {
946
+ Object.assign(props.variant, {
947
+ previewReady: true
948
+ });
949
+ }
950
+ const sandboxUrl = computed(() => {
951
+ return getSandboxUrl(props.story, props.variant);
952
+ });
953
+ const isIframeLoaded = ref(false);
954
+ watch(sandboxUrl, () => {
955
+ isIframeLoaded.value = false;
956
+ });
957
+ function syncSettings() {
958
+ if (iframe.value) {
959
+ iframe.value.contentWindow.postMessage({
960
+ type: PREVIEW_SETTINGS_SYNC,
961
+ settings: toRaw(settings)
962
+ });
963
+ }
964
+ }
965
+ watch(() => settings, () => {
966
+ syncSettings();
967
+ }, {
968
+ deep: true,
969
+ immediate: true
970
+ });
971
+ function onIframeLoad() {
972
+ isIframeLoaded.value = true;
973
+ syncState();
974
+ syncSettings();
975
+ }
976
+ return (_ctx, _cache) => {
977
+ return openBlock(), createBlock(StoryResponsivePreview, { variant: __props.variant }, {
978
+ default: withCtx(({ isResponsiveEnabled, finalWidth, finalHeight, resizing }) => [
979
+ createBaseVNode("iframe", {
980
+ ref_key: "iframe",
981
+ ref: iframe,
982
+ src: unref(sandboxUrl),
983
+ class: normalizeClass(["htw-w-full htw-h-full htw-relative", {
984
+ "htw-invisible": !isIframeLoaded.value,
985
+ "htw-pointer-events-none": resizing
986
+ }]),
987
+ style: normalizeStyle(isResponsiveEnabled ? {
988
+ width: finalWidth ? `${finalWidth}px` : null,
989
+ height: finalHeight ? `${finalHeight}px` : null
990
+ } : void 0),
991
+ "data-test-id": "preview-iframe",
992
+ onLoad: _cache[0] || (_cache[0] = ($event) => onIframeLoad())
993
+ }, null, 46, _hoisted_1$h)
994
+ ]),
995
+ _: 1
996
+ }, 8, ["variant"]);
997
+ };
998
+ }
999
+ });
1000
+ const _hoisted_1$g = {
1001
+ class: "htw-h-full htw-flex htw-flex-col",
1002
+ "data-test-id": "story-variant-single-view"
1003
+ };
1004
+ const _hoisted_2$f = {
1005
+ key: 0,
1006
+ class: "htw-flex-none htw-flex htw-items-center htw-h-8 -htw-mt-1"
1007
+ };
1008
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
1009
+ name: "StoryVariantSingleView",
1010
+ props: {
1011
+ variant: null,
1012
+ story: null
1013
+ },
1014
+ setup(__props) {
1015
+ return (_ctx, _cache) => {
1016
+ return openBlock(), createElementBlock("div", _hoisted_1$g, [
1017
+ !unref(isMobile) ? (openBlock(), createElementBlock("div", _hoisted_2$f, [
1018
+ createVNode(_sfc_main$r, { variant: __props.variant }, null, 8, ["variant"]),
1019
+ !__props.variant.responsiveDisabled ? (openBlock(), createBlock(_sfc_main$p, { key: 0 })) : createCommentVNode("", true),
1020
+ createVNode(StoryVariantBackground),
1021
+ createVNode(_sfc_main$n, {
1022
+ variant: __props.variant,
1023
+ story: __props.story
1024
+ }, null, 8, ["variant", "story"])
1025
+ ])) : createCommentVNode("", true),
1026
+ __props.story.layout.iframe === false ? (openBlock(), createBlock(_sfc_main$j, {
1027
+ key: 1,
1028
+ story: __props.story,
1029
+ variant: __props.variant
1030
+ }, null, 8, ["story", "variant"])) : (openBlock(), createBlock(_sfc_main$i, {
1031
+ key: 2,
1032
+ story: __props.story,
1033
+ variant: __props.variant
1034
+ }, null, 8, ["story", "variant"]))
1035
+ ]);
1036
+ };
1037
+ }
1038
+ });
1039
+ const _hoisted_1$f = {
1040
+ key: 0,
1041
+ class: "htw-p-2 htw-h-full"
1042
+ };
1043
+ const _hoisted_2$e = {
1044
+ key: 0,
1045
+ class: "htw-divide-y htw-divide-gray-100 dark:htw-divide-gray-800 htw-h-full htw-flex htw-flex-col"
1046
+ };
1047
+ const _hoisted_3$8 = /* @__PURE__ */ createTextVNode(" Select a variant... ");
1048
+ const _hoisted_4$5 = {
1049
+ key: 0,
1050
+ class: "htw-p-2 htw-h-full"
1051
+ };
1052
+ const _hoisted_5$3 = { class: "htw-h-full htw-overflow-y-auto" };
1053
+ const _hoisted_6$3 = {
1054
+ key: 0,
1055
+ class: "htw-p-2 htw-h-full"
1056
+ };
1057
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
1058
+ name: "StoryVariantSingle",
1059
+ setup(__props) {
1060
+ useCssVars((_ctx) => {
1061
+ var _a;
1062
+ return {
1063
+ "ffdba94a": (_a = unref(variant)) == null ? void 0 : _a.iconColor
1064
+ };
1065
+ });
1066
+ const storyStore = useStoryStore();
1067
+ const hasSingleVariant = computed(() => {
1068
+ var _a;
1069
+ return ((_a = storyStore.currentStory) == null ? void 0 : _a.variants.length) === 1;
1070
+ });
1071
+ const variant = computed(() => storyStore.currentVariant);
1072
+ const isMenuOpened = ref(false);
1073
+ function openMenu() {
1074
+ isMenuOpened.value = true;
1075
+ }
1076
+ return (_ctx, _cache) => {
1077
+ var _a;
1078
+ return unref(hasSingleVariant) && unref(storyStore).currentVariant ? (openBlock(), createElementBlock("div", _hoisted_1$f, [
1079
+ unref(storyStore).currentVariant.configReady ? (openBlock(), createBlock(_sfc_main$h, {
1080
+ key: 0,
1081
+ variant: unref(storyStore).currentVariant,
1082
+ story: unref(storyStore).currentStory
1083
+ }, null, 8, ["variant", "story"])) : createCommentVNode("", true)
1084
+ ])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1085
+ unref(isMobile) ? (openBlock(), createElementBlock("div", _hoisted_2$e, [
1086
+ createBaseVNode("a", {
1087
+ class: "htw-px-6 htw-h-12 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer htw-flex htw-gap-2 htw-flex-wrap htw-w-full htw-items-center",
1088
+ onClick: openMenu
1089
+ }, [
1090
+ unref(variant) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1091
+ createVNode(unref(Icon), {
1092
+ icon: (_a = unref(variant).icon) != null ? _a : "carbon:cube",
1093
+ class: normalizeClass(["base-list-item-link-icon htw-w-5 htw-h-5 htw-flex-none", {
1094
+ "htw-text-gray-500": !unref(variant).iconColor,
1095
+ "bind-icon-color": unref(variant).iconColor
1096
+ }])
1097
+ }, null, 8, ["icon", "class"]),
1098
+ createTextVNode(" " + toDisplayString(unref(variant).title), 1)
1099
+ ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1100
+ _hoisted_3$8
1101
+ ], 64)),
1102
+ createVNode(unref(Icon), {
1103
+ icon: "carbon:chevron-sort",
1104
+ class: "htw-w-5 htw-h-5 htw-shrink-0 htw-ml-auto"
1105
+ })
1106
+ ]),
1107
+ unref(storyStore).currentVariant ? (openBlock(), createElementBlock("div", _hoisted_4$5, [
1108
+ unref(storyStore).currentVariant.configReady ? (openBlock(), createBlock(_sfc_main$h, {
1109
+ key: 0,
1110
+ variant: unref(storyStore).currentVariant,
1111
+ story: unref(storyStore).currentStory
1112
+ }, null, 8, ["variant", "story"])) : createCommentVNode("", true)
1113
+ ])) : createCommentVNode("", true)
1114
+ ])) : (openBlock(), createBlock(BaseSplitPane, {
1115
+ key: 1,
1116
+ "save-id": "story-single-main-split",
1117
+ min: 5,
1118
+ max: 40,
1119
+ "default-split": 17
1120
+ }, {
1121
+ first: withCtx(() => [
1122
+ createBaseVNode("div", _hoisted_5$3, [
1123
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(storyStore).currentStory.variants, (variant2, index) => {
1124
+ return openBlock(), createBlock(StoryVariantListItem, {
1125
+ key: index,
1126
+ variant: variant2
1127
+ }, null, 8, ["variant"]);
1128
+ }), 128))
1129
+ ])
1130
+ ]),
1131
+ last: withCtx(() => [
1132
+ unref(storyStore).currentVariant ? (openBlock(), createElementBlock("div", _hoisted_6$3, [
1133
+ createVNode(_sfc_main$h, {
1134
+ variant: unref(storyStore).currentVariant,
1135
+ story: unref(storyStore).currentStory
1136
+ }, null, 8, ["variant", "story"])
1137
+ ])) : createCommentVNode("", true)
1138
+ ]),
1139
+ _: 1
1140
+ }))
1141
+ ], 64));
1142
+ };
1143
+ }
1144
+ });
1145
+ var StoryVariantSingle = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["__scopeId", "data-v-a52efa6c"]]);
1146
+ const _hoisted_1$e = { class: "htw-bg-gray-50 htw-h-full dark:htw-bg-gray-750" };
1147
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
1148
+ name: "StoryViewer",
1149
+ setup(__props) {
1150
+ useCssVars((_ctx) => {
1151
+ var _a;
1152
+ return {
1153
+ "4ecaabeb": (_a = unref(variant)) == null ? void 0 : _a.iconColor
1154
+ };
1155
+ });
1156
+ const storyStore = useStoryStore();
1157
+ const variant = computed(() => storyStore.currentVariant);
1158
+ const isMenuOpened = ref(false);
1159
+ function closeMenu() {
1160
+ isMenuOpened.value = false;
1161
+ }
1162
+ watch(variant, () => {
1163
+ isMenuOpened.value = false;
1164
+ });
1165
+ return (_ctx, _cache) => {
1166
+ return openBlock(), createElementBlock(Fragment, null, [
1167
+ createBaseVNode("div", _hoisted_1$e, [
1168
+ unref(storyStore).currentStory.layout.type === "grid" ? (openBlock(), createBlock(_sfc_main$s, { key: 0 })) : unref(storyStore).currentStory.layout.type === "single" ? (openBlock(), createBlock(StoryVariantSingle, { key: 1 })) : createCommentVNode("", true)
1169
+ ]),
1170
+ createVNode(_sfc_main$v, {
1171
+ title: "Select a variant",
1172
+ opened: isMenuOpened.value,
1173
+ onClose: closeMenu
1174
+ }, {
1175
+ default: withCtx(() => [
1176
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(storyStore).currentStory.variants, (variant2, index) => {
1177
+ return openBlock(), createBlock(StoryVariantListItem, {
1178
+ key: index,
1179
+ variant: variant2
1180
+ }, null, 8, ["variant"]);
1181
+ }), 128))
1182
+ ]),
1183
+ _: 1
1184
+ }, 8, ["opened"])
1185
+ ], 64);
1186
+ };
1187
+ }
1188
+ });
1189
+ var StoryViewer = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-141c6b20"]]);
1190
+ const _hoisted_1$d = { class: "htw-cursor-pointer htw-w-full htw-outline-none htw-px-2 htw-h-[27px] -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 hover:htw-border-primary-500 dark:hover:htw-border-primary-500 htw-rounded-sm htw-flex htw-gap-2 htw-items-center htw-leading-normal" };
1191
+ const _hoisted_2$d = { class: "htw-flex-1 htw-truncate" };
1192
+ const _hoisted_3$7 = { class: "htw-flex htw-flex-col htw-bg-gray-50 dark:htw-bg-gray-700" };
1193
+ const _hoisted_4$4 = ["onClick"];
1194
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
1195
+ name: "BaseSelect",
1196
+ props: {
1197
+ modelValue: null,
1198
+ options: null
1199
+ },
1200
+ emits: ["update:modelValue", "select"],
1201
+ setup(__props, { emit: emits }) {
1202
+ const props = __props;
1203
+ const formattedOptions = computed(() => {
1204
+ if (Array.isArray(props.options)) {
1205
+ return Object.fromEntries(props.options.map((value) => [value, value]));
1206
+ }
1207
+ return props.options;
1208
+ });
1209
+ const selectedLabel = computed(() => formattedOptions.value[props.modelValue]);
1210
+ function selectValue(value, hide) {
1211
+ emits("update:modelValue", value);
1212
+ emits("select", value);
1213
+ hide();
1214
+ }
1215
+ return (_ctx, _cache) => {
1216
+ return openBlock(), createBlock(unref(Dropdown), { "auto-size": "" }, {
1217
+ popper: withCtx(({ hide }) => [
1218
+ createBaseVNode("div", _hoisted_3$7, [
1219
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(formattedOptions), (label, value) => {
1220
+ return openBlock(), createElementBlock("div", mergeProps(__spreadProps(__spreadValues({}, _ctx.$attrs), { class: null, style: null }), {
1221
+ key: label,
1222
+ class: ["htw-px-2 htw-py-1 htw-cursor-pointer hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700", {
1223
+ "htw-bg-primary-200 dark:htw-bg-primary-800": props.modelValue === value
1224
+ }],
1225
+ onClick: ($event) => selectValue(value, hide)
1226
+ }), [
1227
+ renderSlot(_ctx.$slots, "option", {
1228
+ label,
1229
+ value
1230
+ }, () => [
1231
+ createTextVNode(toDisplayString(label), 1)
1232
+ ])
1233
+ ], 16, _hoisted_4$4);
1234
+ }), 128))
1235
+ ])
1236
+ ]),
1237
+ default: withCtx(() => [
1238
+ createBaseVNode("div", _hoisted_1$d, [
1239
+ createBaseVNode("div", _hoisted_2$d, [
1240
+ renderSlot(_ctx.$slots, "default", { label: unref(selectedLabel) }, () => [
1241
+ createTextVNode(toDisplayString(unref(selectedLabel)), 1)
1242
+ ])
1243
+ ]),
1244
+ createVNode(unref(Icon), {
1245
+ icon: "carbon:chevron-sort",
1246
+ class: "htw-w-4 htw-h-4 htw-flex-none htw-ml-auto"
1247
+ })
1248
+ ])
1249
+ ]),
1250
+ _: 3
1251
+ });
1252
+ };
1253
+ }
1254
+ });
1255
+ const _hoisted_1$c = { class: "htw-flex htw-gap-2 htw-w-full htw-items-center" };
1256
+ const _hoisted_2$c = ["onUpdate:modelValue"];
1257
+ const _hoisted_3$6 = {
1258
+ key: 1,
1259
+ class: "htw-flex htw-items-center htw-gap-2"
1260
+ };
1261
+ const _hoisted_4$3 = { class: "htw-flex-1 htw-truncate" };
1262
+ const _hoisted_5$2 = { class: "htw-flex htw-gap-2 htw-items-center" };
1263
+ const _hoisted_6$2 = { class: "htw-flex-1 htw-truncate" };
1264
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
1265
+ name: "StatePresets",
1266
+ props: {
1267
+ story: null,
1268
+ variant: null
1269
+ },
1270
+ setup(__props) {
1271
+ const props = __props;
1272
+ const DEFAULT_ID = "default";
1273
+ const saveId = computed(() => `${props.story.id}:${props.variant.id}`);
1274
+ const omitKeys = ["_hPropDefs"];
1275
+ const defaultState = clone(omit(toRawDeep(props.variant.state), omitKeys));
1276
+ const selectedOption = useStorage(`_histoire-presets/${saveId.value}/selected`, DEFAULT_ID);
1277
+ const presetStates = useStorage(`_histoire-presets/${saveId.value}/states`, /* @__PURE__ */ new Map());
1278
+ const presetsOptions = computed(() => {
1279
+ const options = { [DEFAULT_ID]: "Initial state" };
1280
+ presetStates.value.forEach((value, key) => {
1281
+ options[key] = value.label;
1282
+ });
1283
+ return options;
1284
+ });
1285
+ function resetState() {
1286
+ selectedOption.value = DEFAULT_ID;
1287
+ applyStateToVariant(props.variant, clone(defaultState));
1288
+ }
1289
+ function applyPreset(id) {
1290
+ if (id === DEFAULT_ID) {
1291
+ resetState();
1292
+ } else if (presetStates.value.has(id)) {
1293
+ applyStateToVariant(props.variant, clone(presetStates.value.get(id).state));
1294
+ }
1295
+ }
1296
+ onMounted(() => {
1297
+ if (selectedOption.value !== DEFAULT_ID) {
1298
+ applyPreset(selectedOption.value);
1299
+ }
1300
+ });
1301
+ const input = ref();
1302
+ const select = ref();
1303
+ const canEdit = computed(() => selectedOption.value !== DEFAULT_ID);
1304
+ const isEditing = ref(false);
1305
+ async function createPreset() {
1306
+ const id = new Date().getTime().toString();
1307
+ presetStates.value.set(id, { state: clone(omit(toRawDeep(props.variant.state), omitKeys)), label: "New preset" });
1308
+ selectedOption.value = id;
1309
+ isEditing.value = true;
1310
+ await nextTick();
1311
+ input.value.select();
1312
+ }
1313
+ const savedNotif = ref(false);
1314
+ const savedTimeout = useTimeoutFn(() => {
1315
+ savedNotif.value = false;
1316
+ }, 1e3);
1317
+ async function savePreset() {
1318
+ if (!canEdit.value)
1319
+ return;
1320
+ const preset = presetStates.value.get(selectedOption.value);
1321
+ preset.state = clone(omit(toRawDeep(props.variant.state), omitKeys));
1322
+ savedNotif.value = true;
1323
+ savedTimeout.start();
1324
+ }
1325
+ function deletePreset(id) {
1326
+ if (!confirm("Are you sure you want to delete this preset?")) {
1327
+ return;
1328
+ }
1329
+ if (selectedOption.value === id) {
1330
+ resetState();
1331
+ }
1332
+ presetStates.value.delete(id);
1333
+ }
1334
+ async function startEditing() {
1335
+ if (!canEdit.value) {
1336
+ return;
1337
+ }
1338
+ isEditing.value = true;
1339
+ await nextTick();
1340
+ input.value.select();
1341
+ }
1342
+ function stopEditing() {
1343
+ isEditing.value = false;
1344
+ }
1345
+ onClickOutside(select, stopEditing);
1346
+ return (_ctx, _cache) => {
1347
+ const _directive_tooltip = resolveDirective("tooltip");
1348
+ return openBlock(), createElementBlock("div", _hoisted_1$c, [
1349
+ createBaseVNode("div", {
1350
+ ref_key: "select",
1351
+ ref: select,
1352
+ class: "htw-flex-1 htw-min-w-0"
1353
+ }, [
1354
+ createVNode(_sfc_main$e, {
1355
+ modelValue: unref(selectedOption),
1356
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(selectedOption) ? selectedOption.value = $event : null),
1357
+ options: unref(presetsOptions),
1358
+ onDblclick: _cache[3] || (_cache[3] = ($event) => startEditing()),
1359
+ onKeydown: [
1360
+ _cache[4] || (_cache[4] = withKeys(($event) => stopEditing(), ["enter"])),
1361
+ _cache[5] || (_cache[5] = withKeys(($event) => stopEditing(), ["escape"]))
1362
+ ],
1363
+ onSelect: _cache[6] || (_cache[6] = (id) => applyPreset(id))
1364
+ }, {
1365
+ default: withCtx(({ label }) => [
1366
+ isEditing.value ? withDirectives((openBlock(), createElementBlock("input", {
1367
+ key: 0,
1368
+ ref_key: "input",
1369
+ ref: input,
1370
+ "onUpdate:modelValue": ($event) => unref(presetStates).get(unref(selectedOption)).label = $event,
1371
+ type: "text",
1372
+ class: "htw-text-inherit htw-bg-transparent htw-w-full htw-h-full htw-outline-none",
1373
+ onClick: _cache[0] || (_cache[0] = withModifiers(() => {
1374
+ }, ["stop", "prevent"]))
1375
+ }, null, 8, _hoisted_2$c)), [
1376
+ [vModelText, unref(presetStates).get(unref(selectedOption)).label]
1377
+ ]) : (openBlock(), createElementBlock("div", _hoisted_3$6, [
1378
+ createBaseVNode("span", _hoisted_4$3, toDisplayString(label), 1),
1379
+ unref(canEdit) ? withDirectives((openBlock(), createBlock(unref(Icon), {
1380
+ key: 0,
1381
+ icon: "carbon:edit",
1382
+ class: "htw-flex-none htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100",
1383
+ onClick: _cache[1] || (_cache[1] = withModifiers(($event) => startEditing(), ["stop"]))
1384
+ }, null, 512)), [
1385
+ [_directive_tooltip, "Rename this preset"]
1386
+ ]) : createCommentVNode("", true)
1387
+ ]))
1388
+ ]),
1389
+ option: withCtx(({ label, value }) => [
1390
+ createBaseVNode("div", _hoisted_5$2, [
1391
+ createBaseVNode("span", _hoisted_6$2, toDisplayString(label), 1),
1392
+ value !== DEFAULT_ID ? withDirectives((openBlock(), createBlock(unref(Icon), {
1393
+ key: 0,
1394
+ icon: "carbon:trash-can",
1395
+ class: "htw-flex-none htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100",
1396
+ onClick: withModifiers(($event) => deletePreset(value), ["stop"])
1397
+ }, null, 8, ["onClick"])), [
1398
+ [_directive_tooltip, "Delete this preset"]
1399
+ ]) : createCommentVNode("", true)
1400
+ ])
1401
+ ]),
1402
+ _: 1
1403
+ }, 8, ["modelValue", "options"])
1404
+ ], 512),
1405
+ withDirectives(createVNode(unref(Icon), {
1406
+ icon: savedNotif.value ? "carbon:checkmark" : "carbon:save",
1407
+ class: normalizeClass(["htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100", [
1408
+ unref(canEdit) ? "htw-opacity-50 hover:htw-opacity-100" : "htw-opacity-25 htw-pointer-events-none"
1409
+ ]]),
1410
+ onClick: _cache[7] || (_cache[7] = ($event) => savePreset())
1411
+ }, null, 8, ["icon", "class"]), [
1412
+ [_directive_tooltip, savedNotif.value ? "Saved!" : unref(canEdit) ? "Save to preset" : null]
1413
+ ]),
1414
+ withDirectives(createVNode(unref(Icon), {
1415
+ icon: "carbon:add-alt",
1416
+ class: "htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100",
1417
+ onClick: _cache[8] || (_cache[8] = ($event) => createPreset())
1418
+ }, null, 512), [
1419
+ [_directive_tooltip, "Create new preset"]
1420
+ ]),
1421
+ withDirectives(createVNode(unref(Icon), {
1422
+ icon: "carbon:reset",
1423
+ class: "htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100",
1424
+ onClick: _cache[9] || (_cache[9] = ($event) => resetState())
1425
+ }, null, 512), [
1426
+ [_directive_tooltip, "Reset to initial state"]
1427
+ ])
1428
+ ]);
1429
+ };
1430
+ }
1431
+ });
1432
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
1433
+ name: "ControlsComponentPropItem",
1434
+ props: {
1435
+ variant: null,
1436
+ component: null,
1437
+ definition: null
1438
+ },
1439
+ setup(__props) {
1440
+ const props = __props;
1441
+ const comp = computed(() => {
1442
+ var _a;
1443
+ switch ((_a = props.definition.types) == null ? void 0 : _a[0]) {
1444
+ case "string":
1445
+ return "HstText";
1446
+ case "number":
1447
+ return "HstNumber";
1448
+ case "boolean":
1449
+ return "HstCheckbox";
1450
+ case "object":
1451
+ default:
1452
+ return "HstTextarea";
1453
+ }
1454
+ });
1455
+ const isJSON = computed(() => comp.value === "HstTextarea");
1456
+ const invalidValue = ref("");
1457
+ const model = computed({
1458
+ get: () => {
1459
+ var _a;
1460
+ if (invalidValue.value) {
1461
+ return invalidValue.value;
1462
+ }
1463
+ let val = (_a = props.variant.state._hPropState[props.component.index]) == null ? void 0 : _a[props.definition.name];
1464
+ if (val && isJSON.value) {
1465
+ val = JSON.stringify(val, null, 2);
1466
+ }
1467
+ return val;
1468
+ },
1469
+ set: (value) => {
1470
+ invalidValue.value = "";
1471
+ if (isJSON.value) {
1472
+ try {
1473
+ value = JSON.parse(value);
1474
+ } catch (e) {
1475
+ invalidValue.value = value;
1476
+ return;
1477
+ }
1478
+ }
1479
+ if (!props.variant.state._hPropState[props.component.index]) {
1480
+ props.variant.state._hPropState[props.component.index] = {};
1481
+ }
1482
+ props.variant.state._hPropState[props.component.index][props.definition.name] = value;
1483
+ }
1484
+ });
1485
+ function reset() {
1486
+ if (props.variant.state._hPropState[props.component.index]) {
1487
+ delete props.variant.state._hPropState[props.component.index][props.definition.name];
1488
+ }
1489
+ }
1490
+ const canReset = computed(() => {
1491
+ var _a, _b;
1492
+ return ((_b = (_a = props.variant.state) == null ? void 0 : _a._hPropState) == null ? void 0 : _b[props.component.index]) && props.definition.name in props.variant.state._hPropState[props.component.index];
1493
+ });
1494
+ return (_ctx, _cache) => {
1495
+ const _directive_tooltip = resolveDirective("tooltip");
1496
+ return unref(comp) ? (openBlock(), createBlock(resolveDynamicComponent(unref(comp)), {
1497
+ key: 0,
1498
+ modelValue: unref(model),
1499
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(model) ? model.value = $event : null),
1500
+ title: `${__props.definition.name}${unref(canReset) ? " *" : ""}`,
1501
+ placeholder: unref(isJSON) ? "Enter JSON" : null
1502
+ }, {
1503
+ actions: withCtx(() => [
1504
+ invalidValue.value ? withDirectives((openBlock(), createBlock(unref(Icon), {
1505
+ key: 0,
1506
+ icon: "carbon:warning-alt",
1507
+ class: "htw-text-orange-500"
1508
+ }, null, 512)), [
1509
+ [_directive_tooltip, "JSON error"]
1510
+ ]) : createCommentVNode("", true),
1511
+ withDirectives(createVNode(unref(Icon), {
1512
+ icon: "carbon:erase",
1513
+ class: normalizeClass(["htw-cursor-pointer htw-w-4 htw-h-4 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100", [
1514
+ unref(canReset) ? "htw-opacity-50 hover:htw-opacity-100" : "htw-opacity-25 htw-pointer-events-none"
1515
+ ]]),
1516
+ onClick: _cache[0] || (_cache[0] = withModifiers(($event) => reset(), ["stop"]))
1517
+ }, null, 8, ["class"]), [
1518
+ [_directive_tooltip, "Remove override"]
1519
+ ])
1520
+ ]),
1521
+ _: 1
1522
+ }, 8, ["modelValue", "title", "placeholder"])) : createCommentVNode("", true);
1523
+ };
1524
+ }
1525
+ });
1526
+ const _hoisted_1$b = { class: "htw-font-mono htw-p-2 htw-flex htw-items-center htw-gap-1" };
1527
+ const _hoisted_2$b = /* @__PURE__ */ createBaseVNode("span", { class: "htw-opacity-30" }, "<", -1);
1528
+ const _hoisted_3$5 = /* @__PURE__ */ createBaseVNode("span", { class: "htw-opacity-30" }, ">", -1);
1529
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
1530
+ name: "ControlsComponentProps",
1531
+ props: {
1532
+ variant: null,
1533
+ definition: null
1534
+ },
1535
+ setup(__props) {
1536
+ return (_ctx, _cache) => {
1537
+ const _directive_tooltip = resolveDirective("tooltip");
1538
+ return openBlock(), createElementBlock("div", null, [
1539
+ createBaseVNode("div", _hoisted_1$b, [
1540
+ withDirectives(createVNode(unref(Icon), {
1541
+ icon: "carbon:flash",
1542
+ class: "htw-w-4 htw-h-4 htw-text-primary-500 htw-flex-none"
1543
+ }, null, 512), [
1544
+ [_directive_tooltip, "Auto-detected props"]
1545
+ ]),
1546
+ createBaseVNode("div", null, [
1547
+ _hoisted_2$b,
1548
+ createTextVNode(toDisplayString(__props.definition.name), 1),
1549
+ _hoisted_3$5
1550
+ ])
1551
+ ]),
1552
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.definition.props, (prop) => {
1553
+ return openBlock(), createBlock(_sfc_main$c, {
1554
+ key: prop.name,
1555
+ variant: __props.variant,
1556
+ component: __props.definition,
1557
+ definition: prop
1558
+ }, null, 8, ["variant", "component", "definition"]);
1559
+ }), 128))
1560
+ ]);
1561
+ };
1562
+ }
1563
+ });
1564
+ const _hoisted_1$a = {
1565
+ "data-test-id": "story-controls",
1566
+ class: "htw-flex htw-flex-col htw-divide-y htw-divide-gray-100 dark:htw-divide-gray-750"
1567
+ };
1568
+ const _hoisted_2$a = { class: "htw-h-9 htw-flex-none htw-px-2 htw-flex htw-items-center" };
1569
+ const _hoisted_3$4 = /* @__PURE__ */ createBaseVNode("span", null, "No controls available for this story", -1);
1570
+ const _hoisted_4$2 = { key: 2 };
1571
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
1572
+ name: "StoryControls",
1573
+ props: {
1574
+ variant: {
1575
+ type: Object,
1576
+ required: true
1577
+ },
1578
+ story: {
1579
+ type: Object,
1580
+ required: true
1581
+ }
1582
+ },
1583
+ setup(__props) {
1584
+ return (_ctx, _cache) => {
1585
+ var _a, _b, _c, _d;
1586
+ return openBlock(), createElementBlock("div", _hoisted_1$a, [
1587
+ createBaseVNode("div", _hoisted_2$a, [
1588
+ createVNode(_sfc_main$d, {
1589
+ story: __props.story,
1590
+ variant: __props.variant
1591
+ }, null, 8, ["story", "variant"])
1592
+ ]),
1593
+ __props.variant.slots().controls || __props.story.slots().controls ? (openBlock(), createBlock(_sfc_main$w, {
1594
+ key: 0,
1595
+ "slot-name": "controls",
1596
+ variant: __props.variant,
1597
+ story: __props.story,
1598
+ class: "htw-flex-none"
1599
+ }, null, 8, ["variant", "story"])) : !((_b = (_a = __props.variant.state) == null ? void 0 : _a._hPropDefs) == null ? void 0 : _b.length) ? (openBlock(), createBlock(BaseEmpty, { key: 1 }, {
1600
+ default: withCtx(() => [
1601
+ createVNode(unref(Icon), {
1602
+ icon: "carbon:audio-console",
1603
+ class: "htw-w-8 htw-h-8 htw-opacity-50 htw-mb-6"
1604
+ }),
1605
+ _hoisted_3$4
1606
+ ]),
1607
+ _: 1
1608
+ })) : createCommentVNode("", true),
1609
+ ((_d = (_c = __props.variant.state) == null ? void 0 : _c._hPropDefs) == null ? void 0 : _d.length) ? (openBlock(), createElementBlock("div", _hoisted_4$2, [
1610
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.variant.state._hPropDefs, (def, index) => {
1611
+ return openBlock(), createBlock(_sfc_main$b, {
1612
+ key: index,
1613
+ variant: __props.variant,
1614
+ definition: def,
1615
+ class: "htw-flex-none htw-my-2"
1616
+ }, null, 8, ["variant", "definition"]);
1617
+ }), 128))
1618
+ ])) : createCommentVNode("", true)
1619
+ ]);
1620
+ };
1621
+ }
1622
+ });
1623
+ const _hoisted_1$9 = /* @__PURE__ */ createTextVNode(" No documentation available ");
1624
+ const _hoisted_2$9 = ["innerHTML"];
1625
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
1626
+ name: "StoryDocs",
1627
+ props: {
1628
+ story: {
1629
+ type: Object,
1630
+ required: true
1631
+ }
1632
+ },
1633
+ setup(__props) {
1634
+ const props = __props;
1635
+ const renderedDoc = ref("");
1636
+ watchEffect(async () => {
1637
+ var _a;
1638
+ let comp = (_a = props.story.file) == null ? void 0 : _a.component;
1639
+ if (comp.__asyncResolved) {
1640
+ comp = comp.__asyncResolved;
1641
+ } else if (comp.__asyncLoader) {
1642
+ comp = await comp.__asyncLoader();
1643
+ }
1644
+ renderedDoc.value = comp.doc;
1645
+ });
1646
+ return (_ctx, _cache) => {
1647
+ return openBlock(), createElementBlock("div", null, [
1648
+ !renderedDoc.value ? (openBlock(), createBlock(BaseEmpty, { key: 0 }, {
1649
+ default: withCtx(() => [
1650
+ createVNode(unref(Icon), {
1651
+ icon: "carbon:document-unknown",
1652
+ class: "htw-w-8 htw-h-8 htw-opacity-50 htw-mb-6"
1653
+ }),
1654
+ _hoisted_1$9
1655
+ ]),
1656
+ _: 1
1657
+ })) : (openBlock(), createElementBlock("div", {
1658
+ key: 1,
1659
+ class: "htw-prose dark:htw-prose-invert htw-p-4 htw-max-w-none",
1660
+ "data-test-id": "story-docs",
1661
+ innerHTML: renderedDoc.value
1662
+ }, null, 8, _hoisted_2$9))
1663
+ ]);
1664
+ };
1665
+ }
1666
+ });
1667
+ const _hoisted_1$8 = {
1668
+ key: 0,
1669
+ class: "htw-text-xs htw-opacity-50 htw-truncate"
1670
+ };
1671
+ const _hoisted_2$8 = { class: "htw-overflow-auto htw-max-w-[400px] htw-max-h-[400px]" };
1672
+ const _hoisted_3$3 = { class: "htw-p-4" };
1673
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
1674
+ name: "StoryEvent",
1675
+ props: {
1676
+ event: null
1677
+ },
1678
+ setup(__props) {
1679
+ const props = __props;
1680
+ const formattedArgument = computed(() => {
1681
+ switch (typeof props.event.argument) {
1682
+ case "string":
1683
+ return `"${props.event.argument}"`;
1684
+ case "object":
1685
+ return `{ ${Object.keys(props.event.argument).map((key) => `${key}: ${props.event.argument[key]}`).join(", ")} }`;
1686
+ default:
1687
+ return props.event.argument;
1688
+ }
1689
+ });
1690
+ return (_ctx, _cache) => {
1691
+ const _component_VDropdown = resolveComponent("VDropdown");
1692
+ return openBlock(), createBlock(_component_VDropdown, {
1693
+ class: "htw-group",
1694
+ placement: "right",
1695
+ "data-test-id": "event-item"
1696
+ }, {
1697
+ default: withCtx(({ shown }) => [
1698
+ createBaseVNode("div", {
1699
+ class: normalizeClass(["group-hover:htw-bg-primary-100 dark:group-hover:htw-bg-primary-700 htw-cursor-pointer htw-py-2 htw-px-4 htw-flex htw-items-baseline htw-gap-1 htw-leading-normal", [
1700
+ shown ? "htw-bg-primary-50 dark:htw-bg-primary-600" : "group-odd:htw-bg-gray-100/50 dark:group-odd:htw-bg-gray-750/40"
1701
+ ]])
1702
+ }, [
1703
+ createBaseVNode("span", {
1704
+ class: normalizeClass({
1705
+ "htw-text-primary-500": shown
1706
+ })
1707
+ }, toDisplayString(__props.event.name), 3),
1708
+ __props.event.argument ? (openBlock(), createElementBlock("span", _hoisted_1$8, toDisplayString(unref(formattedArgument)), 1)) : createCommentVNode("", true)
1709
+ ], 2)
1710
+ ]),
1711
+ popper: withCtx(() => [
1712
+ createBaseVNode("div", _hoisted_2$8, [
1713
+ createBaseVNode("pre", _hoisted_3$3, toDisplayString(__props.event.argument), 1)
1714
+ ])
1715
+ ]),
1716
+ _: 1
1717
+ });
1718
+ };
1719
+ }
1720
+ });
1721
+ const _hoisted_1$7 = /* @__PURE__ */ createTextVNode(" No event fired ");
1722
+ const _hoisted_2$7 = { key: 1 };
1723
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1724
+ name: "StoryEvents",
1725
+ setup(__props) {
1726
+ const eventsStore = useEventsStore();
1727
+ const hasEvents = computed(() => eventsStore.events.length);
1728
+ onMounted(resetUnseen);
1729
+ watch(() => eventsStore.unseen, resetUnseen);
1730
+ async function resetUnseen() {
1731
+ if (eventsStore.unseen > 0) {
1732
+ eventsStore.unseen = 0;
1733
+ }
1734
+ await nextTick();
1735
+ eventsElement.value.scrollTo({ top: eventsElement.value.scrollHeight });
1736
+ }
1737
+ const eventsElement = ref();
1738
+ return (_ctx, _cache) => {
1739
+ return openBlock(), createElementBlock("div", {
1740
+ ref_key: "eventsElement",
1741
+ ref: eventsElement
1742
+ }, [
1743
+ !unref(hasEvents) ? (openBlock(), createBlock(BaseEmpty, { key: 0 }, {
1744
+ default: withCtx(() => [
1745
+ createVNode(unref(Icon), {
1746
+ icon: "carbon:event-schedule",
1747
+ class: "htw-w-8 htw-h-8 htw-opacity-50 htw-mb-6"
1748
+ }),
1749
+ _hoisted_1$7
1750
+ ]),
1751
+ _: 1
1752
+ })) : (openBlock(), createElementBlock("div", _hoisted_2$7, [
1753
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(eventsStore).events, (event, key) => {
1754
+ return openBlock(), createBlock(_sfc_main$8, {
1755
+ key,
1756
+ event
1757
+ }, null, 8, ["event"]);
1758
+ }), 128))
1759
+ ]))
1760
+ ], 512);
1761
+ };
1762
+ }
1763
+ });
1764
+ const _withScopeId = (n) => (pushScopeId("data-v-32cb8d14"), n = n(), popScopeId(), n);
1765
+ const _hoisted_1$6 = { class: "htw-bg-gray-100 dark:htw-bg-gray-800 htw-h-full htw-overflow-hidden htw-flex htw-flex-col" };
1766
+ const _hoisted_2$6 = {
1767
+ key: 0,
1768
+ class: "htw-h-10 htw-flex-none htw-border-b htw-border-solid htw-border-gray-150 dark:htw-border-gray-850 htw-px-4 htw-flex htw-items-center"
1769
+ };
1770
+ const _hoisted_3$2 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createBaseVNode("div", { class: "htw-text-gray-900 dark:htw-text-gray-100" }, " Source ", -1));
1771
+ const _hoisted_4$1 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createBaseVNode("div", { class: "htw-flex-1" }, null, -1));
1772
+ const _hoisted_5$1 = {
1773
+ key: 1,
1774
+ class: "htw-text-red-500 htw-h-full htw-p-2 htw-overflow-auto htw-font-mono htw-text-sm"
1775
+ };
1776
+ const _hoisted_6$1 = ["value"];
1777
+ const _hoisted_7$1 = {
1778
+ key: 3,
1779
+ class: "htw-w-full htw-h-full htw-overflow-auto",
1780
+ "data-test-id": "story-source-code"
1781
+ };
1782
+ const _hoisted_8$1 = ["innerHTML"];
1783
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1784
+ name: "StorySourceCode",
1785
+ props: {
1786
+ variant: {
1787
+ type: Object,
1788
+ required: true
1789
+ }
1790
+ },
1791
+ setup(__props) {
1792
+ const props = __props;
1793
+ const sourceCode = ref("");
1794
+ const highlighter = shallowRef();
1795
+ const error = ref(null);
1796
+ onMounted(async () => {
1797
+ setCDN("https://unpkg.com/shiki/");
1798
+ highlighter.value = await getHighlighter({
1799
+ langs: [
1800
+ "html",
1801
+ "jsx"
1802
+ ],
1803
+ themes: [
1804
+ "github-light",
1805
+ "github-dark"
1806
+ ]
1807
+ });
1808
+ });
1809
+ watch(() => props.variant, async (value) => {
1810
+ var _a, _b;
1811
+ error.value = null;
1812
+ try {
1813
+ if (value.source) {
1814
+ sourceCode.value = value.source;
1815
+ } else if ((_a = value.slots) == null ? void 0 : _a.call(value).source) {
1816
+ const source = (_b = value.slots) == null ? void 0 : _b.call(value).source()[0].children;
1817
+ if (source) {
1818
+ sourceCode.value = await unindent(source);
1819
+ }
1820
+ } else {
1821
+ sourceCode.value = await generateSourceCode(value);
1822
+ }
1823
+ } catch (e) {
1824
+ console.error(e);
1825
+ error.value = e.message;
1826
+ }
1827
+ }, {
1828
+ deep: true,
1829
+ immediate: true
1830
+ });
1831
+ const sourceHtml = computed(() => {
1832
+ var _a;
1833
+ return (_a = highlighter.value) == null ? void 0 : _a.codeToHtml(sourceCode.value, {
1834
+ lang: "html",
1835
+ theme: isDark.value ? "github-dark" : "github-light"
1836
+ });
1837
+ });
1838
+ return (_ctx, _cache) => {
1839
+ return openBlock(), createElementBlock("div", _hoisted_1$6, [
1840
+ !error.value ? (openBlock(), createElementBlock("div", _hoisted_2$6, [
1841
+ _hoisted_3$2,
1842
+ _hoisted_4$1,
1843
+ createVNode(unref(HstCopyIcon), {
1844
+ content: sourceCode.value,
1845
+ class: "htw-flex-none"
1846
+ }, null, 8, ["content"])
1847
+ ])) : createCommentVNode("", true),
1848
+ error.value ? (openBlock(), createElementBlock("div", _hoisted_5$1, " Error: " + toDisplayString(error.value), 1)) : !unref(sourceHtml) ? (openBlock(), createElementBlock("textarea", {
1849
+ key: 2,
1850
+ class: "__histoire-code-placeholder htw-w-full htw-h-full htw-p-4 htw-outline-none htw-bg-transparent htw-resize-none htw-m-0",
1851
+ value: sourceCode.value,
1852
+ readonly: "",
1853
+ "data-test-id": "story-source-code"
1854
+ }, null, 8, _hoisted_6$1)) : (openBlock(), createElementBlock("div", _hoisted_7$1, [
1855
+ createBaseVNode("div", {
1856
+ class: "__histoire-code htw-p-4 htw-w-fit",
1857
+ innerHTML: unref(sourceHtml)
1858
+ }, null, 8, _hoisted_8$1)
1859
+ ]))
1860
+ ]);
1861
+ };
1862
+ }
1863
+ });
1864
+ var StorySourceCode = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-32cb8d14"]]);
1865
+ const _sfc_main$5 = defineComponent({
1866
+ inheritAttrs: false,
1867
+ props: {
1868
+ exact: {
1869
+ type: Boolean,
1870
+ default: false
1871
+ },
1872
+ matched: {
1873
+ type: Boolean,
1874
+ default: null
1875
+ }
1876
+ }
1877
+ });
1878
+ const _hoisted_1$5 = ["href", "onClick"];
1879
+ const _hoisted_2$5 = {
1880
+ key: 0,
1881
+ class: "htw-absolute htw-bottom-0 htw-left-0 htw-w-full htw-h-[2px] htw-bg-primary-500 dark:htw-bg-primary-400"
1882
+ };
1883
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
1884
+ const _component_router_link = resolveComponent("router-link");
1885
+ return openBlock(), createBlock(_component_router_link, mergeProps(_ctx.$attrs, { custom: "" }), {
1886
+ default: withCtx(({ isActive, isExactActive, href, navigate }) => [
1887
+ createBaseVNode("a", mergeProps(_ctx.$attrs, {
1888
+ href,
1889
+ class: ["htw-px-4 htw-h-full htw-inline-flex htw-items-center hover:htw-bg-primary-50 dark:hover:htw-bg-primary-900 htw-relative htw-text-gray-900 dark:htw-text-gray-100", {
1890
+ "htw-text-primary-500 dark:htw-text-primary-400": _ctx.matched != null ? _ctx.matched : _ctx.exact && isExactActive || !_ctx.exact && isActive
1891
+ }],
1892
+ onClick: navigate
1893
+ }), [
1894
+ renderSlot(_ctx.$slots, "default"),
1895
+ createVNode(Transition, { name: "__histoire-scale-x" }, {
1896
+ default: withCtx(() => [
1897
+ (_ctx.matched != null ? _ctx.matched : _ctx.exact && isExactActive || !_ctx.exact && isActive) ? (openBlock(), createElementBlock("div", _hoisted_2$5)) : createCommentVNode("", true)
1898
+ ]),
1899
+ _: 2
1900
+ }, 1024)
1901
+ ], 16, _hoisted_1$5)
1902
+ ]),
1903
+ _: 3
1904
+ }, 16);
1905
+ }
1906
+ var BaseTab = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$1]]);
1907
+ const _hoisted_1$4 = {
1908
+ role: "button",
1909
+ class: "htw-cursor-pointer hover:htw-bg-primary-50 dark:hover:htw-bg-primary-900 htw-w-8 htw-h-full htw-flex htw-items-center htw-justify-center htw-absolute htw-top-0 htw-right-0"
1910
+ };
1911
+ const _hoisted_2$4 = { class: "htw-flex htw-flex-col htw-items-stretch" };
1912
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1913
+ name: "BaseOverflowMenu",
1914
+ setup(__props) {
1915
+ const overflowButtonWidth = 32;
1916
+ const el = ref();
1917
+ const availableWidth = ref(0);
1918
+ useResizeObserver(el, (entries) => {
1919
+ const containerWidth = entries[0].contentRect.width;
1920
+ availableWidth.value = containerWidth - overflowButtonWidth;
1921
+ });
1922
+ const children = ref(/* @__PURE__ */ new Map());
1923
+ const visibleChildrenCount = computed(() => {
1924
+ let width = 0;
1925
+ const c = [...children.value.values()].sort((a, b) => a.index - b.index);
1926
+ for (let i = 0; i < c.length; i++) {
1927
+ width += c[i].width;
1928
+ if (width > availableWidth.value) {
1929
+ return i;
1930
+ }
1931
+ }
1932
+ return c.length;
1933
+ });
1934
+ const ChildWrapper = {
1935
+ props: ["index"],
1936
+ setup(props, { slots }) {
1937
+ const el2 = ref();
1938
+ const state = reactive({ width: 0, index: props.index });
1939
+ useResizeObserver(el2, (entries) => {
1940
+ const width = entries[0].contentRect.width;
1941
+ if (!children.value.has(el2.value)) {
1942
+ children.value.set(el2.value, state);
1943
+ }
1944
+ state.width = width;
1945
+ });
1946
+ onBeforeUnmount(() => {
1947
+ children.value.delete(el2.value);
1948
+ });
1949
+ const visible = computed(() => visibleChildrenCount.value > state.index);
1950
+ return () => h("div", { ref: el2, style: { visibility: visible.value ? "visible" : "hidden" } }, slots.default());
1951
+ }
1952
+ };
1953
+ const ChildrenRender = (props, { slots }) => {
1954
+ const [fragment] = slots.default();
1955
+ return fragment.children.map((vnode, index) => h(ChildWrapper, { index }, () => [vnode]));
1956
+ };
1957
+ const ChildrenSlice = (props, { slots }) => {
1958
+ const [fragment] = slots.default();
1959
+ return fragment.children.slice(props.start, props.end);
1960
+ };
1961
+ return (_ctx, _cache) => {
1962
+ const _component_VDropdown = resolveComponent("VDropdown");
1963
+ return openBlock(), createElementBlock("div", {
1964
+ ref_key: "el",
1965
+ ref: el,
1966
+ class: "htw-flex htw-overflow-hidden htw-relative"
1967
+ }, [
1968
+ createVNode(ChildrenRender, null, {
1969
+ default: withCtx(() => [
1970
+ renderSlot(_ctx.$slots, "default")
1971
+ ]),
1972
+ _: 3
1973
+ }),
1974
+ unref(visibleChildrenCount) < children.value.size ? (openBlock(), createBlock(_component_VDropdown, { key: 0 }, {
1975
+ popper: withCtx(() => [
1976
+ createBaseVNode("div", _hoisted_2$4, [
1977
+ createVNode(ChildrenSlice, { start: unref(visibleChildrenCount) }, {
1978
+ default: withCtx(() => [
1979
+ renderSlot(_ctx.$slots, "overflow")
1980
+ ]),
1981
+ _: 3
1982
+ }, 8, ["start"])
1983
+ ])
1984
+ ]),
1985
+ default: withCtx(() => [
1986
+ createBaseVNode("div", _hoisted_1$4, [
1987
+ createVNode(unref(Icon), {
1988
+ icon: "carbon:caret-down",
1989
+ class: "htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
1990
+ })
1991
+ ])
1992
+ ]),
1993
+ _: 3
1994
+ })) : createCommentVNode("", true)
1995
+ ], 512);
1996
+ };
1997
+ }
1998
+ });
1999
+ const _sfc_main$3 = defineComponent({
2000
+ inheritAttrs: false,
2001
+ props: {
2002
+ exact: {
2003
+ type: Boolean,
2004
+ default: false
2005
+ },
2006
+ matched: {
2007
+ type: Boolean,
2008
+ default: null
2009
+ }
2010
+ }
2011
+ });
2012
+ const _hoisted_1$3 = ["href", "onClick"];
2013
+ const _hoisted_2$3 = {
2014
+ key: 0,
2015
+ class: "htw-absolute htw-top-0 htw-left-0 htw-h-full htw-w-[2px] htw-bg-primary-500 dark:htw-bg-primary-400"
2016
+ };
2017
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
2018
+ const _component_router_link = resolveComponent("router-link");
2019
+ return openBlock(), createBlock(_component_router_link, mergeProps(_ctx.$attrs, { custom: "" }), {
2020
+ default: withCtx(({ isActive, isExactActive, href, navigate }) => [
2021
+ createBaseVNode("a", mergeProps(_ctx.$attrs, {
2022
+ href,
2023
+ class: ["htw-px-4 htw-h-10 htw-min-w-[150px] htw-inline-flex htw-items-center hover:htw-bg-primary-50 dark:hover:htw-bg-primary-900 htw-relative htw-text-gray-900 dark:htw-text-gray-100", {
2024
+ "htw-text-primary-500 dark:htw-text-primary-400": _ctx.matched != null ? _ctx.matched : _ctx.exact && isExactActive || !_ctx.exact && isActive
2025
+ }],
2026
+ onClick: navigate
2027
+ }), [
2028
+ renderSlot(_ctx.$slots, "default"),
2029
+ createVNode(Transition, { name: "__histoire-scale-y" }, {
2030
+ default: withCtx(() => [
2031
+ (_ctx.matched != null ? _ctx.matched : _ctx.exact && isExactActive || !_ctx.exact && isActive) ? (openBlock(), createElementBlock("div", _hoisted_2$3)) : createCommentVNode("", true)
2032
+ ]),
2033
+ _: 2
2034
+ }, 1024)
2035
+ ], 16, _hoisted_1$3)
2036
+ ]),
2037
+ _: 3
2038
+ }, 16);
2039
+ }
2040
+ var BaseOverflowTab = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render]]);
2041
+ const _hoisted_1$2 = /* @__PURE__ */ createTextVNode(" Controls ");
2042
+ const _hoisted_2$2 = /* @__PURE__ */ createTextVNode(" Docs ");
2043
+ const _hoisted_3$1 = /* @__PURE__ */ createTextVNode(" Events ");
2044
+ const _hoisted_4 = {
2045
+ key: 0,
2046
+ class: "htw-text-center htw-text-xs htw-mx-1 htw-px-0.5 htw-h-4 htw-min-w-4 htw-rounded-full active htw-bg-primary-500 htw-text-white dark:htw-text-black"
2047
+ };
2048
+ const _hoisted_5 = /* @__PURE__ */ createTextVNode(" Controls ");
2049
+ const _hoisted_6 = /* @__PURE__ */ createTextVNode(" Docs ");
2050
+ const _hoisted_7 = /* @__PURE__ */ createTextVNode(" Events ");
2051
+ const _hoisted_8 = {
2052
+ key: 0,
2053
+ class: "htw-text-center htw-text-xs htw-mx-1 htw-px-0.5 htw-h-4 htw-min-w-4 htw-rounded-full active htw-bg-primary-500 htw-text-white dark:htw-text-black"
2054
+ };
2055
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2056
+ name: "PaneTabs",
2057
+ setup(__props) {
2058
+ const eventsStore = useEventsStore();
2059
+ return (_ctx, _cache) => {
2060
+ return openBlock(), createBlock(_sfc_main$4, { class: "htw-h-10 htw-flex-none htw-border-b htw-border-gray-100 dark:htw-border-gray-750" }, {
2061
+ overflow: withCtx(() => [
2062
+ createVNode(BaseOverflowTab, {
2063
+ to: __spreadProps(__spreadValues({}, _ctx.$route), { query: __spreadProps(__spreadValues({}, _ctx.$route.query), { tab: "" }) }),
2064
+ matched: !_ctx.$route.query.tab
2065
+ }, {
2066
+ default: withCtx(() => [
2067
+ _hoisted_5
2068
+ ]),
2069
+ _: 1
2070
+ }, 8, ["to", "matched"]),
2071
+ createVNode(BaseOverflowTab, {
2072
+ to: __spreadProps(__spreadValues({}, _ctx.$route), { query: __spreadProps(__spreadValues({}, _ctx.$route.query), { tab: "docs" }) }),
2073
+ matched: _ctx.$route.query.tab === "docs"
2074
+ }, {
2075
+ default: withCtx(() => [
2076
+ _hoisted_6
2077
+ ]),
2078
+ _: 1
2079
+ }, 8, ["to", "matched"]),
2080
+ createVNode(BaseOverflowTab, {
2081
+ to: __spreadProps(__spreadValues({}, _ctx.$route), { query: __spreadProps(__spreadValues({}, _ctx.$route.query), { tab: "events" }) }),
2082
+ matched: _ctx.$route.query.tab === "events"
2083
+ }, {
2084
+ default: withCtx(() => [
2085
+ _hoisted_7,
2086
+ unref(eventsStore).unseen ? (openBlock(), createElementBlock("span", _hoisted_8, toDisplayString(unref(eventsStore).unseen <= 99 ? unref(eventsStore).unseen : "99+"), 1)) : createCommentVNode("", true)
2087
+ ]),
2088
+ _: 1
2089
+ }, 8, ["to", "matched"])
2090
+ ]),
2091
+ default: withCtx(() => [
2092
+ createVNode(BaseTab, {
2093
+ to: __spreadProps(__spreadValues({}, _ctx.$route), { query: __spreadProps(__spreadValues({}, _ctx.$route.query), { tab: "" }) }),
2094
+ matched: !_ctx.$route.query.tab
2095
+ }, {
2096
+ default: withCtx(() => [
2097
+ _hoisted_1$2
2098
+ ]),
2099
+ _: 1
2100
+ }, 8, ["to", "matched"]),
2101
+ createVNode(BaseTab, {
2102
+ to: __spreadProps(__spreadValues({}, _ctx.$route), { query: __spreadProps(__spreadValues({}, _ctx.$route.query), { tab: "docs" }) }),
2103
+ matched: _ctx.$route.query.tab === "docs"
2104
+ }, {
2105
+ default: withCtx(() => [
2106
+ _hoisted_2$2
2107
+ ]),
2108
+ _: 1
2109
+ }, 8, ["to", "matched"]),
2110
+ createVNode(BaseTab, {
2111
+ to: __spreadProps(__spreadValues({}, _ctx.$route), { query: __spreadProps(__spreadValues({}, _ctx.$route.query), { tab: "events" }) }),
2112
+ matched: _ctx.$route.query.tab === "events"
2113
+ }, {
2114
+ default: withCtx(() => [
2115
+ _hoisted_3$1,
2116
+ unref(eventsStore).unseen ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(unref(eventsStore).unseen <= 99 ? unref(eventsStore).unseen : "99+"), 1)) : createCommentVNode("", true)
2117
+ ]),
2118
+ _: 1
2119
+ }, 8, ["to", "matched"])
2120
+ ]),
2121
+ _: 1
2122
+ });
2123
+ };
2124
+ }
2125
+ });
2126
+ const _hoisted_1$1 = /* @__PURE__ */ createBaseVNode("span", null, "Select a variant", -1);
2127
+ const _hoisted_2$1 = /* @__PURE__ */ createBaseVNode("span", null, "Loading...", -1);
2128
+ const _hoisted_3 = { class: "htw-flex htw-flex-col htw-h-full" };
2129
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2130
+ name: "StorySidePanel",
2131
+ setup(__props) {
2132
+ const storyStore = useStoryStore();
2133
+ const route = useRoute();
2134
+ const panelContentComponent = computed(() => {
2135
+ switch (route.query.tab) {
2136
+ case "docs":
2137
+ return _sfc_main$9;
2138
+ case "events":
2139
+ return _sfc_main$7;
2140
+ default:
2141
+ return _sfc_main$a;
2142
+ }
2143
+ });
2144
+ return (_ctx, _cache) => {
2145
+ return !unref(storyStore).currentVariant ? (openBlock(), createBlock(BaseEmpty, { key: 0 }, {
2146
+ default: withCtx(() => [
2147
+ _hoisted_1$1
2148
+ ]),
2149
+ _: 1
2150
+ })) : !unref(storyStore).currentVariant.previewReady ? (openBlock(), createBlock(BaseEmpty, { key: 1 }, {
2151
+ default: withCtx(() => [
2152
+ _hoisted_2$1
2153
+ ]),
2154
+ _: 1
2155
+ })) : (openBlock(), createBlock(BaseSplitPane, {
2156
+ key: 2,
2157
+ "save-id": "story-sidepane",
2158
+ orientation: "portrait",
2159
+ class: "htw-h-full",
2160
+ "data-test-id": "story-side-panel"
2161
+ }, {
2162
+ first: withCtx(() => [
2163
+ createBaseVNode("div", _hoisted_3, [
2164
+ createVNode(_sfc_main$2),
2165
+ (openBlock(), createBlock(resolveDynamicComponent(unref(panelContentComponent)), {
2166
+ story: unref(storyStore).currentStory,
2167
+ variant: unref(storyStore).currentVariant,
2168
+ class: "htw-h-full htw-overflow-auto"
2169
+ }, null, 8, ["story", "variant"]))
2170
+ ])
2171
+ ]),
2172
+ last: withCtx(() => [
2173
+ createVNode(StorySourceCode, {
2174
+ variant: unref(storyStore).currentVariant,
2175
+ class: "htw-h-full"
2176
+ }, null, 8, ["variant"])
2177
+ ]),
2178
+ _: 1
2179
+ }));
2180
+ };
2181
+ }
2182
+ });
2183
+ const _hoisted_1 = {
2184
+ key: 1,
2185
+ class: "htw-h-full"
2186
+ };
2187
+ const _hoisted_2 = {
2188
+ key: 0,
2189
+ class: "htw-h-full htw-overflow-auto"
2190
+ };
2191
+ const _sfc_main = /* @__PURE__ */ defineComponent({
2192
+ name: "StoryView",
2193
+ setup(__props) {
2194
+ const storyStore = useStoryStore();
2195
+ const router = useRouter();
2196
+ const route = useRoute();
2197
+ watch(() => storyStore.currentVariant, (value) => {
2198
+ if (value) {
2199
+ storyStore.currentStory.lastSelectedVariant = value;
2200
+ }
2201
+ }, {
2202
+ immediate: true
2203
+ });
2204
+ watch(() => [storyStore.currentStory, storyStore.currentVariant], () => {
2205
+ var _a, _b;
2206
+ if (!storyStore.currentVariant) {
2207
+ if ((_a = storyStore.currentStory) == null ? void 0 : _a.lastSelectedVariant) {
2208
+ setVariant(storyStore.currentStory.lastSelectedVariant.id);
2209
+ return;
2210
+ }
2211
+ if (((_b = storyStore.currentStory) == null ? void 0 : _b.variants.length) === 1) {
2212
+ setVariant(storyStore.currentStory.variants[0].id);
2213
+ }
2214
+ }
2215
+ }, {
2216
+ immediate: true
2217
+ });
2218
+ function setVariant(variantId) {
2219
+ router.replace(__spreadProps(__spreadValues({}, route), {
2220
+ query: __spreadProps(__spreadValues({}, route.query), {
2221
+ variantId
2222
+ })
2223
+ }));
2224
+ }
2225
+ return (_ctx, _cache) => {
2226
+ return !unref(storyStore).currentStory ? (openBlock(), createBlock(BaseEmpty, { key: 0 }, {
2227
+ default: withCtx(() => [
2228
+ createVNode(unref(Icon), {
2229
+ icon: "carbon:software-resource-resource",
2230
+ class: "htw-w-16 htw-h-16 htw-opacity-50"
2231
+ })
2232
+ ]),
2233
+ _: 1
2234
+ })) : (openBlock(), createElementBlock("div", _hoisted_1, [
2235
+ unref(storyStore).currentStory.docsOnly ? (openBlock(), createElementBlock("div", _hoisted_2, [
2236
+ createVNode(_sfc_main$9, {
2237
+ story: unref(storyStore).currentStory,
2238
+ class: "md:htw-p-12 htw-w-full md:htw-max-w-[600px] lg:htw-max-w-[800px] xl:htw-max-w-[900px]"
2239
+ }, null, 8, ["story"])
2240
+ ])) : unref(isMobile) ? (openBlock(), createBlock(StoryViewer, { key: 1 })) : (openBlock(), createBlock(BaseSplitPane, {
2241
+ key: 2,
2242
+ "save-id": "story-main",
2243
+ min: 30,
2244
+ max: 95,
2245
+ "default-split": 75,
2246
+ class: "htw-h-full"
2247
+ }, {
2248
+ first: withCtx(() => [
2249
+ createVNode(StoryViewer)
2250
+ ]),
2251
+ last: withCtx(() => [
2252
+ createVNode(_sfc_main$1)
2253
+ ]),
2254
+ _: 1
2255
+ }))
2256
+ ]));
2257
+ };
2258
+ }
2259
+ });
2260
+ export { _sfc_main as default };