likec4 1.59.4 → 1.61.0

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 (186) hide show
  1. package/README.md +2 -0
  2. package/__app__/codegen/react.mjs +4 -10
  3. package/__app__/codegen/webcomponent.mjs +6 -131
  4. package/__app__/index.html +15 -15
  5. package/__app__/src/aichat/index.mjs +11 -7
  6. package/__app__/src/chunks/AIChat.mjs +1355 -739
  7. package/__app__/src/chunks/ErrorComponent.mjs +444 -0
  8. package/__app__/src/chunks/Header.mjs +269 -0
  9. package/__app__/src/chunks/ViewReact.mjs +438 -0
  10. package/__app__/src/chunks/find.mjs +38 -0
  11. package/__app__/src/chunks/hooks.mjs +158 -472
  12. package/__app__/src/chunks/libs/@tabler/icons-react.mjs +340 -0
  13. package/__app__/src/chunks/libs/@tanstack-ai.mjs +11841 -1417
  14. package/__app__/src/chunks/libs/@tanstack.mjs +5110 -2404
  15. package/__app__/src/chunks/libs/fast-equals.mjs +507 -214
  16. package/__app__/src/chunks/libs/html-to-image.mjs +613 -0
  17. package/__app__/src/chunks/libs/nanostores.mjs +170 -0
  18. package/__app__/src/chunks/libs/react-resizable-panels.mjs +2792 -0
  19. package/__app__/src/chunks/react.mjs +22 -0
  20. package/__app__/src/chunks/rolldown-runtime.mjs +16 -29
  21. package/__app__/src/chunks/router.mjs +106 -0
  22. package/__app__/src/chunks/scope.mjs +106 -0
  23. package/__app__/src/chunks/searchParams.mjs +29 -0
  24. package/__app__/src/chunks/single-index.mjs +465 -0
  25. package/__app__/src/chunks/styled-system.mjs +1826 -2528
  26. package/__app__/src/chunks/useAsync.mjs +69 -0
  27. package/__app__/src/chunks/useSyncedRef.mjs +16 -0
  28. package/__app__/src/components/ColorSchemeToggle.mjs +124 -0
  29. package/__app__/src/components/CopyToClipboard.mjs +53 -0
  30. package/__app__/src/components/ErrorComponent.mjs +1 -0
  31. package/__app__/src/components/NavigationPanel.mjs +63 -0
  32. package/__app__/src/components/NotFound.mjs +155 -0
  33. package/__app__/src/components/ViewOutlet.mjs +9 -0
  34. package/__app__/src/components/model-diff/CompareModelProvider.mjs +44 -0
  35. package/__app__/src/components/model-diff/ModelDiffPanel.mjs +179 -0
  36. package/__app__/src/components/model-diff/compare-model.mjs +76 -0
  37. package/__app__/src/components/model-diff/state.mjs +45 -0
  38. package/__app__/src/components/search/OverviewSearch.mjs +92 -0
  39. package/__app__/src/components/search/OverviewSearchAdapter.mjs +94 -0
  40. package/__app__/src/components/sidebar/DiagramTree.css.mjs +48 -0
  41. package/__app__/src/components/sidebar/DiagramsTree.mjs +304 -0
  42. package/__app__/src/components/sidebar/Drawer.mjs +178 -0
  43. package/__app__/src/components/sidebar/SidebarBurger.mjs +28 -0
  44. package/__app__/src/components/sidebar/data.mjs +94 -0
  45. package/__app__/src/components/sidebar/state.mjs +16 -0
  46. package/__app__/src/components/view-page/Header.mjs +1 -0
  47. package/__app__/src/components/view-page/SelectProject.mjs +258 -0
  48. package/__app__/src/components/view-page/ShareModal.mjs +111 -0
  49. package/__app__/src/components/view-page/share-modal/AlertLocalhost.mjs +31 -0
  50. package/__app__/src/components/view-page/share-modal/CopyButtonChild.mjs +36 -0
  51. package/__app__/src/components/view-page/share-modal/EmbedPanel.mjs +100 -0
  52. package/__app__/src/components/view-page/share-modal/WebcomponentsPanel.mjs +264 -0
  53. package/__app__/src/components/view-page/state.mjs +17 -0
  54. package/__app__/src/context/LikeC4CustomizationContext.mjs +26 -0
  55. package/__app__/src/context/LikeC4IconRendererContext.mjs +29 -0
  56. package/__app__/src/context/LikeC4ModelContext.mjs +34 -0
  57. package/__app__/src/context/LikeC4ProjectsContext.mjs +40 -0
  58. package/__app__/src/context/ModelDiffsContext.mjs +33 -0
  59. package/__app__/src/context/safeCtx.mjs +14 -0
  60. package/__app__/src/fonts.css +112 -1
  61. package/__app__/src/hooks.mjs +1 -0
  62. package/__app__/src/main.mjs +6 -29151
  63. package/__app__/src/pages/EmbedPage.mjs +93 -0
  64. package/__app__/src/pages/ExportPage.mjs +691 -0
  65. package/__app__/src/pages/ProjectsOverview.mjs +23 -0
  66. package/__app__/src/pages/ViewAsD2.mjs +105 -0
  67. package/__app__/src/pages/ViewAsDot.mjs +65 -0
  68. package/__app__/src/pages/ViewAsMmd.mjs +109 -0
  69. package/__app__/src/pages/ViewAsPuml.mjs +105 -0
  70. package/__app__/src/pages/ViewEditor.mjs +220 -0
  71. package/__app__/src/pages/ViewReact.mjs +1 -0
  72. package/__app__/src/pages/export-layout.mjs +95 -0
  73. package/__app__/src/pages/export-page-params.mjs +9 -0
  74. package/__app__/src/pages/styles.css.mjs +23 -0
  75. package/__app__/src/routeTree.gen.mjs +105 -0
  76. package/__app__/src/router.mjs +1 -0
  77. package/__app__/src/routes/__root.mjs +65 -0
  78. package/__app__/src/routes/index.css.mjs +29 -0
  79. package/__app__/src/routes/index.mjs +32 -0
  80. package/__app__/src/routes/project._projectId/-components.mjs +100 -0
  81. package/__app__/src/routes/project._projectId/embed._viewId.mjs +5 -0
  82. package/__app__/src/routes/project._projectId/export._viewId.mjs +24 -0
  83. package/__app__/src/routes/project._projectId/index.mjs +14 -0
  84. package/__app__/src/routes/project._projectId/route.mjs +93 -0
  85. package/__app__/src/routes/project._projectId/view._viewId.d2.mjs +34 -0
  86. package/__app__/src/routes/project._projectId/view._viewId.dot.mjs +41 -0
  87. package/__app__/src/routes/project._projectId/view._viewId.index.mjs +7 -0
  88. package/__app__/src/routes/project._projectId/view._viewId.mjs +23 -0
  89. package/__app__/src/routes/project._projectId/view._viewId.mmd.mjs +39 -0
  90. package/__app__/src/routes/project._projectId/view._viewId.puml.mjs +34 -0
  91. package/__app__/src/routes/projects.mjs +36 -0
  92. package/__app__/src/routes/single-index.mjs +1 -0
  93. package/__app__/src/routes/webcomponent._.mjs +94 -0
  94. package/__app__/src/style.css +18497 -1
  95. package/config/schema.json +146 -97
  96. package/dist/app/render-view-client.css +1 -1
  97. package/dist/app/render-view-client.js +394 -238
  98. package/dist/chunks/enableServer.mjs +1 -1
  99. package/dist/chunks/filenames.mjs +25 -17
  100. package/dist/chunks/generate-likec4.mjs +5 -0
  101. package/dist/chunks/index.d.mts +255 -194
  102. package/dist/chunks/index2.d.mts +8246 -3610
  103. package/dist/chunks/libs/@chenglou/pretext.mjs +9 -0
  104. package/dist/chunks/libs/@chevrotain/gast.mjs +27 -1
  105. package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +81 -9
  106. package/dist/chunks/libs/@logtape/logtape.mjs +5 -4
  107. package/dist/chunks/libs/@lume/kiwi.mjs +1 -1
  108. package/dist/chunks/libs/@ts-graphviz/common.d.mts +2 -4
  109. package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -1
  110. package/dist/chunks/libs/birpc.mjs +1 -1
  111. package/dist/chunks/libs/chevrotain-allstar.mjs +2 -2
  112. package/dist/chunks/libs/chevrotain.mjs +88 -36
  113. package/dist/chunks/libs/clone.mjs +1 -0
  114. package/dist/chunks/libs/eventemitter3.mjs +1 -1
  115. package/dist/chunks/libs/fast-equals.mjs +1 -0
  116. package/dist/chunks/libs/fontkit.mjs +1 -0
  117. package/dist/chunks/libs/json5.mjs +4 -4
  118. package/dist/chunks/libs/langium.d.mts +6707 -6715
  119. package/dist/chunks/libs/langium.mjs +16 -24
  120. package/dist/chunks/libs/merge-error-cause.mjs +1 -1
  121. package/dist/chunks/libs/p-limit.mjs +1 -0
  122. package/dist/chunks/libs/p-queue.mjs +1 -1
  123. package/dist/chunks/libs/package-manager-detector.mjs +1 -1
  124. package/dist/chunks/libs/pako.mjs +1 -1
  125. package/dist/chunks/libs/pathe.mjs +1 -1
  126. package/dist/chunks/libs/pretty-ms.mjs +1 -1
  127. package/dist/chunks/libs/remeda.mjs +1 -1
  128. package/dist/chunks/libs/ufo.mjs +1 -1
  129. package/dist/chunks/libs/unstorage.mjs +1 -1
  130. package/dist/chunks/libs/which.mjs +1 -1
  131. package/dist/chunks/node.mjs +111 -77
  132. package/dist/chunks/rolldown-runtime.mjs +1 -1
  133. package/dist/chunks/sequence-view.mjs +1 -1
  134. package/dist/chunks/vite-plugin.mjs +185 -166
  135. package/dist/cli/index.mjs +254 -1306
  136. package/dist/config/index.d.mts +66 -5
  137. package/dist/config/index.mjs +1 -1
  138. package/dist/generators/likec4.d.mts +6530 -0
  139. package/dist/generators/likec4.mjs +1 -0
  140. package/dist/index.d.mts +2 -4
  141. package/dist/model/index.d.mts +0 -7
  142. package/dist/vite-plugin/index.d.mts +83 -58
  143. package/dist/vite-plugin/index.mjs +1 -1
  144. package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +8 -0
  145. package/dist/vite-plugin/internal/index.d.mts +92 -17
  146. package/dist/vite-plugin/internal/index.mjs +225 -126
  147. package/generators/likec4/package.json +4 -0
  148. package/package.json +134 -122
  149. package/react/index.d.mts +7496 -26659
  150. package/react/index.mjs +533 -63936
  151. package/react/rolldown-runtime-CfRud99p.js +1 -0
  152. package/skills/likec4-dsl/SKILL.md +474 -0
  153. package/skills/likec4-dsl/evals/evals-public.json +207 -0
  154. package/skills/likec4-dsl/evals/grading-spec.json +603 -0
  155. package/skills/likec4-dsl/references/bridge-leanix-drawio.md +42 -0
  156. package/skills/likec4-dsl/references/cli.md +168 -0
  157. package/skills/likec4-dsl/references/configuration.md +266 -0
  158. package/skills/likec4-dsl/references/deployment.md +160 -0
  159. package/skills/likec4-dsl/references/diffs.md +52 -0
  160. package/skills/likec4-dsl/references/dynamic-views.md +455 -0
  161. package/skills/likec4-dsl/references/examples.md +370 -0
  162. package/skills/likec4-dsl/references/identifier-validity.md +90 -0
  163. package/skills/likec4-dsl/references/include-predicates-wildcards.md +180 -0
  164. package/skills/likec4-dsl/references/model.md +182 -0
  165. package/skills/likec4-dsl/references/predicates.md +123 -0
  166. package/skills/likec4-dsl/references/relationships-bidirectional.md +176 -0
  167. package/skills/likec4-dsl/references/specification.md +79 -0
  168. package/skills/likec4-dsl/references/style-tokens-colors.md +150 -0
  169. package/skills/likec4-dsl/references/troubleshooting.md +101 -0
  170. package/skills/likec4-dsl/references/views.md +329 -0
  171. package/vite-plugin-modules.d.ts +126 -51
  172. package/__app__/src/chunks/LikeC4Styles.mjs +0 -2306
  173. package/__app__/src/chunks/ProjectsOverview.mjs +0 -537
  174. package/__app__/src/chunks/es.mjs +0 -439
  175. package/__app__/src/chunks/libs/@floating-ui.mjs +0 -2532
  176. package/__app__/src/chunks/libs/@mantine.mjs +0 -13868
  177. package/__app__/src/chunks/libs/@xstate/react.mjs +0 -2015
  178. package/__app__/src/chunks/libs/@xyflow/react.mjs +0 -5367
  179. package/__app__/src/chunks/libs/bezier-js.mjs +0 -1007
  180. package/__app__/src/chunks/libs/d3.mjs +0 -2817
  181. package/__app__/src/chunks/libs/framer.mjs +0 -5926
  182. package/__app__/src/chunks/libs/zod.mjs +0 -3176
  183. package/dist/chunks/libs/@chevrotain/types.d.mts +0 -108
  184. package/dist/chunks/libs/picomatch.mjs +0 -1
  185. package/dist/chunks/libs/zod.d.mts +0 -3840
  186. package/dist/chunks/libs/zod.mjs +0 -65
