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