@@ -1,439 +0,0 @@
1
- import "./rolldown-runtime.mjs";
2
- //#region ../../node_modules/.pnpm/html-to-image@1.11.11/node_modules/html-to-image/es/util.js
3
- function resolveUrl(e, t) {
4
- if (e.match(/^[a-z]+:\/\//i)) return e;
5
- if (e.match(/^\/\//)) return window.location.protocol + e;
6
- if (e.match(/^[a-z]+:/i)) return e;
7
- let n = document.implementation.createHTMLDocument(), r = n.createElement("base"), i = n.createElement("a");
8
- return n.head.appendChild(r), n.body.appendChild(i), t && (r.href = t), i.href = e, i.href;
9
- }
10
- var e = (() => {
11
- let e = 0, random = () => `0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4);
12
- return () => (e += 1, `u${random()}${e}`);
13
- })();
14
- function toArray(e) {
15
- let t = [];
16
- for (let n = 0, r = e.length; n < r; n++) t.push(e[n]);
17
- return t;
18
- }
19
- function px(e, t) {
20
- let n = (e.ownerDocument.defaultView || window).getComputedStyle(e).getPropertyValue(t);
21
- return n ? parseFloat(n.replace("px", "")) : 0;
22
- }
23
- function getNodeWidth(e) {
24
- let t = px(e, "border-left-width"), n = px(e, "border-right-width");
25
- return e.clientWidth + t + n;
26
- }
27
- function getNodeHeight(e) {
28
- let t = px(e, "border-top-width"), n = px(e, "border-bottom-width");
29
- return e.clientHeight + t + n;
30
- }
31
- function getImageSize(e, t = {}) {
32
- return {
33
- width: t.width || getNodeWidth(e),
34
- height: t.height || getNodeHeight(e)
35
- };
36
- }
37
- function getPixelRatio() {
38
- let e, t;
39
- try {
40
- t = process;
41
- } catch {}
42
- let n = t && t.env ? t.env.devicePixelRatio : null;
43
- return n && (e = parseInt(n, 10), Number.isNaN(e) && (e = 1)), e || window.devicePixelRatio || 1;
44
- }
45
- var t = 16384;
46
- function checkCanvasDimensions(e) {
47
- (e.width > t || e.height > t) && (e.width > t && e.height > t ? e.width > e.height ? (e.height *= t / e.width, e.width = t) : (e.width *= t / e.height, e.height = t) : e.width > t ? (e.height *= t / e.width, e.width = t) : (e.width *= t / e.height, e.height = t));
48
- }
49
- function canvasToBlob(e, t = {}) {
50
- return e.toBlob ? new Promise((n) => {
51
- e.toBlob(n, t.type ? t.type : "image/png", t.quality ? t.quality : 1);
52
- }) : new Promise((n) => {
53
- let r = window.atob(e.toDataURL(t.type ? t.type : void 0, t.quality ? t.quality : void 0).split(",")[1]), i = r.length, a = new Uint8Array(i);
54
- for (let e = 0; e < i; e += 1) a[e] = r.charCodeAt(e);
55
- n(new Blob([a], { type: t.type ? t.type : "image/png" }));
56
- });
57
- }
58
- function createImage(e) {
59
- return new Promise((t, n) => {
60
- let r = new Image();
61
- r.decode = () => t(r), r.onload = () => t(r), r.onerror = n, r.crossOrigin = "anonymous", r.decoding = "async", r.src = e;
62
- });
63
- }
64
- async function svgToDataURL(e) {
65
- return Promise.resolve().then(() => new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then((e) => `data:image/svg+xml;charset=utf-8,${e}`);
66
- }
67
- async function nodeToDataURL(e, t, n) {
68
- let r = "http://www.w3.org/2000/svg", i = document.createElementNS(r, "svg"), a = document.createElementNS(r, "foreignObject");
69
- return i.setAttribute("width", `${t}`), i.setAttribute("height", `${n}`), i.setAttribute("viewBox", `0 0 ${t} ${n}`), a.setAttribute("width", "100%"), a.setAttribute("height", "100%"), a.setAttribute("x", "0"), a.setAttribute("y", "0"), a.setAttribute("externalResourcesRequired", "true"), i.appendChild(a), a.appendChild(e), svgToDataURL(i);
70
- }
71
- var isInstanceOfElement = (e, t) => {
72
- if (e instanceof t) return !0;
73
- let n = Object.getPrototypeOf(e);
74
- return n === null ? !1 : n.constructor.name === t.name || isInstanceOfElement(n, t);
75
- };
76
- //#endregion
77
- //#region ../../node_modules/.pnpm/html-to-image@1.11.11/node_modules/html-to-image/es/clone-pseudos.js
78
- function formatCSSText(e) {
79
- let t = e.getPropertyValue("content");
80
- return `${e.cssText} content: '${t.replace(/'|"/g, "")}';`;
81
- }
82
- function formatCSSProperties(e) {
83
- return toArray(e).map((t) => `${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t) ? " !important" : ""};`).join(" ");
84
- }
85
- function getPseudoElementStyle(e, t, n) {
86
- let r = `.${e}:${t}`, i = n.cssText ? formatCSSText(n) : formatCSSProperties(n);
87
- return document.createTextNode(`${r}{${i}}`);
88
- }
89
- function clonePseudoElement(t, n, r) {
90
- let i = window.getComputedStyle(t, r), a = i.getPropertyValue("content");
91
- if (a === "" || a === "none") return;
92
- let o = e();
93
- try {
94
- n.className = `${n.className} ${o}`;
95
- } catch {
96
- return;
97
- }
98
- let s = document.createElement("style");
99
- s.appendChild(getPseudoElementStyle(o, r, i)), n.appendChild(s);
100
- }
101
- function clonePseudoElements(e, t) {
102
- clonePseudoElement(e, t, ":before"), clonePseudoElement(e, t, ":after");
103
- }
104
- //#endregion
105
- //#region ../../node_modules/.pnpm/html-to-image@1.11.11/node_modules/html-to-image/es/mimes.js
106
- var n = "application/font-woff", r = "image/jpeg", i = {
107
- woff: n,
108
- woff2: n,
109
- ttf: "application/font-truetype",
110
- eot: "application/vnd.ms-fontobject",
111
- png: "image/png",
112
- jpg: r,
113
- jpeg: r,
114
- gif: "image/gif",
115
- tiff: "image/tiff",
116
- svg: "image/svg+xml",
117
- webp: "image/webp"
118
- };
119
- function getExtension(e) {
120
- let t = /\.([^./]*?)$/g.exec(e);
121
- return t ? t[1] : "";
122
- }
123
- function getMimeType(e) {
124
- return i[getExtension(e).toLowerCase()] || "";
125
- }
126
- //#endregion
127
- //#region ../../node_modules/.pnpm/html-to-image@1.11.11/node_modules/html-to-image/es/dataurl.js
128
- function getContentFromDataUrl(e) {
129
- return e.split(/,/)[1];
130
- }
131
- function isDataUrl(e) {
132
- return e.search(/^(data:)/) !== -1;
133
- }
134
- function makeDataUrl(e, t) {
135
- return `data:${t};base64,${e}`;
136
- }
137
- async function fetchAsDataURL(e, t, n) {
138
- let r = await fetch(e, t);
139
- if (r.status === 404) throw Error(`Resource "${r.url}" not found`);
140
- let i = await r.blob();
141
- return new Promise((e, t) => {
142
- let a = new FileReader();
143
- a.onerror = t, a.onloadend = () => {
144
- try {
145
- e(n({
146
- res: r,
147
- result: a.result
148
- }));
149
- } catch (e) {
150
- t(e);
151
- }
152
- }, a.readAsDataURL(i);
153
- });
154
- }
155
- var a = {};
156
- function getCacheKey(e, t, n) {
157
- let r = e.replace(/\?.*/, "");
158
- return n && (r = e), /ttf|otf|eot|woff2?/i.test(r) && (r = r.replace(/.*\//, "")), t ? `[${t}]${r}` : r;
159
- }
160
- async function resourceToDataURL(e, t, n) {
161
- let r = getCacheKey(e, t, n.includeQueryParams);
162
- if (a[r] != null) return a[r];
163
- n.cacheBust && (e += (/\?/.test(e) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
164
- let i;
165
- try {
166
- i = makeDataUrl(await fetchAsDataURL(e, n.fetchRequestInit, ({ res: e, result: n }) => (t ||= e.headers.get("Content-Type") || "", getContentFromDataUrl(n))), t);
167
- } catch (t) {
168
- i = n.imagePlaceholder || "";
169
- let r = `Failed to fetch resource: ${e}`;
170
- t && (r = typeof t == "string" ? t : t.message), r && console.warn(r);
171
- }
172
- return a[r] = i, i;
173
- }
174
- //#endregion
175
- //#region ../../node_modules/.pnpm/html-to-image@1.11.11/node_modules/html-to-image/es/clone-node.js
176
- async function cloneCanvasElement(e) {
177
- let t = e.toDataURL();
178
- return t === "data:," ? e.cloneNode(!1) : createImage(t);
179
- }
180
- async function cloneVideoElement(e, t) {
181
- if (e.currentSrc) {
182
- let t = document.createElement("canvas"), n = t.getContext("2d");
183
- return t.width = e.clientWidth, t.height = e.clientHeight, n?.drawImage(e, 0, 0, t.width, t.height), createImage(t.toDataURL());
184
- }
185
- let n = e.poster;
186
- return createImage(await resourceToDataURL(n, getMimeType(n), t));
187
- }
188
- async function cloneIFrameElement(e) {
189
- try {
190
- if (e?.contentDocument?.body) return await cloneNode(e.contentDocument.body, {}, !0);
191
- } catch {}
192
- return e.cloneNode(!1);
193
- }
194
- async function cloneSingleNode(e, t) {
195
- return isInstanceOfElement(e, HTMLCanvasElement) ? cloneCanvasElement(e) : isInstanceOfElement(e, HTMLVideoElement) ? cloneVideoElement(e, t) : isInstanceOfElement(e, HTMLIFrameElement) ? cloneIFrameElement(e) : e.cloneNode(!1);
196
- }
197
- var isSlotElement = (e) => e.tagName != null && e.tagName.toUpperCase() === "SLOT";
198
- async function cloneChildren(e, t, n) {
199
- let r = [];
200
- return r = isSlotElement(e) && e.assignedNodes ? toArray(e.assignedNodes()) : isInstanceOfElement(e, HTMLIFrameElement) && e.contentDocument?.body ? toArray(e.contentDocument.body.childNodes) : toArray((e.shadowRoot ?? e).childNodes), r.length === 0 || isInstanceOfElement(e, HTMLVideoElement) || await r.reduce((e, r) => e.then(() => cloneNode(r, n)).then((e) => {
201
- e && t.appendChild(e);
202
- }), Promise.resolve()), t;
203
- }
204
- function cloneCSSStyle(e, t) {
205
- let n = t.style;
206
- if (!n) return;
207
- let r = window.getComputedStyle(e);
208
- r.cssText ? (n.cssText = r.cssText, n.transformOrigin = r.transformOrigin) : toArray(r).forEach((i) => {
209
- let a = r.getPropertyValue(i);
210
- i === "font-size" && a.endsWith("px") && (a = `${Math.floor(parseFloat(a.substring(0, a.length - 2))) - .1}px`), isInstanceOfElement(e, HTMLIFrameElement) && i === "display" && a === "inline" && (a = "block"), i === "d" && t.getAttribute("d") && (a = `path(${t.getAttribute("d")})`), n.setProperty(i, a, r.getPropertyPriority(i));
211
- });
212
- }
213
- function cloneInputValue(e, t) {
214
- isInstanceOfElement(e, HTMLTextAreaElement) && (t.innerHTML = e.value), isInstanceOfElement(e, HTMLInputElement) && t.setAttribute("value", e.value);
215
- }
216
- function cloneSelectValue(e, t) {
217
- if (isInstanceOfElement(e, HTMLSelectElement)) {
218
- let n = t, r = Array.from(n.children).find((t) => e.value === t.getAttribute("value"));
219
- r && r.setAttribute("selected", "");
220
- }
221
- }
222
- function decorate(e, t) {
223
- return isInstanceOfElement(t, Element) && (cloneCSSStyle(e, t), clonePseudoElements(e, t), cloneInputValue(e, t), cloneSelectValue(e, t)), t;
224
- }
225
- async function ensureSVGSymbols(e, t) {
226
- let n = e.querySelectorAll ? e.querySelectorAll("use") : [];
227
- if (n.length === 0) return e;
228
- let r = {};
229
- for (let i = 0; i < n.length; i++) {
230
- let a = n[i].getAttribute("xlink:href");
231
- if (a) {
232
- let n = e.querySelector(a), i = document.querySelector(a);
233
- !n && i && !r[a] && (r[a] = await cloneNode(i, t, !0));
234
- }
235
- }
236
- let i = Object.values(r);
237
- if (i.length) {
238
- let t = "http://www.w3.org/1999/xhtml", n = document.createElementNS(t, "svg");
239
- n.setAttribute("xmlns", t), n.style.position = "absolute", n.style.width = "0", n.style.height = "0", n.style.overflow = "hidden", n.style.display = "none";
240
- let r = document.createElementNS(t, "defs");
241
- n.appendChild(r);
242
- for (let e = 0; e < i.length; e++) r.appendChild(i[e]);
243
- e.appendChild(n);
244
- }
245
- return e;
246
- }
247
- async function cloneNode(e, t, n) {
248
- return !n && t.filter && !t.filter(e) ? null : Promise.resolve(e).then((e) => cloneSingleNode(e, t)).then((n) => cloneChildren(e, n, t)).then((t) => decorate(e, t)).then((e) => ensureSVGSymbols(e, t));
249
- }
250
- //#endregion
251
- //#region ../../node_modules/.pnpm/html-to-image@1.11.11/node_modules/html-to-image/es/embed-resources.js
252
- var o = /url\((['"]?)([^'"]+?)\1\)/g, s = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, c = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
253
- function toRegex(e) {
254
- let t = e.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
255
- return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`, "g");
256
- }
257
- function parseURLs(e) {
258
- let t = [];
259
- return e.replace(o, (e, n, r) => (t.push(r), e)), t.filter((e) => !isDataUrl(e));
260
- }
261
- async function embed(e, t, n, r, i) {
262
- try {
263
- let a = n ? resolveUrl(t, n) : t, o = getMimeType(t), s;
264
- return s = i ? makeDataUrl(await i(a), o) : await resourceToDataURL(a, o, r), e.replace(toRegex(t), `$1${s}$3`);
265
- } catch {}
266
- return e;
267
- }
268
- function filterPreferredFontFormat(e, { preferredFontFormat: t }) {
269
- return t ? e.replace(c, (e) => {
270
- for (;;) {
271
- let [n, , r] = s.exec(e) || [];
272
- if (!r) return "";
273
- if (r === t) return `src: ${n};`;
274
- }
275
- }) : e;
276
- }
277
- function shouldEmbed(e) {
278
- return e.search(o) !== -1;
279
- }
280
- async function embedResources(e, t, n) {
281
- if (!shouldEmbed(e)) return e;
282
- let r = filterPreferredFontFormat(e, n);
283
- return parseURLs(r).reduce((e, r) => e.then((e) => embed(e, r, t, n)), Promise.resolve(r));
284
- }
285
- //#endregion
286
- //#region ../../node_modules/.pnpm/html-to-image@1.11.11/node_modules/html-to-image/es/embed-images.js
287
- async function embedProp(e, t, n) {
288
- let r = t.style?.getPropertyValue(e);
289
- if (r) {
290
- let i = await embedResources(r, null, n);
291
- return t.style.setProperty(e, i, t.style.getPropertyPriority(e)), !0;
292
- }
293
- return !1;
294
- }
295
- async function embedBackground(e, t) {
296
- await embedProp("background", e, t) || await embedProp("background-image", e, t), await embedProp("mask", e, t) || await embedProp("mask-image", e, t);
297
- }
298
- async function embedImageNode(e, t) {
299
- let n = isInstanceOfElement(e, HTMLImageElement);
300
- if ((!n || isDataUrl(e.src)) && (!isInstanceOfElement(e, SVGImageElement) || isDataUrl(e.href.baseVal))) return;
301
- let r = n ? e.src : e.href.baseVal, i = await resourceToDataURL(r, getMimeType(r), t);
302
- await new Promise((t, r) => {
303
- e.onload = t, e.onerror = r;
304
- let a = e;
305
- a.decode &&= t, a.loading === "lazy" && (a.loading = "eager"), n ? (e.srcset = "", e.src = i) : e.href.baseVal = i;
306
- });
307
- }
308
- async function embedChildren(e, t) {
309
- let n = toArray(e.childNodes).map((e) => embedImages(e, t));
310
- await Promise.all(n).then(() => e);
311
- }
312
- async function embedImages(e, t) {
313
- isInstanceOfElement(e, Element) && (await embedBackground(e, t), await embedImageNode(e, t), await embedChildren(e, t));
314
- }
315
- //#endregion
316
- //#region ../../node_modules/.pnpm/html-to-image@1.11.11/node_modules/html-to-image/es/apply-style.js
317
- function applyStyle(e, t) {
318
- let { style: n } = e;
319
- t.backgroundColor && (n.backgroundColor = t.backgroundColor), t.width && (n.width = `${t.width}px`), t.height && (n.height = `${t.height}px`);
320
- let r = t.style;
321
- return r != null && Object.keys(r).forEach((e) => {
322
- n[e] = r[e];
323
- }), e;
324
- }
325
- //#endregion
326
- //#region ../../node_modules/.pnpm/html-to-image@1.11.11/node_modules/html-to-image/es/embed-webfonts.js
327
- var l = {};
328
- async function fetchCSS(e) {
329
- let t = l[e];
330
- return t ?? (t = {
331
- url: e,
332
- cssText: await (await fetch(e)).text()
333
- }, l[e] = t, t);
334
- }
335
- async function embedFonts(e, t) {
336
- let n = e.cssText, r = /url\(["']?([^"')]+)["']?\)/g, i = (n.match(/url\([^)]+\)/g) || []).map(async (i) => {
337
- let a = i.replace(r, "$1");
338
- return a.startsWith("https://") || (a = new URL(a, e.url).href), fetchAsDataURL(a, t.fetchRequestInit, ({ result: e }) => (n = n.replace(i, `url(${e})`), [i, e]));
339
- });
340
- return Promise.all(i).then(() => n);
341
- }
342
- function parseCSS(e) {
343
- if (e == null) return [];
344
- let t = [], n = e.replace(/(\/\*[\s\S]*?\*\/)/gi, ""), r = /* @__PURE__ */ RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
345
- for (;;) {
346
- let e = r.exec(n);
347
- if (e === null) break;
348
- t.push(e[0]);
349
- }
350
- n = n.replace(r, "");
351
- let i = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi, a = /* @__PURE__ */ RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})", "gi");
352
- for (;;) {
353
- let e = i.exec(n);
354
- if (e === null) {
355
- if (e = a.exec(n), e === null) break;
356
- i.lastIndex = a.lastIndex;
357
- } else a.lastIndex = i.lastIndex;
358
- t.push(e[0]);
359
- }
360
- return t;
361
- }
362
- async function getCSSRules(e, t) {
363
- let n = [], r = [];
364
- return e.forEach((n) => {
365
- if ("cssRules" in n) try {
366
- toArray(n.cssRules || []).forEach((e, i) => {
367
- if (e.type === CSSRule.IMPORT_RULE) {
368
- let a = i + 1, o = e.href, s = fetchCSS(o).then((e) => embedFonts(e, t)).then((e) => parseCSS(e).forEach((e) => {
369
- try {
370
- n.insertRule(e, e.startsWith("@import") ? a += 1 : n.cssRules.length);
371
- } catch (t) {
372
- console.error("Error inserting rule from remote css", {
373
- rule: e,
374
- error: t
375
- });
376
- }
377
- })).catch((e) => {
378
- console.error("Error loading remote css", e.toString());
379
- });
380
- r.push(s);
381
- }
382
- });
383
- } catch (i) {
384
- let a = e.find((e) => e.href == null) || document.styleSheets[0];
385
- n.href != null && r.push(fetchCSS(n.href).then((e) => embedFonts(e, t)).then((e) => parseCSS(e).forEach((e) => {
386
- a.insertRule(e, n.cssRules.length);
387
- })).catch((e) => {
388
- console.error("Error loading remote stylesheet", e);
389
- })), console.error("Error inlining remote css file", i);
390
- }
391
- }), Promise.all(r).then(() => (e.forEach((e) => {
392
- if ("cssRules" in e) try {
393
- toArray(e.cssRules || []).forEach((e) => {
394
- n.push(e);
395
- });
396
- } catch (t) {
397
- console.error(`Error while reading CSS rules from ${e.href}`, t);
398
- }
399
- }), n));
400
- }
401
- function getWebFontRules(e) {
402
- return e.filter((e) => e.type === CSSRule.FONT_FACE_RULE).filter((e) => shouldEmbed(e.style.getPropertyValue("src")));
403
- }
404
- async function parseWebFontRules(e, t) {
405
- if (e.ownerDocument == null) throw Error("Provided element is not within a Document");
406
- return getWebFontRules(await getCSSRules(toArray(e.ownerDocument.styleSheets), t));
407
- }
408
- async function getWebFontCSS(e, t) {
409
- let n = await parseWebFontRules(e, t);
410
- return (await Promise.all(n.map((e) => {
411
- let n = e.parentStyleSheet ? e.parentStyleSheet.href : null;
412
- return embedResources(e.cssText, n, t);
413
- }))).join("\n");
414
- }
415
- async function embedWebFonts(e, t) {
416
- let n = t.fontEmbedCSS == null ? t.skipFonts ? null : await getWebFontCSS(e, t) : t.fontEmbedCSS;
417
- if (n) {
418
- let t = document.createElement("style"), r = document.createTextNode(n);
419
- t.appendChild(r), e.firstChild ? e.insertBefore(t, e.firstChild) : e.appendChild(t);
420
- }
421
- }
422
- //#endregion
423
- //#region ../../node_modules/.pnpm/html-to-image@1.11.11/node_modules/html-to-image/es/index.js
424
- async function toSvg(e, t = {}) {
425
- let { width: n, height: r } = getImageSize(e, t), i = await cloneNode(e, t, !0);
426
- return await embedWebFonts(i, t), await embedImages(i, t), applyStyle(i, t), await nodeToDataURL(i, n, r);
427
- }
428
- async function toCanvas(e, t = {}) {
429
- let { width: n, height: r } = getImageSize(e, t), i = await createImage(await toSvg(e, t)), a = document.createElement("canvas"), o = a.getContext("2d"), s = t.pixelRatio || getPixelRatio(), c = t.canvasWidth || n, l = t.canvasHeight || r;
430
- return a.width = c * s, a.height = l * s, t.skipAutoScale || checkCanvasDimensions(a), a.style.width = `${c}`, a.style.height = `${l}`, t.backgroundColor && (o.fillStyle = t.backgroundColor, o.fillRect(0, 0, a.width, a.height)), o.drawImage(i, 0, 0, a.width, a.height), a;
431
- }
432
- async function toJpeg(e, t = {}) {
433
- return (await toCanvas(e, t)).toDataURL("image/jpeg", t.quality || 1);
434
- }
435
- async function toBlob(e, t = {}) {
436
- return await canvasToBlob(await toCanvas(e, t));
437
- }
438
- //#endregion
439
- export { toBlob, toJpeg };