From ef99bc6f1beb2b39da73cfeb4ab975fbc0f4f807 Mon Sep 17 00:00:00 2001 From: plantain-00 Date: Sat, 13 Apr 2024 23:18:51 +0000 Subject: [PATCH] feat: intersection plugin f2a9304ee67a979baf3315c21c4283cb1fbd74fe --- dev/cad-editor/plugins/clip.plugin.tsx | 4 +- dev/cad-editor/plugins/fill-style.plugin.tsx | 4 +- dev/cad-editor/plugins/hatch.plugin.tsx | 7 +- .../plugins/intersection.plugin.tsx | 50 +++++++++++++ dev/cad-editor/plugins/variables.ts | 57 +++++++++++++- main.bundle.js | 2 +- src/utils/bezier.ts | 74 +++++++++++++++++++ src/utils/intersection.ts | 41 +++++++++- src/utils/math.ts | 13 +--- 9 files changed, 232 insertions(+), 20 deletions(-) create mode 100644 dev/cad-editor/plugins/intersection.plugin.tsx diff --git a/dev/cad-editor/plugins/clip.plugin.tsx b/dev/cad-editor/plugins/clip.plugin.tsx index b18c105d..bd49dbac 100644 --- a/dev/cad-editor/plugins/clip.plugin.tsx +++ b/dev/cad-editor/plugins/clip.plugin.tsx @@ -8,11 +8,11 @@ export function getCommand(ctx: PluginContext): Command { const React = ctx.React const icon = ( - + - + diff --git a/dev/cad-editor/plugins/fill-style.plugin.tsx b/dev/cad-editor/plugins/fill-style.plugin.tsx index 2372a958..42152dc7 100644 --- a/dev/cad-editor/plugins/fill-style.plugin.tsx +++ b/dev/cad-editor/plugins/fill-style.plugin.tsx @@ -97,10 +97,10 @@ export function getCommand(ctx: PluginContext): Command { const icon = ( - + - + ) return { diff --git a/dev/cad-editor/plugins/hatch.plugin.tsx b/dev/cad-editor/plugins/hatch.plugin.tsx index 5e910da3..10cf1e6c 100644 --- a/dev/cad-editor/plugins/hatch.plugin.tsx +++ b/dev/cad-editor/plugins/hatch.plugin.tsx @@ -60,6 +60,7 @@ export function getModel(ctx: PluginContext): model.Model { } }) } + const React = ctx.React return { type: 'hatch', ...ctx.fillModel, @@ -172,6 +173,7 @@ export function getModel(ctx: PluginContext): model.Model { }, propertyPanel(content, update, contents) { return { + ref: update(c => { if (isHatchContent(c) && !v) { c.ref = undefined } })} />, ...ctx.getFillContentPropertyPanel(content, update, contents), } }, @@ -215,7 +217,10 @@ export function getCommand(ctx: PluginContext): Command[] { - + + + + ) return [ diff --git a/dev/cad-editor/plugins/intersection.plugin.tsx b/dev/cad-editor/plugins/intersection.plugin.tsx new file mode 100644 index 00000000..3b16d815 --- /dev/null +++ b/dev/cad-editor/plugins/intersection.plugin.tsx @@ -0,0 +1,50 @@ +import type { PluginContext } from './types' +import type { Command } from '../command' +import type * as model from '../model' +import type { GeometryLinesContent } from './geometry-lines.plugin' +import type { PointContent } from './point.plugin' + +export function getCommand(ctx: PluginContext): Command { + const React = ctx.React + const icon = ( + + + + + + + + + ) + return { + name: 'intersection', + execute({ contents, selected }) { + const first = contents[selected[0][0]] + if (!first) return + const firstLines = ctx.getContentModel(first)?.getGeometries?.(first, contents).lines + if (!firstLines) return + const second = contents[selected[1][0]] + if (!second) return + const secondLines = ctx.getContentModel(second)?.getGeometries?.(second, contents).lines + if (!secondLines) return + let points = ctx.deduplicatePosition(ctx.getIntersectionPoints(first, second, contents)) + const lines = Array.from(ctx.iterateGeometryLinesIntersectionLines(firstLines, secondLines)) + const newContents: model.BaseContent[] = [] + if (lines.length > 0) { + points = points.filter(p => !ctx.pointIsOnGeometryLines(p, lines)) + const allLines = ctx.getSeparatedGeometryLines(lines) + newContents.push(...allLines.map(n => ({ type: 'geometry lines', lines: n } as GeometryLinesContent))) + } + newContents.push(...points.map(n => ({ type: 'point', x: n.x, y: n.y } as PointContent))) + if (newContents.length > 0) { + ctx.deleteSelectedContents(contents, selected.map(s => s[0])) + contents.push(...newContents) + } + }, + contentSelectable(content: model.BaseContent, contents: readonly model.BaseContent[]) { + return ctx.contentIsDeletable(content, contents) + }, + selectCount: 2, + icon, + } +} diff --git a/dev/cad-editor/plugins/variables.ts b/dev/cad-editor/plugins/variables.ts index 9e77a526..4bb64a5f 100644 --- a/dev/cad-editor/plugins/variables.ts +++ b/dev/cad-editor/plugins/variables.ts @@ -1824,7 +1824,7 @@ export { `// dev/cad-editor/plugins/clip.plugin.tsx function getCommand(ctx) { const React = ctx.React; - const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("mask", { id: "0" }, /* @__PURE__ */ React.createElement("path", { d: "M 1 1 L 1 100 L 103 100 L 103 1", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "white", stroke: "currentColor", fillRule: "evenodd" }), /* @__PURE__ */ React.createElement("path", { d: "M 91 70 L 91 73 L 91 75 L 90 78 L 90 80 L 89 82 L 88 84 L 86 86 L 85 88 L 83 90 L 81 91 L 79 93 L 77 94 L 75 95 L 73 96 L 71 97 L 68 97 L 66 98 L 64 98 L 61 98 L 59 97 L 57 97 L 54 96 L 52 95 L 50 94 L 48 93 L 46 91 L 44 90 L 43 88 L 41 86 L 40 84 L 39 82 L 38 80 L 37 78 L 37 75 L 36 73 L 36 70 L 36 68 L 37 66 L 37 63 L 38 61 L 39 59 L 40 57 L 41 55 L 43 53 L 44 51 L 46 49 L 48 48 L 50 47 L 52 46 L 54 45 L 57 44 L 59 43 L 61 43 L 64 43 L 66 43 L 68 43 L 71 44 L 73 45 L 75 46 L 77 47 L 79 48 L 81 49 L 83 51 L 85 53 L 86 55 L 88 57 L 89 59 L 90 61 L 90 63 L 91 66 L 91 68 L 91 70", fill: "black" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#0)" }, /* @__PURE__ */ React.createElement("polygon", { points: "83,99 77,64 103,38 67,33 51,1 35,33 1,39 25,64 19,100 51,83", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "currentColor", stroke: "currentColor" }))); + const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("mask", { id: "clip" }, /* @__PURE__ */ React.createElement("path", { d: "M 1 1 L 1 100 L 103 100 L 103 1", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "white", stroke: "currentColor", fillRule: "evenodd" }), /* @__PURE__ */ React.createElement("path", { d: "M 91 70 L 91 73 L 91 75 L 90 78 L 90 80 L 89 82 L 88 84 L 86 86 L 85 88 L 83 90 L 81 91 L 79 93 L 77 94 L 75 95 L 73 96 L 71 97 L 68 97 L 66 98 L 64 98 L 61 98 L 59 97 L 57 97 L 54 96 L 52 95 L 50 94 L 48 93 L 46 91 L 44 90 L 43 88 L 41 86 L 40 84 L 39 82 L 38 80 L 37 78 L 37 75 L 36 73 L 36 70 L 36 68 L 37 66 L 37 63 L 38 61 L 39 59 L 40 57 L 41 55 L 43 53 L 44 51 L 46 49 L 48 48 L 50 47 L 52 46 L 54 45 L 57 44 L 59 43 L 61 43 L 64 43 L 66 43 L 68 43 L 71 44 L 73 45 L 75 46 L 77 47 L 79 48 L 81 49 L 83 51 L 85 53 L 86 55 L 88 57 L 89 59 L 90 61 L 90 63 L 91 66 L 91 68 L 91 70", fill: "black" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#clip)" }, /* @__PURE__ */ React.createElement("polygon", { points: "83,99 77,64 103,38 67,33 51,1 35,33 1,39 25,64 19,100 51,83", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "currentColor", stroke: "currentColor" }))); return { name: "clip", icon, @@ -4444,7 +4444,7 @@ function getModel(ctx) { } function getCommand(ctx) { const React = ctx.React; - const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "5", y: "6", width: "89", height: "39", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("pattern", { id: "1", patternUnits: "userSpaceOnUse", width: "20", height: "20" }, /* @__PURE__ */ React.createElement("path", { d: "M 0 10 L 10 0 M 20 10 L 10 20", strokeWidth: "1", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", fillRule: "evenodd" })), /* @__PURE__ */ React.createElement("rect", { x: "5", y: "55", width: "89", height: "39", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "url(#1)", stroke: "currentColor" })); + const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "5", y: "6", width: "89", height: "39", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("pattern", { id: "fill-style", patternUnits: "userSpaceOnUse", width: "20", height: "20" }, /* @__PURE__ */ React.createElement("path", { d: "M 0 10 L 10 0 M 20 10 L 10 20", strokeWidth: "1", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", fillRule: "evenodd" })), /* @__PURE__ */ React.createElement("rect", { x: "5", y: "55", width: "89", height: "39", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "url(#fill-style)", stroke: "currentColor" })); return { name: "create fill style", selectCount: 0, @@ -4951,6 +4951,7 @@ function getModel(ctx) { }; }); } + const React = ctx.React; return { type: "hatch", ...ctx.fillModel, @@ -5064,6 +5065,11 @@ function getModel(ctx) { }, propertyPanel(content, update, contents) { return { + ref: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.ref !== void 0, readOnly: content.ref === void 0, setValue: (v) => update((c) => { + if (isHatchContent(c) && !v) { + c.ref = void 0; + } + }) }), ...ctx.getFillContentPropertyPanel(content, update, contents) }; }, @@ -5098,7 +5104,7 @@ function isHatchContent(content) { } function getCommand(ctx) { const React = ctx.React; - const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "1,24 100,24", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "1,72 100,72", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "27,1 27,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "75,0 75,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("pattern", { id: "1", patternUnits: "userSpaceOnUse", width: "10", height: "10" }, /* @__PURE__ */ React.createElement("path", { d: "M 0 5 L 5 0 M 10 5 L 5 10", strokeWidth: "1", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", fillRule: "evenodd" })), /* @__PURE__ */ React.createElement("polygon", { points: "75,43 75,72 27,72 27,24 75,24 75,43", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", fill: "url(#1)", stroke: "currentColor" })); + const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "1,24 100,24", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "1,72 100,72", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "27,1 27,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "75,0 75,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("pattern", { id: "hatch", patternUnits: "userSpaceOnUse", width: "10", height: "10" }, /* @__PURE__ */ React.createElement("path", { d: "M 0 5 L 5 0 M 10 5 L 5 10", strokeWidth: "1", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", fillRule: "evenodd" })), /* @__PURE__ */ React.createElement("polygon", { points: "75,43 75,72 27,72 27,24 75,24 75,43", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", fill: "url(#hatch)", stroke: "currentColor" })); return [ { name: "create hatch", @@ -5328,6 +5334,51 @@ export { isImageContent }; `, +`// dev/cad-editor/plugins/intersection.plugin.tsx +function getCommand(ctx) { + const React = ctx.React; + const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "32", cy: "50", r: "32", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "65", cy: "50", r: "32", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("pattern", { id: "intersection", patternUnits: "userSpaceOnUse", width: "10", height: "10" }, /* @__PURE__ */ React.createElement("path", { d: "M 0 5 L 5 0 M 10 5 L 5 10", strokeWidth: "1", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", fillRule: "evenodd" })), /* @__PURE__ */ React.createElement("path", { d: "M 49 78 L 46 77 L 44 75 L 42 73 L 40 71 L 38 69 L 37 66 L 36 64 L 34 61 L 34 58 L 33 56 L 33 53 L 32 50 L 33 47 L 33 44 L 34 42 L 34 39 L 36 36 L 37 34 L 38 31 L 40 29 L 42 27 L 44 25 L 46 23 L 49 22 L 49 22 L 51 23 L 53 25 L 55 27 L 57 29 L 59 31 L 61 34 L 62 36 L 63 39 L 64 42 L 64 44 L 65 47 L 65 50 L 65 53 L 64 56 L 64 58 L 63 61 L 62 64 L 61 66 L 59 69 L 57 71 L 55 73 L 53 75 L 51 77 L 49 78", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", fill: "url(#intersection)", stroke: "currentColor", fillRule: "evenodd" })); + return { + name: "intersection", + execute({ contents, selected }) { + var _a, _b, _c, _d; + const first = contents[selected[0][0]]; + if (!first) + return; + const firstLines = (_b = (_a = ctx.getContentModel(first)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, first, contents).lines; + if (!firstLines) + return; + const second = contents[selected[1][0]]; + if (!second) + return; + const secondLines = (_d = (_c = ctx.getContentModel(second)) == null ? void 0 : _c.getGeometries) == null ? void 0 : _d.call(_c, second, contents).lines; + if (!secondLines) + return; + let points = ctx.deduplicatePosition(ctx.getIntersectionPoints(first, second, contents)); + const lines = Array.from(ctx.iterateGeometryLinesIntersectionLines(firstLines, secondLines)); + const newContents = []; + if (lines.length > 0) { + points = points.filter((p) => !ctx.pointIsOnGeometryLines(p, lines)); + const allLines = ctx.getSeparatedGeometryLines(lines); + newContents.push(...allLines.map((n) => ({ type: "geometry lines", lines: n }))); + } + newContents.push(...points.map((n) => ({ type: "point", x: n.x, y: n.y }))); + if (newContents.length > 0) { + ctx.deleteSelectedContents(contents, selected.map((s) => s[0])); + contents.push(...newContents); + } + }, + contentSelectable(content, contents) { + return ctx.contentIsDeletable(content, contents); + }, + selectCount: 2, + icon + }; +} +export { + getCommand +}; +`, `// dev/cad-editor/plugins/join.plugin.tsx function getCommand(ctx) { const React = ctx.React; diff --git a/main.bundle.js b/main.bundle.js index 9dd2b198..37f94fc8 100644 --- a/main.bundle.js +++ b/main.bundle.js @@ -1,2 +1,2 @@ /*! For license information please see main.bundle.js.LICENSE.txt */ -(()=>{var e={8941:(e,t,n)=>{"use strict";n.d(t,{navigateTo:()=>a,useLocation:()=>l});var r=n(4629),o="positionLastShown",i="positionMax";function a(e,t){var n=t?"replaceState":"pushState",a=Number(sessionStorage.getItem(i))+1;sessionStorage.setItem(i,String(a)),sessionStorage.setItem(o,String(a));var l=(0,r.__assign)((0,r.__assign)({},s()),{state:history.state});history[n](a,"",e),dispatchEvent(new CustomEvent(n,{detail:l}))}function s(){return{path:location.pathname||"/",search:location.search}}function l(e,t){var n=this,i=(0,r.__read)(e.useState((function(){return s()})),2),a=i[0],l=a.path,c=a.search,u=i[1],d=e.useRef(l+c);return e.useEffect((function(){var e,i,a=function(e){return(0,r.__awaiter)(n,void 0,void 0,(function(){var n,o,i,a;return(0,r.__generator)(this,(function(r){switch(r.label){case 0:return n=s(),o=n.path+n.search,d.current===o?[3,3]:(i=!0,(null==t?void 0:t.confirm)?[4,t.confirm("replace")]:[3,2]);case 1:i=r.sent(),r.label=2;case 2:i?(d.current=o,u(n)):(a=e.detail,history.replaceState(a.state,"",a.path+a.search)),r.label=3;case 3:return[2]}}))}))},l=function(){return(0,r.__awaiter)(n,void 0,void 0,(function(){var e,n,o;return(0,r.__generator)(this,(function(r){switch(r.label){case 0:return e=s(),n=e.path+e.search,d.current===n?[3,3]:(o=!0,(null==t?void 0:t.confirm)?[4,t.confirm("push")]:[3,2]);case 1:o=r.sent(),r.label=2;case 2:o?(d.current=n,u(e)):history.back(),r.label=3;case 3:return[2]}}))}))},c=function(){return(0,r.__awaiter)(n,void 0,void 0,(function(){var e,n,i;return(0,r.__generator)(this,(function(r){switch(r.label){case 0:return e=s(),n=e.path+e.search,d.current===n?[3,3]:(i=!0,(null==t?void 0:t.confirm)?[4,t.confirm("pop")]:[3,2]);case 1:i=r.sent(),r.label=2;case 2:i?(sessionStorage.setItem(o,String(history.state)),d.current=n,u(e)):(a=Number(sessionStorage.getItem(o)),history.state>a?history.back():history.state{"use strict";n.d(t,{default:()=>s});var r=n(8645),o=n.n(r),i=n(278),a=n.n(i)()(o());a.push([e.id,"/* PrismJS 1.26.0\nhttps://prismjs.com/download.html#themes=prism-twilight&languages=markup+clike+javascript+jsx+tsx+typescript&plugins=line-numbers+toolbar+copy-to-clipboard */\ncode[class*=language-],pre[class*=language-]{color:#fff;background:0 0;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;text-shadow:0 -.1em .2em #000;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}:not(pre)>code[class*=language-],pre[class*=language-]{background:#141414}pre[class*=language-]{border-radius:.5em;border:.3em solid #545454;box-shadow:1px 1px .5em #000 inset;margin:.5em 0;overflow:auto;padding:1em}pre[class*=language-]::-moz-selection{background:#27292a}pre[class*=language-]::selection{background:#27292a}code[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection{text-shadow:none;background:hsla(0,0%,93%,.15)}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{text-shadow:none;background:hsla(0,0%,93%,.15)}:not(pre)>code[class*=language-]{border-radius:.3em;border:.13em solid #545454;box-shadow:1px 1px .3em -.1em #000 inset;padding:.15em .2em .05em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#777}.token.punctuation{opacity:.7}.token.namespace{opacity:.7}.token.boolean,.token.deleted,.token.number,.token.tag{color:#ce6849}.token.builtin,.token.constant,.token.keyword,.token.property,.token.selector,.token.symbol{color:#f9ed99}.language-css .token.string,.style .token.string,.token.attr-name,.token.attr-value,.token.char,.token.entity,.token.inserted,.token.operator,.token.string,.token.url,.token.variable{color:#909e6a}.token.atrule{color:#7385a5}.token.important,.token.regex{color:#e8c062}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.language-markup .token.attr-name,.language-markup .token.punctuation,.language-markup .token.tag{color:#ac885c}.token{position:relative;z-index:1}.line-highlight.line-highlight{background:hsla(0,0%,33%,.25);background:linear-gradient(to right,hsla(0,0%,33%,.1) 70%,hsla(0,0%,33%,0));border-bottom:1px dashed #545454;border-top:1px dashed #545454;margin-top:.75em;z-index:0}.line-highlight.line-highlight:before,.line-highlight.line-highlight[data-end]:after{background-color:#8693a6;color:#f4f1ef}\npre[class*=language-].line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}pre[class*=language-].line-numbers>code{position:relative;white-space:inherit}.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:0;font-size:100%;left:-3.8em;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.line-numbers-rows>span{display:block;counter-increment:linenumber}.line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}\ndiv.code-toolbar{position:relative}div.code-toolbar>.toolbar{position:absolute;z-index:10;top:.3em;right:.2em;transition:opacity .3s ease-in-out;opacity:0}div.code-toolbar:hover>.toolbar{opacity:1}div.code-toolbar:focus-within>.toolbar{opacity:1}div.code-toolbar>.toolbar>.toolbar-item{display:inline-block}div.code-toolbar>.toolbar>.toolbar-item>a{cursor:pointer}div.code-toolbar>.toolbar>.toolbar-item>button{background:0 0;border:0;color:inherit;font:inherit;line-height:normal;overflow:visible;padding:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}div.code-toolbar>.toolbar>.toolbar-item>a,div.code-toolbar>.toolbar>.toolbar-item>button,div.code-toolbar>.toolbar>.toolbar-item>span{color:#bbb;font-size:.8em;padding:0 .5em;background:#f5f2f0;background:rgba(224,224,224,.2);box-shadow:0 2px 0 0 rgba(0,0,0,.2);border-radius:.5em}div.code-toolbar>.toolbar>.toolbar-item>a:focus,div.code-toolbar>.toolbar>.toolbar-item>a:hover,div.code-toolbar>.toolbar>.toolbar-item>button:focus,div.code-toolbar>.toolbar>.toolbar-item>button:hover,div.code-toolbar>.toolbar>.toolbar-item>span:focus,div.code-toolbar>.toolbar>.toolbar-item>span:hover{color:inherit;text-decoration:none}\n",""]);const s=a},278:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",r=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),r&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),r&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,r,o,i){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(r)for(var s=0;s0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=i),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),t.push(u))}},t}},8645:e=>{"use strict";e.exports=function(e){return e[1]}},5230:e=>{"use strict";function t(e,t,r){r=r||2;var i,a,s,l,d,p,h,g=t&&t.length,m=g?t[0]*r:e.length,y=n(e,0,m,r,!0),v=[];if(!y||y.next===y.prev)return v;if(g&&(y=function(e,t,r,o){var i,a,s,l=[];for(i=0,a=t.length;i80*r){i=s=e[0],a=l=e[1];for(var x=r;xs&&(s=d),p>l&&(l=p);h=0!==(h=Math.max(s-i,l-a))?32767/h:0}return o(y,v,r,i,a,h,0),v}function n(e,t,n,r,o){var i,a;if(o===_(e,t,n,r)>0)for(i=t;i=t;i-=r)a=P(i,e[i],e[i+1],a);return a&&y(a,a.next)&&(k(a),a=a.next),a}function r(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!y(r,r.next)&&0!==m(r.prev,r,r.next))r=r.next;else{if(k(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function o(e,t,n,c,u,d,f){if(e){!f&&d&&function(e,t,n,r){var o=e;do{0===o.z&&(o.z=p(o.x,o.y,t,n,r)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next}while(o!==e);o.prevZ.nextZ=null,o.prevZ=null,function(e){var t,n,r,o,i,a,s,l,c=1;do{for(n=e,e=null,i=null,a=0;n;){for(a++,r=n,s=0,t=0;t0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(o=n,n=n.nextZ,s--):(o=r,r=r.nextZ,l--),i?i.nextZ=o:e=o,o.prevZ=i,i=o;n=r}i.nextZ=null,c*=2}while(a>1)}(o)}(e,c,u,d);for(var h,g,m=e;e.prev!==e.next;)if(h=e.prev,g=e.next,d?a(e,c,u,d):i(e))t.push(h.i/n|0),t.push(e.i/n|0),t.push(g.i/n|0),k(e),e=g.next,m=g.next;else if((e=g)===m){f?1===f?o(e=s(r(e),t,n),t,n,c,u,d,2):2===f&&l(e,t,n,c,u,d):o(r(e),t,n,c,u,d,1);break}}}function i(e){var t=e.prev,n=e,r=e.next;if(m(t,n,r)>=0)return!1;for(var o=t.x,i=n.x,a=r.x,s=t.y,l=n.y,c=r.y,u=oi?o>a?o:a:i>a?i:a,f=s>l?s>c?s:c:l>c?l:c,g=r.next;g!==t;){if(g.x>=u&&g.x<=p&&g.y>=d&&g.y<=f&&h(o,s,i,l,a,c,g.x,g.y)&&m(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function a(e,t,n,r){var o=e.prev,i=e,a=e.next;if(m(o,i,a)>=0)return!1;for(var s=o.x,l=i.x,c=a.x,u=o.y,d=i.y,f=a.y,g=sl?s>c?s:c:l>c?l:c,x=u>d?u>f?u:f:d>f?d:f,b=p(g,y,t,n,r),C=p(v,x,t,n,r),E=e.prevZ,P=e.nextZ;E&&E.z>=b&&P&&P.z<=C;){if(E.x>=g&&E.x<=v&&E.y>=y&&E.y<=x&&E!==o&&E!==a&&h(s,u,l,d,c,f,E.x,E.y)&&m(E.prev,E,E.next)>=0)return!1;if(E=E.prevZ,P.x>=g&&P.x<=v&&P.y>=y&&P.y<=x&&P!==o&&P!==a&&h(s,u,l,d,c,f,P.x,P.y)&&m(P.prev,P,P.next)>=0)return!1;P=P.nextZ}for(;E&&E.z>=b;){if(E.x>=g&&E.x<=v&&E.y>=y&&E.y<=x&&E!==o&&E!==a&&h(s,u,l,d,c,f,E.x,E.y)&&m(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;P&&P.z<=C;){if(P.x>=g&&P.x<=v&&P.y>=y&&P.y<=x&&P!==o&&P!==a&&h(s,u,l,d,c,f,P.x,P.y)&&m(P.prev,P,P.next)>=0)return!1;P=P.nextZ}return!0}function s(e,t,n){var o=e;do{var i=o.prev,a=o.next.next;!y(i,a)&&v(i,o,o.next,a)&&C(i,a)&&C(a,i)&&(t.push(i.i/n|0),t.push(o.i/n|0),t.push(a.i/n|0),k(o),k(o.next),o=e=a),o=o.next}while(o!==e);return r(o)}function l(e,t,n,i,a,s){var l=e;do{for(var c=l.next.next;c!==l.prev;){if(l.i!==c.i&&g(l,c)){var u=E(l,c);return l=r(l,l.next),u=r(u,u.next),o(l,t,n,i,a,s,0),void o(u,t,n,i,a,s,0)}c=c.next}l=l.next}while(l!==e)}function c(e,t){return e.x-t.x}function u(e,t){var n=function(e,t){var n,r=t,o=e.x,i=e.y,a=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){var s=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=o&&s>a&&(a=s,n=r.x=r.x&&r.x>=u&&o!==r.x&&h(in.x||r.x===n.x&&d(n,r)))&&(n=r,f=l)),r=r.next}while(r!==c);return n}(e,t);if(!n)return t;var o=E(n,e);return r(o,o.next),r(n,n.next)}function d(e,t){return m(e.prev,e,t.prev)<0&&m(t.next,e,e.next)<0}function p(e,t,n,r,o){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*o|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*o|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function f(e){var t=e,n=e;do{(t.x=(e-a)*(i-s)&&(e-a)*(r-s)>=(n-a)*(t-s)&&(n-a)*(i-s)>=(o-a)*(r-s)}function g(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&v(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(C(e,t)&&C(t,e)&&function(e,t){var n=e,r=!1,o=(e.x+t.x)/2,i=(e.y+t.y)/2;do{n.y>i!=n.next.y>i&&n.next.y!==n.y&&o<(n.next.x-n.x)*(i-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(m(e.prev,e,t.prev)||m(e,t.prev,t))||y(e,t)&&m(e.prev,e,e.next)>0&&m(t.prev,t,t.next)>0)}function m(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function y(e,t){return e.x===t.x&&e.y===t.y}function v(e,t,n,r){var o=b(m(e,t,n)),i=b(m(e,t,r)),a=b(m(n,r,e)),s=b(m(n,r,t));return o!==i&&a!==s||!(0!==o||!x(e,n,t))||!(0!==i||!x(e,r,t))||!(0!==a||!x(n,e,r))||!(0!==s||!x(n,t,r))}function x(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function b(e){return e>0?1:e<0?-1:0}function C(e,t){return m(e.prev,e,e.next)<0?m(e,t,e.next)>=0&&m(e,e.prev,t)>=0:m(e,t,e.prev)<0||m(e,e.next,t)<0}function E(e,t){var n=new w(e.i,e.x,e.y),r=new w(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=o,o.prev=n,r.next=n,n.prev=r,i.next=r,r.prev=i,r}function P(e,t,n,r){var o=new w(e,t,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function k(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function w(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function _(e,t,n,r){for(var o=0,i=t,a=n-r;i0&&(r+=e[o-1].length,n.holes.push(r))}return n}},2100:(e,t,n)=>{"use strict";n.d(t,{AstronomicalObjectSimulator:()=>C});var r=n(3696),o=n.n(r),i=n(8662),a=n(9397),s=n(9758),l=n(9018),c=n(972),u=n(9520),d=Object.defineProperty,p=Object.defineProperties,f=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,y=Math.pow,v=(e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))g.call(t,n)&&v(e,n,t[n]);if(h)for(var n of h(t))m.call(t,n)&&v(e,n,t[n]);return e},b=(e,t)=>p(e,f(t));(0,i.enablePatches)();const C=o().forwardRef(((e,t)=>{var n,r;const{width:d,height:p}=(0,s.useWindowSize)(),{state:f,setState:h,undo:g,redo:m,applyPatchFromOtherOperators:v,applyPatchFromSelf:C}=(0,s.usePatchBasedUndoRedo)(e.initialState,e.operator,{onApplyPatchesFromSelf:e.onApplyPatchesFromSelf}),{x:E,y:P,ref:k,setX:w,setY:_}=(0,s.useWheelScroll)(),{scale:S,setScale:R,ref:A}=(0,s.useWheelZoom)({min:.001,onChange(e,t,n){const r=(0,s.scaleByCursorPosition)({width:d,height:p},t/e,n);w(r.setX),_(r.setY)}}),[T,M]=o().useState({x:0,y:0}),{offset:L,onStart:I,mask:O,resetDragMove:B}=(0,s.useDragMove)((()=>{X?M((e=>({x:e.x+L.x,y:e.y+L.y}))):(w((e=>e+L.x)),_((e=>e+L.y)))})),[F,D]=o().useState(),[z,U]=o().useState(),[N,G]=o().useState(!1),[j,V]=o().useState(),W=[],H=[],q=[],$=[],[Y,K]=o().useState(!1),[X,Z]=o().useState(!1);let Q;const J=o().useRef(null),[ee,te,ne]=(0,s.useRefState)(!1),[re,oe,ie]=(0,s.useRefState2)(),ae=null!=re?re:f,{line:se,onClick:le,reset:ce,onMove:ue}=(0,s.useLineClickCreate)(N,(e=>{h((t=>{const n={type:"sphere",x:Y?0:e[0].x,y:e[0].y,z:Y?e[0].x:0,radius:(0,s.getTwoPointsDistance)(e[0],e[1]),speed:{x:0,y:0,z:0},mass:1,color:16711680};t.push(n)})),pe()}),{once:!0});if(se){const e={type:"sphere",x:Y?0:se[0].x,y:se[0].y,z:Y?se[0].x:0,radius:(0,s.getTwoPointsDistance)(se[0],se[1]),speed:{x:0,y:0,z:0},mass:1,color:16711680};W.push(e)}j&&W.push(j);const de={x:X?E:E+L.x,y:X?P:P+L.y,scale:S,center:{x:d/2,y:p/2}},pe=()=>{G(!1),D(void 0),U(void 0),V(void 0)},{editPoint:fe,updateEditPreview:he,onEditMove:ge,onEditClick:me,resetEdit:ye}=(0,s.useEdit)((()=>C(H,q)),(e=>{if((0,c.isSphereContent)(e)){const t=Y?e.z:e.x,n=[{x:t,y:e.y,cursor:"move",update(e,{cursor:t}){(0,c.isSphereContent)(e)&&(Y?e.z=t.x:e.x=t.x,e.y=t.y)}}],r=Y?e.speed.z:e.speed.x;if(r||e.speed.y){const o={x:t,y:e.y},i={x:r,y:e.speed.y},a=(0,s.getPointByLengthAndRadian)(o,e.radius+(0,s.getTwoPointsDistance)(i),Math.atan2(e.speed.y,r));n.push({x:a.x,y:a.y,cursor:"move",update(n,{cursor:r}){if(!(0,c.isSphereContent)(n))return;if((0,s.getTwoPointsDistance)(r,e)<=e.radius)return;const o=r.x-t,i=r.y-e.y,a=(0,s.getTwoPointsDistance)({x:o,y:i}),l=(a-e.radius)/a;Y?n.speed.z=o*l:n.speed.x=o*l,n.speed.y=i*l}})}return{editPoints:n}}}),{scale:de.scale,readOnly:N}),ve=he();if(H.push(...null!=(n=null==ve?void 0:ve.patches)?n:[]),q.push(...null!=(r=null==ve?void 0:ve.reversePatches)?r:[]),void 0!==z&&!ee){const e=ae[z];if(e&&(0,c.isSphereContent)(e)){$.push({content:e,path:[z]});const t=e=>{const[,...t]=(0,i.produceWithPatches)(ae,(t=>{const n=t[z];n&&e(n,t)}));C(...t)},n={x:o().createElement(s.NumberEditor,{value:e.x,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.x=e)}))}),y:o().createElement(s.NumberEditor,{value:e.y,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.y=e)}))}),z:o().createElement(s.NumberEditor,{value:e.z,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.z=e)}))}),radius:o().createElement(s.NumberEditor,{value:e.radius,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.radius=e)}))}),mass:o().createElement(s.NumberEditor,{value:e.mass,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.mass=e)}))}),color:o().createElement(s.NumberEditor,{type:"color",value:e.color,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.color=e)}))}),speed:o().createElement(s.ObjectEditor,{inline:!0,properties:{x:o().createElement(s.NumberEditor,{value:e.speed.x,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.speed.x=e)}))}),y:o().createElement(s.NumberEditor,{value:e.speed.y,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.speed.y=e)}))}),z:o().createElement(s.NumberEditor,{value:e.speed.z,setValue:e=>t((t=>{(0,c.isSphereContent)(t)&&(t.speed.z=e)}))})}})};e.acceleration&&(n.acceleration=o().createElement(s.ObjectEditor,{inline:!0,properties:{x:o().createElement(s.NumberEditor,{value:e.acceleration.x}),y:o().createElement(s.NumberEditor,{value:e.acceleration.y}),z:o().createElement(s.NumberEditor,{value:e.acceleration.z})}})),Q=o().createElement("div",{style:{position:"absolute",right:"0px",top:"0px",bottom:"0px",width:"300px",overflowY:"auto",background:"white",zIndex:11}},o().createElement("div",null,z),o().createElement(s.ObjectEditor,{readOnly:void 0!==re,properties:n}))}}(0,s.useGlobalKeyDown)((e=>{return void 0,null,t=function*(){if("Escape"===e.key)pe(),ce(!0),ye(),B();else if("Backspace"===e.code){if(X)return;void 0!==F?(h((e=>{e[F]=void 0})),D(void 0)):void 0!==z&&(h((e=>{e[z]=void 0})),U(void 0))}else if((0,s.metaKeyIfMacElseCtrlKey)(e))if(e.shiftKey)"KeyZ"===e.code&&(yield m(e));else if("KeyZ"===e.code)yield g(e);else if("Digit0"===e.code)R(1),w(0),_(0),M({x:0,y:0}),e.preventDefault();else if("KeyC"===e.code){if(e.preventDefault(),void 0!==z){const e=f[z];e&&(yield navigator.clipboard.writeText(JSON.stringify(e)))}}else if("KeyV"===e.code){try{const e=yield navigator.clipboard.readText(),t=JSON.parse(e);if((0,c.isSphereContent)(t))return void V(t)}catch(e){console.info(e)}e.preventDefault()}},new Promise(((e,n)=>{var r=e=>{try{i(t.next(e))}catch(e){n(e)}},o=e=>{try{i(t.throw(e))}catch(e){n(e)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,o);i((t=t.apply(undefined,null)).next())}));var t})),o().useImperativeHandle(t,(()=>({handlePatchesEvent(e){try{v(e.patches,e.reversePatches,e.operator)}catch(e){console.error(e)}}})),[v]);const xe=(0,s.useEvent)((e=>{const t={x:e.clientX,y:e.clientY};4===e.buttons?I(t):N||fe||void 0!==F||j||I(t)})),be=(0,s.useEvent)((e=>{const t={x:e.clientX,y:e.clientY},n=(0,s.reverseTransformPosition)(t,de);N?le(n):j?h((e=>{e.push(b(x({},j),{x:n.x,y:n.y}))})):fe?me(n):void 0!==F&&(U(F),D(void 0))})),Ce=(0,s.useEvent)((e=>{var t;const n={x:e.clientX,y:e.clientY};if(X)return void D(null==(t=J.current)?void 0:t.getContentByPosition(n));const r=(0,s.reverseTransformPosition)(n,de);N?ue(r,n):j?V(b(x({},j),{x:r.x,y:r.y})):(ge(r,$),D((e=>{for(let t=0;tZ(!X)},X?"3D":"2D"),!X&&o().createElement(s.Button,{style:{color:N?"red":void 0},onClick:()=>{ce(),G(!0)}},"create"),o().createElement(s.Button,{onClick:()=>{h((e=>{for(let t=f.length-1;t>=0;t--)f[t]||e.splice(t,1)}))}},"compress"),o().createElement(s.Button,{onClick:()=>{if(ne.current)return void te(!1);let e;te(!0);const t=n=>{var r;if(ne.current){if(void 0!==e){const t=.001*(n-e),o=[],l=null!=(r=ie.current)?r:f;for(const e of l)if(e&&(0,c.isSphereContent)(e)){const n={x:0,y:0,z:0};for(const t of l)if(t&&t!==e&&(0,c.isSphereContent)(t)){const r=a.v3.create(t.x-e.x,t.y-e.y,t.z-e.z),o=a.v3.mulScalar(a.v3.normalize(r),t.mass/a.v3.lengthSq(r));n.x+=o[0],n.y+=o[1],n.z+=o[2]}const r=(0,i.produce)(e,(r=>{r.x+=e.speed.x*t,r.y+=e.speed.y*t,r.z+=e.speed.z*t,r.speed.x+=n.x*t,r.speed.y+=n.y*t,r.speed.z+=n.z*t,r.acceleration=n})),u=o.findIndex((e=>y(e.x-r.x,2)+y(e.y-r.y,2)+y(e.z-r.z,2)<=y(e.radius+r.radius,2)));u>=0?o[u]=(0,i.produce)(o[u],(e=>{const t=e.mass+r.mass,n=e.mass/t,o=r.mass/t,i=(0,s.colorNumberToPixelColor)(e.color),a=(0,s.colorNumberToPixelColor)(r.color);e.color=(0,s.pixelColorToColorNumber)([Math.round(i[0]*n+a[0]*o),Math.round(i[1]*n+a[1]*o),Math.round(i[2]*n+a[2]*o)]),e.x=e.x*n+r.x*o,e.y=e.y*n+r.y*o,e.z=e.z*n+r.z*o,e.speed.x=e.speed.x*n+r.speed.x*o,e.speed.y=e.speed.y*n+r.speed.y*o,e.speed.z=e.speed.z*n+r.speed.z*o,e.mass=t,e.radius=y(y(e.radius,3)+y(r.radius,3),1/3)})):o.push(r)}oe(o)}e=n,requestAnimationFrame(t)}};requestAnimationFrame(t)}},ee?"pause":"run"),void 0!==re&&o().createElement(s.Button,{onClick:()=>{te(!1),oe(void 0)}},"stop"),!X&&o().createElement(s.Button,{onClick:()=>K(!Y)},Y?"y-z":"x-y"))),Q,O)}))},6129:(e,t,n)=>{"use strict";n.d(t,{astronomicalObjectData:()=>r});const r=[{type:"sphere",x:231,y:236,z:0,radius:30,speed:{x:-73.70571823105142,y:68.12490364773653,z:0},mass:1e7,color:16711680},{type:"sphere",x:446,y:353,z:0,radius:20,speed:{x:-102.94373709062597,y:168.36353129062343,z:0},mass:1e3,color:65280},{type:"sphere",x:398.9843062850506,y:-117.78508305127633,z:0,radius:20,speed:{x:153.21723012109481,y:57.76555978608411,z:0},mass:1e3,color:255},{type:"sphere",x:41.02054841250941,y:37.316758024428964,z:0,radius:30,speed:{x:65.08066514652798,y:-66.75836078276822,z:0},mass:1e7,color:65535},{type:"sphere",x:3107.5317443426698,y:-18.917171514406107,z:0,radius:37.45047072967306,speed:{x:0,y:0,z:0},mass:1e7,color:54783},{type:"sphere",x:3638.8316388608887,y:-65.11716234207734,z:0,radius:45.06522687618144,speed:{x:-27.342187113971978,y:-33.25473001125231,z:0},mass:1e7,color:16711680},{type:"sphere",x:3497.1057910282866,y:661.0342986264877,z:0,radius:37.45047072967306,speed:{x:0,y:0,z:0},mass:1e7,color:16771584},{type:"sphere",x:635.5477051784671,y:307.619425187331,z:0,radius:20,speed:{x:-19.15755965193336,y:112.03470856588699,z:0},mass:1e3,color:13172480},{type:"sphere",x:839.3864576748671,y:249.379781616931,z:0,radius:20,speed:{x:-6.070839258689052,y:128.36149928851918,z:0},mass:1e3,color:16711829},{type:"sphere",x:813.5021716435781,y:97.30960118310884,z:0,radius:20,speed:{x:-.47910598403916377,y:108.26015976138154,z:0},mass:1e3,color:7536895},{type:"sphere",x:601.5745797624005,y:121.57611933744215,z:0,radius:20,speed:{x:-4.309805634415668,y:95.12035518543071,z:0},mass:1e3,color:15597823},{type:"sphere",x:998.966956569539,y:170.03750534624538,z:0,radius:20,speed:{x:-6.070839258689052,y:128.36149928851918,z:0},mass:1e3,color:49151},{type:"sphere",x:1110.0310760697196,y:39.53716493353312,z:0,radius:20,speed:{x:-6.070839258689052,y:128.36149928851918,z:0},mass:1e3,color:0},{type:"sphere",x:1201.6589746573686,y:-93.73977846668356,z:0,radius:20,speed:{x:-6.070839258689052,y:128.36149928851918,z:0},mass:1e3,color:16756224},{type:"sphere",x:216,y:82,z:0,radius:99.80981915623332,speed:{x:0,y:0,z:0},mass:1,color:16711680}]},972:(e,t,n)=>{"use strict";n.d(t,{getContentModel:()=>a,isSphereContent:()=>o});var r=n(9758);function o(e){return"sphere"===e.type}const i={};function a(e){return i[e.type]}var s;i[(s={type:"sphere",render(e,{target:t,transformRadius:n,yz:o}){const i=n(e.radius),a=o?e.z:e.x,s={x:a,y:e.y},l=[t.renderCircle(a,e.y,i,{fillColor:e.color,strokeWidth:0})],c=o?e.speed.z:e.speed.x;if(c||e.speed.y){const n={x:c,y:e.speed.y},o=(0,r.getPointByLengthAndRadian)(s,e.radius+(0,r.getTwoPointsDistance)(n),Math.atan2(e.speed.y,c)),{arrowPoints:i,endPoint:a}=(0,r.getArrow)(s,o,10,15);l.push(t.renderPolyline([s,a],{strokeColor:e.color}),t.renderPolygon(i,{fillColor:e.color,strokeWidth:0}))}if(e.acceleration){const n=o?e.acceleration.z:e.acceleration.x;if(n||e.acceleration.y){const o={x:n,y:e.acceleration.y},i=(0,r.getPointByLengthAndRadian)(s,e.radius+(0,r.getTwoPointsDistance)(o),Math.atan2(e.acceleration.y,n)),{arrowPoints:a,endPoint:c}=(0,r.getArrow)(s,i,10,15);l.push(t.renderPolyline([s,c],{strokeColor:e.color,dashArray:[5]}),t.renderPolygon(a,{fillColor:e.color,strokeWidth:0}))}}return t.renderGroup(l)}}).type]=s},9520:(e,t,n)=>{"use strict";n.d(t,{Renderer3d:()=>l});var r=n(3696),o=n.n(r),i=n(9397),a=n(9758),s=n(972);const l=o().forwardRef(((e,t)=>{const n=o().useRef(null),r=o().useRef(),l=o().useRef(new a.MapCache),c=o().useRef(new a.WeakmapCache),u=o().useRef(new a.WeakmapCache);return o().useEffect((()=>{n.current&&(r.current=(0,a.createWebgl3DRenderer)(n.current))}),[n.current]),o().useEffect((()=>{if(!r.current)return;const t=[],n=[...(0,a.getAxesGraphics)()],{position:o,up:d}=(0,a.updateCamera)(-e.x,e.y,1e3/e.scale,-.3*e.rotateX,-.3*e.rotateY);e.contents.forEach(((r,o)=>{if(r&&(0,s.isSphereContent)(r)){const s=(0,a.colorNumberToRec)(r.color);e.hovering!==o&&e.selected!==o||(s[3]=.5),t.push({geometry:l.current.get(r.radius,(()=>({type:"sphere",radius:r.radius}))),color:s,position:[r.x,r.y,r.z]});const d=i.v3.create(r.x,r.y,r.z),p=i.v3.create(r.speed.x,r.speed.y,r.speed.z),f=i.v3.add(d,i.v3.mulScalar(i.v3.normalize(p),i.v3.length(p)+r.radius));if(n.push({geometry:c.current.get(r,(()=>({type:"lines",points:[...d,...f]}))),color:s}),r.acceleration){const e=i.v3.create(r.acceleration.x,r.acceleration.y,r.acceleration.z),t=i.v3.add(d,i.v3.mulScalar(i.v3.normalize(e),i.v3.length(e)+r.radius));n.push({geometry:u.current.get(r,(()=>({type:"lines",points:(0,a.getDashedLine)([d[0],d[1],d[2]],[t[0],t[1],t[2]],6).flat()}))),color:s})}}else t.push(void 0)})),t.push(...n),r.current.render(t,{eye:[o.x,o.y,o.z],up:[d.x,d.y,d.z],target:[-e.x,e.y,0],fov:(0,a.angleToRadian)(60),near:.1,far:2e4},{position:[1e3,1e3,1e3],color:[1,1,1,1],specular:[1,1,1,1],shininess:50,specularFactor:1},[1,1,1,1])}),[e.x,e.y,e.scale,e.rotateX,e.rotateY,e.contents,e.hovering,e.selected,e.width,e.height]),o().useImperativeHandle(t,(()=>({getContentByPosition(e){var t,n;return null==(n=null==(t=r.current)?void 0:t.pick)?void 0:n.call(t,e.x,e.y,(e=>"sphere"===e.geometry.type))}})),[]),o().createElement("canvas",{ref:n,width:e.width,height:e.height,onClick:e.onClick,onMouseDown:e.onMouseDown})}))},9018:(e,t,n)=>{"use strict";n.d(t,{Renderer:()=>p});var r=n(8662),o=n(9758),i=n(972),a=Object.defineProperty,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))c.call(t,n)&&u(e,n,t[n]);return e};function p(e){var t,n;const a=o.reactSvgRenderTarget,s=[],l=e.previewPatches.length>0?(0,r.applyPatches)(e.contents,e.previewPatches):e.contents;for(let n=0;ne.hovering===n||e.selected===n?t+1:t,yz:e.yz}))}}for(const t of e.assistentContents){if(!t)continue;const r=null==(n=(0,i.getContentModel)(t))?void 0:n.render;r&&s.push(r(t,{target:a,transformRadius:e=>e,yz:e.yz}))}return a.renderResult(s,e.width,e.height,{attributes:{style:d({position:"absolute",boxSizing:"border-box"},e.style),onClick:e.onClick,onMouseDown:e.onMouseDown,onContextMenu:e.onContextMenu},transform:{x:e.x,y:e.y,scale:e.scale}})}},8995:(e,t,n)=>{"use strict";n.d(t,{default:()=>l});var r=n(3696),o=n.n(r),i=n(9758),a=n(7469),s=n(3385);const l=()=>{const e=(0,i.useWindowSize)().width/2-30,[t,n]=o().useState(),r=o().useRef(new i.MapCache4),l=(e,n,o=!1,a=!1)=>{if(t&&e)return r.current.get(o,a,n,e,(()=>{const r=t.getPath(e,0,n,n,{xScale:n/t.unitsPerEm,yScale:n/t.unitsPerEm}),l=t.charToGlyph(e),c=l.getBoundingBox(),u=l.advanceWidth||0,d=c.x2-c.x1,p=(0,s.opentypeCommandsToPathCommands)(r,o?.7*n:void 0);let f=(0,i.geometryLinesToHatches)((0,i.pathCommandsToGeometryLines)(p));return a&&(f=f.map((e=>(0,i.boldHatch)(e,.01*n)))),{commands:f.map((e=>[e.border,...e.holes])).map((e=>e.map((e=>(0,i.geometryLineToPathCommands)(e))).flat())),x1:(u>d?0:c.x1)/t.unitsPerEm*n,y1:(l.unicode&&l.unicode<256?0:c.y1)/t.unitsPerEm*n,width:Math.max(u,d)/t.unitsPerEm*n}}))},[c,u]=o().useState([{insert:"我们出"},{insert:"去吧",attributes:{stackText:"ab"}},{insert:"Aag jioIb BDxVX晒回吧",attributes:{color:16711680}}]),[d,p]=o().useState("left"),[f,h]=o().useState("top"),[g,m]=o().useState(!1),y=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.color)?n:0},v=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.opacity)?n:1},x=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.fontSize)?n:50},b=e=>{var t,n;return x(e)*((null==(t=null==e?void 0:e.attributes)?void 0:t.script)||(null==(n=null==e?void 0:e.attributes)?void 0:n.stackText)?.7:1)},C=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.backgroundColor)?n:16777215},E=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.underline)&&n},P=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.passThrough)&&n},k=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.bold)&&n},w=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.italic)&&n},_=e=>{var t;return null==(t=null==e?void 0:e.attributes)?void 0:t.script},S=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.circle)&&n},R=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.stackText)?n:""},A=e=>1.5*b(e),T=e=>{var t,n,r;const o=b(e);if(null==(t=e.attributes)?void 0:t.stackText){const t=e.insert.split("").reduce(((e,t)=>{var n,r;return e+(null!=(r=null==(n=l(t,o))?void 0:n.width)?r:0)}),0),n=e.attributes.stackText.split("").reduce(((e,t)=>{var n,r;return e+(null!=(r=null==(n=l(t,o))?void 0:n.width)?r:0)}),0);return Math.max(n,t)}return null!=(r=null==(n=l(e.insert,o))?void 0:n.width)?r:0},M=e=>S(e)?A(e):T(e),{renderEditor:L,layoutResult:I,lineHeights:O,isSelected:B,actualHeight:F,cursorContent:D,setSelectedAttributes:z}=(0,i.useAttributedTextEditor)({state:c,setState:u,width:e,height:200,lineHeight:A,getWidth:M,getReadonlyType:e=>!!(null==e?void 0:e.stackText)||void 0,align:d,verticalAlign:f});o().useEffect((()=>{var e;e=function*(){const e=yield fetch(s.allFonts[0].url),t=yield e.arrayBuffer();n(a.parse(t))},new Promise(((t,n)=>{var r=t=>{try{i(e.next(t))}catch(e){n(e)}},o=t=>{try{i(e.throw(t))}catch(e){n(e)}},i=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,o);i((e=e.apply(undefined,null)).next())}))}),[]);const U=i.reactSvgRenderTarget,N=[],G=[];for(const{x:e,y:t,i:n,content:r,visible:o,row:i}of I){if(!o)continue;const a=M(r),s=O[i],c=B(n);c&&N.push(U.renderRect(e,t,a,s,{fillColor:11785981,strokeWidth:0}));const u=b(r),d=w(r),p=k(r),f=l(r.insert,u,d,p);if(f){const n=y(r),o=v(r),i=C(r);c||16777215===i||N.push(U.renderRect(e,t,a,s,{fillColor:i,strokeWidth:0})),E(r)&&N.push(U.renderPolyline([{x:e,y:t+s},{x:e+a,y:t+s}],{strokeColor:n,strokeOpacity:o})),P(r)&&N.push(U.renderPolyline([{x:e,y:t+s/2},{x:e+a,y:t+s/2}],{strokeColor:n,strokeOpacity:o}));const h={x:e-f.x1,y:t+f.y1+(s-A(r))},m=_(r),x=R(r);if("sub"===m?h.y+=.2*u:("sup"===m||x)&&(h.y-=.7*u),x){const e=r.insert.split("").reduce(((e,t)=>{var n,r;return e+(null!=(r=null==(n=l(t,u))?void 0:n.width)?r:0)}),0);h.x+=(a-e)/2}S(r)&&(h.x+=(s-T(r))/2,N.push(U.renderCircle(e+a/2,t+s/2,s/2,{strokeColor:n,strokeOpacity:o})));const b=g?{strokeColor:n,strokeOpacity:o,strokeWidth:1}:{fillColor:n,fillOpacity:o,strokeWidth:0};if(N.push(U.renderGroup(f.commands.map((e=>U.renderPathCommands(e,b))),{translate:h})),c&&G.push(...f.commands),x){const n=x.split("").reduce(((e,t)=>{var n,r;return e+(null!=(r=null==(n=l(t,u))?void 0:n.width)?r:0)}),0);let o=0;for(const i of x.split("")){const c=l(i,u,d,p);if(c){const i={x:e-c.x1+(a-n)/2+o,y:t+c.y1+(s-A(r))+.2*u};o+=c.width,N.push(U.renderGroup(c.commands.map((e=>U.renderPathCommands(e,b))),{translate:i}))}}}}}const j=U.renderResult(N,e,F);return o().createElement(o().Fragment,null,L(j),o().createElement(i.EnumEditor,{enums:i.aligns,value:d,setValue:p}),o().createElement(i.EnumEditor,{enums:i.verticalAligns,value:f,setValue:h}),o().createElement(i.ObjectEditor,{inline:!0,properties:{color:o().createElement(i.NumberEditor,{type:"color",value:y(D),setValue:e=>z({color:e})}),opacity:o().createElement(i.NumberEditor,{value:v(D),setValue:e=>z({opacity:e})}),fontSize:o().createElement(i.NumberEditor,{value:x(D),setValue:e=>z({fontSize:e})}),backgroundColor:o().createElement(i.NumberEditor,{type:"color",value:C(D),setValue:e=>z({backgroundColor:16777215===e?void 0:e})}),underline:o().createElement(i.BooleanEditor,{value:E(D),setValue:e=>z({underline:!!e||void 0})}),passThrough:o().createElement(i.BooleanEditor,{value:P(D),setValue:e=>z({passThrough:!!e||void 0})}),bold:o().createElement(i.BooleanEditor,{value:k(D),setValue:e=>z({bold:!!e||void 0})}),italic:o().createElement(i.BooleanEditor,{value:w(D),setValue:e=>z({italic:!!e||void 0})}),strokeOnly:o().createElement(i.BooleanEditor,{value:g,setValue:e=>m(e)}),sub:o().createElement(i.BooleanEditor,{value:"sub"===_(D),setValue:e=>z({script:e?"sub":void 0})}),sup:o().createElement(i.BooleanEditor,{value:"sup"===_(D),setValue:e=>z({script:e?"sup":void 0})}),circle:o().createElement(i.BooleanEditor,{value:S(D),setValue:e=>z({circle:!!e||void 0})}),stackText:o().createElement(i.StringEditor,{value:R(D),setValue:e=>z({stackText:e||void 0})}),actions:o().createElement(i.Button,{onClick:()=>navigator.clipboard.writeText(JSON.stringify({contents:G.map(((e,t)=>({id:t,content:{type:"path",commands:e}}))),center:{x:0,y:0}}))},"copy as command path")}}))}},7474:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const[e,t]=o().useState([{insert:"abc"},{insert:"123",attributes:{color:16711680,readonly:"1"}},{insert:"edf",attributes:{readonly:"1"}},{insert:"ghi",attributes:{color:65280}}]),[n,r]=o().useState("left"),[a,s]=o().useState("top"),l=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.fontFamily)?n:"monospace"},c=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.color)?n:0},u=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.bold)&&n},d=e=>{var t,n;return null!=(n=null==(t=null==e?void 0:e.attributes)?void 0:t.italic)&&n},p=e=>{var t,n;return null!=(n=null==(t=(0,i.getTextSizeFromCache)(`${u(e)?"bold ":""}${d(e)?"italic ":""}20px ${l(e)}`,e.insert))?void 0:t.width)?n:0},{renderEditor:f,layoutResult:h,isSelected:g,actualHeight:m,cursorContent:y,setSelectedAttributes:v}=(0,i.useAttributedTextEditor)({state:e,setState:t,width:400,height:200,lineHeight:24,getWidth:p,align:n,verticalAlign:a,getReadonlyType:e=>null==e?void 0:e.readonly}),x=[],b=i.reactCanvasRenderTarget;for(const{x:e,y:t,i:n,content:r,visible:o}of h){if(!o)continue;const i=p(r);g(n)&&x.push(b.renderRect(e,t,i,24,{fillColor:11785981,strokeWidth:0})),x.push(b.renderText(e+i/2,t+20,r.insert,c(r),20,l(r),{textAlign:"center",fontWeight:u(r)?"bold":void 0,fontStyle:d(r)?"italic":void 0}))}const C=b.renderResult(x,400,m);return o().createElement(o().Fragment,null,f(C),o().createElement(i.EnumEditor,{enums:i.aligns,value:n,setValue:r}),o().createElement(i.EnumEditor,{enums:i.verticalAligns,value:a,setValue:s}),o().createElement(i.ObjectEditor,{inline:!0,properties:{color:o().createElement(i.NumberEditor,{type:"color",value:c(y),setValue:e=>v({color:e})}),fontFamily:o().createElement(i.StringEditor,{value:l(y),setValue:e=>v({fontFamily:e})}),bold:o().createElement(i.BooleanEditor,{value:u(y),setValue:e=>v({bold:!!e||void 0})}),italic:o().createElement(i.BooleanEditor,{value:d(y),setValue:e=>v({italic:!!e||void 0})})}}))}},8576:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const{start:e,stop:t,duration:n,volume:r,audioUrl:a,recording:s}=(0,i.useAudioRecorder)(),{play:l,pause:c,playing:u,currentTime:d,audio:p,duration:f}=(0,i.useAudioPlayer)(a);return o().createElement("div",null,s?null:o().createElement("button",{onClick:e},"start"),s?o().createElement("button",{onClick:t},"stop ",n):null,s&&void 0!==r?o().createElement("meter",{max:"1",value:r}):null,a&&o().createElement(o().Fragment,null,o().createElement("button",{onClick:u?c:l},u?"pause":"play"),d,"/",f,p))}},3388:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const f=()=>{const e=o().useRef(null),t=o().useRef(),{x:n,y:r,ref:a}=(0,i.useWheelScroll)(),{scale:f,ref:h}=(0,i.useWheelZoom)(),[g,m]=o().useState({x:0,y:0}),{offset:y,onStart:v,mask:x,resetDragMove:b}=(0,i.useDragMove)((()=>{m((e=>({x:e.x+y.x,y:e.y+y.y})))})),C=(0,i.useWindowSize)(),E=C.width/2,P=C.height,[k,w]=o().useState(),_=y.x+g.x,S=y.y+g.y,R=o().useRef([]);return o().useEffect((()=>{e.current&&(t.current=(0,i.createWebgl3DRenderer)(e.current))}),[e.current]),(0,i.useGlobalKeyDown)((e=>{"Escape"===e.key&&b()})),o().useEffect((()=>{const e=[65,59,80,81,56,55,40].map(((e,t)=>[20*(t+1),e,0])),t=[55,49,70,71,46,45,30].map(((e,t)=>[20*(t+1),e,20])),n=[45,39,60,61,36,35,20].map(((e,t)=>[20*(t+1),e,40])),r=[75,69,90,91,66,65,50].map(((e,t)=>[20*(t+1),e,-20])),o=(0,i.getChartAxis3D)([e,t,n,r],{x:20,y:10,z:20});R.current.push(...o,...e.map((e=>({geometry:{type:"cylinder",radius:3,height:e[1]},color:[1,0,0,1],position:[e[0],e[1]/2,e[2]]}))),...t.map((e=>({geometry:{type:"cylinder",radius:3,height:e[1]},color:[0,1,0,1],position:[e[0],e[1]/2,e[2]]}))),...n.map((e=>({geometry:{type:"cylinder",radius:3,height:e[1]},color:[0,0,1,1],position:[e[0],e[1]/2,e[2]]}))),...r.map((e=>({geometry:{type:"cylinder",radius:3,height:e[1]},color:[0,0,0,1],position:[e[0],e[1]/2,e[2]]}))))}),[]),o().useEffect((()=>{var e,o;const{position:a,up:s}=(0,i.updateCamera)(-n,r,200/f,-.3*_,-.3*S);null==(o=null==(e=t.current)?void 0:e.render)||o.call(e,R.current,{eye:[a.x+40,a.y+40,a.z],up:[s.x,s.y,s.z],target:[40-n,r+40,0],fov:(0,i.angleToRadian)(60),near:.1,far:2e3},{position:[1e3,1e3,1e3],color:[1,1,1,1],specular:[1,1,1,1],shininess:50,specularFactor:1},[1,1,1,1])}),[n,r,f,_,S,k,E,P]),o().createElement("div",{style:{position:"absolute",inset:"0px"}},o().createElement("canvas",{ref:(0,i.bindMultipleRefs)(a,h,e),width:E,height:P,onMouseDown:e=>v({x:e.clientX,y:e.clientY}),onMouseMove:e=>{var n,r;w(void 0);const o=null==(r=null==(n=t.current)?void 0:n.pick)?void 0:r.call(n,e.clientX,e.clientY,(e=>"cylinder"===e.geometry.type));if(void 0!==o){const t=R.current[o];t.position&&w({value:t.position,x:e.clientX,y:e.clientY})}}}),k&&o().createElement(i.ChartTooltip,(A=((e,t)=>{for(var n in t||(t={}))u.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))d.call(t,n)&&p(e,n,t[n]);return e})({},k),T={label:(M=k.value[0]/20,Intl.DateTimeFormat("zh",{month:"long"}).format(new Date(M.toString()))),value:k.value[1]},s(A,l(T)))),x);var A,T,M}},2268:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const f=()=>{const e=(0,i.useWindowSize)().width/2,t=i.reactSvgRenderTarget,[n,r]=o().useState(),[a,f]=o().useState(),h=e=>Intl.DateTimeFormat("zh",{month:"long"}).format(new Date((e+1).toString()));if(o().useEffect((()=>{const n=[[65,59,80,81,56,55,40].map((e=>[e])),[55,49,70,71,46,45,30].map((e=>[e])),[45,39,60,61,36,35,30].map((e=>[e-20,e])),[65,59,80,81,56,55,40].map((e=>[e-30,e-15,e-5,e]))],r=[35,29,50,51,26,25,10].map(((e,t)=>({x:t,y:e}))),{children:o,select:a,tx:g,ty:m}=(0,i.getBarChart)(n,[[16711680],[65280],[255],[16711680,65280,255]],((e,n)=>t.renderPolygon((0,i.getRoundedRectPoints)(e,5,30),{fillColor:n,strokeWidth:0})),t,{y:5},{width:e,height:500},{left:25,right:10,top:10,bottom:20},{getXLabel:h,bounding:(0,i.getPointsBounding)(r)}),y=r.map((e=>({x:g(e.x+.5),y:m(e.y)})));o.push(t.renderPolyline(y,{strokeColor:0})),o.push(...y.map((e=>t.renderCircle(e.x,e.y,3,{fillColor:0,strokeWidth:0})))),f({children:o,select:e=>{const t=y.findIndex((t=>(0,i.getTwoPointsDistance)(t,e)<=5));return t>=0?(n=((e,t)=>{for(var n in t||(t={}))u.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))d.call(t,n)&&p(e,n,t[n]);return e})({},y[t]),o={value:r[t]},s(n,l(o))):a(e);var n,o}})}),[e]),!a)return null;let g=a.children;return n&&(g=[...a.children,...(0,i.renderChartTooltip)(t,n,n.value,{getXLabel:h})]),o().createElement("div",{style:{position:"absolute",inset:"0px"}},t.renderResult(g,e,500,{attributes:{onMouseMove:e=>r(a.select({x:e.clientX,y:e.clientY}))}}))}},1406:(e,t,n)=>{"use strict";n.d(t,{CADEditor:()=>_,useInitialStateValidated:()=>M,usePlugins:()=>A});var r=n(3696),o=n.n(r),i=n(9758),a=n(8662),s=n(2852),l=n(7470),c=n(3031),u=n(4469),d=n(9533),p=n(7449),f=n(81),h=n.n(f),g=n(4864),m=Object.defineProperty,y=Object.defineProperties,v=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,b=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,E=(e,t,n)=>t in e?m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))b.call(t,n)&&E(e,n,t[n]);if(x)for(var n of x(t))C.call(t,n)&&E(e,n,t[n]);return e},k=(e,t)=>y(e,v(t)),w=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{s(n.next(e))}catch(e){o(e)}},a=e=>{try{s(n.throw(e))}catch(e){o(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())}));(0,a.enablePatches)(),(0,p.registerRenderer)(i.reactWebglRenderTarget),(0,p.registerRenderer)(i.reactSvgRenderTarget),(0,p.registerRenderer)(i.reactCanvasRenderTarget),navigator.gpu&&(0,p.registerRenderer)(i.reactWebgpuRenderTarget);const _=o().forwardRef(((e,t)=>{var n,r,s,l,c,f,g,m,y,v,x,b,C,E;const _=new i.Debug(e.debug),{width:A,height:T}=(0,i.useWindowSize)(),{filterSelection:M,selected:L,isSelected:I,addSelection:O,removeSelection:B,setSelected:F,isSelectable:D,operations:z,executeOperation:U,resetOperation:N,selectBeforeOperate:G,operate:j,message:V,onSelectBeforeOperateKeyDown:W}=(0,i.useSelectBeforeOperate)({},((e,t)=>{var n;if("command"===(null==e?void 0:e.type)){if(Ne.current)return null==(n=Ne.current)||n.call(Ne,t),Ne.current=void 0,!0;const r=(0,d.getCommand)(e.name);if(null==r?void 0:r.execute)return X((n=>{var o;n=se(n),null==(o=r.execute)||o.call(r,{contents:n,state:K,selected:t,setEditingContentPath:le,type:e.name,strokeStyleId:he,fillStyleId:ge,textStyleId:me,width:A,height:T,transform:gt})})),F(),N(),!0}return!1}),{onChange:t=>{var n;return null==(n=e.onSendSelection)?void 0:n.call(e,t.map((e=>e[0])))}}),{snapTypes:H,renderTarget:q,readOnly:$,inputFixed:Y}=e,{state:K,setState:X,undo:Z,redo:Q,canRedo:J,canUndo:ee,applyPatchFromSelf:te,applyPatchFromOtherOperators:ne}=(0,i.usePatchBasedUndoRedo)(e.initialState,e.operator,{onApplyPatchesFromSelf(t,n){var r;const o=[];n.forEach((e=>{if("replace"===e.op&&1===e.path.length&&"length"===e.path[0]&&"number"==typeof e.value)for(let t=e.value;t1){const e=se(r)[t];e&&d.add(e)}if("add"!==e.op||e.path.length>1){const e=se(n)[t];e&&p.add(e)}}else if("length"===t&&"replace"===e.op&&"number"==typeof e.value){const t=se(n)[e.value];t&&p.add(t)}}for(const e of d){const t=(0,i.validate)(e,u.Content);if(!0!==t)return console.error(t),!1}for(const e of d){const t=null==(a=null==(o=(0,u.getContentModel)(e))?void 0:o.getGeometries)?void 0:a.call(o,e,r);(null==t?void 0:t.bounding)?null==Dt||Dt.rtree.insert((0,u.boundingToRTreeBounding)(t.bounding),e):null==Dt||Dt.boundlessContents.add(e)}for(const e of p){const t=null==(l=null==(s=(0,u.getContentModel)(e))?void 0:s.getGeometries)?void 0:l.call(s,e,n);(null==t?void 0:t.bounding)?null==Dt||Dt.rtree.remove((0,u.boundingToRTreeBounding)(t.bounding),e):null==Dt||Dt.boundlessContents.delete(e)}Dn((0,u.zoomContentsToFit)(Fn,Bn,r,r,1)),null==(c=e.onChange)||c.call(e,r)}}),{selected:re,setSelected:oe}=(0,i.useSelected)({maxCount:1}),{editingContent:ie,trimPatchPath:ae,getContentByPath:se,setEditingContentPath:le,prependPatchPath:ce}=(0,i.usePartialEdit)(K,{onEditingContentPathChange(e){In(e)}}),[ue,de]=o().useState(),pe=[],fe=[],he=null==(n=u.getStrokeStyles(K).find((e=>e.content.isCurrent)))?void 0:n.index,ge=null==(r=u.getFillStyles(K).find((e=>e.content.isCurrent)))?void 0:r.index,me=null==(s=u.getTextStyles(K).find((e=>e.content.isCurrent)))?void 0:s.index,[ye,ve]=o().useState(),[xe,be]=o().useState(),[Ce,Ee]=o().useState(),Pe=void 0!==xe?ie[xe]:void 0,ke=Pe?null==(c=null==(l=(0,u.getContentModel)(Pe))?void 0:l.getGeometries)?void 0:c.call(l,Pe,ie).bounding:void 0,we=void 0!==ye?ie[ye]:void 0,_e=we&&(0,u.isViewportContent)(we)?we:void 0,Se=_e&&!_e.locked?_e:void 0,Re=void 0!==ye&&Se?ye:void 0,Ae=_e?e=>u.reverseTransformPositionByViewport(e,_e):void 0,Te=_e?e=>u.transformPositionByViewport(e,_e):void 0,[Me,Le]=o().useState(0),[Ie,Oe]=o().useState(0),[Be,Fe]=o().useState(1),[De,ze]=o().useState(0),Ue=o().useRef(),Ne=o().useRef(),Ge=o().useRef(),[je,Ve]=o().useState(),[We,He]=o().useState([]),{x:qe,y:$e,ref:Ye,setX:Ke,setY:Xe}=(0,i.useWheelScroll)({localStorageXKey:e.id+"-x",localStorageYKey:e.id+"-y",setXOffset:Se?e=>Le((t=>t+e)):void 0,setYOffset:Se?e=>Oe((t=>t+e)):void 0}),{scale:Ze,setScale:Qe,ref:Je}=(0,i.useWheelZoom)({min:S,max:R,localStorageKey:e.id+"-scale",setScaleOffset:Se?(e,t)=>{Fe((t=>t*e)),t=(0,i.reverseTransformPosition)(t,gt),Le((n=>(t.x-Se.x)*Ze*(1-e)+n*e)),Oe((n=>(t.y-Se.y)*Ze*(1-e)+n*e))}:void 0,onChange(e,t,n){const r=(0,i.scaleByCursorPosition)({width:A,height:T},t/e,n);Ke(r.setX),Xe(r.setY)}}),[et,tt]=(0,i.useLocalStorageState)(e.id+"-rotate",0),{offset:nt,onStart:rt,mask:ot,resetDragRotate:it}=(0,i.useDragRotate)((()=>{_e&&void 0!==ye?X((e=>{const t=(e=se(e))[ye];t&&(0,u.isViewportContent)(t)&&(t.rotate=ft)})):tt((0,i.angleToRadian)(null==nt?void 0:nt.angle))}),{transformOffset:(e,t)=>{if(t&&void 0!==e&&!t.shiftKey){const t=90*Math.round(e/90);if(Math.abs(t-e)<5)return t}return e}}),{zoomIn:at,zoomOut:st}=(0,i.useZoom)(Ze,Qe,{min:S,max:R}),{offset:lt,onStart:ct,mask:ut,resetDragMove:dt}=(0,i.useDragMove)((()=>{void 0===Re?(Ke((e=>e+lt.x)),Xe((e=>e+lt.y))):te(ce(pe),ce(fe))})),pt=Ze*(null!=(f=null==_e?void 0:_e.scale)?f:1),ft=void 0!==(null==nt?void 0:nt.angle)?(0,i.angleToRadian)(nt.angle):void 0,ht=null!=ft?ft:_e?null!=(g=_e.rotate)?g:0:et,gt={x:qe,y:$e,scale:Ze,center:{x:A/2,y:T/2},rotate:_e?et:null!=ft?ft:et};if(void 0!==Re){const[,e,t]=(0,a.produceWithPatches)(ie,(e=>{const t=e[Re];if(t&&(0,u.isViewportContent)(t)){const e=i.rotatePosition(lt,{x:0,y:0},-et);t.x+=(e.x+Me)/Ze,t.y+=(e.y+Ie)/Ze,t.scale*=Be,void 0!==(null==nt?void 0:nt.angle)&&(t.rotate=(0,i.angleToRadian)(nt.angle))}}));pe.push(...e),fe.push(...t)}else gt.x+=lt.x,gt.y+=lt.y;(0,i.useDelayedAction)(0!==Me||0!==Ie||1!==Be,500,(()=>{te(ce(pe),ce(fe)),Le(0),Oe(0),Fe(1)}));const mt=[];ie.forEach(((e,t)=>{var n,r,o,i;if(e)if(I([t]))mt.push({content:e,path:[t]});else for(const a of L)if(2===a.length&&a[0]===t){const t=null==(i=null==(o=null==(r=null==(n=(0,u.getContentModel)(e))?void 0:n.getGeometries)?void 0:r.call(n,e,ie))?void 0:o.lines)?void 0:i[a[1]];t&&mt.push({content:u.geometryLineToContent(t),path:a})}}));const yt=e=>{Ue.current=t=>{e(t.position,t.target)}},vt=(e,t)=>{const n=L,r="operate"===z.type?z.operate:void 0;Ne.current=e=>{t(e.map((e=>({id:e[0],partIndex:e[1]})))),F(...n),r?j(r):N()},F(),G(e,{type:"command",name:""})},xt=e=>(Te&&(e=Te(e)),i.transformPosition(e,gt)),{editPoint:bt,editMenu:Ct,editLastPosition:Et,updateEditPreview:Pt,onEditMove:kt,onEditClick:wt,onEditContextMenu:_t,getEditAssistentContents:St,resetEdit:Rt}=(0,i.useEdit)(((e,t)=>te(ce([...pe,...e]),ce([...fe,...t]))),(e=>{var t,n;return null==(n=null==(t=(0,u.getContentModel)(e))?void 0:t.getEditPoints)?void 0:n.call(t,e,ie)}),{scale:pt,readOnly:$||"operate"===z.type,contentReadOnly:e=>e.readonly}),{snapOffset:At,snapOffsetActive:Tt,snapOffsetInput:Mt,setSnapOffset:Lt,onSnapOffsetKeyDown:It}=function(e){const[t,n]=o().useState(),[r,i]=o().useState(""),[a,s]=o().useState(!1);return{snapOffset:t,snapOffsetActive:a,setSnapOffset:n,onSnapOffsetKeyDown(e){"Escape"===e.key&&(n(void 0),i(""))},snapOffsetInput:e&&o().createElement("input",{placeholder:t?`${t.x},${t.y}`:"x,y",value:r,style:{position:"absolute",left:"104px",bottom:"1px",width:"70px"},onChange:e=>i(e.target.value),onFocus:()=>s(!0),onBlur:()=>s(!1),onKeyDown:e=>{if("Enter"===e.key){if(!r)return n(void 0),void s(!1);const e=r.split(",");if(2===e.length){const t=+e[0],r=+e[1];isNaN(t)||isNaN(r)||(n({x:t,y:r}),i(""),s(!1))}}}})}}("operate"===z.type&&"command"===z.operate.type||"operate"!==z.type&&void 0!==bt),{getSnapAssistentContents:Ot,getSnapPoint:Bt}=(0,i.usePointSnap)("operate"===z.type&&!(null==(m=(0,d.getCommand)(z.operate.name))?void 0:m.pointSnapDisabled)||void 0!==bt||void 0!==Ue.current,u.getIntersectionPoints,H,u.getContentModel,At,5/pt),Ft=e=>Dt?e?[...Dt.rtree.search({x:e.start.x,y:e.start.y,w:e.end.x-e.start.x,h:e.end.y-e.start.y}),...Dt.boundlessContents]:K:[],[Dt,zt]=o().useState();_.mark("before search");const Ut=e=>(e=(0,i.reverseTransformPosition)(e,gt),Ae&&(e=Ae(e)),e),Nt=(0,i.getPointsBoundingUnsafe)((0,i.getPolygonFromTwoPointsFormRegion)({start:{x:0,y:0},end:{x:A,y:T}}).map((e=>Ut(e)))),Gt=new Set(Ft(Nt)),jt=e=>Gt.has(e)||pn.includes(e),{commandMask:Vt,commandUpdateSelectedContent:Wt,startCommand:Ht,onCommandMouseDown:qt,onCommandMouseUp:$t,onCommandKeyDown:Yt,onCommandKeyUp:Kt,commandInput:Xt,commandButtons:Zt,commandPanel:Qt,onCommandMouseMove:Jt,commandAssistentContents:en,commandSelected:tn,commandHovering:nn,getCommandByHotkey:rn,commandLastPosition:on,resetCommand:an}=(0,d.useCommands)(((...e)=>w(void 0,[...e],(function*({updateContents:e,nextCommand:t}={}){var n;let r=K;if(e){const[,...t]=(0,a.produceWithPatches)(ie,(t=>{e(t,L)}));r=yield te(ce(t[0]),ce(t[1]))}else pe.length>0&&(r=yield te(ce(pe),ce(fe)));"operate"===z.type&&"command"===z.operate.type&&(null==(n=(0,d.getCommand)(z.operate.name))?void 0:n.repeatedly)||(N(),t&&Mn({type:"command",name:t},[],se(r)))}))),(e=>Bt(Ut(e),ie,Ft,sn).position),Y,"operate"===z.type&&"command"===z.operate.type?z.operate.name:void 0,mt,A,T,qe,$e,et,pt,he,ge,me,ie,e.backgroundColor,vt,(e=>{Ge.current=e}),xt,Ft,jt,F),sn=null!=Et?Et:on,{onStartSelect:ln,dragSelectMask:cn,endDragSelect:un,resetDragSelect:dn}=(0,i.useDragSelect)(((e,t,n)=>{var r,o;if(t){const r=(0,i.getPolygonFromTwoPointsFormRegion)((0,i.getTwoPointsFormRegion)(e,t)).map((e=>Ut(e)));if(Ge.current)return Ge.current(r),void(Ge.current=void 0);if("operate"===z.type&&"zoom window"===z.operate.name){if(void 0!==ye&&_e){const e=(0,u.getViewportByPoints)(_e,r,K,_e.rotate);return e&&X((t=>{const n=(t=se(t))[ye];n&&(0,u.isViewportContent)(n)&&(n.x=e.x,n.y=e.y,n.scale=e.scale)})),void N()}const e=(0,i.zoomToFitPoints)(r,{width:A,height:T},{x:A/2,y:T/2},1,gt.rotate);return e&&(Qe(e.scale),Ke(e.x),Xe(e.y)),void N()}const o=(0,i.getContentsByRegion)(ie,r,e.x>t.x,!!gt.rotate,u.getContentModel,n.shiftKey?void 0:D,jt);n.shiftKey?B(...o):O(...o)}else{const t=Ut(e),n=ie.findIndex((e=>{var n,r;return!!e&&(0,u.isViewportContent)(e)&&!!(null==(r=null==(n=(0,u.getContentModel)(e.border))?void 0:n.isPointIn)?void 0:r.call(n,e.border,t,K))}));if(n>=0){if(ye===n&&_e){const e=(0,u.getDefaultViewport)(_e,K,_e.rotate);e&&X((t=>{const n=(t=se(t))[ye];n&&(0,u.isViewportContent)(n)&&(n.x=e.x,n.y=e.y,n.scale=e.scale)}))}return void ve(n)}const a=Ft({start:t,end:t}).filter((e=>!!e)).map((e=>(0,u.getContentIndex)(e,ie))),s=(0,i.getContentByClickPosition)(ie,t,(()=>!0),u.getContentModel,!1,jt,a);if(void 0!==s){const e=ie[s[0]];if(e){const n=null==(o=null==(r=(0,u.getContentModel)(e))?void 0:r.getChildByPoint)?void 0:o.call(r,e,t,K,{textStyleId:me});n&&(Ee(n.child),n.patches&&te(ce(n.patches[0],s),ce(n.patches[1],s)))}return void be(s[0])}if(void 0!==xe)return be(void 0),void Ee(void 0);if(void 0!==ye)return void ve(void 0);const l=(0,u.zoomContentsToFit)(A,T,ie,K,.8,gt.rotate);l&&(Qe(l.scale),Ke(l.x),Xe(l.y))}}));_.mark("before assistent contents");const pn=[...Ot((e=>k(P({type:"circle"},e),{strokeColor:65280})),(e=>k(P({type:"rect"},e),{angle:0,strokeColor:65280})),(e=>({type:"polyline",points:e,strokeColor:65280}))),...en||[]],fn=Pt();pe.push(...null!=(y=null==fn?void 0:fn.patches)?y:[]),fe.push(...null!=(v=null==fn?void 0:fn.reversePatches)?v:[]),pn.push(...null!=(x=null==fn?void 0:fn.assistentContents)?x:[]),fn&&pn.push(...(0,u.updateReferencedContents)(fn.content,fn.result,ie));for(const{content:e,path:t}of mt)if(1===t.length){const n=bt&&(0,i.isSamePath)(bt.path,t)?null==fn?void 0:fn.result:null==fn?void 0:fn.relatedEditPointResults.get(e);pn.push(...St(null!=n?n:e,(e=>k(P({type:"rect"},e),{fillColor:16777215,angle:0}))))}const hn=Wt(K);pn.push(...hn.assistentContents);for(const[e,t]of hn.patches)pe.push(...e),fe.push(...t);o().useEffect((()=>{var t;return null==(t=e.setCanUndo)?void 0:t.call(e,ee)}),[ee]),o().useEffect((()=>{var t;return null==(t=e.setCanRedo)?void 0:t.call(e,J)}),[J]),o().useEffect((()=>{e.setOperation("select"!==z.type?z.operate.name:void 0)}),[z]);const[gn,mn]=o().useState([]);o().useImperativeHandle(t,(()=>({handlePatchesEvent(e){try{ne(e.patches,e.reversePatches,e.operator)}catch(e){console.error(e)}},handleSelectionEvent(e){mn((0,a.produce)(gn,(t=>{const n=gn.findIndex((t=>t.operator===e.operator));n>=0?t[n].selection=e.selectedContents:t.push({selection:e.selectedContents,operator:e.operator})})))},undo:Z,redo:Q,startOperation:Mn})),[ne]);const{input:yn,inputPosition:vn,setInputPosition:xn,setCursorPosition:bn,clearText:Cn}=(0,i.useCursorInput)(V,"operate"===z.type||$?void 0:(e,t)=>{if("Enter"===e.key&&t){const n=rn(t);n&&Mn({type:"command",name:n}),Cn(),e.stopPropagation()}},{hideIfNoInput:!0,inputStyle:{textTransform:"uppercase"}});let En=yn;!$&&yn&&Y&&(En=o().cloneElement(yn,{style:u.fixedInputStyle}));const Pn=(0,i.useEvent)((e=>{e.shiftKey&&e.preventDefault();const t=Ut({x:e.clientX,y:e.clientY}),n=Bt(t,ie,Ft,sn);if(Ue.current)return Ue.current({position:n.position,target:n.target?{id:(0,u.getContentIndex)(n.target.content,K),snapIndex:n.target.snapIndex,param:n.target.param}:void 0}),void(Ue.current=void 0);if("operate"===z.type&&"command"===z.operate.type&&(null==Ht||Ht(n.position,n.target?{id:(0,u.getContentIndex)(n.target.content,K),snapIndex:n.target.snapIndex,param:n.target.param}:void 0)),"operate"!==z.type)if(bt)wt(n.position);else if(re.length>0)e.shiftKey?B(...re):O(...re),oe();else{if(void 0!==xe&&!_e)return be(void 0),void Ee(void 0);ln(e)}("operate"===z.type&&"zoom window"===z.operate.name||Ge.current)&&ln(e),Lt(void 0),Ve(void 0)})),kn=(0,i.useEvent)((e=>{e.shiftKey&&e.preventDefault(),"operate"===z.type&&"move canvas"===z.operate.name||4===e.buttons?ct({x:e.clientX,y:e.clientY}):qt&&qt(Ut({x:e.clientX,y:e.clientY}))})),wn=(0,i.useEvent)((e=>{null==$t||$t(Ut({x:e.clientX,y:e.clientY}))})),_n=(0,i.useEvent)((e=>{const t={x:e.clientX,y:e.clientY};xn(t);const n=Ut(t);if(bn(n),de({x:Math.round(n.x),y:Math.round(n.y)}),"operate"===z.type&&"command"===z.operate.type&&Jt){const e=Bt(n,ie,Ft,sn);Jt(e.position,t,e.target?{id:(0,u.getContentIndex)(e.target.content,K),snapIndex:e.target.snapIndex,param:e.target.param}:void 0)}if("operate"!==z.type){let t;if(bt&&(0,u.isViewportContent)(bt.content)){const e=bt.content;t=Bt(u.reverseTransformPositionByViewport(n,bt.content),ie,Ft,sn,(t=>u.transformPositionByViewport(t,e))),t.target||(t=Bt(n,ie,Ft,sn))}else t=Bt(n,ie,Ft,sn);kt(t.position,mt,t.target);const r=Ft({start:n,end:n}).filter((e=>!!e)).map((e=>(0,u.getContentIndex)(e,ie)));oe((0,i.getContentByClickPosition)(ie,n,e.shiftKey?()=>!0:D,u.getContentModel,z.select.part,jt,r,3/pt))}})),Sn=(0,i.useEvent)((e=>{un(e)})),Rn=(0,i.useEvent)((()=>{oe()}));(0,i.useGlobalKeyDown)((e=>{var t;null==Yt||Yt(e),W(e),It(e),(0,i.metaKeyIfMacElseCtrlKey)(e)?"Minus"===e.code?st(e):"Equal"===e.code?at(e):"ArrowLeft"===e.key?(void 0!==ye&&ke?X((e=>{const t=(e=se(e))[ye];if(t&&(0,u.isViewportContent)(t)){const e=i.rotatePosition({x:(ke.end.x-ke.start.x)/10,y:0},{x:0,y:0},-et);t.x+=e.x,t.y+=e.y}})):Ke((e=>e+A/10)),e.preventDefault()):"ArrowRight"===e.key?(void 0!==ye&&ke?X((e=>{const t=(e=se(e))[ye];if(t&&(0,u.isViewportContent)(t)){const e=i.rotatePosition({x:(ke.end.x-ke.start.x)/10,y:0},{x:0,y:0},-et);t.x-=e.x,t.y-=e.y}})):Ke((e=>e-A/10)),e.preventDefault()):"ArrowUp"===e.key?(void 0!==ye&&ke?X((e=>{const t=(e=se(e))[ye];if(t&&(0,u.isViewportContent)(t)){const e=i.rotatePosition({x:0,y:(ke.end.y-ke.start.y)/10},{x:0,y:0},-et);t.x+=e.x,t.y+=e.y}})):Xe((e=>e+T/10)),e.preventDefault()):"ArrowDown"===e.key?(void 0!==ye&&ke?X((e=>{const t=(e=se(e))[ye];if(t&&(0,u.isViewportContent)(t)){const e=i.rotatePosition({x:0,y:(ke.end.y-ke.start.y)/10},{x:0,y:0},-et);t.x-=e.x,t.y-=e.y}})):Xe((e=>e-T/10)),e.preventDefault()):"KeyZ"===e.code?"select"===z.type?(e.shiftKey?Q(e):Z(e),F()):(null==(t=(0,d.getCommand)(z.operate.name))?void 0:t.repeatedly)&&(e.shiftKey?Q(e):Z(e)):e.shiftKey||("KeyA"===e.code?(O(...ie.map(((e,t)=>[t]))),e.preventDefault()):"Digit0"===e.code?(Qe(1),Ke(0),Xe(0),e.preventDefault()):"KeyC"===e.code?(Mn({type:"command",name:"copy"}),e.preventDefault()):"KeyV"===e.code?(Mn({type:"command",name:"paste"}),e.preventDefault()):"KeyX"===e.code&&(Mn({type:"command",name:"cut"}),e.preventDefault())):"Escape"===e.key&&(_e||(be(void 0),Ee(void 0)),null==an||an(!0),Rt(),Ve(void 0),dn(),it(),dt())})),i.useGlobalKeyUp((e=>{null==Kt||Kt(e)}));const[An,Tn]=o().useState(),Mn=(e,t=L,n=ie)=>{if(Tn(e),null==an||an(),"command"===e.type){const r=(0,d.getCommand)(e.name);if(r){const o={count:r.selectCount,part:"select part"===r.selectType,selectable(e){var t,o;const i=(0,u.getContentByIndex)(n,e);return!!i&&(null==(o=null==(t=r.contentSelectable)?void 0:t.call(r,i,n))||o)}},{result:i,needSelect:a}=M(o.selectable,o.count,t);if(a)return void G(o,e);if(U(e,i))return}}if(j(e),ue&&Jt){const e=Bt(ue,n,Ft);Jt(e.position,vn,e.target?{id:(0,u.getContentIndex)(e.target.content,K),snapIndex:e.target.snapIndex,param:e.target.param}:void 0)}},Ln=(0,i.useEvent)((e=>w(void 0,null,(function*(){e.preventDefault();const t={x:e.clientX,y:e.clientY},n=Ut(t);if(null==bt?void 0:bt.menu)return void _t(n,((e,n)=>o().createElement(i.Menu,{items:e.map((e=>({title:e.title,onClick:n(e)}))),style:{left:t.x+"px",top:t.y+"px"}})));if(je)return void Ve(void 0);const r=[{title:"Undo",disabled:!ee,onClick:()=>{Z(),Ve(void 0)}},{title:"Redo",disabled:!J,onClick:()=>{Q(),Ve(void 0)}}];An&&r.push({type:"divider"},{title:An.name,onClick:()=>{Mn(An),Ve(void 0)}}),r.push({type:"divider"}),r.push({title:"Create geometry lines",disabled:0===ie.length,onClick:()=>{Mn({type:"command",name:"create geometry lines"}),Ve(void 0)}});try{const e=yield navigator.clipboard.readText();if(e){let t;const n=e.split(",");if(2===n.length){const e=n.map((e=>+e));e.every((e=>!isNaN(e)))&&(t={type:"point",x:e[0],y:e[1]})}if(!t){const n=JSON.parse(e);i.is(n,u.Content)?t=n:i.is(n,i.Position)?t=k(P({},n),{type:"point"}):i.is(n,i.Circle)?t=k(P({},n),{type:"circle"}):i.is(n,i.Ellipse)&&(t=k(P({},n),{type:"ellipse"}))}t&&r.push({title:`Mark ${t.type}`,onClick:()=>{t&&He([...We,t]),Ve(void 0)}})}}catch(e){console.info(e)}r.push({type:"divider"}),r.push({title:"Select All",disabled:0===ie.length,onClick:()=>{O(...ie.map(((e,t)=>[t]))),Ve(void 0)}});const a=(0,i.getContentsByClickPosition)(ie,n,e.shiftKey?()=>!0:D,u.getContentModel,jt,3/pt);a.length>0&&r.push({title:"Select",children:a.map((e=>{var t;return{title:(null==(t=ie[e[0]])?void 0:t.type)+" "+e[0],onClick:()=>{O(e),Ve(void 0)}}}))}),r.push({type:"divider"}),r.push({title:"Cut",disabled:0===L.length,onClick:()=>{Mn({type:"command",name:"cut"}),Ve(void 0)}}),r.push({title:"Copy",disabled:0===L.length,onClick:()=>{Mn({type:"command",name:"copy"}),Ve(void 0)}}),r.push({title:"Paste",onClick:()=>{Mn({type:"command",name:"paste"}),Ve(void 0)}}),r.push({type:"divider"}),r.push({title:"Zoom In",onClick:()=>{at(),Ve(void 0)}}),r.push({title:"Zoom Out",onClick:()=>{st(),Ve(void 0)}}),r.push({title:"Reset",onClick:()=>{Qe(1),Ke(0),Xe(0),Ve(void 0)}}),Ve(o().createElement(i.Menu,{items:r,style:{left:t.x+"px",top:t.y+"px"}}))})))),In=e=>{var t,n;const r=h()(),o=new Set;for(const i of e){if(!i)continue;const a=null==(n=null==(t=(0,u.getContentModel)(i))?void 0:t.getGeometries)?void 0:n.call(t,i,e);(null==a?void 0:a.bounding)?r.insert((0,u.boundingToRTreeBounding)(a.bounding),i):o.add(i)}zt({rtree:r,boundlessContents:o})};pn.push(...We);const On=void 0!==e.onApplyPatchesFromSelf,Bn=100,Fn=100;o().useEffect((()=>{In(e.initialState),Dn((0,u.zoomContentsToFit)(Fn,Bn,K,K,1))}),[e.initialState]);const{setMinimapTransform:Dn,minimap:zn,getMinimapPosition:Un}=(0,i.useMinimap)({viewport:{width:A/gt.scale,height:T/gt.scale,rotate:gt.rotate,center:(0,i.reverseTransformPosition)(gt.center,gt)},width:Fn,height:Bn,children:t=>o().createElement(o().Fragment,null,o().createElement(p.MemoizedRenderer,{type:q,contents:ie,x:t.x,y:t.y,scale:t.scale,width:Fn,height:Bn,backgroundColor:e.backgroundColor,debug:e.debug,printMode:e.printMode,performanceMode:!0,operatorVisible:On,time:De,onClick:e=>{if(Un){const t=Un(e);Ke((gt.center.x-t.x)*gt.scale),Xe((gt.center.y-t.y)*gt.scale)}},style:{cursor:"default"}}))}),Nn=e=>{const[,...t]=(0,a.produceWithPatches)(ie,(t=>{mt.forEach((n=>{const r=(0,u.getContentByIndex)(t,n.path);r&&e(r,t)}))}));te(ce(t[0]),ce(t[1]))};let Gn,jn;if(e.panelVisible&&mt.length>0){const e={},t=new Set,n=[],r=[],a=[],s=[];let l=0;mt.forEach((c=>{var d,p,f,h;t.add(c.content.type);const g=c.path[0];n.push(g);const m=null==(p=null==(d=(0,u.getContentModel)(c.content))?void 0:d.propertyPanel)?void 0:p.call(d,c.content,Nn,K,{startTime:e=>{const t=performance.now(),n=r=>{const o=r-t;o>=e?ze(0):(ze(o),requestAnimationFrame(n))};requestAnimationFrame(n)},activeChild:g===xe?Ce:void 0,acquirePoint:yt,acquireContent:vt});m&&Object.entries(m).forEach((([t,n])=>{const r=e[t],o=Array.from((0,i.iterateItemOrArray)(n));0!==o.length&&(Array.isArray(r)?r.push(...o):e[t]=r?[r,...o]:o)})),r.push(o().createElement(i.BooleanEditor,{value:void 0!==c.content.z,setValue:e=>Nn((t=>{t.z=e?g:void 0}))})),void 0!==c.content.z&&r.push(o().createElement(i.NumberEditor,{value:c.content.z,setValue:e=>Nn((t=>{t.z=e}))})),a.push(o().createElement(i.BooleanEditor,{value:!1!==c.content.visible,setValue:e=>Nn((t=>{t.visible=!!e&&void 0}))})),s.push(o().createElement(i.BooleanEditor,{value:!0===c.content.readonly,setValue:e=>Nn((t=>{t.readonly=!!e||void 0}))}));const y=null==(h=null==(f=(0,u.getContentModel)(c.content))?void 0:f.getArea)?void 0:h.call(f,c.content);y&&(l+=y)})),e.z=r,e.visible=a,e.readonly=s,l&&(e.areas=o().createElement(i.NumberEditor,{value:l})),e.debug=o().createElement(i.Button,{onClick:()=>console.info(mt.map((e=>{var t,n;return[e.content,null==(n=null==(t=(0,u.getContentModel)(e.content))?void 0:t.getGeometries)?void 0:n.call(t,e.content,K)]})))},"log to console"),Gn=o().createElement("div",{style:{position:"absolute",right:"0px",top:"100px",bottom:"0px",width:"400px",overflowY:"auto",background:"white",zIndex:11}},Array.from(t).join(","),o().createElement("div",null,n.join(",")),e&&o().createElement(i.ObjectEditor,{properties:e,readOnly:$}))}Pe&&(jn=null==(C=null==(b=(0,u.getContentModel)(Pe))?void 0:b.editPanel)?void 0:C.call(b,Pe,pt,Nn,K,(()=>be(void 0)),xt,Ce)),e.debug&&console.info(_.print());const Vn=o().createElement("div",{ref:(0,i.bindMultipleRefs)(Ye,Je)},o().createElement("div",{style:{cursor:null!=(E=null==bt?void 0:bt.cursor)?E:"operate"===z.type&&"move canvas"===z.operate.name?"grab":"crosshair",position:"absolute",inset:"0px",overflow:"hidden"},onMouseMove:_n},Dt&&o().createElement(p.MemoizedRenderer,{type:q,contents:ie,previewPatches:0===pe.length?void 0:pe,assistentContents:0===pn.length?void 0:pn,selected:L,othersSelectedContents:gn,hovering:re,assistentSelected:tn,assistentHovering:nn,active:xe,activeViewportIndex:ye,onClick:Pn,onMouseDown:kn,onMouseUp:wn,onContextMenu:Ln,onDoubleClick:Sn,onMouseLeave:Rn,x:gt.x,y:gt.y,scale:gt.scale,rotate:gt.rotate,width:A,height:T,backgroundColor:e.backgroundColor,printMode:e.printMode,performanceMode:e.performanceMode,operatorVisible:On,debug:e.debug,time:De}),zn,o().createElement("div",{style:{width:"100px",height:"100px",left:"1px",top:T-204+"px",boxSizing:"border-box",position:"absolute",transform:`rotate(${ht}rad)`,border:"1px solid black",borderRadius:"50px"}},o().createElement(i.RotationBar,{onMouseDown:()=>rt({x:51,y:T-154})})),ue&&o().createElement("span",{style:{position:"absolute",right:0}},ue.x,",",ue.y),Vt,!Tt&&En,!$&&!Tt&&Xt,!$&&!Tt&&Zt,Qt,Ct,je,!$&&Mt),cn,ut,ot);return o().createElement(o().Fragment,null,Vn,Gn,jn)})),S=.001,R=100;function A(){const[e,t]=o().useState([]),[n,r]=o().useState(!1);return o().useEffect((()=>{(()=>{w(this,null,(function*(){try{const e=yield function(){return w(this,null,(function*(){const e=yield Promise.all(g.pluginScripts.map((e=>import("data:text/javascript;charset=utf-8,"+encodeURIComponent(e))))),t=k(P(P({},i),u),{React:o(),produce:a.produce,produceWithPatches:a.produceWithPatches,renderToStaticMarkup:s.renderToStaticMarkup,createRoot:l.createRoot,parseExpression:c.parseExpression,tokenizeExpression:c.tokenizeExpression,evaluateExpression:c.evaluateExpression}),n=[];for(const r of e){if(r.getModel)for(const e of(0,i.iterateItemOrArray)(r.getModel(t)))(0,u.registerModel)(e);if(r.getCommand)for(const e of(0,i.iterateItemOrArray)(r.getCommand(t)))(0,d.registerCommand)(e),e.type?n.push(...e.type):n.push(e)}return n}))}();t(e),r(!0)}catch(e){console.info(e),r(!0)}}))})()}),[]),{pluginCommandTypes:e,pluginLoaded:n}}const T=[(0,i.Nullable)(u.Content)];function M(e,t){const[n,r]=o().useState(!1);return o().useEffect((()=>{if(e&&t){const t=(0,i.validate)(e,T);!0!==t?console.error(t):r(!0)}}),[e,t]),n}},9533:(e,t,n)=>{"use strict";n.d(t,{getCommand:()=>u,registerCommand:()=>p,useCommands:()=>d});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=n(4469);const l={},c={};function u(e){return l[e]}function d(e,t,n,o,u,d,p,f,h,g,m,y,v,x,b,C,E,P,k,w,_,S){let R;return Object.values(l).forEach((n=>{var r;if(n.useCommand){const i=o&&(o===n.name||(null==(r=n.type)?void 0:r.some((e=>e.name===o))))?o:void 0,a=n.useCommand({onEnd:e,transform:t,type:i,selected:u,setSelected:S,width:d,height:p,x:f,y:h,rotate:g,scale:m,strokeStyleId:y,fillStyleId:v,textStyleId:x,contents:b,backgroundColor:C,acquireContent:E,acquireRegion:P,transformPosition:k,getContentsInRange:w,contentVisible:_});i&&(R=a)}})),{commandMask:null==R?void 0:R.mask,commandInput:(null==R?void 0:R.input)?i().cloneElement(R.input,n?{style:s.fixedInputStyle}:{},...R.input.props.children):void 0,commandButtons:(null==R?void 0:R.subcommand)?i().cloneElement(R.subcommand,{style:n?s.fixedButtomStyle:s.fixedInputStyle}):void 0,commandPanel:null==R?void 0:R.panel,commandUpdateSelectedContent(e){const t=[],n=[],o=u.map((e=>e.content));let i=[];for(const{content:r,path:s}of u)if(null==R?void 0:R.updateSelectedContent){const l=R.updateSelectedContent(r,e,o);l.assistentContents&&t.push(...l.assistentContents),l.patches&&n.push([(0,a.prependPatchPath)(l.patches[0],s),(0,a.prependPatchPath)(l.patches[1],s)]),l.newContents&&i.push(...l.newContents)}const l={};for(let t=0;t{var t;const n=(0,s.getContentModel)(e);if(!n)return e;const o=null==(t=n.getRefIds)?void 0:t.call(n,e);return o?o.every((e=>!e||"number"!=typeof e.id||void 0===l[e.id]))?e:(0,r.produce)(e,(e=>{var t;null==(t=n.updateRefId)||t.call(n,e,(e=>"number"==typeof e?l[e]:void 0))})):e})),n.push(...i.map(((t,n)=>[[{op:"add",path:[e.length+n],value:t}],[{op:"replace",path:[e.length+n]}]]))),{assistentContents:t,patches:n}},commandAssistentContents:null==R?void 0:R.assistentContents,commandSelected:null==R?void 0:R.selected,commandHovering:null==R?void 0:R.hovering,startCommand:null==R?void 0:R.onStart,onCommandMouseMove:null==R?void 0:R.onMove,onCommandMouseDown:null==R?void 0:R.onMouseDown,onCommandMouseUp:null==R?void 0:R.onMouseUp,onCommandKeyDown:null==R?void 0:R.onKeyDown,onCommandKeyUp:null==R?void 0:R.onKeyUp,getCommandByHotkey:e=>c[e.toUpperCase()],commandLastPosition:null==R?void 0:R.lastPosition,resetCommand:null==R?void 0:R.reset}}function p(e){if(l[e.name]=e,e.type)for(const t of e.type)t.hotkey&&(c[t.hotkey]=t.name);else e.hotkey&&(c[e.hotkey]=e.name)}},4469:(e,t,n)=>{"use strict";n.r(t),n.d(t,{AngleDeltaFields:()=>T,ArrowFields:()=>R,BaseContent:()=>C,ClipFields:()=>M,ContainerFields:()=>S,Content:()=>E,ContentRef:()=>Xt,FillFields:()=>k,FillStyleContent:()=>ye,PartRef:()=>Jt,PositionRef:()=>Zt,SegmentCountFields:()=>A,SnapResult:()=>qt,SnapTarget:()=>Ht,StrokeFields:()=>P,StrokeStyleContent:()=>ge,TextEditor:()=>rn,TextFields:()=>w,TextStyleContent:()=>xe,VariableValuesFields:()=>_,ViewportContent:()=>Ce,allContentsCache:()=>q,angleDeltaModel:()=>U,arrowModel:()=>D,assistentTextCache:()=>Vt,boundingToRTreeBounding:()=>bn,breakGeometryLinesToPathCommands:()=>Gt,breakPolyline:()=>Ut,clipModel:()=>N,containerModel:()=>F,contentIndexCache:()=>Ze,contentIsClosedPath:()=>nt,contentIsDeletable:()=>tt,contentsBoundingCache:()=>mn,defaultAngleDelta:()=>$e,defaultOpacity:()=>qe,defaultSegmentCount:()=>We,defaultStrokeColor:()=>He,deleteFillRefIds:()=>Lt,deleteSelectedContents:()=>it,deleteStrokeAndFillRefIds:()=>It,deleteStrokeRefIds:()=>Mt,deleteTextStyleRefIds:()=>Ot,dimensionStyle:()=>Ye,fillModel:()=>I,fixedButtomStyle:()=>ne,fixedInputStyle:()=>te,fuzzyStyle:()=>ln,geometryLineToContent:()=>oe,geometryLinesToPline:()=>ie,getAngleDeltaContentPropertyPanel:()=>Se,getArrowContentPropertyPanel:()=>we,getArrowPoints:()=>jt,getAssistentText:()=>Wt,getClipContentEditPoints:()=>gn,getClipContentPropertyPanel:()=>Ae,getContainerExplode:()=>bt,getContainerGeometries:()=>ft,getContainerMirror:()=>Ct,getContainerMove:()=>mt,getContainerRender:()=>Et,getContainerRenderIfSelected:()=>Pt,getContainerRotate:()=>yt,getContainerScale:()=>vt,getContainerSkew:()=>xt,getContainerSnapPoints:()=>lt,getContainerVariableNames:()=>dt,getContentByIndex:()=>re,getContentHatchGeometries:()=>xn,getContentIndex:()=>Xe,getContentModel:()=>ee,getContentsBounding:()=>gt,getContentsBreak:()=>wt,getContentsExplode:()=>kt,getContentsGeometries:()=>ht,getContentsPoints:()=>ae,getContentsSnapPoints:()=>ct,getDefaultStrokeWidth:()=>Ne,getDefaultViewport:()=>$t,getEditPointsFromCache:()=>K,getFillContentPropertyPanel:()=>Pe,getFillRefIds:()=>At,getFillRenderOptionsFromRenderContext:()=>dn,getFillStyleContent:()=>je,getFillStyles:()=>pe,getGeometriesFromCache:()=>$,getGeometryLineBoundingFromCache:()=>vn,getIntersectionPoints:()=>J,getPolylineEditPoints:()=>Ke,getRefPart:()=>en,getRefPosition:()=>Qt,getReference:()=>et,getSegmentCountContentPropertyPanel:()=>_e,getSnapPointsFromCache:()=>Y,getSnapTargetRef:()=>tn,getSortedContents:()=>Je,getStrokeAndFillRefIds:()=>Tt,getStrokeContentPropertyPanel:()=>le,getStrokeFillRenderOptionsFromRenderContext:()=>un,getStrokeRefIds:()=>Rt,getStrokeRenderOptionsFromRenderContext:()=>cn,getStrokeStyleContent:()=>Ge,getStrokeStyles:()=>ue,getTextContentPropertyPanel:()=>ke,getTextStyleContent:()=>Ve,getTextStyleRenderOptionsFromRenderContext:()=>pn,getTextStyles:()=>he,getTimeExpressionValue:()=>Z,getVariableValuesContentPropertyPanel:()=>Re,getViewportByPoints:()=>Yt,getViewportByRegion:()=>Kt,getViewportMatrix:()=>on,hasFill:()=>Ue,isAngleDeltaContent:()=>Fe,isArrowContent:()=>Oe,isClipContent:()=>ze,isContainerContent:()=>Ie,isFillContent:()=>Me,isFillStyleContent:()=>ve,isSegmentCountContent:()=>Be,isStrokeContent:()=>Te,isStrokeStyleContent:()=>me,isTextContent:()=>Le,isTextStyleContent:()=>be,isVariableValuesContent:()=>De,isViewportContent:()=>Ee,iterateAllContents:()=>st,iterateRefContents:()=>ot,iterateRefIds:()=>rt,math:()=>l.math,mergePolylines:()=>Nt,registerModel:()=>j,renderClipContent:()=>fn,renderClipContentIfSelected:()=>hn,renderContainerChildren:()=>ut,renderContainerIfSelected:()=>pt,reverseTransformPositionByViewport:()=>sn,segmentCountModel:()=>z,strokeModel:()=>L,textModel:()=>O,toRefId:()=>_t,toRefIds:()=>St,transformPositionByViewport:()=>an,trimOffsetResult:()=>nn,updateFillRefIds:()=>Ft,updateReferencedContents:()=>at,updateStrokeAndFillRefIds:()=>Dt,updateStrokeRefIds:()=>Bt,updateTextStyleRefIds:()=>zt,variableValuesModel:()=>B,zoomContentsToFit:()=>se});var r=n(3031),o=n(8662),i=n(3696),a=n.n(i),s=n(9758),l=n(5358),c=Object.defineProperty,u=Object.defineProperties,d=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,g=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),m=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))f.call(t,n)&&m(e,n,t[n]);if(p)for(var n of p(t))h.call(t,n)&&m(e,n,t[n]);return e},v=(e,t)=>u(e,d(t)),x=function(e,t){this[0]=e,this[1]=t},b=e=>{var t,n=e[g("asyncIterator")],r=!1,o={};return null==n?(n=e[g("iterator")](),t=e=>o[e]=t=>n[e](t)):(n=n.call(e),t=e=>o[e]=t=>{if(r){if(r=!1,"throw"===e)throw t;return t}return r=!0,{done:!1,value:new x(new Promise((r=>{var o=n[e](t);if(!(o instanceof Object))throw TypeError("Object expected");r(o)})),1)}}),o[g("iterator")]=()=>o,t("next"),"throw"in n?t("throw"):o.throw=e=>{throw e},"return"in n&&t("return"),o};const C=(e=s.string)=>({type:e,z:(0,s.optional)(s.number),visible:(0,s.optional)(s.boolean),readonly:(0,s.optional)(s.boolean)}),E=(e,t)=>{if(!(0,s.isRecord)(e))return{path:t,expect:"object"};const n=e.type;if("string"!=typeof n)return{path:t,expect:"type"};const r=G[n];return r?r.isValid(e,t):{path:t,expect:"register"}},P={dashArray:(0,s.optional)([(0,s.minimum)(0,s.number)]),strokeColor:(0,s.optional)((0,s.minimum)(0,s.number)),strokeWidth:(0,s.optional)((0,s.minimum)(0,s.number)),strokeStyleId:(0,s.optional)((0,s.or)(s.number,E)),trueStrokeColor:(0,s.optional)(s.boolean),strokeOpacity:(0,s.optional)((0,s.maximum)(1,(0,s.minimum)(0,s.number))),lineJoin:(0,s.optional)((0,s.or)("round","bevel","miter")),miterLimit:(0,s.optional)(s.number),lineCap:(0,s.optional)((0,s.or)("butt","round","square"))},k={fillColor:(0,s.optional)((0,s.minimum)(0,s.number)),fillPattern:(0,s.optional)((0,s.and)(s.Size,{lines:[[s.Position]],strokeColor:(0,s.optional)((0,s.minimum)(0,s.number)),strokeOpacity:(0,s.optional)((0,s.maximum)(1,(0,s.minimum)(0,s.number)))})),fillStyleId:(0,s.optional)((0,s.or)(s.number,E)),trueFillColor:(0,s.optional)(s.boolean),fillOpacity:(0,s.optional)((0,s.maximum)(1,(0,s.minimum)(0,s.number)))},w=(0,s.and)(s.TextStyle,{color:s.number,textStyleId:(0,s.optional)((0,s.or)(s.number,E)),lineHeight:(0,s.optional)(s.number),align:(0,s.optional)(s.Align),verticalAlign:(0,s.optional)(s.VerticalAlign)}),_={variableValues:(0,s.optional)((0,s.record)(s.string,s.string))},S=v(y({},_),{contents:[(0,s.Nullable)(E)]}),R={arrowAngle:(0,s.optional)(s.number),arrowSize:(0,s.optional)((0,s.minimum)(0,s.number))},A={segmentCount:(0,s.optional)(s.number)},T={angleDelta:(0,s.optional)((0,s.exclusiveMinimum)(0,s.number))},M={clip:(0,s.optional)({border:E,reverse:(0,s.optional)(s.boolean)})},L={isStroke:!0},I={isFill:!0},O={isText:!0},B={isVariableValues:!0},F=v(y({},B),{isContainer:!0,canSelectPart:!0}),D={isArrow:!0},z={isSegmentCount:!0},U={isAngleDelta:!0},N={isClip:!0},G={};function j(e){G[e.type]=e}const V=new s.WeakmapValuesCache,W=new s.WeakmapCache,H=new s.WeakmapCache,q=new s.WeakmapCache,$=V.get.bind(V),Y=W.get.bind(W),K=H.get.bind(H),X=new s.MapCache;function Z(e,t,n){if(!e||!t)return n;const o=X.get(e,(()=>{try{return(0,r.parseExpression)((0,r.tokenizeExpression)(e))}catch(e){return console.info(e),null}}));if(o)try{const e=(0,r.evaluateExpression)(o,{t});if("number"==typeof e&&!isNaN(e))return e}catch(e){console.info(e)}return n}const Q=new s.WeakmapCache2;function J(e,t,n){return Q.get(e,t,(()=>Array.from((0,s.iterateIntersectionPoints)(e,t,n,ee))))}function ee(e){return G[e.type]}const te={position:"absolute",bottom:"10px",left:"190px"},ne={position:"absolute",bottom:"30px",left:"190px"};function re(e,t){var n,r,o,i;const a=e[t[0]];if(!a)return;if(1===t.length)return a;const s=null==(i=null==(o=null==(r=null==(n=ee(a))?void 0:n.getGeometries)?void 0:r.call(n,a,e))?void 0:o.lines)?void 0:i[t[1]];return s?oe(s):void 0}function oe(e){return Array.isArray(e)?{type:"line",points:e}:"arc"===e.type?y({type:"arc"},e.curve):"ellipse arc"===e.type?y({type:"ellipse arc"},e.curve):"quadratic curve"===e.type?{type:"path",commands:[{type:"move",to:e.curve.from},{type:"quadraticCurve",cp:e.curve.cp,to:e.curve.to}]}:"bezier curve"===e.type?{type:"path",commands:[{type:"move",to:e.curve.from},{type:"bezierCurve",cp1:e.curve.cp1,cp2:e.curve.cp2,to:e.curve.to}]}:"ray"===e.type?y({type:"ray"},e.line):y({type:"nurbs"},e.curve)}function ie(e){if(1===e.length)return oe(e[0]);const t={type:"pline",points:[]};for(let n=0;n!0)){const r=[];return e.forEach((e=>{if(!e)return;if(!n(e))return;const o=ee(e);if(null==o?void 0:o.getGeometries){const{bounding:n}=o.getGeometries(e,t);n&&r.push(n.start,n.end)}})),r}function se(e,t,n,r,o=.8,i){const a=ae(n,r),l=(0,s.getPointsBounding)(a);if(!l)return;const c=(0,s.zoomToFitPoints)(a,{width:e,height:t},{x:e/2,y:t/2},o,i);return c?y({bounding:l},c):void 0}function le(e,t,n){var r;const o=[];if(n){const r=ue(n);r.length>0&&(o.push(a().createElement(s.BooleanEditor,{value:void 0!==e.strokeStyleId,setValue:e=>t((t=>{Te(t)&&(t.strokeStyleId=e?r[0].index:void 0)}))})),"number"==typeof e.strokeStyleId&&o.push(a().createElement(s.EnumEditor,{select:!0,enums:r.map((e=>e.index)),enumTitles:r.map((e=>e.label)),value:e.strokeStyleId,setValue:e=>t((t=>{Te(t)&&(t.strokeStyleId=e)}))})))}return o.length>1?{strokeStyleId:o}:{strokeStyleId:o,dashArray:[a().createElement(s.BooleanEditor,{value:void 0!==e.dashArray,setValue:e=>t((t=>{Te(t)&&(t.dashArray=e?[4]:void 0)}))}),void 0!==e.dashArray?a().createElement(s.ArrayEditor,v(y({inline:!0},(0,s.getArrayEditorProps)((e=>e.dashArray||[]),4,(e=>t((t=>{Te(t)&&e(t)}))))),{items:e.dashArray.map(((e,n)=>a().createElement(s.NumberEditor,{value:e,setValue:e=>t((t=>{Te(t)&&t.dashArray&&(t.dashArray[n]=e)}))})))})):void 0],strokeColor:[a().createElement(s.BooleanEditor,{value:void 0!==e.strokeColor,setValue:e=>t((t=>{Te(t)&&(t.strokeColor=e?0:void 0)}))}),void 0!==e.strokeColor?a().createElement(s.NumberEditor,{type:"color",value:e.strokeColor,setValue:e=>t((t=>{Te(t)&&(t.strokeColor=e)}))}):void 0],trueStrokeColor:a().createElement(s.BooleanEditor,{value:void 0!==e.trueStrokeColor,setValue:e=>t((t=>{Te(t)&&(t.trueStrokeColor=!!e||void 0)}))}),strokeWidth:[a().createElement(s.BooleanEditor,{value:void 0!==e.strokeWidth,setValue:e=>t((t=>{Te(t)&&(t.strokeWidth=e?2:void 0)}))}),void 0!==e.strokeWidth?a().createElement(s.NumberEditor,{value:e.strokeWidth,setValue:e=>t((t=>{Te(t)&&(t.strokeWidth=e)}))}):void 0],strokeOpacity:a().createElement(s.NumberEditor,{value:null!=(r=e.strokeOpacity)?r:1,setValue:e=>t((t=>{Te(t)&&(t.strokeOpacity=1===e?void 0:e)}))}),lineJoin:[a().createElement(s.BooleanEditor,{value:void 0!==e.lineJoin,setValue:e=>t((t=>{Te(t)&&(t.lineJoin=e?s.defaultLineJoin:void 0)}))}),void 0!==e.lineJoin?a().createElement(s.EnumEditor,{enums:["round","bevel","miter"],value:e.lineJoin,setValue:e=>t((t=>{Te(t)&&(t.lineJoin=e)}))}):void 0],miterLimit:[a().createElement(s.BooleanEditor,{value:void 0!==e.miterLimit,setValue:e=>t((t=>{Te(t)&&(t.miterLimit=e?s.defaultMiterLimit:void 0)}))}),void 0!==e.miterLimit?a().createElement(s.NumberEditor,{value:e.miterLimit,setValue:e=>t((t=>{Te(t)&&(t.miterLimit=e)}))}):void 0],lineCap:[a().createElement(s.BooleanEditor,{value:void 0!==e.lineCap,setValue:e=>t((t=>{Te(t)&&(t.lineCap=e?s.defaultLineCap:void 0)}))}),void 0!==e.lineCap?a().createElement(s.EnumEditor,{enums:["butt","round","square"],value:e.lineCap,setValue:e=>t((t=>{Te(t)&&(t.lineCap=e)}))}):void 0]}}const ce=new s.WeakmapCache;function ue(e){return ce.get(e,(()=>e.map(((e,t)=>({c:e,i:t}))).filter((e=>!!e.c&&me(e.c))).map((({c:e,i:t})=>{var n,r,o,i,a;return{index:t,content:e,label:`${null!=(n=e.strokeWidth)?n:1}px ${null!=(o=null==(r=e.dashArray)?void 0:r.join(","))?o:"solid"} ${(0,s.getColorString)(null!=(i=e.strokeColor)?i:0)} ${null!=(a=e.strokeOpacity)?a:qe}`}}))))}const de=new s.WeakmapCache;function pe(e){return de.get(e,(()=>e.map(((e,t)=>({c:e,i:t}))).filter((e=>!!e.c&&ve(e.c))).map((({c:e,i:t})=>{var n,r;let o="";return e.fillPattern?o=`${e.fillPattern.width}*${e.fillPattern.height} ${(0,s.getColorString)(null!=(n=e.fillPattern.strokeColor)?n:0)} ${JSON.stringify(e.fillPattern.lines)}`:void 0!==e.fillColor&&(o=(0,s.getColorString)(e.fillColor)),{index:t,content:e,label:`${o} ${null!=(r=e.fillOpacity)?r:qe}`}}))))}const fe=new s.WeakmapCache;function he(e){return fe.get(e,(()=>e.map(((e,t)=>({c:e,i:t}))).filter((e=>!!e.c&&be(e.c))).map((({c:e,i:t})=>({index:t,content:e,label:`${e.fontFamily} ${e.fontSize} ${(0,s.getColorString)(e.color)}`})))))}const ge=(0,s.and)(C("stroke style"),P,s.Region,{isCurrent:(0,s.optional)(s.boolean)});function me(e){return"stroke style"===e.type}const ye=(0,s.and)(C("fill style"),k,s.Region,{isCurrent:(0,s.optional)(s.boolean)});function ve(e){return"fill style"===e.type}const xe=(0,s.and)(C("text style"),w,s.Position,{isCurrent:(0,s.optional)(s.boolean)});function be(e){return"text style"===e.type}const Ce=(0,s.and)(C("viewport"),s.Position,P,{border:E,scale:s.number,rotate:(0,s.optional)(s.number),locked:(0,s.optional)(s.boolean),hidden:(0,s.optional)(s.boolean)});function Ee(e){return"viewport"===e.type}function Pe(e,t,n){var r,o;const i=[];if(n){const r=pe(n);r.length>0&&(i.push(a().createElement(s.BooleanEditor,{value:void 0!==e.fillStyleId,setValue:e=>t((t=>{Me(t)&&(t.fillStyleId=e?r[0].index:void 0)}))})),"number"==typeof e.fillStyleId&&i.push(a().createElement(s.EnumEditor,{select:!0,enums:r.map((e=>e.index)),enumTitles:r.map((e=>e.label)),value:e.fillStyleId,setValue:e=>t((t=>{Me(t)&&(t.fillStyleId=e)}))})))}return i.length>1?{fillStyleId:i}:{fillStyleId:i,fillColor:[a().createElement(s.BooleanEditor,{value:void 0!==e.fillColor,setValue:e=>t((t=>{Me(t)&&(t.fillColor=e?0:void 0)}))}),void 0!==e.fillColor?a().createElement(s.NumberEditor,{type:"color",value:e.fillColor,setValue:e=>t((t=>{Me(t)&&(t.fillColor=e)}))}):void 0],trueFillColor:a().createElement(s.BooleanEditor,{value:void 0!==e.trueFillColor,setValue:e=>t((t=>{Me(t)&&(t.trueFillColor=!!e||void 0)}))}),fillPattern:[a().createElement(s.BooleanEditor,{value:void 0!==e.fillPattern,setValue:e=>t((t=>{Me(t)&&(t.fillPattern=e?{width:10,height:10,lines:[[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]]}:void 0)}))}),void 0!==e.fillPattern?a().createElement(s.ObjectEditor,{properties:{width:a().createElement(s.NumberEditor,{value:e.fillPattern.width,setValue:e=>t((t=>{Me(t)&&t.fillPattern&&(t.fillPattern.width=e)}))}),height:a().createElement(s.NumberEditor,{value:e.fillPattern.height,setValue:e=>t((t=>{Me(t)&&t.fillPattern&&(t.fillPattern.height=e)}))}),strokeColor:[a().createElement(s.BooleanEditor,{value:void 0!==e.fillPattern.strokeColor,setValue:e=>t((t=>{Me(t)&&t.fillPattern&&(t.fillPattern.strokeColor=e?0:void 0)}))}),void 0!==e.fillPattern.strokeColor?a().createElement(s.NumberEditor,{type:"color",value:e.fillPattern.strokeColor,setValue:e=>t((t=>{Me(t)&&t.fillPattern&&(t.fillPattern.strokeColor=e)}))}):void 0],strokeOpacity:a().createElement(s.NumberEditor,{value:null!=(r=e.fillPattern.strokeOpacity)?r:1,setValue:e=>t((t=>{Me(t)&&t.fillPattern&&(t.fillPattern.strokeOpacity=1===e?void 0:e)}))}),lines:a().createElement(s.ArrayEditor,v(y({},(0,s.getArrayEditorProps)((e=>{var t;return(null==(t=e.fillPattern)?void 0:t.lines)||[]}),[{x:0,y:5},{x:5,y:0}],(e=>t((t=>{Me(t)&&t.fillPattern&&e(t)}))))),{items:e.fillPattern.lines.map(((e,n)=>a().createElement(s.ObjectArrayEditor,v(y({},(0,s.getArrayEditorProps)((e=>e),{x:0,y:5},(e=>t((t=>{Me(t)&&t.fillPattern&&e(t.fillPattern.lines[n])}))))),{properties:e.map(((e,r)=>({x:a().createElement(s.NumberEditor,{value:e.x,setValue:e=>t((t=>{Me(t)&&t.fillPattern&&(t.fillPattern.lines[n][r].x=e)})),style:{width:"70px"}}),y:a().createElement(s.NumberEditor,{value:e.y,setValue:e=>t((t=>{Me(t)&&t.fillPattern&&(t.fillPattern.lines[n][r].y=e)})),style:{width:"70px"}})})))}))))}))}}):void 0],fillOpacity:a().createElement(s.NumberEditor,{value:null!=(o=e.fillOpacity)?o:1,setValue:e=>t((t=>{Me(t)&&(t.fillOpacity=1===e?void 0:e)}))})}}function ke(e,t,n){var r,o;const i=[];if(n){const r=he(n);r.length>0&&(i.push(a().createElement(s.BooleanEditor,{value:void 0!==e.textStyleId,setValue:e=>t((t=>{Le(t)&&(t.textStyleId=e?r[0].index:void 0)}))})),"number"==typeof e.textStyleId&&i.push(a().createElement(s.EnumEditor,{select:!0,enums:r.map((e=>e.index)),enumTitles:r.map((e=>e.label)),value:e.textStyleId,setValue:e=>t((t=>{Le(t)&&(t.textStyleId=e)}))})))}return i.length>1?{textStyleId:i}:{textStyleId:i,fontSize:a().createElement(s.NumberEditor,{value:e.fontSize,setValue:e=>t((t=>{Le(t)&&(t.fontSize=e)}))}),fontFamily:a().createElement(s.StringEditor,{value:e.fontFamily,setValue:e=>t((t=>{Le(t)&&(t.fontFamily=e)}))}),color:a().createElement(s.NumberEditor,{type:"color",value:e.color,setValue:e=>t((t=>{Le(t)&&(t.color=e)}))}),lineHeight:[a().createElement(s.BooleanEditor,{value:void 0!==e.lineHeight,setValue:n=>t((t=>{Le(t)&&(t.lineHeight=n?1.2*e.fontSize:void 0)}))}),void 0!==e.lineHeight?a().createElement(s.NumberEditor,{value:e.lineHeight,setValue:e=>t((t=>{Le(t)&&(t.lineHeight=e)}))}):void 0],align:a().createElement(s.EnumEditor,{enums:s.aligns,value:null!=(r=e.align)?r:"center",setValue:e=>t((t=>{Le(t)&&(t.align=e)}))}),verticalAlign:a().createElement(s.EnumEditor,{enums:s.verticalAligns,value:null!=(o=e.verticalAlign)?o:"middle",setValue:e=>t((t=>{Le(t)&&(t.verticalAlign=e)}))})}}function we(e,t){return{arrowAngle:[a().createElement(s.BooleanEditor,{value:void 0!==e.arrowAngle,setValue:e=>t((t=>{Oe(t)&&(t.arrowAngle=e?Ye.arrowAngle:void 0)}))}),void 0!==e.arrowAngle?a().createElement(s.NumberEditor,{value:e.arrowAngle,setValue:e=>t((t=>{Oe(t)&&(t.arrowAngle=e)}))}):void 0],arrowSize:[a().createElement(s.BooleanEditor,{value:void 0!==e.arrowSize,setValue:e=>t((t=>{Oe(t)&&(t.arrowSize=e?Ye.arrowSize:void 0)}))}),void 0!==e.arrowSize?a().createElement(s.NumberEditor,{value:e.arrowSize,setValue:e=>t((t=>{Oe(t)&&(t.arrowSize=e)}))}):void 0]}}function _e(e,t){return{segmentCount:[a().createElement(s.BooleanEditor,{value:void 0!==e.segmentCount,setValue:e=>t((t=>{Be(t)&&(t.segmentCount=e?We:void 0)}))}),void 0!==e.segmentCount?a().createElement(s.NumberEditor,{value:e.segmentCount,setValue:e=>t((t=>{Be(t)&&(t.segmentCount=e)}))}):void 0]}}function Se(e,t){return{angleDelta:[a().createElement(s.BooleanEditor,{value:void 0!==e.angleDelta,setValue:e=>t((t=>{Fe(t)&&(t.angleDelta=e?$e:void 0)}))}),void 0!==e.angleDelta?a().createElement(s.NumberEditor,{value:e.angleDelta,setValue:e=>t((t=>{Fe(t)&&(t.angleDelta=e)}))}):void 0]}}function Re(e,t,n){return{variableValues:t.length>0?a().createElement(s.ObjectEditor,{properties:Object.assign({},...t.map((t=>{var r,o;return{[t]:a().createElement(s.StringEditor,{value:null!=(o=null==(r=e.variableValues)?void 0:r[t])?o:"",setValue:e=>n((n=>{De(n)&&(n.variableValues||(n.variableValues={}),n.variableValues[t]=e)}))})}})))}):[]}}function Ae(e,t,n,r){const o=a().createElement(s.Button,{onClick:()=>n({count:1,selectable:e=>nt(re(t,e))},(n=>r((r=>{if(ze(r)){const o=en(n[0],t,(t=>t!==e));o&&(r.clip={border:o})}}))))},"select border");let i={};return i=e.clip?{change:o,border:a().createElement(s.Button,{onClick:()=>r((e=>{ze(e)&&(e.clip=void 0)}))},"remove"),reverse:a().createElement(s.BooleanEditor,{value:!!e.clip.reverse,setValue:e=>r((t=>{ze(t)&&t.clip&&(t.clip.reverse=!!e||void 0)}))})}:{add:o},{clip:a().createElement(s.ObjectEditor,{properties:i})}}function Te(e){var t;return!!(null==(t=ee(e))?void 0:t.isStroke)}function Me(e){var t;return!!(null==(t=ee(e))?void 0:t.isFill)}function Le(e){var t;return!!(null==(t=ee(e))?void 0:t.isText)}function Ie(e){var t;return!!(null==(t=ee(e))?void 0:t.isContainer)}function Oe(e){var t;return!!(null==(t=ee(e))?void 0:t.isArrow)}function Be(e){var t;return!!(null==(t=ee(e))?void 0:t.isSegmentCount)}function Fe(e){var t;return!!(null==(t=ee(e))?void 0:t.isAngleDelta)}function De(e){var t;return!!(null==(t=ee(e))?void 0:t.isVariableValues)}function ze(e){var t;return!!(null==(t=ee(e))?void 0:t.isClip)}function Ue(e){return void 0!==e.fillColor||void 0!==e.fillPattern||void 0!==e.fillStyleId}function Ne(e){return Me(e)&&Ue(e)?0:1}function Ge(e,t){if(void 0!==e.strokeStyleId){const n="number"==typeof e.strokeStyleId?t[e.strokeStyleId]:e.strokeStyleId;if(n&&me(n))return n}return e}function je(e,t){if(void 0!==e.fillStyleId){const n="number"==typeof e.fillStyleId?t[e.fillStyleId]:e.fillStyleId;if(n&&ve(n))return n}return e}function Ve(e,t){if(void 0!==e.textStyleId){const n="number"==typeof e.textStyleId?t[e.textStyleId]:e.textStyleId;if(n&&be(n))return n}return e}const We=100,He=0,qe=1,$e=5,Ye={margin:5,arrowAngle:15,arrowSize:10};function Ke(e,t,n,r){const o=e.points,i=!n&&o.length>2&&(0,s.isSamePoint)(o[0],o[o.length-1]),a=[];if(o.forEach(((e,t)=>{if(!n&&t===o.length-1&&i||a.push({pointIndexes:[t],x:e.x,y:e.y}),!r&&t!==o.length-1){const n=o[t+1];a.push({pointIndexes:[t,t+1],x:(e.x+n.x)/2,y:(e.y+n.y)/2})}if(n&&t===o.length-1){const t=o[0];a.push({pointIndexes:[o.length-1,0],x:(e.x+t.x)/2,y:(e.y+t.y)/2})}})),i)for(const e of a)e.pointIndexes.includes(0)?e.pointIndexes.push(o.length-1):e.pointIndexes.includes(o.length-1)&&e.pointIndexes.push(0);return a.map((e=>({x:e.x,y:e.y,cursor:"move",update(n,{cursor:r,start:o,scale:i}){if(!t(n))return;const a=r.x-o.x,s=r.y-o.y;for(const t of e.pointIndexes)n.points[t].x+=a,n.points[t].y+=s;return{assistentContents:[{type:"line",dashArray:[4/i],points:[o,r]}]}}})))}function Xe(e,t){return Ze.get(e,(()=>t.findIndex((t=>e===t))))}const Ze=new s.WeakmapCache,Qe=new s.WeakmapCache;function Je(e){return Qe.get(e,(()=>{const t=e.map(((e,t)=>{var n;return{content:e,index:t,z:null!=(n=null==e?void 0:e.z)?n:t}})),n=(0,o.produce)(t,(e=>{e.sort(((e,t)=>e.z-t.z))}));return{contents:n.map((e=>e.content)),indexes:n.map((e=>e.index))}}))}function et(e,t,n=(e=>!0),r){var o;if("number"!=typeof e)return e&&n(e)?e:void 0;let i=t[e];return!i&&r&&r.length>0&&(i=null==(o=r.find((t=>"add"===t.op&&t.path[0]===e)))?void 0:o.value),i&&n(i)?i:void 0}function tt(e,t){var n,r,o;if(e.readonly)return!1;const i=Xe(e,t);for(const e of st(t))if(null==(o=null==(r=null==(n=ee(e))?void 0:n.getRefIds)?void 0:r.call(n,e))?void 0:o.some((e=>(null==e?void 0:e.id)===i&&e.required)))return!1;return!0}function nt(e){var t;return!!e&&!e.readonly&&void 0!==(null==(t=ee(e))?void 0:t.isPointIn)}function*rt(e,t){var n,r;if(e)for(const o of e){if(void 0===o)continue;if(null===o)continue;"number"==typeof o&&(yield o);const e="number"!=typeof o?o:t[o];if(e){const o=null==(r=null==(n=ee(e))?void 0:n.getRefIds)?void 0:r.call(n,e);yield*b(rt(null==o?void 0:o.map((e=>null==e?void 0:e.id)),t))}}}function*ot(e,t,n){var r,o;if(e)for(const i of e){if(void 0===i)continue;if(null===i)continue;const e="number"!=typeof i.id?i.id:t[i.id];if(e&&!n.includes(e)){yield e;const i=null==(o=null==(r=ee(e))?void 0:r.getRefIds)?void 0:o.call(r,e);yield*b(ot(i,t,[...n,e]))}}}function it(e,t){for(const n of t)e[n]=void 0;e.forEach(((e,n)=>{var r,o;e&&!t.includes(n)&&(null==(o=null==(r=ee(e))?void 0:r.deleteRefId)||o.call(r,e,t))}))}function at(e,t,n,r){var i,a;const s=[],l=Xe(e,n);for(const e of st(n)){if(null==r?void 0:r.includes(e))continue;const n=ee(e);(null==(a=null==(i=null==n?void 0:n.getRefIds)?void 0:i.call(n,e))?void 0:a.some((e=>(null==e?void 0:e.id)===l)))&&s.push((0,o.produce)(e,(e=>{var r;null==(r=n.updateRefId)||r.call(n,e,(e=>{if(e===l)return t}))})))}return s}function*st(e){for(const t of e)t&&(yield t,Ie(t)&&(yield*b(st(t.contents))))}function lt(e,t){return ct(e,t)}function ct(e,t,n=(e=>e.contents)){return Y(e,(()=>{const r=[];return n(e).forEach((e=>{var n,o;if(!e)return;const i=null==(o=null==(n=ee(e))?void 0:n.getSnapPoints)?void 0:o.call(n,e,t);i&&r.push(...i)})),r}))}function ut(e,t){t=v(y({},t),{variableContext:y(y({},t.variableContext),e.variableValues)});const n=[];return Je(e.contents).contents.forEach((e=>{if(!e)return;const r=ee(e);if(null==r?void 0:r.render){const o=r.render;n.push(o(e,t))}})),n}function dt(e){var t,n;const r=new Set;for(const o of e.contents)if(o){const e=null==(n=null==(t=ee(o))?void 0:t.getVariableNames)?void 0:n.call(t,o);e&&e.forEach((e=>r.add(e)))}return Array.from(r)}function pt(e,t,n,r){const{bounding:o}=ft(e,t.contents,r,n);return o?t.target.renderRect(o.start.x,o.start.y,o.end.x-o.start.x,o.end.y-o.start.y,{strokeColor:t.color,dashArray:[4],strokeWidth:t.strokeWidth}):t.target.renderEmpty()}function ft(e,t,n,r){return ht(e,t,n,r)}function ht(e,t,n,r,o=(e=>e.contents)){const i=new Set(ot(n(e),t,r));return $(e,i,(()=>{const n=[],r=[],i=[],a=[];return o(e).forEach((e=>{var o,s;if(!e)return;const l=null==(s=null==(o=ee(e))?void 0:o.getGeometries)?void 0:s.call(o,e,t);l&&(n.push(...l.lines),l.bounding&&i.push(l.bounding.start,l.bounding.end),l.renderingLines&&r.push(...l.renderingLines),l.regions&&a.push(...l.regions))})),{lines:n,bounding:(0,s.getPointsBounding)(i),renderingLines:r,regions:a.length>0?a:void 0}}))}function gt(e,t){const n=[];return e.forEach((e=>{var r,o;if(e){const i=null==(o=null==(r=ee(e))?void 0:r.getGeometries)?void 0:o.call(r,e,t).bounding;i&&n.push(i.start,i.end)}})),(0,s.getPointsBounding)(n)}function mt(e,t){e.contents.forEach((e=>{var n,r;e&&(null==(r=null==(n=ee(e))?void 0:n.move)||r.call(n,e,t))}))}function yt(e,t,n,r){e.contents.forEach((e=>{var o,i;e&&(null==(i=null==(o=ee(e))?void 0:o.rotate)||i.call(o,e,t,n,r))}))}function vt(e,t,n,r,o){var i,a;for(let s=0;s{var o,i;e&&(null==(i=null==(o=ee(e))?void 0:o.mirror)||i.call(o,e,t,n,r))}))}function Et(e,t){const n=ut(e,t);return t.target.renderGroup(n)}function Pt(e,t,n,r){return pt(e,t,n,r)}function kt(e){return e.filter((e=>!!e))}function wt(e,t,n){const r=[];for(const o of e)if(o){const e=ee(o);if((null==e?void 0:e.break)&&e.getGeometries){const i=e.getGeometries(o,n),a=t.filter((e=>i.lines.some((t=>(0,s.isZero)((0,s.getPointAndGeometryLineMinimumDistance)(e,t),.1))))),l=e.break(o,a,n);l?r.push(...l):r.push(o)}}return r}function _t(e,t){return void 0!==e?[{id:e,required:t}]:[]}function St(e,t){const n=[];if(e)for(const r of e)r&&n.push({id:r,required:t});return n}function Rt(e){return _t(e.strokeStyleId)}function At(e){return _t(e.fillStyleId)}function Tt(e){return[..._t(e.strokeStyleId),..._t(e.fillStyleId)]}function Mt(e,t){void 0!==e.strokeStyleId&&t.includes(e.strokeStyleId)&&(e.strokeStyleId=void 0)}function Lt(e,t){void 0!==e.fillStyleId&&t.includes(e.fillStyleId)&&(e.fillStyleId=void 0)}function It(e,t){Mt(e,t),Lt(e,t)}function Ot(e,t){void 0!==e.textStyleId&&t.includes(e.textStyleId)&&(e.textStyleId=void 0)}function Bt(e,t){if(void 0!==e.strokeStyleId){const n=t(e.strokeStyleId);void 0!==n&&(e.strokeStyleId=n)}}function Ft(e,t){if(void 0!==e.fillStyleId){const n=t(e.fillStyleId);void 0!==n&&(e.fillStyleId=n)}}function Dt(e,t){Bt(e,t),Ft(e,t)}function zt(e,t){if(void 0!==e.textStyleId){const n=t(e.textStyleId);void 0!==n&&(e.textStyleId=n)}}function Ut(e,t){const n=(0,s.breakPolylineToPolylines)(e,t).map((e=>({type:"polyline",points:e})));for(const e of n)2===e.points.length&&(e.type="line");return n}function Nt(e){(0,s.mergePolylinesToPolyline)(e);for(const t of e)t.points.length>2&&(t.type="polyline")}function Gt(e,t){return(0,s.breakGeometryLines)(e,t).map((e=>({type:"path",commands:(0,s.geometryLineToPathCommands)(e)})))}function jt(e,t,n){var r,o;const i=null!=(r=n.arrowSize)?r:Ye.arrowSize,a=null!=(o=n.arrowAngle)?o:Ye.arrowAngle;return(0,s.getArrow)(e,t,i,a,n.strokeWidth)}const Vt=new s.MapCache3;function Wt(e,t,n,r,o=16711680){(t=Math.round(t))<12&&(t=12);const i=[];for(let a=0;a({}))),i.push({type:"text",x:n+a*t*.6,y:r,text:s,color:o,fontSize:t,fontFamily:"monospace"})}return i}const Ht={snapIndex:s.number,param:(0,s.optional)(s.number),id:s.number},qt={position:s.Position,target:(0,s.optional)(Ht)};function $t(e,t,n){return Yt(e,ae(t,t,(e=>!Ee(e))),t,n)}function Yt(e,t,n,r){r&&(t=t.map((e=>(0,s.rotatePosition)(e,{x:0,y:0},r))));const o=(0,s.getPointsBounding)(t);if(o)return Kt(e,o,n)}function Kt(e,t,n){var r,o;const i=null==(o=null==(r=ee(e))?void 0:r.getGeometries)?void 0:o.call(r,e,n).bounding;if(!i)return;const a=i.end.x-i.start.x,s=i.end.y-i.start.y,l=t.end.x-t.start.x,c=t.end.y-t.start.y,u=a/l,d=s/c;let p,f=0,h=0;return u!n.includes(e)),r);if(l){const n=ee(l);let r=null==(i=null==(o=null==n?void 0:n.getSnapPoints)?void 0:o.call(n,l,t))?void 0:i[e.snapIndex];if(!r&&void 0!==e.param){const o=null==(a=null==n?void 0:n.getGeometries)?void 0:a.call(n,l,t).lines;o&&(r=(0,s.getGeometryLinesPointAtParam)(e.param,o))}return r}}}const Jt={id:Xt,partIndex:(0,s.optional)(s.number)};function en(e,t,n=(e=>!0),r){var o,i,a;if(void 0!==e){const s=et(e.id,t,n,r);if(s){const r=ee(s);if(void 0!==e.partIndex){const l=null==(a=null==(i=null==(o=null==r?void 0:r.getGeometries)?void 0:o.call(r,s,t))?void 0:i.lines)?void 0:a[e.partIndex];if(l){const e=oe(l);if(e&&n(e))return e}}if(n(s))return s}}}function tn(e,t){return e?{id:Xe(e.content,t),snapIndex:e.snapIndex,param:e.param}:void 0}function nn(e,t,n,r){let o=[];for(let t=0;t0){let n=Ut(Array.from((0,s.iteratePolylineLines)(e)),o);const i=n.filter(((e,t)=>t%2==0)),a=n.filter(((e,t)=>t%2==1));return n=Math.min(...i.map((e=>{var n,o,i,a,l;return null==(l=null!=(a=null==(i=null==(o=null==(n=ee(e))?void 0:n.getGeometries)?void 0:o.call(n,e,r))?void 0:i.lines)?a:[])?void 0:l.map((e=>(0,s.getPointAndGeometryLineMinimumDistance)(t,e)))})).flat(2))>Math.min(...a.map((e=>{var n,o,i,a,l;return null==(l=null!=(a=null==(i=null==(o=null==(n=ee(e))?void 0:n.getGeometries)?void 0:o.call(n,e,r))?void 0:i.lines)?a:[])?void 0:l.map((e=>(0,s.getPointAndGeometryLineMinimumDistance)(t,e)))})).flat(2))?a:i,Nt(n),n.map((e=>e.points))}return[e]}function rn(e){var t,n,r;const{state:o,setState:i,undo:l,redo:c}=(0,s.useUndoRedo)(e.value.split("")),{renderEditor:u}=(0,s.useFlowLayoutTextEditor)({state:o,setState:i,width:e.width,height:null!=(t=e.height)?t:100,fontSize:e.fontSize,fontFamily:e.fontFamily,lineHeight:null!=(n=e.lineHeight)?n:1.2*e.fontSize,processInput(t){var n;return"Escape"===t.key?(null==(n=e.onCancel)||n.call(e),!0):(t.stopPropagation(),!(!(0,s.metaKeyIfMacElseCtrlKey)(t)||"z"!==t.key||(t.shiftKey?c(t):l(t),0)))},autoHeight:!0,autoFocus:!0,onBlur:()=>{setTimeout((()=>{if(!e.readOnly&&e.setValue){const t=o.join("");t!==e.value&&e.setValue(t)}}),0)},align:e.align,verticalAlign:e.verticalAlign,style:{border:"unset"}}),d=null!=(r=e.borderWidth)?r:1;return a().createElement("div",{style:v(y({position:"absolute",zIndex:10},s.controlStyle),{padding:"0px",left:e.x-d+"px",top:e.y-d+"px",borderWidth:`${d}px`})},u({target:s.reactCanvasRenderTarget,getTextColors:()=>({color:e.color})}))}function on(e){return s.m3.multiply(s.m3.multiply(s.m3.translation(e.x,e.y),s.m3.scaling(e.scale,e.scale)),s.m3.rotation(-(e.rotate||0)))}function an(e,t){return{x:(e=(0,s.rotatePosition)(e,{x:0,y:0},t.rotate||0)).x*t.scale+t.x,y:e.y*t.scale+t.y}}function sn(e,t){return(0,s.rotatePosition)({x:(e.x-t.x)/t.scale,y:(e.y-t.y)/t.scale},{x:0,y:0},-(t.rotate||0))}const ln={lineCap:"round",lineJoin:"round",strokeOpacity:.25};function cn(e,{getStrokeColor:t,time:n,transformStrokeWidth:r,isHoveringOrSelected:o,target:i,contents:a}){var s,l;const c=Ge(e,a),u=null!=(s=c.strokeWidth)?s:Ne(e),d=r(u),p=o&&d!==u,f=t(c),h=null!=(l=c.strokeOpacity)?l:qe;return{options:y({strokeColor:f,strokeWidth:d,strokeOpacity:h,dashArray:c.dashArray,lineJoin:c.lineJoin,miterLimit:c.miterLimit,lineCap:c.lineCap},p?ln:{}),time:n,contents:a,target:i,fillOptions:y({strokeColor:p?f:void 0,strokeWidth:p?r(0):0,fillColor:p?void 0:f},p?ln:{}),strokeColor:f,strokeOpacity:h}}function un(e,{getStrokeColor:t,getFillColor:n,getFillPattern:r,transformStrokeWidth:o,isHoveringOrSelected:i,time:a,target:s,contents:l,clip:c}){var u,d,p;const f=Ge(e,l),h=je(e,l),g=null!=(u=f.strokeWidth)?u:Ne(e),m=o(g),v=i&&m!==g,x=v&&!g&&void 0!==h.fillColor?h.fillColor:t(f),b=null!=(d=f.strokeOpacity)?d:qe,C=null!=(p=h.fillOpacity)?p:qe;return{options:y({fillColor:n(h),strokeColor:x,strokeWidth:m,strokeOpacity:b,fillPattern:r(h),fillOpacity:C,dashArray:f.dashArray,lineJoin:f.lineJoin,miterLimit:f.miterLimit,lineCap:f.lineCap,clip:c},v?ln:{}),time:a,contents:l,target:s,strokeColor:x,strokeOpacity:b,dashed:!!f.dashArray}}function dn(e,{getFillColor:t,getFillPattern:n,transformStrokeWidth:r,isHoveringOrSelected:o,time:i,target:a,contents:s,clip:l}){var c,u;const d=je(e,s),p=r(1),f=o&&1!==p,h=null!=(c=d.fillOpacity)?c:qe,g=null!=(u=t(d))?u:He;return{options:y({fillColor:g,fillPattern:n(d),fillOpacity:h,clip:l,strokeColor:f?g:void 0,strokeWidth:f?p:0},f?ln:{}),time:i,contents:s,target:a}}function pn(e,{transformStrokeWidth:t,isHoveringOrSelected:n}){const r=t(0),o=n&&0!==r;return v(y({},o?ln:{}),{strokeColor:o?e:void 0,strokeWidth:o?r:void 0})}function fn(e,t,n){var r,o;if(e.clip){const i=ee(e.clip.border),a=null==i?void 0:i.render;if(a){if(e.clip.reverse){const a=null==(r=i.getGeometries)?void 0:r.call(i,e.clip.border,n.contents);if(!(null==a?void 0:a.bounding))return t;const l=ee(e);if(!l)return t;const c=null==(o=l.getGeometries)?void 0:o.call(l,e,n.contents);return(null==c?void 0:c.bounding)?n.target.renderPath([(0,s.getPolygonFromTwoPointsFormRegion)((0,s.mergeBoundingsUnsafe)([c.bounding,a.bounding])),(0,s.getGeometryLinesPoints)(a.lines)],v(y({},n),{strokeWidth:0,clip:()=>t})):t}return a(e.clip.border,v(y({},n),{transformStrokeWidth:()=>0,clip:()=>t}))}}return t}function hn(e,t,n){if(e.clip){const r=ee(e.clip.border),o=null==r?void 0:r.render;if(o)return n.target.renderGroup([t,o(e.clip.border,v(y({},n),{transformColor:e=>e,transformStrokeWidth:()=>n.strokeWidth,getStrokeColor:()=>n.color,getFillColor:()=>{},getFillPattern:()=>{}}))])}return t}function gn(e,t){var n,r;if(!e.clip)return[];const i=null==(r=null==(n=ee(e.clip.border))?void 0:n.getEditPoints)?void 0:r.call(n,e.clip.border,t);return i?i.editPoints.map((e=>v(y({},e),{update(t,n){if(!ze(t))return;if(!t.clip)return;let r;return t.clip.border=(0,o.produce)(t.clip.border,(t=>{e.update&&(r=e.update(t,n))})),r||void 0}}))):[]}const mn=new s.WeakmapCache,yn=new s.WeakmapCache;function vn(e){if(Array.isArray(e)||"ray"!==e.type)return yn.get(e,(()=>(0,s.getGeometryLineBounding)(e)))}function xn(e,t){var n,r;if(!e)return;const o=null==(r=null==(n=ee(e))?void 0:n.getGeometries)?void 0:r.call(n,e,t);return!o||o.lines.length>30?void 0:{lines:o.lines,id:Xe(e,t)}}function bn(e){return{x:e.start.x-1,y:e.start.y-1,w:e.end.x-e.start.x+2,h:e.end.y-e.start.y+2}}},4864:(e,t,n)=>{"use strict";n.d(t,{pluginScripts:()=>r});const r=['// dev/cad-editor/plugins/arrow.plugin.tsx\nfunction getModel(ctx) {\n const ArrowContent = ctx.and(ctx.BaseContent("arrow"), ctx.StrokeFields, ctx.ArrowFields, {\n p1: ctx.Position,\n p2: ctx.Position,\n ref1: ctx.optional(ctx.PositionRef),\n ref2: ctx.optional(ctx.PositionRef)\n });\n const getRefIds = (content) => {\n var _a, _b;\n return [...ctx.getStrokeRefIds(content), ...ctx.toRefIds([(_a = content.ref1) == null ? void 0 : _a.id, (_b = content.ref2) == null ? void 0 : _b.id])];\n };\n function getArrowGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n var _a, _b;\n const p1 = (_a = ctx.getRefPosition(content.ref1, contents, [content])) != null ? _a : content.p1;\n const p2 = (_b = ctx.getRefPosition(content.ref2, contents, [content])) != null ? _b : content.p2;\n const { arrowPoints, endPoint } = ctx.getArrowPoints(p1, p2, content);\n const points = [p1, endPoint];\n return {\n lines: Array.from(ctx.iteratePolylineLines(points)),\n bounding: ctx.getPointsBounding(points),\n regions: [\n {\n points: arrowPoints,\n lines: Array.from(ctx.iteratePolygonLines(arrowPoints))\n }\n ],\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray)\n };\n });\n }\n const React = ctx.React;\n return {\n type: "arrow",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n move(content, offset) {\n ctx.movePoint(content.p1, offset);\n ctx.movePoint(content.p2, offset);\n },\n rotate(content, center, angle) {\n ctx.rotatePoint(content.p1, center, angle);\n ctx.rotatePoint(content.p2, center, angle);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content.p1, center, sx, sy);\n ctx.scalePoint(content.p2, center, sx, sy);\n },\n skew(content, center, sx, sy) {\n ctx.skewPoint(content.p1, center, sx, sy);\n ctx.skewPoint(content.p2, center, sx, sy);\n },\n mirror(content, line) {\n ctx.mirrorPoint(content.p1, line);\n ctx.mirrorPoint(content.p2, line);\n },\n render(content, renderCtx) {\n const { options, target, contents, fillOptions } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { regions, renderingLines } = getArrowGeometriesFromCache(content, contents);\n const children = [];\n for (const line of renderingLines) {\n children.push(target.renderPolyline(line, options));\n }\n if (regions) {\n for (let i = 0; i < 2 && i < regions.length; i++) {\n children.push(target.renderPolygon(regions[i].points, fillOptions));\n }\n }\n return target.renderGroup(children);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content.p1,\n cursor: "move",\n update(c, { cursor, start, scale, target }) {\n if (!isArrowContent(c)) {\n return;\n }\n c.p1.x += cursor.x - start.x;\n c.p1.y += cursor.y - start.y;\n c.ref1 = ctx.getSnapTargetRef(target, contents);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n ...content.p2,\n cursor: "move",\n update(c, { cursor, start, scale, target }) {\n if (!isArrowContent(c)) {\n return;\n }\n c.p2.x += cursor.x - start.x;\n c.p2.y += cursor.y - start.y;\n c.ref2 = ctx.getSnapTargetRef(target, contents);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getArrowGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n var _a, _b;\n return {\n p1: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p, ref) => update((c) => {\n if (isArrowContent(c)) {\n c.p1.x = p.x;\n c.p1.y = p.y;\n c.ref1 = ref;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p1.x, setValue: (v) => update((c) => {\n if (isArrowContent(c)) {\n c.p1.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p1.y, setValue: (v) => update((c) => {\n if (isArrowContent(c)) {\n c.p1.y = v;\n }\n }) })\n }\n }\n ),\n p2: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p, ref) => update((c) => {\n if (isArrowContent(c)) {\n c.p2.x = p.x;\n c.p2.y = p.y;\n c.ref2 = ref;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p2.x, setValue: (v) => update((c) => {\n if (isArrowContent(c)) {\n c.p2.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p2.y, setValue: (v) => update((c) => {\n if (isArrowContent(c)) {\n c.p2.y = v;\n }\n }) })\n }\n }\n ),\n ref1: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.ref1 !== void 0, readOnly: content.ref1 === void 0, setValue: (v) => update((c) => {\n if (isArrowContent(c) && !v) {\n c.ref1 = void 0;\n }\n }) }),\n content.ref1 !== void 0 && typeof content.ref1.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref1.id, setValue: (v) => update((c) => {\n if (isArrowContent(c) && c.ref1) {\n c.ref1.id = v;\n }\n }) }) : void 0,\n content.ref1 !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref1.snapIndex, setValue: (v) => update((c) => {\n if (isArrowContent(c) && c.ref1) {\n c.ref1.snapIndex = v;\n }\n }) }) : void 0,\n ((_a = content.ref1) == null ? void 0 : _a.param) !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { readOnly: true, value: content.ref1.param }) : void 0\n ],\n ref2: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.ref2 !== void 0, readOnly: content.ref2 === void 0, setValue: (v) => update((c) => {\n if (isArrowContent(c) && !v) {\n c.ref2 = void 0;\n }\n }) }),\n content.ref2 !== void 0 && typeof content.ref2.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref2.id, setValue: (v) => update((c) => {\n if (isArrowContent(c) && c.ref2) {\n c.ref2.id = v;\n }\n }) }) : void 0,\n content.ref2 !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref2.snapIndex, setValue: (v) => update((c) => {\n if (isArrowContent(c) && c.ref2) {\n c.ref2.snapIndex = v;\n }\n }) }) : void 0,\n ((_b = content.ref2) == null ? void 0 : _b.param) !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { readOnly: true, value: content.ref2.param }) : void 0\n ],\n ...ctx.getArrowContentPropertyPanel(content, update),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, ArrowContent, p),\n getRefIds,\n updateRefId(content, update) {\n if (content.ref1) {\n const newRefId = update(content.ref1.id);\n if (newRefId !== void 0) {\n content.ref1.id = newRefId;\n }\n }\n if (content.ref2) {\n const newRefId = update(content.ref2.id);\n if (newRefId !== void 0) {\n content.ref2.id = newRefId;\n }\n }\n ctx.updateStrokeRefIds(content, update);\n },\n deleteRefId(content, ids) {\n if (content.ref1 && ids.includes(content.ref1.id)) {\n content.ref1 = void 0;\n }\n if (content.ref2 && ids.includes(content.ref2.id)) {\n content.ref2 = void 0;\n }\n ctx.deleteStrokeRefIds(content, ids);\n },\n reverse: (content) => ({\n ...content,\n p1: content.p2,\n p2: content.p1,\n ref1: content.ref2,\n ref2: content.ref1\n })\n };\n}\nfunction isArrowContent(content) {\n return content.type === "arrow";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("g", { transform: "" }, /* @__PURE__ */ React.createElement("polyline", { points: "12,86 81,20", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "88,14 72,39 62,28", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" })));\n return {\n name: "create arrow",\n hotkey: "AR",\n icon,\n useCommand({ onEnd, type, strokeStyleId }) {\n const { line, positionTargets, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create arrow",\n (c, targets) => onEnd({\n updateContents: (contents) => contents.push({\n type: "arrow",\n p1: c[0],\n p2: c[1],\n ref1: targets[0],\n ref2: targets[1],\n strokeStyleId\n })\n }),\n {\n once: true\n }\n );\n const assistentContents = [];\n if (line) {\n assistentContents.push({\n type: "arrow",\n p1: line[0],\n p2: line[1],\n ref1: positionTargets[0],\n ref2: positionTargets[1],\n strokeStyleId\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isArrowContent\n};\n','// dev/cad-editor/plugins/block.plugin.tsx\nfunction getModel(ctx) {\n const React = ctx.React;\n const BlockContent = ctx.and(ctx.BaseContent("block"), ctx.ContainerFields, {\n base: ctx.Position\n });\n const BlockReferenceContent = ctx.and(ctx.BaseContent("block reference"), ctx.Position, ctx.VariableValuesFields, {\n refId: ctx.ContentRef,\n angle: ctx.number,\n scale: ctx.optional(ctx.or(ctx.number, ctx.Position))\n });\n const getBlockRefIds = (content) => ctx.toRefIds(content.contents);\n const getBlockReferenceRefIds = (content) => ctx.toRefId(content.refId, true);\n const blockModel = {\n type: "block",\n ...ctx.containerModel,\n explode: ctx.getContainerExplode,\n render: ctx.getContainerRender,\n renderIfSelected: (content, renderCtx) => ctx.getContainerRenderIfSelected(content, renderCtx, [content], getBlockRefIds),\n getOperatorRenderPosition(content) {\n return content.base;\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content.base,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isBlockContent(c)) {\n return;\n }\n c.base.x += cursor.x - start.x;\n c.base.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content.base, cursor] }] };\n }\n }\n ],\n angleSnapStartPoint: content.base\n };\n });\n },\n getSnapPoints: ctx.getContainerSnapPoints,\n getGeometries: (content, contents) => ctx.getContainerGeometries(content, contents, getBlockRefIds, [content]),\n propertyPanel(content, update, _, { acquirePoint }) {\n return {\n base: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isBlockContent(c)) {\n c.base.x = p.x, c.base.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.base.x, setValue: (v) => update((c) => {\n if (isBlockContent(c)) {\n c.base.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.base.y, setValue: (v) => update((c) => {\n if (isBlockContent(c)) {\n c.base.y = v;\n }\n }) })\n }\n }\n ),\n ...ctx.getVariableValuesContentPropertyPanel(content, ctx.getContainerVariableNames(content), update)\n };\n },\n isValid: (c, p) => ctx.validate(c, BlockContent, p),\n getRefIds: getBlockRefIds\n };\n const blockSnapPointsCache = new ctx.WeakmapCache2();\n function extractContentInBlockReference(target, content, block, contents) {\n let model = ctx.getContentModel(target);\n if (!model) {\n return void 0;\n }\n let newResult;\n const result = ctx.produce(target, (draft) => {\n var _a, _b, _c;\n const scale = ctx.getScaleOptionsScale(content);\n if (scale) {\n const r = (_a = model == null ? void 0 : model.scale) == null ? void 0 : _a.call(model, draft, block.base, scale.x, scale.y, contents);\n if (r) {\n model = ctx.getContentModel(r);\n newResult = r;\n draft = r;\n }\n }\n if (content.angle) {\n (_b = model == null ? void 0 : model.rotate) == null ? void 0 : _b.call(model, draft, block.base, content.angle, contents);\n }\n (_c = model == null ? void 0 : model.move) == null ? void 0 : _c.call(model, draft, content);\n });\n return newResult || result;\n }\n function getBlockReferenceGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getBlockReferenceRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n const lines = [];\n const boundings = [];\n const renderingLines = [];\n const regions = [];\n block.contents.forEach((c) => {\n var _a, _b;\n if (!c) {\n return;\n }\n const extracted = extractContentInBlockReference(c, content, block, contents);\n if (extracted) {\n const r = (_b = (_a = ctx.getContentModel(extracted)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, extracted, contents);\n if (r) {\n lines.push(...r.lines);\n if (r.bounding) {\n boundings.push(r.bounding);\n }\n if (r.renderingLines) {\n renderingLines.push(...r.renderingLines);\n }\n if (r.regions) {\n regions.push(...r.regions);\n }\n }\n }\n });\n return {\n lines,\n bounding: ctx.mergeBoundingsUnsafe(boundings),\n renderingLines,\n regions\n };\n }\n return { lines: [], renderingLines: [] };\n });\n }\n const blockReferenceModel = {\n type: "block reference",\n ...ctx.variableValuesModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle, contents) {\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n const p = ctx.rotatePoint({ x: content.x + block.base.x, y: content.y + block.base.y }, center, angle);\n content.x = p.x - block.base.x;\n content.y = p.y - block.base.y;\n content.angle += angle;\n }\n },\n scale(content, center, sx, sy, contents) {\n var _a, _b;\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n const p = { x: content.x + block.base.x, y: content.y + block.base.y };\n ctx.scalePoint(p, center, sx, sy);\n content.x = p.x - block.base.x;\n content.y = p.y - block.base.y;\n const scale = ctx.getScaleOptionsScale(content);\n content.scale = {\n x: ((_a = scale == null ? void 0 : scale.x) != null ? _a : 1) * sx,\n y: ((_b = scale == null ? void 0 : scale.y) != null ? _b : 1) * sy\n };\n }\n },\n explode(content, contents) {\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n const result = [];\n block.contents.forEach((c) => {\n if (!c) {\n return;\n }\n const extracted = extractContentInBlockReference(c, content, block, contents);\n if (extracted) {\n result.push(extracted);\n }\n });\n return result;\n }\n return [];\n },\n mirror(content, line, angle, contents) {\n var _a, _b;\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n const p = ctx.mirrorPoint({ x: content.x + block.base.x, y: content.y + block.base.y }, line);\n content.x = p.x - block.base.x;\n content.y = p.y - block.base.y;\n content.angle = 2 * angle - content.angle;\n const scale = ctx.getScaleOptionsScale(content);\n content.scale = {\n x: (_a = scale == null ? void 0 : scale.x) != null ? _a : 1,\n y: -((_b = scale == null ? void 0 : scale.y) != null ? _b : 1)\n };\n }\n },\n render(content, renderCtx) {\n const block = ctx.getReference(content.refId, renderCtx.contents, isBlockContent);\n if (block) {\n const children = ctx.renderContainerChildren({ ...block, variableValues: content.variableValues }, renderCtx);\n return renderCtx.target.renderGroup(children, { translate: content, base: block.base, angle: content.angle, scale: content.scale });\n }\n return renderCtx.target.renderEmpty();\n },\n renderIfSelected(content, renderCtx) {\n const block = ctx.getReference(content.refId, renderCtx.contents, isBlockContent);\n if (block) {\n const children = ctx.renderContainerIfSelected(block, renderCtx, [content], getBlockRefIds);\n return renderCtx.target.renderGroup([children], { translate: content, base: block.base, angle: content.angle, scale: content.scale });\n }\n return renderCtx.target.renderEmpty();\n },\n getOperatorRenderPosition(content, contents) {\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n return { x: content.x + block.base.x, y: content.y + block.base.y };\n }\n return content;\n },\n getEditPoints(content, contents) {\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (!block) {\n return;\n }\n return ctx.getEditPointsFromCache(content, () => {\n const p = { x: content.x + block.base.x, y: content.y + block.base.y };\n return {\n editPoints: [\n {\n ...p,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isBlockReferenceContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [p, cursor] }] };\n }\n }\n ],\n angleSnapStartPoint: p\n };\n });\n },\n getSnapPoints(content, contents) {\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n return blockSnapPointsCache.get(block, content, () => {\n const result = [];\n block.contents.forEach((c) => {\n var _a;\n if (!c) {\n return;\n }\n const model = ctx.getContentModel(c);\n const extracted = extractContentInBlockReference(c, content, block, contents);\n if (extracted) {\n const r = (_a = model == null ? void 0 : model.getSnapPoints) == null ? void 0 : _a.call(model, extracted, contents);\n if (r) {\n result.push(...r);\n }\n }\n });\n return result;\n });\n }\n return [];\n },\n getGeometries: getBlockReferenceGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n var _a, _b;\n let variableNames = [];\n const block = ctx.getReference(content.refId, contents, isBlockContent);\n if (block) {\n variableNames = ctx.getContainerVariableNames(block);\n }\n const scale = ctx.getScaleOptionsScale(content);\n return {\n refId: typeof content.refId === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.refId, setValue: (v) => update((c) => {\n if (isBlockReferenceContent(c)) {\n c.refId = v;\n }\n }) }) : [],\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isBlockReferenceContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isBlockReferenceContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isBlockReferenceContent(c)) {\n c.y = v;\n }\n }) }),\n angle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.angle, setValue: (v) => update((c) => {\n if (isBlockReferenceContent(c)) {\n c.angle = v;\n }\n }) }),\n sx: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_a = scale == null ? void 0 : scale.x) != null ? _a : 1, setValue: (v) => update((c) => {\n var _a2;\n if (isBlockReferenceContent(c)) {\n c.scale = { x: v, y: (_a2 = scale == null ? void 0 : scale.y) != null ? _a2 : v };\n }\n }) }),\n sy: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_b = scale == null ? void 0 : scale.y) != null ? _b : 1, setValue: (v) => update((c) => {\n var _a2;\n if (isBlockReferenceContent(c)) {\n c.scale = { x: (_a2 = scale == null ? void 0 : scale.x) != null ? _a2 : v, y: v };\n }\n }) }),\n ...ctx.getVariableValuesContentPropertyPanel(content, variableNames, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, BlockReferenceContent, p),\n getRefIds: getBlockReferenceRefIds,\n updateRefId(content, update) {\n const newRefId = update(content.refId);\n if (newRefId !== void 0) {\n content.refId = newRefId;\n }\n }\n };\n return [\n blockModel,\n blockReferenceModel\n ];\n}\nfunction isBlockContent(content) {\n return content.type === "block";\n}\nfunction isBlockReferenceContent(content) {\n return content.type === "block reference";\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 576 512" }, /* @__PURE__ */ React.createElement("path", { fill: "currentColor", d: "M32 119.4C12.9 108.4 0 87.7 0 64C0 28.7 28.7 0 64 0c23.7 0 44.4 12.9 55.4 32H456.6C467.6 12.9 488.3 0 512 0c35.3 0 64 28.7 64 64c0 23.7-12.9 44.4-32 55.4V392.6c19.1 11.1 32 31.7 32 55.4c0 35.3-28.7 64-64 64c-23.7 0-44.4-12.9-55.4-32H119.4c-11.1 19.1-31.7 32-55.4 32c-35.3 0-64-28.7-64-64c0-23.7 12.9-44.4 32-55.4V119.4zM456.6 96H119.4c-5.6 9.7-13.7 17.8-23.4 23.4V392.6c9.7 5.6 17.8 13.7 23.4 23.4H456.6c5.6-9.7 13.7-17.8 23.4-23.4V119.4c-9.7-5.6-17.8-13.7-23.4-23.4zM128 160c0-17.7 14.3-32 32-32H288c17.7 0 32 14.3 32 32v96c0 17.7-14.3 32-32 32H160c-17.7 0-32-14.3-32-32V160zM256 320h32c35.3 0 64-28.7 64-64V224h64c17.7 0 32 14.3 32 32v96c0 17.7-14.3 32-32 32H288c-17.7 0-32-14.3-32-32V320z" }));\n const referenceIcon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 640 512" }, /* @__PURE__ */ React.createElement("path", { fill: "currentColor", d: "M32 119.4C12.9 108.4 0 87.7 0 64C0 28.7 28.7 0 64 0c23.7 0 44.4 12.9 55.4 32H328.6C339.6 12.9 360.3 0 384 0c35.3 0 64 28.7 64 64c0 23.7-12.9 44.4-32 55.4V232.6c19.1 11.1 32 31.7 32 55.4c0 35.3-28.7 64-64 64c-23.7 0-44.4-12.9-55.4-32H119.4c-11.1 19.1-31.7 32-55.4 32c-35.3 0-64-28.7-64-64c0-23.7 12.9-44.4 32-55.4V119.4zM119.4 96c-5.6 9.7-13.7 17.8-23.4 23.4V232.6c9.7 5.6 17.8 13.7 23.4 23.4H328.6c5.6-9.7 13.7-17.8 23.4-23.4V119.4c-9.7-5.6-17.8-13.7-23.4-23.4H119.4zm192 384c-11.1 19.1-31.7 32-55.4 32c-35.3 0-64-28.7-64-64c0-23.7 12.9-44.4 32-55.4V352h64v40.6c9.7 5.6 17.8 13.7 23.4 23.4H520.6c5.6-9.7 13.7-17.8 23.4-23.4V279.4c-9.7-5.6-17.8-13.7-23.4-23.4h-46c-5.4-15.4-14.6-28.9-26.5-39.6V192h72.6c11.1-19.1 31.7-32 55.4-32c35.3 0 64 28.7 64 64c0 23.7-12.9 44.4-32 55.4V392.6c19.1 11.1 32 31.7 32 55.4c0 35.3-28.7 64-64 64c-23.7 0-44.4-12.9-55.4-32H311.4z" }));\n const blockCommand = {\n name: "create block",\n useCommand({ onEnd, type }) {\n let message = "";\n if (type) {\n message = "specify base point";\n }\n const { input, setInputPosition, resetInput } = ctx.useCursorInput(message);\n return {\n onStart(p) {\n onEnd({\n updateContents: (contents, selected) => {\n const newContent = {\n type: "block",\n contents: contents.filter((c, i) => c && ctx.isSelected([i], selected) && contentSelectable(c, contents)),\n base: p\n };\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n contents.push(newContent);\n }\n });\n },\n input,\n onMove(_, p) {\n setInputPosition(p);\n },\n reset: resetInput\n };\n },\n contentSelectable,\n hotkey: "B",\n icon\n };\n const blockReferenceCommand = {\n name: "create block reference",\n useCommand({ onEnd, type, scale }) {\n let message = "";\n if (type) {\n message = "specify target point";\n }\n const { input, setInputPosition, cursorPosition, setCursorPosition, resetInput } = ctx.useCursorInput(message);\n return {\n onStart(p) {\n resetInput();\n onEnd({\n updateContents: (contents, selected) => {\n contents.push(\n ...contents.filter((c, i) => !!c && ctx.isSelected([i], selected) && isBlockContent(c)).map((block) => ({\n type: "block reference",\n refId: ctx.getContentIndex(block, contents),\n x: p.x - block.base.x,\n y: p.y - block.base.y,\n angle: 0\n }))\n );\n setCursorPosition(void 0);\n }\n });\n },\n input,\n onMove(p, viewportPosition) {\n setInputPosition(viewportPosition || p);\n if (!type) {\n return;\n }\n setCursorPosition(p);\n },\n updateSelectedContent(content, contents) {\n if (!isBlockContent(content)) {\n return {};\n }\n if (cursorPosition) {\n return {\n newContents: [\n {\n type: "block reference",\n refId: ctx.getContentIndex(content, contents),\n x: cursorPosition.x - content.base.x,\n y: cursorPosition.y - content.base.y,\n angle: 0\n }\n ],\n assistentContents: [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [{ x: content.base.x, y: content.base.y }, cursorPosition]\n }\n ]\n };\n }\n return {};\n },\n reset: resetInput\n };\n },\n contentSelectable: isBlockContent,\n selectCount: 1,\n icon: referenceIcon\n };\n return [blockCommand, blockReferenceCommand];\n}\nexport {\n getCommand,\n getModel,\n isBlockContent,\n isBlockReferenceContent\n};\n','// dev/cad-editor/plugins/break.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 640 512" }, /* @__PURE__ */ React.createElement("path", { fill: "currentColor", d: "M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L489.3 358.2l90.5-90.5c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114l-96 96-31.9-25C430.9 239.6 420.1 175.1 377 132c-52.2-52.3-134.5-56.2-191.3-11.7L38.8 5.1zM239 162c30.1-14.9 67.7-9.9 92.8 15.3c20 20 27.5 48.3 21.7 74.5L239 162zM406.6 416.4L220.9 270c-2.1 39.8 12.2 80.1 42.2 110c38.9 38.9 94.4 51 143.6 36.3zm-290-228.5L60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5l61.8-61.8-50.6-39.9z" }));\n return {\n name: "break",\n execute({ contents, selected }) {\n const newContents = [];\n const indexes = [];\n contents.forEach((content, index) => {\n var _a, _b, _c, _d;\n if (content && ctx.isSelected([index], selected) && ((_b = (_a = this.contentSelectable) == null ? void 0 : _a.call(this, content, contents)) != null ? _b : true)) {\n let intersectionPoints = [];\n for (let i = 0; i < contents.length; i++) {\n const c = contents[i];\n if (c && i !== index) {\n const p = i < index ? [c, content] : [content, c];\n intersectionPoints.push(...ctx.getIntersectionPoints(...p, contents));\n }\n }\n intersectionPoints = ctx.deduplicatePosition(intersectionPoints);\n if (intersectionPoints.length > 0) {\n const result = (_d = (_c = ctx.getContentModel(content)) == null ? void 0 : _c.break) == null ? void 0 : _d.call(_c, content, intersectionPoints, contents);\n if (result) {\n newContents.push(...result);\n indexes.push(index);\n }\n }\n }\n });\n ctx.deleteSelectedContents(contents, indexes);\n contents.push(...newContents);\n },\n contentSelectable(content, contents) {\n const model = ctx.getContentModel(content);\n return (model == null ? void 0 : model.break) !== void 0 && ctx.contentIsDeletable(content, contents);\n },\n hotkey: "BR",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\n\n// dev/cad-editor/plugins/center-line.plugin.tsx\nfunction getModel(ctx) {\n const CenterLineReferenceContent = ctx.and(ctx.BaseContent("center line"), {\n ref1: ctx.PartRef,\n ref2: ctx.PartRef\n });\n const getRefIds = (content) => ctx.toRefIds([content.ref1.id, content.ref2.id], true);\n function getCenterLineGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n const ref1 = ctx.getRefPart(content.ref1, contents, isLineContent);\n const ref2 = ctx.getRefPart(content.ref2, contents, isLineContent);\n if (ref1 && ref2) {\n const line = ctx.maxmiumBy([\n [ctx.getTwoPointCenter(ref1.points[0], ref2.points[0]), ctx.getTwoPointCenter(ref1.points[1], ref2.points[1])],\n [ctx.getTwoPointCenter(ref1.points[0], ref2.points[1]), ctx.getTwoPointCenter(ref1.points[1], ref2.points[0])]\n ].map((r) => ({ line: r, length: ctx.getTwoPointsDistance(...r) })), (v) => v.length).line;\n return {\n lines: [line],\n bounding: ctx.getPointsBounding(line),\n renderingLines: ctx.dashedPolylineToLines(line, [8, 4])\n };\n }\n return { lines: [], renderingLines: [] };\n });\n }\n const React = ctx.React;\n return {\n type: "center line",\n render(content, renderCtx) {\n const { options, target, contents } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { renderingLines } = getCenterLineGeometriesFromCache(content, contents);\n return target.renderGroup(renderingLines.map((line) => target.renderPolyline(line, options)));\n },\n getGeometries: getCenterLineGeometriesFromCache,\n propertyPanel(content, update, contents, { acquireContent }) {\n return {\n ref1: [\n /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquireContent({ count: 1, part: true, selectable: (v) => contentSelectable(ctx.getContentByIndex(contents, v)) }, (r) => update((c) => {\n if (isCenterLineContent(c)) {\n c.ref1 = r[0];\n }\n })) }, "select"),\n typeof content.ref1.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref1.id, setValue: (v) => update((c) => {\n if (isCenterLineContent(c)) {\n c.ref1.id = v;\n }\n }) }) : void 0,\n content.ref1.partIndex !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref1.partIndex, setValue: (v) => update((c) => {\n if (isCenterLineContent(c)) {\n c.ref1.partIndex = v;\n }\n }) }) : void 0\n ],\n ref2: [\n /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquireContent({ count: 1, part: true, selectable: (v) => contentSelectable(ctx.getContentByIndex(contents, v)) }, (r) => update((c) => {\n if (isCenterLineContent(c)) {\n c.ref2 = r[0];\n }\n })) }, "select"),\n typeof content.ref2.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref2.id, setValue: (v) => update((c) => {\n if (isCenterLineContent(c)) {\n c.ref2.id = v;\n }\n }) }) : void 0,\n content.ref2.partIndex !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref2.partIndex, setValue: (v) => update((c) => {\n if (isCenterLineContent(c)) {\n c.ref2.partIndex = v;\n }\n }) }) : void 0\n ]\n };\n },\n isValid: (c, p) => ctx.validate(c, CenterLineReferenceContent, p),\n getRefIds,\n updateRefId(content, update) {\n const newRefId1 = update(content.ref1.id);\n if (newRefId1 !== void 0) {\n content.ref1.id = newRefId1;\n }\n const newRefId2 = update(content.ref2.id);\n if (newRefId2 !== void 0) {\n content.ref2.id = newRefId2;\n }\n }\n };\n}\nfunction isCenterLineContent(content) {\n return content.type === "center line";\n}\nfunction contentSelectable(content) {\n return !!content && isLineContent(content);\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "48,0 48,100", strokeWidth: "5", strokeDasharray: "8", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "100,0 100,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "0,1 0,99", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create center line",\n icon,\n contentSelectable,\n selectCount: 2,\n selectType: "select part",\n execute({ contents, selected }) {\n contents.push({\n type: "center line",\n ref1: {\n id: selected[0][0],\n partIndex: selected[0][1]\n },\n ref2: {\n id: selected[1][0],\n partIndex: selected[1][1]\n }\n });\n }\n };\n}\nexport {\n getCommand,\n getModel,\n isCenterLineContent\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isCircleContent(content) {\n return content.type === "circle";\n}\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/center-mark.plugin.tsx\nfunction getModel(ctx) {\n const CenterMarkReferenceContent = ctx.and(ctx.BaseContent("center mark"), {\n ref: ctx.PartRef\n });\n const getRefIds = (content) => ctx.toRefId(content.ref.id, true);\n function getCenterMarkGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n const target = ctx.getRefPart(content.ref, contents, contentSelectable);\n if (target) {\n const lines = [\n [{ x: target.x - target.r, y: target.y }, { x: target.x + target.r, y: target.y }],\n [{ x: target.x, y: target.y - target.r }, { x: target.x, y: target.y + target.r }]\n ];\n return {\n lines,\n bounding: ctx.getPointsBounding(lines.flat()),\n renderingLines: lines.map((line) => ctx.dashedPolylineToLines(line, [8, 4])).flat()\n };\n }\n return { lines: [], renderingLines: [] };\n });\n }\n const React = ctx.React;\n return {\n type: "center mark",\n render(content, renderCtx) {\n const { options, target, contents } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { renderingLines } = getCenterMarkGeometriesFromCache(content, contents);\n return target.renderGroup(renderingLines.map((line) => target.renderPolyline(line, options)));\n },\n getGeometries: getCenterMarkGeometriesFromCache,\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquireContent }) {\n return {\n ref: [\n /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquireContent({ count: 1, part: true, selectable: (v) => contentSelectable(ctx.getContentByIndex(contents, v)) }, (r) => update((c) => {\n if (isCenterMarkContent(c)) {\n c.ref = r[0];\n }\n })) }, "select"),\n typeof content.ref.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref.id, setValue: (v) => update((c) => {\n if (isCenterMarkContent(c)) {\n c.ref.id = v;\n }\n }) }) : void 0,\n content.ref.partIndex !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref.partIndex, setValue: (v) => update((c) => {\n if (isCenterMarkContent(c)) {\n c.ref.partIndex = v;\n }\n }) }) : void 0\n ]\n };\n },\n isValid: (c, p) => ctx.validate(c, CenterMarkReferenceContent, p),\n getRefIds,\n updateRefId(content, update) {\n const newRefId = update(content.ref.id);\n if (newRefId !== void 0) {\n content.ref.id = newRefId;\n }\n }\n };\n}\nfunction isCenterMarkContent(content) {\n return content.type === "center mark";\n}\nfunction contentSelectable(content) {\n return !!content && (isArcContent(content) || isCircleContent(content));\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "48,0 48,100", strokeWidth: "5", strokeDasharray: "8", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "0,49 100,49", strokeWidth: "5", strokeDasharray: "8", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create center mark",\n icon,\n contentSelectable,\n selectType: "select part",\n execute({ contents, selected }) {\n contents.push(...selected.map(([index, partIndex]) => ({\n type: "center mark",\n ref: {\n id: index,\n partIndex\n }\n })));\n }\n };\n}\nexport {\n getCommand,\n getModel,\n isCenterMarkContent\n};\n','// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\n\n// dev/cad-editor/plugins/chamfer.plugin.tsx\nfunction getCommand(ctx) {\n function getChamfers(content1, content2, d1, d2) {\n const result = [];\n if (isLineContent(content1) && isLineContent(content2)) {\n const point = ctx.getTwoLinesIntersectionPoint(content1.points[0], content1.points[1], content2.points[0], content2.points[1]);\n if (point) {\n const p1 = [];\n const a1 = ctx.getPointByLengthAndDirectionSafely(point, d1, content1.points[0]);\n const b1 = ctx.getPointByLengthAndDirectionSafely(point, d1, content1.points[1]);\n if (a1) {\n p1.push(a1);\n }\n if (b1 && (!a1 || !ctx.isSamePoint(a1, b1))) {\n p1.push(b1);\n }\n const p2 = [];\n const a2 = ctx.getPointByLengthAndDirectionSafely(point, d2, content2.points[0]);\n const b2 = ctx.getPointByLengthAndDirectionSafely(point, d2, content2.points[1]);\n if (a2) {\n p2.push(a2);\n }\n if (b2 && (!a2 || !ctx.isSamePoint(a2, b2))) {\n p2.push(b2);\n }\n for (const c1 of p1) {\n for (const c2 of p2) {\n result.push([c1, c2]);\n }\n }\n }\n }\n return result;\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "11,12 57,12 86,41 86,86", strokeWidth: "3", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }));\n return {\n name: "chamfer",\n useCommand({ onEnd, type, selected, scale }) {\n const [candidates, setCandidates] = React.useState([]);\n const [result, setResult] = React.useState();\n let message = "";\n if (type) {\n if (candidates.length > 0) {\n message = "select one result";\n } else {\n message = "input distance";\n }\n }\n const assistentContents = candidates.map((c) => ({\n type: "line",\n points: c,\n dashArray: c === result ? void 0 : [4 / scale]\n }));\n const { input, setInputPosition, setCursorPosition, clearText, resetInput } = ctx.useCursorInput(message, type && candidates.length == 0 ? (e, text) => {\n if (e.key === "Enter") {\n const position = text.split(",");\n if (position.length === 2) {\n const d1 = +position[0];\n const d2 = +position[1];\n if (!isNaN(d1) && !isNaN(d2)) {\n setCandidates(getChamfers(selected[0].content, selected[1].content, d1, d2));\n clearText();\n }\n } else {\n const d = +text;\n if (!isNaN(d)) {\n setCandidates(getChamfers(selected[0].content, selected[1].content, d, d));\n clearText();\n }\n }\n }\n } : void 0);\n const reset = () => {\n setCandidates([]);\n setResult(void 0);\n clearText();\n resetInput();\n };\n return {\n onStart(p) {\n setCursorPosition(p);\n if (result) {\n onEnd({\n updateContents: (contents) => {\n contents.push({ type: "line", points: result });\n }\n });\n setCandidates([]);\n }\n },\n input,\n onMove(p, viewportPosition) {\n setCursorPosition(p);\n setInputPosition(viewportPosition || p);\n setResult(candidates.find((c) => ctx.getPointAndLineSegmentMinimumDistance(p, c[0], c[1]) < 5));\n },\n assistentContents,\n reset\n };\n },\n selectCount: 2,\n contentSelectable: (c) => isLineContent(c),\n selectType: "select part",\n hotkey: "CHA",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\nfunction isPolyLineContent(content) {\n return content.type === "polyline";\n}\n\n// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction getModel(ctx) {\n const CircleContent = ctx.and(ctx.BaseContent("circle"), ctx.StrokeFields, ctx.FillFields, ctx.Circle, {\n xExpression: ctx.optional(ctx.string),\n yExpression: ctx.optional(ctx.string),\n rExpression: ctx.optional(ctx.string)\n });\n const ArcContent = ctx.and(ctx.BaseContent("arc"), ctx.StrokeFields, ctx.FillFields, ctx.AngleDeltaFields, ctx.Arc);\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const circleGeometriesCache = new ctx.WeakmapValuesCache();\n const arcGeometriesCache = new ctx.WeakmapValuesCache();\n function getCircleGeometries(content, contents, time) {\n const quadrantPoints = ctx.getCircleQuadrantPoints(content);\n if (time && (content.xExpression || content.yExpression || content.rExpression)) {\n const x = ctx.getTimeExpressionValue(content.xExpression, time, content.x);\n const y = ctx.getTimeExpressionValue(content.yExpression, time, content.y);\n const r = ctx.getTimeExpressionValue(content.rExpression, time, content.r);\n return { quadrantPoints, ...getArcGeometries(ctx.circleToArc({ ...content, x, y, r }), contents) };\n }\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return circleGeometriesCache.get(content, refs, () => {\n return { quadrantPoints, ...getArcGeometries(ctx.circleToArc(content), contents) };\n });\n }\n function getArcGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return arcGeometriesCache.get(content, refs, () => {\n var _a;\n const points = ctx.arcToPolyline(content, (_a = content.angleDelta) != null ? _a : ctx.defaultAngleDelta);\n const middleAngle = ctx.getTwoNumberCenter(content.startAngle, ctx.getFormattedEndAngle(content));\n const geometries = {\n lines: [{ type: "arc", curve: content }],\n points,\n start: ctx.getArcPointAtAngle(content, content.startAngle),\n end: ctx.getArcPointAtAngle(content, content.endAngle),\n middle: ctx.getArcPointAtAngle(content, middleAngle),\n bounding: ctx.getArcBounding(content),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray)\n };\n if (ctx.hasFill(content)) {\n return {\n ...geometries,\n lines: [],\n points: geometries.points,\n bounding: geometries.bounding,\n regions: [{\n lines: geometries.lines,\n points: geometries.points\n }],\n renderingLines: []\n };\n }\n return geometries;\n });\n }\n const React = ctx.React;\n return [\n {\n type: "circle",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle) {\n ctx.rotatePoint(content, center, angle);\n },\n scale(content, center, sx, sy) {\n if (sx !== sy && !ctx.isZero(sx + sy)) {\n const ellipse = {\n ...content,\n type: "ellipse",\n cx: content.x,\n cy: content.y,\n rx: content.r,\n ry: content.r\n };\n ctx.scaleEllipse(ellipse, center, sx, sy);\n return ellipse;\n }\n ctx.scalePoint(content, center, sx, sy);\n content.r *= Math.abs(sx);\n return;\n },\n skew(content, center, sx, sy) {\n const ellipse = {\n ...content,\n type: "ellipse",\n cx: content.x,\n cy: content.y,\n rx: content.r,\n ry: content.r\n };\n ctx.skewEllipse(ellipse, center, sx, sy);\n return ellipse;\n },\n mirror(content, line) {\n ctx.mirrorPoint(content, line);\n },\n offset(content, point, distance) {\n if (!distance) {\n distance = ctx.getTwoNumbersDistance(ctx.getTwoPointsDistance(point, content), content.r);\n }\n return ctx.getParallelCirclesByDistance(content, distance)[ctx.pointSideToIndex(ctx.getPointSideOfCircle(point, content))];\n },\n break(content, points) {\n if (points.length < 2) {\n return;\n }\n const angles = points.map((p) => ctx.radianToAngle(ctx.getCircleRadian(p, content)));\n angles.sort((a, b) => a - b);\n return angles.map((a, i) => ({\n ...content,\n type: "arc",\n startAngle: a,\n endAngle: i === angles.length - 1 ? angles[0] + 360 : angles[i + 1]\n }));\n },\n render(content, renderCtx) {\n const { options, dashed, time, contents, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n if (dashed) {\n const { points } = getCircleGeometries(content, contents, time);\n return target.renderPolyline(points, options);\n }\n const x = ctx.getTimeExpressionValue(content.xExpression, time, content.x);\n const y = ctx.getTimeExpressionValue(content.yExpression, time, content.y);\n const r = ctx.getTimeExpressionValue(content.rExpression, time, content.r);\n return target.renderCircle(x, y, r, options);\n },\n getOperatorRenderPosition(content) {\n return content;\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const x = content.x;\n const y = content.y;\n const { quadrantPoints } = getCircleGeometries(content, contents);\n const updateEdges = (c, { cursor, scale }) => {\n if (!isCircleContent(c)) {\n return;\n }\n c.r = ctx.getTwoPointsDistance(cursor, c);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n };\n return {\n editPoints: [\n {\n x,\n y,\n cursor: "move",\n type: "move",\n update(c, { cursor, start, scale }) {\n if (!isCircleContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n {\n ...quadrantPoints[0],\n cursor: "ew-resize",\n update: updateEdges\n },\n {\n ...quadrantPoints[1],\n cursor: "ns-resize",\n update: updateEdges\n },\n {\n ...quadrantPoints[2],\n cursor: "ew-resize",\n update: updateEdges\n },\n {\n ...quadrantPoints[3],\n cursor: "ns-resize",\n update: updateEdges\n }\n ],\n angleSnapStartPoint: content\n };\n });\n },\n getSnapPoints(content, contents) {\n const { quadrantPoints } = getCircleGeometries(content, contents);\n return ctx.getSnapPointsFromCache(content, () => [\n { x: content.x, y: content.y, type: "center" },\n ...quadrantPoints.map((p) => ({ ...p, type: "endpoint" }))\n ]);\n },\n getGeometries: getCircleGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isCircleContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.y = v;\n }\n }) }),\n r: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.r, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.r = v;\n }\n }) }),\n xExpression: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.xExpression !== void 0, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.xExpression = v ? "" : void 0;\n }\n }) }),\n content.xExpression !== void 0 ? /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.xExpression, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.xExpression = v;\n }\n }) }) : void 0\n ],\n yExpression: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.yExpression !== void 0, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.yExpression = v ? "" : void 0;\n }\n }) }),\n content.yExpression !== void 0 ? /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.yExpression, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.yExpression = v;\n }\n }) }) : void 0\n ],\n rExpression: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.rExpression !== void 0, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.rExpression = v ? "" : void 0;\n }\n }) }),\n content.rExpression !== void 0 ? /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.rExpression, setValue: (v) => update((c) => {\n if (isCircleContent(c)) {\n c.rExpression = v;\n }\n }) }) : void 0\n ],\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, CircleContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point) => ctx.getTwoPointsDistance(content, point) < content.r,\n getArea: (content) => Math.PI * content.r ** 2\n },\n {\n type: "arc",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n ...ctx.angleDeltaModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle) {\n ctx.rotateArc(content, center, angle);\n },\n scale(content, center, sx, sy) {\n if (sx !== sy && !ctx.isZero(sx + sy)) {\n const ellipse = {\n ...content,\n type: "ellipse arc",\n cx: content.x,\n cy: content.y,\n rx: content.r,\n ry: content.r\n };\n ctx.scaleEllipseArc(ellipse, center, sx, sy);\n return ellipse;\n }\n ctx.scalePoint(content, center, sx, sy);\n content.r *= Math.abs(sx);\n return;\n },\n skew(content, center, sx, sy) {\n const ellipse = {\n ...content,\n type: "ellipse arc",\n cx: content.x,\n cy: content.y,\n rx: content.r,\n ry: content.r\n };\n ctx.skewEllipseArc(ellipse, center, sx, sy);\n return ellipse;\n },\n mirror(content, line, angle) {\n ctx.mirrorArc(content, line, angle);\n },\n offset(content, point, distance) {\n if (!distance) {\n distance = ctx.getTwoNumbersDistance(ctx.getTwoPointsDistance(point, content), content.r);\n }\n return ctx.getParallelArcsByDistance(content, distance)[ctx.pointSideToIndex(ctx.getPointSideOfArc(point, content))];\n },\n break(content, points) {\n if (points.length === 0) {\n return;\n }\n const angles = points.map((p) => ctx.normalizeAngleInRange(ctx.radianToAngle(ctx.getCircleRadian(p, content)), content));\n angles.sort((a, b) => a - b);\n const result = [];\n if (!ctx.isSameNumber(angles[0], content.startAngle)) {\n result.push({\n ...content,\n type: "arc",\n startAngle: content.startAngle,\n endAngle: angles[0]\n });\n }\n angles.forEach((a, i) => {\n if (i === angles.length - 1) {\n if (!ctx.isSameNumber(a, content.endAngle)) {\n result.push({\n ...content,\n type: "arc",\n startAngle: a,\n endAngle: content.endAngle\n });\n }\n } else {\n result.push({\n ...content,\n type: "arc",\n startAngle: a,\n endAngle: angles[i + 1]\n });\n }\n });\n return result.length > 1 ? result : void 0;\n },\n join(content, target) {\n if (isArcContent(target)) {\n return ctx.mergeArc(content, target);\n }\n if (isLineContent(target) || isPolyLineContent(target)) {\n const newLines = ctx.mergeGeometryLines([{ type: "arc", curve: content }], Array.from(ctx.iteratePolylineLines(target.points)));\n if (newLines) {\n return ctx.geometryLinesToPline(newLines);\n }\n }\n return;\n },\n extend(content, point) {\n const angle = ctx.radianToAngle(ctx.getCircleRadian(point, content));\n const endAngle = ctx.getFormattedEndAngle({ startAngle: content.startAngle, endAngle: angle });\n const startAngle = ctx.getFormattedStartAngle({ startAngle: angle, endAngle: content.endAngle });\n const angle1 = Math.abs(endAngle - content.startAngle);\n const angle2 = Math.abs(content.endAngle - startAngle);\n if (angle1 < angle2) {\n content.endAngle = endAngle;\n } else {\n content.startAngle = startAngle;\n }\n },\n render(content, renderCtx) {\n const { options, dashed, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n if (dashed) {\n return target.renderPolyline(getCircleGeometries(content, renderCtx.contents).points, options);\n }\n return target.renderArc(content.x, content.y, content.r, content.startAngle, content.endAngle, { ...options, counterclockwise: content.counterclockwise });\n },\n renderIfSelected(content, { color, target, strokeWidth, contents }) {\n const { points } = getArcGeometries({ ...content, startAngle: content.endAngle, endAngle: content.startAngle }, contents);\n return target.renderPolyline(points, { strokeColor: color, dashArray: [4], strokeWidth });\n },\n getOperatorRenderPosition(content, contents) {\n const { points } = getArcGeometries(content, contents);\n return points[0];\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { start, end, middle } = getArcGeometries(content, contents);\n return {\n editPoints: [\n {\n x: content.x,\n y: content.y,\n cursor: "move",\n type: "move",\n update(c, { cursor, start: start2, scale }) {\n if (!isArcContent(c)) {\n return;\n }\n c.x += cursor.x - start2.x;\n c.y += cursor.y - start2.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n {\n ...start,\n cursor: ctx.getResizeCursor(content.startAngle, "top"),\n update(c, { cursor, scale }) {\n if (!isArcContent(c)) {\n return;\n }\n c.startAngle = ctx.radianToAngle(ctx.getCircleRadian(cursor, c));\n c.r = ctx.getTwoPointsDistance(cursor, c);\n ctx.normalizeAngleRange(c);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n {\n ...end,\n cursor: ctx.getResizeCursor(content.endAngle, "top"),\n update(c, { cursor, scale }) {\n if (!isArcContent(c)) {\n return;\n }\n c.endAngle = ctx.radianToAngle(ctx.getCircleRadian(cursor, c));\n c.r = ctx.getTwoPointsDistance(cursor, c);\n ctx.normalizeAngleRange(c);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n {\n ...middle,\n cursor: ctx.getResizeCursor((content.startAngle + content.endAngle) / 2, "right"),\n update(c, { cursor, scale }) {\n if (!isArcContent(c)) {\n return;\n }\n c.r = ctx.getTwoPointsDistance(cursor, c);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n }\n ],\n angleSnapStartPoint: content\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { start, end, middle } = getArcGeometries(content, contents);\n return [\n { x: content.x, y: content.y, type: "center" },\n { ...start, type: "endpoint" },\n { ...end, type: "endpoint" },\n { ...middle, type: "midpoint" }\n ];\n });\n },\n getGeometries: getArcGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isArcContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isArcContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isArcContent(c)) {\n c.y = v;\n }\n }) }),\n r: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.r, setValue: (v) => update((c) => {\n if (isArcContent(c)) {\n c.r = v;\n }\n }) }),\n startAngle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.startAngle, setValue: (v) => update((c) => {\n if (isArcContent(c)) {\n c.startAngle = v;\n }\n }) }),\n endAngle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.endAngle, setValue: (v) => update((c) => {\n if (isArcContent(c)) {\n c.endAngle = v;\n }\n }) }),\n counterclockwise: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.counterclockwise === true, setValue: (v) => update((c) => {\n if (isArcContent(c)) {\n c.counterclockwise = v ? true : void 0;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents),\n ...ctx.getAngleDeltaContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, ArcContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n getArea: (content) => {\n const radian = ctx.angleToRadian(content.endAngle - content.startAngle);\n return content.r ** 2 * (radian - Math.sin(radian)) / 2;\n },\n reverse: (content) => ctx.reverseArc(content)\n }\n ];\n}\nfunction isCircleContent(content) {\n return content.type === "circle";\n}\nfunction isArcContent(content) {\n return content.type === "arc";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const circleIcon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "44", cy: "48", r: "39", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "44,48 66,15", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }));\n const icon2 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "44", cy: "48", r: "39", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "18", cy: "20", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }), /* @__PURE__ */ React.createElement("circle", { cx: "72", cy: "76", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }));\n const icon3 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "44", cy: "48", r: "39", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "18", cy: "20", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }), /* @__PURE__ */ React.createElement("circle", { cx: "36", cy: "87", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }), /* @__PURE__ */ React.createElement("circle", { cx: "80", cy: "28", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }));\n const circleIcon4 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "44", cy: "48", r: "39", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "25,82 66,15", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }));\n const arcIcon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("path", { d: "M 31 80 A 35 35 0 1 0 25 24", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }));\n return [\n {\n name: "create circle",\n type: [\n { name: "2 points", icon: icon2 },\n { name: "3 points", icon: icon3 },\n { name: "center radius", hotkey: "C", icon: circleIcon },\n { name: "center diameter", icon: circleIcon4 }\n ],\n useCommand({ onEnd, scale, type, strokeStyleId, fillStyleId }) {\n const { circle, onClick, onMove, input, startPosition, middlePosition, cursorPosition, reset } = ctx.useCircleClickCreate(\n type === "2 points" || type === "3 points" || type === "center diameter" || type === "center radius" ? type : void 0,\n (c) => onEnd({\n updateContents: (contents) => contents.push({ ...c, strokeStyleId, fillStyleId, type: "circle" })\n })\n );\n const assistentContents = [];\n if (startPosition && cursorPosition) {\n if (middlePosition) {\n assistentContents.push({ type: "polygon", points: [startPosition, middlePosition, cursorPosition], dashArray: [4 / scale] });\n } else {\n assistentContents.push(\n { type: "line", points: [startPosition, cursorPosition], dashArray: [4 / scale] },\n ...ctx.getAssistentText(\n ctx.getTwoPointsDistance(startPosition, cursorPosition).toFixed(2),\n 16 / scale,\n (startPosition.x + cursorPosition.x) / 2 - 20,\n (startPosition.y + cursorPosition.y) / 2 + 4\n )\n );\n }\n }\n if (circle) {\n assistentContents.push({ ...circle, strokeStyleId, fillStyleId, type: "circle" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition: middlePosition != null ? middlePosition : startPosition,\n reset\n };\n },\n selectCount: 0\n },\n {\n name: "create arc",\n useCommand({ onEnd, type, scale, strokeStyleId, fillStyleId }) {\n const { circle, arc, onClick, onMove, input, startPosition, middlePosition, cursorPosition, reset } = ctx.useCircleArcClickCreate(\n type === "create arc" ? "center radius" : void 0,\n (c) => onEnd({\n updateContents: (contents) => contents.push({ ...c, strokeStyleId, fillStyleId, type: "arc" })\n })\n );\n const assistentContents = [];\n if (startPosition && cursorPosition) {\n if (middlePosition) {\n assistentContents.push({ type: "polygon", points: [startPosition, middlePosition, cursorPosition], dashArray: [4 / scale] });\n } else {\n assistentContents.push(\n { type: "line", points: [startPosition, cursorPosition], dashArray: [4 / scale] },\n ...ctx.getAssistentText(\n ctx.getTwoPointsDistance(startPosition, cursorPosition).toFixed(2),\n 16 / scale,\n (startPosition.x + cursorPosition.x) / 2 - 20,\n (startPosition.y + cursorPosition.y) / 2 + 4\n )\n );\n }\n }\n if (arc) {\n assistentContents.push({ ...arc, dashArray: [4 / scale], type: "circle" });\n if (arc.startAngle !== arc.endAngle) {\n assistentContents.push(\n {\n type: "line",\n points: [\n {\n x: arc.x + arc.r * Math.cos(ctx.angleToRadian(arc.startAngle)),\n y: arc.y + arc.r * Math.sin(ctx.angleToRadian(arc.startAngle))\n },\n {\n x: arc.x,\n y: arc.y\n }\n ],\n dashArray: [4 / scale]\n },\n {\n type: "line",\n points: [\n {\n x: arc.x,\n y: arc.y\n },\n {\n x: arc.x + arc.r * Math.cos(ctx.angleToRadian(arc.endAngle)),\n y: arc.y + arc.r * Math.sin(ctx.angleToRadian(arc.endAngle))\n }\n ],\n dashArray: [4 / scale]\n }\n );\n }\n if (cursorPosition) {\n assistentContents.push({ type: "line", points: [arc, cursorPosition], dashArray: [4 / scale] });\n }\n }\n if (circle) {\n assistentContents.push({ ...circle, dashArray: [4 / scale], type: "circle" });\n if (cursorPosition) {\n assistentContents.push({ type: "line", points: [circle, cursorPosition], dashArray: [4 / scale] });\n }\n }\n if (arc && arc.startAngle !== arc.endAngle) {\n assistentContents.push({ ...arc, strokeStyleId, fillStyleId, type: "arc" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition: middlePosition != null ? middlePosition : startPosition,\n reset\n };\n },\n selectCount: 0,\n hotkey: "A",\n icon: arcIcon\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isArcContent,\n isCircleContent\n};\n','// dev/cad-editor/plugins/clip.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("mask", { id: "0" }, /* @__PURE__ */ React.createElement("path", { d: "M 1 1 L 1 100 L 103 100 L 103 1", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "white", stroke: "currentColor", fillRule: "evenodd" }), /* @__PURE__ */ React.createElement("path", { d: "M 91 70 L 91 73 L 91 75 L 90 78 L 90 80 L 89 82 L 88 84 L 86 86 L 85 88 L 83 90 L 81 91 L 79 93 L 77 94 L 75 95 L 73 96 L 71 97 L 68 97 L 66 98 L 64 98 L 61 98 L 59 97 L 57 97 L 54 96 L 52 95 L 50 94 L 48 93 L 46 91 L 44 90 L 43 88 L 41 86 L 40 84 L 39 82 L 38 80 L 37 78 L 37 75 L 36 73 L 36 70 L 36 68 L 37 66 L 37 63 L 38 61 L 39 59 L 40 57 L 41 55 L 43 53 L 44 51 L 46 49 L 48 48 L 50 47 L 52 46 L 54 45 L 57 44 L 59 43 L 61 43 L 64 43 L 66 43 L 68 43 L 71 44 L 73 45 L 75 46 L 77 47 L 79 48 L 81 49 L 83 51 L 85 53 L 86 55 L 88 57 L 89 59 L 90 61 L 90 63 L 91 66 L 91 68 L 91 70", fill: "black" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#0)" }, /* @__PURE__ */ React.createElement("polygon", { points: "83,99 77,64 103,38 67,33 51,1 35,33 1,39 25,64 19,100 51,83", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "currentColor", stroke: "currentColor" })));\n return {\n name: "clip",\n icon,\n useCommand({ type, onEnd, acquireContent, selected, contents }) {\n const target = React.useRef();\n const border = React.useRef();\n const reset = () => {\n target.current = void 0;\n border.current = void 0;\n };\n React.useEffect(() => {\n if (!type)\n return;\n if (!target.current) {\n target.current = selected[0].path;\n acquireContent(\n {\n count: 1,\n selectable: (v) => {\n var _a, _b;\n const content = ctx.getContentByIndex(contents, v);\n if (!content)\n return false;\n const geometries = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content, contents);\n if (!geometries)\n return false;\n return geometries.lines.length > 0;\n }\n },\n (r) => {\n border.current = ctx.getRefPart(r[0], contents, (c) => c !== selected[0].content);\n }\n );\n } else if (border.current) {\n onEnd({\n updateContents(contents2) {\n if (target.current) {\n const content = contents2[target.current[0]];\n if (content && ctx.isClipContent(content) && border.current) {\n content.clip = {\n border: border.current\n };\n }\n }\n }\n });\n reset();\n }\n }, [type]);\n return {\n onStart() {\n },\n reset\n };\n },\n selectCount: 1,\n contentSelectable(content) {\n return ctx.isClipContent(content) && !content.readonly;\n }\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/clone.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "8", y: "27", width: "62", height: "65", strokeWidth: "3", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "30", y: "8", width: "62", height: "65", strokeWidth: "3", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "clone",\n useCommand({ onEnd, transform, type, scale }) {\n const { offset, onStart, mask, startPosition, resetDragMove } = ctx.useDragMove(\n () => onEnd({}),\n {\n repeatedly: true,\n transform,\n ignoreLeavingEvent: true\n }\n );\n let message = "";\n if (type) {\n message = startPosition ? "specify end point" : "specify start point";\n }\n const { input, setInputPosition, resetInput } = ctx.useCursorInput(message);\n const reset = () => {\n resetDragMove();\n resetInput();\n };\n return {\n onStart: (s) => onStart(s),\n mask,\n reset,\n input,\n onMove(_, p) {\n setInputPosition(p);\n },\n updateSelectedContent(content) {\n if (startPosition && (offset.x !== 0 || offset.y !== 0)) {\n return {\n newContents: [\n ctx.produce(content, (d) => {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(d)) == null ? void 0 : _a.move) == null ? void 0 : _b.call(_a, d, offset);\n })\n ]\n };\n }\n return {};\n },\n assistentContents: startPosition && (offset.x !== 0 || offset.y !== 0) ? [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [startPosition, { x: startPosition.x + offset.x, y: startPosition.y + offset.y }]\n }\n ] : void 0\n };\n },\n contentSelectable(content) {\n var _a;\n return ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.move) !== void 0;\n },\n hotkey: "CO",\n icon,\n repeatedly: true\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\nfunction isPolyLineContent(content) {\n return content.type === "polyline";\n}\n\n// dev/cad-editor/plugins/ellipse.plugin.tsx\nfunction isEllipseArcContent(content) {\n return content.type === "ellipse arc";\n}\n\n// dev/cad-editor/plugins/combined-path.plugin.tsx\nfunction getModel(ctx) {\n const CombinedPathContent = ctx.and(ctx.BaseContent("combined path"), ctx.ContainerFields, ctx.StrokeFields, ctx.FillFields);\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const getGeometries = (content, contents) => {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n const lines = [];\n const result = [];\n const boundings = [];\n content.contents.forEach((c) => {\n var _a, _b, _c, _d;\n if (!c) {\n return;\n }\n const r = (_b = (_a = ctx.getContentModel(c)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, c, contents);\n if (r) {\n lines.push(...r.lines);\n if (r.bounding) {\n boundings.push(r.bounding.start, r.bounding.end);\n }\n }\n if (isLineContent(c) || isPolyLineContent(c)) {\n result.push({ points: c.points });\n } else if (isArcContent(c)) {\n result.push({ points: ctx.arcToPolyline(c, (_c = c.angleDelta) != null ? _c : ctx.defaultAngleDelta) });\n } else if (isEllipseArcContent(c)) {\n result.push({ points: ctx.ellipseArcToPolyline(c, (_d = c.angleDelta) != null ? _d : ctx.defaultAngleDelta) });\n }\n });\n ctx.mergePolylinesToPolyline(result);\n const renderingLines = result.map((m) => m.points);\n const points = renderingLines.flat();\n return {\n lines,\n bounding: ctx.getPointsBounding(boundings),\n renderingLines,\n regions: ctx.hasFill(content) ? [{\n lines,\n points\n }] : void 0\n };\n });\n };\n return {\n type: "combined path",\n ...ctx.containerModel,\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move: ctx.getContainerMove,\n rotate: ctx.getContainerRotate,\n scale: ctx.getContainerScale,\n explode: ctx.getContainerExplode,\n mirror: ctx.getContainerMirror,\n render(content, renderCtx) {\n const geometries = getGeometries(content, renderCtx.contents);\n const { options } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n return renderCtx.target.renderGroup(geometries.renderingLines.map((line) => {\n return renderCtx.target.renderPolyline(line, options);\n }));\n },\n renderIfSelected: (content, renderCtx) => ctx.getContainerRenderIfSelected(content, renderCtx, [content], getRefIds),\n getSnapPoints: ctx.getContainerSnapPoints,\n getGeometries,\n propertyPanel(content, update, contents) {\n return {\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, CombinedPathContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds\n };\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents) && (isLineContent(content) || isArcContent(content) || isPolyLineContent(content) || isEllipseArcContent(content));\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "36,93 40,92 43,90 47,88 51,86 55,84 58,81 62,79 65,76 69,73 72,70 75,67 78,64 80,60 83,57 85,54 86,51 88,47 89,44 90,41 90,38 91,36 90,33 90,31 89,28 88,26 87,25 85,23 83,22 81,21 78,20 76,20 73,20 69,20 66,20 63,21 59,22 55,23 52,25 48,27 44,29 40,31 37,34 33,36 30,39 26,42 23,45 20,48 17,51 15,55 12,58 10,61 9,64 36,93", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "create combined path",\n execute({ contents, selected, strokeStyleId, fillStyleId }) {\n const newContent = {\n type: "combined path",\n strokeStyleId,\n fillStyleId,\n contents: contents.filter((c, i) => c && ctx.isSelected([i], selected) && contentSelectable(c, contents))\n };\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n contents.push(newContent);\n },\n contentSelectable,\n icon\n };\n}\nexport {\n getCommand,\n getModel\n};\n','// dev/cad-editor/plugins/compress.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "10", y: "44", width: "81", height: "20", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "9", y: "69", width: "81", height: "20", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "42,6 57,6 57,31 73,31 51,44 27,32 42,32", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "compress",\n execute({ contents }) {\n var _a, _b;\n const newIndexes = [];\n let validContentCount = 0;\n const invalidContentsIndex = [];\n const contentIsValid = (d) => {\n var _a2, _b2;\n return !!d && ((_b2 = (_a2 = ctx.getContentModel(d)) == null ? void 0 : _a2.isValid(d)) != null ? _b2 : true) === true;\n };\n contents.forEach((d, i) => {\n if (contentIsValid(d)) {\n newIndexes.push(validContentCount);\n if (ctx.isContainerContent(d)) {\n d.contents = d.contents.filter((c) => contentIsValid(c));\n }\n validContentCount++;\n } else {\n newIndexes.push(void 0);\n invalidContentsIndex.unshift(i);\n }\n });\n invalidContentsIndex.forEach((i) => {\n contents.splice(i, 1);\n });\n for (const content of ctx.iterateAllContents(contents)) {\n (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.updateRefId) == null ? void 0 : _b.call(_a, content, (refId) => typeof refId === "number" ? newIndexes[refId] : void 0);\n }\n ctx.contentIndexCache.clear();\n },\n selectCount: 0,\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/coordinate-axis.plugin.tsx\nfunction getModel(ctx) {\n const CoordinateAxisContent = ctx.and(ctx.BaseContent("coordinate axis"), ctx.StrokeFields, ctx.ArrowFields, ctx.Position, ctx.Bounding, {\n flipY: ctx.optional(ctx.boolean)\n });\n const getRefIds = (content) => ctx.getStrokeRefIds(content);\n function getGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n const yMin = content.flipY ? -content.yMax : content.yMin;\n const yMax = content.flipY ? -content.yMin : content.yMax;\n const lines = [\n [\n { x: content.x + content.xMin, y: content.y },\n { x: content.x + content.xMax, y: content.y }\n ],\n [\n { x: content.x, y: content.y + yMin },\n { x: content.x, y: content.y + yMax }\n ]\n ];\n const areas = [];\n const renderingLines = [];\n lines.forEach(([p1, p2], i) => {\n if (content.flipY && i === 1) {\n [p2, p1] = [p1, p2];\n }\n const { arrowPoints, endPoint } = ctx.getArrowPoints(p1, p2, content);\n areas.push(arrowPoints);\n lines[i][content.flipY && i === 1 ? 0 : 1] = endPoint;\n renderingLines.push(...ctx.dashedPolylineToLines(lines[i], content.dashArray));\n });\n return {\n lines,\n bounding: {\n start: {\n x: content.x + Math.min(0, content.xMin, content.xMax),\n y: content.y + Math.min(0, yMin, yMax)\n },\n end: {\n x: content.x + Math.max(0, content.xMin, content.xMax),\n y: content.y + Math.max(0, yMin, yMax)\n }\n },\n regions: areas.map((e) => ({\n points: e,\n lines: Array.from(ctx.iteratePolygonLines(e))\n })),\n renderingLines\n };\n });\n }\n const React = ctx.React;\n return {\n type: "coordinate axis",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n render(content, renderCtx) {\n const { options, target, fillOptions } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { regions, renderingLines } = getGeometriesFromCache(content, renderCtx.contents);\n const children = [];\n for (const line of renderingLines) {\n children.push(target.renderPolyline(line, options));\n }\n if (regions) {\n for (let i = 0; i < regions.length; i++) {\n children.push(target.renderPolygon(regions[i].points, fillOptions));\n }\n }\n return target.renderGroup(children);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isCoordinateAxisContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.y = v;\n }\n }) }),\n xMin: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.xMin, setValue: (v) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.xMin = v;\n }\n }) }),\n xMax: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.xMax, setValue: (v) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.xMax = v;\n }\n }) }),\n yMin: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.yMin, setValue: (v) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.yMin = v;\n }\n }) }),\n yMax: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.yMax, setValue: (v) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.yMax = v;\n }\n }) }),\n flipY: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.flipY === true, setValue: (v) => update((c) => {\n if (isCoordinateAxisContent(c)) {\n c.flipY = v ? true : void 0;\n }\n }) }),\n ...ctx.getArrowContentPropertyPanel(content, update),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, CoordinateAxisContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds\n };\n}\nfunction isCoordinateAxisContent(content) {\n return content.type === "coordinate axis";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "0,50 95,50", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "50,5 50,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "100,50 82,58 82,42", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "50,0 58,18 42,18", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "create coordinate axis",\n selectCount: 0,\n icon,\n useCommand({ onEnd, type }) {\n const [result, setResult] = React.useState();\n const reset = () => {\n setResult(void 0);\n };\n return {\n onStart() {\n if (result) {\n onEnd({\n updateContents: (contents) => {\n if (result) {\n contents.push(result);\n }\n }\n });\n reset();\n }\n },\n onMove(p) {\n if (type) {\n setResult({\n type: "coordinate axis",\n x: p.x,\n y: p.y,\n xMin: -50,\n xMax: 50,\n yMin: -50,\n yMax: 50,\n flipY: true\n });\n }\n },\n assistentContents: result ? [result] : void 0,\n reset\n };\n }\n };\n}\nexport {\n getCommand,\n getModel,\n isCoordinateAxisContent\n};\n','// dev/cad-editor/plugins/copy-paste.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const CopyData = {\n contents: ctx.minItems(0, [{\n id: ctx.number,\n content: ctx.Content\n }]),\n center: ctx.Position\n };\n const cutOrCopyCommand = {\n name: "copy",\n execute({ contents, selected, type }) {\n const ids = [];\n contents.forEach((content, index) => {\n if (content && ctx.isSelected([index], selected)) {\n for (const id of ctx.iterateRefIds([index], contents)) {\n const index2 = ids.indexOf(id);\n if (index2 >= 0) {\n ids.splice(index2, 1);\n }\n ids.push(id);\n }\n }\n });\n if (type === "cut") {\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n }\n const copiedContents = [];\n const boundingPoints = [];\n ids.forEach((id) => {\n var _a, _b;\n const content = contents[id];\n if (content) {\n const geometries = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content, contents);\n if (geometries == null ? void 0 : geometries.bounding) {\n boundingPoints.push(geometries.bounding.start, geometries.bounding.end);\n }\n copiedContents.unshift({\n id,\n content\n });\n }\n });\n const bounding = ctx.getPointsBounding(boundingPoints);\n if (!bounding) {\n return;\n }\n const copyData = {\n contents: copiedContents,\n center: ctx.getTwoPointCenter(bounding.start, bounding.end)\n };\n navigator.clipboard.writeText(JSON.stringify(copyData));\n }\n };\n return [\n cutOrCopyCommand,\n {\n ...cutOrCopyCommand,\n name: "cut"\n },\n {\n name: "paste",\n useCommand({ onEnd, type }) {\n let message = "";\n if (type) {\n message = "specify target point";\n }\n const [copyData, setCopyData] = React.useState();\n const { input, setInputPosition, cursorPosition, setCursorPosition, resetInput } = ctx.useCursorInput(message);\n ctx.useValueChanged(type, () => {\n if (type) {\n (async () => {\n try {\n const text = await navigator.clipboard.readText();\n const copyData2 = JSON.parse(text);\n const r = ctx.validate(copyData2, CopyData);\n if (r === true) {\n setCopyData(copyData2);\n return;\n } else {\n console.info(r);\n reset();\n onEnd();\n }\n } catch (error) {\n console.info(error);\n }\n })();\n }\n });\n const reset = () => {\n setCopyData(void 0);\n resetInput();\n setCursorPosition(void 0);\n setInputPosition(void 0);\n };\n const assistentContents = [];\n if (cursorPosition && copyData) {\n const offset = {\n x: cursorPosition.x - copyData.center.x,\n y: cursorPosition.y - copyData.center.y\n };\n copyData.contents.forEach((c) => {\n assistentContents.push(ctx.produce(c.content, (draft) => {\n var _a, _b;\n const model = ctx.getContentModel(draft);\n (_a = model == null ? void 0 : model.move) == null ? void 0 : _a.call(model, draft, offset);\n (_b = model == null ? void 0 : model.updateRefId) == null ? void 0 : _b.call(model, draft, (d) => {\n if (typeof d === "number") {\n const index = copyData.contents.findIndex((c2) => c2.id === d);\n if (index >= 0 && index < assistentContents.length) {\n return assistentContents[index];\n }\n }\n return void 0;\n });\n }));\n });\n }\n return {\n onStart(p) {\n resetInput();\n onEnd({\n updateContents: (contents) => {\n if (copyData) {\n const offset = {\n x: p.x - copyData.center.x,\n y: p.y - copyData.center.y\n };\n const idMap = {};\n let id = contents.length;\n copyData.contents.forEach((c) => {\n idMap[c.id] = id++;\n });\n copyData.contents.forEach((c) => {\n contents.push(ctx.produce(c.content, (draft) => {\n var _a, _b;\n const model = ctx.getContentModel(draft);\n (_a = model == null ? void 0 : model.move) == null ? void 0 : _a.call(model, draft, offset);\n (_b = model == null ? void 0 : model.updateRefId) == null ? void 0 : _b.call(model, draft, (d) => typeof d === "number" ? idMap[d] : void 0);\n }));\n });\n }\n reset();\n }\n });\n },\n input,\n onMove(p, viewportPosition) {\n setInputPosition(viewportPosition || p);\n if (!type) {\n return;\n }\n setCursorPosition(p);\n },\n assistentContents,\n reset\n };\n },\n selectCount: 0\n }\n ];\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isCircleContent(content) {\n return content.type === "circle";\n}\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/create-tangent-tangent-line.plugin.tsx\nfunction getCommand(ctx) {\n function getTangentTangentLines(content1, content2) {\n const content1IsCircle = isCircleContent(content1) || isArcContent(content1);\n const content2IsCircle = isCircleContent(content2) || isArcContent(content2);\n if (content1IsCircle && content2IsCircle) {\n return ctx.getLinesTangentTo2Circles(content1, content2);\n }\n return [];\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "78", cy: "80", r: "18", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "29", cy: "29", r: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "92,70 51,13", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "create tangent tangent line",\n useCommand({ onEnd, type, selected, scale }) {\n const [candidates, setCandidates] = React.useState();\n const [result, setResult] = React.useState();\n const assistentContents = (candidates || []).map((c) => ({\n points: c,\n type: "line",\n dashArray: c === result ? void 0 : [4 / scale]\n }));\n React.useEffect(() => {\n if (type && !candidates) {\n setCandidates(getTangentTangentLines(selected[0].content, selected[1].content));\n }\n }, [type, selected]);\n const reset = () => {\n setCandidates(void 0);\n setResult(void 0);\n };\n return {\n onStart() {\n if (result) {\n onEnd({\n updateContents: (contents) => {\n contents.push({ type: "line", points: result });\n }\n });\n reset();\n }\n },\n onMove(p) {\n setResult(candidates == null ? void 0 : candidates.find((c) => ctx.getPointAndLineSegmentMinimumDistance(p, ...c) < 5));\n },\n assistentContents,\n reset\n };\n },\n selectCount: 2,\n contentSelectable: (c) => isCircleContent(c) || isArcContent(c),\n selectType: "select part",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isCircleContent(content) {\n return content.type === "circle";\n}\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\n\n// dev/cad-editor/plugins/create-tangent-tangent-radius-circle.plugin.tsx\nfunction getCommand(ctx) {\n function getTangentTangentRadiusCircles(content1, content2, radius) {\n const result = [];\n if (isCircleContent(content1) || isArcContent(content1)) {\n if (isCircleContent(content2) || isArcContent(content2)) {\n result.push(...ctx.getCirclesTangentTo2Circles(content1, content2, radius));\n } else if (isLineContent(content2)) {\n const line2 = ctx.twoPointLineToGeneralFormLine(content2.points[0], content2.points[1]);\n if (!line2)\n return [];\n result.push(...ctx.getCirclesTangentToLineAndCircle(line2, content1, radius));\n }\n } else if (isLineContent(content1)) {\n const line1 = ctx.twoPointLineToGeneralFormLine(content1.points[0], content1.points[1]);\n if (!line1)\n return [];\n if (isCircleContent(content2) || isArcContent(content2)) {\n result.push(...ctx.getCirclesTangentToLineAndCircle(line1, content2, radius));\n } else if (isLineContent(content2)) {\n const line2 = ctx.twoPointLineToGeneralFormLine(content2.points[0], content2.points[1]);\n if (!line2)\n return [];\n result.push(...ctx.getCirclesTangentTo2Lines(line1, line2, radius));\n }\n }\n return result.map((c) => ({ ...c, r: radius }));\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "10,87 89,87", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "17", cy: "40", r: "16", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "60", cy: "57", r: "30", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n const contentSelectable = (c) => isCircleContent(c) || isArcContent(c) || isLineContent(c);\n const command = {\n name: "create tangent tangent radius circle",\n useCommand({ onEnd, type, selected, scale }) {\n const [candidates, setCandidates] = React.useState([]);\n const [result, setResult] = React.useState();\n let message = "";\n if (type) {\n if (candidates.length > 0) {\n message = "select one result";\n } else {\n message = "input radius";\n }\n }\n const assistentContents = candidates.map((c) => ({\n ...c,\n type: "circle",\n dashArray: c === result ? void 0 : [4 / scale]\n }));\n const { input, setInputPosition, setCursorPosition, clearText, resetInput } = ctx.useCursorInput(message, type && candidates.length == 0 ? (e, text) => {\n if (e.key === "Enter") {\n const radius = +text;\n if (!isNaN(radius)) {\n setCandidates(getTangentTangentRadiusCircles(selected[0].content, selected[1].content, radius));\n clearText();\n }\n }\n } : void 0);\n const reset = () => {\n setCandidates([]);\n setResult(void 0);\n clearText();\n resetInput();\n };\n return {\n onStart(p) {\n setCursorPosition(p);\n if (result) {\n onEnd({\n updateContents: (contents) => {\n contents.push({ type: "circle", ...result });\n }\n });\n setCandidates([]);\n }\n },\n input,\n onMove(p, viewportPosition) {\n setCursorPosition(p);\n setInputPosition(viewportPosition || p);\n setResult(candidates.find((c) => ctx.getTwoNumbersDistance(ctx.getTwoPointsDistance(c, p), c.r) < 5));\n },\n assistentContents,\n reset\n };\n },\n selectCount: 2,\n contentSelectable,\n selectType: "select part",\n icon\n };\n return [\n command,\n {\n ...command,\n name: "create tangent tangent radius circle 2",\n useCommand({ onEnd, type, scale, contentVisible, contents, getContentsInRange }) {\n const [first, setFirst] = React.useState();\n const [second, setSecond] = React.useState();\n const [hovering, setHovering] = React.useState();\n const [result, setResult] = React.useState();\n let message = "";\n if (type) {\n if (!first) {\n message = "select first circle, arc or line";\n } else if (!second) {\n message = "select second circle, arc or line";\n } else {\n message = "input radius";\n }\n }\n const assistentContents = [];\n if (result) {\n assistentContents.push({ ...result, type: "circle", dashArray: [4 / scale] });\n }\n const selected = [];\n if (first) {\n selected.push(first.path);\n }\n if (second) {\n selected.push(second.path);\n }\n const getCandidate = (radius) => {\n if (!first || !second)\n return;\n const candidates = getTangentTangentRadiusCircles(first.content, second.content, radius);\n const candidate = ctx.minimumBy(candidates.map((c) => ({\n content: c,\n distance: ctx.getTwoPointsDistanceSquare(c, first.point) + ctx.getTwoPointsDistanceSquare(c, second.point)\n })), (c) => c.distance);\n return candidate == null ? void 0 : candidate.content;\n };\n const { input, setInputPosition, setCursorPosition, clearText, resetInput } = ctx.useCursorInput(message, type ? (e, text) => {\n if (e.key === "Enter") {\n const radius = +text;\n if (!isNaN(radius) && first && second) {\n const candidate = getCandidate(radius);\n if (!candidate)\n return;\n onEnd({\n updateContents: (contents2) => {\n contents2.push({ type: "circle", ...candidate });\n }\n });\n reset();\n }\n }\n } : void 0);\n const reset = () => {\n setFirst(void 0);\n setSecond(void 0);\n setHovering(void 0);\n setResult(void 0);\n clearText();\n resetInput();\n };\n const selectContent = (p) => {\n const indexes = getContentsInRange({ start: p, end: p }).filter((c) => !!c).map((c) => ctx.getContentIndex(c, contents));\n const contentPath = ctx.getContentByClickPosition(contents, p, (c) => {\n const content = ctx.getContentByIndex(contents, c);\n return !!content && contentSelectable(content);\n }, ctx.getContentModel, true, contentVisible, indexes, 3 / scale);\n if (contentPath) {\n const content = ctx.getContentByIndex(contents, contentPath);\n if (content) {\n return { content, point: p, path: contentPath };\n }\n }\n return;\n };\n return {\n onStart(p) {\n if (!first) {\n setFirst(hovering);\n setHovering(void 0);\n return;\n } else if (!second) {\n setSecond(hovering);\n setHovering(void 0);\n return;\n }\n setCursorPosition(p);\n if (result) {\n onEnd({\n updateContents: (contents2) => {\n contents2.push({ type: "circle", ...result });\n }\n });\n reset();\n }\n },\n input,\n onMove(p, viewportPosition) {\n setCursorPosition(p);\n setInputPosition(viewportPosition || p);\n if (!first) {\n setHovering(selectContent(p));\n return;\n } else if (!second) {\n setHovering(selectContent(p));\n return;\n }\n setResult(getCandidate(ctx.getTwoPointsDistance(second.point, p)));\n },\n assistentContents,\n selected,\n hovering: hovering ? [hovering.path] : void 0,\n reset\n };\n },\n selectCount: 0\n }\n ];\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isCircleContent(content) {\n return content.type === "circle";\n}\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\n\n// dev/cad-editor/plugins/create-tangent-tangent-tangent-circle.plugin.tsx\nfunction getCommand(ctx) {\n function getTangentTangentTangentCircles(content1, content2, content3) {\n const result = [];\n if (isLineContent(content1)) {\n const line1 = ctx.twoPointLineToGeneralFormLine(content1.points[0], content1.points[1]);\n if (!line1)\n return [];\n if (isLineContent(content2)) {\n const line2 = ctx.twoPointLineToGeneralFormLine(content2.points[0], content2.points[1]);\n if (!line2)\n return [];\n if (isLineContent(content3)) {\n const line3 = ctx.twoPointLineToGeneralFormLine(content3.points[0], content3.points[1]);\n if (!line3)\n return [];\n result.push(...ctx.getCirclesTangentTo3Lines(line1, line2, line3));\n } else if (isCircleContent(content3) || isArcContent(content3)) {\n result.push(...ctx.getCirclesTangentToLineLineCircle(line1, line2, content3));\n }\n } else if (isCircleContent(content2) || isArcContent(content2)) {\n if (isLineContent(content3)) {\n const line3 = ctx.twoPointLineToGeneralFormLine(content3.points[0], content3.points[1]);\n if (!line3)\n return [];\n result.push(...ctx.getCirclesTangentToLineLineCircle(line1, line3, content2));\n } else if (isCircleContent(content3) || isArcContent(content3)) {\n result.push(...ctx.getCirclesTangentToLineCircleCircle(line1, content2, content3));\n }\n }\n } else if (isCircleContent(content1) || isArcContent(content1)) {\n if (isLineContent(content2)) {\n const line2 = ctx.twoPointLineToGeneralFormLine(content2.points[0], content2.points[1]);\n if (!line2)\n return [];\n if (isLineContent(content3)) {\n const line3 = ctx.twoPointLineToGeneralFormLine(content3.points[0], content3.points[1]);\n if (!line3)\n return [];\n result.push(...ctx.getCirclesTangentToLineLineCircle(line2, line3, content1));\n } else if (isCircleContent(content3) || isArcContent(content3)) {\n result.push(...ctx.getCirclesTangentToLineCircleCircle(line2, content1, content3));\n }\n } else if (isCircleContent(content2) || isArcContent(content2)) {\n if (isLineContent(content3)) {\n const line3 = ctx.twoPointLineToGeneralFormLine(content3.points[0], content3.points[1]);\n if (!line3)\n return [];\n result.push(...ctx.getCirclesTangentToLineCircleCircle(line3, content1, content2));\n } else if (isCircleContent(content3) || isArcContent(content3)) {\n result.push(...ctx.getCirclesTangentTo3Circles(content1, content2, content3));\n }\n }\n }\n return result;\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "0,8 100,8", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "99,19 60,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "0,22 44,98", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "50", cy: "42", r: "34", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "create tangent tangent tangent circle",\n useCommand({ onEnd, type, selected, scale }) {\n const [candidates, setCandidates] = React.useState();\n const [result, setResult] = React.useState();\n const assistentContents = (candidates || []).map((c) => ({\n ...c,\n type: "circle",\n dashArray: c === result ? void 0 : [4 / scale]\n }));\n const reset = () => {\n setCandidates(void 0);\n setResult(void 0);\n };\n React.useEffect(() => {\n if (type && !candidates) {\n setCandidates(getTangentTangentTangentCircles(selected[0].content, selected[1].content, selected[2].content));\n }\n }, [type, selected]);\n return {\n onStart() {\n if (result) {\n onEnd({\n updateContents: (contents) => {\n contents.push({ type: "circle", ...result });\n }\n });\n setCandidates([]);\n }\n },\n onMove(p) {\n setResult(candidates == null ? void 0 : candidates.find((c) => ctx.getTwoNumbersDistance(ctx.getTwoPointsDistance(c, p), c.r) < 5));\n },\n assistentContents,\n reset\n };\n },\n selectCount: 3,\n contentSelectable: (c) => isLineContent(c) || isCircleContent(c) || isArcContent(c),\n selectType: "select part",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/delete.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "17,21 80,84", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "77,23 19,81", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "delete",\n execute({ contents, selected }) {\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n },\n contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n },\n hotkey: "E",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/diamond.plugin.tsx\nfunction getModel(ctx) {\n const DiamondContent = ctx.and(ctx.BaseContent("diamond"), ctx.StrokeFields, ctx.FillFields, ctx.Region);\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n const points = [\n { x: content.x, y: content.y - content.height / 2 },\n { x: content.x + content.width / 2, y: content.y },\n { x: content.x, y: content.y + content.height / 2 },\n { x: content.x - content.width / 2, y: content.y }\n ];\n const lines = Array.from(ctx.iteratePolygonLines(points));\n return {\n lines,\n points,\n bounding: ctx.getPointsBounding(points),\n renderingLines: ctx.dashedPolylineToLines(ctx.polygonToPolyline(points), content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n return {\n type: "diamond",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content, center, sx, sy);\n content.width *= sx;\n content.height *= sy;\n },\n skew(content, center, sx, sy, contents) {\n const points = ctx.produce(getGeometries(content, contents).points, (draft) => {\n for (const p of draft) {\n ctx.skewPoint(p, center, sx, sy);\n }\n });\n return { ...content, points, type: "polygon" };\n },\n explode(content, contents) {\n const { lines } = getGeometries(content, contents);\n return lines.map((line) => ({ type: "line", points: line }));\n },\n offset(content, point, distance, contents) {\n var _a;\n if (!distance) {\n distance = Math.min(...getGeometries(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= ((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point, contents)) ? -2 : 2;\n const scale = content.width / content.height;\n const height = distance / Math.sin(Math.atan(scale));\n const width = height * scale;\n return ctx.produce(content, (d) => {\n d.width += width;\n d.height += height;\n });\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getGeometries(content, renderCtx.contents);\n return target.renderPolygon(points, options);\n },\n getOperatorRenderPosition(content, contents) {\n const { points } = getGeometries(content, contents);\n return points[0];\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points } = getGeometries(content, contents);\n return {\n editPoints: [\n { x: content.x, y: content.y, direction: "center" },\n { ...points[0], direction: "top" },\n { ...points[1], direction: "right" },\n { ...points[2], direction: "bottom" },\n { ...points[3], direction: "left" }\n ].map((p) => ({\n x: p.x,\n y: p.y,\n cursor: ctx.getResizeCursor(0, p.direction),\n update(c, { cursor, start, scale }) {\n if (!isDiamondContent(c)) {\n return;\n }\n const offset = ctx.getResizeOffset(start, cursor, p.direction);\n if (!offset) {\n return;\n }\n c.x += offset.x + offset.width / 2;\n c.y += offset.y + offset.height / 2;\n c.width += offset.width;\n c.height += offset.height;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }))\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points, lines } = getGeometries(content, contents);\n return [\n { x: content.x, y: content.y, type: "center" },\n ...points.map((p) => ({ ...p, type: "endpoint" })),\n ...lines.map(([start, end]) => ({\n x: (start.x + end.x) / 2,\n y: (start.y + end.y) / 2,\n type: "midpoint"\n }))\n ];\n });\n },\n getGeometries,\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isDiamondContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isDiamondContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isDiamondContent(c)) {\n c.y = v;\n }\n }) }),\n width: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.width, setValue: (v) => update((c) => {\n if (isDiamondContent(c)) {\n c.width = v;\n }\n }) }),\n height: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.height, setValue: (v) => update((c) => {\n if (isDiamondContent(c)) {\n c.height = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, DiamondContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point, contents) => ctx.pointInPolygon(point, getGeometries(content, contents).points)\n };\n}\nfunction isDiamondContent(content) {\n return content.type === "diamond";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "52,5 97,50 52,96 6,50", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create diamond",\n icon,\n useCommand({ onEnd, type, strokeStyleId, fillStyleId, scale }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create diamond",\n (c) => onEnd({\n updateContents: (contents) => contents.push({\n type: "diamond",\n x: (c[0].x + c[1].x) / 2,\n y: (c[0].y + c[1].y) / 2,\n width: Math.abs(c[0].x - c[1].x),\n height: Math.abs(c[0].y - c[1].y),\n strokeStyleId,\n fillStyleId\n })\n }),\n {\n once: true\n }\n );\n const assistentContents = [];\n if (line) {\n assistentContents.push({\n type: "diamond",\n x: (line[0].x + line[1].x) / 2,\n y: (line[0].y + line[1].y) / 2,\n width: Math.abs(line[0].x - line[1].x),\n height: Math.abs(line[0].y - line[1].y),\n strokeStyleId,\n fillStyleId\n });\n assistentContents.push({\n type: "rect",\n x: (line[0].x + line[1].x) / 2,\n y: (line[0].y + line[1].y) / 2,\n width: Math.abs(line[0].x - line[1].x),\n height: Math.abs(line[0].y - line[1].y),\n angle: 0,\n dashArray: [4 / scale]\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isDiamondContent\n};\n','// dev/cad-editor/plugins/edit-container.plugin.tsx\nfunction getCommand(ctx) {\n function contentSelectable(c) {\n return !c.readonly && ctx.isContainerContent(c);\n }\n const React = ctx.React;\n const startIcon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "42,73 42,74 41,75 41,77 41,78 40,79 39,81 39,82 38,83 37,84 36,85 35,86 34,86 32,87 31,88 30,88 28,88 27,89 26,89 24,89 23,88 21,88 20,88 19,87 17,86 16,86 15,85 14,84 13,83 12,82 12,81 11,79 10,78 10,77 10,75 9,74 9,73 9,71 10,70 10,68 10,67 11,66 12,64 12,63 13,62 14,61 15,60 16,59 17,59 19,58 20,57 21,57 23,57 24,56 25,56 27,56 28,57 30,57 31,57 32,58 34,59 35,59 36,60 37,61 38,62 39,63 39,64 40,66 41,67 41,68 41,70 42,71 42,73", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "12,10 76,10 76,45 12,45", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "70,93 93,52 46,52", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n const startCommand = {\n name: "start edit container",\n icon: startIcon,\n execute({ contents, selected, setEditingContentPath }) {\n contents.forEach((content, index) => {\n var _a, _b;\n if (content && ctx.isSelected([index], selected) && ((_b = (_a = this.contentSelectable) == null ? void 0 : _a.call(this, content, contents)) != null ? _b : true)) {\n setEditingContentPath(contentSelectable(content) ? [index, "contents"] : void 0);\n }\n });\n },\n contentSelectable,\n selectCount: 1\n };\n const cancelIcon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "37,82 32,77 45,64 34,52 22,65 16,58 4,90", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "83,40 78,34 65,46 53,35 67,24 61,17 94,8", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "60,82 66,78 53,64 64,53 76,66 83,60 93,93", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "17,38 22,32 35,45 46,34 34,23 40,16 7,5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n const cancelCommand = {\n name: "cancel edit container",\n execute({ setEditingContentPath }) {\n setEditingContentPath(void 0);\n },\n selectCount: 0,\n icon: cancelIcon\n };\n return [startCommand, cancelCommand];\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/ellipse.plugin.tsx\nfunction getModel(ctx) {\n const EllipseContent = ctx.and(ctx.BaseContent("ellipse"), ctx.StrokeFields, ctx.FillFields, ctx.AngleDeltaFields, ctx.Ellipse);\n const EllipseArcContent = ctx.and(ctx.BaseContent("ellipse arc"), ctx.StrokeFields, ctx.FillFields, ctx.AngleDeltaFields, ctx.EllipseArc);\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const ellipseGeometriesCache = new ctx.WeakmapValuesCache();\n const ellipseArcGeometriesCache = new ctx.WeakmapValuesCache();\n function getEllipseGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ellipseGeometriesCache.get(content, refs, () => {\n var _a;\n const points = ctx.ellipseToPolygon(content, (_a = content.angleDelta) != null ? _a : ctx.defaultAngleDelta);\n const lines = Array.from(ctx.iteratePolygonLines(points));\n const polylinePoints = ctx.polygonToPolyline(points);\n const center = ctx.getEllipseCenter(content);\n const left = ctx.rotatePositionByEllipseCenter({ x: content.cx - content.rx, y: content.cy }, content);\n const right = ctx.rotatePositionByEllipseCenter({ x: content.cx + content.rx, y: content.cy }, content);\n const top = ctx.rotatePositionByEllipseCenter({ x: content.cx, y: content.cy - content.ry }, content);\n const bottom = ctx.rotatePositionByEllipseCenter({ x: content.cx, y: content.cy + content.ry }, content);\n return {\n lines: [{\n type: "ellipse arc",\n curve: ctx.ellipseToEllipseArc(content)\n }],\n points,\n center,\n left,\n right,\n top,\n bottom,\n bounding: ctx.getEllipseBounding(content),\n renderingLines: ctx.dashedPolylineToLines(polylinePoints, content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0\n };\n });\n }\n function getEllipseArcGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ellipseArcGeometriesCache.get(content, refs, () => {\n var _a;\n const points = ctx.ellipseArcToPolyline(content, (_a = content.angleDelta) != null ? _a : ctx.defaultAngleDelta);\n const lines = Array.from(ctx.iteratePolylineLines(points));\n const center = ctx.getEllipseCenter(content);\n const startRadian = ctx.angleToRadian(content.startAngle);\n const endRadian = ctx.angleToRadian(content.endAngle);\n const middleRadian = (startRadian + endRadian) / 2;\n return {\n lines: [{\n type: "ellipse arc",\n curve: content\n }],\n points,\n center,\n start: ctx.getEllipsePointAtRadian(content, startRadian),\n end: ctx.getEllipsePointAtRadian(content, endRadian),\n middle: ctx.getEllipsePointAtRadian(content, middleRadian),\n bounding: ctx.getEllipseArcBounding(content),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n const ellipseModel = {\n type: "ellipse",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n ...ctx.angleDeltaModel,\n move(content, offset) {\n ctx.moveEllipse(content, offset);\n },\n rotate(content, center, angle) {\n ctx.rotateEllipse(content, center, angle);\n },\n scale(content, center, sx, sy) {\n ctx.scaleEllipse(content, center, sx, sy);\n },\n skew(content, center, sx, sy) {\n ctx.skewEllipse(content, center, sx, sy);\n },\n mirror(content, line, angle) {\n ctx.mirrorEllipse(content, line, angle);\n },\n offset(content, point, distance, contents) {\n if (!distance) {\n distance = Math.min(...getEllipseGeometries(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n return ctx.getParallelEllipsesByDistance(content, distance)[ctx.pointSideToIndex(ctx.getPointSideOfEllipse(point, content))];\n },\n break(content, points) {\n if (points.length < 2) {\n return;\n }\n const angles = points.map((p) => ctx.getEllipseAngle(p, content));\n angles.sort((a, b) => a - b);\n return angles.map((a, i) => ({\n ...content,\n type: "ellipse arc",\n startAngle: a,\n endAngle: i === angles.length - 1 ? angles[0] + 360 : angles[i + 1]\n }));\n },\n render(content, renderCtx) {\n const { options, target, dashed } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n if (dashed) {\n const { points } = getEllipseGeometries(content, renderCtx.contents);\n return target.renderPolygon(points, options);\n }\n return target.renderEllipse(content.cx, content.cy, content.rx, content.ry, { ...options, angle: content.angle });\n },\n getOperatorRenderPosition(content) {\n return ctx.getEllipseCenter(content);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n var _a;\n const { center, left, right, top, bottom } = getEllipseGeometries(content, contents);\n const rotate = -((_a = content.angle) != null ? _a : 0);\n return {\n editPoints: [\n {\n x: content.cx,\n y: content.cy,\n cursor: "move",\n type: "move",\n update(c, { cursor, start, scale }) {\n if (!isEllipseContent(c)) {\n return;\n }\n c.cx += cursor.x - start.x;\n c.cy += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n },\n {\n x: left.x,\n y: left.y,\n cursor: ctx.getResizeCursor(-rotate, "left"),\n update(c, { cursor, scale }) {\n if (!isEllipseContent(c)) {\n return;\n }\n c.rx = ctx.getTwoPointsDistance(cursor, center);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n },\n {\n x: right.x,\n y: right.y,\n cursor: ctx.getResizeCursor(-rotate, "right"),\n update(c, { cursor, scale }) {\n if (!isEllipseContent(c)) {\n return;\n }\n c.rx = ctx.getTwoPointsDistance(cursor, center);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n },\n {\n x: top.x,\n y: top.y,\n cursor: ctx.getResizeCursor(-rotate, "top"),\n update(c, { cursor, scale }) {\n if (!isEllipseContent(c)) {\n return;\n }\n c.ry = ctx.getTwoPointsDistance(cursor, center);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n },\n {\n x: bottom.x,\n y: bottom.y,\n cursor: ctx.getResizeCursor(-rotate, "bottom"),\n update(c, { cursor, scale }) {\n if (!isEllipseContent(c)) {\n return;\n }\n c.ry = ctx.getTwoPointsDistance(cursor, center);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n }\n ],\n angleSnapStartPoint: ctx.getEllipseCenter(content)\n };\n });\n },\n getSnapPoints(content, contents) {\n const { center, left, right, top, bottom } = getEllipseGeometries(content, contents);\n return ctx.getSnapPointsFromCache(content, () => [\n { ...center, type: "center" },\n { ...left, type: "endpoint" },\n { ...right, type: "endpoint" },\n { ...top, type: "endpoint" },\n { ...bottom, type: "endpoint" }\n ]);\n },\n getGeometries: getEllipseGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isEllipseContent(c)) {\n c.cx = p.x, c.cy = p.y;\n }\n })) }, "canvas"),\n cx: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.cx, setValue: (v) => update((c) => {\n if (isEllipseContent(c)) {\n c.cx = v;\n }\n }) }),\n cy: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.cy, setValue: (v) => update((c) => {\n if (isEllipseContent(c)) {\n c.cy = v;\n }\n }) }),\n rx: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.rx, setValue: (v) => update((c) => {\n if (isEllipseContent(c)) {\n c.rx = v;\n }\n }) }),\n ry: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ry, setValue: (v) => update((c) => {\n if (isEllipseContent(c)) {\n c.ry = v;\n }\n }) }),\n angle: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.angle !== void 0, setValue: (v) => update((c) => {\n if (isEllipseContent(c)) {\n c.angle = v ? 0 : void 0;\n }\n }) }),\n content.angle !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.angle, setValue: (v) => update((c) => {\n if (isEllipseContent(c)) {\n c.angle = v;\n }\n }) }) : void 0\n ],\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents),\n ...ctx.getAngleDeltaContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, EllipseContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point, contents) => ctx.pointInPolygon(point, getEllipseGeometries(content, contents).points),\n getArea: (content) => Math.PI * content.rx * content.ry\n };\n return [\n ellipseModel,\n {\n type: "ellipse arc",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n ...ctx.angleDeltaModel,\n move: ellipseModel.move,\n rotate: ellipseModel.rotate,\n scale(content, center, sx, sy) {\n ctx.scaleEllipseArc(content, center, sx, sy);\n },\n skew(content, center, sx, sy) {\n ctx.skewEllipseArc(content, center, sx, sy);\n },\n mirror: ellipseModel.mirror,\n break(content, points) {\n if (points.length === 0) {\n return;\n }\n const angles = points.map((p) => ctx.normalizeAngleInRange(ctx.getEllipseAngle(p, content), content));\n angles.sort((a, b) => a - b);\n const result = [];\n if (!ctx.isSameNumber(angles[0], content.startAngle)) {\n result.push({\n ...content,\n type: "ellipse arc",\n startAngle: content.startAngle,\n endAngle: angles[0]\n });\n }\n angles.forEach((a, i) => {\n if (i === angles.length - 1) {\n if (!ctx.isSameNumber(a, content.endAngle)) {\n result.push({\n ...content,\n type: "ellipse arc",\n startAngle: a,\n endAngle: content.endAngle\n });\n }\n } else {\n result.push({\n ...content,\n type: "ellipse arc",\n startAngle: a,\n endAngle: angles[i + 1]\n });\n }\n });\n return result.length > 1 ? result : void 0;\n },\n offset(content, point, distance, contents) {\n if (!distance) {\n distance = Math.min(...getEllipseArcGeometries(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n return ctx.getParallelEllipseArcsByDistance(content, distance)[ctx.pointSideToIndex(ctx.getPointSideOfEllipseArc(point, content))];\n },\n join(content, target) {\n if (isEllipseArcContent(target)) {\n return ctx.mergeEllipseArc(content, target);\n }\n return;\n },\n extend(content, point) {\n const angle = ctx.getEllipseAngle(point, content);\n const endAngle = ctx.getFormattedEndAngle({ startAngle: content.startAngle, endAngle: angle });\n const startAngle = ctx.getFormattedStartAngle({ startAngle: angle, endAngle: content.endAngle });\n const angle1 = Math.abs(endAngle - content.startAngle);\n const angle2 = Math.abs(content.endAngle - startAngle);\n if (angle1 < angle2) {\n content.endAngle = endAngle;\n } else {\n content.startAngle = startAngle;\n }\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getEllipseArcGeometries(content, renderCtx.contents);\n return target.renderPolyline(points, options);\n },\n renderIfSelected(content, { color, target, strokeWidth, contents }) {\n const { points } = getEllipseArcGeometries({ ...content, startAngle: content.endAngle, endAngle: content.startAngle }, contents);\n return target.renderPolyline(points, { strokeColor: color, dashArray: [4], strokeWidth });\n },\n getOperatorRenderPosition(content, contents) {\n const { points } = getEllipseArcGeometries(content, contents);\n return points[0];\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n var _a;\n const { center, start, end } = getEllipseArcGeometries(content, contents);\n const rotate = -((_a = content.angle) != null ? _a : 0);\n return {\n editPoints: [\n {\n x: content.cx,\n y: content.cy,\n cursor: "move",\n update(c, { cursor, start: start2, scale }) {\n if (!isEllipseArcContent(c)) {\n return;\n }\n c.cx += cursor.x - start2.x;\n c.cy += cursor.y - start2.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n },\n {\n ...start,\n cursor: ctx.getResizeCursor(content.startAngle - rotate, "top"),\n update(c, { cursor, scale }) {\n if (!isEllipseArcContent(c)) {\n return;\n }\n c.startAngle = ctx.getEllipseAngle(cursor, content);\n ctx.normalizeAngleRange(c);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n },\n {\n ...end,\n cursor: ctx.getResizeCursor(content.endAngle - rotate, "top"),\n update(c, { cursor, scale }) {\n if (!isEllipseArcContent(c)) {\n return;\n }\n c.endAngle = ctx.getEllipseAngle(cursor, content);\n ctx.normalizeAngleRange(c);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [center, cursor] }] };\n }\n }\n ],\n angleSnapStartPoint: center\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { center, start, end, middle } = getEllipseArcGeometries(content, contents);\n return [\n { ...center, type: "center" },\n { ...start, type: "endpoint" },\n { ...end, type: "endpoint" },\n { ...middle, type: "midpoint" }\n ];\n });\n },\n getGeometries: getEllipseArcGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.cx = p.x, c.cy = p.y;\n }\n })) }, "canvas"),\n cx: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.cx, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.cx = v;\n }\n }) }),\n cy: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.cy, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.cy = v;\n }\n }) }),\n rx: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.rx, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.rx = v;\n }\n }) }),\n ry: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ry, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.ry = v;\n }\n }) }),\n angle: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.angle !== void 0, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.angle = v ? 0 : void 0;\n }\n }) }),\n content.angle !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.angle, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.angle = v;\n }\n }) }) : void 0\n ],\n startAngle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.startAngle, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.startAngle = v;\n }\n }) }),\n endAngle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.endAngle, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.endAngle = v;\n }\n }) }),\n counterclockwise: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.counterclockwise === true, setValue: (v) => update((c) => {\n if (isEllipseArcContent(c)) {\n c.counterclockwise = v ? true : void 0;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents),\n ...ctx.getAngleDeltaContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, EllipseArcContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n getArea: (content) => {\n const radian = ctx.angleToRadian(content.endAngle - content.startAngle);\n return content.rx * content.ry * (radian - Math.sin(radian)) / 2;\n },\n reverse: (content) => ctx.reverseEllipseArc(content)\n }\n ];\n}\nfunction isEllipseContent(content) {\n return content.type === "ellipse";\n}\nfunction isEllipseArcContent(content) {\n return content.type === "ellipse arc";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon1 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("ellipse", { cx: "50", cy: "50", rx: "42", ry: "25", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "50", cy: "50", r: "10", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "92", cy: "50", r: "10", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n const icon2 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("ellipse", { cx: "50", cy: "50", rx: "42", ry: "25", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "8", cy: "50", r: "10", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "92", cy: "50", r: "10", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n const icon3 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "7,71 8,69 8,66 9,64 10,61 12,58 14,55 16,52 18,49 21,46 23,43 27,40 30,38 33,35 37,32 40,30 44,28 48,25 51,23 55,22 59,20 62,19 66,18 69,17 72,16 76,16 78,16 81,16 84,17 86,17 88,18 89,19 91,21 92,22 92,24 93,26 93,29 92,31 92,34 91,36 90,39 88,42 86,45 84,48 82,51 79,54 77,57 73,60 70,62 67,65 63,68 60,70 56,72 52,75 49,77 45,78 41,80 38,81 34,82", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return [\n {\n name: "create ellipse",\n type: [\n { name: "ellipse center", hotkey: "EL", icon: icon1 },\n { name: "ellipse endpoint", icon: icon2 }\n ],\n useCommand({ onEnd, type, scale, strokeStyleId, fillStyleId }) {\n const { ellipse, onClick, onMove, input, startPosition, middlePosition, cursorPosition, reset } = ctx.useEllipseClickCreate(\n type === "ellipse center" || type === "ellipse endpoint" ? type : void 0,\n (c) => onEnd({\n updateContents: (contents) => contents.push({ ...c, strokeStyleId, fillStyleId, type: "ellipse" })\n })\n );\n const assistentContents = [];\n if (startPosition && cursorPosition) {\n if (middlePosition) {\n assistentContents.push({ type: "line", points: [startPosition, middlePosition], dashArray: [4 / scale] });\n if (type === "ellipse center") {\n assistentContents.push({ type: "line", points: [startPosition, cursorPosition], dashArray: [4 / scale] });\n } else if (ellipse) {\n assistentContents.push({ type: "line", points: [ctx.getEllipseCenter(ellipse), cursorPosition], dashArray: [4 / scale] });\n }\n } else {\n assistentContents.push({ type: "line", points: [startPosition, cursorPosition], dashArray: [4 / scale] });\n }\n }\n if (ellipse) {\n assistentContents.push({ ...ellipse, strokeStyleId, fillStyleId, type: "ellipse" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition: middlePosition != null ? middlePosition : startPosition,\n reset\n };\n },\n selectCount: 0\n },\n {\n name: "create ellipse arc",\n useCommand({ onEnd, type, scale, strokeStyleId, fillStyleId }) {\n const { ellipse, ellipseArc, onClick, onMove, input, startPosition, middlePosition, cursorPosition, reset } = ctx.useEllipseArcClickCreate(\n type === "create ellipse arc" ? "ellipse center" : void 0,\n (c) => onEnd({\n updateContents: (contents) => contents.push({ ...c, strokeStyleId, fillStyleId, type: "ellipse arc" })\n })\n );\n const assistentContents = [];\n if (startPosition && cursorPosition) {\n if (middlePosition) {\n assistentContents.push({ type: "line", points: [startPosition, middlePosition], dashArray: [4 / scale] });\n const center = type === "create ellipse arc" ? startPosition : { x: (startPosition.x + middlePosition.x) / 2, y: (startPosition.y + middlePosition.y) / 2 };\n assistentContents.push({ type: "line", points: [center, cursorPosition], dashArray: [4 / scale] });\n } else {\n assistentContents.push({ type: "line", points: [startPosition, cursorPosition], dashArray: [4 / scale] });\n }\n }\n if (ellipseArc) {\n assistentContents.push({ ...ellipseArc, dashArray: [4 / scale], type: "ellipse" });\n if (ellipseArc.startAngle !== ellipseArc.endAngle) {\n assistentContents.push(\n {\n type: "line",\n points: [\n ctx.getEllipsePointAtRadian(ellipseArc, ctx.angleToRadian(ellipseArc.startAngle)),\n {\n x: ellipseArc.cx,\n y: ellipseArc.cy\n }\n ],\n dashArray: [4 / scale]\n },\n {\n type: "line",\n points: [\n {\n x: ellipseArc.cx,\n y: ellipseArc.cy\n },\n ctx.getEllipsePointAtRadian(ellipseArc, ctx.angleToRadian(ellipseArc.endAngle))\n ],\n dashArray: [4 / scale]\n }\n );\n }\n if (cursorPosition) {\n assistentContents.push({ type: "line", points: [ctx.getEllipseCenter(ellipseArc), cursorPosition], dashArray: [4 / scale] });\n }\n } else if (ellipse) {\n assistentContents.push({ ...ellipse, dashArray: [4 / scale], type: "ellipse" });\n if (cursorPosition) {\n assistentContents.push({ type: "line", points: [ctx.getEllipseCenter(ellipse), cursorPosition], dashArray: [4 / scale] });\n }\n }\n if (ellipseArc && ellipseArc.startAngle !== ellipseArc.endAngle) {\n assistentContents.push({ ...ellipseArc, strokeStyleId, fillStyleId, type: "ellipse arc" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition: middlePosition != null ? middlePosition : startPosition,\n reset\n };\n },\n selectCount: 0,\n icon: icon3\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isEllipseArcContent,\n isEllipseContent\n};\n','// dev/cad-editor/plugins/coordinate-axis.plugin.tsx\nfunction isCoordinateAxisContent(content) {\n return content.type === "coordinate axis";\n}\n\n// dev/cad-editor/plugins/equation.plugin.tsx\nfunction getModel(ctx) {\n const EquationContent = ctx.and(ctx.BaseContent("equation"), ctx.StrokeFields, ctx.SegmentCountFields, {\n axisId: ctx.ContentRef,\n dependentVariable: ctx.or("x", "y"),\n expression: ctx.string\n });\n const getRefIds = (content) => [...ctx.getStrokeRefIds(content), ...ctx.toRefId(content.axisId, true)];\n const equationCache = new ctx.WeakmapValuesCache();\n function getGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return equationCache.get(content, refs, () => {\n var _a;\n const axis = ctx.getReference(content.axisId, contents, isCoordinateAxisContent);\n if (axis) {\n if (content.expression) {\n try {\n const expression = ctx.parseExpression(ctx.tokenizeExpression(content.expression));\n const points = [];\n const segmentCount = (_a = content.segmentCount) != null ? _a : ctx.defaultSegmentCount;\n if (content.dependentVariable === "y") {\n const step = (axis.xMax - axis.xMin) / segmentCount;\n for (let x = axis.xMin; x <= axis.xMax; x += step) {\n const y = ctx.evaluateExpression(expression, {\n Math,\n x\n });\n if (typeof y === "number" && !isNaN(y)) {\n points.push({ x: x + axis.x, y: y * (axis.flipY ? -1 : 1) + axis.y });\n }\n }\n } else {\n const step = (axis.yMax - axis.yMin) / segmentCount;\n for (let y = axis.yMin; y <= axis.yMax; y += step) {\n const x = ctx.evaluateExpression(expression, {\n Math,\n y\n });\n if (typeof x === "number" && !isNaN(x)) {\n points.push({ x: x + axis.x, y: y * (axis.flipY ? -1 : 1) + axis.y });\n }\n }\n }\n const lines = Array.from(ctx.iteratePolylineLines(points));\n return {\n points,\n lines,\n bounding: ctx.getPointsBounding(points),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray)\n };\n } catch (e) {\n console.info(e);\n }\n }\n return { lines: [], points: [], renderingLines: [] };\n }\n return { lines: [], points: [], renderingLines: [] };\n });\n }\n const React = ctx.React;\n return {\n type: "equation",\n ...ctx.strokeModel,\n ...ctx.segmentCountModel,\n render(content, renderCtx) {\n const { options, contents, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getGeometriesFromCache(content, contents);\n return target.renderPolyline(points, options);\n },\n getGeometries: getGeometriesFromCache,\n propertyPanel(content, update, contents) {\n return {\n dependentVariable: /* @__PURE__ */ React.createElement(ctx.EnumEditor, { value: content.dependentVariable, enums: ["x", "y"], setValue: (v) => update((c) => {\n if (isEquationContent(c)) {\n c.dependentVariable = v;\n }\n }) }),\n expression: /* @__PURE__ */ React.createElement(ctx.ExpressionEditor, { suggestionSources: ctx.math, validate: ctx.validateExpression, value: content.expression, setValue: (v) => update((c) => {\n if (isEquationContent(c)) {\n c.expression = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getSegmentCountContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, EquationContent, p),\n getRefIds,\n updateRefId(content, update) {\n const newAxisId = update(content.axisId);\n if (newAxisId !== void 0) {\n content.axisId = newAxisId;\n }\n ctx.updateStrokeRefIds(content, update);\n },\n deleteRefId: ctx.deleteStrokeRefIds\n };\n}\nfunction isEquationContent(content) {\n return content.type === "equation";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "7,93 88,93", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,12 7,93", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "97,93 68,101 68,85", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,3 15,32 1,32", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,93 8,85 9,81 10,78 11,76 12,74 12,72 13,71 14,69 15,68 16,66 17,65 18,64 19,62 20,61 21,60 21,59 22,58 23,57 24,56 25,55 26,54 27,53 28,52 29,51 29,51 30,50 31,49 32,48 33,47 34,47 35,46 36,45 37,44 38,44 38,43 39,42 40,41 41,41 42,40 43,39 44,39 45,38 46,37 47,37 47,36 48,35 49,35 50,34 51,34 52,33 53,32 54,32 55,31 56,31 56,30 57,30 58,29 59,28 60,28 61,27 62,27 63,26 64,26 65,25 65,25 66,24 67,24 68,23 69,23 70,22 71,22 72,21 73,21 74,20 74,20 75,19 76,19 77,18 78,18 79,17 80,17 81,16 82,16 83,15 84,15 84,14 85,14 86,13 87,13 88,13 89,12 90,12 91,11 92,11 93,10 93,10 94,9 95,9 96,9", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create equation",\n icon,\n useCommand({ onEnd, type, selected }) {\n const [dependentVariable, setDependentVariable] = React.useState("y");\n const enabled = type === "create equation";\n let message = "";\n if (enabled) {\n message = dependentVariable === "x" ? "input f(y)" : "input f(x)";\n }\n const { input, setCursorPosition, clearText, setInputPosition, resetInput } = ctx.useCursorInput(message, enabled ? (e, text) => {\n if (e.key === "Enter") {\n onEnd({\n updateContents(contents) {\n contents.push({\n type: "equation",\n axisId: selected[0].path[0],\n dependentVariable,\n expression: text\n });\n }\n });\n clearText();\n }\n } : void 0);\n const reset = () => {\n resetInput();\n setDependentVariable("y");\n };\n return {\n input,\n onStart() {\n },\n onMove(p, viewportPosition) {\n setInputPosition(viewportPosition || p);\n setCursorPosition(p);\n },\n subcommand: enabled ? /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("button", { onClick: () => setDependentVariable(dependentVariable === "x" ? "y" : "x"), style: { position: "relative" } }, "f(", dependentVariable, ")")) : void 0,\n reset\n };\n },\n contentSelectable: isCoordinateAxisContent,\n selectCount: 1\n };\n}\nexport {\n getCommand,\n getModel,\n isEquationContent\n};\n','// dev/cad-editor/plugins/explode.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "17,11 83,11", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "80,91 16,91", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "9,84 9,19", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "90,19 90,85", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "explode",\n execute({ contents, selected }) {\n const newContents = [];\n const indexes = [];\n contents.forEach((content, index) => {\n var _a, _b, _c, _d;\n if (content && ctx.isSelected([index], selected) && ((_b = (_a = this.contentSelectable) == null ? void 0 : _a.call(this, content, contents)) != null ? _b : true)) {\n const result = (_d = (_c = ctx.getContentModel(content)) == null ? void 0 : _c.explode) == null ? void 0 : _d.call(_c, content, contents);\n if (result) {\n newContents.push(...result);\n indexes.push(index);\n }\n }\n });\n ctx.deleteSelectedContents(contents, indexes);\n contents.push(...newContents);\n },\n contentSelectable(content, contents) {\n const model = ctx.getContentModel(content);\n return (model == null ? void 0 : model.explode) !== void 0 && ctx.contentIsDeletable(content, contents);\n },\n hotkey: "X",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/export-code.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "25,13 7,51 22,90", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "75,13 93,51 78,90", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "export code",\n execute({ contents, selected, width, height, transform }) {\n const result = [];\n contents.forEach((content, index) => {\n if (content && ctx.isSelected([index], selected)) {\n const model = ctx.getContentModel(content);\n if (model == null ? void 0 : model.render) {\n const code = model.render(content, {\n target: ctx.codeRenderTarget,\n transformColor: (c) => c,\n transformStrokeWidth: (w) => w,\n getFillColor: (c) => c.fillColor,\n getStrokeColor: (c) => {\n var _a;\n return (_a = c.strokeColor) != null ? _a : ctx.hasFill(c) ? void 0 : ctx.defaultStrokeColor;\n },\n getFillPattern: (c) => c.fillPattern ? {\n width: c.fillPattern.width,\n height: c.fillPattern.height,\n pattern: () => {\n var _a, _b, _c, _d;\n return ctx.codeRenderTarget.renderPath((_b = (_a = c.fillPattern) == null ? void 0 : _a.lines) != null ? _b : [], {\n strokeColor: (_d = (_c = c.fillPattern) == null ? void 0 : _c.strokeColor) != null ? _d : ctx.defaultStrokeColor\n });\n }\n } : void 0,\n contents\n });\n result.push(code);\n }\n }\n });\n navigator.clipboard.writeText(ctx.codeRenderTarget.renderResult(result, width, height, {\n transform\n }));\n },\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/export-jsx.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "25,13 7,51 22,90", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "75,13 93,51 78,90", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "64,15 51,90", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "export jsx",\n execute({ contents, selected }) {\n const result = [];\n contents.forEach((content, index) => {\n if (content && ctx.isSelected([index], selected)) {\n const model = ctx.getContentModel(content);\n if (model == null ? void 0 : model.render) {\n let color;\n if (ctx.isFillContent(content) && content.fillColor !== void 0) {\n color = content.fillColor;\n } else if (ctx.isStrokeContent(content)) {\n color = content.strokeColor;\n }\n color = color != null ? color : ctx.defaultStrokeColor;\n const svg = ctx.renderToStaticMarkup(model.render(content, {\n target: ctx.reactSvgRenderTarget,\n transformColor: (c) => c,\n transformStrokeWidth: (w) => w,\n getFillColor: (c) => c.fillColor,\n getStrokeColor: (c) => {\n var _a;\n return (_a = c.strokeColor) != null ? _a : ctx.hasFill(c) ? void 0 : ctx.defaultStrokeColor;\n },\n getFillPattern: (c) => c.fillPattern ? {\n width: c.fillPattern.width,\n height: c.fillPattern.height,\n pattern: () => {\n var _a, _b, _c, _d;\n return ctx.reactSvgRenderTarget.renderPath((_b = (_a = c.fillPattern) == null ? void 0 : _a.lines) != null ? _b : [], {\n strokeColor: (_d = (_c = c.fillPattern) == null ? void 0 : _c.strokeColor) != null ? _d : ctx.defaultStrokeColor\n });\n }\n } : void 0,\n contents\n })(index, 1, false, 100, 100));\n let jsx = "";\n for (let j = 0; j < svg.length; j++) {\n const c = svg[j];\n if (c === "-" && ctx.isLetter(svg[j + 1])) {\n jsx += svg[j + 1].toUpperCase();\n j++;\n } else {\n jsx += c;\n }\n }\n jsx = jsx.replaceAll(/[0-9]+\\.[0-9]+/g, (c) => Math.round(+c).toString());\n result.push(jsx.split(ctx.getColorString(color)).join("currentColor"));\n }\n }\n });\n navigator.clipboard.writeText(result.join("\\n"));\n },\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/export-png.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "51,0 51,60", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "51,60 83,28", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "51,60 21,31", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "11,84 91,84", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "export png",\n execute({ state, selected }) {\n const draws = [];\n const targets = [];\n state.forEach((content, index) => {\n if (content && ctx.isSelected([index], selected)) {\n const model = ctx.getContentModel(content);\n if (model == null ? void 0 : model.render) {\n targets.push(content);\n draws.push(model.render(content, {\n target: ctx.reactCanvasRenderTarget,\n transformColor: (c) => c,\n transformStrokeWidth: (w) => w,\n getFillColor: (c) => c.fillColor,\n getStrokeColor: (c) => {\n var _a;\n return (_a = c.strokeColor) != null ? _a : ctx.hasFill(c) ? void 0 : ctx.defaultStrokeColor;\n },\n getFillPattern: (c) => c.fillPattern ? {\n width: c.fillPattern.width,\n height: c.fillPattern.height,\n pattern: () => {\n var _a, _b, _c, _d;\n return ctx.reactCanvasRenderTarget.renderPath((_b = (_a = c.fillPattern) == null ? void 0 : _a.lines) != null ? _b : [], {\n strokeColor: (_d = (_c = c.fillPattern) == null ? void 0 : _c.strokeColor) != null ? _d : ctx.defaultStrokeColor\n });\n }\n } : void 0,\n contents: state\n }));\n }\n }\n });\n const width = window.innerWidth, height = window.innerHeight;\n const transform = ctx.zoomContentsToFit(width, height, targets, state, 0.8);\n if (!transform)\n return;\n const container = document.createElement("div");\n ctx.createRoot(container).render(/* @__PURE__ */ React.createElement(ctx.CanvasDrawCanvas, { width, height, draws, transform, onRender: () => {\n const child = container.children.item(0);\n if (child && child instanceof HTMLCanvasElement) {\n child.toBlob((blob) => {\n if (blob) {\n navigator.clipboard.write([new ClipboardItem({ [blob.type]: blob })]);\n }\n });\n }\n } }));\n },\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/extend.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "-0,0 101,0", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "56,-0 43,57", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "43,57 35,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "extend",\n useCommand({ onEnd, selected, contents, backgroundColor, setSelected }) {\n var _a;\n const [hovering, setHovering] = React.useState();\n const [trimHovering, setTrimHovering] = React.useState();\n const [shift, setShift] = React.useState(false);\n const reset = () => {\n setHovering(void 0);\n setTrimHovering(void 0);\n };\n const assistentContents = [];\n if (hovering) {\n assistentContents.push(hovering.content);\n } else if (trimHovering) {\n if (ctx.isStrokeContent(trimHovering.content)) {\n assistentContents.push({\n ...trimHovering.content,\n strokeWidth: ((_a = trimHovering.content.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(trimHovering.content)) + 2,\n strokeColor: backgroundColor,\n trueStrokeColor: true\n });\n }\n }\n return {\n onStart() {\n var _a2, _b, _c, _d, _e;\n if (hovering) {\n onEnd({\n updateContents(contents2) {\n var _a3, _b2;\n const content = ctx.getContentByIndex(contents2, hovering.path);\n if (content) {\n (_b2 = (_a3 = ctx.getContentModel(content)) == null ? void 0 : _a3.extend) == null ? void 0 : _b2.call(_a3, content, hovering.point, contents2);\n }\n }\n });\n } else if (trimHovering) {\n const content = ctx.getContentByIndex(contents, trimHovering.path);\n if (content) {\n const points = [];\n const lines = (_c = (_b = (_a2 = ctx.getContentModel(trimHovering.content)) == null ? void 0 : _a2.getGeometries) == null ? void 0 : _b.call(_a2, trimHovering.content, contents)) == null ? void 0 : _c.lines;\n if (lines) {\n const { start, end } = ctx.getGeometryLinesStartAndEnd(lines);\n if (start && end) {\n if (!ctx.isSamePoint(start, end)) {\n points.push(start, end);\n }\n } else if (start) {\n points.push(start);\n } else if (end) {\n points.push(end);\n }\n }\n if (points.length > 0) {\n const r = (_e = (_d = ctx.getContentModel(content)) == null ? void 0 : _d.break) == null ? void 0 : _e.call(_d, content, points, contents);\n if (r) {\n const index = ctx.getContentIndex(content, contents);\n const newContents = r.filter((c) => !ctx.deepEquals(trimHovering.content, c));\n onEnd({\n updateContents: (contents2) => {\n contents2[index] = void 0;\n contents2.push(...newContents);\n }\n });\n const newSelected = selected.map((s) => s.path);\n for (let i = 0; i < newContents.length; i++) {\n newSelected.push([contents.length + i]);\n }\n setSelected(...newSelected);\n }\n }\n }\n }\n reset();\n },\n onMove(p) {\n var _a2, _b, _c, _d, _e, _f, _g, _h;\n for (const s of selected) {\n const lines = (_c = (_b = (_a2 = ctx.getContentModel(s.content)) == null ? void 0 : _a2.getGeometries) == null ? void 0 : _b.call(_a2, s.content, contents)) == null ? void 0 : _c.lines;\n if (lines == null ? void 0 : lines.some((line) => ctx.getPointAndGeometryLineMinimumDistance(p, line) < 5)) {\n let points = [];\n for (const c of selected) {\n if (c !== s) {\n const lines2 = (_f = (_e = (_d = ctx.getContentModel(c.content)) == null ? void 0 : _d.getGeometries) == null ? void 0 : _e.call(_d, c.content, contents)) == null ? void 0 : _f.lines;\n if (lines2) {\n for (let i = 0; i < lines.length; i++) {\n const extend = i === 0 || i === lines.length - 1;\n for (const line of lines2) {\n if (shift) {\n points.push(...ctx.getTwoGeometryLinesIntersectionPoint(lines[i], line));\n } else {\n points.push(...ctx.getTwoGeometryLinesIntersectionPoint(lines[i], line, extend).filter((p2) => !ctx.pointIsOnGeometryLines(p2, lines)));\n }\n }\n }\n }\n }\n }\n points = ctx.deduplicatePosition(points);\n if (shift) {\n let parts = [s.content];\n if (points.length > 0) {\n parts = ((_h = (_g = ctx.getContentModel(s.content)) == null ? void 0 : _g.break) == null ? void 0 : _h.call(_g, s.content, points, contents)) || [s.content];\n }\n const content = parts.length === 1 ? parts[0] : parts.find((f) => {\n var _a3, _b2, _c2;\n return (_c2 = (_b2 = (_a3 = ctx.getContentModel(f)) == null ? void 0 : _a3.getGeometries) == null ? void 0 : _b2.call(_a3, f, contents)) == null ? void 0 : _c2.lines.some((n) => ctx.getPointAndGeometryLineMinimumDistance(p, n) < 5);\n });\n if (content) {\n setTrimHovering({\n ...s,\n content\n });\n return;\n }\n } else if (points.length > 0) {\n const point = points.length === 1 ? points[0] : ctx.minimumBy(points.map((point2) => ({\n point: point2,\n distance: ctx.getTwoPointsDistanceSquare(p, point2)\n })), (n) => n.distance).point;\n setHovering({\n ...s,\n point,\n content: ctx.produce(s.content, (draft) => {\n var _a3, _b2;\n (_b2 = (_a3 = ctx.getContentModel(s.content)) == null ? void 0 : _a3.extend) == null ? void 0 : _b2.call(_a3, draft, point, contents);\n })\n });\n return;\n }\n }\n }\n setHovering(void 0);\n setTrimHovering(void 0);\n },\n onKeyDown(e) {\n setShift(e.shiftKey);\n },\n onKeyUp(e) {\n setShift(e.shiftKey);\n },\n reset,\n assistentContents,\n hovering: hovering ? [hovering.path] : trimHovering ? [trimHovering.path] : void 0\n };\n },\n contentSelectable(content, contents) {\n var _a, _b, _c, _d;\n return !content.readonly && !!((_d = (_c = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content, contents)) == null ? void 0 : _c.lines) == null ? void 0 : _d.length);\n },\n icon,\n repeatedly: true\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/fill-style.plugin.tsx\nfunction getModel(ctx) {\n function getGeometriesFromCache(content) {\n return ctx.getGeometriesFromCache(content, /* @__PURE__ */ new Set(), () => {\n const points = [\n { x: content.x, y: content.y },\n { x: content.x + content.width, y: content.y },\n { x: content.x + content.width, y: content.y + content.height },\n { x: content.x, y: content.y + content.height }\n ];\n return {\n lines: [],\n bounding: ctx.getPointsBounding(points),\n regions: [\n {\n points,\n lines: Array.from(ctx.iteratePolygonLines(points))\n }\n ],\n renderingLines: []\n };\n });\n }\n const React = ctx.React;\n return {\n type: "fill style",\n ...ctx.fillModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content, center, sx, sy);\n },\n render(content, { target, getFillColor, transformColor, getFillPattern }) {\n const options = {\n strokeColor: content.isCurrent ? transformColor(16711680) : void 0,\n strokeWidth: content.isCurrent ? 1 : 0,\n fillColor: getFillColor(content),\n fillOpacity: content.fillOpacity,\n fillPattern: getFillPattern(content)\n };\n return target.renderRect(content.x, content.y, content.width, content.height, options);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!ctx.isFillStyleContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n isCurrent: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.isCurrent === true, setValue: (v) => update((c, draft) => {\n if (ctx.isFillStyleContent(c)) {\n const currentFillStyle = ctx.getFillStyles(contents).find((s) => s.content.isCurrent);\n if (currentFillStyle) {\n const c2 = draft[currentFillStyle.index];\n if (c2 && ctx.isFillStyleContent(c2)) {\n c2.isCurrent = void 0;\n }\n }\n c.isCurrent = v ? true : void 0;\n }\n }) }),\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (ctx.isFillStyleContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (ctx.isFillStyleContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (ctx.isFillStyleContent(c)) {\n c.y = v;\n }\n }) }),\n width: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.width, setValue: (v) => update((c) => {\n if (ctx.isFillStyleContent(c)) {\n c.width = v;\n }\n }) }),\n height: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.height, setValue: (v) => update((c) => {\n if (ctx.isFillStyleContent(c)) {\n c.height = v;\n }\n }) }),\n ...ctx.getFillContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, ctx.FillStyleContent, p)\n };\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "5", y: "6", width: "89", height: "39", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("pattern", { id: "1", patternUnits: "userSpaceOnUse", width: "20", height: "20" }, /* @__PURE__ */ React.createElement("path", { d: "M 0 10 L 10 0 M 20 10 L 10 20", strokeWidth: "1", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", fillRule: "evenodd" })), /* @__PURE__ */ React.createElement("rect", { x: "5", y: "55", width: "89", height: "39", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "url(#1)", stroke: "currentColor" }));\n return {\n name: "create fill style",\n selectCount: 0,\n icon,\n useCommand({ onEnd, type, scale }) {\n const [result, setResult] = React.useState();\n const reset = () => {\n setResult(void 0);\n };\n return {\n onStart() {\n if (result) {\n onEnd({\n updateContents: (contents) => {\n if (result) {\n contents.push(result);\n }\n }\n });\n reset();\n }\n },\n onMove(p) {\n if (type) {\n setResult({\n type: "fill style",\n x: p.x,\n y: p.y,\n width: 100 / scale,\n height: 20 / scale,\n fillColor: 0\n });\n }\n },\n assistentContents: result ? [result] : void 0,\n reset\n };\n }\n };\n}\nexport {\n getCommand,\n getModel\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isCircleContent(content) {\n return content.type === "circle";\n}\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction isLineContent(content) {\n return content.type === "line";\n}\n\n// dev/cad-editor/plugins/fillet.plugin.tsx\nfunction getCommand(ctx) {\n function getFillets(content1, content2, radius) {\n const result = [];\n if (!contentSelectable(content1) || !contentSelectable(content2)) {\n return result;\n }\n const circles = [];\n if (isLineContent(content1)) {\n const line1 = ctx.twoPointLineToGeneralFormLine(content1.points[0], content1.points[1]);\n if (!line1)\n return [];\n if (isLineContent(content2)) {\n const line2 = ctx.twoPointLineToGeneralFormLine(content2.points[0], content2.points[1]);\n if (!line2)\n return [];\n circles.push(...ctx.getCirclesTangentTo2Lines(line1, line2, radius).map((c) => ({\n center: c,\n foot1: ctx.getPerpendicularPoint(c, line1),\n foot2: ctx.getPerpendicularPoint(c, line2)\n })));\n } else if (isCircleContent(content2) || isArcContent(content2)) {\n circles.push(...ctx.getCirclesTangentToLineAndCircle(line1, content2, radius).map((c) => ({\n center: c,\n foot1: ctx.getPerpendicularPoint(c, line1),\n foot2: ctx.getTwoCircleIntersectionPoints({ ...c, r: radius }, content2)[0]\n })));\n }\n } else if (isCircleContent(content1) || isArcContent(content1)) {\n if (isCircleContent(content2) || isArcContent(content2)) {\n circles.push(...ctx.getCirclesTangentTo2Circles(content1, content2, radius).map((c) => ({\n center: c,\n foot1: ctx.getTwoCircleIntersectionPoints({ ...c, r: radius }, content1)[0],\n foot2: ctx.getTwoCircleIntersectionPoints({ ...c, r: radius }, content2)[0]\n })));\n } else if (isLineContent(content2)) {\n const line2 = ctx.twoPointLineToGeneralFormLine(content2.points[0], content2.points[1]);\n if (!line2)\n return [];\n circles.push(...ctx.getCirclesTangentToLineAndCircle(line2, content1, radius).map((c) => ({\n center: c,\n foot1: ctx.getPerpendicularPoint(c, line2),\n foot2: ctx.getTwoCircleIntersectionPoints({ ...c, r: radius }, content1)[0]\n })));\n }\n }\n return circles.map(({ foot1, foot2, center: c }) => {\n const angle1 = ctx.radianToAngle(ctx.getTwoPointsRadian(foot1, c));\n const angle2 = ctx.radianToAngle(ctx.getTwoPointsRadian(foot2, c));\n const min = Math.min(angle1, angle2);\n const max = Math.max(angle1, angle2);\n if (max - min < 180) {\n return { ...c, r: radius, startAngle: min, endAngle: max };\n }\n return { ...c, r: radius, startAngle: max, endAngle: min + 360 };\n });\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "9,10 92,10", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "92,10 92,93", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("path", { d: "M 92 60 A 50 50 0 0 0 42 10", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "fillet",\n useCommand({ onEnd, type, selected, scale }) {\n const [candidates, setCandidates] = React.useState([]);\n const [result, setResult] = React.useState();\n let message = "";\n if (type) {\n if (candidates.length > 0) {\n message = "select one result";\n } else {\n message = "input radius";\n }\n }\n const assistentContents = candidates.map((c) => ({\n ...c,\n type: "arc",\n dashArray: c === result ? void 0 : [4 / scale]\n }));\n const { input, setInputPosition, setCursorPosition, clearText, resetInput } = ctx.useCursorInput(message, type && candidates.length == 0 ? (e, text) => {\n if (e.key === "Enter") {\n const radius = +text;\n if (!isNaN(radius)) {\n setCandidates(getFillets(selected[0].content, selected[1].content, radius));\n clearText();\n }\n }\n } : void 0);\n const reset = () => {\n setCandidates([]);\n setResult(void 0);\n clearText();\n resetInput();\n };\n return {\n onStart(p) {\n setCursorPosition(p);\n if (result) {\n onEnd({\n updateContents: (contents) => {\n contents.push({ type: "arc", ...result });\n }\n });\n setCandidates([]);\n }\n },\n input,\n onMove(p, viewportPosition) {\n setCursorPosition(p);\n setInputPosition(viewportPosition || p);\n setResult(candidates.find((c) => ctx.getTwoNumbersDistance(ctx.getTwoPointsDistance(c, p), c.r) < 5));\n },\n assistentContents,\n reset\n };\n },\n selectCount: 2,\n contentSelectable,\n selectType: "select part",\n hotkey: "F",\n icon\n };\n}\nfunction contentSelectable(content) {\n return isLineContent(content) || isCircleContent(content) || isArcContent(content);\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/geometry-lines.plugin.tsx\nfunction getModel(ctx) {\n const GeometryLinesContent = ctx.and(ctx.BaseContent("geometry lines"), ctx.StrokeFields, ctx.FillFields, {\n lines: [ctx.GeometryLine]\n });\n const refGeometriesCache = new ctx.WeakmapValuesCache();\n function getGeometryLinesGeometries(content) {\n return refGeometriesCache.get(content, [], () => {\n const points = ctx.getGeometryLinesPoints(content.lines);\n const rays = [];\n const endPoints = [];\n for (const line of content.lines) {\n if (!Array.isArray(line) && line.type === "ray") {\n rays.push(line.line);\n }\n const { start, end } = ctx.getGeometryLineStartAndEnd(line);\n if (start && endPoints.every((p) => !ctx.isSamePoint(p, start))) {\n endPoints.push(start);\n }\n if (end && endPoints.every((p) => !ctx.isSamePoint(p, end))) {\n endPoints.push(end);\n }\n }\n const geometries = {\n lines: content.lines,\n points,\n endPoints,\n rays,\n bounding: ctx.getGeometryLinesBounding(content.lines),\n renderingLines: rays.length > 0 ? [] : ctx.dashedPolylineToLines(points, content.dashArray),\n region: rays.length > 0 ? [] : void 0\n };\n if (ctx.hasFill(content)) {\n return {\n ...geometries,\n lines: [],\n regions: [{\n lines: geometries.lines,\n points\n }],\n renderingLines: []\n };\n }\n return geometries;\n });\n }\n return {\n type: "geometry lines",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n for (const line of content.lines) {\n ctx.moveGeometryLine(line, offset);\n }\n },\n rotate(content, center, angle) {\n for (const line of content.lines) {\n ctx.rotateGeometryLine(line, center, angle);\n }\n },\n scale(content, center, sx, sy) {\n ctx.scaleGeometryLines(content.lines, center, sx, sy);\n },\n skew(content, center, sx, sy) {\n ctx.skewGeometryLines(content.lines, center, sx, sy);\n },\n explode(content) {\n return content.lines.map((line) => ctx.geometryLineToContent(line));\n },\n break(content, intersectionPoints) {\n return ctx.breakGeometryLines(content.lines, intersectionPoints).map((lines) => ({ ...content, type: "geometry lines", lines }));\n },\n mirror(content, line, angle) {\n for (const n of content.lines) {\n ctx.mirrorGeometryLine(n, line, angle);\n }\n },\n offset(content, point, distance, _, lineJoin) {\n const newLines = ctx.trimGeometryLines(ctx.getParallelGeometryLinesByDistancePoint(point, content.lines, distance, lineJoin));\n return { ...content, lines: newLines };\n },\n join(content, target, contents) {\n var _a, _b, _c;\n const line2 = (_c = (_b = (_a = ctx.getContentModel(target)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, target, contents)) == null ? void 0 : _c.lines;\n if (!line2)\n return;\n const newLines = ctx.mergeGeometryLines(content.lines, line2);\n if (!newLines)\n return;\n return { ...content, lines: newLines };\n },\n extend(content, point) {\n ctx.extendGeometryLines(content.lines, point);\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { points, rays } = getGeometryLinesGeometries(content);\n return target.renderGroup([\n target.renderPath([points], options),\n ...rays.map((r) => target.renderRay(r.x, r.y, r.angle, { ...options, bidirectional: r.bidirectional }))\n ]);\n },\n getSnapPoints(content) {\n const { endPoints } = getGeometryLinesGeometries(content);\n return ctx.getSnapPointsFromCache(content, () => {\n return endPoints.map((p) => ({ ...p, type: "endpoint" }));\n });\n },\n getGeometries: getGeometryLinesGeometries,\n canSelectPart: true,\n propertyPanel(content, update, contents) {\n return {\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n getRefIds: ctx.getStrokeAndFillRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n isValid: (c, p) => ctx.validate(c, GeometryLinesContent, p),\n reverse(content) {\n const newLines = ctx.reverseGeometryLines(content.lines);\n return { ...content, lines: newLines };\n }\n };\n}\nfunction isGeometryLinesContent(content) {\n return content.type === "geometry lines";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n return [\n {\n name: "create geometry lines",\n useCommand({ type, onEnd, width, height }) {\n const [json, setJson] = React.useState("");\n const reset = () => {\n setJson("");\n };\n return {\n reset,\n subcommand: type === "create geometry lines" ? /* @__PURE__ */ React.createElement("span", { style: { position: "relative" } }, /* @__PURE__ */ React.createElement(ctx.StringEditor, { textarea: true, value: json, style: { width: width * 0.7 + "px", height: height * 0.7 + "px" }, setValue: setJson }), /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => {\n if (json) {\n try {\n const lines = JSON.parse(json);\n const result = ctx.validate(lines, [ctx.GeometryLine]);\n if (result === true && lines.length > 0) {\n const allLines = ctx.getSeparatedGeometryLines(lines);\n onEnd({\n updateContents: (contents) => {\n contents.push(...allLines.map((n) => ({ type: "geometry lines", lines: n })));\n }\n });\n } else {\n console.info(result);\n }\n } catch (error) {\n console.info(error);\n }\n }\n } }, "OK")) : void 0\n };\n },\n selectCount: 0\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isGeometryLinesContent\n};\n','// dev/cad-editor/plugins/group.plugin.tsx\nfunction getModel(ctx) {\n const GroupContent = ctx.and(ctx.BaseContent("group"), ctx.ContainerFields, ctx.ClipFields);\n const getRefIds = (content) => ctx.toRefIds(content.contents);\n return {\n type: "group",\n ...ctx.containerModel,\n ...ctx.clipModel,\n move(content, offset) {\n var _a, _b;\n ctx.getContainerMove(content, offset);\n if (content.clip) {\n (_b = (_a = ctx.getContentModel(content.clip.border)) == null ? void 0 : _a.move) == null ? void 0 : _b.call(_a, content.clip.border, offset);\n }\n },\n rotate(content, center, angle, contents) {\n var _a, _b;\n ctx.getContainerRotate(content, center, angle, contents);\n if (content.clip) {\n (_b = (_a = ctx.getContentModel(content.clip.border)) == null ? void 0 : _a.rotate) == null ? void 0 : _b.call(_a, content.clip.border, center, angle, contents);\n }\n },\n scale(content, center, sx, sy, contents) {\n var _a, _b;\n ctx.getContainerScale(content, center, sx, sy, contents);\n if (content.clip) {\n return (_b = (_a = ctx.getContentModel(content.clip.border)) == null ? void 0 : _a.scale) == null ? void 0 : _b.call(_a, content.clip.border, center, sx, sy, contents);\n }\n },\n skew(content, center, sx, sy, contents) {\n var _a, _b;\n ctx.getContainerSkew(content, center, sx, sy, contents);\n if (content.clip) {\n return (_b = (_a = ctx.getContentModel(content.clip.border)) == null ? void 0 : _a.skew) == null ? void 0 : _b.call(_a, content.clip.border, center, sx, sy, contents);\n }\n },\n explode: ctx.getContainerExplode,\n mirror(content, line, angle, contents) {\n var _a, _b;\n ctx.getContainerMirror(content, line, angle, contents);\n if (content.clip) {\n (_b = (_a = ctx.getContentModel(content.clip.border)) == null ? void 0 : _a.mirror) == null ? void 0 : _b.call(_a, content.clip.border, line, angle, contents);\n }\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: ctx.getClipContentEditPoints(content, contents)\n };\n });\n },\n render: (content, renderCtx) => {\n return ctx.renderClipContent(content, ctx.getContainerRender(content, renderCtx), renderCtx);\n },\n renderIfSelected(content, renderCtx) {\n const result = ctx.getContainerRenderIfSelected(content, renderCtx, [content], getRefIds);\n return ctx.renderClipContentIfSelected(content, result, renderCtx);\n },\n getSnapPoints: ctx.getContainerSnapPoints,\n getGeometries: (content, contents) => ctx.getContainerGeometries(content, contents, getRefIds, [content]),\n propertyPanel: (content, update, contents, { acquireContent }) => {\n return {\n ...ctx.getVariableValuesContentPropertyPanel(content, ctx.getContainerVariableNames(content), update),\n ...ctx.getClipContentPropertyPanel(content, contents, acquireContent, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, GroupContent, p),\n getRefIds\n };\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "28", cy: "73", r: "22", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "93,78 97,48 71,34 49,56 63,82", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "7", y: "8", width: "50", height: "37", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create group",\n execute({ contents, selected }) {\n const newContent = {\n type: "group",\n contents: contents.filter((c, i) => c && ctx.isSelected([i], selected) && contentSelectable(c, contents))\n };\n ctx.deleteSelectedContents(contents, selected.map((s) => s[0]));\n contents.push(newContent);\n },\n contentSelectable,\n hotkey: "G",\n icon\n };\n}\nexport {\n getCommand,\n getModel\n};\n','// dev/cad-editor/plugins/hatch.plugin.tsx\nfunction getModel(ctx) {\n const HatchContent = ctx.and(ctx.BaseContent("hatch"), ctx.FillFields, {\n border: [ctx.GeometryLine],\n holes: ctx.optional([[ctx.GeometryLine]]),\n ref: ctx.optional({\n point: ctx.Position,\n ids: [ctx.ContentRef]\n })\n });\n const getRefIds = (content) => {\n var _a;\n return [...ctx.getFillRefIds(content), ...ctx.toRefIds((_a = content.ref) == null ? void 0 : _a.ids)];\n };\n const refGeometriesCache = new ctx.WeakmapValuesCache();\n function getHatchGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return refGeometriesCache.get(content, refs, () => {\n let hatch = content;\n if (content.ref && content.ref.ids.length > 0) {\n const refContents = content.ref.ids.map((id) => ctx.getReference(id, contents)).filter((d) => !!d && !ctx.shallowEquals(d, content));\n if (refContents.length > 0) {\n const p = content.ref.point;\n const getGeometriesInRange = () => refContents.map((c) => ctx.getContentHatchGeometries(c, contents));\n const border = ctx.getHatchByPosition(p, getGeometriesInRange);\n if (border) {\n const holes2 = ctx.getHatchHoles(border.lines, getGeometriesInRange);\n hatch = {\n border: border.lines,\n holes: holes2 == null ? void 0 : holes2.holes\n };\n }\n }\n }\n const points = ctx.getGeometryLinesPoints(hatch.border);\n const holes = (hatch.holes || []).map((h) => ctx.getGeometryLinesPoints(h));\n return {\n lines: [],\n border: points,\n holes,\n bounding: ctx.getGeometryLinesBounding(hatch.border),\n renderingLines: [],\n regions: [\n {\n lines: hatch.border,\n points,\n holes\n }\n ]\n };\n });\n }\n return {\n type: "hatch",\n ...ctx.fillModel,\n move(content, offset) {\n if (content.ref) {\n ctx.movePoint(content.ref.point, offset);\n }\n for (const line of content.border) {\n ctx.moveGeometryLine(line, offset);\n }\n if (content.holes) {\n for (const hole of content.holes) {\n for (const line of hole) {\n ctx.moveGeometryLine(line, offset);\n }\n }\n }\n },\n rotate(content, center, angle) {\n if (content.ref) {\n ctx.rotatePoint(content.ref.point, center, angle);\n }\n for (const line of content.border) {\n ctx.rotateGeometryLine(line, center, angle);\n }\n if (content.holes) {\n for (const hole of content.holes) {\n for (const line of hole) {\n ctx.rotateGeometryLine(line, center, angle);\n }\n }\n }\n },\n scale(content, center, sx, sy) {\n if (content.ref) {\n ctx.scalePoint(content.ref.point, center, sx, sy);\n }\n ctx.scaleGeometryLines(content.border, center, sx, sy);\n if (content.holes) {\n for (const hole of content.holes) {\n ctx.scaleGeometryLines(hole, center, sx, sy);\n }\n }\n },\n skew(content, center, sx, sy) {\n if (content.ref) {\n ctx.skewPoint(content.ref.point, center, sx, sy);\n }\n ctx.skewGeometryLines(content.border, center, sx, sy);\n if (content.holes) {\n for (const hole of content.holes) {\n ctx.skewGeometryLines(hole, center, sx, sy);\n }\n }\n },\n mirror(content, line, angle) {\n if (content.ref) {\n ctx.mirrorPoint(content.ref.point, line);\n }\n for (const b of content.border) {\n ctx.mirrorGeometryLine(b, line, angle);\n }\n if (content.holes) {\n for (const hole of content.holes) {\n for (const h of hole) {\n ctx.mirrorGeometryLine(h, line, angle);\n }\n }\n }\n },\n join(content, target) {\n var _a;\n if (isHatchContent(target)) {\n const result = (_a = ctx.mergeHatches({ border: content.border, holes: content.holes || [] }, { border: target.border, holes: target.holes || [] })) == null ? void 0 : _a[0];\n if (result) {\n return {\n ...content,\n border: result.border,\n holes: result.holes,\n ref: void 0\n };\n }\n }\n return;\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getFillRenderOptionsFromRenderContext(content, renderCtx);\n const { border, holes } = getHatchGeometries(content, renderCtx.contents);\n return target.renderPath([border, ...holes], options);\n },\n getGeometries: getHatchGeometries,\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n const editPoints = [];\n if (content.ref) {\n editPoints.push({\n x: content.ref.point.x,\n y: content.ref.point.y,\n cursor: "move",\n update(c, { cursor, start }) {\n if (!isHatchContent(c) || !c.ref) {\n return;\n }\n c.ref.point.x += cursor.x - start.x;\n c.ref.point.y += cursor.y - start.y;\n }\n });\n }\n return { editPoints };\n });\n },\n propertyPanel(content, update, contents) {\n return {\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, HatchContent, p),\n getRefIds,\n updateRefId(content, update) {\n if (content.ref) {\n for (const [i, id] of content.ref.ids.entries()) {\n const newRefId = update(id);\n if (newRefId !== void 0) {\n content.ref.ids[i] = newRefId;\n }\n }\n }\n ctx.updateFillRefIds(content, update);\n },\n deleteRefId(content, ids) {\n if (content.ref) {\n for (const id of ids) {\n const index = content.ref.ids.indexOf(id);\n if (index >= 0) {\n content.ref.ids.splice(index, 1);\n }\n }\n }\n ctx.deleteFillRefIds(content, ids);\n }\n };\n}\nfunction isHatchContent(content) {\n return content.type === "hatch";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "1,24 100,24", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "1,72 100,72", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "27,1 27,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "75,0 75,100", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("pattern", { id: "1", patternUnits: "userSpaceOnUse", width: "10", height: "10" }, /* @__PURE__ */ React.createElement("path", { d: "M 0 5 L 5 0 M 10 5 L 5 10", strokeWidth: "1", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", fillRule: "evenodd" })), /* @__PURE__ */ React.createElement("polygon", { points: "75,43 75,72 27,72 27,24 75,24 75,43", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", fill: "url(#1)", stroke: "currentColor" }));\n return [\n {\n name: "create hatch",\n icon,\n useCommand({ onEnd, contents, getContentsInRange, width, height, x, y, rotate, scale }) {\n const [hatch, setHatch] = React.useState();\n const reset = () => {\n setHatch(void 0);\n };\n return {\n onStart: () => {\n onEnd({\n updateContents: (contents2) => {\n if (hatch) {\n contents2.push(hatch);\n }\n }\n });\n },\n onMove(p) {\n const lineSegment = ctx.getRayTransformedLineSegment({ x: p.x, y: p.y, angle: 0 }, width, height, { x, y, scale, rotate });\n if (!lineSegment)\n return;\n const getGeometriesInRange = (region) => getContentsInRange(region).map((c) => ctx.getContentHatchGeometries(c, contents));\n const border = ctx.getHatchByPosition(p, (line) => getGeometriesInRange(ctx.getGeometryLineBoundingFromCache(line)), lineSegment[1].x);\n if (border) {\n const holes = ctx.getHatchHoles(border.lines, getGeometriesInRange);\n setHatch({\n type: "hatch",\n border: border.lines,\n holes: holes == null ? void 0 : holes.holes,\n ref: {\n point: p,\n ids: [...border.ids, ...(holes == null ? void 0 : holes.ids) || []]\n }\n });\n } else {\n setHatch(void 0);\n }\n },\n assistentContents: hatch ? [hatch] : void 0,\n reset\n };\n },\n selectCount: 0\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isHatchContent\n};\n','// dev/cad-editor/plugins/image.plugin.tsx\nfunction getModel(ctx) {\n const ImageContent = ctx.and(ctx.BaseContent("image"), ctx.Image, ctx.ClipFields);\n function getImageGeometries(content) {\n return ctx.getGeometriesFromCache(content, /* @__PURE__ */ new Set(), () => {\n const points = [\n { x: content.x, y: content.y + content.height },\n { x: content.x + content.width, y: content.y + content.height },\n { x: content.x + content.width, y: content.y },\n { x: content.x, y: content.y }\n ];\n const lines = Array.from(ctx.iteratePolygonLines(points));\n return {\n lines: [],\n bounding: ctx.getPointsBounding(points),\n regions: [\n {\n lines,\n points\n }\n ],\n renderingLines: []\n };\n });\n }\n const React = ctx.React;\n return {\n type: "image",\n ...ctx.clipModel,\n move(content, offset) {\n var _a, _b;\n ctx.movePoint(content, offset);\n if (content.clip) {\n (_b = (_a = ctx.getContentModel(content.clip.border)) == null ? void 0 : _a.move) == null ? void 0 : _b.call(_a, content.clip.border, offset);\n }\n },\n scale(content, center, sx, sy, contents) {\n var _a, _b;\n ctx.scalePoint(content, center, sx, sy);\n content.width *= sx;\n content.height *= sy;\n if (content.clip) {\n return (_b = (_a = ctx.getContentModel(content.clip.border)) == null ? void 0 : _a.scale) == null ? void 0 : _b.call(_a, content.clip.border, center, sx, sy, contents);\n }\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n x: content.x,\n y: content.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isImageContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n ...ctx.getClipContentEditPoints(content, contents)\n ]\n };\n });\n },\n render(content, renderCtx) {\n const { target, isHoveringOrSelected, transformStrokeWidth } = renderCtx;\n const strokeWidth = transformStrokeWidth(0);\n const fuzzy = isHoveringOrSelected && strokeWidth !== 0;\n let image = target.renderImage(content.url, content.x, content.y, content.width, content.height);\n image = ctx.renderClipContent(content, image, renderCtx);\n if (fuzzy) {\n return target.renderGroup([\n target.renderRect(content.x, content.y, content.width, content.height, {\n strokeWidth,\n ...ctx.fuzzyStyle\n }),\n image\n ]);\n }\n return image;\n },\n renderIfSelected(content, renderCtx) {\n const { color, target, strokeWidth } = renderCtx;\n const result = target.renderRect(content.x, content.y, content.width, content.height, { strokeColor: color, dashArray: [4], strokeWidth });\n return ctx.renderClipContentIfSelected(content, result, renderCtx);\n },\n getOperatorRenderPosition(content) {\n return content;\n },\n getGeometries: getImageGeometries,\n propertyPanel(content, update, contents, { acquirePoint, acquireContent }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isImageContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isImageContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isImageContent(c)) {\n c.y = v;\n }\n }) }),\n width: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.width, setValue: (v) => update((c) => {\n if (isImageContent(c)) {\n c.width = v;\n }\n }) }),\n height: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.height, setValue: (v) => update((c) => {\n if (isImageContent(c)) {\n c.height = v;\n }\n }) }),\n url: /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.url, setValue: (v) => update((c) => {\n if (isImageContent(c)) {\n c.url = v;\n }\n }) }),\n ...ctx.getClipContentPropertyPanel(content, contents, acquireContent, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, ImageContent, p)\n };\n}\nfunction isImageContent(content) {\n return content.type === "image";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "100,100 100,50 66,67 28,11 0,36 0,100", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "70", cy: "22", r: "13", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "create image",\n useCommand({ onEnd, type }) {\n const { image, onClick, onMove, input, reset } = ctx.useImageClickCreate(\n type === "create image",\n (c) => onEnd({\n updateContents: (contents) => contents.push({\n type: "image",\n ...c\n })\n })\n );\n const assistentContents = [];\n if (image) {\n assistentContents.push({\n type: "image",\n ...image\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n reset\n };\n },\n selectCount: 0,\n hotkey: "I",\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isImageContent\n};\n','// dev/cad-editor/plugins/join.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "0,49 100,49", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "51,49 76,32 76,64", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "54,49 27,32 28,65", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "join",\n execute({ contents, selected }) {\n var _a, _b;\n const source = new Set(contents.filter((content, index) => {\n var _a2, _b2;\n return !!content && ctx.isSelected([index], selected) && ((_b2 = (_a2 = this.contentSelectable) == null ? void 0 : _a2.call(this, content, contents)) != null ? _b2 : true);\n }));\n const removedContents = /* @__PURE__ */ new Set();\n const newContents = /* @__PURE__ */ new Set();\n while (source.size > 1) {\n const [current, ...rest] = source;\n const count = source.size;\n for (const r of rest) {\n const result = (_b = (_a = ctx.getContentModel(current)) == null ? void 0 : _a.join) == null ? void 0 : _b.call(_a, current, r, contents);\n if (result) {\n removedContents.add(r);\n source.delete(r);\n newContents.delete(r);\n removedContents.add(current);\n source.delete(current);\n newContents.delete(current);\n source.add(result);\n newContents.add(result);\n break;\n }\n }\n if (count === source.size) {\n source.delete(current);\n continue;\n }\n }\n const indexes = [];\n for (const content of removedContents) {\n const id = ctx.getContentIndex(content, contents);\n if (id >= 0) {\n indexes.push(id);\n }\n }\n ctx.deleteSelectedContents(contents, indexes);\n for (const content of newContents) {\n contents.push(content);\n }\n },\n contentSelectable(content, contents) {\n const model = ctx.getContentModel(content);\n return (model == null ? void 0 : model.join) !== void 0 && ctx.contentIsDeletable(content, contents);\n },\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/lead.plugin.tsx\nfunction getModel(ctx) {\n const LeadContent = ctx.and(ctx.BaseContent("lead"), ctx.StrokeFields, ctx.ArrowFields, ctx.TextFields, {\n ref: ctx.optional(ctx.ContentRef),\n points: [ctx.Position],\n text: ctx.string,\n toleranceSymbolId: ctx.optional(ctx.number),\n bordered: ctx.optional(ctx.boolean)\n });\n const getRefIds = (content) => [...ctx.getStrokeRefIds(content), ...ctx.toRefId(content.ref)];\n const leadCache = new ctx.WeakmapValuesCache();\n function getLeadGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return leadCache.get(content, refs, () => {\n var _a, _b, _c;\n const ref = ctx.getReference(content.ref, contents, (c) => !ctx.shallowEquals(c, content));\n let p0 = content.points[0];\n let line;\n if (ref && content.points.length > 1) {\n const lines2 = (_c = (_b = (_a = ctx.getContentModel(ref)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, ref, contents)) == null ? void 0 : _c.lines;\n if (lines2) {\n const p = ctx.getPerpendicularPointToGeometryLines(content.points[1], lines2);\n if (p) {\n p0 = p.point;\n line = p.line;\n }\n }\n }\n let points;\n let arrow;\n if (content.points.length > 1) {\n const arrowPoints = ctx.getArrowPoints(content.points[1], p0, content);\n arrow = arrowPoints.arrowPoints;\n points = [arrowPoints.endPoint, ...content.points.slice(1)];\n } else {\n points = [];\n }\n let extendLine;\n if (line) {\n const { start, end } = ctx.getGeometryLineStartAndEnd(line);\n if (start && (!end || ctx.getTwoPointsDistance(start, p0) < ctx.getTwoPointsDistance(end, p0))) {\n const param0 = ctx.getGeometryLineParamAtPoint(p0, line, true);\n line = ctx.getPartOfGeometryLine(param0, 0, line);\n const marginParam = ctx.getGeometryLineParamByLength(line, -ctx.dimensionStyle.margin);\n if (marginParam !== void 0) {\n extendLine = ctx.getPartOfGeometryLine(marginParam, 1, line);\n }\n } else if (end && (!start || ctx.getTwoPointsDistance(end, p0) < ctx.getTwoPointsDistance(start, p0))) {\n const param0 = ctx.getGeometryLineParamAtPoint(p0, line);\n line = ctx.getPartOfGeometryLine(param0, 1, line);\n const marginParam = ctx.getGeometryLineParamByLength(line, -ctx.dimensionStyle.margin);\n if (marginParam !== void 0) {\n extendLine = ctx.getPartOfGeometryLine(marginParam, 1, line);\n }\n }\n }\n const size = ctx.getTextSize(ctx.getTextStyleFont(content), content.text);\n if (!size) {\n throw "not supported";\n }\n const previous = content.points[content.points.length - 2];\n const last = content.points[content.points.length - 1];\n const right = !previous || previous.x <= last.x;\n const padding = content.fontSize / 4;\n const toleranceSymbol = content.toleranceSymbolId !== void 0 ? toleranceSymbols[content.toleranceSymbolId] : void 0;\n const width = (size.width + content.fontSize * (toleranceSymbol ? 1 : 0) + padding * (toleranceSymbol ? 4 : 2)) * (right ? 1 : -1);\n const height = Math.max(size.height, content.fontSize) / 2 + padding;\n const textPoints = [\n { x: last.x, y: last.y - height },\n { x: last.x + width, y: last.y - height },\n { x: last.x + width, y: last.y + height },\n { x: last.x, y: last.y + height }\n ];\n const lines = Array.from(ctx.iteratePolylineLines(points));\n const renderingLines = ctx.dashedPolylineToLines(points, content.dashArray);\n if (extendLine) {\n lines.push(extendLine);\n renderingLines.push(...ctx.dashedPolylineToLines(ctx.getGeometryLinesPoints([extendLine])));\n }\n return {\n lines,\n first: p0,\n last,\n right,\n padding,\n bounding: ctx.mergeBoundings([ctx.getGeometryLinesBounding(lines), ctx.getPointsBounding(textPoints)]),\n regions: [\n {\n points: textPoints,\n lines: Array.from(ctx.iteratePolygonLines(textPoints))\n },\n ...arrow ? [{\n points: arrow,\n lines: Array.from(ctx.iteratePolygonLines(arrow))\n }] : []\n ],\n renderingLines\n };\n });\n }\n const React = ctx.React;\n return {\n type: "lead",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n ...ctx.textModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point, offset);\n }\n },\n rotate(content, center, angle) {\n for (const point of content.points) {\n ctx.rotatePoint(point, center, angle);\n }\n },\n scale(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.scalePoint(point, center, sx, sy);\n }\n content.fontSize *= Math.abs(sx);\n },\n mirror(content, line) {\n for (const point of content.points) {\n ctx.mirrorPoint(point, line);\n }\n },\n render(content, renderCtx) {\n const { options, target, contents, fillOptions } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { regions, renderingLines, last, right, padding } = getLeadGeometriesFromCache(content, contents);\n const children = [];\n for (const line of renderingLines) {\n children.push(target.renderPolyline(line, options));\n }\n if (regions && regions.length > 1) {\n children.push(target.renderPolygon(regions[1].points, fillOptions));\n }\n if (content.bordered && regions && regions.length > 0) {\n children.push(target.renderPolygon(regions[0].points, options));\n }\n const textStyleContent = ctx.getTextStyleContent(content, contents);\n const color = renderCtx.transformColor(textStyleContent.color);\n let cacheKey;\n if (renderCtx.isAssistence) {\n cacheKey = ctx.assistentTextCache.get(content.text, textStyleContent.fontSize, textStyleContent.color);\n }\n if (!cacheKey) {\n cacheKey = content;\n }\n let textX = last.x;\n const toleranceSymbol = content.toleranceSymbolId !== void 0 ? toleranceSymbols[content.toleranceSymbolId] : void 0;\n if (toleranceSymbol) {\n children.push(target.renderGroup([\n toleranceSymbol(target, textStyleContent.fontSize, options)\n ], { translate: { x: last.x + textStyleContent.fontSize * (right ? 0 : -1) + padding * (right ? 1 : -1), y: last.y - textStyleContent.fontSize / 2 } }));\n textX += (textStyleContent.fontSize + padding * 2) * (right ? 1 : -1);\n if (content.bordered && regions && regions.length > 0) {\n children.push(target.renderPolyline([{ x: textX, y: regions[0].points[0].y }, { x: textX, y: regions[0].points[2].y }], options));\n }\n }\n textX += padding * (right ? 1 : -1);\n const textOptions = ctx.getTextStyleRenderOptionsFromRenderContext(color, renderCtx);\n children.push(target.renderText(textX, last.y, content.text, color, textStyleContent.fontSize, textStyleContent.fontFamily, { cacheKey, ...textOptions, textBaseline: "middle", textAlign: right ? "left" : "right" }));\n return target.renderGroup(children);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const geometries = getLeadGeometriesFromCache(content, contents);\n return {\n editPoints: content.points.map((p, i) => {\n if (i === 0) {\n p = geometries.first;\n }\n return {\n ...p,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isLeadContent(c)) {\n return;\n }\n c.points[i].x += cursor.x - start.x;\n c.points[i].y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n };\n })\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const geometries = getLeadGeometriesFromCache(content, contents);\n return content.points.map((p, i) => {\n if (i === 0) {\n p = geometries.first;\n }\n return { ...p, type: "endpoint" };\n });\n });\n },\n getGeometries: getLeadGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n var _a;\n return {\n ref: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.ref !== void 0, readOnly: content.ref === void 0, setValue: (v) => update((c) => {\n if (isLeadContent(c) && !v) {\n c.ref = void 0;\n }\n }) }),\n typeof content.ref === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref, setValue: (v) => update((c) => {\n if (isLeadContent(c)) {\n c.ref = v;\n }\n }) }) : void 0\n ],\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { x: 0, y: 0 }, (v) => update((c) => {\n if (isLeadContent(c)) {\n v(c);\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isLeadContent(c)) {\n c.points[i].x = p.x, c.points[i].y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.x, setValue: (v) => update((c) => {\n if (isLeadContent(c)) {\n c.points[i].x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.y, setValue: (v) => update((c) => {\n if (isLeadContent(c)) {\n c.points[i].y = v;\n }\n }) })\n }\n }\n ))\n }\n ),\n text: /* @__PURE__ */ React.createElement(ctx.StringEditor, { textarea: true, value: content.text, setValue: (v) => update((c) => {\n if (isLeadContent(c)) {\n c.text = v;\n }\n }) }),\n toleranceSymbolId: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.toleranceSymbolId !== void 0, setValue: (v) => update((c) => {\n if (isLeadContent(c)) {\n c.toleranceSymbolId = v ? 0 : void 0;\n }\n }) }),\n content.toleranceSymbolId !== void 0 ? /* @__PURE__ */ React.createElement(\n ctx.EnumEditor,\n {\n enums: toleranceSymbols.map((_, i) => i),\n enumTitles: toleranceSymbols.map((s) => ctx.reactSvgRenderTarget.renderResult([s(ctx.reactSvgRenderTarget, 13)], 13, 13)),\n value: content.toleranceSymbolId,\n setValue: (v) => update((c) => {\n if (isLeadContent(c)) {\n c.toleranceSymbolId = v;\n }\n })\n }\n ) : void 0\n ],\n bordered: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: (_a = content.bordered) != null ? _a : false, setValue: (v) => update((c) => {\n if (isLeadContent(c)) {\n c.bordered = v;\n }\n }) }),\n ...ctx.getTextContentPropertyPanel(content, update, contents),\n ...ctx.getArrowContentPropertyPanel(content, update),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n editPanel(content, scale, update, contents, cancel, transformPosition) {\n const p = transformPosition(content.points[content.points.length - 1]);\n const textStyleContent = ctx.getTextStyleContent(content, contents);\n const fontSize = textStyleContent.fontSize * scale;\n return /* @__PURE__ */ React.createElement(\n ctx.StringEditor,\n {\n style: {\n zIndex: 10,\n position: "absolute",\n left: `${p.x - 1}px`,\n top: `${p.y - fontSize - 1}px`,\n fontSize: `${fontSize}px`,\n fontFamily: content.fontFamily,\n color: ctx.getColorString(content.color),\n padding: "0px"\n },\n textarea: true,\n autoFocus: true,\n onCancel: cancel,\n value: content.text,\n setValue: (v) => {\n update((c) => {\n if (isLeadContent(c)) {\n c.text = v;\n }\n });\n }\n }\n );\n },\n isValid: (c, p) => ctx.validate(c, LeadContent, p),\n getRefIds,\n updateRefId(content, update) {\n if (content.ref !== void 0) {\n const newRefId = update(content.ref);\n if (newRefId !== void 0) {\n content.ref = newRefId;\n }\n }\n ctx.updateStrokeRefIds(content, update);\n },\n deleteRefId(content, ids) {\n if (content.ref && ids.includes(content.ref)) {\n content.ref = void 0;\n }\n ctx.deleteStrokeRefIds(content, ids);\n }\n };\n}\nfunction isLeadContent(content) {\n return content.type === "lead";\n}\nvar toleranceSymbols = [\n (target, size, options) => target.renderPolyline([{ x: 0, y: size * 0.5 }, { x: size, y: size * 0.5 }], options),\n (target, size, options) => target.renderPolygon([{ x: 0, y: size }, { x: size * 0.7, y: size }, { x: size, y: 0 }, { x: size * 0.3, y: 0 }], options),\n (target, size, options) => target.renderCircle(size * 0.5, size * 0.5, size * 0.48, options),\n (target, size, options) => target.renderGroup([\n target.renderCircle(size * 0.5, size * 0.5, size * 0.25, options),\n target.renderPolyline([{ x: 0, y: size }, { x: size * 0.4, y: 0 }], options),\n target.renderPolyline([{ x: size, y: 0 }, { x: size * 0.6, y: size }], options)\n ]),\n (target, size, options) => target.renderArc(size * 0.5, size * 0.7, size * 0.48, -180, 0, options),\n (target, size, options) => target.renderArc(size * 0.5, size * 0.7, size * 0.48, -180, 0, { ...options, closed: true }),\n (target, size, options) => target.renderGroup([\n target.renderPolyline([{ x: 0, y: size }, { x: size * 0.4, y: 0 }], options),\n target.renderPolyline([{ x: size, y: 0 }, { x: size * 0.6, y: size }], options)\n ]),\n (target, size, options) => target.renderGroup([\n target.renderPolyline([{ x: 0, y: size }, { x: size, y: size }], options),\n target.renderPolyline([{ x: size * 0.5, y: 0 }, { x: size * 0.5, y: size }], options)\n ]),\n (target, size, options) => target.renderPolyline([{ x: size, y: size }, { x: 0, y: size }, { x: size, y: 0 }], options),\n (target, size, options) => target.renderGroup([\n target.renderCircle(size * 0.5, size * 0.5, size * 0.25, options),\n target.renderPolyline([{ x: size * 0.5, y: 0 }, { x: size * 0.5, y: size }], options),\n target.renderPolyline([{ x: 0, y: size * 0.5 }, { x: size, y: size * 0.5 }], options)\n ]),\n (target, size, options) => target.renderGroup([\n target.renderCircle(size * 0.5, size * 0.5, size * 0.25, options),\n target.renderCircle(size * 0.5, size * 0.5, size * 0.45, options)\n ]),\n (target, size, options) => target.renderGroup([\n target.renderPolyline([{ x: 0, y: size * 0.5 }, { x: size, y: size * 0.5 }], options),\n target.renderPolyline([{ x: size * 0.25, y: size * 0.25 }, { x: size * 0.75, y: size * 0.25 }], options),\n target.renderPolyline([{ x: size * 0.25, y: size * 0.75 }, { x: size * 0.75, y: size * 0.75 }], options)\n ]),\n (target, size, options) => target.renderGroup([\n target.renderPolyline([{ x: size * 0.2, y: size }, { x: size * 0.8, y: 0 }], options),\n target.renderPolyline([{ x: size * 0.35, y: size * 0.4 }, { x: size * 0.8, y: 0 }, { x: size * 0.65, y: size * 0.55 }], options)\n ]),\n (target, size, options) => target.renderGroup([\n target.renderPolyline([{ x: size * 0.4, y: 0 }, { x: 0, y: size }, { x: size * 0.6, y: size }, { x: size, y: 0 }], options),\n target.renderPolyline([{ x: 0, y: size * 0.4 }, { x: size * 0.4, y: 0 }, { x: size * 0.35, y: size * 0.55 }], options),\n target.renderPolyline([{ x: size * 0.6, y: size * 0.4 }, { x: size, y: 0 }, { x: size * 0.95, y: size * 0.55 }], options)\n ])\n];\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "47,4 96,4", strokeWidth: "8", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "71,4 71,54", strokeWidth: "8", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "46,29 5,92", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "0,100 12,62 30,73", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "create lead",\n icon,\n useCommand({ onEnd, type, scale, textStyleId, transformPosition, contents }) {\n const [lead, setLead] = React.useState();\n const [editText, setEditText] = React.useState(false);\n let message = "";\n if (type && !editText) {\n message = "press Enter to end";\n }\n const { input, clearText, setCursorPosition, setInputPosition, resetInput } = ctx.useCursorInput(message, type ? (e, text) => {\n if (e.key === "Enter") {\n if (text) {\n clearText();\n } else if (lead) {\n setEditText(true);\n setLead(ctx.produce(lead, (draft) => {\n draft.text = "";\n draft.points.splice(draft.points.length - 1, 1);\n }));\n e.preventDefault();\n }\n }\n } : void 0);\n const reset = () => {\n setLead(void 0);\n resetInput();\n setEditText(false);\n };\n const assistentContents = [];\n let panel;\n if (type) {\n if (lead) {\n assistentContents.push(lead);\n if (editText) {\n const last = lead.points[lead.points.length - 1];\n const p = transformPosition(last);\n const textStyleContent = ctx.getTextStyleContent(lead, contents);\n const fontSize = textStyleContent.fontSize * scale;\n panel = /* @__PURE__ */ React.createElement(\n ctx.StringEditor,\n {\n style: {\n zIndex: 10,\n position: "absolute",\n left: `${p.x - 1}px`,\n top: `${p.y - fontSize - 1}px`,\n fontSize: `${fontSize}px`,\n fontFamily: lead.fontFamily,\n color: ctx.getColorString(lead.color),\n padding: "0px"\n },\n textarea: true,\n autoFocus: true,\n onCancel: reset,\n value: lead.text,\n setValue: (v) => {\n setLead(ctx.produce(lead, (draft) => {\n draft.text = v;\n }));\n }\n }\n );\n }\n }\n }\n return {\n input,\n onStart: (p, target) => {\n if (!type)\n return;\n if (!lead) {\n setLead({\n type: "lead",\n text: "abc",\n textStyleId,\n color: 0,\n fontSize: 16 / scale,\n fontFamily: "monospace",\n points: [p, p],\n ref: target == null ? void 0 : target.id\n });\n } else if (editText) {\n onEnd({\n updateContents: (contents2) => contents2.push(lead)\n });\n reset();\n } else {\n const last = lead.points[lead.points.length - 1];\n setLead(ctx.produce(lead, (draft) => {\n draft.points.push(last);\n }));\n }\n },\n onMove(p, viewportPosition) {\n if (!type)\n return;\n if (editText)\n return;\n setInputPosition(viewportPosition || p);\n setCursorPosition(p);\n if (lead) {\n setLead(ctx.produce(lead, (draft) => {\n draft.points[lead.points.length - 1] = p;\n }));\n }\n },\n assistentContents,\n reset,\n panel\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isLeadContent\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/line-polyline.plugin.tsx\nfunction getModel(ctx) {\n const LineContent = ctx.and(ctx.BaseContent(ctx.or("line", "polyline")), ctx.StrokeFields, ctx.FillFields, {\n points: ctx.minItems(2, [ctx.Position])\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getPolylineGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n const lines = Array.from(ctx.iteratePolylineLines(content.points));\n return {\n lines,\n points: content.points,\n bounding: ctx.getPointsBounding(content.points),\n renderingLines: ctx.dashedPolylineToLines(content.points, content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points: content.points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n const lineModel = {\n type: "line",\n ...ctx.strokeModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point, offset);\n }\n },\n rotate(content, center, angle) {\n for (const point of content.points) {\n ctx.rotatePoint(point, center, angle);\n }\n },\n scale(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.scalePoint(point, center, sx, sy);\n }\n },\n skew(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.skewPoint(point, center, sx, sy);\n }\n },\n mirror(content, line) {\n for (const point of content.points) {\n ctx.mirrorPoint(point, line);\n }\n },\n break(content, intersectionPoints, contents) {\n const { lines } = getPolylineGeometries(content, contents);\n return ctx.breakPolyline(lines, intersectionPoints);\n },\n offset(content, point, distance, contents) {\n const { lines } = getPolylineGeometries(content, contents);\n if (!distance) {\n distance = Math.min(...lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n const index = ctx.getLinesOffsetDirection(point, lines);\n const points = ctx.getParallelPolylineByDistance(lines, distance, index);\n return ctx.trimOffsetResult(points, point, false, contents).map((p) => ctx.produce(content, (d) => {\n d.points = p;\n }));\n },\n join(content, target, contents) {\n if (isLineContent(target) || isPolyLineContent(target)) {\n const lines = [\n ...getPolylineGeometries(content, contents).lines.map((n) => ({ type: "line", points: [...n] })),\n ...getPolylineGeometries(target, contents).lines.map((n) => ({ type: "line", points: [...n] }))\n ];\n ctx.mergePolylines(lines);\n if (lines.length === 1) {\n return {\n ...content,\n points: lines[0].points\n };\n }\n }\n if (isArcContent(target)) {\n const newLines = ctx.mergeGeometryLines([{ type: "arc", curve: target }], getPolylineGeometries(content, contents).lines);\n if (newLines) {\n return ctx.geometryLinesToPline(newLines);\n }\n }\n return;\n },\n extend(content, point, contents) {\n const { lines } = getPolylineGeometries(content, contents);\n if (ctx.pointIsOnRay(point, { ...lines[0][0], angle: ctx.radianToAngle(ctx.getTwoPointsRadian(lines[0][0], lines[0][1])) })) {\n content.points[0] = point;\n } else {\n content.points[content.points.length - 1] = point;\n }\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderPolyline(content.points, options);\n },\n getOperatorRenderPosition(content) {\n return content.points[0];\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => ({ editPoints: ctx.getPolylineEditPoints(content, isLineContent) }));\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points, lines } = getPolylineGeometries(content, contents);\n return [\n ...points.map((p) => ({ ...p, type: "endpoint" })),\n ...lines.map(([start, end]) => ({\n x: (start.x + end.x) / 2,\n y: (start.y + end.y) / 2,\n type: "midpoint"\n }))\n ];\n });\n },\n getGeometries: getPolylineGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { x: 0, y: 0 }, (v) => update((c) => {\n if (isLineContent(c)) {\n v(c);\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isLineContent(c)) {\n c.points[i].x = p.x, c.points[i].y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.x, setValue: (v) => update((c) => {\n if (isLineContent(c)) {\n c.points[i].x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.y, setValue: (v) => update((c) => {\n if (isLineContent(c)) {\n c.points[i].y = v;\n }\n }) })\n }\n }\n ))\n }\n ),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, LineContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n reverse: (content) => ({\n ...content,\n points: content.points.slice().reverse()\n })\n };\n return [\n lineModel,\n {\n ...lineModel,\n type: "polyline",\n ...ctx.fillModel,\n explode(content, contents) {\n const { lines } = getPolylineGeometries(content, contents);\n return lines.map((line) => ({ type: "line", points: line }));\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderPolyline(content.points, options);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => ({ editPoints: ctx.getPolylineEditPoints(content, isPolyLineContent) }));\n },\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { x: 0, y: 0 }, (v) => update((c) => {\n if (isPolyLineContent(c)) {\n v(c);\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPolyLineContent(c)) {\n c.points[i].x = p.x, c.points[i].y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.x, setValue: (v) => update((c) => {\n if (isPolyLineContent(c)) {\n c.points[i].x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.y, setValue: (v) => update((c) => {\n if (isPolyLineContent(c)) {\n c.points[i].y = v;\n }\n }) })\n }\n }\n ))\n }\n ),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n }\n }\n ];\n}\nfunction isLineContent(content) {\n return content.type === "line";\n}\nfunction isPolyLineContent(content) {\n return content.type === "polyline";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon1 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "10", cy: "87", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }), /* @__PURE__ */ React.createElement("circle", { cx: "87", cy: "9", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }), /* @__PURE__ */ React.createElement("polyline", { points: "10,87 87,9", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n const icon2 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "12,86 38,24 62,64 88,13", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return [\n {\n name: "create line",\n useCommand({ onEnd, scale, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, inputMode, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create line",\n (c) => onEnd({\n updateContents: (contents) => contents.push(...Array.from(ctx.iteratePolylineLines(c)).map((line2) => ({ points: line2, strokeStyleId, fillStyleId, type: "line" })))\n })\n );\n const assistentContents = [];\n if (line && line.length > 1) {\n const start = line[line.length - 2];\n const end = line[line.length - 1];\n const r = ctx.getTwoPointsDistance(start, end);\n const angle = ctx.radianToAngle(ctx.getTwoPointsRadian(end, start));\n assistentContents.push(\n {\n type: "arc",\n x: start.x,\n y: start.y,\n r,\n dashArray: [4 / scale],\n startAngle: angle > 180 || angle < 0 ? angle : 0,\n endAngle: angle > 180 || angle < 0 ? 0 : angle\n },\n {\n type: "line",\n dashArray: [4 / scale],\n points: [start, { x: start.x + r, y: start.y }]\n },\n ...ctx.getAssistentText(\n r.toFixed(2),\n 16 / scale,\n (start.x + end.x) / 2 - 20,\n (start.y + end.y) / 2 + 4,\n inputMode === "length" ? 16711680 : 16764108\n ),\n ...ctx.getAssistentText(\n `${angle.toFixed(1)}\\xB0`,\n 16 / scale,\n end.x + 10,\n end.y - 10,\n inputMode === "angle" ? 16711680 : 16764108\n )\n );\n }\n if (line) {\n for (const lineSegment of ctx.iteratePolylineLines(line)) {\n assistentContents.push({ points: lineSegment, strokeStyleId, fillStyleId, type: "line" });\n }\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0,\n hotkey: "L",\n icon: icon1\n },\n {\n name: "create polyline",\n useCommand({ onEnd, scale, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, inputMode, lastPosition, reset, positions } = ctx.useLineClickCreate(\n type === "create polyline",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ points: c, strokeStyleId, fillStyleId, type: "polyline" })\n })\n );\n const assistentContents = [];\n if (line && line.length > 1) {\n const start = line[line.length - 2];\n const end = line[line.length - 1];\n const r = ctx.getTwoPointsDistance(start, end);\n const angle = ctx.radianToAngle(ctx.getTwoPointsRadian(end, start));\n assistentContents.push(\n {\n type: "arc",\n x: start.x,\n y: start.y,\n r,\n dashArray: [4 / scale],\n startAngle: angle > 180 || angle < 0 ? angle : 0,\n endAngle: angle > 180 || angle < 0 ? 0 : angle\n },\n {\n type: "line",\n dashArray: [4 / scale],\n points: [start, { x: start.x + r, y: start.y }]\n },\n ...ctx.getAssistentText(\n r.toFixed(2),\n 16 / scale,\n (start.x + end.x) / 2 - 20,\n (start.y + end.y) / 2 + 4,\n inputMode === "length" ? 16711680 : 16764108\n ),\n ...ctx.getAssistentText(\n `${angle.toFixed(1)}\\xB0`,\n 16 / scale,\n end.x + 10,\n end.y - 10,\n inputMode === "angle" ? 16711680 : 16764108\n )\n );\n }\n if (line) {\n assistentContents.push({ points: line, strokeStyleId, fillStyleId, type: "polyline" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset,\n subcommand: type === "create polyline" && positions.length > 2 ? /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(\n "button",\n {\n onClick: () => {\n onEnd({\n updateContents: (contents) => contents.push({ points: positions, type: "polygon" })\n });\n reset();\n },\n style: { position: "relative" }\n },\n "close"\n )) : void 0\n };\n },\n selectCount: 0,\n hotkey: "PL",\n icon: icon2\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isLineContent,\n isPolyLineContent\n};\n','// dev/cad-editor/plugins/linear-dimension.plugin.tsx\nfunction getModel(ctx) {\n const LinearDimensionContent = ctx.and(ctx.BaseContent("linear dimension"), ctx.StrokeFields, ctx.ArrowFields, ctx.LinearDimension, {\n ref1: ctx.optional(ctx.PositionRef),\n ref2: ctx.optional(ctx.PositionRef)\n });\n const getRefIds = (content) => {\n var _a, _b;\n return [...ctx.getStrokeRefIds(content), ...ctx.toRefIds([(_a = content.ref1) == null ? void 0 : _a.id, (_b = content.ref2) == null ? void 0 : _b.id])];\n };\n const linearDimensionCache = new ctx.WeakmapValuesCache();\n const getLinearDimensionPositions = (content, contents) => {\n var _a, _b;\n const p1 = (_a = ctx.getRefPosition(content.ref1, contents, [content])) != null ? _a : content.p1;\n const p2 = (_b = ctx.getRefPosition(content.ref2, contents, [content])) != null ? _b : content.p2;\n return { p1, p2 };\n };\n function getLinearDimensionGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return linearDimensionCache.get(content, refs, () => {\n var _a, _b;\n const { p1, p2 } = getLinearDimensionPositions(content, contents);\n return ctx.getLinearDimensionGeometries({ ...content, p1, p2 }, {\n arrowAngle: (_a = content.arrowAngle) != null ? _a : ctx.dimensionStyle.arrowAngle,\n arrowSize: (_b = content.arrowSize) != null ? _b : ctx.dimensionStyle.arrowSize,\n margin: ctx.dimensionStyle.margin\n }, (c) => getTextPosition(c, contents));\n });\n }\n const textPositionMap = new ctx.WeakmapCache3();\n function getTextPosition(content, contents) {\n const { p1, p2 } = getLinearDimensionPositions(content, contents);\n return textPositionMap.get(content, p1, p2, () => {\n return ctx.getLinearDimensionTextPosition({ ...content, p1, p2 }, ctx.dimensionStyle.margin, ctx.getTextSizeFromCache);\n });\n }\n const React = ctx.React;\n return {\n type: "linear dimension",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n move(content, offset) {\n ctx.movePoint(content.p1, offset);\n ctx.movePoint(content.p2, offset);\n ctx.movePoint(content.position, offset);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content.p1, center, sx, sy);\n ctx.scalePoint(content.p2, center, sx, sy);\n ctx.scalePoint(content.position, center, sx, sy);\n },\n render(content, renderCtx) {\n const { options, fillOptions, contents, target, strokeColor } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { regions, lines } = getLinearDimensionGeometriesFromCache(content, contents);\n const children = [];\n for (const line of lines) {\n children.push(target.renderPolyline(line, options));\n }\n if (regions) {\n for (let i = 0; i < 2 && i < regions.length; i++) {\n children.push(target.renderPolygon(regions[i].points, fillOptions));\n }\n }\n const { textPosition, text, textRotation } = getTextPosition(content, contents);\n const textOptions = ctx.getTextStyleRenderOptionsFromRenderContext(strokeColor, renderCtx);\n children.push(target.renderGroup(\n [\n target.renderText(textPosition.x, textPosition.y, text, strokeColor, content.fontSize, content.fontFamily, { cacheKey: content, ...textOptions })\n ],\n {\n rotation: textRotation,\n base: textPosition\n }\n ));\n return target.renderGroup(children);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { p1, p2 } = getLinearDimensionPositions(content, contents);\n return {\n editPoints: [\n {\n x: content.position.x,\n y: content.position.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isLinearDimensionContent(c)) {\n return;\n }\n c.position.x += cursor.x - start.x;\n c.position.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: p1.x,\n y: p1.y,\n cursor: "move",\n update(c, { cursor, start, scale, target }) {\n if (!isLinearDimensionContent(c)) {\n return;\n }\n c.p1.x = cursor.x;\n c.p1.y = cursor.y;\n c.ref1 = ctx.getSnapTargetRef(target, contents);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: p2.x,\n y: p2.y,\n cursor: "move",\n update(c, { cursor, start, scale, target }) {\n if (!isLinearDimensionContent(c)) {\n return;\n }\n c.p2.x = cursor.x;\n c.p2.y = cursor.y;\n c.ref2 = ctx.getSnapTargetRef(target, contents);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getLinearDimensionGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n var _a, _b;\n return {\n p1: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p, ref) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.p1.x = p.x;\n c.p1.y = p.y;\n c.ref1 = ref;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p1.x, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.p1.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p1.y, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.p1.y = v;\n }\n }) })\n }\n }\n ),\n p2: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p, ref) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.p2.x = p.x;\n c.p2.y = p.y;\n c.ref2 = ref;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p2.x, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.p2.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.p2.y, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.p2.y = v;\n }\n }) })\n }\n }\n ),\n ref1: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.ref1 !== void 0, readOnly: content.ref1 === void 0, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c) && !v) {\n c.ref1 = void 0;\n }\n }) }),\n content.ref1 !== void 0 && typeof content.ref1.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref1.id, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c) && c.ref1) {\n c.ref1.id = v;\n }\n }) }) : void 0,\n content.ref1 !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref1.snapIndex, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c) && c.ref1) {\n c.ref1.snapIndex = v;\n }\n }) }) : void 0,\n ((_a = content.ref1) == null ? void 0 : _a.param) !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { readOnly: true, value: content.ref1.param }) : void 0\n ],\n ref2: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.ref2 !== void 0, readOnly: content.ref2 === void 0, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c) && !v) {\n c.ref2 = void 0;\n }\n }) }),\n content.ref2 !== void 0 && typeof content.ref2.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref2.id, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c) && c.ref2) {\n c.ref2.id = v;\n }\n }) }) : void 0,\n content.ref2 !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref2.snapIndex, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c) && c.ref2) {\n c.ref2.snapIndex = v;\n }\n }) }) : void 0,\n ((_b = content.ref2) == null ? void 0 : _b.param) !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { readOnly: true, value: content.ref2.param }) : void 0\n ],\n position: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.position.x = p.x, c.position.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.position.x, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.position.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.position.y, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.position.y = v;\n }\n }) })\n }\n }\n ),\n direct: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.direct === true, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.direct = v ? true : void 0;\n }\n }) }),\n text: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.text !== void 0, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.text = v ? "" : void 0;\n }\n }) }),\n content.text !== void 0 ? /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.text, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.text = v;\n }\n }) }) : void 0\n ],\n fontSize: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.fontSize, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.fontSize = v;\n }\n }) }),\n fontFamily: /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.fontFamily, setValue: (v) => update((c) => {\n if (isLinearDimensionContent(c)) {\n c.fontFamily = v;\n }\n }) }),\n ...ctx.getArrowContentPropertyPanel(content, update),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, LinearDimensionContent, p),\n getRefIds,\n updateRefId(content, update) {\n if (content.ref1) {\n const newRefId = update(content.ref1.id);\n if (newRefId !== void 0) {\n content.ref1.id = newRefId;\n }\n }\n if (content.ref2) {\n const newRefId = update(content.ref2.id);\n if (newRefId !== void 0) {\n content.ref2.id = newRefId;\n }\n }\n ctx.updateStrokeRefIds(content, update);\n },\n deleteRefId(content, ids) {\n if (content.ref1 && ids.includes(content.ref1.id)) {\n content.ref1 = void 0;\n }\n if (content.ref2 && ids.includes(content.ref2.id)) {\n content.ref2 = void 0;\n }\n ctx.deleteStrokeRefIds(content, ids);\n }\n };\n}\nfunction isLinearDimensionContent(content) {\n return content.type === "linear dimension";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "15", cy: "83", r: "10", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "82", cy: "84", r: "10", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "15,83 14,7", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "82,84 82,6", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "14,25 81,25", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "66,34 83,24 65,15", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "29,34 12,25 29,15", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "create linear dimension",\n selectCount: 0,\n useCommand({ onEnd, type, scale, strokeStyleId }) {\n const [p1, setP1] = React.useState();\n const [p2, setP2] = React.useState();\n const [p1Target, setP1Target] = React.useState();\n const [p2Target, setP2Target] = React.useState();\n const [direct, setDirect] = React.useState(false);\n const [result, setResult] = React.useState();\n const [text, setText] = React.useState();\n let message = "";\n if (type) {\n message = "input text";\n }\n const { input, cursorPosition, setCursorPosition, clearText, setInputPosition, resetInput } = ctx.useCursorInput(message, type ? (e, text2) => {\n if (e.key === "Enter") {\n setText(text2);\n if (result) {\n setResult({ ...result, text: text2 });\n }\n clearText();\n }\n } : void 0);\n const reset = () => {\n setP1(void 0);\n setP2(void 0);\n setP1Target(void 0);\n setP2Target(void 0);\n setResult(void 0);\n resetInput();\n setText(void 0);\n };\n const assistentContents = [];\n if (result) {\n assistentContents.push(result);\n } else if (p1 && cursorPosition) {\n assistentContents.push({ type: "line", points: [p1, cursorPosition], dashArray: [4 / scale] });\n }\n return {\n input,\n reset,\n onStart(p, target) {\n if (!p1) {\n setP1(p);\n setP1Target(target);\n } else if (!p2) {\n setP2(p);\n setP2Target(target);\n } else if (result) {\n onEnd({\n updateContents: (contents) => {\n contents.push(result);\n },\n nextCommand: type\n });\n reset();\n }\n },\n onMove(p, viewportPosition) {\n setInputPosition(viewportPosition || p);\n setCursorPosition(p);\n if (type && p1 && p2) {\n setResult({\n type: "linear dimension",\n position: p,\n p1,\n p2,\n ref1: p1Target,\n ref2: p2Target,\n strokeStyleId,\n direct,\n fontSize: 16,\n fontFamily: "monospace",\n text\n });\n }\n },\n subcommand: type ? /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("button", { onClick: () => {\n if (result) {\n setResult({ ...result, direct: !direct });\n }\n setDirect(!direct);\n }, style: { position: "relative" } }, direct ? "direct" : "axis")) : void 0,\n assistentContents,\n lastPosition: p2 != null ? p2 : p1\n };\n },\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isLinearDimensionContent\n};\n','// dev/cad-editor/plugins/measure.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "9,14 43,92", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "94,14 93,21 92,28 91,36 88,43 86,49 82,56 78,62 74,68 69,74 63,79 57,83 51,87 44,91", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "9,14 94,14", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "measure",\n useCommand({ transform, type, scale }) {\n const { onStart, mask, startPosition, resetDragMove } = ctx.useDragMove(void 0, {\n transform,\n ignoreLeavingEvent: true\n });\n let message = "";\n if (type) {\n message = startPosition ? "specify end point" : "specify start point";\n }\n const { input, setInputPosition, cursorPosition, setCursorPosition, resetInput } = ctx.useCursorInput(message);\n const reset = () => {\n resetDragMove();\n resetInput();\n };\n const assistentContents = [];\n if (startPosition && cursorPosition) {\n const start = startPosition;\n const end = cursorPosition;\n const r = ctx.getTwoPointsDistance(start, end);\n const angle = ctx.radianToAngle(ctx.getTwoPointsRadian(end, start));\n assistentContents.push(\n {\n type: "arc",\n x: start.x,\n y: start.y,\n r,\n dashArray: [4 / scale],\n startAngle: angle > 180 || angle < 0 ? angle : 0,\n endAngle: angle > 180 || angle < 0 ? 0 : angle\n },\n {\n type: "line",\n dashArray: [4 / scale],\n points: [start, { x: start.x + r, y: start.y }]\n },\n ...ctx.getAssistentText(\n r.toFixed(2),\n 16 / scale,\n (start.x + end.x) / 2 - 20,\n (start.y + end.y) / 2 + 4\n ),\n ...ctx.getAssistentText(\n `${angle.toFixed(1)}\\xB0`,\n 16 / scale,\n end.x + 10,\n end.y - 10\n ),\n {\n type: "line",\n points: [startPosition, cursorPosition]\n }\n );\n }\n return {\n onStart: (s) => onStart(s),\n mask,\n input,\n reset,\n onMove(p, viewportPosition) {\n setCursorPosition(p);\n setInputPosition(viewportPosition != null ? viewportPosition : p);\n },\n assistentContents\n };\n },\n selectCount: 0,\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/mirror.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "9,91 38,46 9,10", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "50,0 50,100", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "90,91 62,46 91,10", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "mirror",\n useCommand({ onEnd, transform, type, scale }) {\n const [changeOriginal, setChangeOriginal] = React.useState(false);\n const { offset, onStart, mask, startPosition, resetDragMove } = ctx.useDragMove(onEnd, {\n transform,\n ignoreLeavingEvent: true\n });\n let message = "";\n if (type) {\n message = startPosition ? "specify second point" : "specify first point";\n }\n const { input, setInputPosition, clearText, setCursorPosition, resetInput } = ctx.useCursorInput(message, type ? (e, text) => {\n if (e.key === "Enter") {\n if (text.toLowerCase() === "y" || text.toLowerCase() === "n") {\n setChangeOriginal(!changeOriginal);\n clearText();\n }\n }\n } : void 0);\n const reset = () => {\n resetDragMove();\n resetInput();\n };\n return {\n onStart: (s) => onStart(s),\n mask: type ? mask : void 0,\n input,\n reset,\n subcommand: type ? /* @__PURE__ */ React.createElement(\n "button",\n {\n onClick: (e) => {\n setChangeOriginal(!changeOriginal);\n e.stopPropagation();\n }\n },\n changeOriginal ? "create new(N)" : "change original(Y)"\n ) : void 0,\n updateSelectedContent(content, contents, selected) {\n if (startPosition && offset && (offset.x !== 0 || offset.y !== 0)) {\n const end = { x: startPosition.x + offset.x, y: startPosition.y + offset.y };\n const line = ctx.twoPointLineToGeneralFormLine(startPosition, end);\n if (!line)\n return {};\n const angle = ctx.radianToAngle(ctx.getTwoPointsRadian(end, startPosition));\n if (changeOriginal) {\n const [newContent, ...patches] = ctx.produceWithPatches(content, (draft) => {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.mirror) == null ? void 0 : _b.call(_a, draft, line, angle, contents);\n });\n const assistentContents = ctx.updateReferencedContents(content, newContent, contents, selected);\n return {\n patches,\n assistentContents\n };\n }\n return {\n newContents: [\n ctx.produce(content, (d) => {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(d)) == null ? void 0 : _a.mirror) == null ? void 0 : _b.call(_a, d, line, angle, contents);\n })\n ]\n };\n }\n return {};\n },\n onMove(p, viewportPosition) {\n setCursorPosition(p);\n setInputPosition(viewportPosition || p);\n },\n assistentContents: startPosition && offset && (offset.x !== 0 || offset.y !== 0) ? [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [startPosition, { x: startPosition.x + offset.x, y: startPosition.y + offset.y }]\n }\n ] : void 0\n };\n },\n contentSelectable(content) {\n var _a;\n return !content.readonly && ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.mirror) !== void 0;\n },\n hotkey: "MI",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/move.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "9,60 55,60 55,91 9,91", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "44", y: "10", width: "46", height: "31", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "move",\n useCommand({ onEnd, transform, type, scale }) {\n const { offset, onStart, mask, startPosition, resetDragMove } = ctx.useDragMove(onEnd, {\n transform,\n ignoreLeavingEvent: true\n });\n let message = "";\n if (type) {\n message = startPosition ? "specify end point" : "specify start point";\n }\n const { input, setInputPosition, resetInput } = ctx.useCursorInput(message);\n const reset = () => {\n resetDragMove();\n resetInput();\n };\n return {\n onStart: (s) => onStart(s),\n mask,\n input,\n onMove(_, p) {\n setInputPosition(p);\n },\n reset,\n updateSelectedContent(content, contents, selected) {\n if (startPosition && (offset.x !== 0 || offset.y !== 0)) {\n const [newContent, ...patches] = ctx.produceWithPatches(content, (draft) => {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.move) == null ? void 0 : _b.call(_a, draft, offset);\n });\n const assistentContents = ctx.updateReferencedContents(content, newContent, contents, selected);\n return {\n patches,\n assistentContents\n };\n }\n return {};\n },\n assistentContents: startPosition && (offset.x !== 0 || offset.y !== 0) ? [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [startPosition, { x: startPosition.x + offset.x, y: startPosition.y + offset.y }]\n }\n ] : void 0\n };\n },\n contentSelectable(content) {\n var _a;\n return !content.readonly && ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.move) !== void 0;\n },\n hotkey: "M",\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/nurbs.plugin.tsx\nfunction getModel(ctx) {\n const NurbsContent = ctx.and(ctx.BaseContent("nurbs"), ctx.StrokeFields, ctx.FillFields, ctx.SegmentCountFields, ctx.Nurbs);\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getNurbsGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n var _a;\n let points;\n const nurbsSegmentCount = (_a = content.segmentCount) != null ? _a : ctx.defaultSegmentCount;\n let lines;\n if (content.points.length > 2) {\n if (!content.weights && !content.knots && (content.degree === 2 || content.points.length === 3)) {\n lines = ctx.getQuadraticSplineCurves(content.points).map((c) => ({ type: "quadratic curve", curve: c }));\n points = ctx.getGeometryLinesPoints(lines, nurbsSegmentCount);\n } else if (!content.weights && !content.knots && content.degree === 3) {\n lines = ctx.getBezierSplineCurves(content.points, false).map((c) => ({ type: "bezier curve", curve: c }));\n points = ctx.getGeometryLinesPoints(lines, nurbsSegmentCount);\n } else if (!content.weights && !content.knots && content.degree === 1) {\n points = content.points;\n lines = Array.from(ctx.iteratePolylineLines(points));\n } else {\n lines = [{\n type: "nurbs curve",\n curve: {\n degree: content.degree,\n points: content.points,\n knots: content.knots || ctx.getDefaultNurbsKnots(content.points.length, content.degree),\n weights: content.weights\n }\n }];\n points = ctx.getGeometryLinesPoints(lines, nurbsSegmentCount);\n }\n } else {\n points = content.points;\n lines = Array.from(ctx.iteratePolylineLines(points));\n }\n return {\n lines,\n points,\n bounding: ctx.getGeometryLinesBounding(lines),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points: content.points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n const nurbsModel = {\n type: "nurbs",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n ...ctx.segmentCountModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point, offset);\n }\n },\n rotate(content, center, angle) {\n for (const point of content.points) {\n ctx.rotatePoint(point, center, angle);\n }\n },\n mirror(content, line) {\n for (const point of content.points) {\n ctx.mirrorPoint(point, line);\n }\n },\n break(content, intersectionPoints, contents) {\n const lines = getNurbsGeometries(content, contents).lines;\n const result = ctx.breakGeometryLines(lines, intersectionPoints);\n return result.map((r) => r.map((t) => ctx.geometryLineToContent(t))).flat();\n },\n offset(content, point, distance, contents) {\n const lines = getNurbsGeometries(content, contents).lines;\n return ctx.trimGeometryLines(ctx.getParallelGeometryLinesByDistancePoint(point, lines, distance)).map((r) => ctx.geometryLineToContent(r));\n },\n render(content, renderCtx) {\n const { points } = getNurbsGeometries(content, renderCtx.contents);\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderPolyline(points, options);\n },\n renderIfSelected(content, { color, target, strokeWidth }) {\n return target.renderPolyline(content.points, { strokeColor: color, dashArray: [4], strokeWidth });\n },\n getOperatorRenderPosition(content) {\n return content.points[0];\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => ({ editPoints: ctx.getPolylineEditPoints(content, isNurbsContent, false, true) }));\n },\n getSnapPoints(content) {\n return ctx.getSnapPointsFromCache(content, () => content.points.map((p) => ({ ...p, type: "endpoint" })));\n },\n getGeometries: getNurbsGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { x: 0, y: 0 }, (v) => update((c) => {\n if (isNurbsContent(c)) {\n v(c);\n if (c.points.length !== content.points.length) {\n c.knots = void 0;\n c.weights = void 0;\n }\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isNurbsContent(c)) {\n c.points[i].x = p.x, c.points[i].y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.x, setValue: (v) => update((c) => {\n if (isNurbsContent(c)) {\n c.points[i].x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.y, setValue: (v) => update((c) => {\n if (isNurbsContent(c)) {\n c.points[i].y = v;\n }\n }) })\n }\n }\n ))\n }\n ),\n degree: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.degree, setValue: (v) => update((c) => {\n if (isNurbsContent(c) && Number.isInteger(v) && v >= 1) {\n c.degree = v;\n c.knots = void 0;\n }\n }) }),\n knots: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.knots !== void 0, setValue: (v) => update((c) => {\n if (isNurbsContent(c)) {\n c.knots = v ? ctx.getDefaultNurbsKnots(content.points.length, content.degree) : void 0;\n }\n }) }),\n content.knots !== void 0 ? /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.knots || [], () => content.knots && content.knots.length > 0 ? content.knots[content.knots.length - 1] + 1 : 0, (v) => update((c) => {\n if (isNurbsContent(c)) {\n v(c);\n }\n })),\n items: content.knots.map((f, i) => /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f, setValue: (v) => update((c) => {\n if (isNurbsContent(c) && c.knots) {\n c.knots[i] = v;\n }\n }) }))\n }\n ) : void 0\n ],\n weights: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.weights !== void 0, setValue: (v) => update((c) => {\n if (isNurbsContent(c)) {\n c.weights = v ? ctx.getDefaultWeights(content.points.length) : void 0;\n }\n }) }),\n content.weights !== void 0 ? /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.weights || [], 1, (v) => update((c) => {\n if (isNurbsContent(c)) {\n v(c);\n }\n })),\n items: content.weights.map((f, i) => /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f, setValue: (v) => update((c) => {\n if (isNurbsContent(c) && c.weights) {\n c.weights[i] = v;\n }\n }) }))\n }\n ) : void 0\n ],\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents),\n ...ctx.getSegmentCountContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, NurbsContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n reverse: (content) => ctx.reverseNurbs(content)\n };\n return [\n nurbsModel\n ];\n}\nfunction isNurbsContent(content) {\n return content.type === "nurbs";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon1 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "13", cy: "22", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "28", cy: "79", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "63", cy: "22", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "85", cy: "80", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "13,22 14,24 14,26 15,29 15,31 16,33 17,34 17,36 18,38 18,40 19,41 20,43 20,44 21,46 22,47 22,49 23,50 23,51 24,52 25,53 25,54 26,55 27,56 27,56 28,57 29,58 29,58 30,59 31,59 31,59 32,60 33,60 33,60 34,60 35,60 35,60 36,60 37,60 37,59 38,59 39,58 39,58 40,57 41,57 41,56 42,55 43,55 43,54 44,53 45,52 46,51 46,49 47,48 48,47 48,46 49,46 50,45 50,44 51,44 52,43 53,43 53,42 54,42 55,42 56,41 56,41 57,41 58,41 59,41 59,41 60,42 61,42 62,42 63,43 63,43 64,44 65,44 66,45 67,46 67,47 68,47 69,48 70,49 71,51 71,52 72,53 73,54 74,56 75,57 76,59 76,60 77,62 78,64 79,65 80,67 81,69 82,71 82,73 83,75 84,78 85,80", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n const nurbsCommand = {\n name: "create nurbs",\n type: [\n { name: "nurbs", icon: icon1 }\n ],\n useCommand({ onEnd, type, scale, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "nurbs",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ points: c, type: "nurbs", degree: 2, strokeStyleId, fillStyleId })\n })\n );\n const assistentContents = [];\n if (line) {\n assistentContents.push(\n { points: line, type: "nurbs", strokeStyleId, fillStyleId, degree: 2 },\n { points: line, type: "polyline", dashArray: [4 / scale] }\n );\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n return [\n nurbsCommand\n ];\n}\nexport {\n getCommand,\n getModel,\n isNurbsContent\n};\n','// dev/cad-editor/plugins/offset.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "8", y: "9", width: "82", height: "82", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "22", y: "23", width: "55", height: "55", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n function contentSelectable(content) {\n var _a;\n return ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.offset) !== void 0;\n }\n function getOffsetResult(content, p, offset, contents, lineJoin) {\n const model = ctx.getContentModel(content);\n if (model == null ? void 0 : model.offset) {\n const newContent = model.offset(content, p, offset, contents, lineJoin);\n if (Array.isArray(newContent)) {\n return newContent.filter((c) => model.isValid(c) === true);\n }\n if (newContent && model.isValid(newContent) === true) {\n return [newContent];\n }\n }\n return [];\n }\n return {\n name: "offset",\n useCommand({ onEnd, type, contents }) {\n let message = "";\n if (type) {\n message = "input offset or click to end";\n }\n const [lineJoin, setLineJoin] = React.useState(ctx.defaultLineJoin);\n const [offset, setOffset] = React.useState(0);\n const { input, clearText, setInputPosition, cursorPosition, setCursorPosition, resetInput } = ctx.useCursorInput(message, type ? (e, text) => {\n if (e.key === "Enter") {\n const offset2 = +text;\n if (!isNaN(offset2) && offset2 >= 0) {\n setOffset(offset2);\n clearText();\n } else if (text.toUpperCase() === "T") {\n setOffset(0);\n clearText();\n }\n }\n } : void 0);\n return {\n onStart(p) {\n resetInput();\n onEnd({\n nextCommand: "offset",\n updateContents: (contents2, selected) => {\n const target = contents2.filter((c, i) => c && ctx.isSelected([i], selected) && contentSelectable(c));\n for (const content of target) {\n if (content) {\n contents2.push(...getOffsetResult(content, p, offset, contents2, lineJoin));\n }\n }\n setCursorPosition(void 0);\n }\n });\n },\n input,\n onMove(p, viewportPosition) {\n setInputPosition(viewportPosition || p);\n if (!type) {\n return;\n }\n setCursorPosition(p);\n },\n updateSelectedContent(content) {\n if (cursorPosition) {\n const newContents = getOffsetResult(content, cursorPosition, offset, contents, lineJoin);\n if (newContents.length > 0) {\n return {\n newContents\n };\n }\n }\n return {};\n },\n subcommand: type === "offset" ? /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(ctx.EnumEditor, { value: lineJoin, enums: ["miter", "bevel", "round"], setValue: setLineJoin })) : void 0,\n reset: resetInput\n };\n },\n contentSelectable,\n selectCount: 1,\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/coordinate-axis.plugin.tsx\nfunction isCoordinateAxisContent(content) {\n return content.type === "coordinate axis";\n}\n\n// dev/cad-editor/plugins/parametric-equation.plugin.tsx\nfunction getModel(ctx) {\n const ParametricEquationContent = ctx.and(ctx.BaseContent("parametric equation"), ctx.StrokeFields, ctx.SegmentCountFields, {\n axisId: ctx.ContentRef,\n xExpression: ctx.string,\n yExpression: ctx.string,\n min: ctx.number,\n max: ctx.number\n });\n const getRefIds = (content) => [...ctx.getStrokeRefIds(content), ...ctx.toRefId(content.axisId, true)];\n const equationCache = new ctx.WeakmapValuesCache();\n function getGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return equationCache.get(content, refs, () => {\n var _a;\n const axis = ctx.getReference(content.axisId, contents, isCoordinateAxisContent);\n if (axis) {\n if (content.xExpression && content.yExpression) {\n try {\n const xExpression = ctx.parseExpression(ctx.tokenizeExpression(content.xExpression));\n const yExpression = ctx.parseExpression(ctx.tokenizeExpression(content.yExpression));\n const points = [];\n const segmentCount = (_a = content.segmentCount) != null ? _a : ctx.defaultSegmentCount;\n const step = (content.max - content.min) / segmentCount;\n for (let t = content.min; t <= content.max; t += step) {\n const x = ctx.evaluateExpression(xExpression, { Math, t });\n const y = ctx.evaluateExpression(yExpression, { Math, t });\n if (typeof x === "number" && !isNaN(x) && typeof y === "number" && !isNaN(y)) {\n points.push({ x: x + axis.x, y: y * (axis.flipY ? -1 : 1) + axis.y });\n }\n }\n const lines = Array.from(ctx.iteratePolylineLines(points));\n return {\n points,\n lines,\n bounding: ctx.getPointsBounding(points),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray)\n };\n } catch (e) {\n console.info(e);\n }\n }\n return { lines: [], points: [], renderingLines: [] };\n }\n return { lines: [], points: [], renderingLines: [] };\n });\n }\n const React = ctx.React;\n return {\n type: "parametric equation",\n ...ctx.strokeModel,\n ...ctx.segmentCountModel,\n render(content, renderCtx) {\n const { options, contents, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getGeometriesFromCache(content, contents);\n return target.renderPolyline(points, options);\n },\n getGeometries: getGeometriesFromCache,\n propertyPanel(content, update, contents) {\n return {\n xExpression: /* @__PURE__ */ React.createElement(ctx.ExpressionEditor, { suggestionSources: ctx.math, validate: ctx.validateExpression, value: content.xExpression, setValue: (v) => update((c) => {\n if (isParametricEquationContent(c)) {\n c.xExpression = v;\n }\n }) }),\n yExpression: /* @__PURE__ */ React.createElement(ctx.ExpressionEditor, { suggestionSources: ctx.math, validate: ctx.validateExpression, value: content.yExpression, setValue: (v) => update((c) => {\n if (isParametricEquationContent(c)) {\n c.yExpression = v;\n }\n }) }),\n min: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.min, setValue: (v) => update((c) => {\n if (isParametricEquationContent(c)) {\n c.min = v;\n }\n }) }),\n max: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.max, setValue: (v) => update((c) => {\n if (isParametricEquationContent(c)) {\n c.max = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getSegmentCountContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, ParametricEquationContent, p),\n getRefIds,\n updateRefId(content, update) {\n const newAxisId = update(content.axisId);\n if (newAxisId !== void 0) {\n content.axisId = newAxisId;\n }\n ctx.updateStrokeRefIds(content, update);\n },\n deleteRefId: ctx.deleteStrokeRefIds\n };\n}\nfunction isParametricEquationContent(content) {\n return content.type === "parametric equation";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "7,93 88,93", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,12 7,93", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "97,93 68,101 68,85", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,3 15,32 1,32", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "76,49 76,47 76,46 76,44 76,43 75,41 75,40 74,38 73,37 73,35 72,34 71,33 70,32 69,31 67,29 66,29 65,28 64,27 62,26 61,26 59,25 58,25 56,24 55,24 53,24 51,24 50,24 48,24 47,24 45,25 44,25 42,26 41,26 39,27 38,28 37,29 36,29 34,31 33,32 32,33 31,34 30,35 30,37 29,38 28,40 28,41 27,43 27,44 27,46 27,47 26,49 27,50 27,52 27,53 27,55 28,56 28,58 29,59 30,61 30,62 31,63 32,65 33,66 34,67 36,68 37,69 38,70 39,71 41,71 42,72 44,73 45,73 47,73 48,74 50,74 51,74 53,74 55,74 56,73 58,73 59,73 61,72 62,71 64,71 65,70 66,69 67,68 69,67 70,66 71,65 72,63 73,62 73,61 74,59 75,58 75,56 76,55 76,53 76,52 76,50 76,49", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "create parametric equation",\n icon,\n execute({ contents, selected }) {\n contents.push({\n type: "parametric equation",\n axisId: selected[0][0],\n min: 0,\n max: Math.PI * 2,\n xExpression: "25 + 25 * Math.cos(t)",\n yExpression: "25 + 25 * Math.sin(t)"\n });\n },\n contentSelectable: isCoordinateAxisContent,\n selectCount: 1\n };\n}\nexport {\n getCommand,\n getModel,\n isParametricEquationContent\n};\n','// dev/cad-editor/plugins/path-array.plugin.tsx\nfunction getModel(ctx) {\n const PathArrayContent = ctx.and(ctx.BaseContent("path array"), ctx.ContainerFields, {\n path: ctx.PartRef,\n length: ctx.number,\n aligned: ctx.optional(ctx.boolean)\n });\n const getRefIds = (content) => [...ctx.toRefId(content.path.id, true), ...ctx.toRefIds(content.contents)];\n const allContentsCache = new ctx.WeakmapCache2();\n const getAllContentsFromCache = (content, contents) => {\n const path = ctx.getRefPart(content.path, contents, (c) => !ctx.shallowEquals(c, content));\n if (!path)\n return [];\n return allContentsCache.get(content, path, () => {\n var _a, _b, _c, _d;\n const lines = (_b = (_a = ctx.getContentModel(path)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, path, contents).lines;\n if (!lines)\n return [];\n const boundings = [];\n for (const child of content.contents) {\n if (child) {\n const geometries = (_d = (_c = ctx.getContentModel(child)) == null ? void 0 : _c.getGeometries) == null ? void 0 : _d.call(_c, child, contents);\n if (geometries == null ? void 0 : geometries.bounding) {\n boundings.push(geometries.bounding);\n }\n }\n }\n const bounding = ctx.mergeBoundingsUnsafe(boundings);\n const center = ctx.getTwoPointCenter(bounding.start, bounding.end);\n const result = [];\n const lengths = lines.map((line) => ctx.getGeometryLineLength(line) || 0);\n const totalLength = lengths.reduce((p, c) => p + c, 0);\n for (let length = 0; length <= totalLength; length += content.length) {\n const r = ctx.getGeometryLinesPointAndTangentRadianByLength(lines, length, lengths);\n if (r) {\n result.push(...content.contents.map((child) => {\n var _a2, _b2;\n if (!child)\n return;\n const model = ctx.getContentModel(child);\n if (!model)\n return;\n const bounding2 = (_b2 = (_a2 = model.getGeometries) == null ? void 0 : _a2.call(model, child, contents)) == null ? void 0 : _b2.bounding;\n if (!bounding2)\n return;\n const move = model.move;\n if (!move)\n return;\n return ctx.produce(child, (draft) => {\n var _a3;\n move(draft, { x: -center.x + r.point.x, y: -center.y + r.point.y });\n if (content.aligned) {\n (_a3 = model.rotate) == null ? void 0 : _a3.call(model, draft, r.point, ctx.radianToAngle(r.radian), contents);\n }\n });\n }));\n }\n }\n return result;\n });\n };\n const getGeometries = (content, contents) => ctx.getContentsGeometries(content, contents, getRefIds, [content], (c) => getAllContentsFromCache(c, contents));\n const React = ctx.React;\n return {\n type: "path array",\n ...ctx.containerModel,\n move: ctx.getContainerMove,\n rotate: ctx.getContainerRotate,\n scale: ctx.getContainerScale,\n explode(content, contents) {\n return ctx.getContentsExplode(getAllContentsFromCache(content, contents));\n },\n break(content, points, contents) {\n return ctx.getContentsBreak(getAllContentsFromCache(content, contents), points, contents);\n },\n render(content, renderCtx) {\n return renderCtx.target.renderGroup(ctx.renderContainerChildren({ contents: getAllContentsFromCache(content, renderCtx.contents), variableValues: content.variableValues }, renderCtx));\n },\n getSnapPoints(content, contents) {\n return ctx.getContentsSnapPoints(content, contents, (c) => getAllContentsFromCache(c, contents));\n },\n getGeometries,\n propertyPanel(content, update, contents, { acquireContent }) {\n return {\n path: [\n /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquireContent({ count: 1, selectable: (v) => pathContentSelectable(ctx, ctx.getContentByIndex(contents, v), contents) }, (r) => update((c) => {\n if (isPathArrayContent(c)) {\n c.path = r[0];\n }\n })) }, "select"),\n typeof content.path.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.path.id, setValue: (v) => update((c) => {\n if (isPathArrayContent(c)) {\n c.path.id = v;\n }\n }) }) : void 0\n ],\n length: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.length, setValue: (v) => update((c) => {\n if (isPathArrayContent(c)) {\n c.length = v;\n }\n }) }),\n aligned: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.aligned === true, setValue: (v) => update((c) => {\n if (isPathArrayContent(c)) {\n c.aligned = v ? true : void 0;\n }\n }) }),\n ...ctx.getVariableValuesContentPropertyPanel(content, ctx.getContainerVariableNames(content), update)\n };\n },\n getRefIds,\n updateRefId(content, update) {\n if (content.path) {\n const newRefId = update(content.path.id);\n if (newRefId !== void 0) {\n content.path.id = newRefId;\n }\n }\n },\n isValid: (c, p) => ctx.validate(c, PathArrayContent, p)\n };\n}\nfunction isPathArrayContent(content) {\n return content.type === "path array";\n}\nfunction pathContentSelectable(ctx, content, contents) {\n var _a, _b;\n if (!content)\n return false;\n const geometries = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content, contents);\n if (!geometries)\n return false;\n return geometries.lines.length > 0;\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "11,89 92,8", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "11", cy: "89", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "36", cy: "64", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "61", cy: "39", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "86", cy: "14", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "create path array",\n useCommand({ type, onEnd, acquireContent, selected, contents }) {\n const target = React.useRef();\n const path = React.useRef();\n const reset = () => {\n target.current = void 0;\n path.current = void 0;\n };\n React.useEffect(() => {\n if (!type)\n return;\n if (!target.current) {\n target.current = selected.map((s) => s.path);\n acquireContent(\n {\n count: 1,\n selectable: (v) => {\n const content = ctx.getContentByIndex(contents, v);\n if (!content)\n return false;\n return pathContentSelectable(ctx, content, contents);\n }\n },\n (r) => {\n path.current = r[0];\n }\n );\n } else if (path.current) {\n const children = target.current.map((c) => contents[c[0]]);\n const bounding = ctx.getContentsBounding(children, contents);\n if (bounding) {\n const length = ctx.getTwoPointsDistance(bounding.start, bounding.end);\n onEnd({\n updateContents(contents2) {\n if (target.current && path.current) {\n contents2.push({\n type: "path array",\n contents: children,\n path: path.current,\n length\n });\n ctx.deleteSelectedContents(contents2, target.current.map((c) => c[0]));\n }\n }\n });\n }\n reset();\n }\n }, [type]);\n return {\n onStart() {\n },\n reset\n };\n },\n contentSelectable,\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isPathArrayContent\n};\n','// dev/cad-editor/plugins/path.plugin.tsx\nfunction getModel(ctx) {\n const PathContent = ctx.and(ctx.BaseContent("path"), ctx.StrokeFields, ctx.FillFields, {\n commands: [ctx.PathCommand]\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n function getPathGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n const lines = ctx.pathCommandsToGeometryLines(content.commands)[0];\n const points = ctx.getGeometryLinesPoints(lines);\n return {\n lines,\n bounding: ctx.getGeometryLinesBounding(lines),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n return {\n type: "path",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n for (const command of content.commands) {\n if (command.type !== "close") {\n ctx.movePoint(command.to, offset);\n }\n if (command.type === "arc") {\n ctx.movePoint(command.from, offset);\n } else if (command.type === "bezierCurve") {\n ctx.movePoint(command.cp1, offset);\n ctx.movePoint(command.cp2, offset);\n } else if (command.type === "quadraticCurve") {\n ctx.movePoint(command.cp, offset);\n }\n }\n },\n rotate(content, center, angle) {\n for (const command of content.commands) {\n if (command.type !== "close") {\n ctx.rotatePoint(command.to, center, angle);\n }\n if (command.type === "arc") {\n ctx.rotatePoint(command.from, center, angle);\n } else if (command.type === "bezierCurve") {\n ctx.rotatePoint(command.cp1, center, angle);\n ctx.rotatePoint(command.cp2, center, angle);\n } else if (command.type === "quadraticCurve") {\n ctx.rotatePoint(command.cp, center, angle);\n }\n }\n },\n scale(content, center, sx, sy) {\n for (const command of content.commands) {\n if (command.type !== "close") {\n ctx.scalePoint(command.to, center, sx, sy);\n }\n if (command.type === "arc") {\n ctx.scalePoint(command.from, center, sx, sy);\n } else if (command.type === "bezierCurve") {\n ctx.scalePoint(command.cp1, center, sx, sy);\n ctx.scalePoint(command.cp2, center, sx, sy);\n } else if (command.type === "quadraticCurve") {\n ctx.scalePoint(command.cp, center, sx, sy);\n }\n }\n },\n skew(content, center, sx, sy) {\n for (const command of content.commands) {\n if (command.type !== "close") {\n ctx.skewPoint(command.to, center, sx, sy);\n }\n if (command.type === "arc") {\n ctx.skewPoint(command.from, center, sx, sy);\n } else if (command.type === "bezierCurve") {\n ctx.skewPoint(command.cp1, center, sx, sy);\n ctx.skewPoint(command.cp2, center, sx, sy);\n } else if (command.type === "quadraticCurve") {\n ctx.skewPoint(command.cp, center, sx, sy);\n }\n }\n },\n mirror(content, line) {\n for (const command of content.commands) {\n if (command.type !== "close") {\n ctx.mirrorPoint(command.to, line);\n }\n if (command.type === "arc") {\n ctx.mirrorPoint(command.from, line);\n } else if (command.type === "bezierCurve") {\n ctx.mirrorPoint(command.cp1, line);\n ctx.mirrorPoint(command.cp2, line);\n } else if (command.type === "quadraticCurve") {\n ctx.mirrorPoint(command.cp, line);\n }\n }\n },\n break(content, intersectionPoints, contents) {\n const lines = getPathGeometriesFromCache(content, contents).lines;\n return ctx.breakGeometryLinesToPathCommands(lines, intersectionPoints);\n },\n offset(content, point, distance, contents, lineJoin) {\n const lines = getPathGeometriesFromCache(content, contents).lines;\n return {\n ...content,\n commands: ctx.geometryLineToPathCommands(ctx.trimGeometryLines(ctx.getParallelGeometryLinesByDistancePoint(point, lines, distance, lineJoin)))\n };\n },\n extend(content, point, contents) {\n const lines = getPathGeometriesFromCache(content, contents).lines;\n const newLines = ctx.produce(lines, (draft) => ctx.extendGeometryLines(draft, point));\n content.commands = ctx.geometryLineToPathCommands(newLines);\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderPathCommands(content.commands, options);\n },\n renderIfSelected(content, { color, target, strokeWidth }) {\n const points = [];\n content.commands.forEach((c, i) => {\n const last = ctx.getPathCommandEndPoint(content.commands, i - 1);\n if (last) {\n if (c.type === "quadraticCurve") {\n points.push([last, c.cp, c.to]);\n } else if (c.type === "bezierCurve") {\n points.push([last, c.cp1, c.cp2, c.to]);\n } else if (c.type === "arc") {\n points.push([last, c.from, c.to]);\n } else if (c.type === "ellipseArc") {\n points.push([last, c.to]);\n }\n }\n });\n return target.renderPath(points, { strokeColor: color, dashArray: [4], strokeWidth });\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n const editPoints = [];\n content.commands.forEach((command, i) => {\n if (command.type === "arc") {\n editPoints.push({\n ...command.from,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPathContent(c)) {\n return;\n }\n const m = c.commands[i];\n if (m.type !== "arc") {\n return;\n }\n m.from.x += cursor.x - start.x;\n m.from.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n });\n } else if (command.type === "bezierCurve") {\n editPoints.push(\n {\n ...command.cp1,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPathContent(c)) {\n return;\n }\n const m = c.commands[i];\n if (m.type !== "bezierCurve") {\n return;\n }\n m.cp1.x += cursor.x - start.x;\n m.cp1.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n ...command.cp2,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPathContent(c)) {\n return;\n }\n const m = c.commands[i];\n if (m.type !== "bezierCurve") {\n return;\n }\n m.cp2.x += cursor.x - start.x;\n m.cp2.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n );\n } else if (command.type === "quadraticCurve") {\n editPoints.push({\n ...command.cp,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPathContent(c)) {\n return;\n }\n const m = c.commands[i];\n if (m.type !== "quadraticCurve") {\n return;\n }\n m.cp.x += cursor.x - start.x;\n m.cp.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n });\n }\n if (command.type !== "close") {\n editPoints.push({\n ...command.to,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPathContent(c)) {\n return;\n }\n const m = c.commands[i];\n if (m.type === "close") {\n return;\n }\n m.to.x += cursor.x - start.x;\n m.to.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n });\n }\n });\n return {\n editPoints\n };\n });\n },\n getGeometries: getPathGeometriesFromCache,\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n commands: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.commands, { type: "line", to: { x: 0, y: 0 } }, (v) => update((c) => {\n if (isPathContent(c)) {\n v(c);\n }\n })),\n items: content.commands.map((f, i) => {\n const properties = {\n type: /* @__PURE__ */ React.createElement(ctx.EnumEditor, { select: true, value: f.type, enums: ["move", "line", "arc", "ellipseArc", "bezierCurve", "quadraticCurve", "close"], setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n if (v === "move" || v === "line") {\n c.commands[i] = {\n type: v,\n to: { x: 0, y: 0 }\n };\n } else if (v === "arc") {\n c.commands[i] = {\n type: v,\n radius: 10,\n from: { x: 0, y: 0 },\n to: { x: 0, y: 0 }\n };\n } else if (v === "ellipseArc") {\n c.commands[i] = {\n type: v,\n rx: 10,\n ry: 10,\n angle: 0,\n sweep: true,\n largeArc: true,\n to: { x: 0, y: 0 }\n };\n } else if (v === "bezierCurve") {\n c.commands[i] = {\n type: v,\n cp1: { x: 0, y: 0 },\n cp2: { x: 0, y: 0 },\n to: { x: 0, y: 0 }\n };\n } else if (v === "quadraticCurve") {\n c.commands[i] = {\n type: v,\n cp: { x: 0, y: 0 },\n to: { x: 0, y: 0 }\n };\n } else if (v === "close") {\n c.commands[i] = {\n type: v\n };\n }\n }\n }) })\n };\n if (f.type === "arc") {\n properties.from = /* @__PURE__ */ React.createElement(ctx.ObjectEditor, { inline: true, properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "arc") {\n m.from.x = p.x;\n m.from.y = p.y;\n }\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.from.x, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "arc") {\n m.from.x = v;\n }\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.from.y, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "arc") {\n m.from.y = v;\n }\n }\n }) })\n } });\n properties.radius = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.radius, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "arc") {\n m.radius = v;\n }\n }\n }) });\n } else if (f.type === "ellipseArc") {\n properties.rx = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.rx, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "ellipseArc") {\n m.rx = v;\n }\n }\n }) });\n properties.ry = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.ry, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "ellipseArc") {\n m.ry = v;\n }\n }\n }) });\n properties.angle = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.angle, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "ellipseArc") {\n m.angle = v;\n }\n }\n }) });\n properties.largeArc = /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: f.largeArc, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "ellipseArc") {\n m.largeArc = v;\n }\n }\n }) });\n properties.sweep = /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: f.sweep, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "ellipseArc") {\n m.sweep = v;\n }\n }\n }) });\n } else if (f.type === "bezierCurve") {\n properties.cp1 = /* @__PURE__ */ React.createElement(ctx.ObjectEditor, { inline: true, properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "bezierCurve") {\n m.cp1.x = p.x;\n m.cp1.y = p.y;\n }\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.cp1.x, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "bezierCurve") {\n m.cp1.x = v;\n }\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.cp1.y, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "bezierCurve") {\n m.cp1.y = v;\n }\n }\n }) })\n } });\n properties.cp2 = /* @__PURE__ */ React.createElement(ctx.ObjectEditor, { inline: true, properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "bezierCurve") {\n m.cp2.x = p.x;\n m.cp2.y = p.y;\n }\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.cp2.x, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "bezierCurve") {\n m.cp2.x = v;\n }\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.cp2.y, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "bezierCurve") {\n m.cp2.y = v;\n }\n }\n }) })\n } });\n } else if (f.type === "quadraticCurve") {\n properties.cp = /* @__PURE__ */ React.createElement(ctx.ObjectEditor, { inline: true, properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "quadraticCurve") {\n m.cp.x = p.x;\n m.cp.y = p.y;\n }\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.cp.x, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "quadraticCurve") {\n m.cp.x = v;\n }\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.cp.y, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type === "quadraticCurve") {\n m.cp.y = v;\n }\n }\n }) })\n } });\n }\n if (f.type !== "close") {\n properties.to = /* @__PURE__ */ React.createElement(ctx.ObjectEditor, { inline: true, properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type !== "close") {\n m.to.x = p.x;\n m.to.y = p.y;\n }\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.to.x, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type !== "close") {\n m.to.x = v;\n }\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.to.y, setValue: (v) => update((c) => {\n if (isPathContent(c)) {\n const m = c.commands[i];\n if (m.type !== "close") {\n m.to.y = v;\n }\n }\n }) })\n } });\n }\n return /* @__PURE__ */ React.createElement(ctx.ObjectEditor, { inline: true, properties });\n })\n }\n ),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, PathContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n reverse: (content, contents) => ({\n ...content,\n commands: ctx.geometryLineToPathCommands(ctx.reverseGeometryLines(getPathGeometriesFromCache(content, contents).lines))\n })\n };\n}\nfunction isPathContent(content) {\n return content.type === "path";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("path", { d: " M 8 8 L 40 7 A 50 50 0 0 1 91 57 Q 91 91, 17 90 C 50 72, 50 31, 8 24 Z", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create path",\n hotkey: "P",\n icon,\n useCommand({ onEnd, type, scale, strokeStyleId, fillStyleId }) {\n const { path, controlPoint, controlPoint2, preview, onClick, onMove, input, setInputType, cursorPosition, reset } = ctx.usePathClickCreate(\n type === "create path",\n (c) => onEnd({\n updateContents: (contents) => contents.push({\n type: "path",\n strokeStyleId,\n fillStyleId,\n commands: c\n })\n })\n );\n const assistentContents = [];\n if (preview.length > 1) {\n assistentContents.push({\n type: "path",\n strokeStyleId,\n fillStyleId,\n commands: preview\n });\n }\n const last = ctx.getPathCommandEndPoint(path, path.length - 1);\n if (last) {\n if (controlPoint) {\n assistentContents.push({ type: "line", points: [last, controlPoint], dashArray: [4 / scale] });\n if (controlPoint2) {\n assistentContents.push({ type: "line", points: [controlPoint, controlPoint2], dashArray: [4 / scale] });\n if (cursorPosition) {\n assistentContents.push({ type: "line", points: [controlPoint2, cursorPosition], dashArray: [4 / scale] });\n }\n } else {\n if (cursorPosition) {\n assistentContents.push({ type: "line", points: [controlPoint, cursorPosition], dashArray: [4 / scale] });\n }\n }\n } else if (cursorPosition) {\n assistentContents.push({ type: "line", points: [last, cursorPosition], dashArray: [4 / scale] });\n }\n }\n return {\n onStart: onClick,\n input,\n onMove,\n reset,\n subcommand: type === "create path" ? /* @__PURE__ */ React.createElement("span", null, ["line", "arc", "bezierCurve", "quadraticCurve", "close"].map((m) => /* @__PURE__ */ React.createElement("button", { key: m, onClick: () => setInputType(m), style: { position: "relative" } }, m))) : void 0,\n assistentContents\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isPathContent\n};\n','// dev/cad-editor/plugins/pen.plugin.tsx\nfunction getModel(ctx) {\n const PenContent = ctx.and(ctx.BaseContent("pen"), ctx.StrokeFields, {\n points: ctx.minItems(2, [ctx.Position])\n });\n const getRefIds = (content) => ctx.getStrokeRefIds(content);\n function getGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n const lines = Array.from(ctx.iteratePolylineLines(content.points));\n return {\n lines,\n bounding: ctx.getPointsBounding(content.points),\n renderingLines: ctx.dashedPolylineToLines(content.points, content.dashArray)\n };\n });\n }\n return {\n type: "pen",\n ...ctx.strokeModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point, offset);\n }\n },\n rotate(content, center, angle) {\n for (const point of content.points) {\n ctx.rotatePoint(point, center, angle);\n }\n },\n scale(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.scalePoint(point, center, sx, sy);\n }\n },\n skew(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.skewPoint(point, center, sx, sy);\n }\n },\n mirror(content, line) {\n for (const point of content.points) {\n ctx.mirrorPoint(point, line);\n }\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderPolyline(content.points, options);\n },\n getGeometries,\n propertyPanel(content, update, contents) {\n return ctx.getStrokeContentPropertyPanel(content, update, contents);\n },\n isValid: (c, p) => ctx.validate(c, PenContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds,\n reverse: (content) => ({\n ...content,\n points: content.points.slice().reverse()\n })\n };\n}\nfunction isPenContent(content) {\n return content.type === "pen";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { viewBox: "0 0 1024 1024", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React.createElement("path", { d: "m199.04 672.64 193.984 112 224-387.968-193.92-112-224 388.032zm-23.872 60.16 32.896 148.288 144.896-45.696L175.168 732.8zM455.04 229.248l193.92 112 56.704-98.112-193.984-112-56.64 98.112zM104.32 708.8l384-665.024 304.768 175.936L409.152 884.8h.064l-248.448 78.336L104.32 708.8zm384 254.272v-64h448v64h-448z", fill: "currentColor" }));\n return {\n name: "create pen",\n useCommand({ onEnd, type, strokeStyleId }) {\n const { reset, points, onClick, onMove } = ctx.usePenClickCreate(\n type === "create pen",\n () => onEnd({\n updateContents: (contents) => contents.push({ points, strokeStyleId, type: "pen" })\n })\n );\n const assistentContents = [];\n if (points.length > 1) {\n assistentContents.push({ points, strokeStyleId, type: "pen" });\n }\n return {\n onStart: onClick,\n onMove,\n assistentContents,\n reset\n };\n },\n selectCount: 0,\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isPenContent\n};\n','// dev/cad-editor/plugins/pline.plugin.tsx\nfunction getModel(ctx) {\n const PlineContent = ctx.and(ctx.BaseContent("pline"), ctx.StrokeFields, ctx.FillFields, {\n points: ctx.minItems(2, [{ point: ctx.Position, bulge: ctx.number }]),\n closed: ctx.optional(ctx.boolean)\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getPlineGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n const lines = [];\n const centers = [];\n const middles = [];\n for (let i = 0; i < content.points.length; i++) {\n const p = content.points[i];\n if (i === content.points.length - 1) {\n if (content.closed) {\n lines.push(ctx.getGeometryLineByStartEndBulge(p.point, content.points[0].point, p.bulge));\n }\n } else {\n lines.push(ctx.getGeometryLineByStartEndBulge(p.point, content.points[i + 1].point, p.bulge));\n }\n }\n for (const line of lines) {\n if (Array.isArray(line)) {\n middles.push(ctx.getTwoPointCenter(...line));\n } else if (line.type === "arc") {\n centers.push(line.curve);\n middles.push(ctx.getArcPointAtAngle(line.curve, ctx.getTwoNumberCenter(line.curve.startAngle, ctx.getFormattedEndAngle(line.curve))));\n }\n }\n const points = ctx.getGeometryLinesPoints(lines);\n return {\n lines,\n points,\n centers,\n middles,\n bounding: ctx.getGeometryLinesBounding(lines),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n return {\n type: "pline",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point.point, offset);\n }\n },\n rotate(content, center, angle) {\n for (const point of content.points) {\n ctx.rotatePoint(point.point, center, angle);\n }\n },\n scale(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.scalePoint(point.point, center, sx, sy);\n }\n },\n skew(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.skewPoint(point.point, center, sx, sy);\n }\n },\n mirror(content, line) {\n for (const point of content.points) {\n ctx.mirrorPoint(point.point, line);\n point.bulge *= -1;\n }\n },\n break(content, intersectionPoints, contents) {\n const { lines } = getPlineGeometries(content, contents);\n const newLines = ctx.breakGeometryLines(lines, intersectionPoints);\n return newLines.map((line) => ctx.geometryLinesToPline(line));\n },\n explode(content, contents) {\n const { lines } = getPlineGeometries(content, contents);\n return lines.map((line) => ctx.geometryLineToContent(line));\n },\n offset(content, point, distance, contents, lineJoin) {\n const { lines } = getPlineGeometries(content, contents);\n const newLines = ctx.trimGeometryLines(ctx.getParallelGeometryLinesByDistancePoint(point, lines, distance, lineJoin));\n return ctx.geometryLinesToPline(newLines);\n },\n join(content, target, contents) {\n var _a, _b, _c;\n const { lines } = getPlineGeometries(content, contents);\n const line2 = (_c = (_b = (_a = ctx.getContentModel(target)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, target, contents)) == null ? void 0 : _c.lines;\n if (!line2)\n return;\n const newLines = ctx.mergeGeometryLines(lines, line2);\n if (!newLines)\n return;\n return ctx.geometryLinesToPline(newLines);\n },\n extend(content, point, contents) {\n if (content.closed)\n return;\n const { lines } = getPlineGeometries(content, contents);\n const first = lines[0], last = lines[lines.length - 1];\n if (Array.isArray(first)) {\n if (ctx.pointIsOnRay(point, { ...first[0], angle: ctx.radianToAngle(ctx.getTwoPointsRadian(...first)) })) {\n content.points[0].point = point;\n }\n } else if (first.type === "arc") {\n if (ctx.pointIsOnCircle(point, first.curve)) {\n content.points[0].point = point;\n content.points[0].bulge = ctx.getArcBulge({ ...first.curve, startAngle: ctx.radianToAngle(ctx.getCircleRadian(point, first.curve)) }, point);\n }\n }\n if (Array.isArray(last)) {\n if (ctx.pointIsOnRay(point, { ...last[1], angle: ctx.radianToAngle(ctx.getTwoPointsRadian(last[1], last[0])) })) {\n content.points[content.points.length - 1].point = point;\n }\n } else if (last.type === "arc") {\n if (ctx.pointIsOnCircle(point, last.curve)) {\n content.points[0].point = point;\n content.points[0].bulge = ctx.getArcBulge({ ...last.curve, endAngle: ctx.radianToAngle(ctx.getCircleRadian(point, last.curve)) }, void 0, point);\n }\n }\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderPath([getPlineGeometries(content, renderCtx.contents).points], options);\n },\n getOperatorRenderPosition(content) {\n return content.points[0].point;\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { middles } = getPlineGeometries(content, contents);\n const endpoints = content.points.map((p, i) => ({\n x: p.point.x,\n y: p.point.y,\n cursor: "move",\n type: "move",\n update(c, { cursor, start, scale }) {\n if (!isPlineContent(c)) {\n return;\n }\n c.points[i].point.x += cursor.x - start.x;\n c.points[i].point.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [p.point, cursor] }] };\n },\n menu: [\n {\n title: "Remove",\n execute(draft) {\n if (isPlineContent(draft)) {\n draft.points.splice(i, 1);\n }\n }\n },\n ...i === 0 || i === content.points.length - 1 ? [{\n title: "Add",\n update(c, { cursor, scale }) {\n if (!isPlineContent(c)) {\n return;\n }\n c.points.splice(i === 0 ? 0 : i + 1, 0, { point: { x: cursor.x, y: cursor.y }, bulge: 0 });\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [p.point, cursor] }] };\n }\n }] : []\n ]\n }));\n const midpoints = middles.map((p, i) => ({\n x: p.x,\n y: p.y,\n cursor: "move",\n type: "move",\n update(c, { cursor, start, scale }) {\n if (!isPlineContent(c)) {\n return;\n }\n const j = i === content.points.length - 1 ? 0 : i + 1;\n if (ctx.isZero(content.points[i].bulge)) {\n c.points[i].point.x += cursor.x - start.x;\n c.points[i].point.y += cursor.y - start.y;\n c.points[j].point.x += cursor.x - start.x;\n c.points[j].point.y += cursor.y - start.y;\n } else {\n const bulge = ctx.getArcBulgeByStartEndPoint(content.points[i].point, content.points[j].point, cursor);\n if (bulge !== void 0) {\n c.points[i].bulge = bulge;\n }\n }\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [p, cursor] }] };\n },\n menu: [\n {\n title: "Add",\n update(c, { cursor, scale }) {\n if (!isPlineContent(c)) {\n return;\n }\n c.points.splice(i + 1, 0, { point: { x: cursor.x, y: cursor.y }, bulge: 0 });\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [p, cursor] }] };\n }\n },\n ctx.isZero(content.points[i].bulge) ? {\n title: "To Arc",\n update(c, { cursor, scale }) {\n if (!isPlineContent(c)) {\n return;\n }\n const j = i === content.points.length - 1 ? 0 : i + 1;\n const bulge = ctx.getArcBulgeByStartEndPoint(content.points[i].point, content.points[j].point, cursor);\n if (bulge !== void 0) {\n c.points[i].bulge = bulge;\n }\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [p, cursor] }] };\n }\n } : {\n title: "To Line",\n execute(draft) {\n if (isPlineContent(draft)) {\n draft.points[i].bulge = 0;\n }\n }\n }\n ]\n }));\n return {\n editPoints: [\n ...endpoints,\n ...midpoints\n ]\n };\n });\n },\n getSnapPoints(content, contents) {\n const { centers, middles } = getPlineGeometries(content, contents);\n return ctx.getSnapPointsFromCache(content, () => {\n return [\n ...content.points.map((p) => ({ ...p.point, type: "endpoint" })),\n ...centers.map((p) => ({ ...p, type: "center" })),\n ...middles.map((p) => ({ ...p, type: "midpoint" }))\n ];\n });\n },\n getGeometries: getPlineGeometries,\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquirePoint }) {\n var _a;\n return {\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { point: { x: 0, y: 0 }, bulge: 0 }, (v) => update((c) => {\n if (isPlineContent(c)) {\n v(c);\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPlineContent(c)) {\n c.points[i].point.x = p.x, c.points[i].point.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.point.x, setValue: (v) => update((c) => {\n if (isPlineContent(c)) {\n c.points[i].point.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.point.y, setValue: (v) => update((c) => {\n if (isPlineContent(c)) {\n c.points[i].point.y = v;\n }\n }) }),\n bulge: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.bulge, setValue: (v) => update((c) => {\n if (isPlineContent(c)) {\n c.points[i].bulge = v;\n }\n }) }),\n radius: f.bulge ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: ctx.getArcByStartEndBulge(f.point, (content.points[i + 1] || content.points[0]).point, f.bulge).r, setValue: (v) => update((c) => {\n if (isPlineContent(c)) {\n c.points[i].bulge = ctx.getArcBulgeByStartEndRadius(f.point, (content.points[i + 1] || content.points[0]).point, v, f.bulge) || 0;\n }\n }) }) : []\n }\n }\n ))\n }\n ),\n closed: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: (_a = content.closed) != null ? _a : false, setValue: (v) => update((c) => {\n if (isPlineContent(c)) {\n c.closed = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, PlineContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n reverse: (content) => ({\n ...content,\n points: content.points.slice().reverse().map((p, i, points) => ({\n point: p.point,\n bulge: -points[i === points.length - 1 ? 0 : i + 1].bulge\n }))\n }),\n isPointIn: (content, point, contents) => ctx.pointInPolygon(point, getPlineGeometries(content, contents).points)\n };\n}\nfunction isPlineContent(content) {\n return content.type === "pline";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "6,92 56,92", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("path", { d: "M 54 15 A 38 38 0 0 1 55 92", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "create pline",\n useCommand({ onEnd, scale, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, inputMode, lastPosition, reset, positions } = ctx.useLineClickCreate(\n type === "create pline",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ points: c.map((p) => ({ point: p, bulge: 0 })), strokeStyleId, fillStyleId, type: "pline" })\n })\n );\n const assistentContents = [];\n if (line && line.length > 1) {\n const start = line[line.length - 2];\n const end = line[line.length - 1];\n const r = ctx.getTwoPointsDistance(start, end);\n const angle = ctx.radianToAngle(ctx.getTwoPointsRadian(end, start));\n assistentContents.push(\n {\n type: "arc",\n x: start.x,\n y: start.y,\n r,\n dashArray: [4 / scale],\n startAngle: angle > 180 || angle < 0 ? angle : 0,\n endAngle: angle > 180 || angle < 0 ? 0 : angle\n },\n {\n type: "line",\n dashArray: [4 / scale],\n points: [start, { x: start.x + r, y: start.y }]\n },\n ...ctx.getAssistentText(\n r.toFixed(2),\n 16 / scale,\n (start.x + end.x) / 2 - 20,\n (start.y + end.y) / 2 + 4,\n inputMode === "length" ? 16711680 : 16764108\n ),\n ...ctx.getAssistentText(\n `${angle.toFixed(1)}\\xB0`,\n 16 / scale,\n end.x + 10,\n end.y - 10,\n inputMode === "angle" ? 16711680 : 16764108\n )\n );\n }\n if (line) {\n assistentContents.push({ points: line, strokeStyleId, fillStyleId, type: "polyline" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset,\n subcommand: type === "create pline" && positions.length > 2 ? /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(\n "button",\n {\n onClick: () => {\n onEnd({\n updateContents: (contents) => contents.push({ points: positions, type: "polygon" })\n });\n reset();\n },\n style: { position: "relative" }\n },\n "close"\n )) : void 0\n };\n },\n selectCount: 0,\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isPlineContent\n};\n','// dev/cad-editor/plugins/point.plugin.tsx\nfunction getModel(ctx) {\n const PointContent = ctx.and(ctx.BaseContent("point"), ctx.Position);\n function getPointGeometries(content) {\n return ctx.getGeometriesFromCache(content, /* @__PURE__ */ new Set(), () => {\n return {\n lines: [[content, content]],\n bounding: ctx.getPointsBounding([content]),\n renderingLines: [],\n regions: []\n };\n });\n }\n const React = ctx.React;\n return {\n type: "point",\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle) {\n ctx.rotatePoint(content, center, angle);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content, center, sx, sy);\n },\n skew(content, center, sx, sy) {\n ctx.skewPoint(content, center, sx, sy);\n },\n mirror(content, line) {\n ctx.mirrorPoint(content, line);\n },\n render(content, { target, isHoveringOrSelected, transformStrokeWidth }) {\n const strokeWidth = transformStrokeWidth(1);\n const fuzzy = isHoveringOrSelected && strokeWidth !== 1;\n const result = target.renderCircle(content.x, content.y, 1, { fillColor: 0 });\n if (fuzzy) {\n return target.renderGroup([\n target.renderCircle(content.x, content.y, strokeWidth, {\n fillColor: 0,\n strokeWidth: 0,\n fillOpacity: ctx.fuzzyStyle.strokeOpacity\n }),\n result\n ]);\n }\n return result;\n },\n getOperatorRenderPosition(content) {\n return content;\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n x: content.x,\n y: content.y,\n cursor: "move",\n type: "move",\n update(c, { cursor, start, scale }) {\n if (!isPointContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getSnapPoints(content) {\n return ctx.getSnapPointsFromCache(content, () => [{ x: content.x, y: content.y, type: "endpoint" }]);\n },\n getGeometries: getPointGeometries,\n propertyPanel(content, update, _, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPointContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isPointContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isPointContent(c)) {\n c.y = v;\n }\n }) })\n };\n },\n isValid: (c, p) => ctx.validate(c, PointContent, p)\n };\n}\nfunction isPointContent(content) {\n return content.type === "point";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "44", cy: "48", r: "4", strokeWidth: "2", vectorEffect: "non-scaling-stroke", fill: "none", stroke: "currentColor" }));\n return [\n {\n name: "create point",\n icon,\n useCommand({ type, onEnd }) {\n const [point, setPoint] = React.useState();\n const reset = () => {\n setPoint(void 0);\n };\n const assistentContents = [];\n if (point) {\n assistentContents.push({ ...point, type: "point" });\n }\n return {\n onStart: (p) => {\n onEnd({\n updateContents: (contents) => contents.push({ x: p.x, y: p.y, type: "point" })\n });\n },\n onMove(p) {\n if (!type)\n return;\n setPoint(p);\n },\n assistentContents,\n reset\n };\n },\n selectCount: 0\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isPointContent\n};\n','// dev/cad-editor/plugins/polar-array.plugin.tsx\nfunction getModel(ctx) {\n const PolarArrayContent = ctx.and(ctx.BaseContent("polar array"), ctx.ContainerFields, {\n center: ctx.Position,\n itemCount: ctx.number,\n itemAngle: ctx.number,\n rowCount: ctx.number,\n rowSpacing: ctx.number\n });\n const getRefIds = (content) => ctx.toRefIds(content.contents);\n const getAllContentsFromCache = (content, contents) => {\n return ctx.allContentsCache.get(content, () => {\n const result = [];\n const bounding = ctx.getContentsBounding(content.contents, contents);\n if (!bounding)\n return result;\n const base = {\n x: ctx.getTwoNumberCenter(bounding.start.x, bounding.end.x),\n y: ctx.getTwoNumberCenter(bounding.start.y, bounding.end.y)\n };\n for (let i = 0; i < content.rowCount; i++) {\n for (let j = 0; j < content.itemCount; j++) {\n const angle = j * content.itemAngle;\n if (i === 0 && j === 0) {\n result.push(...content.contents);\n } else {\n result.push(...content.contents.map((c) => {\n if (!c)\n return;\n const model = ctx.getContentModel(c);\n const rotate = model == null ? void 0 : model.rotate;\n if (!rotate)\n return;\n const move = model.move;\n if (!move)\n return;\n return ctx.produce(c, (draft) => {\n if (i !== 0) {\n const center = ctx.getPointByLengthAndDirection(base, -i * content.rowSpacing, content.center);\n move(draft, {\n x: center.x - base.x,\n y: center.y - base.y\n });\n }\n rotate(draft, content.center, angle, contents);\n });\n }));\n }\n }\n }\n return result;\n });\n };\n const getGeometries = (content, contents) => ctx.getContentsGeometries(content, contents, getRefIds, [content], (c) => getAllContentsFromCache(c, contents));\n const React = ctx.React;\n return {\n type: "polar array",\n ...ctx.containerModel,\n move(content, offset) {\n ctx.getContainerMove(content, offset);\n ctx.movePoint(content.center, offset);\n },\n rotate(content, center, angle, contents) {\n ctx.rotatePoint(content.center, center, angle);\n content.contents.forEach((c) => {\n var _a, _b;\n if (!c)\n return;\n (_b = (_a = ctx.getContentModel(c)) == null ? void 0 : _a.rotate) == null ? void 0 : _b.call(_a, c, center, angle, contents);\n });\n },\n scale(content, center, sx, sy, contents) {\n ctx.scalePoint(content.center, center, sx, sy);\n ctx.getContainerScale(content, center, sx, sy, contents);\n },\n skew(content, center, sx, sy, contents) {\n ctx.skewPoint(content.center, center, sx, sy);\n ctx.getContainerSkew(content, center, sx, sy, contents);\n },\n explode(content, contents) {\n return ctx.getContentsExplode(getAllContentsFromCache(content, contents));\n },\n break(content, points, contents) {\n return ctx.getContentsBreak(getAllContentsFromCache(content, contents), points, contents);\n },\n render(content, renderCtx) {\n return renderCtx.target.renderGroup(ctx.renderContainerChildren({ contents: getAllContentsFromCache(content, renderCtx.contents), variableValues: content.variableValues }, renderCtx));\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const bounding = ctx.getContentsBounding(content.contents, contents);\n if (!bounding) {\n return { editPoints: [] };\n }\n const base = {\n x: ctx.getTwoNumberCenter(bounding.start.x, bounding.end.x),\n y: ctx.getTwoNumberCenter(bounding.start.y, bounding.end.y)\n };\n const editPoints = [\n {\n ...base,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPolarArrayContent(c)) {\n return;\n }\n ctx.getContainerMove(c, {\n x: cursor.x - start.x,\n y: cursor.y - start.y\n });\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: content.center.x,\n y: content.center.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPolarArrayContent(c)) {\n return;\n }\n c.center.x += cursor.x - start.x;\n c.center.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ];\n if (content.rowCount > 1) {\n const p = ctx.getPointByLengthAndDirection(base, -content.rowSpacing, content.center);\n editPoints.push({\n ...p,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPolarArrayContent(c)) {\n return;\n }\n c.rowSpacing = ctx.getTwoPointsDistance(cursor, base);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n });\n }\n if (content.rowCount > 2) {\n const p = ctx.getPointByLengthAndDirection(base, -(content.rowCount - 1) * content.rowSpacing, content.center);\n editPoints.push({\n ...p,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPolarArrayContent(c)) {\n return;\n }\n c.rowCount = Math.round(ctx.getTwoPointsDistance(cursor, base) / c.rowSpacing) + 1;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n });\n }\n if (content.itemCount > 1) {\n const p = ctx.rotatePositionByCenter(base, content.center, -content.itemAngle);\n editPoints.push({\n ...p,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPolarArrayContent(c)) {\n return;\n }\n c.itemAngle = ctx.radianToAngle(ctx.getTwoPointsRadian(cursor, content.center) - ctx.getTwoPointsRadian(base, content.center));\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n });\n }\n if (content.itemCount > 2) {\n const p = ctx.rotatePositionByCenter(base, content.center, -(content.itemCount - 1) * content.itemAngle);\n editPoints.push({\n ...p,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isPolarArrayContent(c)) {\n return;\n }\n let angle = ctx.radianToAngle(ctx.getTwoPointsRadian(cursor, content.center) - ctx.getTwoPointsRadian(base, content.center));\n if (c.itemAngle > 0) {\n if (angle < 0) {\n angle += 360;\n }\n } else {\n if (angle > 0) {\n angle -= 360;\n }\n }\n c.itemCount = Math.round(angle / c.itemAngle) + 1;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n });\n }\n return {\n editPoints\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getContentsSnapPoints(content, contents, (c) => getAllContentsFromCache(c, contents));\n },\n getGeometries,\n propertyPanel(content, update, _, { acquirePoint }) {\n return {\n center: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPolarArrayContent(c)) {\n c.center.x = p.x, c.center.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.center.x, setValue: (v) => update((c) => {\n if (isPolarArrayContent(c)) {\n c.center.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.center.y, setValue: (v) => update((c) => {\n if (isPolarArrayContent(c)) {\n c.center.y = v;\n }\n }) })\n }\n }\n ),\n rowCount: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.rowCount, setValue: (v) => update((c) => {\n if (isPolarArrayContent(c)) {\n c.rowCount = v;\n }\n }) }),\n itemCount: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.itemCount, setValue: (v) => update((c) => {\n if (isPolarArrayContent(c)) {\n c.itemCount = v;\n }\n }) }),\n rowSpacing: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.rowSpacing, setValue: (v) => update((c) => {\n if (isPolarArrayContent(c)) {\n c.rowSpacing = v;\n }\n }) }),\n itemAngle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.itemAngle, setValue: (v) => update((c) => {\n if (isPolarArrayContent(c)) {\n c.itemAngle = v;\n }\n }) }),\n ...ctx.getVariableValuesContentPropertyPanel(content, ctx.getContainerVariableNames(content), update)\n };\n },\n isValid: (c, p) => ctx.validate(c, PolarArrayContent, p),\n getRefIds\n };\n}\nfunction isPolarArrayContent(content) {\n return content.type === "polar array";\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "30", cy: "22", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "67", cy: "23", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "82", cy: "53", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "67", cy: "81", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "28", cy: "79", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "13", cy: "50", r: "12", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create polar array",\n useCommand({ onEnd, type, scale, contents }) {\n let message = "";\n if (type) {\n message = "specify target point";\n }\n const { input, setInputPosition, cursorPosition, setCursorPosition, resetInput } = ctx.useCursorInput(message);\n return {\n onStart(p) {\n resetInput();\n onEnd({\n updateContents: (contents2, selected) => {\n const target = contents2.filter((c, i) => c && ctx.isSelected([i], selected) && contentSelectable(c, contents2));\n const bounding = ctx.getContentsBounding(target, contents2);\n if (!bounding)\n return;\n const newContent = {\n type: "polar array",\n center: p,\n contents: target,\n rowCount: 1,\n rowSpacing: ctx.getTwoPointsDistance(bounding.end, bounding.start) * 1.5,\n itemCount: 6,\n itemAngle: 60\n };\n ctx.deleteSelectedContents(contents2, selected.map((c) => c[0]));\n contents2.push(newContent);\n setCursorPosition(void 0);\n }\n });\n },\n input,\n onMove(p, viewportPosition) {\n setInputPosition(viewportPosition || p);\n if (!type) {\n return;\n }\n setCursorPosition(p);\n },\n updateSelectedContent(content) {\n var _a, _b;\n if (cursorPosition) {\n const bounding = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content, contents).bounding;\n if (!bounding)\n return {};\n const base = {\n x: ctx.getTwoNumberCenter(bounding.start.x, bounding.end.x),\n y: ctx.getTwoNumberCenter(bounding.start.y, bounding.end.y)\n };\n return {\n newContents: [\n {\n type: "polar array",\n center: cursorPosition,\n contents: [content],\n rowCount: 1,\n rowSpacing: ctx.getTwoPointsDistance(bounding.end, bounding.start) * 1.5,\n itemCount: 6,\n itemAngle: 60\n }\n ],\n assistentContents: [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [base, cursorPosition]\n }\n ]\n };\n }\n return {};\n },\n reset: resetInput\n };\n },\n contentSelectable,\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isPolarArrayContent\n};\n','// dev/cad-editor/plugins/polygon.plugin.tsx\nfunction getModel(ctx) {\n const PolygonContent = ctx.and(ctx.BaseContent("polygon"), ctx.StrokeFields, ctx.FillFields, {\n points: [ctx.Position]\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getPolygonGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n const lines = Array.from(ctx.iteratePolygonLines(content.points));\n return {\n lines,\n points: content.points,\n bounding: ctx.getPointsBounding(content.points),\n renderingLines: ctx.dashedPolylineToLines(ctx.polygonToPolyline(content.points), content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points: content.points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n return {\n type: "polygon",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point, offset);\n }\n },\n rotate(content, center, angle) {\n for (const point of content.points) {\n ctx.rotatePoint(point, center, angle);\n }\n },\n scale(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.scalePoint(point, center, sx, sy);\n }\n },\n skew(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.skewPoint(point, center, sx, sy);\n }\n },\n mirror(content, line) {\n for (const point of content.points) {\n ctx.mirrorPoint(point, line);\n }\n },\n explode(content, contents) {\n const { lines } = getPolygonGeometries(content, contents);\n return lines.map((line) => ({ type: "line", points: line }));\n },\n break(content, intersectionPoints, contents) {\n const { lines } = getPolygonGeometries(content, contents);\n return ctx.breakPolyline(lines, intersectionPoints);\n },\n offset(content, point, distance, contents) {\n const { lines } = getPolygonGeometries(content, contents);\n if (!distance) {\n distance = Math.min(...lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n const index = ctx.getLinesOffsetDirection(point, lines);\n const points = ctx.getParallelPolylineByDistance(lines, distance, index);\n return ctx.trimOffsetResult(points.slice(0, points.length - 1), point, true, contents).map((p) => ctx.produce(content, (d) => {\n d.points = p;\n }));\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderPolygon(content.points, options);\n },\n getOperatorRenderPosition(content) {\n return content.points[0];\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => ({ editPoints: ctx.getPolylineEditPoints(content, isPolygonContent, true) }));\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points, lines } = getPolygonGeometries(content, contents);\n return [\n ...points.map((p) => ({ ...p, type: "endpoint" })),\n ...lines.map(([start, end]) => ({\n x: (start.x + end.x) / 2,\n y: (start.y + end.y) / 2,\n type: "midpoint"\n }))\n ];\n });\n },\n getGeometries: getPolygonGeometries,\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { x: 0, y: 0 }, (v) => update((c) => {\n if (isPolygonContent(c)) {\n v(c);\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isPolygonContent(c)) {\n c.points[i].x = p.x, c.points[i].y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.x, setValue: (v) => update((c) => {\n if (isPolygonContent(c)) {\n c.points[i].x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.y, setValue: (v) => update((c) => {\n if (isPolygonContent(c)) {\n c.points[i].y = v;\n }\n }) })\n }\n }\n ))\n }\n ),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, PolygonContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point) => ctx.pointInPolygon(point, content.points)\n };\n}\nfunction isPolygonContent(content) {\n return content.type === "polygon";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "10,81 86,83 88,39 52,10 12,35", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create polygon",\n useCommand({ onEnd, type, scale, strokeStyleId, fillStyleId }) {\n const [createType, setCreateType] = React.useState("point");\n const { polygon, onClick, onMove, input, startSetSides, startPosition, cursorPosition, reset } = ctx.usePolygonClickCreate(\n type === "create polygon",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ points: c, strokeStyleId, fillStyleId, type: "polygon" })\n }),\n {\n toEdge: createType === "edge",\n setSidesKey: "S",\n switchTypeKey: "T",\n switchType: () => setCreateType(createType === "edge" ? "point" : "edge")\n }\n );\n const assistentContents = [];\n if (startPosition && cursorPosition) {\n assistentContents.push({ type: "line", points: [startPosition, cursorPosition], dashArray: [4 / scale] });\n }\n if (polygon) {\n assistentContents.push({ points: polygon, strokeStyleId, fillStyleId, type: "polygon" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n reset,\n subcommand: type === "create polygon" ? /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("button", { onClick: startSetSides, style: { position: "relative" } }, "set sides(S)"), /* @__PURE__ */ React.createElement("button", { onClick: () => setCreateType(createType === "edge" ? "point" : "edge"), style: { position: "relative" } }, createType, "(T)")) : void 0,\n assistentContents,\n lastPosition: startPosition\n };\n },\n selectCount: 0,\n hotkey: "POL",\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isPolygonContent\n};\n','// dev/cad-editor/plugins/circle-arc.plugin.tsx\nfunction isCircleContent(content) {\n return content.type === "circle";\n}\nfunction isArcContent(content) {\n return content.type === "arc";\n}\n\n// dev/cad-editor/plugins/radial-dimension.plugin.tsx\nfunction getModel(ctx) {\n const RadialDimensionReferenceContent = ctx.and(ctx.BaseContent("radial dimension reference"), ctx.StrokeFields, ctx.ArrowFields, ctx.RadialDimension, {\n ref: ctx.PartRef\n });\n const getRefIds = (content) => [...ctx.getStrokeRefIds(content), ...ctx.toRefId(content.ref.id, true)];\n const radialDimensionReferenceCache = new ctx.WeakmapValuesCache();\n function getRadialDimensionReferenceGeometriesFromCache(content, contents, patches) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return radialDimensionReferenceCache.get(content, refs, () => {\n var _a, _b;\n const target = ctx.getRefPart(content.ref, contents, contentSelectable, patches);\n if (target) {\n return ctx.getRadialDimensionGeometries(content, target, {\n arrowAngle: (_a = content.arrowAngle) != null ? _a : ctx.dimensionStyle.arrowAngle,\n arrowSize: (_b = content.arrowSize) != null ? _b : ctx.dimensionStyle.arrowSize,\n margin: ctx.dimensionStyle.margin\n }, getTextPosition);\n }\n return { lines: [], points: [], renderingLines: [] };\n });\n }\n const textPositionMap = new ctx.WeakmapCache2();\n function getTextPosition(content, circle) {\n return textPositionMap.get(content, circle, () => {\n return ctx.getRadialDimensionTextPosition(content, circle, ctx.dimensionStyle.margin, ctx.getTextSizeFromCache);\n });\n }\n const React = ctx.React;\n return {\n type: "radial dimension reference",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n move(content, offset) {\n ctx.movePoint(content.position, offset);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content.position, center, sx, sy);\n },\n skew(content, center, sx, sy) {\n ctx.skewPoint(content.position, center, sx, sy);\n },\n render(content, renderCtx) {\n const { options, contents, target, fillOptions, strokeColor } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { regions, lines } = getRadialDimensionReferenceGeometriesFromCache(content, contents, renderCtx.patches);\n const children = [];\n for (const line of lines) {\n children.push(target.renderPolyline(line, options));\n }\n if (regions && regions.length > 0) {\n children.push(target.renderPolygon(regions[0].points, fillOptions));\n }\n const referenceTarget = ctx.getRefPart(content.ref, contents, contentSelectable, renderCtx.patches);\n if (referenceTarget) {\n const { textPosition, textRotation, text } = getTextPosition(content, referenceTarget);\n const textOptions = ctx.getTextStyleRenderOptionsFromRenderContext(strokeColor, renderCtx);\n children.push(target.renderGroup(\n [\n target.renderText(textPosition.x, textPosition.y, text, strokeColor, content.fontSize, content.fontFamily, textOptions)\n ],\n {\n rotation: textRotation,\n base: textPosition\n }\n ));\n }\n return target.renderGroup(children);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n x: content.position.x,\n y: content.position.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRadialDimensionReferenceContent(c)) {\n return;\n }\n c.position.x += cursor.x - start.x;\n c.position.y += cursor.y - start.y;\n const target = ctx.getRefPart(content.ref, contents, contentSelectable);\n if (!target || ctx.getTwoPointsDistance(target, c.position) > target.r) {\n return;\n }\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [target, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getRadialDimensionReferenceGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint, acquireContent }) {\n return {\n ref: [\n /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquireContent({ count: 1, part: true, selectable: (v) => contentSelectable(ctx.getContentByIndex(contents, v)) }, (r) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.ref = r[0];\n }\n })) }, "select"),\n typeof content.ref.id === "number" ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref.id, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.ref.id = v;\n }\n }) }) : void 0,\n content.ref.partIndex !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.ref.partIndex, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.ref.partIndex = v;\n }\n }) }) : void 0\n ],\n position: /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.position.x = p.x, c.position.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.position.x, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.position.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.position.y, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.position.y = v;\n }\n }) })\n }\n }\n ),\n text: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.text !== void 0, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.text = v ? "" : void 0;\n }\n }) }),\n content.text !== void 0 ? /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.text, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.text = v;\n }\n }) }) : void 0\n ],\n fontSize: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.fontSize, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.fontSize = v;\n }\n }) }),\n fontFamily: /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.fontFamily, setValue: (v) => update((c) => {\n if (isRadialDimensionReferenceContent(c)) {\n c.fontFamily = v;\n }\n }) }),\n ...ctx.getArrowContentPropertyPanel(content, update),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, RadialDimensionReferenceContent, p),\n getRefIds,\n updateRefId(content, update) {\n const newRefId = update(content.ref.id);\n if (newRefId !== void 0) {\n content.ref.id = newRefId;\n }\n ctx.updateStrokeRefIds(content, update);\n },\n deleteRefId: ctx.deleteStrokeRefIds\n };\n}\nfunction isRadialDimensionReferenceContent(content) {\n return content.type === "radial dimension reference";\n}\nfunction contentSelectable(content) {\n return !!content && (isArcContent(content) || isCircleContent(content));\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "36", cy: "64", r: "31", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "36,64 90,9", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "75,32 65,22 54,44", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "create radial dimension",\n selectCount: 1,\n selectType: "select part",\n icon,\n contentSelectable,\n useCommand({ onEnd, selected, type, strokeStyleId }) {\n const [result, setResult] = React.useState();\n const [text, setText] = React.useState();\n let message = "";\n if (type) {\n message = "input text";\n }\n const { input, clearText, setCursorPosition, setInputPosition, resetInput } = ctx.useCursorInput(message, type ? (e, text2) => {\n if (e.key === "Enter") {\n setText(text2);\n if (result) {\n setResult({ ...result, text: text2 });\n }\n clearText();\n }\n } : void 0);\n const reset = () => {\n setResult(void 0);\n resetInput();\n setText(void 0);\n };\n return {\n input,\n onStart() {\n if (result) {\n onEnd({\n updateContents: (draft) => {\n if (selected.length > 0 && type) {\n const { content, path } = selected[0];\n if (contentSelectable(content)) {\n result.ref = {\n id: path[0],\n partIndex: path[1]\n };\n }\n }\n draft.push({\n type: "radial dimension reference",\n position: result.position,\n fontSize: result.fontSize,\n fontFamily: result.fontFamily,\n ref: result.ref,\n text: result.text,\n strokeStyleId\n });\n },\n nextCommand: type\n });\n reset();\n }\n },\n onMove(p, viewportPosition) {\n setInputPosition(viewportPosition || p);\n setCursorPosition(p);\n if (selected.length > 0 && type) {\n const { content, path } = selected[0];\n if (contentSelectable(content)) {\n setResult({\n type: "radial dimension reference",\n position: p,\n fontSize: 16,\n fontFamily: "monospace",\n ref: {\n id: path[0],\n partIndex: path[1]\n },\n text,\n strokeStyleId\n });\n }\n }\n },\n assistentContents: result ? [result] : void 0,\n reset\n };\n }\n };\n}\nexport {\n getCommand,\n getModel,\n isRadialDimensionReferenceContent\n};\n','// dev/cad-editor/plugins/ray.plugin.tsx\nfunction getModel(ctx) {\n const RayContent = ctx.and(ctx.BaseContent("ray"), ctx.StrokeFields, ctx.Ray);\n const getRefIds = (content) => ctx.getStrokeRefIds(content);\n function getRayGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n return {\n lines: [{ type: "ray", line: content }],\n renderingLines: []\n };\n });\n }\n const React = ctx.React;\n const rayModel = {\n type: "ray",\n ...ctx.strokeModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle) {\n ctx.rotatePoint(content, center, angle);\n content.angle += angle;\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content, center, sx, sy);\n },\n mirror(content, line, angle) {\n ctx.mirrorPoint(content, line);\n content.angle = 2 * angle - content.angle;\n },\n break(content, intersectionPoints, contents) {\n return ctx.breakGeometryLines(getRayGeometries(content, contents).lines, intersectionPoints).flat().map((n) => ctx.geometryLineToContent(n));\n },\n offset(content, point, distance) {\n if (!distance) {\n distance = ctx.getPointAndRayNearestPointAndDistance(point, content).distance;\n }\n const index = ctx.pointSideToIndex(ctx.getPointSideOfGeometryLine(point, { type: "ray", line: content }));\n return ctx.getParallelRaysByDistance(content, distance)[index];\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n return target.renderRay(content.x, content.y, content.angle, { ...options, bidirectional: content.bidirectional });\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => ({\n editPoints: [{\n x: content.x,\n y: content.y,\n cursor: "move",\n type: "move",\n update(c, { cursor, start, scale }) {\n if (!isRayContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n }]\n }));\n },\n getSnapPoints(content) {\n return ctx.getSnapPointsFromCache(content, () => {\n return [{ x: content.x, y: content.y, type: "endpoint" }];\n });\n },\n getGeometries: getRayGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isRayContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isRayContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isRayContent(c)) {\n c.y = v;\n }\n }) }),\n angle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.angle, setValue: (v) => update((c) => {\n if (isRayContent(c)) {\n c.angle = v;\n }\n }) }),\n bidirectional: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.bidirectional || false, setValue: (v) => update((c) => {\n if (isRayContent(c)) {\n c.bidirectional = v;\n }\n }) }),\n reversed: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.reversed || false, setValue: (v) => update((c) => {\n if (isRayContent(c)) {\n c.reversed = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, RayContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds,\n reverse: (content) => ({ ...content, ...ctx.reverseRay(content) })\n };\n return rayModel;\n}\nfunction isRayContent(content) {\n return content.type === "ray";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "10", cy: "87", r: "12", strokeWidth: "0", vectorEffect: "non-scaling-stroke", fill: "currentColor", stroke: "#000000" }), /* @__PURE__ */ React.createElement("polyline", { points: "10,87 87,9", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create ray",\n useCommand({ onEnd, type, strokeStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create ray",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ type: "ray", x: c[0].x, y: c[0].y, angle: ctx.radianToAngle(ctx.getTwoPointsRadian(c[1], c[0])), strokeStyleId })\n }),\n { once: true }\n );\n const assistentContents = [];\n if (line && line.length > 1) {\n const start = line[line.length - 2];\n const end = line[line.length - 1];\n const angle = ctx.radianToAngle(ctx.getTwoPointsRadian(end, start));\n assistentContents.push({ type: "ray", x: start.x, y: start.y, angle, strokeStyleId });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0,\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isRayContent\n};\n','// dev/cad-editor/plugins/rect-array.plugin.tsx\nfunction getModel(ctx) {\n const RectArrayContent = ctx.and(ctx.BaseContent("rect array"), ctx.ContainerFields, {\n rowCount: ctx.number,\n rowSpacing: ctx.number,\n columnCount: ctx.number,\n columnSpacing: ctx.number\n });\n const getRefIds = (content) => ctx.toRefIds(content.contents);\n const getAllContentsFromCache = (content) => {\n return ctx.allContentsCache.get(content, () => {\n const result = [];\n for (let i = 0; i < content.columnCount; i++) {\n const x = i * content.columnSpacing;\n for (let j = 0; j < content.rowCount; j++) {\n const y = j * content.rowSpacing;\n if (x === 0 && y === 0) {\n result.push(...content.contents);\n } else {\n result.push(...content.contents.map((c) => {\n var _a;\n if (!c)\n return;\n const move = (_a = ctx.getContentModel(c)) == null ? void 0 : _a.move;\n if (!move)\n return;\n return ctx.produce(c, (draft) => {\n move(draft, { x, y });\n });\n }));\n }\n }\n }\n return result;\n });\n };\n const getGeometries = (content, contents) => ctx.getContentsGeometries(content, contents, getRefIds, [content], getAllContentsFromCache);\n const React = ctx.React;\n return {\n type: "rect array",\n ...ctx.containerModel,\n move: ctx.getContainerMove,\n rotate(content, center, angle, contents) {\n const x = content.columnSpacing * (content.columnCount - 1) * 0.5;\n const y = content.rowSpacing * (content.rowCount - 1) * 0.5;\n content.contents.forEach((c) => {\n var _a, _b, _c;\n if (!c)\n return;\n const m = ctx.getContentModel(c);\n if (!m)\n return;\n (_a = m.move) == null ? void 0 : _a.call(m, c, { x, y });\n (_b = m.rotate) == null ? void 0 : _b.call(m, c, center, angle, contents);\n (_c = m.move) == null ? void 0 : _c.call(m, c, { x: -x, y: -y });\n });\n },\n scale(content, center, sx, sy, contents) {\n ctx.getContainerScale(content, center, sx, sy, contents);\n content.rowSpacing *= sx;\n content.columnSpacing *= sy;\n },\n explode(content) {\n return ctx.getContentsExplode(getAllContentsFromCache(content));\n },\n break(content, points, contents) {\n return ctx.getContentsBreak(getAllContentsFromCache(content), points, contents);\n },\n render(content, renderCtx) {\n return renderCtx.target.renderGroup(ctx.renderContainerChildren({ contents: getAllContentsFromCache(content), variableValues: content.variableValues }, renderCtx));\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const bounding = ctx.getContentsBounding(content.contents, contents);\n if (!bounding) {\n return { editPoints: [] };\n }\n const base = {\n x: ctx.getTwoNumberCenter(bounding.start.x, bounding.end.x),\n y: ctx.getTwoNumberCenter(bounding.start.y, bounding.end.y)\n };\n return {\n editPoints: [\n {\n ...base,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRectArrayContent(c)) {\n return;\n }\n ctx.getContainerMove(c, {\n x: cursor.x - start.x,\n y: cursor.y - start.y\n });\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: base.x + content.columnSpacing,\n y: base.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRectArrayContent(c)) {\n return;\n }\n c.columnSpacing = cursor.x - base.x;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: base.x,\n y: base.y + content.rowSpacing,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRectArrayContent(c)) {\n return;\n }\n c.rowSpacing = cursor.y - base.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: base.x + content.columnSpacing * (content.columnCount - 1),\n y: base.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRectArrayContent(c)) {\n return;\n }\n let columnCount = Math.round((cursor.x - base.x) / content.columnSpacing);\n if (columnCount < 0) {\n columnCount = -columnCount;\n c.columnSpacing = -content.columnSpacing;\n }\n c.columnCount = columnCount + 1;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: base.x,\n y: base.y + content.rowSpacing * (content.rowCount - 1),\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRectArrayContent(c)) {\n return;\n }\n let rowCount = Math.round((cursor.y - base.y) / content.rowSpacing);\n if (rowCount < 0) {\n rowCount = -rowCount;\n c.rowSpacing = -content.rowSpacing;\n }\n c.rowCount = rowCount + 1;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n {\n x: base.x + content.columnSpacing * (content.columnCount - 1),\n y: base.y + content.rowSpacing * (content.rowCount - 1),\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRectArrayContent(c)) {\n return;\n }\n let rowCount = Math.round((cursor.y - base.y) / content.rowSpacing);\n if (rowCount < 0) {\n rowCount = -rowCount;\n c.rowSpacing = -content.rowSpacing;\n }\n let columnCount = Math.round((cursor.x - base.x) / content.columnSpacing);\n if (columnCount < 0) {\n columnCount = -columnCount;\n c.columnSpacing = -content.columnSpacing;\n }\n c.rowCount = rowCount + 1;\n c.columnCount = columnCount + 1;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getContentsSnapPoints(content, contents, getAllContentsFromCache);\n },\n getGeometries,\n propertyPanel(content, update) {\n return {\n rowCount: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.rowCount, setValue: (v) => update((c) => {\n if (isRectArrayContent(c)) {\n c.rowCount = v;\n }\n }) }),\n columnCount: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.columnCount, setValue: (v) => update((c) => {\n if (isRectArrayContent(c)) {\n c.columnCount = v;\n }\n }) }),\n rowSpacing: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.rowSpacing, setValue: (v) => update((c) => {\n if (isRectArrayContent(c)) {\n c.rowSpacing = v;\n }\n }) }),\n columnSpacing: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.columnSpacing, setValue: (v) => update((c) => {\n if (isRectArrayContent(c)) {\n c.columnSpacing = v;\n }\n }) }),\n ...ctx.getVariableValuesContentPropertyPanel(content, ctx.getContainerVariableNames(content), update)\n };\n },\n isValid: (c, p) => ctx.validate(c, RectArrayContent, p),\n getRefIds\n };\n}\nfunction isRectArrayContent(content) {\n return content.type === "rect array";\n}\nfunction getCommand(ctx) {\n function contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n }\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "3", y: "70", width: "40", height: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "58", y: "70", width: "40", height: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "3", y: "35", width: "40", height: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "58", y: "35", width: "40", height: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "3", y: "0", width: "40", height: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "58", y: "1", width: "40", height: "27", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create rect array",\n execute({ contents, selected }) {\n const target = contents.filter((c, i) => c && ctx.isSelected([i], selected) && contentSelectable(c, contents));\n const bounding = ctx.getContentsBounding(target, contents);\n if (!bounding)\n return;\n const newContent = {\n type: "rect array",\n contents: target,\n rowCount: 3,\n rowSpacing: -(bounding.end.y - bounding.start.y) * 1.5,\n columnCount: 4,\n columnSpacing: (bounding.end.x - bounding.start.x) * 1.5\n };\n ctx.deleteSelectedContents(contents, selected.map((c) => c[0]));\n contents.push(newContent);\n },\n contentSelectable,\n icon\n };\n}\nexport {\n getCommand,\n getModel,\n isRectArrayContent\n};\n','// dev/cad-editor/plugins/rect.plugin.tsx\nfunction getModel(ctx) {\n const RectContent = ctx.and(ctx.BaseContent("rect"), ctx.StrokeFields, ctx.FillFields, ctx.Region, {\n angle: ctx.number\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getRectGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n const points = [\n { x: content.x - content.width / 2, y: content.y - content.height / 2 },\n { x: content.x + content.width / 2, y: content.y - content.height / 2 },\n { x: content.x + content.width / 2, y: content.y + content.height / 2 },\n { x: content.x - content.width / 2, y: content.y + content.height / 2 }\n ].map((p) => ctx.rotatePositionByCenter(p, content, -content.angle));\n const lines = Array.from(ctx.iteratePolygonLines(points));\n return {\n lines,\n points,\n midpoints: lines.map((line) => ctx.getTwoPointCenter(...line)),\n bounding: ctx.getPointsBounding(points),\n renderingLines: ctx.dashedPolylineToLines(ctx.polygonToPolyline(points), content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n return {\n type: "rect",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle) {\n ctx.rotatePoint(content, center, angle);\n content.angle += angle;\n },\n scale(content, center, sx, sy, contents) {\n if (content.angle) {\n const points = ctx.produce(getRectGeometries(content, contents).points, (draft) => {\n for (const p of draft) {\n ctx.scalePoint(p, center, sx, sy);\n }\n });\n return { ...content, points, type: "polygon" };\n }\n ctx.scalePoint(content, center, sx, sy);\n content.width *= sx;\n content.height *= sy;\n return;\n },\n skew(content, center, sx, sy, contents) {\n const points = ctx.produce(getRectGeometries(content, contents).points, (draft) => {\n for (const p of draft) {\n ctx.skewPoint(p, center, sx, sy);\n }\n });\n return { ...content, points, type: "polygon" };\n },\n explode(content, contents) {\n const { lines } = getRectGeometries(content, contents);\n return lines.map((line) => ({ type: "line", points: line }));\n },\n break(content, intersectionPoints, contents) {\n const { lines } = getRectGeometries(content, contents);\n return ctx.breakPolyline(lines, intersectionPoints);\n },\n mirror(content, line, angle) {\n ctx.mirrorPoint(content, line);\n content.angle = 2 * angle - content.angle;\n },\n offset(content, point, distance, contents) {\n var _a;\n if (!distance) {\n distance = Math.min(...getRectGeometries(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= 2 * (((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point, contents)) ? -1 : 1);\n return ctx.produce(content, (d) => {\n d.width += distance;\n d.height += distance;\n });\n },\n render(content, renderCtx) {\n const { options, dashed, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n if (dashed) {\n const { points } = getRectGeometries(content, renderCtx.contents);\n return target.renderPolygon(points, options);\n }\n return target.renderRect(content.x - content.width / 2, content.y - content.height / 2, content.width, content.height, { ...options, angle: content.angle });\n },\n getOperatorRenderPosition(content, contents) {\n const { points } = getRectGeometries(content, contents);\n return points[0];\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points, midpoints } = getRectGeometries(content, contents);\n return {\n editPoints: [\n { x: content.x, y: content.y, direction: "center" },\n { ...points[0], direction: "left-top" },\n { ...points[1], direction: "right-top" },\n { ...points[2], direction: "right-bottom" },\n { ...points[3], direction: "left-bottom" },\n { ...midpoints[0], direction: "top" },\n { ...midpoints[1], direction: "right" },\n { ...midpoints[2], direction: "bottom" },\n { ...midpoints[3] || midpoints[1], direction: "left" }\n ].map((p, i) => ({\n x: p.x,\n y: p.y,\n type: i === 0 ? "move" : void 0,\n cursor: ctx.getResizeCursor(content.angle, p.direction),\n update(c, { cursor, start, scale }) {\n if (!isRectContent(c)) {\n return;\n }\n const offset = ctx.getResizeOffset(start, cursor, p.direction, -ctx.angleToRadian(content.angle));\n if (!offset) {\n return;\n }\n c.x += offset.x + offset.width / 2;\n c.y += offset.y + offset.height / 2;\n c.width = Math.abs(c.width + offset.width);\n c.height = Math.abs(c.height + offset.height);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }))\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points, midpoints } = getRectGeometries(content, contents);\n return [\n { x: content.x, y: content.y, type: "center" },\n ...points.map((p) => ({ ...p, type: "endpoint" })),\n ...midpoints.map((p) => ({ ...p, type: "midpoint" }))\n ];\n });\n },\n getGeometries: getRectGeometries,\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isRectContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isRectContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isRectContent(c)) {\n c.y = v;\n }\n }) }),\n width: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.width, setValue: (v) => update((c) => {\n if (isRectContent(c)) {\n c.width = v;\n }\n }) }),\n height: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.height, setValue: (v) => update((c) => {\n if (isRectContent(c)) {\n c.height = v;\n }\n }) }),\n angle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.angle, setValue: (v) => update((c) => {\n if (isRectContent(c)) {\n c.angle = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, RectContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point, contents) => ctx.pointInPolygon(point, getRectGeometries(content, contents).points),\n getArea: (content) => content.width * content.height\n };\n}\nfunction isRectContent(content) {\n return content.type === "rect";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "11", y: "26", width: "79", height: "48", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create rect",\n icon,\n useCommand({ onEnd, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create rect",\n (c) => onEnd({\n updateContents: (contents) => contents.push({\n type: "rect",\n x: (c[0].x + c[1].x) / 2,\n y: (c[0].y + c[1].y) / 2,\n width: Math.abs(c[0].x - c[1].x),\n height: Math.abs(c[0].y - c[1].y),\n angle: 0,\n strokeStyleId,\n fillStyleId\n })\n }),\n {\n once: true\n }\n );\n const assistentContents = [];\n if (line) {\n assistentContents.push({\n type: "rect",\n x: (line[0].x + line[1].x) / 2,\n y: (line[0].y + line[1].y) / 2,\n width: Math.abs(line[0].x - line[1].x),\n height: Math.abs(line[0].y - line[1].y),\n angle: 0,\n strokeStyleId,\n fillStyleId\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0,\n hotkey: "REC"\n };\n}\nexport {\n getCommand,\n getModel,\n isRectContent\n};\n','// dev/cad-editor/plugins/regular-polygon.plugin.tsx\nfunction getModel(ctx) {\n const RegularPolygonContent = ctx.and(ctx.BaseContent("regular polygon"), ctx.StrokeFields, ctx.FillFields, ctx.Position, {\n radius: ctx.number,\n count: ctx.number,\n angle: ctx.number\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getRegularPolygonGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n var _a;\n const angle = -((_a = content.angle) != null ? _a : 0);\n const p0 = ctx.rotatePositionByCenter({ x: content.x + content.radius, y: content.y }, content, angle);\n const points = [];\n for (let i = 0; i < content.count; i++) {\n points.push(ctx.rotatePositionByCenter(p0, content, 360 / content.count * i));\n }\n const lines = Array.from(ctx.iteratePolygonLines(points));\n return {\n points,\n lines,\n bounding: ctx.getPointsBounding(points),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0,\n renderingLines: ctx.dashedPolylineToLines(ctx.polygonToPolyline(points), content.dashArray)\n };\n });\n }\n const React = ctx.React;\n return {\n type: "regular polygon",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n scale(content, center, sx, sy, contents) {\n if (sx !== sy) {\n const points = ctx.produce(getRegularPolygonGeometriesFromCache(content, contents).points, (draft) => {\n for (const p of draft) {\n ctx.scalePoint(p, center, sx, sy);\n }\n });\n return { ...content, points, type: "polygon" };\n }\n ctx.scalePoint(content, center, sx, sy);\n content.radius *= sx;\n return;\n },\n skew(content, center, sx, sy, contents) {\n const points = ctx.produce(getRegularPolygonGeometriesFromCache(content, contents).points, (draft) => {\n for (const p of draft) {\n ctx.skewPoint(p, center, sx, sy);\n }\n });\n return { ...content, points, type: "polygon" };\n },\n offset(content, point, distance, contents) {\n var _a;\n if (!distance) {\n distance = Math.min(...getRegularPolygonGeometriesFromCache(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= ((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point, contents)) ? -1 : 1;\n const radius = distance / Math.cos(Math.PI / content.count);\n return ctx.produce(content, (d) => {\n d.radius += radius;\n });\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getRegularPolygonGeometriesFromCache(content, renderCtx.contents);\n return target.renderPolygon(points, options);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points } = getRegularPolygonGeometriesFromCache(content, contents);\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n type: "move",\n update(c, { cursor, start, scale }) {\n if (!isRegularPolygonContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n ...points.map((p) => ({\n x: p.x,\n y: p.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRegularPolygonContent(c)) {\n return;\n }\n c.radius = ctx.getTwoPointsDistance(cursor, c);\n c.angle = ctx.radianToAngle(ctx.getTwoPointsRadian(cursor, c));\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }))\n ]\n };\n });\n },\n getGeometries: getRegularPolygonGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isRegularPolygonContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isRegularPolygonContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isRegularPolygonContent(c)) {\n c.y = v;\n }\n }) }),\n radius: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.radius, setValue: (v) => update((c) => {\n if (isRegularPolygonContent(c)) {\n c.radius = v;\n }\n }) }),\n count: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.count, setValue: (v) => update((c) => {\n if (isRegularPolygonContent(c)) {\n c.count = v;\n }\n }) }),\n angle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.angle, setValue: (v) => update((c) => {\n if (isRegularPolygonContent(c)) {\n c.angle = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n canSelectPart: true,\n isValid: (c, p) => ctx.validate(c, RegularPolygonContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point, contents) => ctx.pointInPolygon(point, getRegularPolygonGeometriesFromCache(content, contents).points)\n };\n}\nfunction isRegularPolygonContent(content) {\n return content.type === "regular polygon";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "91,40 53,7 10,33 22,82 72,85", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create regular polygon",\n icon,\n useCommand({ onEnd, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create regular polygon",\n ([p0, p1]) => onEnd({\n updateContents: (contents) => {\n contents.push({\n type: "regular polygon",\n x: p0.x,\n y: p0.y,\n radius: ctx.getTwoPointsDistance(p0, p1),\n count: 5,\n angle: ctx.radianToAngle(ctx.getTwoPointsRadian(p1, p0)),\n strokeStyleId,\n fillStyleId\n });\n }\n }),\n {\n once: true\n }\n );\n const assistentContents = [];\n if (line) {\n const [p0, p1] = line;\n assistentContents.push({\n type: "regular polygon",\n x: p0.x,\n y: p0.y,\n radius: ctx.getTwoPointsDistance(p0, p1),\n count: 5,\n angle: ctx.radianToAngle(ctx.getTwoPointsRadian(p1, p0)),\n strokeStyleId,\n fillStyleId\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isRegularPolygonContent\n};\n','// dev/cad-editor/plugins/reverse.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "1,71 56,7", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "62,0 54,18 46,11", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "97,27 91,34", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "84,42 78,50", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "71,57 64,65", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "58,72 51,80", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "45,87 42,90", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "36,97 45,79 53,86", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n return {\n name: "reverse",\n execute({ contents, selected }) {\n contents.forEach((content, index) => {\n var _a, _b, _c, _d;\n if (content && ctx.isSelected([index], selected) && ((_b = (_a = this.contentSelectable) == null ? void 0 : _a.call(this, content, contents)) != null ? _b : true)) {\n const result = (_d = (_c = ctx.getContentModel(content)) == null ? void 0 : _c.reverse) == null ? void 0 : _d.call(_c, content, contents);\n if (result) {\n contents[index] = result;\n }\n }\n });\n },\n contentSelectable(content) {\n var _a;\n return !content.readonly && ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.reverse) !== void 0;\n },\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/ring.plugin.tsx\nfunction getModel(ctx) {\n const RingContent = ctx.and(ctx.BaseContent("ring"), ctx.StrokeFields, ctx.FillFields, ctx.AngleDeltaFields, ctx.Position, {\n outerRadius: ctx.number,\n innerRadius: ctx.number\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n function getRingGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n var _a;\n const angleDelta = (_a = content.angleDelta) != null ? _a : ctx.defaultAngleDelta;\n const arc1 = ctx.circleToArc({ ...content, r: content.outerRadius });\n const arc2 = ctx.circleToArc({ ...content, r: content.innerRadius });\n const points1 = ctx.arcToPolyline(arc1, angleDelta);\n const points2 = ctx.arcToPolyline(arc2, angleDelta);\n const lines = [{ type: "arc", curve: arc1 }, { type: "arc", curve: arc2 }];\n return {\n lines,\n bounding: ctx.getCircleBounding({ ...content, r: content.outerRadius }),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points: points1,\n holes: [points2]\n }\n ] : void 0,\n renderingLines: [\n ...ctx.dashedPolylineToLines(ctx.polygonToPolyline(points1), content.dashArray),\n ...ctx.dashedPolylineToLines(ctx.polygonToPolyline(points2), content.dashArray)\n ]\n };\n });\n }\n const React = ctx.React;\n return {\n type: "ring",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n ...ctx.angleDeltaModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content, center, sx, sy);\n content.innerRadius *= sx;\n content.outerRadius *= sx;\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { renderingLines, regions } = getRingGeometriesFromCache(content, renderCtx.contents);\n if (regions) {\n return target.renderPath([regions[0].points, ...regions[0].holes || []], options);\n }\n return target.renderGroup(renderingLines.map((r) => target.renderPolyline(r, options)));\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isRingContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getRingGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isRingContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isRingContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isRingContent(c)) {\n c.y = v;\n }\n }) }),\n outerRadius: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.outerRadius, setValue: (v) => update((c) => {\n if (isRingContent(c)) {\n c.outerRadius = v;\n }\n }) }),\n innerRadius: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.innerRadius, setValue: (v) => update((c) => {\n if (isRingContent(c)) {\n c.innerRadius = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents),\n ...ctx.getAngleDeltaContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, RingContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds\n };\n}\nfunction isRingContent(content) {\n return content.type === "ring";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "91,50 91,53 91,57 90,60 89,64 87,67 86,70 84,74 82,76 79,79 76,82 74,84 70,86 67,87 64,89 60,90 57,91 53,91 50,91 46,91 42,91 39,90 35,89 32,87 29,86 25,84 23,82 20,79 17,76 15,74 13,70 12,67 10,64 9,60 8,57 8,53 8,50 8,46 8,42 9,39 10,35 12,32 13,29 15,25 17,23 20,20 23,17 25,15 29,13 32,12 35,10 39,9 42,8 46,8 49,8 53,8 57,8 60,9 64,10 67,12 70,13 74,15 76,17 79,20 82,23 84,25 86,29 87,32 89,35 90,39 91,42 91,46 91,49", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "70,50 70,51 70,53 70,55 69,57 68,58 68,60 67,62 66,63 64,64 63,66 62,67 60,68 58,68 57,69 55,70 53,70 51,70 50,70 48,70 46,70 44,70 42,69 41,68 39,68 37,67 36,66 35,64 33,63 32,62 31,60 31,58 30,57 29,55 29,53 29,51 29,50 29,48 29,46 29,44 30,42 31,41 31,39 32,37 33,36 35,35 36,33 37,32 39,31 41,31 42,30 44,29 46,29 48,29 49,29 51,29 53,29 55,29 57,30 58,31 60,31 62,32 63,33 64,35 66,36 67,37 68,39 68,41 69,42 70,44 70,46 70,48 70,49", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create ring",\n icon,\n useCommand({ onEnd, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create ring",\n (c) => onEnd({\n updateContents: (contents) => {\n const outerRadius = ctx.getTwoPointsDistance(c[0], c[1]);\n contents.push({\n type: "ring",\n x: c[0].x,\n y: c[0].y,\n outerRadius,\n innerRadius: outerRadius * 0.5,\n strokeStyleId,\n fillStyleId\n });\n }\n }),\n {\n once: true\n }\n );\n const assistentContents = [];\n if (line) {\n const outerRadius = ctx.getTwoPointsDistance(line[0], line[1]);\n assistentContents.push({\n type: "ring",\n x: line[0].x,\n y: line[0].y,\n outerRadius,\n innerRadius: outerRadius * 0.5,\n strokeStyleId,\n fillStyleId\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isRingContent\n};\n','// dev/cad-editor/plugins/rotate.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "5,66 66,66 66,94 5,94", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "35", y: "26", width: "61", height: "28", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", transform: "rotate(56,66,40)" }));\n return {\n name: "rotate",\n icon,\n useCommand({ onEnd, transform, type, scale }) {\n const [changeOriginal, setChangeOriginal] = React.useState(true);\n const { offset, onStart, mask, center: startPosition, resetDragRotate } = ctx.useDragRotate(\n onEnd,\n {\n transform,\n transformOffset: (f) => f - 90,\n ignoreLeavingEvent: true\n }\n );\n let message = "";\n if (type) {\n message = startPosition ? "specify angle point" : "specify center point";\n }\n const { input, setInputPosition } = ctx.useCursorInput(message);\n let assistentContents;\n if (startPosition && (offset == null ? void 0 : offset.angle) !== void 0) {\n const r = ctx.getTwoPointsDistance(startPosition, offset);\n assistentContents = [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [startPosition, offset]\n },\n {\n type: "arc",\n x: startPosition.x,\n y: startPosition.y,\n r,\n dashArray: [4 / scale],\n startAngle: offset.angle > 180 || offset.angle < 0 ? offset.angle : 0,\n endAngle: offset.angle > 180 || offset.angle < 0 ? 0 : offset.angle\n },\n {\n type: "line",\n dashArray: [4 / scale],\n points: [startPosition, { x: startPosition.x + r, y: startPosition.y }]\n }\n ];\n }\n return {\n onStart,\n mask,\n input,\n onMove(_, p) {\n setInputPosition(p);\n },\n reset: resetDragRotate,\n subcommand: type ? /* @__PURE__ */ React.createElement(\n "button",\n {\n onClick: (e) => {\n setChangeOriginal(!changeOriginal);\n e.stopPropagation();\n }\n },\n changeOriginal ? "create new(N)" : "change original(Y)"\n ) : void 0,\n updateSelectedContent(content, contents, selected) {\n if (startPosition && (offset == null ? void 0 : offset.angle) !== void 0) {\n const angle = offset.angle;\n if (!changeOriginal) {\n return {\n newContents: [\n ctx.produce(content, (d) => {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(d)) == null ? void 0 : _a.rotate) == null ? void 0 : _b.call(_a, d, startPosition, angle, contents);\n })\n ]\n };\n }\n const [newContent, ...patches] = ctx.produceWithPatches(content, (draft) => {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.rotate) == null ? void 0 : _b.call(_a, draft, startPosition, angle, contents);\n });\n const assistentContents2 = ctx.updateReferencedContents(content, newContent, contents, selected);\n return {\n patches,\n assistentContents: assistentContents2\n };\n }\n return {};\n },\n assistentContents\n };\n },\n contentSelectable(content) {\n var _a;\n return !content.readonly && ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.rotate) !== void 0;\n },\n hotkey: "RO"\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/rounded-rect.plugin.tsx\nfunction getModel(ctx) {\n const RoundedRectContent = ctx.and(ctx.BaseContent("rounded rect"), ctx.StrokeFields, ctx.FillFields, ctx.Region, ctx.AngleDeltaFields, {\n radius: ctx.number\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n var _a;\n const rectPoints = [\n { x: content.x - content.width / 2, y: content.y - content.height / 2 },\n { x: content.x + content.width / 2, y: content.y - content.height / 2 },\n { x: content.x + content.width / 2, y: content.y + content.height / 2 },\n { x: content.x - content.width / 2, y: content.y + content.height / 2 }\n ];\n const points = ctx.getRoundedRectPoints(content, content.radius, (_a = content.angleDelta) != null ? _a : ctx.defaultAngleDelta);\n const lines = Array.from(ctx.iteratePolygonLines(points));\n const geometryLines = [\n { type: "arc", curve: { x: content.x - content.width / 2 + content.radius, y: content.y - content.height / 2 + content.radius, r: content.radius, startAngle: 180, endAngle: 270 } },\n [{ x: content.x - content.width / 2 + content.radius, y: content.y - content.height / 2 }, { x: content.x + content.width / 2 - content.radius, y: content.y - content.height / 2 }],\n { type: "arc", curve: { x: content.x + content.width / 2 - content.radius, y: content.y - content.height / 2 + content.radius, r: content.radius, startAngle: 270, endAngle: 360 } },\n [{ x: content.x + content.width / 2, y: content.y - content.height / 2 + content.radius }, { x: content.x + content.width / 2, y: content.y + content.height / 2 - content.radius }],\n { type: "arc", curve: { x: content.x + content.width / 2 - content.radius, y: content.y + content.height / 2 - content.radius, r: content.radius, startAngle: 0, endAngle: 90 } },\n [{ x: content.x + content.width / 2 - content.radius, y: content.y + content.height / 2 }, { x: content.x - content.width / 2 + content.radius, y: content.y + content.height / 2 }],\n { type: "arc", curve: { x: content.x - content.width / 2 + content.radius, y: content.y + content.height / 2 - content.radius, r: content.radius, startAngle: 80, endAngle: 180 } },\n [{ x: content.x - content.width / 2, y: content.y + content.height / 2 - content.radius }, { x: content.x - content.width / 2, y: content.y - content.height / 2 + content.radius }]\n ];\n return {\n lines: geometryLines,\n points: rectPoints,\n arcPoints: [\n { x: rectPoints[0].x + content.radius, y: rectPoints[0].y },\n { x: rectPoints[0].x, y: rectPoints[0].y + content.radius },\n { x: rectPoints[1].x - content.radius, y: rectPoints[1].y },\n { x: rectPoints[1].x, y: rectPoints[1].y + content.radius },\n { x: rectPoints[2].x - content.radius, y: rectPoints[2].y },\n { x: rectPoints[2].x, y: rectPoints[2].y - content.radius },\n { x: rectPoints[3].x + content.radius, y: rectPoints[3].y },\n { x: rectPoints[3].x, y: rectPoints[3].y - content.radius }\n ],\n bounding: ctx.getGeometryLinesBounding(geometryLines),\n renderingLines: ctx.dashedPolylineToLines(ctx.polygonToPolyline(points), content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n return {\n type: "rounded rect",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n ...ctx.angleDeltaModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content, center, sx, sy);\n content.width *= sx;\n content.height *= sy;\n content.radius *= sx;\n },\n offset(content, point, distance, contents) {\n var _a;\n if (!distance) {\n distance = Math.min(...getGeometries(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= ((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point, contents)) ? -2 : 2;\n return ctx.produce(content, (d) => {\n d.width += distance;\n d.height += distance;\n });\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { renderingLines } = getGeometries(content, renderCtx.contents);\n return target.renderPath(renderingLines, options);\n },\n renderIfSelected(content, { color, target, strokeWidth, contents }) {\n const { points, arcPoints } = getGeometries(content, contents);\n return target.renderGroup(points.map((p, i) => target.renderPolyline([arcPoints[2 * i], p, arcPoints[2 * i + 1]], { strokeColor: color, dashArray: [4], strokeWidth })));\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points } = getGeometries(content, contents);\n return {\n editPoints: [\n { x: content.x, y: content.y, direction: "center" },\n { ...points[0], direction: "left-top" },\n { ...points[1], direction: "right-top" },\n { ...points[2], direction: "right-bottom" },\n { ...points[3], direction: "left-bottom" }\n ].map((p) => ({\n x: p.x,\n y: p.y,\n cursor: ctx.getResizeCursor(0, p.direction),\n update(c, { cursor, start, scale }) {\n if (!isRoundedRectContent(c)) {\n return;\n }\n const offset = ctx.getResizeOffset(start, cursor, p.direction);\n if (!offset) {\n return;\n }\n c.x += offset.x + offset.width / 2;\n c.y += offset.y + offset.height / 2;\n c.width += offset.width;\n c.height += offset.height;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }))\n };\n });\n },\n getSnapPoints(content, contents) {\n return ctx.getSnapPointsFromCache(content, () => {\n const { points } = getGeometries(content, contents);\n return [\n { x: content.x, y: content.y, type: "center" },\n ...points.map((p) => ({ ...p, type: "endpoint" })),\n ...Array.from(ctx.iteratePolygonLines(points)).map(([start, end]) => ({\n x: (start.x + end.x) / 2,\n y: (start.y + end.y) / 2,\n type: "midpoint"\n }))\n ];\n });\n },\n getGeometries,\n canSelectPart: true,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isRoundedRectContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isRoundedRectContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isRoundedRectContent(c)) {\n c.y = v;\n }\n }) }),\n width: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.width, setValue: (v) => update((c) => {\n if (isRoundedRectContent(c)) {\n c.width = v;\n }\n }) }),\n height: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.height, setValue: (v) => update((c) => {\n if (isRoundedRectContent(c)) {\n c.height = v;\n }\n }) }),\n radius: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.radius, setValue: (v) => update((c) => {\n if (isRoundedRectContent(c)) {\n c.radius = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents),\n ...ctx.getAngleDeltaContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, RoundedRectContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point, contents) => ctx.pointInPolygon(point, getGeometries(content, contents).points)\n };\n}\nfunction isRoundedRectContent(content) {\n return content.type === "rounded rect";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("path", { d: "M 35 11 L 65 11 L 65 11 L 67 11 L 69 11 L 71 12 L 73 13 L 75 13 L 77 14 L 79 16 L 81 17 L 82 18 L 84 20 L 85 22 L 86 24 L 87 25 L 88 27 L 89 30 L 89 32 L 89 34 L 90 36 L 90 36 L 90 66 L 90 66 L 89 68 L 89 70 L 89 72 L 88 74 L 87 76 L 86 78 L 85 80 L 84 82 L 82 83 L 81 85 L 79 86 L 77 87 L 75 88 L 73 89 L 71 90 L 69 90 L 67 90 L 65 91 L 65 91 L 35 91 L 35 91 L 33 90 L 31 90 L 29 90 L 26 89 L 24 88 L 23 87 L 21 86 L 19 85 L 17 83 L 16 82 L 15 80 L 13 78 L 12 76 L 12 74 L 11 72 L 10 70 L 10 68 L 10 66 L 10 66 L 10 36 L 10 36 L 10 34 L 10 32 L 11 30 L 12 27 L 12 25 L 13 23 L 15 22 L 16 20 L 17 18 L 19 17 L 21 16 L 22 14 L 24 13 L 26 13 L 29 12 L 31 11 L 33 11 L 35 11", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor", fillRule: "evenodd" }));\n return {\n name: "create rounded rect",\n icon,\n useCommand({ onEnd, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create rounded rect",\n (c) => onEnd({\n updateContents: (contents) => {\n const width = Math.abs(c[0].x - c[1].x);\n const height = Math.abs(c[0].y - c[1].y);\n contents.push({\n type: "rounded rect",\n x: (c[0].x + c[1].x) / 2,\n y: (c[0].y + c[1].y) / 2,\n width,\n height,\n radius: Math.round(Math.min(width, height) / 4),\n strokeStyleId,\n fillStyleId\n });\n }\n }),\n {\n once: true\n }\n );\n const assistentContents = [];\n if (line) {\n const width = Math.abs(line[0].x - line[1].x);\n const height = Math.abs(line[0].y - line[1].y);\n assistentContents.push({\n type: "rounded rect",\n x: (line[0].x + line[1].x) / 2,\n y: (line[0].y + line[1].y) / 2,\n width,\n height,\n radius: Math.round(Math.min(width, height) / 4),\n strokeStyleId,\n fillStyleId\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isRoundedRectContent\n};\n','// dev/cad-editor/plugins/scale.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "12,11 91,11 91,90 12,90", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "40", y: "37", width: "42", height: "42", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "scale",\n useCommand({ onEnd, scale, type, selected, contents }) {\n const [data, setData] = React.useState();\n const [cursor, setCursor] = React.useState();\n let message = "";\n if (type) {\n message = data ? "specify scale" : "specify center point";\n }\n const { input, setInputPosition, resetInput, setCursorPosition } = ctx.useCursorInput(message, type ? (e, text) => {\n if (e.key === "Enter" && data) {\n const value = +text;\n if (!isNaN(value) && value > 0) {\n onEnd({\n updateContents(contents2, selected2) {\n contents2.forEach((content, index) => {\n var _a, _b;\n if (content && ctx.isSelected([index], selected2)) {\n const result = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.scale) == null ? void 0 : _b.call(_a, content, data.center, value, value, contents2);\n if (result) {\n contents2[index] = result;\n }\n }\n });\n }\n });\n reset();\n }\n }\n } : void 0);\n const reset = () => {\n setData(void 0);\n setCursor(void 0);\n resetInput();\n };\n return {\n onStart(s) {\n var _a, _b, _c;\n if (!type)\n return;\n if (!data) {\n const boundings = [];\n for (const c of selected) {\n const bounding2 = (_c = (_b = (_a = ctx.getContentModel(c.content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, c.content, contents)) == null ? void 0 : _c.bounding;\n if (bounding2) {\n boundings.push(bounding2);\n }\n }\n const bounding = ctx.mergeBoundings(boundings);\n if (bounding) {\n setData({ center: s, size: Math.max(bounding.end.x - bounding.start.x, bounding.end.y - bounding.start.y) });\n }\n } else {\n onEnd();\n reset();\n }\n },\n onMove(p, c) {\n if (!type)\n return;\n setInputPosition(c || p);\n setCursorPosition(c || p);\n if (data) {\n setCursor(p);\n }\n },\n reset,\n input,\n updateSelectedContent(content, contents2, selected2) {\n if (data && cursor) {\n const sx = ctx.getTwoNumbersDistance(cursor.x, data.center.x) / data.size;\n const sy = ctx.getTwoNumbersDistance(cursor.y, data.center.y) / data.size;\n if (!sx || !sy) {\n return {};\n }\n const [newContent, ...patches] = ctx.produceWithPatches(content, (draft) => {\n var _a, _b;\n return (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.scale) == null ? void 0 : _b.call(_a, draft, data.center, sx, sy, contents2);\n });\n const assistentContents = ctx.updateReferencedContents(content, newContent, contents2, selected2);\n return {\n patches,\n assistentContents\n };\n }\n return {};\n },\n assistentContents: data && cursor ? [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [data.center, cursor]\n }\n ] : void 0\n };\n },\n contentSelectable(content) {\n var _a;\n return !content.readonly && ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.scale) !== void 0;\n },\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/skew.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "5", y: "5", width: "51", height: "89", strokeWidth: "5", strokeDasharray: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polygon", { points: "40,5 92,5 57,95 5,95", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fillOpacity: "1", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return {\n name: "skew",\n useCommand({ onEnd, scale, type, selected, contents }) {\n const [data, setData] = React.useState();\n const [cursor, setCursor] = React.useState();\n let message = "";\n if (type) {\n message = data ? "specify skew" : "specify center point";\n }\n const { input, setInputPosition, resetInput, setCursorPosition } = ctx.useCursorInput(message, type ? (e, text) => {\n if (e.key === "Enter" && data) {\n const value = +text;\n if (!isNaN(value)) {\n onEnd({\n updateContents(contents2, selected2) {\n contents2.forEach((content, index) => {\n var _a, _b;\n if (content && ctx.isSelected([index], selected2)) {\n const result = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.skew) == null ? void 0 : _b.call(_a, content, data.center, value, 0, contents2);\n if (result) {\n contents2[index] = result;\n }\n }\n });\n }\n });\n reset();\n }\n }\n } : void 0);\n const reset = () => {\n setData(void 0);\n setCursor(void 0);\n resetInput();\n };\n return {\n onStart(s) {\n var _a, _b, _c;\n if (!type)\n return;\n if (!data) {\n const boundings = [];\n for (const c of selected) {\n const bounding2 = (_c = (_b = (_a = ctx.getContentModel(c.content)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, c.content, contents)) == null ? void 0 : _c.bounding;\n if (bounding2) {\n boundings.push(bounding2);\n }\n }\n const bounding = ctx.mergeBoundings(boundings);\n if (bounding) {\n setData({ center: s, size: Math.max(bounding.end.x - bounding.start.x, bounding.end.y - bounding.start.y) });\n }\n } else {\n onEnd();\n reset();\n }\n },\n onMove(p, c) {\n if (!type)\n return;\n setInputPosition(c || p);\n setCursorPosition(c || p);\n if (data) {\n setCursor(p);\n }\n },\n reset,\n input,\n updateSelectedContent(content, contents2, selected2) {\n if (data && cursor) {\n const sx = (cursor.x - data.center.x) / data.size;\n if (!sx) {\n return {};\n }\n const sy = (cursor.y - data.center.y) / data.size;\n const [newContent, ...patches] = ctx.produceWithPatches(content, (draft) => {\n var _a, _b;\n return (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.skew) == null ? void 0 : _b.call(_a, draft, data.center, sx, sy, contents2);\n });\n const assistentContents = ctx.updateReferencedContents(content, newContent, contents2, selected2);\n return {\n patches,\n assistentContents\n };\n }\n return {};\n },\n assistentContents: data && cursor ? [\n {\n type: "line",\n dashArray: [4 / scale],\n points: [data.center, cursor]\n }\n ] : void 0\n };\n },\n contentSelectable(content) {\n var _a;\n return !content.readonly && ((_a = ctx.getContentModel(content)) == null ? void 0 : _a.skew) !== void 0;\n },\n icon\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/spline.plugin.tsx\nfunction getModel(ctx) {\n const SplineContent = ctx.and(ctx.BaseContent("spline"), ctx.StrokeFields, ctx.FillFields, ctx.SegmentCountFields, {\n points: [ctx.Position],\n fitting: ctx.optional(ctx.or(ctx.boolean, "closed"))\n });\n const SplineArrowContent = ctx.and(ctx.BaseContent("spline arrow"), ctx.StrokeFields, ctx.SegmentCountFields, {\n points: [ctx.Position],\n fitting: ctx.optional(ctx.boolean)\n });\n const getSplineRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const getSplineArrowRefIds = (content) => ctx.getStrokeRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getSplineGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getSplineRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n var _a;\n let points;\n let lines;\n const splineSegmentCount = (_a = content.segmentCount) != null ? _a : ctx.defaultSegmentCount;\n if (content.points.length > 2) {\n if (content.fitting === "closed") {\n lines = ctx.getBezierSplineCurves([...content.points.slice(content.points.length - 3), ...content.points, ...content.points.slice(0, 3)]).map((c) => ({ type: "bezier curve", curve: c }));\n lines = lines.slice(3, lines.length - 2);\n } else if (content.fitting) {\n lines = ctx.getBezierSplineCurves(content.points).map((c) => ({ type: "bezier curve", curve: c }));\n } else if (content.points.length === 3) {\n lines = ctx.getQuadraticSplineCurves(content.points).map((c) => ({ type: "quadratic curve", curve: c }));\n } else {\n lines = ctx.getBezierSplineCurves(content.points, false).map((c) => ({ type: "bezier curve", curve: c }));\n }\n points = ctx.getGeometryLinesPoints(lines, splineSegmentCount);\n } else {\n points = content.points;\n lines = Array.from(ctx.iteratePolylineLines(points));\n }\n return {\n lines,\n points,\n bounding: ctx.getGeometryLinesBounding(lines),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points: content.points\n }\n ] : void 0\n };\n });\n }\n function getSplineArrowGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getSplineArrowRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n const geometry = getSplineGeometries(content, contents);\n let arrowPoints;\n let points = geometry.points;\n if (content.points.length > 1) {\n const p1 = content.points[content.points.length - 2];\n const p2 = content.points[content.points.length - 1];\n const r = ctx.getArrowPoints(p1, p2, content);\n arrowPoints = r.arrowPoints;\n const index = points.findIndex((p) => ctx.getTwoPointsDistance(p, p2) < r.distance);\n points = [...points.slice(0, index), r.endPoint];\n }\n const lines = Array.from(ctx.iteratePolylineLines(points));\n return {\n lines,\n points,\n bounding: ctx.getPointsBounding(points),\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray),\n regions: arrowPoints ? [\n {\n points: arrowPoints,\n lines: Array.from(ctx.iteratePolygonLines(arrowPoints))\n }\n ] : void 0\n };\n });\n }\n const React = ctx.React;\n const splineModel = {\n type: "spline",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n ...ctx.segmentCountModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point, offset);\n }\n },\n rotate(content, center, angle) {\n for (const point of content.points) {\n ctx.rotatePoint(point, center, angle);\n }\n },\n scale(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.scalePoint(point, center, sx, sy);\n }\n },\n skew(content, center, sx, sy) {\n for (const point of content.points) {\n ctx.skewPoint(point, center, sx, sy);\n }\n },\n mirror(content, line) {\n for (const point of content.points) {\n ctx.mirrorPoint(point, line);\n }\n },\n break(content, intersectionPoints, contents) {\n const lines = getSplineGeometries(content, contents).lines;\n return ctx.breakGeometryLinesToPathCommands(lines, intersectionPoints);\n },\n explode(content, contents) {\n const lines = getSplineGeometries(content, contents).lines;\n return [{ type: "path", commands: ctx.geometryLineToPathCommands(lines) }];\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getSplineGeometries(content, renderCtx.contents);\n return target.renderPolyline(points, options);\n },\n renderIfSelected(content, { color, target, strokeWidth }) {\n return target.renderPolyline(content.points, { strokeColor: color, dashArray: [4], strokeWidth });\n },\n getOperatorRenderPosition(content) {\n return content.points[0];\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => ({ editPoints: ctx.getPolylineEditPoints(content, isSplineContent, false, true) }));\n },\n getSnapPoints(content) {\n return ctx.getSnapPointsFromCache(content, () => content.points.map((p) => ({ ...p, type: "endpoint" })));\n },\n getGeometries: getSplineGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { x: 0, y: 0 }, (v) => update((c) => {\n if (isSplineContent(c)) {\n v(c);\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isSplineContent(c)) {\n c.points[i].x = p.x, c.points[i].y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.x, setValue: (v) => update((c) => {\n if (isSplineContent(c)) {\n c.points[i].x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.y, setValue: (v) => update((c) => {\n if (isSplineContent(c)) {\n c.points[i].y = v;\n }\n }) })\n }\n }\n ))\n }\n ),\n fitting: /* @__PURE__ */ React.createElement(ctx.EnumEditor, { enums: ["true", "false", "closed"], value: content.fitting === "closed" ? "closed" : content.fitting ? "true" : "false", setValue: (v) => update((c) => {\n if (isSplineContent(c)) {\n c.fitting = v === "closed" ? "closed" : v === "true" ? true : void 0;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents),\n ...ctx.getSegmentCountContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, SplineContent, p),\n getRefIds: getSplineRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n reverse: (content) => ({\n ...content,\n points: content.points.slice().reverse()\n })\n };\n return [\n splineModel,\n {\n type: "spline arrow",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n ...ctx.segmentCountModel,\n move: splineModel.move,\n rotate: splineModel.rotate,\n scale: splineModel.scale,\n mirror: splineModel.mirror,\n render(content, renderCtx) {\n const { options, target, fillOptions } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { regions, renderingLines } = getSplineArrowGeometries(content, renderCtx.contents);\n const children = [];\n for (const line of renderingLines) {\n children.push(target.renderPolyline(line, options));\n }\n if (regions) {\n for (let i = 0; i < 2 && i < regions.length; i++) {\n children.push(target.renderPolyline(regions[i].points, fillOptions));\n }\n }\n return target.renderGroup(children);\n },\n renderIfSelected: splineModel.renderIfSelected,\n getOperatorRenderPosition: splineModel.getOperatorRenderPosition,\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => ({ editPoints: ctx.getPolylineEditPoints(content, isSplineArrowContent, false, true) }));\n },\n getSnapPoints: splineModel.getSnapPoints,\n getGeometries: getSplineArrowGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n points: /* @__PURE__ */ React.createElement(\n ctx.ArrayEditor,\n {\n inline: true,\n ...ctx.getArrayEditorProps((v) => v.points, { x: 0, y: 0 }, (v) => update((c) => {\n if (isSplineArrowContent(c)) {\n v(c);\n }\n })),\n items: content.points.map((f, i) => /* @__PURE__ */ React.createElement(\n ctx.ObjectEditor,\n {\n inline: true,\n properties: {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isSplineArrowContent(c)) {\n c.points[i].x = p.x, c.points[i].y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.x, setValue: (v) => update((c) => {\n if (isSplineArrowContent(c)) {\n c.points[i].x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: f.y, setValue: (v) => update((c) => {\n if (isSplineArrowContent(c)) {\n c.points[i].y = v;\n }\n }) })\n }\n }\n ))\n }\n ),\n fitting: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.fitting === true, setValue: (v) => update((c) => {\n if (isSplineArrowContent(c)) {\n c.fitting = v ? true : void 0;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getArrowContentPropertyPanel(content, update),\n ...ctx.getSegmentCountContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, SplineArrowContent, p),\n getRefIds: getSplineArrowRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds,\n reverse: (content) => ({\n ...content,\n points: content.points.slice().reverse()\n })\n }\n ];\n}\nfunction isSplineContent(content) {\n return content.type === "spline";\n}\nfunction isSplineArrowContent(content) {\n return content.type === "spline arrow";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon1 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "13", cy: "22", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "28", cy: "79", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "63", cy: "22", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "85", cy: "80", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "13,22 14,24 14,26 15,29 15,31 16,33 17,34 17,36 18,38 18,40 19,41 20,43 20,44 21,46 22,47 22,49 23,50 23,51 24,52 25,53 25,54 26,55 27,56 27,56 28,57 29,58 29,58 30,59 31,59 31,59 32,60 33,60 33,60 34,60 35,60 35,60 36,60 37,60 37,59 38,59 39,58 39,58 40,57 41,57 41,56 42,55 43,55 43,54 44,53 45,52 46,51 46,49 47,48 48,47 48,46 49,46 50,45 50,44 51,44 52,43 53,43 53,42 54,42 55,42 56,41 56,41 57,41 58,41 59,41 59,41 60,42 61,42 62,42 63,43 63,43 64,44 65,44 66,45 67,46 67,47 68,47 69,48 70,49 71,51 71,52 72,53 73,54 74,56 75,57 76,59 76,60 77,62 78,64 79,65 80,67 81,69 82,71 82,73 83,75 84,78 85,80", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n const icon2 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "13", cy: "22", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "28", cy: "79", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "63", cy: "22", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "85", cy: "80", r: "5", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "13,22 13,23 13,24 13,25 13,26 13,27 14,28 14,29 14,30 14,31 14,31 14,32 14,33 14,34 14,35 14,36 14,37 15,38 15,39 15,40 15,41 15,42 15,43 15,43 15,44 15,45 15,46 15,47 16,48 16,49 16,49 16,50 16,51 16,52 16,53 16,54 16,54 17,55 17,56 17,57 17,58 17,58 17,59 17,60 17,61 18,61 18,62 18,63 18,63 18,64 18,65 18,65 18,66 19,67 19,67 19,68 19,69 19,69 19,70 19,70 20,71 20,71 20,72 20,72 20,73 20,73 21,74 21,74 21,75 21,75 21,75 21,76 22,76 22,77 22,77 22,77 22,78 23,78 23,78 23,78 23,79 23,79 24,79 24,79 24,79 24,79 25,80 25,80 25,80 25,80 25,80 26,80 26,80 26,80 26,80 27,80 27,80 27,79 27,79 28,79 28,79 28,79 29,79 29,78 29,78 29,78 30,77 30,77 30,77 31,76 31,76 31,76 32,75 32,75 32,74 32,74 33,73 33,73 33,72 34,72 34,71 34,71 35,70 35,69 35,69 36,68 36,68 37,67 37,66 37,66 38,65 38,64 38,64 39,63 39,62 39,62 40,61 40,60 40,59 41,59 41,58 42,57 42,56 42,56 43,55 43,54 43,53 44,53 44,52 45,51 45,50 45,50 46,49 46,48 46,47 47,47 47,46 48,45 48,44 48,44 49,43 49,42 50,41 50,41 50,40 51,39 51,39 51,38 52,37 52,37 53,36 53,35 53,35 54,34 54,33 54,33 55,32 55,31 55,31 56,30 56,30 57,29 57,29 57,28 58,28 58,27 58,27 59,26 59,26 59,25 60,25 60,25 60,24 61,24 61,24 61,23 62,23 62,23 62,22 63,22 63,22 63,22 64,22 64,22 64,21 65,21 65,21 65,21 65,21 66,21 66,21 66,21 67,21 67,21 67,22 67,22 68,22 68,22 68,22 69,22 69,23 69,23 69,23 70,23 70,24 70,24 70,24 71,25 71,25 71,25 71,26 72,26 72,27 72,27 72,27 73,28 73,28 73,29 73,29 73,30 74,31 74,31 74,32 74,32 75,33 75,33 75,34 75,35 75,35 76,36 76,37 76,37 76,38 76,39 77,39 77,40 77,41 77,42 77,42 78,43 78,44 78,45 78,46 78,46 79,47 79,48 79,49 79,50 79,50 80,51 80,52 80,53 80,54 80,55 80,56 81,57 81,57 81,58 81,59 81,60 82,61 82,62 82,63 82,64 82,65 82,66 83,67 83,68 83,69 83,69 83,70 83,71 84,72 84,73 84,74 84,75 84,76 84,77 85,78 85,79 85,80", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n const icon3 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "8,93 8,90 8,87 8,83 8,81 8,78 9,75 9,72 9,70 9,67 10,65 10,62 10,60 11,58 11,56 12,54 12,53 13,51 13,49 14,48 15,46 15,45 16,44 17,43 17,42 18,41 19,40 20,39 21,39 22,38 23,38 24,38 25,38 26,37 27,37 28,38 29,38 30,38 32,38 33,39 34,40 36,40 37,41 38,42 40,43 41,44 43,45 44,46 46,48 47,49 49,51 51,53 52,54 54,55 55,57 57,58 58,59 60,60 61,61 62,62 64,62 65,63 66,63 68,64 69,64 70,64 71,64 72,64 73,64 74,64 75,64 76,63 77,63 78,62 79,62 80,61 81,60 81,59 82,58 83,56 83,55 84,54 85,52 85,51 86,49 86,47 87,45 87,43 88,41 88,39 88,37 89,34 89,32 89,29 89,26 90,24 90,21 90,18 90,17", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "90,8 98,37 82,37", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" }));\n const splineCommand = {\n name: "create spline",\n type: [\n { name: "spline", hotkey: "SPL", icon: icon1 },\n { name: "spline fitting", icon: icon2 }\n ],\n useCommand({ onEnd, type, scale, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "spline" || type === "spline fitting",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ points: c, type: "spline", strokeStyleId, fillStyleId, fitting: type === "spline fitting" })\n })\n );\n const assistentContents = [];\n if (line) {\n assistentContents.push(\n { points: line, type: "spline", strokeStyleId, fillStyleId, fitting: type === "spline fitting" },\n { points: line, type: "polyline", dashArray: [4 / scale] }\n );\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n return [\n splineCommand,\n {\n name: "create spline arrow",\n icon: icon3,\n useCommand({ onEnd, type, scale, strokeStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create spline arrow",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ points: c, strokeStyleId, type: "spline arrow" })\n })\n );\n const assistentContents = [];\n if (line) {\n assistentContents.push(\n { points: line, strokeStyleId, type: "spline arrow" },\n { points: line, type: "polyline", dashArray: [4 / scale] }\n );\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isSplineArrowContent,\n isSplineContent\n};\n','// dev/cad-editor/plugins/star.plugin.tsx\nfunction getModel(ctx) {\n const StarContent = ctx.and(ctx.BaseContent("star"), ctx.StrokeFields, ctx.FillFields, ctx.Position, {\n outerRadius: ctx.number,\n innerRadius: ctx.number,\n count: ctx.number,\n angle: ctx.optional(ctx.number)\n });\n const getRefIds = (content) => ctx.getStrokeAndFillRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n function getStarGeometriesFromCache(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n var _a;\n const angle = -((_a = content.angle) != null ? _a : 0);\n const p0 = ctx.rotatePositionByCenter({ x: content.x + content.outerRadius, y: content.y }, content, angle);\n const p1 = ctx.rotatePositionByCenter({ x: content.x + content.innerRadius, y: content.y }, content, angle + 180 / content.count);\n const points = [];\n for (let i = 0; i < content.count; i++) {\n const angle2 = 360 / content.count * i;\n points.push(\n ctx.rotatePositionByCenter(p0, content, angle2),\n ctx.rotatePositionByCenter(p1, content, angle2)\n );\n }\n const lines = Array.from(ctx.iteratePolygonLines(points));\n return {\n points,\n lines,\n bounding: ctx.getPointsBounding(points),\n regions: ctx.hasFill(content) ? [\n {\n lines,\n points\n }\n ] : void 0,\n renderingLines: ctx.dashedPolylineToLines(ctx.polygonToPolyline(points), content.dashArray)\n };\n });\n }\n const React = ctx.React;\n return {\n type: "star",\n ...ctx.strokeModel,\n ...ctx.fillModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n scale(content, center, sx, sy, contents) {\n if (sx !== sy) {\n const points = ctx.produce(getStarGeometriesFromCache(content, contents).points, (draft) => {\n for (const p of draft) {\n ctx.scalePoint(p, center, sx, sy);\n }\n });\n return { ...content, points, type: "polygon" };\n }\n ctx.scalePoint(content, center, sx, sy);\n content.innerRadius *= sx;\n content.outerRadius *= sy;\n return;\n },\n skew(content, center, sx, sy, contents) {\n const points = ctx.produce(getStarGeometriesFromCache(content, contents).points, (draft) => {\n for (const p of draft) {\n ctx.skewPoint(p, center, sx, sy);\n }\n });\n return { ...content, points, type: "polygon" };\n },\n break(content, intersectionPoints, contents) {\n const { lines } = getStarGeometriesFromCache(content, contents);\n return ctx.breakPolyline(lines, intersectionPoints);\n },\n offset(content, point, distance, contents) {\n var _a;\n if (!distance) {\n distance = Math.min(...getStarGeometriesFromCache(content, contents).lines.map((line) => ctx.getPointAndGeometryLineMinimumDistance(point, line)));\n }\n distance *= ((_a = this.isPointIn) == null ? void 0 : _a.call(this, content, point, contents)) ? -1 : 1;\n const angle = Math.PI / content.count;\n const length = Math.sqrt(content.innerRadius ** 2 + content.outerRadius ** 2 - 2 * content.innerRadius * content.outerRadius * Math.cos(angle));\n distance *= length / Math.sin(angle);\n return ctx.produce(content, (d) => {\n d.outerRadius += distance / content.innerRadius;\n d.innerRadius += distance / content.outerRadius;\n });\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeFillRenderOptionsFromRenderContext(content, renderCtx);\n const { points } = getStarGeometriesFromCache(content, renderCtx.contents);\n return target.renderPolygon(points, options);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { points } = getStarGeometriesFromCache(content, contents);\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isStarContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n ...points.map((p, i) => ({\n x: p.x,\n y: p.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isStarContent(c)) {\n return;\n }\n if (i % 2 === 0) {\n c.outerRadius = ctx.getTwoPointsDistance(cursor, c);\n } else {\n c.innerRadius = ctx.getTwoPointsDistance(cursor, c);\n }\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }))\n ]\n };\n });\n },\n getGeometries: getStarGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n var _a;\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isStarContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isStarContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isStarContent(c)) {\n c.y = v;\n }\n }) }),\n outerRadius: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.outerRadius, setValue: (v) => update((c) => {\n if (isStarContent(c)) {\n c.outerRadius = v;\n }\n }) }),\n innerRadius: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.innerRadius, setValue: (v) => update((c) => {\n if (isStarContent(c)) {\n c.innerRadius = v;\n }\n }) }),\n count: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.count, setValue: (v) => update((c) => {\n if (isStarContent(c)) {\n c.count = v;\n }\n }) }),\n angle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_a = content.angle) != null ? _a : 0, setValue: (v) => update((c) => {\n if (isStarContent(c)) {\n c.angle = v === 0 ? void 0 : v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents),\n ...ctx.getFillContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, StarContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeAndFillRefIds,\n deleteRefId: ctx.deleteStrokeAndFillRefIds,\n isPointIn: (content, point, contents) => ctx.pointInPolygon(point, getStarGeometriesFromCache(content, contents).points)\n };\n}\nfunction isStarContent(content) {\n return content.type === "star";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polygon", { points: "75,84 70,56 90,36 62,32 49,7 37,33 9,37 29,56 25,84 50,71", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create star",\n icon,\n useCommand({ onEnd, type, strokeStyleId, fillStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create star",\n ([p0, p1]) => onEnd({\n updateContents: (contents) => {\n const outerRadius = ctx.getTwoPointsDistance(p0, p1);\n contents.push({\n type: "star",\n x: p0.x,\n y: p0.y,\n outerRadius,\n innerRadius: outerRadius * 0.5,\n count: 5,\n angle: ctx.radianToAngle(ctx.getTwoPointsRadian(p1, p0)),\n strokeStyleId,\n fillStyleId\n });\n }\n }),\n {\n once: true\n }\n );\n const assistentContents = [];\n if (line) {\n const [p0, p1] = line;\n const outerRadius = ctx.getTwoPointsDistance(p0, p1);\n assistentContents.push({\n type: "star",\n x: p0.x,\n y: p0.y,\n outerRadius,\n innerRadius: outerRadius * 0.5,\n count: 5,\n angle: ctx.radianToAngle(ctx.getTwoPointsRadian(p1, p0)),\n strokeStyleId,\n fillStyleId\n });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0\n };\n}\nexport {\n getCommand,\n getModel,\n isStarContent\n};\n','// dev/cad-editor/plugins/stroke-style.plugin.tsx\nfunction getModel(ctx) {\n function getGeometriesFromCache(content) {\n return ctx.getGeometriesFromCache(content, /* @__PURE__ */ new Set(), () => {\n const points = [\n { x: content.x, y: content.y },\n { x: content.x + content.width, y: content.y },\n { x: content.x + content.width, y: content.y + content.height },\n { x: content.x, y: content.y + content.height }\n ];\n return {\n lines: [],\n bounding: ctx.getPointsBounding(points),\n regions: [\n {\n points,\n lines: Array.from(ctx.iteratePolygonLines(points))\n }\n ],\n renderingLines: []\n };\n });\n }\n const React = ctx.React;\n return {\n type: "stroke style",\n ...ctx.strokeModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n render(content, { target, getStrokeColor, transformStrokeWidth, transformColor }) {\n var _a;\n const options = {\n strokeColor: getStrokeColor(content),\n strokeWidth: transformStrokeWidth((_a = content.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(content)),\n dashArray: content.dashArray,\n strokeOpacity: content.strokeOpacity\n };\n return target.renderGroup([\n target.renderRect(content.x, content.y, content.width, content.height, {\n strokeColor: transformColor(content.isCurrent ? 16711680 : 0)\n }),\n target.renderPolyline([\n { x: content.x, y: content.y + content.height / 2 },\n { x: content.x + content.width, y: content.y + content.height / 2 }\n ], options)\n ]);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!ctx.isStrokeStyleContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n isCurrent: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.isCurrent === true, setValue: (v) => update((c, draft) => {\n if (ctx.isStrokeStyleContent(c)) {\n const currentStrokeStyle = ctx.getStrokeStyles(contents).find((s) => s.content.isCurrent);\n if (currentStrokeStyle) {\n const c2 = draft[currentStrokeStyle.index];\n if (c2 && ctx.isStrokeStyleContent(c2)) {\n c2.isCurrent = void 0;\n }\n }\n c.isCurrent = v ? true : void 0;\n }\n }) }),\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (ctx.isStrokeStyleContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (ctx.isStrokeStyleContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (ctx.isStrokeStyleContent(c)) {\n c.y = v;\n }\n }) }),\n width: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.width, setValue: (v) => update((c) => {\n if (ctx.isStrokeStyleContent(c)) {\n c.width = v;\n }\n }) }),\n height: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.height, setValue: (v) => update((c) => {\n if (ctx.isStrokeStyleContent(c)) {\n c.height = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, ctx.StrokeStyleContent, p)\n };\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "0,22 100,22", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "0,45 100,45", strokeWidth: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "0,65 100,65", strokeWidth: "5", strokeDasharray: "10 5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "0,81 100,81", strokeWidth: "5", strokeDasharray: "15", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create stroke style",\n selectCount: 0,\n icon,\n useCommand({ onEnd, type, scale }) {\n const [result, setResult] = React.useState();\n const reset = () => {\n setResult(void 0);\n };\n return {\n onStart() {\n if (result) {\n onEnd({\n updateContents: (contents) => {\n if (result) {\n contents.push(result);\n }\n }\n });\n reset();\n }\n },\n onMove(p) {\n if (type) {\n setResult({\n type: "stroke style",\n x: p.x,\n y: p.y,\n width: 100 / scale,\n height: 20 / scale\n });\n }\n },\n assistentContents: result ? [result] : void 0,\n reset\n };\n }\n };\n}\nexport {\n getCommand,\n getModel\n};\n','// dev/cad-editor/plugins/table.plugin.tsx\nfunction getModel(ctx) {\n const TableCellText = ctx.and(ctx.TextFields, {\n type: "table cell text",\n text: ctx.string,\n column: ctx.number\n });\n const TableRow = {\n height: ctx.number,\n cells: ctx.optional([TableCellText])\n };\n const MergedCell = {\n row: ctx.tuple(ctx.number, ctx.number),\n column: ctx.tuple(ctx.number, ctx.number)\n };\n const TableContent = ctx.and(ctx.BaseContent("table"), ctx.Position, ctx.StrokeFields, {\n rows: [TableRow],\n widths: [ctx.number],\n mergedCells: ctx.optional([MergedCell])\n });\n const getRefIds = (content) => ctx.getStrokeRefIds(content);\n const geometriesCache = new ctx.WeakmapValuesCache();\n const textLayoutResultCache = new ctx.WeakmapMap3Cache();\n const getGeometries = (content, contents) => {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return geometriesCache.get(content, refs, () => {\n const lines = [];\n const width = content.widths.reduce((p, c) => p + c, 0);\n const height = content.rows.reduce((p, c) => p + c.height, 0);\n lines.push([{ x: content.x, y: content.y }, { x: content.x + width, y: content.y }]);\n lines.push([{ x: content.x, y: content.y }, { x: content.x, y: content.y + height }]);\n const rows = [];\n const columns = [];\n const xs = [];\n const ys = [];\n const children = [];\n let x = content.x;\n content.widths.forEach((w) => {\n x += w;\n xs.push(x - w / 2);\n });\n let yStart = content.y;\n content.rows.forEach((row, i) => {\n const yMiddle = yStart + row.height / 2;\n const yEnd = yStart + row.height;\n ys.push(yMiddle);\n let xStart = content.x;\n content.widths.forEach((w, j) => {\n var _a, _b, _c;\n const xMiddle = xStart + w / 2;\n const xEnd = xStart + w;\n if (!((_a = content.mergedCells) == null ? void 0 : _a.some((c) => i >= c.row[0] && i < c.row[0] + c.row[1] - 1 && j >= c.column[0] && j < c.column[0] + c.column[1]))) {\n lines.push([{ x: xStart, y: yEnd }, { x: xEnd, y: yEnd }]);\n rows.push({ x: xMiddle, y: yEnd, index: i });\n }\n if (!((_b = content.mergedCells) == null ? void 0 : _b.some((c) => i >= c.row[0] && i < c.row[0] + c.row[1] && j >= c.column[0] && j < c.column[0] + c.column[1] - 1))) {\n lines.push([{ x: xEnd, y: yStart }, { x: xEnd, y: yEnd }]);\n columns.push({ x: xEnd, y: yMiddle, index: j });\n }\n const cell = (_c = content.mergedCells) == null ? void 0 : _c.find((c) => i >= c.row[0] && i < c.row[0] + c.row[1] && j >= c.column[0] && j < c.column[0] + c.column[1]);\n if (cell) {\n if (i === cell.row[0] && j === cell.column[0]) {\n const end = {\n x: xEnd,\n y: yEnd\n };\n for (let k = 1; k < cell.column[1] && k < content.widths.length - j; k++) {\n end.x += content.widths[j + k];\n }\n for (let k = 1; k < cell.row[1] && k < content.rows.length - i; k++) {\n end.y += content.rows[i + k].height;\n }\n children.push({\n row: i,\n column: j,\n x: xStart - content.x,\n y: yStart - content.y,\n width: end.x - xStart,\n height: end.y - yStart,\n region: ctx.getPolygonFromTwoPointsFormRegion({ start: { x: xStart, y: yStart }, end })\n });\n }\n } else {\n children.push({\n row: i,\n column: j,\n x: xStart - content.x,\n y: yStart - content.y,\n width: w,\n height: row.height,\n region: ctx.getPolygonFromTwoPointsFormRegion({ start: { x: xStart, y: yStart }, end: { x: xEnd, y: yEnd } })\n });\n }\n xStart = xEnd;\n });\n yStart = yEnd;\n });\n const bounding = { start: { x: content.x, y: content.y }, end: { x: content.x + width, y: content.y + height } };\n const polygon = ctx.getPolygonFromTwoPointsFormRegion(bounding);\n return {\n lines,\n rows,\n columns,\n xs,\n ys,\n bounding,\n renderingLines: lines.map((r) => ctx.dashedPolylineToLines(r, content.dashArray)).flat(),\n regions: [{\n points: polygon,\n lines: Array.from(ctx.iteratePolygonLines(polygon))\n }],\n children\n };\n });\n };\n const React = ctx.React;\n const tableModel = {\n type: "table",\n ...ctx.strokeModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n scale(content, center, sx, sy) {\n ctx.scalePoint(content, center, sx, sy);\n for (const row of content.rows) {\n row.height *= sy;\n }\n content.widths = content.widths.map((w) => w * sx);\n },\n render(content, renderCtx) {\n const geometries = getGeometries(content, renderCtx.contents);\n const { options, strokeColor } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const textOptions = ctx.getTextStyleRenderOptionsFromRenderContext(strokeColor, renderCtx);\n const children = geometries.renderingLines.map((line) => renderCtx.target.renderPolyline(line, options));\n content.rows.forEach((row, i) => {\n var _a;\n (_a = row.cells) == null ? void 0 : _a.forEach((cell) => {\n var _a2, _b;\n const child = geometries.children.find((f) => f.row === i && f.column === cell.column);\n if (!child)\n return;\n const { width, height } = child;\n const textStyleContent = ctx.getTextStyleContent(cell, renderCtx.contents);\n const textLayout = textLayoutResultCache.get(cell, textStyleContent, width, height, () => {\n var _a3, _b2, _c;\n const state = cell.text.split("");\n const getTextWidth = (text) => {\n var _a4, _b3;\n return (_b3 = (_a4 = ctx.getTextSizeFromCache(ctx.getTextStyleFont(textStyleContent), text)) == null ? void 0 : _a4.width) != null ? _b3 : 0;\n };\n return ctx.flowLayout({\n state,\n width,\n height,\n lineHeight: (_a3 = textStyleContent.lineHeight) != null ? _a3 : textStyleContent.fontSize * 1.2,\n getWidth: getTextWidth,\n align: (_b2 = textStyleContent.align) != null ? _b2 : "center",\n verticalAlign: (_c = textStyleContent.verticalAlign) != null ? _c : "middle",\n endContent: "",\n isNewLineContent: (c) => c === "\\n",\n isPartOfComposition: (c) => ctx.isWordCharactor(c),\n getComposition: (index) => ctx.getTextComposition(index, state, getTextWidth, (c) => c)\n });\n });\n const font = ctx.getTextStyleFont(textStyleContent);\n for (const { x, y, content: text } of textLayout.layoutResult) {\n const textWidth = (_b = (_a2 = ctx.getTextSizeFromCache(font, text)) == null ? void 0 : _a2.width) != null ? _b : 0;\n children.push(renderCtx.target.renderText(content.x + child.x + x + textWidth / 2, content.y + child.y + y + textStyleContent.fontSize, text, textStyleContent.color, textStyleContent.fontSize, textStyleContent.fontFamily, { textAlign: "center", cacheKey: cell, ...textOptions }));\n }\n });\n });\n return renderCtx.target.renderGroup(children);\n },\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const { rows, columns, xs, ys } = getGeometries(content, contents);\n return {\n editPoints: [\n {\n x: content.x,\n y: content.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isTableContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n },\n ...rows.map((p) => ({\n x: p.x,\n y: p.y,\n cursor: "row-resize",\n update(c, { cursor, start, scale }) {\n if (!isTableContent(c)) {\n return;\n }\n c.rows[p.index].height += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n })),\n ...columns.map((p) => ({\n x: p.x,\n y: p.y,\n cursor: "col-resize",\n update(c, { cursor, start, scale }) {\n if (!isTableContent(c)) {\n return;\n }\n c.widths[p.index] += cursor.x - start.x;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n })),\n ...xs.map((p, i) => ({\n x: p,\n y: content.y,\n cursor: "not-allowed",\n execute(c) {\n if (isTableContent(c)) {\n deleteTableColumn(c, i);\n }\n }\n })),\n ...ys.map((p, i) => ({\n x: content.x,\n y: p,\n cursor: "not-allowed",\n execute(c) {\n if (isTableContent(c)) {\n deleteTableRow(c, i);\n }\n }\n })),\n ...xs.map((p, i) => ({\n x: p + content.widths[i] / 2,\n y: content.y,\n cursor: "cell",\n execute(c) {\n if (isTableContent(c)) {\n insertTableColumn(c, i);\n }\n }\n })),\n ...ys.map((p, i) => ({\n x: content.x,\n y: p + content.rows[i].height / 2,\n cursor: "cell",\n execute(c) {\n if (isTableContent(c)) {\n insertTableRow(c, i);\n }\n }\n }))\n ]\n };\n });\n },\n getGeometries,\n propertyPanel(content, update, contents, options) {\n var _a, _b, _c, _d, _e;\n const properties = {};\n if (options.activeChild) {\n const [row, column] = options.activeChild;\n properties.row = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { readOnly: true, value: row });\n properties.column = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { readOnly: true, value: column });\n const mergedCell = (_b = (_a = content.mergedCells) == null ? void 0 : _a.find) == null ? void 0 : _b.call(_a, (c) => c.row[0] === row && c.column[0] === column);\n properties.rowSpan = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_c = mergedCell == null ? void 0 : mergedCell.row[1]) != null ? _c : 1, setValue: (v) => update((c) => {\n if (isTableContent(c)) {\n setTableRowSpan(c, row, column, v);\n }\n }) });\n properties.columnSpan = /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_d = mergedCell == null ? void 0 : mergedCell.column[1]) != null ? _d : 1, setValue: (v) => update((c) => {\n if (isTableContent(c)) {\n setTableColumnSpan(c, row, column, v);\n }\n }) });\n const cell = (_e = content.rows[row].cells) == null ? void 0 : _e.find((c) => c.column === column);\n if (cell) {\n Object.assign(properties, ctx.getTextContentPropertyPanel(cell, (f) => update((c) => {\n if (isTableContent(c)) {\n setTableCell(c, row, column, f);\n }\n }), contents));\n }\n }\n return {\n ...properties,\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isTableContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isTableContent(c)) {\n c.y = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n editPanel(content, scale, update, contents, cancel, transformPosition, activeChild) {\n var _a, _b, _c;\n const p = transformPosition(content);\n if (!activeChild)\n return /* @__PURE__ */ React.createElement(React.Fragment, null);\n const [row, column] = activeChild;\n const cell = (_a = content.rows[row].cells) == null ? void 0 : _a.find((c) => c.column === column);\n if (!cell)\n return /* @__PURE__ */ React.createElement(React.Fragment, null);\n const { children } = getGeometries(content, contents);\n const child = children.find((f) => f.row === row && f.column === column);\n if (!child)\n return /* @__PURE__ */ React.createElement(React.Fragment, null);\n const textStyleContent = ctx.getTextStyleContent(cell, contents);\n const fontSize = textStyleContent.fontSize * scale;\n return /* @__PURE__ */ React.createElement(\n ctx.TextEditor,\n {\n fontSize,\n width: child.width * scale,\n height: child.height * scale,\n color: textStyleContent.color,\n fontFamily: textStyleContent.fontFamily,\n align: (_b = textStyleContent.align) != null ? _b : "center",\n verticalAlign: (_c = textStyleContent.verticalAlign) != null ? _c : "middle",\n lineHeight: textStyleContent.lineHeight ? textStyleContent.lineHeight * scale : void 0,\n onCancel: cancel,\n x: p.x + child.x * scale,\n y: p.y + child.y * scale,\n borderWidth: 0,\n value: cell.text,\n setValue: (v) => update((c) => {\n if (isTableContent(c)) {\n setTableCell(c, row, column, (t) => t.text = v);\n }\n })\n }\n );\n },\n isValid: (c, p) => ctx.validate(c, TableContent, p),\n getRefIds,\n getChildByPoint(content, point, contents, { textStyleId }) {\n var _a;\n const { children } = getGeometries(content, contents);\n const child = children.find((c) => ctx.pointInPolygon(point, c.region));\n if (child) {\n if (!((_a = content.rows[child.row].cells) == null ? void 0 : _a.some((c) => c.column === child.column))) {\n const [, patches, reversePatches] = ctx.produceWithPatches(content, (draft) => {\n const row = draft.rows[child.row];\n if (!row.cells) {\n row.cells = [];\n }\n row.cells.push({\n type: "table cell text",\n textStyleId,\n text: "",\n color: 0,\n fontSize: 16,\n fontFamily: "monospace",\n column: child.column\n });\n });\n return {\n child: [child.row, child.column],\n patches: [patches, reversePatches]\n };\n }\n return {\n child: [child.row, child.column]\n };\n }\n return;\n }\n };\n return [\n tableModel,\n {\n type: "table cell text",\n ...ctx.textModel,\n isValid: (c, p) => ctx.validate(c, TableCellText, p)\n }\n ];\n}\nfunction isTableContent(content) {\n return content.type === "table";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "7,10 91,10", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,10 7,87", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "35,10 35,87", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "63,10 63,87", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "91,10 91,87", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,34 91,34", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,60 91,60", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "7,87 91,87", strokeWidth: "4", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create table",\n useCommand({ onEnd, strokeStyleId }) {\n const assistentContents = [];\n const [position, setPosition] = React.useState();\n const newContent = {\n type: "table",\n x: 0,\n y: 0,\n widths: [100, 100, 100],\n rows: [\n { height: 20 },\n { height: 20 },\n { height: 20 },\n { height: 20 }\n ],\n strokeStyleId\n };\n if (position) {\n assistentContents.push({\n ...newContent,\n x: position.x,\n y: position.y\n });\n }\n return {\n onStart(p) {\n onEnd({\n updateContents: (contents) => {\n contents.push({\n ...newContent,\n x: p.x,\n y: p.y\n });\n }\n });\n },\n onMove(p) {\n setPosition(p);\n },\n assistentContents,\n reset() {\n setPosition(void 0);\n }\n };\n },\n selectCount: 0,\n icon\n };\n}\nfunction deleteTableColumn(c, i) {\n c.widths.splice(i, 1);\n if (c.mergedCells) {\n const indexes = [];\n c.mergedCells.forEach((cell, k) => {\n if (i < cell.column[0]) {\n cell.column[0]--;\n } else if (i === cell.column[0]) {\n indexes.unshift(k);\n } else if (i < cell.column[0] + cell.column[1]) {\n cell.column[1]--;\n }\n });\n indexes.forEach((d) => {\n var _a;\n return (_a = c.mergedCells) == null ? void 0 : _a.splice(d, 1);\n });\n }\n}\nfunction deleteTableRow(c, i) {\n c.rows.splice(i, 1);\n if (c.mergedCells) {\n const indexes = [];\n c.mergedCells.forEach((cell, k) => {\n if (i < cell.row[0]) {\n cell.row[0]--;\n } else if (i === cell.row[0]) {\n indexes.unshift(k);\n } else if (i < cell.row[0] + cell.row[1]) {\n cell.row[1]--;\n }\n });\n indexes.forEach((d) => {\n var _a;\n return (_a = c.mergedCells) == null ? void 0 : _a.splice(d, 1);\n });\n }\n}\nfunction setTableRowSpan(c, row, column, v) {\n if (!c.mergedCells)\n c.mergedCells = [];\n const index = c.mergedCells.findIndex((m) => m.row[0] === row && m.column[0] === column);\n if (index < 0) {\n c.mergedCells.push({ row: [row, v], column: [column, 1] });\n } else if (v <= 1 && c.mergedCells[index].column[1] <= 1) {\n c.mergedCells.splice(index, 1);\n if (c.mergedCells.length === 0)\n c.mergedCells = void 0;\n } else {\n c.mergedCells[index].row[1] = v;\n }\n}\nfunction setTableColumnSpan(c, row, column, v) {\n if (!c.mergedCells)\n c.mergedCells = [];\n const index = c.mergedCells.findIndex((m) => m.row[0] === row && m.column[0] === column);\n if (index < 0) {\n c.mergedCells.push({ row: [row, 1], column: [column, v] });\n } else if (v <= 1 && c.mergedCells[index].row[1] <= 1) {\n c.mergedCells.splice(index, 1);\n if (c.mergedCells.length === 0)\n c.mergedCells = void 0;\n } else {\n c.mergedCells[index].column[1] = v;\n }\n}\nfunction insertTableColumn(c, i) {\n var _a;\n c.widths.splice(i, 0, c.widths[i]);\n (_a = c.mergedCells) == null ? void 0 : _a.forEach((cell) => {\n if (i < cell.column[0]) {\n cell.column[0]++;\n } else if (i < cell.column[0] + cell.column[1] - 1) {\n cell.column[1]++;\n }\n });\n}\nfunction insertTableRow(c, i) {\n var _a;\n c.rows.splice(i, 0, c.rows[i]);\n (_a = c.mergedCells) == null ? void 0 : _a.forEach((cell) => {\n if (i < cell.row[0]) {\n cell.row[0]++;\n } else if (i < cell.row[0] + cell.row[1] - 1) {\n cell.row[1]++;\n }\n });\n}\nfunction setTableCell(c, row, column, update) {\n var _a;\n const t = (_a = c.rows[row].cells) == null ? void 0 : _a.find((c2) => c2.column === column);\n if (t) {\n update(t);\n }\n}\nexport {\n getCommand,\n getModel,\n isTableContent\n};\n','// dev/cad-editor/plugins/text-style.plugin.tsx\nfunction getModel(ctx) {\n const geometriesCache = new ctx.WeakmapCache();\n function getGeometriesFromCache(content) {\n return geometriesCache.get(content, () => {\n var _a, _b;\n const text = `${content.fontFamily} ${content.fontSize} ${ctx.getColorString(content.color)}`;\n const width = (_b = (_a = ctx.getTextSizeFromCache(ctx.getTextStyleFont(content), text)) == null ? void 0 : _a.width) != null ? _b : 0;\n const height = content.fontSize * 1.2;\n const points = ctx.getPolygonFromTwoPointsFormRegion({ start: content, end: { x: content.x + width, y: content.y + height } });\n return {\n lines: [],\n bounding: ctx.getPointsBounding(points),\n text,\n width,\n height,\n regions: [\n {\n points,\n lines: Array.from(ctx.iteratePolygonLines(points))\n }\n ],\n renderingLines: []\n };\n });\n }\n const React = ctx.React;\n return {\n type: "text style",\n ...ctx.textModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n render(content, { target, transformColor }) {\n const { width, height, text } = getGeometriesFromCache(content);\n return target.renderGroup([\n target.renderRect(content.x, content.y, width, height, {\n strokeColor: transformColor(content.isCurrent ? 16711680 : 0)\n }),\n target.renderText(content.x, content.y, text, content.color, content.fontSize, content.fontFamily, { textBaseline: "top" })\n ]);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!ctx.isTextStyleContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getGeometriesFromCache,\n propertyPanel(content, update, contents, { acquirePoint }) {\n return {\n isCurrent: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.isCurrent === true, setValue: (v) => update((c, draft) => {\n if (ctx.isTextStyleContent(c)) {\n const currentTextStyle = ctx.getTextStyles(contents).find((s) => s.content.isCurrent);\n if (currentTextStyle) {\n const c2 = draft[currentTextStyle.index];\n if (c2 && ctx.isTextStyleContent(c2)) {\n c2.isCurrent = void 0;\n }\n }\n c.isCurrent = v ? true : void 0;\n }\n }) }),\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (ctx.isTextStyleContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (ctx.isTextStyleContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (ctx.isTextStyleContent(c)) {\n c.y = v;\n }\n }) }),\n ...ctx.getTextContentPropertyPanel(content, update)\n };\n },\n isValid: (c, p) => ctx.validate(c, ctx.TextStyleContent, p)\n };\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "6,7 40,7", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "23,7 23,43", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "61,7 82,7", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "72,7 72,26", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "51,49 90,49", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "71,47 71,94", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "11,71 32,71", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "21,71 21,89", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create text style",\n selectCount: 0,\n icon,\n useCommand({ onEnd, type }) {\n const [result, setResult] = React.useState();\n const reset = () => {\n setResult(void 0);\n };\n return {\n onStart() {\n if (result) {\n onEnd({\n updateContents: (contents) => {\n if (result) {\n contents.push(result);\n }\n }\n });\n reset();\n }\n },\n onMove(p) {\n if (type) {\n setResult({\n type: "text style",\n x: p.x,\n y: p.y,\n fontFamily: "monospace",\n fontSize: 20,\n color: 0\n });\n }\n },\n assistentContents: result ? [result] : void 0,\n reset\n };\n }\n };\n}\nexport {\n getCommand,\n getModel\n};\n','// dev/cad-editor/plugins/text.plugin.tsx\nfunction getModel(ctx) {\n const TextContent = ctx.and(ctx.BaseContent("text"), ctx.Position, ctx.TextFields, {\n text: ctx.string,\n width: ctx.optional(ctx.number),\n textVariableName: ctx.optional(ctx.string),\n angle: ctx.optional(ctx.number),\n scale: ctx.optional(ctx.or(ctx.number, ctx.Position))\n });\n const getRefIds = (content) => ctx.toRefId(content.textStyleId);\n const textLayoutResultCache = new ctx.WeakmapCache2();\n function getTextLayoutResult(content, c, variableContext) {\n return textLayoutResultCache.get(content, c, () => {\n var _a;\n const state = getText(content, variableContext).split("");\n const getTextWidth = (text) => {\n var _a2, _b;\n return (_b = (_a2 = ctx.getTextSizeFromCache(ctx.getTextStyleFont(c), text)) == null ? void 0 : _a2.width) != null ? _b : 0;\n };\n return ctx.flowLayout({\n state,\n width: content.width,\n lineHeight: (_a = c.lineHeight) != null ? _a : c.fontSize * 1.2,\n getWidth: getTextWidth,\n align: c.align,\n endContent: "",\n isNewLineContent: (c2) => c2 === "\\n",\n isPartOfComposition: (c2) => ctx.isWordCharactor(c2),\n getComposition: (index) => ctx.getTextComposition(index, state, getTextWidth, (c2) => c2)\n });\n });\n }\n function hasWidth(content) {\n return content.width !== void 0;\n }\n function getText(content, variableContext) {\n if (content.textVariableName && variableContext) {\n const text = variableContext[content.textVariableName];\n if (typeof text === "string") {\n return text;\n }\n }\n return content.text;\n }\n function getTextGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n let points;\n if (hasWidth(content)) {\n const textStyleContent = ctx.getTextStyleContent(content, contents);\n const { newContentHeight } = getTextLayoutResult(content, textStyleContent);\n points = [\n { x: content.x, y: content.y + newContentHeight },\n { x: content.x + content.width, y: content.y + newContentHeight },\n { x: content.x + content.width, y: content.y },\n { x: content.x, y: content.y }\n ];\n } else {\n const size = ctx.getTextSize(ctx.getTextStyleFont(content), content.text);\n if (!size) {\n throw "not supported";\n }\n points = [\n { x: content.x, y: content.y - size.height },\n { x: content.x + size.width, y: content.y - size.height },\n { x: content.x + size.width, y: content.y },\n { x: content.x, y: content.y }\n ];\n }\n const scale = ctx.getScaleOptionsScale(content);\n if (scale) {\n for (const p of points) {\n ctx.scalePoint(p, content, scale.x, scale.y);\n }\n }\n if (content.angle) {\n for (const p of points) {\n ctx.rotatePoint(p, content, content.angle);\n }\n }\n const lines = Array.from(ctx.iteratePolygonLines(points));\n return {\n lines: [],\n bounding: ctx.getPointsBounding(points),\n regions: [\n {\n lines,\n points\n }\n ],\n renderingLines: []\n };\n });\n }\n const React = ctx.React;\n return {\n type: "text",\n ...ctx.textModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle) {\n var _a;\n ctx.rotatePoint(content, center, angle);\n content.angle = ((_a = content.angle) != null ? _a : 0) + angle;\n },\n scale(content, center, sx, sy) {\n var _a, _b;\n ctx.scalePoint(content, center, sx, sy);\n const scale = ctx.getScaleOptionsScale(content);\n content.scale = {\n x: ((_a = scale == null ? void 0 : scale.x) != null ? _a : 1) * sx,\n y: ((_b = scale == null ? void 0 : scale.y) != null ? _b : 1) * sy\n };\n },\n mirror(content, line, angle) {\n var _a, _b, _c;\n ctx.mirrorPoint(content, line);\n content.angle = 2 * angle - ((_a = content.angle) != null ? _a : 0);\n const scale = ctx.getScaleOptionsScale(content);\n content.scale = {\n x: (_b = scale == null ? void 0 : scale.x) != null ? _b : 1,\n y: -((_c = scale == null ? void 0 : scale.y) != null ? _c : 1)\n };\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n x: content.x,\n y: content.y,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isTextContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n {\n x: content.x,\n y: content.y + content.fontSize * (content.width ? 1 : -1),\n cursor: "move",\n update(c, { cursor, scale }) {\n if (!isTextContent(c)) {\n return;\n }\n c.fontSize = Math.abs(cursor.y - content.y);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n },\n ...content.width ? [{\n x: content.x + content.width,\n y: content.y,\n cursor: "move",\n update(c, { cursor, scale }) {\n if (!isTextContent(c)) {\n return;\n }\n c.width = Math.abs(cursor.x - content.x);\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [content, cursor] }] };\n }\n }] : []\n ]\n };\n });\n },\n render(content, renderCtx) {\n var _a, _b;\n const { contents, transformColor, variableContext, isAssistence, target } = renderCtx;\n const textStyleContent = ctx.getTextStyleContent(content, contents);\n const color = transformColor(textStyleContent.color);\n const text = getText(content, variableContext);\n let cacheKey;\n if (isAssistence) {\n cacheKey = ctx.assistentTextCache.get(text, textStyleContent.fontSize, textStyleContent.color);\n }\n if (!cacheKey) {\n cacheKey = content;\n }\n const textOptions = ctx.getTextStyleRenderOptionsFromRenderContext(color, renderCtx);\n const children = [];\n if (hasWidth(content)) {\n const { layoutResult } = getTextLayoutResult(content, textStyleContent, variableContext);\n for (const { x, y, content: text2 } of layoutResult) {\n const textWidth = (_b = (_a = ctx.getTextSizeFromCache(ctx.getTextStyleFont(textStyleContent), text2)) == null ? void 0 : _a.width) != null ? _b : 0;\n children.push(target.renderText(content.x + x + textWidth / 2, content.y + y + textStyleContent.fontSize, text2, textStyleContent.color, textStyleContent.fontSize, textStyleContent.fontFamily, { textAlign: "center", cacheKey, ...textOptions }));\n }\n } else {\n children.push(target.renderText(content.x, content.y, text, color, textStyleContent.fontSize, textStyleContent.fontFamily, { cacheKey, ...textOptions }));\n }\n return target.renderGroup(children, { base: content, angle: content.angle, scale: content.scale });\n },\n getGeometries: getTextGeometries,\n propertyPanel(content, update, contents, { acquirePoint }) {\n var _a, _b, _c;\n const scale = ctx.getScaleOptionsScale(content);\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isTextContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.y = v;\n }\n }) }),\n ...ctx.getTextContentPropertyPanel(content, update, contents),\n text: /* @__PURE__ */ React.createElement(ctx.StringEditor, { textarea: true, value: content.text, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.text = v;\n }\n }) }),\n width: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.width !== void 0, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.width = v ? 600 : void 0;\n }\n }) }),\n content.width !== void 0 ? /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.width, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.width = v;\n }\n }) }) : void 0\n ],\n textVariableName: [\n /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.textVariableName !== void 0, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.textVariableName = v ? "" : void 0;\n }\n }) }),\n content.textVariableName !== void 0 ? /* @__PURE__ */ React.createElement(ctx.StringEditor, { value: content.textVariableName, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.textVariableName = v;\n }\n }) }) : void 0\n ],\n angle: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_a = content.angle) != null ? _a : 0, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.angle = v;\n }\n }) }),\n sx: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_b = scale == null ? void 0 : scale.x) != null ? _b : 1, setValue: (v) => update((c) => {\n var _a2;\n if (isTextContent(c)) {\n c.scale = { x: v, y: (_a2 = scale == null ? void 0 : scale.y) != null ? _a2 : v };\n }\n }) }),\n sy: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: (_c = scale == null ? void 0 : scale.y) != null ? _c : 1, setValue: (v) => update((c) => {\n var _a2;\n if (isTextContent(c)) {\n c.scale = { x: (_a2 = scale == null ? void 0 : scale.x) != null ? _a2 : v, y: v };\n }\n }) })\n };\n },\n editPanel(content, scale, update, contents, cancel, transformPosition) {\n const p = transformPosition(content);\n const textStyleContent = ctx.getTextStyleContent(content, contents);\n const fontSize = textStyleContent.fontSize * scale;\n if (content.width) {\n return /* @__PURE__ */ React.createElement(\n ctx.TextEditor,\n {\n fontSize,\n width: content.width * scale,\n color: textStyleContent.color,\n fontFamily: textStyleContent.fontFamily,\n align: textStyleContent.align,\n lineHeight: textStyleContent.lineHeight ? textStyleContent.lineHeight * scale : void 0,\n onCancel: cancel,\n x: p.x,\n y: p.y,\n value: content.text,\n setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.text = v;\n }\n })\n }\n );\n }\n return /* @__PURE__ */ React.createElement(ctx.StringEditor, { style: {\n zIndex: 10,\n position: "absolute",\n left: `${p.x - 1}px`,\n top: `${p.y - fontSize - 1}px`,\n fontSize: `${fontSize}px`,\n fontFamily: content.fontFamily,\n color: ctx.getColorString(content.color),\n padding: "0px"\n }, textarea: true, autoFocus: true, onCancel: cancel, value: content.text, setValue: (v) => update((c) => {\n if (isTextContent(c)) {\n c.text = v;\n }\n }) });\n },\n isValid: (c, p) => ctx.validate(c, TextContent, p),\n getRefIds,\n updateRefId: ctx.updateTextStyleRefIds,\n deleteRefId: ctx.deleteTextStyleRefIds,\n getVariableNames: (content) => content.textVariableName ? [content.textVariableName] : []\n };\n}\nfunction isTextContent(content) {\n return content.type === "text";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "16,22 83,22", strokeWidth: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "49,22 49,89", strokeWidth: "10", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }));\n return {\n name: "create text",\n icon,\n useCommand({ onEnd, type, scale, textStyleId, transformPosition, contents }) {\n const [start, setStart] = React.useState();\n const [cursor, setCursor] = React.useState();\n const [text, setText] = React.useState();\n const reset = () => {\n setText(void 0);\n setStart(void 0);\n setCursor(void 0);\n };\n const assistentContents = [];\n let panel;\n if (type) {\n if (text) {\n assistentContents.push(text);\n const p = transformPosition(text);\n const textStyleContent = ctx.getTextStyleContent(text, contents);\n const fontSize = textStyleContent.fontSize * scale;\n if (text.width) {\n panel = /* @__PURE__ */ React.createElement(\n ctx.TextEditor,\n {\n fontSize,\n width: text.width * scale,\n color: textStyleContent.color,\n fontFamily: textStyleContent.fontFamily,\n align: textStyleContent.align,\n lineHeight: textStyleContent.lineHeight ? textStyleContent.lineHeight * scale : void 0,\n onCancel: reset,\n x: p.x,\n y: p.y,\n value: text.text,\n setValue: (v) => setText({\n ...text,\n text: v\n })\n }\n );\n }\n } else if (cursor) {\n if (start) {\n assistentContents.push({ type: "polygon", points: ctx.getPolygonFromTwoPointsFormRegion(ctx.getTwoPointsFormRegion(start, cursor)), dashArray: [4 / scale] });\n assistentContents.push({\n type: "text",\n text: "abc",\n textStyleId,\n color: 0,\n fontSize: 16 / scale,\n fontFamily: "monospace",\n x: Math.min(start.x, cursor.x),\n y: Math.min(start.y, cursor.y),\n width: Math.abs(start.x - cursor.x)\n });\n } else {\n assistentContents.push({\n type: "text",\n text: "abc",\n textStyleId,\n color: 0,\n fontSize: 16 / scale,\n fontFamily: "monospace",\n x: cursor.x,\n y: cursor.y,\n width: 100\n });\n }\n }\n }\n return {\n onStart: (p) => {\n if (!type)\n return;\n if (text) {\n onEnd({ updateContents: (contents2) => contents2.push(text) });\n reset();\n return;\n }\n if (start) {\n setText({\n type: "text",\n text: "",\n textStyleId,\n color: 0,\n fontSize: 16 / scale,\n fontFamily: "monospace",\n x: Math.min(start.x, p.x),\n y: Math.min(start.y, p.y),\n width: Math.abs(start.x - p.x)\n });\n } else {\n setStart(p);\n }\n },\n onMove: (p) => {\n if (!type)\n return;\n setCursor(p);\n },\n assistentContents,\n reset,\n panel\n };\n },\n selectCount: 0,\n hotkey: "T"\n };\n}\nexport {\n getCommand,\n getModel,\n isTextContent\n};\n','// dev/cad-editor/plugins/time-axis.plugin.tsx\nfunction getModel(ctx) {\n const TimeAxisContent = ctx.and(ctx.BaseContent("time axis"), ctx.StrokeFields, ctx.ArrowFields, ctx.Position, {\n max: ctx.number\n });\n const getRefIds = (content) => ctx.toRefId(content.strokeStyleId);\n function getGeometriesFromCache(content, contents, time) {\n const getGeometries = () => {\n const { arrowPoints, endPoint } = ctx.getArrowPoints(content, { x: content.x + content.max / 10, y: content.y }, content);\n const points = [content, endPoint];\n const result = {\n lines: Array.from(ctx.iteratePolylineLines(points)),\n bounding: ctx.getPointsBounding(points),\n regions: [\n {\n points: arrowPoints,\n lines: Array.from(ctx.iteratePolygonLines(arrowPoints))\n }\n ],\n renderingLines: ctx.dashedPolylineToLines(points, content.dashArray)\n };\n if (time) {\n const timePoints = ctx.arcToPolyline(ctx.circleToArc({ x: content.x + time / 10, y: content.y, r: 5 }), ctx.defaultAngleDelta);\n result.regions.push({\n points: timePoints,\n lines: Array.from(ctx.iteratePolygonLines(timePoints))\n });\n }\n return result;\n };\n if (time) {\n return getGeometries();\n }\n const refs = new Set(ctx.iterateRefContents(getRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, getGeometries);\n }\n const React = ctx.React;\n return {\n type: "time axis",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n render(content, renderCtx) {\n const { options, contents, time, target, fillOptions } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const { regions, renderingLines } = getGeometriesFromCache(content, contents, time);\n const children = [];\n for (const line of renderingLines) {\n children.push(target.renderPolyline(line, options));\n }\n if (regions) {\n for (let i = 0; i < regions.length; i++) {\n children.push(target.renderPolygon(regions[i].points, fillOptions));\n }\n }\n return target.renderGroup(children);\n },\n getEditPoints(content) {\n return ctx.getEditPointsFromCache(content, () => {\n return {\n editPoints: [\n {\n ...content,\n cursor: "move",\n update(c, { cursor, start, scale }) {\n if (!isTimeAxisContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return { assistentContents: [{ type: "line", dashArray: [4 / scale], points: [start, cursor] }] };\n }\n }\n ]\n };\n });\n },\n getGeometries: getGeometriesFromCache,\n propertyPanel(content, update, contents, { startTime, acquirePoint }) {\n return {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => acquirePoint((p) => update((c) => {\n if (isTimeAxisContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (isTimeAxisContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (isTimeAxisContent(c)) {\n c.y = v;\n }\n }) }),\n max: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.max, setValue: (v) => update((c) => {\n if (isTimeAxisContent(c) && v > 0) {\n c.max = v;\n }\n }) }),\n action: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => startTime(content.max) }, "start"),\n ...ctx.getArrowContentPropertyPanel(content, update),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, TimeAxisContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds\n };\n}\nfunction isTimeAxisContent(content) {\n return content.type === "time axis";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("g", { transform: "" }, /* @__PURE__ */ React.createElement("polyline", { points: "3,52 90,53", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "99,53 70,60 70,45", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" })));\n return {\n name: "create time axis",\n selectCount: 0,\n icon,\n useCommand({ onEnd, type }) {\n const [result, setResult] = React.useState();\n const reset = () => {\n setResult(void 0);\n };\n return {\n onStart() {\n if (result) {\n onEnd({\n updateContents: (contents) => {\n if (result) {\n contents.push(result);\n }\n }\n });\n reset();\n }\n },\n onMove(p) {\n if (type) {\n setResult({\n type: "time axis",\n x: p.x,\n y: p.y,\n max: 5e3\n });\n }\n },\n assistentContents: result ? [result] : void 0,\n reset\n };\n }\n };\n}\nexport {\n getCommand,\n getModel,\n isTimeAxisContent\n};\n','// dev/cad-editor/plugins/hatch.plugin.tsx\nfunction isHatchContent(content) {\n return content.type === "hatch";\n}\n\n// dev/cad-editor/plugins/trim.plugin.tsx\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { viewBox: "64 64 896 896", width: "1em", height: "1em", fill: "currentColor" }, /* @__PURE__ */ React.createElement("path", { d: "M567.1 512l318.5-319.3c5-5 1.5-13.7-5.6-13.7h-90.5c-2.1 0-4.2.8-5.6 2.3l-273.3 274-90.2-90.5c12.5-22.1 19.7-47.6 19.7-74.8 0-83.9-68.1-152-152-152s-152 68.1-152 152 68.1 152 152 152c27.7 0 53.6-7.4 75.9-20.3l90 90.3-90.1 90.3A151.04 151.04 0 00288 582c-83.9 0-152 68.1-152 152s68.1 152 152 152 152-68.1 152-152c0-27.2-7.2-52.7-19.7-74.8l90.2-90.5 273.3 274c1.5 1.5 3.5 2.3 5.6 2.3H880c7.1 0 10.7-8.6 5.6-13.7L567.1 512zM288 370c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80zm0 444c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z" }));\n return {\n name: "trim",\n useCommand({ onEnd, type, selected, backgroundColor, contents, getContentsInRange }) {\n const [candidates, setCandidates] = React.useState([]);\n const [currents, setCurrents] = React.useState([]);\n const [trackPoints, setTrackPoints] = React.useState([]);\n const { state, setState, resetHistory, undo, redo } = ctx.useUndoRedo([]);\n React.useEffect(() => {\n var _a, _b;\n if (type) {\n const allContents = [];\n for (let i = 0; i < selected.length; i++) {\n const content = selected[i].content;\n let intersectionPoints = [];\n for (let j = 0; j < selected.length; j++) {\n const c = selected[j].content;\n if (c && i !== j) {\n const p = i < j ? [c, content] : [content, c];\n intersectionPoints.push(...ctx.getIntersectionPoints(...p, contents));\n }\n }\n intersectionPoints = ctx.deduplicatePosition(intersectionPoints);\n if (intersectionPoints.length > 0) {\n const result = (_b = (_a = ctx.getContentModel(content)) == null ? void 0 : _a.break) == null ? void 0 : _b.call(_a, content, intersectionPoints, contents);\n if (result) {\n allContents.push({ content, children: result });\n }\n } else {\n allContents.push({ content, children: [content] });\n }\n }\n setCandidates(allContents);\n }\n }, [type]);\n const assistentContents = [];\n const collectAssistentContent = (child) => {\n var _a;\n if (ctx.isStrokeContent(child)) {\n assistentContents.push({\n ...child,\n strokeWidth: ((_a = child.strokeWidth) != null ? _a : ctx.getDefaultStrokeWidth(child)) + 2,\n strokeColor: backgroundColor,\n trueStrokeColor: true\n });\n } else if (isHatchContent(child)) {\n assistentContents.push({\n ...child,\n fillPattern: void 0,\n fillColor: backgroundColor,\n trueFillColor: true\n });\n }\n };\n for (const current of currents) {\n for (const child of current.children) {\n collectAssistentContent(child);\n }\n }\n if (trackPoints.length > 1) {\n assistentContents.push({ points: trackPoints, type: "polyline" });\n }\n for (const { children } of state) {\n for (const child of children) {\n collectAssistentContent(child);\n }\n }\n const reset = () => {\n setCandidates([]);\n setCurrents([]);\n resetHistory();\n setTrackPoints([]);\n };\n return {\n onStart() {\n if (currents.length > 0) {\n setState((draft) => {\n for (const current of currents) {\n const index = state.findIndex((s) => s.content === current.content);\n if (index >= 0) {\n draft[index].children.push(...current.children);\n } else {\n draft.push(current);\n }\n }\n });\n }\n setTrackPoints([]);\n },\n onMouseDown(p) {\n if (currents.length === 0) {\n setTrackPoints([p]);\n }\n },\n onMove(p) {\n var _a, _b, _c, _d;\n if (trackPoints.length > 0) {\n const newTracePoints = [...trackPoints, p];\n if (newTracePoints.length > 1) {\n const trackLines = Array.from(ctx.iteratePolylineLines(newTracePoints));\n const newCurrents = [];\n for (const candidate of candidates) {\n for (const child of candidate.children) {\n const geometries = (_b = (_a = ctx.getContentModel(child)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, child, contents);\n if (geometries) {\n for (const line of geometries.lines) {\n if (trackLines.some((t) => ctx.getTwoGeometryLinesIntersectionPoint(line, t).length > 0)) {\n const index = newCurrents.findIndex((s) => s.content === candidate.content);\n if (index >= 0) {\n newCurrents[index].children.push(child);\n } else {\n newCurrents.push({ content: candidate.content, children: [child] });\n }\n break;\n }\n }\n }\n }\n }\n setCurrents(newCurrents);\n }\n setTrackPoints(newTracePoints);\n return;\n }\n for (const candidate of candidates) {\n for (const child of candidate.children) {\n const geometries = (_d = (_c = ctx.getContentModel(child)) == null ? void 0 : _c.getGeometries) == null ? void 0 : _d.call(_c, child, contents);\n if (geometries) {\n if (isHatchContent(child) && geometries.regions && geometries.bounding) {\n for (const region of geometries.regions) {\n if (region.holes && region.holes.some((h) => ctx.pointInPolygon(p, h))) {\n continue;\n }\n if (ctx.pointInPolygon(p, region.points)) {\n const getGeometriesInRange = (region2) => getContentsInRange(region2).map((c) => ctx.getContentHatchGeometries(c, contents));\n const border = ctx.getHatchByPosition(p, (line) => getGeometriesInRange(ctx.getGeometryLineBoundingFromCache(line)), geometries.bounding.end.x);\n if (border) {\n const holes = ctx.getHatchHoles(border.lines, getGeometriesInRange);\n setCurrents([{\n children: [{\n type: "hatch",\n border: border.lines,\n holes: holes == null ? void 0 : holes.holes,\n ref: {\n point: p,\n ids: [...border.ids, ...(holes == null ? void 0 : holes.ids) || []]\n }\n }],\n content: candidate.content\n }]);\n }\n return;\n }\n }\n }\n for (const line of geometries.lines) {\n if (ctx.getPointAndGeometryLineMinimumDistance(p, line) < 5) {\n setCurrents([{ children: [child], content: candidate.content }]);\n return;\n }\n }\n }\n }\n }\n setCurrents([]);\n },\n onKeyDown(e) {\n var _a, _b;\n if (e.code === "KeyZ" && ctx.metaKeyIfMacElseCtrlKey(e)) {\n if (e.shiftKey) {\n redo(e);\n } else {\n undo(e);\n }\n } else if (e.key === "Enter") {\n if (!type)\n return;\n const removedIndexes = [];\n const newContents = [];\n for (const { content, children } of state) {\n const parentModel = ctx.getContentModel(content);\n if (parentModel == null ? void 0 : parentModel.break) {\n let points = [];\n for (const child of children) {\n const geometries = (_b = (_a = ctx.getContentModel(child)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, child, contents);\n if (geometries) {\n const { start, end } = ctx.getGeometryLinesStartAndEnd(geometries.lines);\n if (start && end) {\n if (!ctx.isSamePoint(start, end)) {\n points.push(start, end);\n }\n } else if (start) {\n points.push(start);\n } else if (end) {\n points.push(end);\n }\n }\n }\n points = ctx.deduplicatePosition(points);\n const r = parentModel.break(content, points, contents);\n if (r) {\n removedIndexes.push(ctx.getContentIndex(content, contents));\n newContents.push(...r.filter((c) => children.every((f) => !ctx.deepEquals(f, c))));\n }\n } else if (isHatchContent(content)) {\n const holes = [];\n const ids = [];\n if (content.ref) {\n ids.push(...content.ref.ids);\n }\n const borders = [content.border];\n if (content.holes) {\n holes.push(...content.holes);\n }\n for (const child of children) {\n if (isHatchContent(child)) {\n holes.push(child.border);\n if (child.holes) {\n borders.push(...child.holes);\n }\n if (child.ref) {\n ids.push(...child.ref.ids);\n }\n }\n }\n removedIndexes.push(ctx.getContentIndex(content, contents));\n const result = borders.map((b) => {\n const polygon = ctx.getGeometryLinesPoints(b);\n return ctx.optimizeHatch(b, holes.filter((h) => {\n const start = ctx.getGeometryLineStartAndEnd(h[0]).start;\n return start && (ctx.pointIsOnGeometryLines(start, b) || ctx.pointInPolygon(start, polygon));\n }));\n }).flat();\n newContents.push(...result.map((r) => {\n let ref;\n if (content.ref) {\n const p = content.ref.point;\n if (ctx.pointInPolygon(p, ctx.getGeometryLinesPoints(r.border)) && r.holes.every((h) => !ctx.pointInPolygon(p, ctx.getGeometryLinesPoints(h)))) {\n ref = {\n point: p,\n ids: Array.from(new Set(ids))\n };\n }\n }\n return { ...content, border: r.border, holes: r.holes, ref };\n }));\n }\n }\n onEnd({\n updateContents: (contents2) => {\n ctx.deleteSelectedContents(contents2, removedIndexes);\n contents2.push(...newContents);\n }\n });\n reset();\n }\n },\n assistentContents,\n reset\n };\n },\n contentSelectable(content, contents) {\n return ctx.contentIsDeletable(content, contents);\n },\n hotkey: "TR",\n icon,\n pointSnapDisabled: true\n };\n}\nexport {\n getCommand\n};\n','// dev/cad-editor/plugins/viewport.plugin.tsx\nfunction getModel(ctx) {\n const getRefIds = (content) => [...ctx.getStrokeRefIds(content), ...ctx.toRefId(content.border, true)];\n function getViewportGeometriesFromCache(content, contents) {\n var _a, _b;\n const geometries = (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.getGeometries) == null ? void 0 : _b.call(_a, content.border, contents);\n if (geometries) {\n return geometries;\n }\n return { lines: [], renderingLines: [] };\n }\n const renderCache = new ctx.WeakmapMapCache();\n const React = ctx.React;\n return {\n type: "viewport",\n ...ctx.strokeModel,\n ...ctx.arrowModel,\n move(content, offset) {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.move) == null ? void 0 : _b.call(_a, content.border, offset);\n ctx.movePoint(content, offset);\n },\n rotate(content, center, angle, contents) {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.rotate) == null ? void 0 : _b.call(_a, content.border, center, angle, contents);\n },\n scale(content, center, sx, sy, contents) {\n var _a, _b;\n return (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.scale) == null ? void 0 : _b.call(_a, content.border, center, sx, sy, contents);\n },\n skew(content, center, sx, sy, contents) {\n var _a, _b;\n return (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.skew) == null ? void 0 : _b.call(_a, content.border, center, sx, sy, contents);\n },\n mirror(content, line, angle, contents) {\n var _a, _b;\n (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.mirror) == null ? void 0 : _b.call(_a, content.border, line, angle, contents);\n },\n render(content, renderCtx) {\n var _a;\n const render = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.render;\n if (render) {\n return render(content.border, {\n ...renderCtx,\n clip: renderCtx.isHoveringOrSelected || content.hidden ? void 0 : () => {\n const sortedContents = ctx.getSortedContents(renderCtx.contents).contents;\n const children = renderCache.get(sortedContents, renderCtx.target.type, () => {\n const children2 = [];\n sortedContents.forEach((content2) => {\n var _a2;\n if (!content2 || content2.visible === false || ctx.isViewportContent(content2)) {\n return;\n }\n const ContentRender = (_a2 = ctx.getContentModel(content2)) == null ? void 0 : _a2.render;\n if (ContentRender) {\n children2.push(ContentRender(content2, renderCtx));\n }\n });\n return children2;\n });\n return renderCtx.target.renderGroup(children, { matrix: ctx.getViewportMatrix(content) });\n }\n });\n }\n return renderCtx.target.renderEmpty();\n },\n getEditPoints(content, contents) {\n var _a, _b;\n const editPoints = (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.getEditPoints) == null ? void 0 : _b.call(_a, content.border, contents);\n if (!editPoints)\n return;\n return ctx.getEditPointsFromCache(content, () => {\n return {\n ...editPoints,\n editPoints: editPoints.editPoints.map((e) => ({\n ...e,\n update(c, props) {\n var _a2;\n if (!ctx.isViewportContent(c)) {\n return;\n }\n if (e.type === "move") {\n c.x += props.cursor.x - props.start.x;\n c.y += props.cursor.y - props.start.y;\n }\n return (_a2 = e.update) == null ? void 0 : _a2.call(e, c.border, props);\n }\n }))\n };\n });\n },\n getGeometries: getViewportGeometriesFromCache,\n propertyPanel(content, update, contents, options) {\n var _a, _b;\n const border = (_b = (_a = ctx.getContentModel(content.border)) == null ? void 0 : _a.propertyPanel) == null ? void 0 : _b.call(_a, content.border, (recipe) => {\n update((c) => {\n if (ctx.isViewportContent(c)) {\n recipe(c.border, contents);\n }\n });\n }, contents, options);\n const result = {\n from: /* @__PURE__ */ React.createElement(ctx.Button, { onClick: () => options.acquirePoint((p) => update((c) => {\n if (ctx.isViewportContent(c)) {\n c.x = p.x, c.y = p.y;\n }\n })) }, "canvas"),\n x: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.x, setValue: (v) => update((c) => {\n if (ctx.isViewportContent(c)) {\n c.x = v;\n }\n }) }),\n y: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.y, setValue: (v) => update((c) => {\n if (ctx.isViewportContent(c)) {\n c.y = v;\n }\n }) }),\n scale: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.scale, setValue: (v) => update((c) => {\n if (ctx.isViewportContent(c)) {\n c.scale = v;\n }\n }) }),\n rotate: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.rotate || 0, setValue: (v) => update((c) => {\n if (ctx.isViewportContent(c)) {\n c.rotate = v;\n }\n }) }),\n locked: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.locked || false, setValue: (v) => update((c) => {\n if (ctx.isViewportContent(c)) {\n c.locked = v;\n }\n }) }),\n hidden: /* @__PURE__ */ React.createElement(ctx.BooleanEditor, { value: content.hidden || false, setValue: (v) => update((c) => {\n if (ctx.isViewportContent(c)) {\n c.hidden = v;\n }\n }) })\n };\n if (border) {\n result.border = /* @__PURE__ */ React.createElement(ctx.ObjectEditor, { properties: border });\n }\n return {\n ...result,\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, ctx.ViewportContent, p),\n getRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds\n };\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("rect", { x: "14", y: "18", width: "71", height: "71", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("g", { transform: "" }, /* @__PURE__ */ React.createElement("polyline", { points: "47,55 78,24", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "85,18 70,43 59,32", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" })), /* @__PURE__ */ React.createElement("g", { transform: "" }, /* @__PURE__ */ React.createElement("polyline", { points: "47,55 20,82", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "14,89 29,62 40,73", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" })), /* @__PURE__ */ React.createElement("g", { transform: "" }, /* @__PURE__ */ React.createElement("polyline", { points: "47,54 78,82", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "85,89 58,75 69,63", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" })), /* @__PURE__ */ React.createElement("g", { transform: "" }, /* @__PURE__ */ React.createElement("polyline", { points: "47,55 20,25", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "14,18 39,34 27,44", strokeWidth: "0", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", fill: "currentColor", stroke: "currentColor" })));\n return {\n name: "create viewport",\n selectCount: 1,\n icon,\n contentSelectable(content) {\n return ctx.contentIsClosedPath(content);\n },\n execute({ contents, selected }) {\n contents.forEach((content, index) => {\n var _a, _b;\n if (content && ctx.isSelected([index], selected) && ((_b = (_a = this.contentSelectable) == null ? void 0 : _a.call(this, content, contents)) != null ? _b : true)) {\n const viewport = ctx.getDefaultViewport(content, contents);\n if (!viewport)\n return;\n const result = {\n type: "viewport",\n border: content,\n ...viewport\n };\n if (result) {\n contents[index] = result;\n }\n }\n });\n }\n };\n}\nexport {\n getCommand,\n getModel\n};\n','// dev/cad-editor/plugins/wire.plugin.tsx\nfunction getModel(ctx) {\n const WireContent = ctx.and(ctx.BaseContent("wire"), {\n points: ctx.minItems(2, [ctx.Position]),\n refs: [ctx.ContentRef]\n });\n const LampContent = ctx.and(ctx.BaseContent("lamp"), ctx.Position, {\n size: ctx.number\n });\n const getWireRefIds = (content) => [...ctx.getStrokeRefIds(content), ...ctx.toRefIds(content.refs)];\n const getLampRefIds = (content) => ctx.getStrokeRefIds(content);\n function getWireGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getWireRefIds(content), contents, [content]));\n return ctx.getGeometriesFromCache(content, refs, () => {\n let lines = Array.from(ctx.iteratePolylineLines(content.points));\n for (const ref of content.refs) {\n if (ref) {\n const lamp = ctx.getReference(ref, contents, isLampContent);\n if (lamp) {\n const params = ctx.deduplicate(Array.from(ctx.iterateGeometryLinesIntersectionPoints(lines, getLampGeometries(lamp, contents).lines)).map((p) => ctx.getGeometryLinesParamAtPoint(p, lines)), ctx.isSameNumber);\n if (params.length === 1) {\n const param = params[0];\n if (param < lines.length / 2) {\n lines = ctx.getPartOfGeometryLines(param, lines.length, lines);\n } else {\n lines = ctx.getPartOfGeometryLines(0, param, lines);\n }\n } else if (params.length > 1) {\n lines = [\n ...ctx.getPartOfGeometryLines(0, Math.min(...params), lines),\n ...ctx.getPartOfGeometryLines(Math.max(...params), lines.length, lines)\n ];\n }\n }\n }\n }\n return {\n lines,\n bounding: ctx.getPointsBounding(content.points),\n renderingLines: lines.map((line) => ctx.dashedPolylineToLines(ctx.getGeometryLinesPoints([line]), content.dashArray)).flat()\n };\n });\n }\n function getLampGeometries(content, contents) {\n const refs = new Set(ctx.iterateRefContents(getLampRefIds(content), contents, [content]));\n const arc = ctx.circleToArc({ x: content.x, y: content.y, r: content.size });\n return ctx.getGeometriesFromCache(content, refs, () => {\n const size = content.size * Math.SQRT1_2;\n const lineSegments = [\n [{ x: content.x - size, y: content.y - size }, { x: content.x + size, y: content.y + size }],\n [{ x: content.x - size, y: content.y + size }, { x: content.x + size, y: content.y - size }]\n ];\n const points = ctx.arcToPolyline(arc, ctx.defaultAngleDelta);\n return {\n lines: [{ type: "arc", curve: arc }, ...lineSegments],\n bounding: {\n start: { x: content.x - content.size, y: content.y - content.size },\n end: { x: content.x + content.size, y: content.y + content.size }\n },\n renderingLines: [\n ...ctx.dashedPolylineToLines(points, content.dashArray),\n ...lineSegments.map((s) => ctx.dashedPolylineToLines(s, content.dashArray)).flat()\n ]\n };\n });\n }\n const React = ctx.React;\n return [\n {\n type: "wire",\n ...ctx.strokeModel,\n move(content, offset) {\n for (const point of content.points) {\n ctx.movePoint(point, offset);\n }\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const renderingLines = getWireGeometries(content, renderCtx.contents).renderingLines;\n return target.renderGroup(renderingLines.map((line) => target.renderPolyline(line, options)));\n },\n getGeometries: getWireGeometries,\n propertyPanel(content, update, contents) {\n return {\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, WireContent, p),\n getRefIds: getWireRefIds,\n updateRefId(content, update) {\n for (const [i, id] of content.refs.entries()) {\n const newRefId = update(id);\n if (newRefId !== void 0) {\n content.refs[i] = newRefId;\n }\n }\n ctx.updateStrokeRefIds(content, update);\n },\n deleteRefId(content, ids) {\n for (const id of ids) {\n const index = content.refs.indexOf(id);\n if (index >= 0) {\n content.refs.splice(index, 1);\n }\n }\n ctx.deleteStrokeRefIds(content, ids);\n }\n },\n {\n type: "lamp",\n ...ctx.strokeModel,\n move(content, offset) {\n ctx.movePoint(content, offset);\n },\n render(content, renderCtx) {\n const { options, target } = ctx.getStrokeRenderOptionsFromRenderContext(content, renderCtx);\n const geometries = getLampGeometries(content, renderCtx.contents);\n const children = [target.renderCircle(content.x, content.y, content.size, options)];\n for (const line of geometries.lines) {\n if (Array.isArray(line)) {\n children.push(target.renderPolyline(line, options));\n }\n }\n return target.renderGroup(children);\n },\n getGeometries: getLampGeometries,\n getEditPoints(content, contents) {\n return ctx.getEditPointsFromCache(content, () => {\n const editPoints = [{\n x: content.x,\n y: content.y,\n cursor: "move",\n update(c, { cursor, start, target }) {\n if (!isLampContent(c)) {\n return;\n }\n c.x += cursor.x - start.x;\n c.y += cursor.y - start.y;\n return {\n updateRelatedContents() {\n const index = ctx.getContentIndex(content, contents);\n const targetIndex = target ? ctx.getContentIndex(target.content, contents) : void 0;\n const [, patches, reversePatches] = ctx.produceWithPatches(contents, (draft) => {\n var _a, _b;\n for (let i = 0; i < draft.length; i++) {\n const c2 = draft[i];\n if (!c2)\n continue;\n if (i === targetIndex && isWireContent(c2)) {\n if (!c2.refs.includes(index)) {\n c2.refs.push(index);\n }\n } else {\n (_b = (_a = ctx.getContentModel(c2)) == null ? void 0 : _a.deleteRefId) == null ? void 0 : _b.call(_a, c2, [index]);\n }\n }\n });\n return { patches, reversePatches };\n }\n };\n }\n }];\n return { editPoints };\n });\n },\n propertyPanel(content, update, contents) {\n return {\n size: /* @__PURE__ */ React.createElement(ctx.NumberEditor, { value: content.size, setValue: (v) => update((c) => {\n if (isLampContent(c)) {\n c.size = v;\n }\n }) }),\n ...ctx.getStrokeContentPropertyPanel(content, update, contents)\n };\n },\n isValid: (c, p) => ctx.validate(c, LampContent, p),\n getRefIds: getLampRefIds,\n updateRefId: ctx.updateStrokeRefIds,\n deleteRefId: ctx.deleteStrokeRefIds\n }\n ];\n}\nfunction isWireContent(content) {\n return content.type === "wire";\n}\nfunction isLampContent(content) {\n return content.type === "lamp";\n}\nfunction getCommand(ctx) {\n const React = ctx.React;\n const icon1 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("polyline", { points: "4,4 97,4 97,96", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n const icon2 = /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" }, /* @__PURE__ */ React.createElement("circle", { cx: "50", cy: "50", r: "45", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "18,18 82,82", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }), /* @__PURE__ */ React.createElement("polyline", { points: "18,82 82,18", strokeWidth: "5", strokeMiterlimit: "10", strokeLinejoin: "miter", strokeLinecap: "butt", strokeOpacity: "1", fill: "none", stroke: "currentColor" }));\n return [\n {\n name: "create wire",\n useCommand({ onEnd, type, strokeStyleId }) {\n const { line, onClick, onMove, input, lastPosition, reset } = ctx.useLineClickCreate(\n type === "create wire",\n (c) => onEnd({\n updateContents: (contents) => contents.push({ points: c, refs: [], strokeStyleId, type: "wire" })\n })\n );\n const assistentContents = [];\n if (line) {\n assistentContents.push({ points: line, refs: [], strokeStyleId, type: "wire" });\n }\n return {\n onStart: onClick,\n input,\n onMove,\n assistentContents,\n lastPosition,\n reset\n };\n },\n selectCount: 0,\n icon: icon1\n },\n {\n name: "create lamp",\n useCommand({ onEnd, type, strokeStyleId }) {\n const [lamp, setLamp] = React.useState();\n const [wireId, setWireId] = React.useState();\n const reset = () => {\n setWireId(void 0);\n setLamp(void 0);\n };\n const assistentContents = [];\n if (lamp) {\n assistentContents.push(lamp);\n }\n return {\n onStart: (p) => {\n onEnd({\n updateContents: (contents) => {\n if (wireId !== void 0) {\n const content = contents[wireId];\n if (content && isWireContent(content)) {\n content.refs.push(contents.length);\n }\n }\n contents.push({ x: p.x, y: p.y, size: 5, strokeStyleId, type: "lamp" });\n }\n });\n },\n onMove(p, _, target) {\n if (!type)\n return;\n setWireId(target == null ? void 0 : target.id);\n setLamp({ x: p.x, y: p.y, size: 5, strokeStyleId, type: "lamp" });\n },\n assistentContents,\n reset\n };\n },\n selectCount: 0,\n icon: icon2\n }\n ];\n}\nexport {\n getCommand,\n getModel,\n isLampContent,\n isWireContent\n};\n']},7449:(e,t,n)=>{"use strict";n.d(t,{MemoizedRenderer:()=>y,getAllRendererTypes:()=>b,registerRenderer:()=>x});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=n(4469),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&h(e,n,t[n]);if(d)for(var n of d(t))f.call(t,n)&&h(e,n,t[n]);return e},m=(e,t)=>c(e,u(t));const y=i().memo((function(e){var t,n,o,l,c,u;const d=new a.Debug(e.debug),p=v[e.type||b()[0]],f=i().useRef(new a.WeakmapMapCache);(0,a.useValueChanged)(e.type,(()=>f.current.clear())),(0,a.useValueChanged)(e.backgroundColor,(()=>f.current.clear()));const h=i().useRef(new a.WeakmapCache);if((0,a.useValueChanged)(p,(()=>h.current.clear())),!p)return null;const y=(0,a.getColorString)(e.backgroundColor),x=+`0x${y.substring(1,3)}`,C=+`0x${y.substring(3,5)}`,E=+`0x${y.substring(5)}`,P=(Math.max(x,E,C)+Math.min(x,E,C))/2,k=e=>P<128?0===e?16777215:e:16777215===e?0:e;d.mark("before contents");let w=[];const _=new a.Merger((e=>w.push(p.renderPath(e.target,{strokeColor:e.type.strokeColor,dashArray:e.type.dashArray,strokeWidth:e.type.strokeWidth,strokeOpacity:e.type.strokeOpacity,lineJoin:e.type.lineJoin,miterLimit:e.type.miterLimit,lineCap:e.type.lineCap}))),((e,t)=>e.strokeColor===t.strokeColor&&e.strokeWidth===t.strokeWidth&&e.strokeOpacity===t.strokeOpacity&&e.lineJoin===t.lineJoin&&e.miterLimit===t.miterLimit&&e.lineCap===t.lineCap&&(0,a.isSamePath)(e.dashArray,t.dashArray)),(e=>e.line)),S=null!=(t=e.previewPatches)?t:[],R=S.length>0&&!e.performanceMode?(0,r.applyPatches)(e.contents,S):e.contents,A=(0,s.getSortedContents)(R).contents,T={transformColor:k,target:p,getStrokeColor:e=>void 0!==e.strokeColor?e.trueStrokeColor?e.strokeColor:k(e.strokeColor):(0,s.hasFill)(e)?void 0:s.defaultStrokeColor,getFillColor:e=>void 0!==e.fillColor?e.trueFillColor?e.fillColor:k(e.fillColor):void 0,getFillPattern:e=>{if(void 0===e.fillPattern)return;const t=e.fillPattern;return h.current.get(t,(()=>({width:t.width,height:t.height,pattern:()=>{var e;return p.renderPath(t.lines,{strokeColor:null!=(e=void 0!==t.strokeColor?k(t.strokeColor):void 0)?e:s.defaultStrokeColor,strokeOpacity:t.strokeOpacity,lineCap:"square"})}})))},time:e.time,contents:R,patches:S};w=f.current.get(A,e.time,(()=>(A.forEach((t=>{var n,r,o,i,l,c;if(!t||!1===t.visible)return;const u=(0,s.getContentModel)(t);if(u)if("svg"!==p.type&&u.getGeometries){const{renderingLines:d,regions:p,bounding:f}=u.getGeometries(t,e.contents);if(!d||!f||p||(0,s.isClipContent)(t)&&t.clip||(0,s.isViewportContent)(t)&&!t.hidden){const e=u.render;e&&(_.flushLast(),w.push(e(t,g({transformStrokeWidth:e=>e},T))))}else{const e=null!=(n=(0,s.isStrokeContent)(t)?t.strokeWidth:void 0)?n:(0,s.getDefaultStrokeWidth)(t);let u=null!=(r=(0,s.isStrokeContent)(t)?t.strokeColor:void 0)?r:s.defaultStrokeColor;u=k(u);const p=null!=(o=(0,s.isStrokeContent)(t)?t.strokeOpacity:void 0)?o:s.defaultOpacity,f=null!=(i=(0,s.isStrokeContent)(t)?t.lineJoin:void 0)?i:a.defaultLineJoin,h=null!=(l=(0,s.isStrokeContent)(t)?t.miterLimit:void 0)?l:a.defaultMiterLimit,g=null!=(c=(0,s.isStrokeContent)(t)?t.lineCap:void 0)?c:a.defaultLineCap;for(const t of d)_.push({line:t,strokeColor:u,strokeWidth:e,strokeOpacity:p,lineJoin:f,miterLimit:h,lineCap:g})}}else{const e=u.render;e&&(_.flushLast(),w.push(e(t,g({transformStrokeWidth:e=>e},T))))}})),w))),_.flushLast(),d.mark("before assistent contents");const M=[],L=[];if(e.performanceMode){const t=new Set(S.map((e=>e.path[0]))),n=[];for(const o of t){const t=S.filter((e=>e.path[0]===o));if(t.length>0){const i=e.contents[o];i?n.push((0,r.applyPatches)(i,t.map((e=>m(g({},e),{path:e.path.slice(1)}))))):t.forEach((e=>{"add"===e.op&&e.value&&n.push(e.value)}))}}let o=[];if(n.forEach((e=>{var t;const n=null==(t=(0,s.getContentModel)(e))?void 0:t.render;n&&o.push(n(e,m(g({transformStrokeWidth:e=>e},T),{isAssistence:!0})))})),o.length>0&&void 0!==e.activeViewportIndex){const t=R[e.activeViewportIndex];t&&(0,s.isViewportContent)(t)&&(o=[p.renderGroup(o,{matrix:(0,s.getViewportMatrix)(t)})])}M.push(...o)}if(!1!==e.operatorVisible){const t=e.selected||[],n=e.othersSelectedContents||[];t.length+n.length>0&&e.contents.forEach(((r,o)=>{if(!r)return;const i=(0,s.getContentModel)(r);if(!i)return;const l=n.filter((e=>e.selection.includes(o))).map((e=>e.operator));if((0,a.isSelected)([o],t)&&l.unshift("me"),i.getOperatorRenderPosition&&l.length>0){const t=i.getOperatorRenderPosition(r,e.contents);L.push(p.renderText(t.x,t.y,l.join(","),16711680,16,"monospace"))}}))}for(const t of[...e.hovering||[],...e.assistentHovering||[]]){const e=(0,s.getContentByIndex)(R,t);if(e){const t=null==(n=(0,s.getContentModel)(e))?void 0:n.render;t&&(L.push(t(e,m(g({transformStrokeWidth:e=>e+4},T),{isHoveringOrSelected:!0}))),L.push(t(e,m(g({transformStrokeWidth:e=>e+2},T),{isHoveringOrSelected:!0}))),L.push(t(e,m(g({transformStrokeWidth:e=>e},T),{isHoveringOrSelected:!0}))))}}for(const t of[...e.selected||[],...e.assistentSelected||[]]){const n=(0,s.getContentByIndex)(R,t);if(n){const t=null!=(o=(0,s.isStrokeContent)(n)?n.strokeWidth:void 0)?o:(0,s.getDefaultStrokeWidth)(n),r=(0,s.getContentModel)(n),i=null==r?void 0:r.render;i&&(L.push(i(n,m(g({transformStrokeWidth:e=>e+4},T),{isHoveringOrSelected:!0}))),L.push(i(n,m(g({transformStrokeWidth:e=>e+2},T),{isHoveringOrSelected:!0}))),L.push(i(n,m(g({transformStrokeWidth:e=>e},T),{isHoveringOrSelected:!0}))));const a=null==r?void 0:r.renderIfSelected;a&&L.push(a(n,{color:k(16711680),target:p,strokeWidth:t,contents:e.contents}))}}if(void 0!==e.activeViewportIndex){const t=R[e.activeViewportIndex];if(t){const e=null==(l=(0,s.getContentModel)(t))?void 0:l.render;e&&(M.push(e(t,m(g({transformStrokeWidth:e=>e+4},T),{isHoveringOrSelected:!0}))),M.push(e(t,m(g({transformStrokeWidth:e=>e+2},T),{isHoveringOrSelected:!0}))))}}else if(void 0!==e.active){const t=R[e.active];if(t){const e=null==(c=(0,s.getContentModel)(t))?void 0:c.render;e&&M.push(e(t,m(g({transformStrokeWidth:e=>e+1},T),{isHoveringOrSelected:!0})))}}if(null==(u=e.assistentContents)||u.forEach((e=>{var t;const n=null==(t=(0,s.getContentModel)(e))?void 0:t.render;n&&L.push(n(e,m(g({transformStrokeWidth:e=>e},T),{isAssistence:!0})))})),L.length>0){const t=void 0!==e.activeViewportIndex?R[e.activeViewportIndex]:void 0;t&&(0,s.isViewportContent)(t)?M.push(p.renderGroup(L,{matrix:(0,s.getViewportMatrix)(t)})):M.push(...L)}const I=0===M.length?w:[...w,...M];return e.debug&&console.info(d.print()),p.renderResult(I,e.width,e.height,{attributes:{style:g({position:"absolute",boxSizing:"border-box"},e.style),onClick:e.onClick,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onMouseLeave:e.onMouseLeave},transform:{x:e.x,y:e.y,scale:e.scale,rotate:e.rotate},backgroundColor:e.backgroundColor,debug:e.debug,strokeWidthFixed:!e.printMode})})),v={};function x(e){v[e.type]=e}function b(){return Object.keys(v)}},2197:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{circle:n,arc:o,onClick:s,onMove:l,input:c,reset:u}=(0,a.useCircleArcClickCreate)("center radius",(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&u()}));const d=n||o;return i().createElement("div",{onClick:e=>s({x:e.clientX,y:e.clientY}),onMouseMove:e=>l({x:e.clientX,y:e.clientY}),style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>s({x:e.clientX,y:e.clientY}),onMouseMove:e=>l({x:e.clientX,y:e.clientY})},d&&i().createElement("circle",{cx:d.x,cy:d.y,r:d.r,stroke:"#00ff00",strokeDasharray:"4"}),[...e,o].map(((e,t)=>{if(e){const n=(0,a.polarToCartesian)(e.x,e.y,e.r,e.endAngle),r=(0,a.polarToCartesian)(e.x,e.y,e.r,e.startAngle);return i().createElement("path",{key:t,d:`M ${n.x} ${n.y} A ${e.r} ${e.r} 0 ${e.endAngle-e.startAngle<=180?"0":"1"} 0 ${r.x} ${r.y}`,stroke:"#00ff00"})}return null}))),c)}},6844:(e,t,n)=>{"use strict";n.d(t,{default:()=>m});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e},g=(e,t)=>l(e,c(t));const m=()=>{const[e,t]=i().useState({x:200,y:200,r:100,startAngle:-30,endAngle:120}),{offset:n,onStart:o,mask:s,reset:l}=(0,a.useCircleArcEdit)((()=>t(c)));(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()}));const c=(0,r.produce)(e,(e=>{n&&(e.x+=n.x,e.y+=n.y,e.r+=n.r,e.startAngle+=n.startAngle,e.endAngle+=n.endAngle,(0,a.normalizeAngleRange)(e))})),u=(0,a.polarToCartesian)(c.x,c.y,c.r,c.endAngle),d=(0,a.polarToCartesian)(c.x,c.y,c.r,c.startAngle);return i().createElement(i().Fragment,null,i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0}},i().createElement("path",{d:`M ${u.x} ${u.y} A ${c.r} ${c.r} 0 ${c.endAngle-c.startAngle<=180?"0":"1"} 0 ${d.x} ${d.y}`,stroke:"#00ff00"})),i().createElement(a.CircleArcEditBar,g(h({},c),{onMouseDown:(e,t,n)=>o(e,g(h({},c),{type:t,cursor:n}))})),s)}},2960:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{circle:n,onClick:o,onMove:s,input:l,reset:c}=(0,a.useCircleClickCreate)("center radius",(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()})),i().createElement("div",{onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY}),style:{height:"100%"}},[...e,n].map(((e,t)=>e&&i().createElement("div",{key:t,style:{width:2*e.r+"px",height:2*e.r+"px",left:e.x-e.r+"px",top:e.y-e.r+"px",borderRadius:`${e.r}px`,position:"absolute",border:"1px solid #00ff00"}}))),l)}},9857:(e,t,n)=>{"use strict";n.d(t,{default:()=>h});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const h=()=>{const[e,t]=i().useState({x:300,y:200,r:100}),{offset:n,onStart:o,mask:s,reset:h}=(0,a.useCircleEdit)((()=>t(g))),g=(0,r.produce)(e,(e=>{e.x+=n.x,e.y+=n.y,e.r+=n.r}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&h()})),i().createElement(i().Fragment,null,i().createElement("div",{style:{width:2*g.r+"px",height:2*g.r+"px",left:g.x-g.r+"px",top:g.y-g.r+"px",borderRadius:`${g.r}px`,position:"absolute",border:"1px solid #00ff00"}}),i().createElement(a.CircleEditBar,{x:g.x,y:g.y,radius:g.r,onMouseDown:(t,n,r)=>{return o(t,(i=((e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e})({},e),l(i,c({type:n,cursor:r}))));var i}}),s)}},3802:(e,t,n)=>{"use strict";n.d(t,{CircuitGraphEditor:()=>g});var r=n(3696),o=n.n(r),i=n(8662),a=n(9758),s=n(7883),l=n(4942),c=n(5918),u=n(66),d=n(4607),p=n(3031),f=n(7305),h=n(3649);(0,i.enablePatches)(),(0,s.registerModel)(l.powerModel),(0,s.registerModel)(c.resistanceModel),(0,s.registerModel)(u.wireModel),(0,s.registerModel)(f.switchModel),(0,s.registerModel)(h.capacitorModel);const g=o().forwardRef(((e,t)=>{var n,r,l,c,u;const{width:f,height:h}=(0,a.useWindowSize)(),{state:g,setState:m,undo:y,redo:v,applyPatchFromSelf:x,applyPatchFromOtherOperators:b}=(0,a.usePatchBasedUndoRedo)(e.initialState,e.operator,{onApplyPatchesFromSelf:e.onApplyPatchesFromSelf}),{x:C,y:E,ref:P,setX:k,setY:w}=(0,a.useWheelScroll)(),{scale:_,ref:S}=(0,a.useWheelZoom)({min:.001,onChange(e,t,n){const r=(0,a.scaleByCursorPosition)({width:f,height:h},t/e,n);k(r.setX),w(r.setY)}}),[R,A]=o().useState(),[T,M]=o().useState(),[L,I]=o().useState(),[O,B]=o().useState(),F=L?s.modelCenter[L]:void 0,D=[],z=[],U=[],N=[],[G,j]=o().useState();let V;const[W,H]=o().useState([]),[q,$]=o().useState(),Y=o().useRef(),K=o().useRef(),{line:X,onClick:Z,reset:Q,onMove:J,lastPosition:ee}=(0,a.useLineClickCreate)(void 0!==L,(e=>{m((t=>{if(!(null==F?void 0:F.createPreview))return;let n,r,o=g.length;if(void 0===Y.current){const r={type:"junction",position:e[0]};t.push(r),n=o,o++}else n=Y.current;if(void 0===K.current){const n={type:"junction",position:e[1]};t.push(n),r=o,o++}else r=K.current;t.push(F.createPreview({start:n,end:r}))})),ne()}),{once:!0});if(X&&(null==F?void 0:F.createPreview)){const e={type:"junction",position:X[0]},t={type:"junction",position:X[1]};D.push(e,t,F.createPreview({start:e,end:t}))}const te={x:C,y:E,scale:_,center:{x:f/2,y:h/2}},ne=()=>{I(void 0),Y.current=void 0,K.current=void 0,B(void 0),A(void 0),M(void 0),$(void 0)},{editPoint:re,updateEditPreview:oe,onEditMove:ie,onEditClick:ae,editLastPosition:se,getEditAssistentContents:le,resetEdit:ce}=(0,a.useEdit)((()=>{const e=[],t=[];let n=g.length;for(const r of z)if("replace"===r.op&&2===r.path.length&&r.value&&(0,s.isJunctionContent)(r.value)){const o=r.path[1];"start"!==o&&"end"!==o||(e.push({op:"add",path:[n],value:r.value}),r.value=n,t.push({op:"replace",path:["length"],value:n}),n++)}x([...z,...e],[...U,...t])}),(e=>{var t,n;return null==(n=null==(t=(0,s.getContentModel)(e))?void 0:t.getEditPoints)?void 0:n.call(t,e,g)}),{scale:te.scale,readOnly:!!L}),ue=oe();if(z.push(...null!=(n=null==ue?void 0:ue.patches)?n:[]),U.push(...null!=(r=null==ue?void 0:ue.reversePatches)?r:[]),D.push(...null!=(l=null==ue?void 0:ue.assistentContents)?l:[]),ue&&D.push(...(0,s.updateReferencedContents)(ue.content,ue.result,g)),void 0!==T){const e=g[T];if(e){N.push({content:e,path:[T]});const t=re&&(0,a.isSamePath)(re.path,[T])?null==ue?void 0:ue.result:null==ue?void 0:ue.relatedEditPointResults.get(e);D.push(...le(null!=t?t:e,(e=>({type:"circle",x:e.x,y:e.y,radius:7}))));const n=e=>{const[,...t]=(0,i.produceWithPatches)(g,(t=>{const n=t[T];n&&e(n,t)}));x(...t)},r=null==(u=null==(c=(0,s.getContentModel)(e))?void 0:c.propertyPanel)?void 0:u.call(c,e,n,g);let l;if((0,s.isJunctionContent)(e)){const e=W[T];void 0!==e&&(l=o().createElement("div",null,e,"V"))}V=o().createElement("div",{style:{position:"absolute",right:"0px",top:"0px",bottom:"0px",width:"300px",overflowY:"auto",background:"white",zIndex:11}},e.type,o().createElement("div",null,T),l,r&&o().createElement(a.ObjectEditor,{properties:r}))}}const de=null!=se?se:ee,pe=e=>{for(let t=0;t{const t=90*Math.round(e/90);if(t!==e&&Math.abs(t-e)<5)return t})),(0,a.isSameNumber)(de.x,e.x)){for(const t of g)if(t&&(0,s.isJunctionContent)(t)&&(0,a.getTwoNumbersDistance)(e.y,t.position.y)<=5){const n={type:"line",point:{x:e.x,y:t.position.y},start:t.position};return B(n),n}}else if((0,a.isSameNumber)(de.y,e.y))for(const t of g)if(t&&(0,s.isJunctionContent)(t)&&(0,a.getTwoNumbersDistance)(e.x,t.position.x)<=5){const n={type:"line",point:{x:t.position.x,y:e.y},start:t.position};return B(n),n}return B(void 0),{point:e}};"point"===(null==O?void 0:O.type)&&D.push({type:"circle",x:O.point.x,y:O.point.y,radius:7}),"line"===(null==O?void 0:O.type)&&D.push({type:"line",p1:O.start,p2:O.point});const fe=e=>{j(e),Q(),I(e)},he=(0,a.useEvent)((e=>{const t={x:e.clientX,y:e.clientY},n=(0,a.reverseTransformPosition)(t,te),r=pe(n);L?(void 0===X?Y.current=r.id:K.current=r.id,Z(r.point)):re?ae(r.point):q?q.act((e=>{const[,...t]=(0,i.produceWithPatches)(g,(t=>{const n=t[q.index];n&&e(n,t)}));x(...t)})):void 0!==R&&(M(R),A(void 0))})),ge=(0,a.useEvent)((e=>{const t={x:e.clientX,y:e.clientY},n=(0,a.reverseTransformPosition)(t,te),r=pe(n);L?J(r.point,t):(ie(r.point,N),A((e=>{var t,n;for(let t=0;t{var t,n;for(let r=0;r{G&&(fe(G),e.preventDefault())}));let ye;return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key?(ne(),Q(!0),ce()):(0,a.metaKeyIfMacElseCtrlKey)(e)&&(e.shiftKey?"KeyZ"===e.code&&v(e):"KeyZ"===e.code?y(e):"Backspace"===e.code&&(void 0===R||(0,s.contentIsReferenced)(R,g)?void 0===T||(0,s.contentIsReferenced)(T,g)||(m((e=>{e[T]=void 0})),M(void 0)):(m((e=>{e[R]=void 0})),A(void 0))))})),o().useImperativeHandle(t,(()=>({handlePatchesEvent(e){try{b(e.patches,e.reversePatches,e.operator)}catch(e){console.error(e)}}})),[b]),o().useEffect((()=>{const e=[];g.forEach(((t,n)=>{var r,o;if(t)if((0,s.isJunctionContent)(t)){const r=[],o=[];g.forEach(((e,t)=>{e&&(0,s.isDeviceContent)(e)&&(e.start===n?r.push(`I${t}`):e.end===n&&o.push(`I${t}`))})),r.length+o.length>0&&e.push({left:r.join(" + ")||"0",right:o.join(" + ")||"0"}),t.ground&&e.push({left:`U${n}`,right:"0"})}else if((0,s.isDeviceContent)(t)&&"number"==typeof t.start&&"number"==typeof t.end){const i=null==(o=null==(r=(0,s.getContentModel)(t))?void 0:r.getEquationData)?void 0:o.call(r,t,n);i&&e.push(i)}}));const t=e.map((e=>({left:(0,p.parseExpression)((0,p.tokenizeExpression)(e.left)),right:(0,p.parseExpression)((0,p.tokenizeExpression)(e.right))}))),n=[];for(const[e,r]of Object.entries((0,a.solveEquations)(t)[0]))Array.isArray(r)||"NumericLiteral"!==r.type||(n[+e.slice(1)]=r.value);H(n)}),[g]),re?ye=re.cursor:(void 0!==R&&R!==T||q)&&(ye="pointer"),o().createElement(o().Fragment,null,o().createElement("div",{ref:(0,a.bindMultipleRefs)(P,S)},o().createElement("div",{style:{cursor:ye,position:"absolute",inset:"0px"},onMouseMove:ge},o().createElement(d.Renderer,{contents:g,x:te.x,y:te.y,scale:te.scale,width:f,height:h,assistentContents:D,hovering:R,selected:T,previewPatches:z,equationResult:W,onClick:he,onContextMenu:me}))),o().createElement("div",{style:{position:"relative"}},Object.values(s.modelCenter).filter((e=>e.createPreview)).map((e=>{if(e.icon){const t=o().cloneElement(e.icon,{onClick:()=>fe(e.type),style:{width:"20px",height:"20px",margin:"5px",cursor:"pointer",color:L===e.type?"red":void 0}});return o().createElement("span",{title:e.type,key:e.type},t)}return null})),o().createElement("span",{title:"compress"},o().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100",style:{width:"20px",height:"20px",margin:"5px",cursor:"pointer"},onClick:()=>{m((e=>{var t,n;const r=[];let o=0;const i=[];e.forEach(((e,t)=>{e?(r.push(o),o++):(r.push(void 0),i.unshift(t))})),i.forEach((t=>{e.splice(t,1)}));for(const o of e)o&&(null==(n=null==(t=(0,s.getContentModel)(o))?void 0:t.updateRefId)||n.call(t,o,(e=>"number"==typeof e?r[e]:void 0)));s.contentIndexCache.clear()}))}},o().createElement("rect",{x:"10",y:"44",width:"81",height:"20",strokeWidth:"0",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"currentColor",stroke:"currentColor"}),o().createElement("rect",{x:"9",y:"69",width:"81",height:"20",strokeWidth:"0",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"currentColor",stroke:"currentColor"}),o().createElement("polygon",{points:"42,6 57,6 57,31 73,31 51,44 27,32 42,32",strokeWidth:"0",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"currentColor",stroke:"currentColor"})))),V)}))},7883:(e,t,n)=>{"use strict";n.d(t,{contentIndexCache:()=>h,contentIsReferenced:()=>x,deviceGeometryCache:()=>d,deviceModel:()=>s,getContentModel:()=>v,getDeviceText:()=>b,getReference:()=>f,isDeviceContent:()=>u,isJunctionContent:()=>l,modelCenter:()=>m,registerModel:()=>y,updateReferencedContents:()=>g});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s={isDevice:!0,getRefIds(e){const t=[];return"number"==typeof e.start&&t.push(e.start),"number"==typeof e.end&&t.push(e.end),t},updateRefId(e,t){const n=t(e.start);void 0!==n&&(e.start=n);const r=t(e.end);void 0!==r&&(e.end=r)},getEditPoints:(e,t)=>p.get(e,(()=>{const n=[],r=f(e.start,t,l);r&&n.push({field:"start",content:r});const o=f(e.end,t,l);return o&&n.push({field:"end",content:o}),{editPoints:n.map((({field:e,content:n})=>({x:n.position.x,y:n.position.y,cursor:"move",update(r,{cursor:o}){if(!u(r))return;const i=t.findIndex((e=>e&&l(e)&&(0,a.isSamePoint)(e.position,o)));return r[e]=i>=0?i:{type:"junction",position:{x:o.x,y:o.y}},{assistentContents:[{type:"line",p1:n.position,p2:o}]}}})))}}))};function l(e){return"junction"===e.type}const c={type:"junction",render(e,{target:t,transformStrokeWidth:n}){const r=n(3),o=[t.renderCircle(e.position.x,e.position.y,r,{fillColor:0})];return e.ground&&o.push(t.renderPolyline([{x:e.position.x,y:e.position.y+20},{x:e.position.x,y:e.position.y}]),t.renderPolyline([{x:e.position.x-12,y:e.position.y+20},{x:e.position.x+12,y:e.position.y+20}]),t.renderPolyline([{x:e.position.x-8,y:e.position.y+23},{x:e.position.x+8,y:e.position.y+23}]),t.renderPolyline([{x:e.position.x-4,y:e.position.y+26},{x:e.position.x+4,y:e.position.y+26}])),t.renderGroup(o)},getEditPoints:e=>p.get(e,(()=>({editPoints:[{x:e.position.x,y:e.position.y,cursor:"move",update(t,{cursor:n}){if(l(t))return t.position.x=n.x,t.position.y=n.y,{assistentContents:[{type:"line",p1:e.position,p2:n}]}}}]}))),propertyPanel(e,t){var n;return{ground:i().createElement(a.BooleanEditor,{value:null!=(n=e.ground)&&n,setValue:e=>t((t=>{l(t)&&(t.ground=!!e||void 0)}))})}}};function u(e){var t;return!!(null==(t=v(e))?void 0:t.isDevice)}const d=new a.WeakmapCache3,p=new a.WeakmapCache;function f(e,t,n){if("number"!=typeof e)return n(e)?e:void 0;const r=t[e];return r&&n(r)?r:void 0}const h=new a.WeakmapCache;function g(e,t,n){var o,i;const a=[];if(!l(t))return a;const s=function(e,t){return h.get(e,(()=>t.findIndex((t=>e===t))))}(e,n);for(const e of n){if(!e)continue;const n=v(e);(null==(i=null==(o=null==n?void 0:n.getRefIds)?void 0:o.call(n,e))?void 0:i.includes(s))&&a.push((0,r.produce)(e,(e=>{var r;null==(r=n.updateRefId)||r.call(n,e,(e=>{if(e===s)return t}))})))}return a}const m={};function y(e){m[e.type]=e}function v(e){return m[e.type]}function x(e,t){var n,r,o;for(const i of t)if(i&&(null==(o=null==(r=null==(n=v(i))?void 0:n.getRefIds)?void 0:r.call(n,i))?void 0:o.includes(e)))return!0;return!1}function b(e,t,n,r,o="A"){const i=Math.abs((0,a.getTwoPointsRadian)(e.right,e.left))/Math.PI;let s,l,c=e.center.x,u=e.center.y,d=e.center.x,p=e.center.y;i>1/4&&i<3/4?(c+=10,d-=10,s="left",l="right"):(u-=15,p+=15,s="center",l="center");const f=[];if(n&&f.push(t.renderText(c,u,n,0,16,"monospace",{textAlign:s,textBaseline:"middle"})),void 0!==r){const n=(0,a.isZero)(r)?0:+Math.abs(r).toPrecision(3);if(f.push(t.renderText(d,p,n+o,0,16,"monospace",{textAlign:l,textBaseline:"middle"})),!(0,a.isZero)(r)&&"A"===o){const n=r>0?e.right:e.left,o=(0,a.getPointByLengthAndDirection)(e.center,12,n),i=(0,a.getPointByLengthAndDirection)(e.center,20,n);f.push(t.renderPolyline([(0,a.rotatePositionByCenter)(o,i,30),i,(0,a.rotatePositionByCenter)(o,i,-30)]))}}return f}y(c),y({type:"circle",render:(e,{target:t})=>t.renderCircle(e.x,e.y,e.radius)}),y({type:"line",render:(e,{target:t})=>t.renderPolyline([e.p1,e.p2],{dashArray:[4]})})},3649:(e,t,n)=>{"use strict";n.d(t,{capacitorModel:()=>h});var r=n(3696),o=n.n(r),i=n(9758),a=n(7883),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const h=l(((e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e})({type:"capacitor"},a.deviceModel),c({render(e,{target:t,transformStrokeWidth:n,contents:r,value:o,equationResult:i}){const s=n(1),{lines:l,data:c}=g(e,r),u=l.map((e=>t.renderPolyline(e,{strokeWidth:s})));if(c){if(i&&"number"==typeof e.start&&"number"==typeof e.end){const t=i[e.start],n=i[e.end];void 0!==t&&void 0!==n&&(o=(n-t)*e.value)}u.push(...(0,a.getDeviceText)(c,t,e.value+"F",o,"C"))}return t.renderGroup(u)},createPreview:e=>({type:"capacitor",start:e.start,end:e.end,value:1}),getGeometries:g,icon:o().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},o().createElement("polyline",{points:"9,48 37,48",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"36,75 36,22",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"96,48 64,48",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"64,75 64,22",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"})),propertyPanel:(e,t)=>({value:o().createElement(i.NumberEditor,{value:e.value,setValue:e=>t((t=>{(function(e){return"capacitor"===e.type})(t)&&(t.value=e)}))})}),getEquationData:(e,t)=>({left:`I${t}`,right:"0"})}));function g(e,t){const n=(0,a.getReference)(e.start,t,a.isJunctionContent),r=(0,a.getReference)(e.end,t,a.isJunctionContent);return n&&r?a.deviceGeometryCache.get(e,n,r,(()=>{const e=(0,i.getTwoPointCenter)(n.position,r.position),t=(0,i.getPointByLengthAndDirection)(e,3,n.position),o=(0,i.getPointByLengthAndDirection)(e,3,r.position),a=(0,i.getTwoPointsRadian)(n.position,r.position)+Math.PI/2,s=[[n.position,t],[r.position,o],[(0,i.getPointByLengthAndRadian)(t,8,a),(0,i.getPointByLengthAndRadian)(t,-8,a)],[(0,i.getPointByLengthAndRadian)(o,8,a),(0,i.getPointByLengthAndRadian)(o,-8,a)]];return{data:{center:e,left:n.position,right:r.position},lines:s}})):{lines:[]}}},4942:(e,t,n)=>{"use strict";n.d(t,{powerModel:()=>g});var r=n(3696),o=n.n(r),i=n(9758),a=n(7883),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function h(e){return"power"===e.type}const g=(m=((e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e})({type:"power"},a.deviceModel),y={render(e,{target:t,transformStrokeWidth:n,contents:r,value:o}){const i=n(1),{lines:s,data:l}=v(e,r),c=s.map((e=>t.renderPolyline(e,{strokeWidth:i})));return l&&c.push(...(0,a.getDeviceText)(l,t,e.value+"V",o)),t.renderGroup(c)},createPreview:e=>({type:"power",start:e.start,end:e.end,value:1}),getGeometries:v,icon:o().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},o().createElement("polyline",{points:"9,48 37,48",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"36,66 36,32",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"96,48 64,48",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"64,75 64,22",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"})),propertyPanel:(e,t)=>({value:o().createElement(i.NumberEditor,{value:e.value,setValue:e=>t((t=>{h(t)&&(t.value=e)}))}),direction:o().createElement(i.Button,{onClick:()=>t((e=>{if(h(e)){const t=e.end;e.end=e.start,e.start=t}}))},"switch")}),getEquationData:e=>({left:`U${e.start} + ${e.value}`,right:`U${e.end}`})},l(m,c(y)));var m,y;function v(e,t){const n=(0,a.getReference)(e.start,t,a.isJunctionContent),r=(0,a.getReference)(e.end,t,a.isJunctionContent);return n&&r?a.deviceGeometryCache.get(e,n,r,(()=>{const e=(0,i.getTwoPointCenter)(n.position,r.position),t=(0,i.getPointByLengthAndDirection)(e,3,n.position),o=(0,i.getPointByLengthAndDirection)(e,3,r.position),a=(0,i.getTwoPointsRadian)(n.position,r.position)+Math.PI/2,s=[[n.position,t],[r.position,o],[(0,i.getPointByLengthAndRadian)(t,4,a),(0,i.getPointByLengthAndRadian)(t,-4,a)],[(0,i.getPointByLengthAndRadian)(o,8,a),(0,i.getPointByLengthAndRadian)(o,-8,a)]];return{data:{center:e,left:n.position,right:r.position},lines:s}})):{lines:[]}}},5918:(e,t,n)=>{"use strict";n.d(t,{resistanceModel:()=>h});var r=n(3696),o=n.n(r),i=n(9758),a=n(7883),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const h=l(((e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e})({type:"resistance"},a.deviceModel),c({render(e,{target:t,transformStrokeWidth:n,contents:r,value:o}){const i=n(1),{lines:s,data:l}=g(e,r),c=s.map((e=>t.renderPolyline(e,{strokeWidth:i})));return l&&c.push(...(0,a.getDeviceText)(l,t,e.value+"Ω",o)),t.renderGroup(c)},createPreview:e=>({type:"resistance",start:e.start,end:e.end,value:1}),getGeometries:g,icon:o().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},o().createElement("rect",{x:"15",y:"35",width:"71",height:"24",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"85,45 99,45",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"13,44 0,44",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"})),propertyPanel:(e,t)=>({value:o().createElement(i.NumberEditor,{value:e.value,setValue:e=>t((t=>{(function(e){return"resistance"===e.type})(t)&&(t.value=e)}))})}),getEquationData:(e,t)=>({left:`U${e.start} - ${e.value} * I${t}`,right:`U${e.end}`})}));function g(e,t){const n=(0,a.getReference)(e.start,t,a.isJunctionContent),r=(0,a.getReference)(e.end,t,a.isJunctionContent);return n&&r?a.deviceGeometryCache.get(e,n,r,(()=>{const e=(0,i.getTwoPointCenter)(n.position,r.position),t=(0,i.getPointByLengthAndDirection)(e,8,n.position),o=(0,i.getPointByLengthAndDirection)(e,8,r.position),a=(0,i.getTwoPointsRadian)(n.position,r.position)+Math.PI/2,s=[[n.position,t],[r.position,o],...(0,i.iteratePolygonLines)([(0,i.getPointByLengthAndRadian)(t,4,a),(0,i.getPointByLengthAndRadian)(t,-4,a),(0,i.getPointByLengthAndRadian)(o,-4,a),(0,i.getPointByLengthAndRadian)(o,4,a)])];return{data:{center:e,left:n.position,right:r.position},lines:s}})):{lines:[]}}},7305:(e,t,n)=>{"use strict";n.d(t,{switchModel:()=>g});var r=n(3696),o=n.n(r),i=n(9758),a=n(7883),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function h(e){return"switch"===e.type}const g=l(((e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e})({type:"switch"},a.deviceModel),c({render(e,{target:t,transformStrokeWidth:n,contents:r,value:o}){const i=n(1),{lines:s,data:l}=m(e,r),c=s.map((e=>t.renderPolyline(e,{strokeWidth:i})));return l&&c.push(...(0,a.getDeviceText)(l,t,void 0,o)),t.renderGroup(c)},createPreview:e=>({type:"switch",start:e.start,end:e.end,on:!1}),getGeometries:m,icon:o().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},o().createElement("polyline",{points:"1,46 34,46",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("circle",{cx:"39",cy:"47",r:"7",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"43,41 71,27",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"}),o().createElement("polyline",{points:"69,47 100,47",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"})),propertyPanel:(e,t)=>({on:o().createElement(i.BooleanEditor,{value:e.on,setValue:e=>t((t=>{h(t)&&(t.on=e)}))})}),getEquationData:(e,t)=>e.on?{left:`U${e.start}`,right:`U${e.end}`}:{left:`I${t}`,right:"0"},getAction(e,t,n){const{data:r}=m(t,n);if(r&&(0,i.getTwoPointsDistance)(r.center,e)<16)return e=>{e((e=>{h(e)&&(e.on=!e.on)}))}}}));function m(e,t){const n=(0,a.getReference)(e.start,t,a.isJunctionContent),r=(0,a.getReference)(e.end,t,a.isJunctionContent);return n&&r?a.deviceGeometryCache.get(e,n,r,(()=>{const t=(0,i.getTwoPointCenter)(n.position,r.position),o=(0,i.getPointByLengthAndDirection)(t,8,n.position),a=[[n.position,(0,i.getPointByLengthAndDirection)(o,3,n.position)],...(0,i.iteratePolylineLines)((0,i.arcToPolyline)((0,i.circleToArc)({x:o.x,y:o.y,r:3}),5))];if(e.on)a.push([(0,i.getPointByLengthAndDirection)(o,3,r.position),r.position]);else{const e=(0,i.getPointByLengthAndDirection)(t,8,r.position),n=(0,i.rotatePositionByCenter)(e,o,30);a.push([(0,i.getPointByLengthAndDirection)(o,3,n),n],[e,r.position])}return{lines:a,data:{center:t,left:n.position,right:r.position}}})):{lines:[]}}},66:(e,t,n)=>{"use strict";n.d(t,{wireModel:()=>h});var r=n(3696),o=n.n(r),i=n(9758),a=n(7883),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const h=l(((e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e})({type:"wire"},a.deviceModel),c({render(e,{target:t,transformStrokeWidth:n,contents:r,value:o}){const i=n(1),{lines:s,data:l}=g(e,r),c=s.map((e=>t.renderPolyline(e,{strokeWidth:i})));return l&&c.push(...(0,a.getDeviceText)(l,t,void 0,o)),t.renderGroup(c)},createPreview:e=>({type:"wire",start:e.start,end:e.end}),getGeometries:g,icon:o().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},o().createElement("polyline",{points:"1,46 100,46",strokeWidth:"5",strokeMiterlimit:"10",strokeLinejoin:"miter",strokeLinecap:"butt",fill:"none",stroke:"currentColor"})),getEquationData:e=>({left:`U${e.start}`,right:`U${e.end}`})}));function g(e,t){const n=(0,a.getReference)(e.start,t,a.isJunctionContent),r=(0,a.getReference)(e.end,t,a.isJunctionContent);return n&&r?a.deviceGeometryCache.get(e,n,r,(()=>{const e=(0,i.getTwoPointCenter)(n.position,r.position);return{lines:[[n.position,r.position]],data:{center:e,left:n.position,right:r.position}}})):{lines:[]}}},4607:(e,t,n)=>{"use strict";n.d(t,{Renderer:()=>p});var r=n(8662),o=n(9758),i=n(7883),a=Object.defineProperty,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))c.call(t,n)&&u(e,n,t[n]);return e};function p(e){var t,n;const a=o.reactSvgRenderTarget,s=[],l=e.previewPatches.length>0?(0,r.applyPatches)(e.contents,e.previewPatches):e.contents;for(let n=0;ne.hovering===n||e.selected===n?t+1:t,contents:l,value:e.equationResult[n],equationResult:e.equationResult}))}}for(const t of e.assistentContents){if(!t)continue;const e=null==(n=(0,i.getContentModel)(t))?void 0:n.render;e&&s.push(e(t,{target:a,transformStrokeWidth:e=>e,contents:l}))}return a.renderResult(s,e.width,e.height,{attributes:{style:d({position:"absolute",boxSizing:"border-box"},e.style),onClick:e.onClick,onMouseDown:e.onMouseDown,onContextMenu:e.onContextMenu},transform:{x:e.x,y:e.y,scale:e.scale}})}},9277:(e,t,n)=>{"use strict";n.d(t,{Combination2:()=>u});var r=n(3696),o=n.n(r),i=n(9758),a=n(7449),s=n(1406),l=Math.pow;const c=Math.round(15*Math.random()*l(16,3)+l(16,3)).toString(16);function u(){const[e,t]=o().useState(),{pluginLoaded:n,pluginCommandTypes:r}=(0,s.usePlugins)(),[l,u]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:panel",!0),[d,p]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:print-mode",!1),[f,h]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:performance-mode",!1),g=(0,s.useInitialStateValidated)(e,n);o().useEffect((()=>{t([])}),[]);const m=o().useRef(null),[y,v]=o().useState(!1),[x,b]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:snaps",i.allSnapTypes),[C,E]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:render-target",void 0),[P,k]=o().useState(!1),[w,_]=o().useState(!1),[S,R]=o().useState(),[A,T]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:input-fixed",!1),[M,L]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:background-color",16777215),[I,O]=(0,i.useLocalStorageState)("composable-editor-canvas-combination2:debug",!1);return o().createElement("div",{style:{height:"100%"}},e&&n&&g&&o().createElement(s.CADEditor,{ref:m,id:"combination2",operator:c,initialState:e,readOnly:y,snapTypes:x,renderTarget:C,setCanUndo:k,setCanRedo:_,setOperation:R,inputFixed:A,backgroundColor:M,debug:I,panelVisible:l,printMode:d,performanceMode:f}),o().createElement("div",{style:{position:"fixed",width:"100%"}},!y&&r.map((e=>{if(e.icon){const t=o().cloneElement(e.icon,{onClick:()=>{var t;return null==(t=m.current)?void 0:t.startOperation({type:"command",name:e.name})},key:e.name,style:{width:"20px",height:"20px",margin:"5px",cursor:"pointer",color:S===e.name?"red":void 0}});return o().createElement("span",{title:e.name,key:e.name},t)}return null})),["move canvas","zoom window"].map((e=>o().createElement("button",{onClick:()=>{var t;return null==(t=m.current)?void 0:t.startOperation({type:"non command",name:e})},key:e,style:{position:"relative",top:"-10px",borderColor:S===e?"red":void 0}},e))),o().createElement("button",{onClick:()=>(t(void 0),void setTimeout((()=>{const e=[];for(let t=0;t<200;t++)for(let n=0;n<200;n++){const r=Math.random();if(r<.05)e.push({type:"circle",x:100*t+50*(Math.random()-.5),y:100*n+50*(Math.random()-.5),r:80*Math.random()+20});else if(r<.1)e.push({type:"rect",x:100*t+50*(Math.random()-.5),y:100*n+50*(Math.random()-.5),width:80*Math.random()+20,height:20*Math.random()+80,angle:360*Math.random()-180});else if(r<.15)e.push({type:"ellipse",cx:100*t+50*(Math.random()-.5),cy:100*n+50*(Math.random()-.5),rx:80*Math.random()+20,ry:20*Math.random()+80,angle:360*Math.random()-180});else if(r<.2)e.push({type:"regular polygon",x:100*t+50*(Math.random()-.5),y:100*n+50*(Math.random()-.5),radius:80*Math.random()+20,count:[3,5,6,8][Math.floor(4*Math.random())],angle:360*Math.random()-180});else if(r<.25){const r=80*Math.random()+20;e.push({type:"star",x:100*t+50*(Math.random()-.5),y:100*n+50*(Math.random()-.5),innerRadius:r*(.4*Math.random()+.3),outerRadius:r,count:[5,6,8][Math.floor(3*Math.random())],angle:360*Math.random()-180})}}t(e)}),0)),style:{position:"relative",top:"-10px"}},"add mock data"),!y&&o().createElement("button",{disabled:!P,onClick:()=>{var e;return null==(e=m.current)?void 0:e.undo()},style:{position:"relative",top:"-10px"}},"undo"),!y&&o().createElement("button",{disabled:!w,onClick:()=>{var e;return null==(e=m.current)?void 0:e.redo()},style:{position:"relative",top:"-10px"}},"redo"),!y&&o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:l,onChange:()=>u(!l)}),"panel"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:d,onChange:()=>p(!d)}),"print mode"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:f,onChange:()=>h(!f)}),"performance mode"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:I,onChange:()=>O(!I)}),"debug"),o().createElement("select",{value:C,onChange:e=>E(e.target.value),style:{position:"relative"}},(0,a.getAllRendererTypes)().map((e=>o().createElement("option",{key:e,value:e},e)))),!y&&i.allSnapTypes.map((e=>o().createElement("label",{key:e,style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:x.includes(e),onChange:t=>b(t.target.checked?[...x,e]:x.filter((t=>t!==e)))}),e))),o().createElement("label",{style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:y,onChange:e=>v(e.target.checked)}),"read only"),!y&&o().createElement("label",{style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:A,onChange:e=>T(e.target.checked)}),"input fixed"),o().createElement("input",{type:"color",style:{position:"relative"},value:(0,i.getColorString)(M),onChange:e=>L((0,i.colorStringToNumber)(e.target.value))})))}},9456:(e,t,n)=>{"use strict";n.d(t,{Combination3:()=>y});var r=n(3696),o=n.n(r),i=n(8214),a=n(5011),s=n(395),l=n(7310),c=n(2693),u=n(726),d=n(4430),p=n(3685),f=n(8749),h=n(6286),g=Math.pow;const m=Math.round(15*Math.random()*g(16,3)+g(16,3)).toString(16);function y(){const[e]=o().useState(h.richTextData),[t,n]=o().useState(!0),[r,g]=o().useState(!1),y=o().useRef({blocks:{h1:a.h1,h2:a.h2,h3:a.h3,h4:a.h4,h5:a.h5,h6:a.h6,p:a.p,ul:a.ul,ol:a.ol,hr:a.hr},styles:{"font size":s.fontSize,"font family":s.fontFamily,bold:s.bold,italic:s.italic,underline:s.underline,"pass through":s.passThrough,color:s.color,"background color":s.backgroundColor},hooks:[l.useAt,c.useLink,u.useImage,p.useCircle,f.useStack],inlines:[c.link,u.image,p.circle,f.stack],textInlines:{span:d.span,code:d.code,mark:d.mark,sub:d.sub,sup:d.sup}});return e?o().createElement("div",null,o().createElement("div",null,o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:t,onChange:e=>n(e.target.checked)}),"autoHeight"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:r,onChange:e=>g(e.target.checked)}),"readOnly")),o().createElement(i.RichTextEditor,{initialState:e,width:500,height:300,autoHeight:t,readOnly:r,operator:m,plugin:y.current})):null}},7511:(e,t,n)=>{"use strict";n.d(t,{Combination4:()=>l});var r=n(3696),o=n.n(r),i=n(3802),a=Math.pow;const s=Math.round(15*Math.random()*a(16,3)+a(16,3)).toString(16);function l(){const[e]=o().useState([]),t=o().useRef(null);return e?o().createElement("div",null,o().createElement(i.CircuitGraphEditor,{operator:s,ref:t,initialState:e})):null}},3714:(e,t,n)=>{"use strict";n.d(t,{Combination5:()=>c});var r=n(3696),o=n.n(r),i=n(2100),a=n(6129),s=Math.pow;const l=Math.round(15*Math.random()*s(16,3)+s(16,3)).toString(16);function c(){const[e]=o().useState(a.astronomicalObjectData),t=o().useRef(null);return o().createElement("div",null,o().createElement(i.AstronomicalObjectSimulator,{operator:l,ref:t,initialState:e}))}},577:(e,t,n)=>{"use strict";n.d(t,{Combination6:()=>y});var r=n(3696),o=n.n(r),i=n(8662),a=n(9758),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=Math.pow,h=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&h(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&h(e,n,t[n]);return e},m=(e,t)=>l(e,c(t));function y(){const{width:e,height:t}=(0,a.useWindowSize)(),n=a.reactCanvasRenderTarget,[r,s,l]=(0,a.useRefState)([]),[c,u]=o().useState(),[d,p]=o().useState(!1),[h,y]=o().useState(!1),P=o().useRef(!1),[k,w]=o().useState(),_=[],S={x:e/2,y:t-v},R=o().useRef(new WeakSet);o().useEffect((()=>{let n;const r=o=>{if(void 0!==n){const r=.002*(o-n),c=P.current?x:v,u=[];for(const n of l.current){if(n.x<0||n.y<0||n.x>e||n.y>t)continue;const o=(0,i.produce)(n,(e=>{e.x=n.x+r*n.speed.x;const t=n.speed.y+r*b;e.y=n.y+r*(0,a.getTwoNumberCenter)(t,n.speed.y),e.speed.y=t})),s=u.findIndex((e=>f(e.x-o.x,2)+f(e.y-o.y,2)<=f(c,2)));s>=0?u.splice(s,1):(u.push(o),R.current.has(n)&&(R.current.add(o),R.current.delete(n)))}s(u)}n=o,requestAnimationFrame(r)};requestAnimationFrame(r)}),[]),o().useEffect((()=>{if(!d)return;const t=setInterval((()=>{const t=Math.random();s((0,i.produce)(l.current,(n=>{n.push({type:"drop",x:t*e,y:v,speed:{x:(t>.5?-1:1)*Math.random()*e*.03,y:0}})})))}),1e3);return()=>clearInterval(t)}),[d]),o().useEffect((()=>{if(!h)return;const e=setInterval((()=>{B()}),1e3);return()=>clearInterval(e)}),[h]);const{line:A,cursorPosition:T,onClick:M,reset:L,onMove:I}=(0,a.useLineClickCreate)("drop"===c,(e=>{s((0,i.produce)(r,(t=>{t.push(E(e,v,c))}))),L()}),{once:!0}),O=e=>{L(),u(e)},B=()=>{const e=l.current.find((e=>"drop"===e.type&&!R.current.has(e)));if(!e)return;const t=function(e,t){const n=t.x-e.x,r=t.y-e.y,o=n*e.speed.y-r*e.speed.x,i=f(C,2),s=f(n,2)+f(r,2),l=4*i*f(n,2)-4*f(o,2)+4*i*f(r,2);if((0,a.lessThan)(l,0))return[];const c=-o*r,u=o*n;if((0,a.isZero)(l))return[{x:c/s,y:u/s}];const d=f(l,.5),p=.5*n*d,h=.5*r*d;return[{x:(c+p)/s,y:(u+h)/s},{x:(c-p)/s,y:(u-h)/s}]}(e,S);0!==t.length&&(s((0,i.produce)(l.current,(e=>{for(const n of t)n.y<0&&e.push(m(g({type:"shoot down"},S),{speed:n}))}))),R.current.add(e))};A?_.push(E(A,v,c)):T?_.push(E([T,T],v,c)):k&&_.push(E([S,k],v,c));const F=[];for(const e of[...r,..._]){const t="drop"===e.type?16711680:65280,r=P.current&&"shoot down"===e.type?x:v;if(F.push(n.renderCircle(e.x,e.y,r,{fillColor:t,strokeWidth:0})),e.speed.x||e.speed.y){const r=(0,a.getTwoPointsDistance)(e.speed),o=(0,a.getTwoPointsRadian)(e.speed),i=(0,a.getPointByLengthAndRadian)(e,r+v,o);F.push(n.renderPolyline([e,i],{strokeColor:t}))}}const D=(0,a.useEvent)((e=>{const t={x:e.clientX,y:e.clientY};"drop"===c?M(t):"shoot down"===c&&k&&s((0,i.produce)(r,(e=>{e.push(E([S,k],v,c))})))})),z=(0,a.useEvent)((e=>{const t={x:e.clientX,y:e.clientY};"drop"===c?I(t):"shoot down"===c&&w(t)}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&(u(void 0),w(void 0),L(!0))})),o().createElement("div",{style:{position:"absolute",inset:"0px",overflow:"hidden"},onMouseMove:z},n.renderResult(F,e,t,{attributes:{onClick:D}}),o().createElement("div",{style:{position:"absolute",top:"0px"}},o().createElement(a.Button,{style:{color:"drop"===c?"red":void 0},onClick:()=>O("drop")},"drop"),o().createElement("label",{style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:d,onChange:e=>p(e.target.checked)}),"drop auto")),o().createElement("div",{style:{position:"absolute",bottom:"0px",right:"0px"}},o().createElement(a.Button,{style:{color:"shoot down"===c?"red":void 0},onClick:()=>O("shoot down")},"shoot down"),o().createElement("label",{style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:P.current,onChange:e=>P.current=e.target.checked}),"detonate"),o().createElement(a.Button,{onClick:()=>B()},"aim auto"),o().createElement("label",{style:{position:"relative"}},o().createElement("input",{type:"checkbox",checked:h,onChange:e=>y(e.target.checked)}),"shoot auto")))}const v=5,x=25,b=9.8,C=200;function E([e,t],n,r){if("drop"===r)e={x:e.x,y:n},t={x:t.x,y:n};else if("shoot down"===r){const n=(0,a.getTwoPointsRadian)(t,e),r=(0,a.multipleDirection)((0,a.getDirectionByRadian)(n),C);return m(g({type:"shoot down"},e),{speed:r})}const o=(0,a.getTwoPointsDistance)(e,t);let i;if(o>n){const r=(0,a.getPointByLengthAndDirection)(t,o-n,e);i={x:t.x-r.x,y:t.y-r.y}}else i={x:0,y:0};return m(g({type:"drop"},e),{speed:i})}},84:(e,t,n)=>{"use strict";n.d(t,{Combination7:()=>f});var r=n(3696),o=n.n(r),i=n(8662),a=n(9758),s=n(7951),l=n(490),c=n(5527),u=n(3107),d=n(7728),p=n(5722);function f(){const e=a.reactCanvasRenderTarget,{width:t,height:n}=(0,a.useWindowSize)(),[r,f,h]=(0,a.useRefState)(s.initialModels),[g,m,y]=(0,a.useRefState)([]),[v,x]=o().useState([]),[,b,C]=(0,a.useRefState)(0),E=o().useRef();let P;v.length>0&&(P=o().createElement(c.Panel,{target:r[v[0]],status:E,updater:e=>{f((0,i.produce)(r,(t=>{e(t[0])})))}}));const{onStartSelect:k,dragSelectMask:w,resetDragSelect:_}=(0,a.useDragSelect)(((e,t)=>{var n,o;if(t&&Math.abs(e.x-t.x)>10&&Math.abs(e.y-t.y)>10){const n={start:{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y)},end:{x:Math.max(e.x,t.x),y:Math.max(e.y,t.y)}};x(Array.from(r.entries()).filter((([,e])=>(0,a.pointIsInRegion)(e.position,n))).map((([e])=>e)))}else{if(null==(n=E.current)?void 0:n.ability){const t=(0,p.getAbilityFromIndex)(E.current.ability);if(null==(o=null==t?void 0:t.cast)?void 0:o.radius)return f((0,i.produce)(r,(t=>{for(const n of v)t[n].canControl&&E.current&&(t[n].action={type:"attack",ability:E.current.ability,target:e})}))),void(E.current=void 0)}for(const[t,n]of r.entries())if((0,a.getTwoPointsDistance)(n.position,e)<=d.units[n.unit].size){if(E.current){f((0,i.produce)(r,(e=>{for(const n of v)e[n].canControl&&E.current&&(e[n].action={type:"attack",ability:E.current.ability,target:t})}))),E.current=void 0;break}x([t]);break}}}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key?(_(),x([])):"s"===e.key?f((0,i.produce)(r,(e=>{for(const t of v)e[t].canControl&&e[t].action&&(e[t].action=void 0)}))):"a"===e.key&&(E.current={type:"attack"})})),o().useEffect((()=>{const e=t=>{if(0!==C.current){const e=(0,l.updateModels)(.001*(t-C.current),h.current,y.current);e.models&&f(e.models),e.bullets&&m(e.bullets)}b(t),requestAnimationFrame(e)};requestAnimationFrame(e)}),[]),o().createElement(o().Fragment,null,o().createElement("div",{style:{position:"absolute",inset:"0px",overflow:"hidden"},onMouseDown:k,onContextMenu:e=>{f((0,i.produce)(r,(t=>{for(const n of v)t[n].canControl&&(t[n].action={type:"move",to:{x:Math.round(e.clientX),y:Math.round(e.clientY)}})}))),e.preventDefault()}},e.renderResult((0,u.renderModels)(r,g,v),t,n),w),P)}},8977:(e,t,n)=>{"use strict";n.d(t,{abilities:()=>i});var r=n(5722),o=n(1915);const i=[{name:"Laguna Blade",cooldown:70,mana:150,cast:{range:300,bulletSpeed:400,hit:(e,t)=>(0,r.attackPureDamage)(e,t,500)},launch(e,t){t((t=>{a(t,e)}))}},{name:"Firestorm",cooldown:16,mana:110,cast:{range:300,bulletSpeed:400,radius:200,hit:(e,t)=>(0,r.attackPureDamage)(e,t,200)},launch(e,t){t((t=>{a(t,e)}))}}];function a(e,t){const n=i[t];if(void 0!==e.mana){const i=(0,r.getModelResult)(e);i.mana&&(e.mana=Math.min(e.mana-n.mana/i.mana.total,1)),(0,o.updateAbilityCooldown)(e,t,"abilities",n.cooldown)}}},7951:(e,t,n)=>{"use strict";n.d(t,{initialModels:()=>r});const r=[{unit:0,position:{x:200,y:200},facing:0,canControl:!0,health:.4,mana:.5,attackCooldown:0,items:[],abilities:[0,1]},{unit:1,position:{x:300,y:200},facing:0,canControl:!0,health:.8},{unit:2,position:{x:400,y:200},facing:0,canControl:!1,health:1}]},1915:(e,t,n)=>{"use strict";n.d(t,{items:()=>o,updateAbilityCooldown:()=>i});var r=n(5722);const o=[{name:"Icon Branch",strength:1,agility:1,intelligence:1},{name:"Boots of Speed",speed:45},{name:"Vitality Booster",health:250},{name:"Ring of Health",heathRegeneration:4.5},{name:"Platemail",armor:10},{name:"Cloak",magicResistance:.2},{name:"Aether Lens",mana:300,manaRegeneration:2.5},{name:"Monkey King Bar",attackDamage:40,attackSpeed:45},{name:"Arcane Boots",mana:250,speed:45,ability:{name:"Replenish Mana",cooldown:55,mana:0,launch(e,t){t((t=>{if(void 0!==t.mana){const e=(0,r.getModelResult)(t);e.mana&&(t.mana=Math.min(t.mana+175/e.mana.total,1))}const n=o[e];n.ability&&i(t,e,"items",n.ability.cooldown)}))}}},{name:"Dagon",strength:7,agility:7,intelligence:7,ability:{name:"Energy Burst",cooldown:35,mana:120,cast:{range:300,hit:(e,t)=>(0,r.attackMagicDamage)(e,t,400)},launch(e,t){t((t=>{!function(e,t){const n=o[t];if(void 0!==e.mana&&n.ability){const o=(0,r.getModelResult)(e);o.mana&&(e.mana=Math.min(e.mana-n.ability.mana/o.mana.total,1)),i(e,t,"items",n.ability.cooldown)}}(t,e)}))}}}];function i(e,t,n,r){e.abilityCooldowns||(e.abilityCooldowns=[]);const o=e.abilityCooldowns.find((e=>e.index===t));o?o.cooldown=r:e.abilityCooldowns.push({index:t,cooldown:r,source:n})}},5527:(e,t,n)=>{"use strict";n.d(t,{Panel:()=>c});var r=n(3696),o=n.n(r),i=n(9758),a=n(5722),s=n(1915),l=n(8977);function c({target:e,updater:t,status:n}){const[r,c]=o().useState(0),u=(0,a.getModelResult)(e),d={speed:o().createElement(i.Label,null,u.speed,"<-",u.baseSpeed),canControl:o().createElement(i.BooleanEditor,{value:e.canControl,setValue:e=>t((t=>{t.canControl=e}))})};let p;return u.health&&(d.health=o().createElement(i.Label,null,Math.round(u.health.current),"/",Math.round(u.health.total),"<-",Math.round(u.health.base.total)),d.healthRegeneration=o().createElement(i.Label,null,u.health.regeneration,"<-",u.health.base.regeneration),d.armor=o().createElement(i.Label,null,Math.round(u.health.armor),"<-",u.health.base.armor),d.magicResistance=o().createElement(i.Label,null,u.health.magicResistance,"<-",u.health.base.magicResistance)),u.mana&&(p=Math.round(u.mana.current),d.mana=o().createElement(i.Label,null,p,"/",Math.round(u.mana.total),"<-",Math.round(u.mana.base.total)),d.manaRegeneration=o().createElement(i.Label,null,u.mana.regeneration,"<-",u.mana.regeneration)),u.attack&&(d.damage=o().createElement(i.Label,null,Math.round(u.attack.damage),"+-",u.attack.damageRange,"<-",u.attack.base.damage),d.attackSpeed=o().createElement(i.Label,null,u.attack.speed,"<-",u.attack.base.speed),d.attackTime=o().createElement(i.Label,null,Math.round(u.attack.time),"<-",u.attack.base.time),d.bulletSpeed=o().createElement(i.Label,null,u.attack.bulletSpeed),d.attackRange=o().createElement(i.Label,null,u.attack.range,"<-",u.attack.base.range)),u.attributes&&(d.strength=o().createElement(i.Label,null,u.attributes.strength,"<-",u.attributes.base.strength),d.agility=o().createElement(i.Label,null,u.attributes.agility,"<-",u.attributes.base.agility),d.intelligence=o().createElement(i.Label,null,u.attributes.intelligence,"<-",u.attributes.base.intelligence),d.primary=o().createElement(i.Label,null,u.attributes.primary)),o().createElement("div",{style:{position:"absolute",right:"0px",top:"0px",bottom:"0px",width:"400px",overflowY:"auto",background:"white",zIndex:11}},o().createElement("select",{value:r,onChange:e=>c(+e.target.value)},s.items.map(((e,t)=>o().createElement("option",{key:e.name,value:t},e.name)))),e.items&&o().createElement(i.ArrayEditor,{inline:!0,add:()=>t((e=>{e.items&&e.items.push(r)})),remove:e=>t((t=>{t.items&&t.items.splice(e,1)})),items:e.items.map((r=>{var a,l;const c=s.items[r],u=null==(l=null==(a=e.abilityCooldowns)?void 0:a.find((e=>"items"===e.source&&e.index===r)))?void 0:l.cooldown;if(!c.ability)return o().createElement(i.Label,null,s.items[r].name);const d=!!u||void 0===p||p{c.ability&&!d&&(c.ability.cast?n.current={type:"attack",ability:{index:r,source:"items"}}:c.ability.launch(r,t))}},s.items[r].name," ",u?u.toFixed(1):"")}))}),e.abilities&&o().createElement(i.ArrayEditor,{inline:!0,items:e.abilities.map((r=>{var a,s;const c=l.abilities[r],u=null==(s=null==(a=e.abilityCooldowns)?void 0:a.find((e=>"abilities"===e.source&&e.index===r)))?void 0:s.cooldown,d=!!u||void 0===p||p{d||(c.cast?n.current={type:"attack",ability:{index:r,source:"abilities"}}:c.launch(r,t))}},l.abilities[r].name," ",u?u.toFixed(1):"")}))}),o().createElement(i.ObjectEditor,{inline:!0,properties:d}))}},3107:(e,t,n)=>{"use strict";n.d(t,{renderModels:()=>i});var r=n(9758),o=n(7728);function i(e,t,n){const i=r.reactCanvasRenderTarget,a=e.map(((e,t)=>{const a=o.units[e.unit].size,s=n.includes(t)?e.canControl?65280:255:void 0,l=[i.renderCircle(e.position.x,e.position.y,a,{strokeColor:s}),i.renderPolyline([(0,r.getPointByLengthAndRadian)(e.position,a,e.facing),(0,r.getPointByLengthAndRadian)(e.position,2*a,e.facing)],{strokeColor:s})];if(void 0!==e.health){const t=6,n=a,r=e.health;l.push(i.renderRect(e.position.x-n/2,e.position.y-a-t,n,t),i.renderRect(e.position.x-n/2,e.position.y-a-t,r*a,t,{fillColor:65280}))}if(void 0!==e.mana){const t=6,n=-6,r=a,o=e.mana;l.push(i.renderRect(e.position.x-r/2,e.position.y-a-t-n,r,t),i.renderRect(e.position.x-r/2,e.position.y-a-t-n,o*a,t,{fillColor:255}))}return i.renderGroup(l)}));return a.push(...t.map((e=>"instant"===e.type?i.renderEmpty():i.renderCircle(e.position.x,e.position.y,5)))),a}},490:(e,t,n)=>{"use strict";n.d(t,{updateModels:()=>l});var r=n(8662),o=n(9758),i=n(5722),a=n(1915),s=n(7728);function l(e,t,n){var l,c;const u=[...t];let d=!1;const p=[];for(const t of n){const n=u[t.source];let a;if(void 0===t.type){const n=e*t.speed,r=u[t.target];(0,o.getTwoPointsDistance)(t.position,r.position)-s.units[r.unit].size>n&&(a=(0,o.getPointByLengthAndDirection)(t.position,n,r.position))}else if("position"===t.type){const n=e*t.speed;(0,o.getTwoPointsDistance)(t.position,t.target)>n&&(a=(0,o.getPointByLengthAndDirection)(t.position,n,t.target))}if(a){const e=a;p.push((0,r.produce)(t,(t=>{void 0!==t.type&&"position"!==t.type||(t.position=e)})))}else{const e="position"===t.type?(0,i.getModelsAroundPositionByRadiusExcept)(u,t.target,t.radius,t.source):[[t.target,u[t.target]]];for(const[o,a]of e){if(!s.units[a.unit].health)continue;const e=(0,i.getModelResult)(n),l=(0,i.getModelResult)(a);if(t.ability){const e=(0,i.getAbilityFromIndex)(t.ability);if(null==e?void 0:e.cast){const t=e.cast.hit(a,l);t&&(u[o]=t,d=!0)}}else if(e.attack&&l.health){const s=(0,i.getDamageAfterArmor)(e.attack.damage+Math.random()*e.attack.damageRange,l.health.armor),c=Math.max(0,(l.health.current-s)/l.health.total);u[o]=(0,r.produce)(a,(e=>{e.health=c})),0===c&&(u[t.source]=(0,r.produce)(n,(e=>{e.action=void 0}))),d=!0}}}}for(const t of u.keys()){let n=u[t];const f=(0,i.getModelResult)(n);if(void 0!==n.health&&f.health&&f.health.regeneration&&n.health>0&&n.health<1){const o=e*f.health.regeneration,i=f.health.total;u[t]=(0,r.produce)(n,(e=>{e.health&&(e.health=Math.min(e.health+o/i,1))})),d=!0,n=u[t]}if(void 0!==n.mana&&f.mana&&f.mana.regeneration&&n.mana<1){const o=e*f.mana.regeneration,i=f.mana.total;u[t]=(0,r.produce)(n,(e=>{e.mana&&(e.mana=Math.min(e.mana+o/i,1))})),d=!0,n=u[t]}if(n.abilityCooldowns&&n.abilityCooldowns.length>0){const o=[];for(const t of n.abilityCooldowns){const n=Math.max(0,t.cooldown-e);n&&o.push({index:t.index,source:t.source,cooldown:n})}u[t]=(0,r.produce)(n,(e=>{e.abilityCooldowns=o})),d=!0,n=u[t]}if(n.action){if("attack"===n.action.type){let h,g,m=0;if("number"==typeof n.action.target){const e=u[n.action.target];h=e.position,g=!!e.health&&e.health>0,m=s.units[e.unit].size}else h=n.action.target,g=!0;const y=(0,o.getTwoPointsRadian)(h,n.position);if(g){const g=(0,o.getTwoPointsDistance)(n.position,h)-s.units[n.unit].size-m;if(n.action.ability){const m=(0,i.getAbilityFromIndex)(n.action.ability),{index:v,source:x}=n.action.ability;if(null==m?void 0:m.cast){if(g>m.cast.range){const i=e*f.speed,a=(0,o.getPointByLengthAndDirection)(n.position,i,h);u[t]=(0,r.produce)(n,(e=>{e.position=a,e.facing=y})),d=!0;continue}if(!(null==(c=null==(l=n.abilityCooldowns)?void 0:l.find((e=>e.source===x&&e.index===v)))?void 0:c.cooldown)){if(u[t]=(0,r.produce)(n,(e=>{e.facing=y,e.action=void 0,(0,a.updateAbilityCooldown)(e,v,x,m.cooldown),m.launch(v,(t=>{t(e)}))})),"number"!=typeof n.action.target){m.cast.bulletSpeed&&m.cast.radius&&(p.push({type:"position",position:(0,o.getPointByLengthAndDirection)(n.position,s.units[n.unit].size,h),source:t,target:h,speed:m.cast.bulletSpeed,radius:m.cast.radius,ability:{index:v,source:x}}),d=!0);continue}if(!m.cast.bulletSpeed){p.push({type:"instant",source:t,target:n.action.target,ability:{index:v,source:x}}),d=!0;continue}p.push({position:(0,o.getPointByLengthAndDirection)(n.position,s.units[n.unit].size,h),source:t,target:n.action.target,ability:{index:v,source:x},speed:m.cast.bulletSpeed}),d=!0;continue}u[t]=(0,r.produce)(n,(e=>{e.facing=y})),d=!0;continue}}else if(f.attack){if(g>f.attack.range){const i=e*f.speed,a=(0,o.getPointByLengthAndDirection)(n.position,i,h);u[t]=(0,r.produce)(n,(e=>{e.position=a,e.facing=y})),d=!0;continue}const i=f.attack.time;if(0===f.attack.cooldown&&"number"==typeof n.action.target){u[t]=(0,r.produce)(n,(e=>{e.facing=y,e.attackCooldown=.001*i})),p.push({position:(0,o.getPointByLengthAndDirection)(n.position,s.units[n.unit].size,h),source:t,target:n.action.target,speed:f.attack.bulletSpeed}),d=!0;continue}u[t]=(0,r.produce)(n,(t=>{t.facing=y,t.attackCooldown&&(t.attackCooldown=Math.max(0,t.attackCooldown-e))})),d=!0;continue}}y!==n.facing&&(u[t]=(0,r.produce)(n,(e=>{e.facing=y})),d=!0);continue}const h=e*f.speed,g=n.action.to,m=(0,o.getTwoPointsDistance)(n.position,g),y=(0,o.getTwoPointsRadian)(g,n.position);let v;if(m<=h)v=(0,r.produce)(n,(e=>{e.position=g,e.action=void 0,e.facing=y}));else{const e=(0,o.getPointByLengthAndDirection)(n.position,h,g);v=(0,r.produce)(n,(t=>{t.position=e,t.facing=y}))}let x=!0;for(let e=0;e{e.facing=y})),d=!0)}}return{models:d?u:void 0,bullets:p.length>0||n.length>0?p:void 0}}},7728:(e,t,n)=>{"use strict";n.d(t,{units:()=>r});const r=[{speed:300,size:24,health:{total:500,regeneration:10,armor:0,magicResistance:.25},mana:{total:400,regeneration:.5},attack:{damage:50,damageRange:2,speed:100,time:1700,bulletSpeed:900,range:300},attributes:{strength:20,agility:30,intelligence:15,primary:"agility"}},{speed:300,size:24,health:{total:600,regeneration:10,armor:10,magicResistance:.25}},{speed:300,size:24,health:{total:700,regeneration:10,armor:-10,magicResistance:0}}]},5722:(e,t,n)=>{"use strict";n.d(t,{attackMagicDamage:()=>C,attackPureDamage:()=>b,getAbilityFromIndex:()=>x,getDamageAfterArmor:()=>v,getModelResult:()=>y,getModelsAroundPositionByRadiusExcept:()=>E});var r=n(8662),o=n(8977),i=n(1915),a=n(7728),s=n(9758),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&h(e,n,t[n]);if(d)for(var n of d(t))f.call(t,n)&&h(e,n,t[n]);return e},m=(e,t)=>c(e,u(t));function y(e){const t=a.units[e.unit];let n=t.speed;const r=t.attributes?m(g({},t.attributes),{base:t.attributes}):void 0,o=t.health&&void 0!==e.health?m(g({},t.health),{current:e.health,base:t.health}):void 0,s=t.mana&&void 0!==e.mana?m(g({},t.mana),{current:e.mana,base:t.mana}):void 0,l=t.attack&&void 0!==e.attackCooldown?m(g({},t.attack),{cooldown:e.attackCooldown,base:t.attack}):void 0;if(e.items)for(const t of e.items){const e=i.items[t];e.speed&&(n+=e.speed),o&&(e.health&&(o.total+=e.health),e.heathRegeneration&&(o.regeneration+=e.heathRegeneration),e.armor&&(o.armor+=e.armor),e.magicResistance&&e.magicResistance),s&&(e.mana&&(s.total+=e.mana),e.manaRegeneration&&(s.regeneration+=e.manaRegeneration)),l&&(e.attackDamage&&(l.damage+=e.attackDamage),e.attackSpeed&&(l.speed+=e.attackSpeed),e.attackRange&&(l.range+=e.attackRange)),r&&(e.strength&&(r.strength+=e.strength),e.agility&&(r.agility+=e.agility),e.intelligence&&(r.intelligence+=e.intelligence))}return o&&((null==r?void 0:r.strength)&&(o.total+=22*r.strength,o.regeneration+=.1*r.strength),(null==r?void 0:r.agility)&&(o.armor+=r.agility/6),(null==r?void 0:r.intelligence)&&(o.magicResistance=1-1*(1-(o.magicResistance+.001*r.intelligence))),o.current*=o.total),s&&((null==r?void 0:r.intelligence)&&(s.total+=12*r.intelligence,s.regeneration+=.05*r.intelligence),s.current*=s.total),l&&r&&("strength"===r.primary?l.damage+=r.strength:"agility"===r.primary?l.damage+=r.agility:"intelligence"===r.primary?l.damage+=r.intelligence:l.damage+=.7*(r.strength+r.agility+r.intelligence),r.agility&&(l.speed+=r.agility),l.time*=100/l.speed),{size:t.size,baseSpeed:t.speed,speed:n,health:o,mana:s,attack:l,attributes:r}}function v(e,t){return e*(1-.06*t/(1+.06*Math.abs(t)))}function x(e){return"abilities"===e.source?o.abilities[e.index]:i.items[e.index].ability}function b(e,t,n){if(!t.health||void 0===e.health)return e;const o=t.health.total,i=Math.max(0,e.health-n/o);return(0,r.produce)(e,(e=>{e.health=i}))}function C(e,t,n){if(!t.health||void 0===e.health)return e;const o=t.health.magicResistance,i=t.health.total,a=n*(1-o),s=Math.max(0,e.health-a/i);return(0,r.produce)(e,(e=>{e.health=s}))}function E(e,t,n,r){return Array.from(e.entries()).filter((([e,o])=>e!==r&&(0,s.getTwoPointsDistance)(o.position,t)-a.units[o.unit].size<=n))}},8781:(e,t,n)=>{"use strict";n.d(t,{styleGuide:()=>r});const r={name:"test",templates:[{id:"1",name:"组件",x:0,y:0,width:500,height:300,contents:[{kind:"text",text:"test",fontFamily:"serif",fontSize:50,color:"#ff0000",width:100,height:100,x:10,y:10},{kind:"image",url:"https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg",width:100,height:100,x:210,y:10}]},{id:"2",name:"模板",x:600,y:0,width:1100,height:400,contents:[{kind:"color",x:0,y:0,width:1100,height:400,color:"#cccccc"},{kind:"reference",id:"1",x:10,y:10},{kind:"snapshot",rotate:30,snapshot:{id:"1",name:"组件",x:0,y:0,width:500,height:300,contents:[{kind:"text",text:"test",fontFamily:"serif",fontSize:50,color:"#ff0000",width:100,height:100,x:10,y:10},{kind:"image",url:"https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg",width:100,height:100,x:210,y:10}]},x:550,y:10}]}]}},4341:(e,t,n)=>{"use strict";n.d(t,{HoverRenderer:()=>a});var r=n(3696),o=n.n(r),i=n(681);function a(e){var t,n;const{styleGuide:r,hovered:a}=e,s=(0,i.getTargetByPath)(a,r);if(!s)return null;const l=s.template;if("template"===s.kind)return o().createElement(o().Fragment,null,o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:l.x,top:l.y,width:l.width,height:l.height,backgroundColor:"green",opacity:.1}}));const c=s.content,u=(0,i.getTemplateContentSize)(c,r);if(!u)return null;const{width:d,height:p}=u;let f=o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:c.x,top:c.y,width:d,height:p,backgroundColor:"green",opacity:.1,transform:`rotate(${null!=(t=c.rotate)?t:0}deg)`}});for(const e of s.parents)"snapshot"===e.kind&&(f=o().createElement("div",{style:{position:"absolute",left:e.x,top:e.y,width:e.snapshot.width,height:e.snapshot.height,transform:`rotate(${null!=(n=e.rotate)?n:0}deg)`}},f));return o().createElement("div",{style:{position:"absolute",left:l.x,top:l.y,width:l.width,height:l.height}},f)}},5371:(e,t,n)=>{"use strict";n.d(t,{App:()=>f});var r=n(3696),o=n.n(r),i=n(9758),a=n(8781),s=n(4341),l=n(2550),c=n(2801),u=n(681);const d="composable-editor-canvas-draft",p=localStorage.getItem(d);function f(){var e;const{state:t,setState:n,undo:r,redo:f,stateIndex:g}=(0,i.useUndoRedo)(p?JSON.parse(p):a.styleGuide);o().useEffect((()=>{g>0&&localStorage.setItem(d,JSON.stringify(t))}),[t,g]);const m=Math.min(...t.templates.map((e=>e.x))),y=Math.min(...t.templates.map((e=>e.y))),[v]=o().useState({width:Math.max(...t.templates.map((e=>e.x+e.width)))-m,height:Math.max(...t.templates.map((e=>e.y+e.height)))-y}),x={width:window.innerWidth,height:window.innerHeight},{ref:b,scale:C,setScale:E}=(0,i.useWheelZoom)(),P=C*Math.min((x.width-80)/v.width,(x.height-80)/v.height),k={width:v.width*P+80,height:v.height*P+80},{x:w,y:_,setX:S,setY:R,ref:A}=(0,i.useWheelScroll)({maxOffsetX:(k.width-x.width)/2,maxOffsetY:(k.height-x.height)/2}),{zoomIn:T,zoomOut:M}=(0,i.useZoom)(C,E),{selected:[L],setSelected:I,onSelectedKeyDown:O}=(0,i.useSelected)({maxCount:1}),{selected:[B],setSelected:F,onSelectedKeyDown:D}=(0,i.useSelected)({maxCount:1}),z={containerSize:x,targetSize:v,x:w,y:_,scale:P},U=(0,u.getSelectedSize)(L,t),N=(0,u.getTargetByPath)(L,t),G="content"===(null==N?void 0:N.kind)?N.parents.reduce(((e,t)=>{var n;return e+(null!=(n=t.rotate)?n:0)}),0):void 0,{regionAlignmentX:j,regionAlignmentY:V,changeOffsetByRegionAlignment:W,clearRegionAlignments:H}=(0,i.useRegionAlignment)(6/P),{offset:q,onStart:$,mask:Y,startPosition:K,resetDragMove:X}=(0,i.useDragMove)((()=>{H(),0===q.x&&0===q.y&&K?I((0,u.selectByPosition)(t,h(K,z),P)):n((e=>{const t=(0,u.getSelectedPosition)(L,e);t&&(t.x+=q.x,t.y+=q.y)}))}),{scale:P,parentRotate:G,transformOffset:(e,n)=>{if(n&&!n.shiftKey&&"template"===(null==N?void 0:N.kind)){const n=N.template;W(e,n,t.templates.filter((e=>e!==n)))}else H();return e}}),{offset:Z,onStart:Q,mask:J,center:ee,resetDragRotate:te}=(0,i.useDragRotate)((()=>{n((e=>{const t=(0,u.getTargetByPath)(L,e);"content"===(null==t?void 0:t.kind)&&(t.content.rotate=null==Z?void 0:Z.angle)}))}),{transform:e=>h(e,z),parentRotate:G,transformOffset:(e,t)=>{if(t&&void 0!==e&&!t.shiftKey){const t=45*Math.round(e/45);Math.abs(t-e)<5&&(e=t)}return e}}),{lineAlignmentX:ne,lineAlignmentY:re,changeOffsetByLineAlignment:oe,clearLineAlignments:ie}=(0,i.useLineAlignment)(6/P),{offset:ae,onStart:se,mask:le,startPosition:ce,resetDragResize:ue}=(0,i.useDragResize)((()=>{ie(),n((e=>{const t=(0,u.getSelectedSize)(L,e),n=(0,u.getSelectedPosition)(L,e);t&&(t.width+=ae.width,t.height+=ae.height),n&&(n.x+=ae.x,n.y+=ae.y)}))}),{centeredScaling:e=>e.shiftKey,keepRatio:e=>{if((0,i.metaKeyIfMacElseCtrlKey)(e)&&U)return U.width/U.height},rotate:"content"===(null==N?void 0:N.kind)&&null!=(e=N.content.rotate)?e:0,parentRotate:G,transform:e=>h(e,z),transformOffset:(e,n,r)=>{if(n&&r&&!n.altKey&&"template"===(null==N?void 0:N.kind)){const n=N.template,o=t.templates.filter((e=>e!==n)).map((e=>[e.x,e.x+e.width])).flat(),i=t.templates.filter((e=>e!==n)).map((e=>[e.y,e.y+e.height])).flat();oe(e,r,n,o,i)}else ie();return e}}),{onStartSelect:de,dragSelectMask:pe,dragSelectStartPosition:fe,resetDragSelect:he}=(0,i.useDragSelect)(((e,n)=>{if(n){const r=(0,u.selectTemplateByArea)(t,h(e,z),h(n,z));void 0!==r&&I([r])}else I((0,u.selectByPosition)(t,h(e,z),P))}),(e=>e.shiftKey));(0,i.useGlobalKeyDown)((e=>{O(e),D(e),"Escape"===e.key?(he(),te(),ue(),X()):(0,i.metaKeyIfMacElseCtrlKey)(e)&&("KeyZ"===e.code?e.shiftKey?f(e):r(e):"Minus"===e.code?M(e):"Equal"===e.code&&T(e))}));const ge={x:q.x+ae.x,y:q.y+ae.y,width:ae.width,height:ae.height},me=K||ee||ce||fe;return o().createElement("div",{style:{position:"absolute",inset:"0px",backgroundColor:"#E0DFDE",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},ref:(0,i.bindMultipleRefs)(A,b),onMouseMove:e=>{if(me)F();else{const n=(0,u.selectByPosition)(t,h({x:e.clientX,y:e.clientY},z),P);(0,i.isSamePath)(n,B)||F(n)}},onMouseDown:e=>{de(e,void 0)}},o().createElement(l.StyleGuideRenderer,{styleGuide:t,targetSize:v,x:w,y:_,scale:P,onStartSelect:de,offset:ge,rotate:null==Z?void 0:Z.angle,selected:L}),L&&o().createElement("div",{style:{position:"absolute",transform:`translate(${w}px, ${_}px) scale(${P})`,width:v.width,height:v.height,pointerEvents:"none"}},o().createElement(c.SelectionRenderer,{styleGuide:t,scale:P,selected:L,onStartMove:$,offset:ge,rotate:null==Z?void 0:Z.angle,onStartRotate:Q,onStartResize:se})),B&&o().createElement("div",{style:{position:"absolute",transform:`translate(${w}px, ${_}px) scale(${P})`,width:v.width,height:v.height,pointerEvents:"none"}},o().createElement(s.HoverRenderer,{styleGuide:t,hovered:B})),o().createElement(i.Scrollbar,{value:w,type:"horizontal",containerSize:x.width,contentSize:k.width,onChange:S}),o().createElement(i.Scrollbar,{value:_,type:"vertical",containerSize:x.height,contentSize:k.height,onChange:R}),o().createElement(i.AlignmentLine,{type:"x",value:null!=j?j:ne,transformX:e=>function(e,t){var n,r,o,i,a,s;return(null!=(r=null==(n=null==t?void 0:t.containerSize)?void 0:n.width)?r:0)/2-((null!=(i=null==(o=null==t?void 0:t.targetSize)?void 0:o.width)?i:0)/2-e)*(null!=(a=null==t?void 0:t.scale)?a:1)+(null!=(s=null==t?void 0:t.x)?s:0)}(e,z)}),o().createElement(i.AlignmentLine,{type:"y",value:null!=V?V:re,transformY:e=>function(e,t){var n,r,o,i,a,s;return(null!=(r=null==(n=null==t?void 0:t.containerSize)?void 0:n.height)?r:0)/2-((null!=(i=null==(o=null==t?void 0:t.targetSize)?void 0:o.height)?i:0)/2-e)*(null!=(a=null==t?void 0:t.scale)?a:1)+(null!=(s=null==t?void 0:t.y)?s:0)}(e,z)}),Y,J,le,pe)}function h({x:e,y:t},n){var r,o,i,a,s,l,c,u,d,p,f,h;return{x:(null!=(o=null==(r=null==n?void 0:n.targetSize)?void 0:r.width)?o:0)/2-((null!=(a=null==(i=null==n?void 0:n.containerSize)?void 0:i.width)?a:0)/2-e+(null!=(s=null==n?void 0:n.x)?s:0))/(null!=(l=null==n?void 0:n.scale)?l:1),y:(null!=(u=null==(c=null==n?void 0:n.targetSize)?void 0:c.height)?u:0)/2-((null!=(p=null==(d=null==n?void 0:n.containerSize)?void 0:d.height)?p:0)/2-t+(null!=(f=null==n?void 0:n.y)?f:0))/(null!=(h=null==n?void 0:n.scale)?h:1)}}},2550:(e,t,n)=>{"use strict";n.d(t,{StyleGuideRenderer:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(681);function s(e){const{x:t,y:n,scale:r,styleGuide:a,targetSize:s,onStartSelect:c,selected:u,offset:d,rotate:p}=e;return o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",transform:`translate(${t}px, ${n}px) scale(${r})`,width:s.width,height:s.height}},a.templates.map(((e,t)=>o().createElement(l,{key:e.id,template:e,styleGuide:a,path:[t],onStartSelect:c,selected:u,offset:d,rotate:p,scale:r,isSelected:(0,i.isSamePath)(u,[t])}))))}function l(e){const{template:t,selected:n,offset:r,rotate:i,onStartSelect:s,scale:l}=e;return o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:t.x+(e.isSelected?r.x:0),top:t.y+(e.isSelected?r.y:0),width:t.width+(e.isSelected?r.width:0),height:t.height+(e.isSelected?r.height:0),border:1/l+"px solid rgb(160, 160, 160)",backgroundColor:"white"},onMouseDown:e=>{e.stopPropagation(),s(e)}},t.name&&o().createElement("div",{style:{position:"absolute",top:`-${a.nameSize}px`,lineHeight:`${a.nameSize}px`,fontSize:"12px",width:t.name.length*a.nameSize+"px",transform:`scale(${1/l})`,transformOrigin:"left bottom",cursor:"pointer"}},t.name),t.contents.map(((t,a)=>o().createElement(u,{key:a,content:t,styleGuide:e.styleGuide,offset:r,rotate:i,path:[...e.path,a],selected:n}))))}function c(e){var t,n,r,i,a,s;const{template:l,styleGuide:c,content:d,offset:p,rotate:f}=e;return o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:d.x+(e.isSelected&&null!=(t=null==p?void 0:p.x)?t:0),top:d.y+(e.isSelected&&null!=(n=null==p?void 0:p.y)?n:0),width:l.width+(e.isSelected&&null!=(r=null==p?void 0:p.width)?r:0),height:l.height+(e.isSelected&&null!=(i=null==p?void 0:p.height)?i:0),clipPath:"inset(0)",backgroundColor:"white",transform:`rotate(${null!=(s=null!=(a=e.isSelected?f:void 0)?a:d.rotate)?s:0}deg)`}},l.contents.map(((t,n)=>o().createElement(u,{key:n,content:t,styleGuide:c,path:[...e.path,n],offset:p,rotate:f,selected:e.selected}))))}function u(e){const{content:t,offset:n,rotate:r}=e;if(t.hidden)return null;const a=(0,i.isSamePath)(e.selected,e.path);if("text"===t.kind)return o().createElement(d,{content:t,offset:a?n:void 0,rotate:a?r:void 0});if("image"===t.kind)return o().createElement(p,{content:t,offset:a?n:void 0,rotate:a?r:void 0});if("color"===t.kind)return o().createElement(f,{content:t,offset:a?n:void 0,rotate:a?r:void 0});if("reference"===t.kind){const i=e.styleGuide.templates.findIndex((e=>e.id===t.id));if(i>=0)return o().createElement(c,{template:e.styleGuide.templates[i],styleGuide:e.styleGuide,content:t,path:[i],offset:n,rotate:r,selected:e.selected,isSelected:a})}return"snapshot"===t.kind?o().createElement(c,{template:t.snapshot,styleGuide:e.styleGuide,content:t,path:e.path,offset:n,rotate:r,selected:e.selected,isSelected:a}):null}function d(e){var t,n,r,i,a;const{content:s,offset:l,rotate:c}=e;return o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:s.x+(null!=(t=null==l?void 0:l.x)?t:0),top:s.y+(null!=(n=null==l?void 0:l.y)?n:0),width:s.width+(null!=(r=null==l?void 0:l.width)?r:0),height:s.height+(null!=(i=null==l?void 0:l.height)?i:0),color:s.color,fontSize:s.fontSize,fontFamily:s.fontFamily,transform:`rotate(${null!=(a=null!=c?c:s.rotate)?a:0}deg)`}},s.text)}function p(e){var t,n,r,i,a;const{content:s,offset:l,rotate:c}=e;return o().createElement("img",{src:s.url,style:{position:"absolute",boxSizing:"border-box",left:s.x+(null!=(t=null==l?void 0:l.x)?t:0),top:s.y+(null!=(n=null==l?void 0:l.y)?n:0),width:s.width+(null!=(r=null==l?void 0:l.width)?r:0),height:s.height+(null!=(i=null==l?void 0:l.height)?i:0),transform:`rotate(${null!=(a=null!=c?c:s.rotate)?a:0}deg)`}})}function f(e){var t,n,r,i,a;const{content:s,offset:l,rotate:c}=e;return o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:s.x+(null!=(t=null==l?void 0:l.x)?t:0),top:s.y+(null!=(n=null==l?void 0:l.y)?n:0),width:s.width+(null!=(r=null==l?void 0:l.width)?r:0),height:s.height+(null!=(i=null==l?void 0:l.height)?i:0),backgroundColor:s.color,transform:`rotate(${null!=(a=null!=c?c:s.rotate)?a:0}deg)`}})}},2801:(e,t,n)=>{"use strict";n.d(t,{SelectionRenderer:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(681);function s(e){var t,n,r,s;const{styleGuide:l,scale:c,selected:u,offset:d,rotate:p,onStartRotate:f,onStartResize:h}=e,g=(0,a.getTargetByPath)(u,l);if(!g)return null;const m=t=>{var n;t.stopPropagation(),null==(n=e.onStartMove)||n.call(e,{x:t.clientX,y:t.clientY})},y=g.template;if("template"===g.kind)return o().createElement(o().Fragment,null,o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:y.x+d.x,top:y.y+d.y,width:y.width+d.width,height:y.height+d.height,border:1/c+"px solid green",cursor:"move",pointerEvents:"auto"},onMouseDown:m}),o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:y.x+d.x,top:y.y+d.y,width:y.width+d.width,height:y.height+d.height}},o().createElement(i.ResizeBar,{scale:c,onMouseDown:h})),y.name&&o().createElement("div",{style:{position:"absolute",left:y.x+d.x,top:y.y+d.y-a.nameSize,height:a.nameSize,fontSize:"12px",width:y.name.length*a.nameSize,transform:`scale(${1/c})`,transformOrigin:"left bottom",cursor:"move",pointerEvents:"auto"},onMouseDown:m}));const v=g.content,x=(0,a.getTemplateContentSize)(v,l);if(!x)return null;const{width:b,height:C}=x;let E=o().createElement(o().Fragment,null,o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:v.x+d.x,top:v.y+d.y,width:b+d.width,height:C+d.height,border:1/c+"px solid green",cursor:"move",pointerEvents:"auto",transform:`rotate(${null!=(t=null!=p?p:v.rotate)?t:0}deg)`},onMouseDown:m}),o().createElement("div",{style:{position:"absolute",boxSizing:"border-box",left:v.x+d.x,top:v.y+d.y,width:b+d.width,height:C+d.height,transform:`rotate(${null!=(n=null!=p?p:v.rotate)?n:0}deg)`}},o().createElement(i.RotationBar,{scale:c,onMouseDown:e=>{e.stopPropagation(),f((0,a.getRotatedCenter)(g,l))}}),o().createElement(i.ResizeBar,{scale:c,onMouseDown:h,rotate:(null!=(r=v.rotate)?r:0)+g.parents.reduce(((e,t)=>{var n;return e+(null!=(n=t.rotate)?n:0)}),0)})));for(const e of g.parents)"snapshot"===e.kind&&(E=o().createElement("div",{style:{position:"absolute",left:e.x,top:e.y,width:e.snapshot.width,height:e.snapshot.height,transform:`rotate(${null!=(s=e.rotate)?s:0}deg)`}},E));return o().createElement("div",{style:{position:"absolute",left:y.x,top:y.y,width:y.width,height:y.height}},E)}},681:(e,t,n)=>{"use strict";n.d(t,{getRotatedCenter:()=>y,getSelectedPosition:()=>l,getSelectedSize:()=>s,getTargetByPath:()=>c,getTemplateContentSize:()=>d,nameSize:()=>h,selectByPosition:()=>g,selectTemplateByArea:()=>p});var r=n(9758),o=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),i=function(e,t){this[0]=e,this[1]=t},a=e=>{var t,n=e[o("asyncIterator")],r=!1,a={};return null==n?(n=e[o("iterator")](),t=e=>a[e]=t=>n[e](t)):(n=n.call(e),t=e=>a[e]=t=>{if(r){if(r=!1,"throw"===e)throw t;return t}return r=!0,{done:!1,value:new i(new Promise((r=>{var o=n[e](t);if(!(o instanceof Object))throw TypeError("Object expected");r(o)})),1)}}),a[o("iterator")]=()=>a,t("next"),"throw"in n?t("throw"):a.throw=e=>{throw e},"return"in n&&t("return"),a};function s(e,t){const n=c(e,t);if(!n)return;const r=n.template;return"content"===n.kind?d(n.content,t):r}function l(e,t){const n=c(e,t);if(n)return"template"===n.kind?n.template:n.content}function c(e,t){if(!e)return;const[n,...r]=e,o=t.templates[n];if(0===r.length)return{kind:"template",template:o};const i=u(r,o,t,[]);return i?{kind:"content",template:o,content:i.content,parents:i.parents}:void 0}function u([e,...t],n,r,o){const i=n.contents[e];if(0===t.length)return{content:i,parents:o};if("snapshot"===i.kind)return u(t,i.snapshot,r,[...o,i]);if("reference"===i.kind){const e=r.templates.find((e=>e.id===i.id));if(!e)return;return u(t,e,r,[...o,i])}}function d(e,t){if("snapshot"===e.kind)return e.snapshot;if("reference"===e.kind){const n=t.templates.find((t=>t.id===e.id));if(!n)return;return n}return e}function p(e,t,n){const r={x:Math.min(t.x,n.x),y:Math.min(t.y,n.y),width:Math.abs(t.x-n.x),height:Math.abs(t.y-n.y)};for(let t=0;tf(e,t))):(e=function(e,t){if(!t.rotate)return e;const n=t.x+t.width/2,o=t.y+t.height/2;return(0,r.rotatePositionByCenter)(e,{x:n,y:o},t.rotate)}(e,t),e.x>=t.x&&e.y>=t.y&&e.x<=t.x+t.width&&e.y<=t.y+t.height)}const h=14;function g(e,t,n){const r=h/n;for(let n=e.templates.length-1;n>=0;n--){const o=e.templates[n];if(o.name&&f(t,{x:o.x,y:o.y-r,width:r*o.name.length,height:r}))return[n];for(const r of m(o,o,e,[],[]))if(f(t,r))return[n,...r.path];if(f(t,o))return[n]}}function*m(e,t,n,o,i){var s,l,c;for(let u=e.contents.length-1;u>=0;u--){const p=e.contents[u],f=[...i,u];let h=t.x+p.x,g=t.y+p.y;if("snapshot"===p.kind){const e=[{rotate:null!=(s=p.rotate)?s:0,x:h+p.snapshot.width/2,y:g+p.snapshot.height/2},...o];yield*a(m(p.snapshot,{x:h,y:g},n,e,f))}const{width:y,height:v}=null!=(l=d(p,n))?l:{width:0,height:0};let x={x:h+y/2,y:g+v/2},b=null!=(c=p.rotate)?c:0;for(const e of o)b+=e.rotate,x=(0,r.rotatePositionByCenter)(x,e,-e.rotate);h=x.x-y/2,g=x.y-v/2,yield{x:h,y:g,rotate:b,width:y,height:v,path:f}}}function y(e,t){var n,o;let i={x:e.template.x,y:e.template.y};const a=[];for(const t of e.parents)"snapshot"===t.kind&&(i.x+=t.x,i.y+=t.y,a.unshift({rotate:null!=(n=t.rotate)?n:0,x:i.x+t.snapshot.width/2,y:i.y+t.snapshot.height/2}));const{width:s,height:l}=null!=(o=d(e.content,t))?o:{width:0,height:0};i.x+=e.content.x+s/2,i.y+=e.content.y+l/2;for(const e of a)i=(0,r.rotatePositionByCenter)(i,e,-e.rotate);return i}},3464:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const[e,t]=o().useState(0),[n,r]=o().useState(0),{offset:a,onStart:s,mask:l,resetDragMove:c}=(0,i.useDragMove)((()=>{t((e=>e+a.x)),r((e=>e+a.y))}));return(0,i.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()})),o().createElement("div",{style:{width:"300px",height:"300px",overflow:"hidden",position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid green"}},o().createElement("div",{style:{width:"800px",height:"800px",position:"absolute",transform:`translate(${e+a.x}px, ${n+a.y}px)`,background:"radial-gradient(50% 50% at 50% 50%, red 0%, white 100%)",cursor:"grab"},onMouseDown:e=>s({x:e.clientX,y:e.clientY})}),l)}},7215:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState({x:200,y:200,width:100,height:100}),{offset:n,onStart:o,mask:s,resetDragResize:l}=(0,a.useDragResize)((()=>t(c)),{centeredScaling:e=>e.shiftKey,keepRatio:t=>(0,a.metaKeyIfMacElseCtrlKey)(t)?e.width/e.height:void 0});(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()}));const c=(0,r.produce)(e,(e=>{e.width+=n.width,e.height+=n.height,e.x+=n.x,e.y+=n.y}));return i().createElement(i().Fragment,null,i().createElement("div",{style:{width:`${c.width}px`,height:`${c.height}px`,left:`${c.x}px`,top:`${c.y}px`,boxSizing:"border-box",position:"absolute",background:"radial-gradient(50% 50% at 50% 50%, red 0%, white 100%)"}},i().createElement(a.ResizeBar,{onMouseDown:o})),s)}},4874:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState({x:200,y:200,width:100,height:100,rotate:0,url:"https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg"}),{offset:n,onStart:o,mask:s,resetDragRotate:l}=(0,a.useDragRotate)((()=>t(c)),{transformOffset:(e,t)=>{if(t&&void 0!==e&&!t.shiftKey){const t=45*Math.round(e/45);Math.abs(t-e)<5&&(e=t)}return e}});(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()}));const c=(0,r.produce)(e,(e=>{void 0!==(null==n?void 0:n.angle)&&(e.rotate=n.angle)}));return i().createElement(i().Fragment,null,i().createElement("div",{style:{width:`${e.width}px`,height:`${e.width}px`,left:`${e.x}px`,top:`${e.y}px`,boxSizing:"border-box",position:"absolute",transform:`rotate(${c.rotate}deg)`,background:`url(${e.url})`,backgroundSize:"contain"}},i().createElement(a.RotationBar,{onMouseDown:()=>o({x:e.x+e.width/2,y:e.y+e.height/2})})),s)}},3191:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{onStartSelect:n,dragSelectMask:o,resetDragSelect:s}=(0,a.useDragSelect)(((n,o)=>{o&&t((0,r.produce)(e,(e=>{e.push({x:Math.min(n.x,o.x),y:Math.min(n.y,o.y),width:Math.abs(o.x-n.x),height:Math.abs(o.y-n.y)})})))}),(e=>e.shiftKey));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&s()})),i().createElement("div",{onMouseDown:e=>n(e,void 0),style:{height:"100%"}},e.map(((e,t)=>i().createElement("div",{key:t,style:{width:`${e.width}px`,height:`${e.height}px`,left:`${e.x}px`,top:`${e.y}px`,position:"absolute",border:"1px solid green"}}))),o)}},9612:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{var e;const[t,n]=o().useState({x:300,y:200,r:100}),{editPoint:r,updateEditPreview:a,onEditMove:s,onEditClick:l,getEditAssistentContents:c,resetEdit:u}=(0,i.useEdit)((()=>n(f)),(e=>({editPoints:[{x:e.x,y:e.y,cursor:"move",update(e,{cursor:t,start:n}){e.x+=t.x-n.x,e.y+=t.y-n.y}},{x:e.x-e.r,y:e.y,cursor:"ew-resize",update(e,{cursor:t}){e.r=(0,i.getTwoPointsDistance)(t,e)}},{x:e.x,y:e.y-e.r,cursor:"ns-resize",update(e,{cursor:t}){e.r=(0,i.getTwoPointsDistance)(t,e)}},{x:e.x+e.r,y:e.y,cursor:"ew-resize",update(e,{cursor:t}){e.r=(0,i.getTwoPointsDistance)(t,e)}},{x:e.x,y:e.y+e.r,cursor:"ns-resize",update(e,{cursor:t}){e.r=(0,i.getTwoPointsDistance)(t,e)}}]})));(0,i.useGlobalKeyDown)((e=>{"Escape"===e.key&&u()}));const d=[],p=a(),f=null!=(e=null==p?void 0:p.result)?e:t;return d.push(...c(f,(e=>e))),o().createElement(o().Fragment,null,o().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0,cursor:null==r?void 0:r.cursor},onMouseMove:e=>s({x:e.clientX,y:e.clientY},[{content:f,path:[0]}]),onClick:e=>r&&l({x:e.clientX,y:e.clientY})},o().createElement("circle",{cx:f.x,cy:f.y,r:f.r,stroke:"#00ff00"}),d.map(((e,t)=>o().createElement("rect",{key:t,x:e.x-e.width/2,y:e.y-e.height/2,width:e.width,height:e.height,stroke:"#00ff00",fill:"#ffffff"})))))}},2071:(e,t,n)=>{"use strict";n.d(t,{default:()=>l});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=n(4469);const l=()=>{const[e,t]=i().useState([]),{ellipse:n,ellipseArc:o,onClick:l,onMove:c,input:u,reset:d}=(0,a.useEllipseArcClickCreate)("ellipse center",(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&d()}));const p=n||o;return i().createElement("div",{onClick:e=>l({x:e.clientX,y:e.clientY}),onMouseMove:e=>c({x:e.clientX,y:e.clientY}),style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>l({x:e.clientX,y:e.clientY}),onMouseMove:e=>c({x:e.clientX,y:e.clientY})},p&&i().createElement("ellipse",{stroke:"#00ff00",cx:p.cx,cy:p.cy,rx:p.rx,ry:p.ry,transform:p.angle?`rotate(${p.angle},${p.cx},${p.cy})`:void 0,strokeDasharray:"4"}),[...e,o].map(((e,t)=>{if(e){const n=(0,a.ellipseArcToPolyline)(e,s.defaultAngleDelta);return i().createElement("polyline",{key:t,points:n.map((e=>`${e.x},${e.y}`)).join(" "),stroke:"#00ff00"})}return null}))),u)}},7258:(e,t,n)=>{"use strict";n.d(t,{default:()=>y});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=n(4469),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&h(e,n,t[n]);if(d)for(var n of d(t))f.call(t,n)&&h(e,n,t[n]);return e},m=(e,t)=>c(e,u(t));const y=()=>{const[e,t]=i().useState({cx:200,cy:200,rx:100,ry:150,angle:45,startAngle:-30,endAngle:120}),{offset:n,onStart:o,mask:l,reset:c}=(0,a.useEllipseArcEdit)((()=>t(u))),u=(0,r.produce)(e,(e=>{n&&(e.cx+=n.cx,e.cy+=n.cy,e.rx+=n.rx,e.ry+=n.ry,e.startAngle+=n.startAngle,e.endAngle+=n.endAngle,(0,a.normalizeAngleRange)(e))}));(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()}));const d=(0,a.ellipseArcToPolyline)(u,s.defaultAngleDelta);return i().createElement(i().Fragment,null,i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0}},i().createElement("polyline",{points:d.map((e=>`${e.x},${e.y}`)).join(" "),stroke:"#00ff00"})),i().createElement(a.EllipseArcEditBar,m(g({},u),{onMouseDown:(e,t,n)=>o(e,m(g({},u),{type:t,cursor:n}))})),l)}},2682:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{ellipse:n,onClick:o,onMove:s,input:l,reset:c}=(0,a.useEllipseClickCreate)("ellipse center",(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()})),i().createElement("div",{style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY})},[...e,n].map(((e,t)=>e&&i().createElement("ellipse",{key:t,stroke:"#00ff00",cx:e.cx,cy:e.cy,rx:e.rx,ry:e.ry,transform:e.angle?`rotate(${e.angle},${e.cx},${e.cy})`:void 0})))),l)}},1783:(e,t,n)=>{"use strict";n.d(t,{default:()=>m});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e},g=(e,t)=>l(e,c(t));const m=()=>{const[e,t]=i().useState({cx:200,cy:200,rx:100,ry:150,angle:45}),{offset:n,onStart:o,mask:s,reset:l}=(0,a.useEllipseEdit)((()=>t(c))),c=(0,r.produce)(e,(e=>{n&&(e.cx+=n.cx,e.cy+=n.cy,e.rx+=n.rx,e.ry+=n.ry)}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()})),i().createElement(i().Fragment,null,i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0}},i().createElement("ellipse",{stroke:"#00ff00",cx:c.cx,cy:c.cy,rx:c.rx,ry:c.ry,transform:c.angle?`rotate(${c.angle},${c.cx},${c.cy})`:void 0})),i().createElement(a.EllipseEditBar,g(h({},c),{onMouseDown:(e,t,n)=>o(e,g(h({},c),{type:t,cursor:n}))})),s)}},5090:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(3031),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState("X1 ** 2 + X2 * X3"),[n,o]=i().useState("(-X6) ** 0.5 / (X4 - X5 ** 3)"),[s,l]=i().useState(),[c,u]=i().useState(!1);return i().useEffect((()=>{try{l({left:(0,r.parseExpression)((0,r.tokenizeExpression)(e)),right:(0,r.parseExpression)((0,r.tokenizeExpression)(n))})}catch(e){console.info(e)}}),[e,n]),i().createElement("div",null,i().createElement(a.ExpressionEditor,{value:e,setValue:t,validate:a.validateExpression}),i().createElement(a.ExpressionEditor,{value:n,setValue:o,validate:a.validateExpression}),i().createElement("label",null,i().createElement("input",{type:"checkbox",checked:c,onChange:()=>u(!c)}),"keep binary expression order"),s&&(0,a.renderEquation)(a.reactSvgRenderTarget,s,{keepBinaryExpressionOrder:c}),s&&i().createElement("code",null,(0,a.printEquation)(s,{keepBinaryExpressionOrder:c})))}},6690:(e,t,n)=>{"use strict";n.d(t,{default:()=>h});var r=n(3031),o=n(3696),i=n.n(o),a=n(9758),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const h=()=>{const{value:e,update:t,getArrayProps:n}=(0,a.useJsonEditorData)([{equation:"a * x + b * y = c",variable:"x"},{equation:"x ** 2 + y ** 2 = r",variable:"y"}]),[o,s]=i().useState(!1),[h,g]=i().useState([]),[m,y]=i().useState(!1),[v,x]=i().useState(!1);return i().useEffect((()=>{try{const t=(0,a.solveEquations)(e.map((e=>{const t=e.equation.split("=");return{left:(0,r.parseExpression)((0,r.tokenizeExpression)(o?(0,a.mathStyleExpressionToExpression)(t[0]):t[0])),right:(0,r.parseExpression)((0,r.tokenizeExpression)(o?(0,a.mathStyleExpressionToExpression)(t[1]):t[1]))}})),new Set(e.map((e=>e.variable))));g(t.map((e=>Object.entries(e).map((([e,t])=>Array.isArray(t)?{left:t[0],right:t[1]}:{left:{type:"Identifier",name:e},right:t})))))}catch(e){console.info(e)}}),[e,o]),i().createElement("div",null,i().createElement(a.ObjectArrayEditor,(b=((e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e})({},n((e=>e),{equation:"x = 1",variable:"x"})),C={properties:e.map(((e,n)=>({equation:i().createElement(a.ExpressionEditor,{value:e.equation,setValue:t(((e,t)=>e[n].equation=t)),height:20,width:400,autoHeight:!0}),variable:i().createElement(a.StringEditor,{style:{width:"30px"},value:e.variable,setValue:t(((e,t)=>e[n].variable=t))})})))},l(b,c(C)))),i().createElement("label",null,i().createElement("input",{type:"checkbox",checked:o,onChange:()=>s(!o)}),"math style expression"),i().createElement("label",null,i().createElement("input",{type:"checkbox",checked:m,onChange:()=>y(!m)}),"keep binary expression order"),i().createElement("label",null,i().createElement("input",{type:"checkbox",checked:v,onChange:()=>x(!v)}),"show text"),h.map(((e,t)=>i().createElement("div",{key:t,style:{borderBottom:"1px solid black",display:"flex",flexDirection:"column"}},e.map(((e,t)=>i().createElement(i().Fragment,{key:t},!v&&(0,a.renderEquation)(a.reactSvgRenderTarget,e,{keepBinaryExpressionOrder:m}),v&&i().createElement("div",null,i().createElement("code",null,(0,a.printEquation)(e,{keepBinaryExpressionOrder:m}))))))))),o&&h.map(((e,t)=>i().createElement("div",{key:t,style:{borderBottom:"1px solid black",display:"flex",flexDirection:"column"}},e.map(((e,t)=>i().createElement("div",{key:t},i().createElement("code",null,(0,a.printMathStyleExpression)(e.left)," = ",(0,a.printMathStyleExpression)(e.right)))))))));var b,C}},8673:(e,t,n)=>{"use strict";n.d(t,{default:()=>h});var r=n(3696),o=n.n(r),i=n(9758),a=n(3031),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const h=()=>{const{value:e,update:t,getArrayProps:n}=(0,i.useJsonEditorData)(["sin(x)"]),[r,s]=o().useState(),[h,g]=o().useState(0),[m,y]=o().useState(10),[v,x]=o().useState(!0),[b,C]=o().useState(),E=(0,i.useWindowSize)().width/2,P=i.reactSvgRenderTarget,[k,w]=o().useState(),_=e=>(0,a.parseExpression)((0,a.tokenizeExpression)(v?(0,i.mathStyleExpressionToExpression)(e):e));let S;return k&&(S=k.children,r&&(S=[...k.children,...(0,i.renderChartTooltip)(P,r,r.value)])),o().createElement("div",{style:{position:"absolute",inset:"0px"}},k&&S&&o().createElement("div",null,P.renderResult(S,E,300,{attributes:{onMouseMove:e=>s(k.select({x:e.clientX,y:e.clientY}))}})),o().createElement("div",{style:{margin:"10px"}},o().createElement(i.ArrayEditor,(R=((e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e})({},n((e=>e),"")),A={inline:!0,style:{width:"calc(50% - 30px)"},items:e.map(((e,n)=>o().createElement(i.StringEditor,{style:{height:"50px"},textarea:!0,value:e,setValue:t(((e,t)=>e[n]=t))})))},l(R,c(A)))),o().createElement("div",null,o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:v,onChange:()=>x(!v)}),"input math style expression")),o().createElement("div",null,o().createElement(i.NumberEditor,{style:{width:"50px"},value:h,setValue:g}),"~",o().createElement(i.NumberEditor,{style:{width:"50px"},value:m,setValue:y})),o().createElement(i.Button,{disabled:0===e.length,onClick:()=>{try{if(0===e.length)return;const t=[],n=(m-h)/100;for(const r of e){if(!r)continue;const e=[],o=_(r);for(let t=h;t<=m;t+=n){const n=(0,a.evaluateExpression)(o,{sin:Math.sin,cos:Math.cos,tan:Math.tan,x:t});"number"!=typeof n||isNaN(n)||e.push({x:t,y:n})}e.length>0&&t.push(e)}const r=(0,i.getLineChart)([[{x:h,y:0},{x:m,y:0}],...t],P,{x:.01,y:.01},{width:E,height:300},{left:25,right:25,top:10,bottom:20},{xLabelDisabled:!0,yLabelDisabled:!0});if(!r)return;const{points:[o,...s],children:l,select:c}=r;l.push(P.renderPolyline(o,{strokeColor:65280}));for(const e of s)l.push(P.renderPolyline(e,{strokeColor:16711680}));w({children:l,select:c}),C(void 0)}catch(e){console.info(e),C(String(e))}}},"draw chart"),b&&o().createElement("div",null,b)));var R,A}},6808:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(5358);const s=()=>{const[e,t]=o().useState("1 + 2 - 3");return o().createElement(i.ExpressionEditor,{suggestionSources:a.math,value:e,setValue:t,validate:i.validateExpression})}},2458:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(3031);const s=()=>{const[e,t]=o().useState("(x + a)^3"),[n,r]=o().useState("x"),[s,l]=o().useState(""),[c,u]=o().useState(!0),[d,p]=o().useState(!0),[f,h]=o().useState(),[g,m]=o().useState(),[y,v]=o().useState(),x=e=>(0,a.parseExpression)((0,a.tokenizeExpression)(c?(0,i.mathStyleExpressionToExpression)(e):e)),b=e=>d?(0,i.printMathStyleExpression)(e):(0,a.printExpression)(e),C=t=>{try{if(!n)return;if(!e)return;const r=x(e),o=(0,i.taylorExpandExpressionWith)(r,n,+s||5,t);v(o),h(void 0)}catch(e){h(String(e)),v(void 0)}},E=e=>{t(e),h(void 0),m(void 0),v(void 0)};return o().createElement("div",null,o().createElement(i.StringEditor,{style:{width:"calc(100% - 30px)",height:"150px"},textarea:!0,value:e,setValue:E}),o().createElement("div",null,o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:c,onChange:()=>u(!c)}),"input math style expression"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:d,onChange:()=>p(!d)}),"output math style expression")),o().createElement("div",null,o().createElement(i.StringEditor,{style:{width:"50px"},value:n,setValue:r}),"=",o().createElement(i.StringEditor,{style:{width:"calc(100% - 115px)"},value:s,setValue:l})),o().createElement(i.Button,{disabled:!e,onClick:()=>{try{if(!e)return;const t=(0,i.expandExpression)(x(e));let n=(0,i.expressionToFactors)(t);n?(n=(0,i.optimizeFactors)(n),(0,i.sortFactors)(n),m(n),v(void 0)):(v(t),m(void 0)),h(void 0)}catch(e){console.info(e),h(String(e)),m(void 0),v(void 0)}}},"expand all"),o().createElement(i.Button,{disabled:!n||!g,onClick:()=>{try{if(!n)return;if(!g)return;const e=x(n),t=(0,i.expressionToFactors)(e);if(t){const e=(0,i.divideFactors)(g,t);e&&m(e)}h(void 0)}catch(e){h(String(e))}}},"divide by"),o().createElement(i.Button,{disabled:!n||!g,onClick:()=>{try{if(!n)return;if(!g)return;const e=x(n),t=(0,i.expressionToFactors)(e);if(t&&1===t.length){const e=(0,i.groupFactorsBy)(g,t[0]);e&&v(e)}h(void 0)}catch(e){h(String(e))}}},"group by"),o().createElement(i.Button,{disabled:!e||!n||!s,onClick:()=>{try{if(!n)return;if(!s)return;if(!e)return;const t=x(e),r=x(s),o=(0,i.composeExpression)(t,{[n]:r});o&&v(o),h(void 0)}catch(e){h(String(e))}}},"replace with"),o().createElement(i.Button,{disabled:!e,onClick:()=>{try{if(!e)return;const t=x(e);v(t),h(void 0)}catch(e){h(String(e)),v(void 0)}}},"format style"),o().createElement(i.Button,{disabled:!g,onClick:()=>{g&&v((0,i.groupAllFactors)(g))}},"group all"),o().createElement(i.Button,{disabled:!e||!n,onClick:()=>{try{if(!n)return;if(!e)return;const t=x(e),r=(0,i.optimizeExpression)((0,i.deriveExpressionWith)(t,n),(e=>(0,i.expressionHasVariable)(e,n)));v(r),h(void 0)}catch(e){h(String(e)),v(void 0)}}},"derive with"),o().createElement(i.Button,{disabled:!e,onClick:()=>{try{if(!e)return;const t=x(e),n=(0,i.optimizeExpression)(t);v(n),h(void 0)}catch(e){h(String(e)),v(void 0)}}},"optimize"),o().createElement(i.Button,{disabled:!n||!g,onClick:()=>{try{if(!n)return;if(!g)return;const e=x(n),t=(0,i.expressionToFactors)(e);if(t&&1===t.length){const e=(0,i.groupFactorsByVariables)(g,t[0].variables.filter((e=>"string"==typeof e)));e&&v(e)}h(void 0)}catch(e){h(String(e))}}},"group by variables"),o().createElement(i.Button,{disabled:!e||!n,onClick:()=>C(!1)},"taylor expand"),o().createElement(i.Button,{disabled:!e||!n,onClick:()=>C(!0)},"primary function"),g&&g.length>0&&o().createElement("div",{style:{border:"1px solid black",maxHeight:"150px",overflowY:"auto",marginBottom:"5px"}},g.map(((e,t)=>o().createElement("div",{key:t},o().createElement("code",null,b((0,i.factorToExpression)(e))))))),g&&o().createElement("div",{style:{border:"1px solid black",maxHeight:"150px",overflowY:"auto",marginBottom:"5px",position:"relative"}},o().createElement("code",null,b((0,i.factorsToExpression)(g))),o().createElement(i.Button,{style:{position:"absolute",right:0,top:0,background:"wheat"},onClick:()=>navigator.clipboard.writeText(b((0,i.factorsToExpression)(g)))},"copy"),o().createElement(i.Button,{style:{position:"absolute",right:65,top:0,background:"wheat"},onClick:()=>E(b((0,i.factorsToExpression)(g)))},"edit")),y&&o().createElement("div",{style:{border:"1px solid black",maxHeight:"150px",overflowY:"auto",position:"relative"}},o().createElement("code",null,b(y)),o().createElement(i.Button,{style:{position:"absolute",right:0,top:0,background:"wheat"},onClick:()=>navigator.clipboard.writeText(b(y))},"copy"),o().createElement(i.Button,{style:{position:"absolute",right:65,top:0,background:"wheat"},onClick:()=>E(b(y))},"edit")),y&&(0,i.renderExpression)(i.reactSvgRenderTarget,y),f&&o().createElement("div",null,f))}},5358:(e,t,n)=>{"use strict";n.d(t,{math:()=>r});const r=[{name:"Math",members:[{name:"E",comment:"The mathematical constant e. This is Euler's number, the base of natural logarithms."},{name:"LN10",comment:"The natural logarithm of 10."},{name:"LN2",comment:"The natural logarithm of 2."},{name:"LOG2E",comment:"The base-2 logarithm of e."},{name:"LOG10E",comment:"The base-10 logarithm of e."},{name:"PI",comment:"Pi. This is the ratio of the circumference of a circle to its diameter."},{name:"SQRT1_2",comment:"The square root of 0.5, or, equivalently, one divided by the square root of 2."},{name:"SQRT2",comment:"The square root of 2."},{name:"abs",comment:"Returns the absolute value of a number (the value without regard to whether it is positive or negative).\r\nFor example, the absolute value of -5 is the same as the absolute value of 5.",parameters:[{name:"x",comment:"A numeric expression for which the absolute value is needed.",optional:!1}]},{name:"acos",comment:"Returns the arc cosine (or inverse cosine) of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"asin",comment:"Returns the arcsine of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"atan",comment:"Returns the arctangent of a number.",parameters:[{name:"x",comment:"A numeric expression for which the arctangent is needed.",optional:!1}]},{name:"atan2",comment:"Returns the angle (in radians) from the X axis to a point.",parameters:[{name:"y",comment:"A numeric expression representing the cartesian y-coordinate.",optional:!1},{name:"x",comment:"A numeric expression representing the cartesian x-coordinate.",optional:!1}]},{name:"ceil",comment:"Returns the smallest integer greater than or equal to its numeric argument.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"cos",comment:"Returns the cosine of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"exp",comment:"Returns e (the base of natural logarithms) raised to a power.",parameters:[{name:"x",comment:"A numeric expression representing the power of e.",optional:!1}]},{name:"floor",comment:"Returns the greatest integer less than or equal to its numeric argument.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"log",comment:"Returns the natural logarithm (base e) of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"max",comment:"Returns the larger of a set of supplied numeric expressions.",parameters:[{name:"values",comment:"Numeric expressions to be evaluated.",optional:!1}]},{name:"min",comment:"Returns the smaller of a set of supplied numeric expressions.",parameters:[{name:"values",comment:"Numeric expressions to be evaluated.",optional:!1}]},{name:"pow",comment:"Returns the value of a base expression taken to a specified power.",parameters:[{name:"x",comment:"The base value of the expression.",optional:!1},{name:"y",comment:"The exponent value of the expression.",optional:!1}]},{name:"random",comment:"Returns a pseudorandom number between 0 and 1.",parameters:[]},{name:"round",comment:"Returns a supplied numeric expression rounded to the nearest integer.",parameters:[{name:"x",comment:"The value to be rounded to the nearest integer.",optional:!1}]},{name:"sin",comment:"Returns the sine of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"sqrt",comment:"Returns the square root of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"tan",comment:"Returns the tangent of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"clz32",comment:"Returns the number of leading zero bits in the 32-bit binary representation of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"imul",comment:"Returns the result of 32-bit multiplication of two numbers.",parameters:[{name:"x",comment:"First number",optional:!1},{name:"y",comment:"Second number",optional:!1}]},{name:"sign",comment:"Returns the sign of the x, indicating whether x is positive, negative or zero.",parameters:[{name:"x",comment:"The numeric expression to test",optional:!1}]},{name:"log10",comment:"Returns the base 10 logarithm of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"log2",comment:"Returns the base 2 logarithm of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"log1p",comment:"Returns the natural logarithm of 1 + x.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"expm1",comment:"Returns the result of (e^x - 1), which is an implementation-dependent approximation to\r\nsubtracting 1 from the exponential function of x (e raised to the power of x, where e\r\nis the base of the natural logarithms).",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"cosh",comment:"Returns the hyperbolic cosine of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"sinh",comment:"Returns the hyperbolic sine of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"tanh",comment:"Returns the hyperbolic tangent of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"acosh",comment:"Returns the inverse hyperbolic cosine of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"asinh",comment:"Returns the inverse hyperbolic sine of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"atanh",comment:"Returns the inverse hyperbolic tangent of a number.",parameters:[{name:"x",comment:"A numeric expression that contains an angle measured in radians.",optional:!1}]},{name:"hypot",comment:"Returns the square root of the sum of squares of its arguments.",parameters:[{name:"values",comment:"Values to compute the square root for.\r\nIf no arguments are passed, the result is +0.\r\nIf there is only one argument, the result is the absolute value.\r\nIf any argument is +Infinity or -Infinity, the result is +Infinity.\r\nIf any argument is NaN, the result is NaN.\r\nIf all arguments are either +0 or −0, the result is +0.",optional:!1}]},{name:"trunc",comment:"Returns the integral part of the a numeric expression, x, removing any fractional digits.\r\nIf x is already an integer, the result is x.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"fround",comment:"Returns the nearest single precision float representation of a number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]},{name:"cbrt",comment:"Returns an implementation-dependent approximation to the cube root of number.",parameters:[{name:"x",comment:"A numeric expression.",optional:!1}]}]}]},8859:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState((()=>new Array(3).fill(0).map((()=>({children:new Array(20).fill(0).map((()=>({radius:5+Math.round(20*Math.random()),color:Math.round(16777215*Math.random())}))),blockStart:5,blockEnd:5}))))),[n,o]=i().useState("left"),[s,l]=i().useState("top"),{renderEditor:c,layoutResult:u,lineHeights:d,isSelected:p,actualHeight:f,inputContent:h,inputInline:g,getCopiedContents:m}=(0,a.useFlowLayoutBlockEditor)({state:e,setState:n=>t((0,r.produce)(e,n)),width:400,height:400,lineHeight:e=>2*e.radius,getWidth:e=>2*e.radius,endContent:{radius:0,color:0},isNewLineContent:e=>0===e.radius,align:n,verticalAlign:s,processInput(e){if((0,a.metaKeyIfMacElseCtrlKey)(e)){if("v"===e.key)return navigator.clipboard.readText().then((e=>{if(e){const t=JSON.parse(e);1===t.length?g(t[0].children):h(t)}})),e.preventDefault(),!0;if("c"===e.key||"x"===e.key){const t=m("x"===e.key);return t&&navigator.clipboard.writeText(JSON.stringify(t)),!0}}return!1}}),y=a.reactCanvasRenderTarget,v=[];u.forEach(((e,t)=>{e.forEach((({x:e,y:n,content:r,visible:o,row:i},a)=>{o&&(p([t,a])&&v.push(y.renderRect(e,n,2*r.radius,d[i],{fillColor:11785981,strokeWidth:0})),v.push(y.renderCircle(e+r.radius,n+d[i]/2,r.radius,{fillColor:r.color,strokeWidth:0})))}))}));const x=y.renderResult(v,400,f);return i().createElement(i().Fragment,null,c(x),i().createElement(a.EnumEditor,{enums:a.aligns,value:n,setValue:o}),i().createElement(a.EnumEditor,{enums:a.verticalAligns,value:s,setValue:l}))}},3823:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState((()=>new Array(30).fill(0).map((()=>({radius:5+Math.round(20*Math.random()),color:Math.round(16777215*Math.random())}))))),[n,o]=i().useState("left"),[s,l]=i().useState("top"),{renderEditor:c,layoutResult:u,lineHeights:d,isSelected:p,actualHeight:f,inputContent:h,getCopiedContents:g}=(0,a.useFlowLayoutEditor)({state:e,setState:n=>t((0,r.produce)(e,n)),width:400,height:200,lineHeight:e=>2*e.radius,getWidth:e=>2*e.radius,endContent:{radius:0,color:0},isNewLineContent:e=>0===e.radius,align:n,verticalAlign:s,processInput(e){if("Enter"===e.key)return h([{radius:0,color:0}]),!0;if((0,a.metaKeyIfMacElseCtrlKey)(e)){if("v"===e.key)return navigator.clipboard.readText().then((e=>{e&&h(JSON.parse(e))})),e.preventDefault(),!0;if("c"===e.key||"x"===e.key){const t=g("x"===e.key);return t&&navigator.clipboard.writeText(JSON.stringify(t)),!0}}return!1}}),m=a.reactCanvasRenderTarget,y=[];for(const{x:e,y:t,i:n,content:r,visible:o,row:i}of u)o&&(p(n)&&y.push(m.renderRect(e,t,2*r.radius,d[i],{fillColor:11785981,strokeWidth:0})),y.push(m.renderCircle(e+r.radius,t+d[i]/2,r.radius,{fillColor:r.color,strokeWidth:0})));const v=m.renderResult(y,400,f);return i().createElement(i().Fragment,null,c(v),i().createElement(a.EnumEditor,{enums:a.aligns,value:n,setValue:o}),i().createElement(a.EnumEditor,{enums:a.verticalAligns,value:s,setValue:l}))}},1805:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState((()=>"1 + 2 = 3".split(""))),[n,o]=i().useState("left"),[s,l]=i().useState("top"),{renderEditor:c,layoutResult:u}=(0,a.useFlowLayoutTextEditor)({state:e,setState:n=>t((0,r.produce)(e,n)),width:400,height:200,fontSize:20,fontFamily:"monospace",lineHeight:24,align:n,verticalAlign:s});return i().createElement(i().Fragment,null,c({target:a.reactCanvasRenderTarget,getTextColors:e=>{if(["+","-","*","/","="].includes(u[e].content))return{color:255}}}),i().createElement(a.EnumEditor,{enums:a.aligns,value:n,setValue:o}),i().createElement(a.EnumEditor,{enums:a.verticalAligns,value:s,setValue:l}))}},601:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{image:n,onClick:o,onMove:s,input:l,reset:c}=(0,a.useImageClickCreate)(!0,(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()})),i().createElement("div",{style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY})},[...e,n].map(((e,t)=>e&&i().createElement("image",{key:t,href:e.url,x:e.x,y:e.y,width:e.width,height:e.height})))),l)}},250:(e,t,n)=>{"use strict";n.d(t,{stories:()=>de});var r=n(8995),o=n(7474),i=n(8576),a=n(3388),s=n(2268),l=n(2197),c=n(6844),u=n(2960),d=n(9857),p=n(3464),f=n(7215),h=n(4874),g=n(3191),m=n(9612),y=n(2071),v=n(7258),x=n(2682),b=n(1783),C=n(5090),E=n(6690),P=n(8673),k=n(6808),w=n(2458),_=n(8859),S=n(3823),R=n(1805),A=n(601),T=n(3613),M=n(4565),L=n(4855),I=n(7265),O=n(2754),B=n(8208),F=n(6821),D=n(425),z=n(6856),U=n(5047),N=n(5836),G=n(5207),j=n(5779),V=n(2890),W=n(1993),H=n(7631),q=n(277),$=n(574),Y=n(597),K=n(4623),X=n(4922),Z=n(5982),Q=n(7560),J=n(4339),ee=n(94),te=n(8751),ne=n(9967),re=n(5503),oe=n(8119),ie=n(8337),ae=n(1459),se=n(432),le=n(5301),ce=n(7507),ue=n(1986);const de=[{path:"attributed-opentype-text-editor.story",name:"",Component:r.default,code:"() => {\n type Attribute = Partial<{ color: number, fontSize: number, backgroundColor: number, underline: boolean, passThrough: boolean, script?: 'sub' | 'sup', circle?: boolean, stackText?: string, bold?: boolean, italic?: boolean, opacity?: number }>\n const size = useWindowSize()\n const width = size.width / 2 - 30\n const [font, setFont] = React.useState()\n const cache = React.useRef(new MapCache4())\n const getTextLayout = (text: string, fontSize: number, italic = false, bold = false) => {\n if (!font || !text) return\n return cache.current.get(italic, bold, fontSize, text, () => {\n const path = font.getPath(text, 0, fontSize, fontSize, { xScale: fontSize / font.unitsPerEm, yScale: fontSize / font.unitsPerEm })\n const glyph = font.charToGlyph(text)\n const box = glyph.getBoundingBox()\n const advanceWidth = glyph.advanceWidth || 0\n const width = box.x2 - box.x1\n const commands = opentypeCommandsToPathCommands(path, italic ? fontSize * 0.7 : undefined)\n let hatches = geometryLinesToHatches(pathCommandsToGeometryLines(commands))\n if (bold) {\n hatches = hatches.map(h => boldHatch(h, fontSize * 0.01))\n }\n return {\n commands: hatches.map(h => [h.border, ...h.holes]).map(h => h.map(lines => geometryLineToPathCommands(lines)).flat()),\n x1: (advanceWidth > width ? 0 : box.x1) / font.unitsPerEm * fontSize,\n y1: (glyph.unicode && glyph.unicode < 256 ? 0 : box.y1) / font.unitsPerEm * fontSize,\n width: Math.max(advanceWidth, width) / font.unitsPerEm * fontSize,\n }\n })\n }\n const [state, setState] = React.useState[]>([{ insert: '我们出' }, { insert: '去吧', attributes: { stackText: 'ab' } }, { insert: 'Aag jioIb BDxVX晒回吧', attributes: { color: 0xff0000 } }])\n const [align, setAlign] = React.useState('left')\n const [verticalAlign, setVerticalAlign] = React.useState('top')\n const [strokeOnly, setStrokeOnly] = React.useState(false)\n const getColor = (content: AttributedText) => content?.attributes?.color ?? 0x000000\n const getOpacity = (content: AttributedText) => content?.attributes?.opacity ?? 1\n const getFontSize = (content?: AttributedText) => content?.attributes?.fontSize ?? 50\n const getComputedFontSize = (content?: AttributedText) => getFontSize(content) * (content?.attributes?.script || content?.attributes?.stackText ? 0.7 : 1)\n const getBackgroundColor = (content?: AttributedText) => content?.attributes?.backgroundColor ?? 0xffffff\n const getUnderline = (content?: AttributedText) => content?.attributes?.underline ?? false\n const getPassThrough = (content?: AttributedText) => content?.attributes?.passThrough ?? false\n const getBold = (content?: AttributedText) => content?.attributes?.bold ?? false\n const getItalic = (content?: AttributedText) => content?.attributes?.italic ?? false\n const getScript = (content?: AttributedText) => content?.attributes?.script\n const getCircle = (content?: AttributedText) => content?.attributes?.circle ?? false\n const getStackText = (content?: AttributedText) => content?.attributes?.stackText ?? ''\n const getLineHeight = (content: AttributedText) => getComputedFontSize(content) * 1.5\n const getWidth = (content: AttributedText) => {\n const fontSize = getComputedFontSize(content)\n if (content.attributes?.stackText) {\n const width = content.insert.split('').reduce((p, c) => p + (getTextLayout(c, fontSize)?.width ?? 0), 0)\n const stackWidth = content.attributes.stackText.split('').reduce((p, c) => p + (getTextLayout(c, fontSize)?.width ?? 0), 0)\n return Math.max(stackWidth, width)\n }\n return getTextLayout(content.insert, fontSize)?.width ?? 0\n }\n const getComputedWidth = (content: AttributedText) => getCircle(content) ? getLineHeight(content) : getWidth(content)\n const getReadonlyType = (attributes?: Attribute) => attributes?.stackText ? true : undefined\n const { renderEditor, layoutResult, lineHeights, isSelected, actualHeight, cursorContent, setSelectedAttributes } = useAttributedTextEditor({\n state,\n setState,\n width,\n height: 200,\n lineHeight: getLineHeight,\n getWidth: getComputedWidth,\n getReadonlyType,\n align,\n verticalAlign,\n })\n\n React.useEffect(() => {\n const fetchFont = async () => {\n const res = await fetch(allFonts[0].url)\n const buffer = await res.arrayBuffer()\n setFont(opentype.parse(buffer))\n }\n fetchFont()\n }, [])\n\n const target = reactSvgRenderTarget\n const children: ReturnType[] = []\n const commands: PathCommand[][] = []\n for (const { x, y, i, content, visible, row } of layoutResult) {\n if (!visible) continue\n const width = getComputedWidth(content)\n const lineHeight = lineHeights[row]\n const selected = isSelected(i)\n if (selected) {\n children.push(target.renderRect(x, y, width, lineHeight, { fillColor: 0xB3D6FD, strokeWidth: 0 }))\n }\n const fontSize = getComputedFontSize(content)\n const italic = getItalic(content)\n const bold = getBold(content)\n const layout = getTextLayout(content.insert, fontSize, italic, bold)\n if (layout) {\n const color = getColor(content)\n const opacity = getOpacity(content)\n const backgroundColor = getBackgroundColor(content)\n if (!selected && backgroundColor !== 0xffffff) {\n children.push(target.renderRect(x, y, width, lineHeight, { fillColor: backgroundColor, strokeWidth: 0 }))\n }\n if (getUnderline(content)) {\n children.push(target.renderPolyline([{ x, y: y + lineHeight }, { x: x + width, y: y + lineHeight }], { strokeColor: color, strokeOpacity: opacity }))\n }\n if (getPassThrough(content)) {\n children.push(target.renderPolyline([{ x, y: y + lineHeight / 2 }, { x: x + width, y: y + lineHeight / 2 }], { strokeColor: color, strokeOpacity: opacity }))\n }\n const pos = {\n x: x - layout.x1,\n y: y + layout.y1 + (lineHeight - getLineHeight(content)),\n }\n const script = getScript(content)\n const stackText = getStackText(content)\n if (script === 'sub') {\n pos.y += fontSize * 0.2\n } else if (script === 'sup' || stackText) {\n pos.y -= fontSize * 0.7\n }\n if (stackText) {\n const textWidth = content.insert.split('').reduce((p, c) => p + (getTextLayout(c, fontSize)?.width ?? 0), 0)\n pos.x += (width - textWidth) / 2\n }\n if (getCircle(content)) {\n pos.x += (lineHeight - getWidth(content)) / 2\n children.push(target.renderCircle(x + width / 2, y + lineHeight / 2, lineHeight / 2, { strokeColor: color, strokeOpacity: opacity }))\n }\n const style = strokeOnly ? { strokeColor: color, strokeOpacity: opacity, strokeWidth: 1 } : { fillColor: color, fillOpacity: opacity, strokeWidth: 0 }\n children.push(target.renderGroup(layout.commands.map(c => target.renderPathCommands(c, style)), { translate: pos }))\n if (selected) {\n commands.push(...layout.commands)\n }\n if (stackText) {\n const stackWidth = stackText.split('').reduce((p, c) => p + (getTextLayout(c, fontSize)?.width ?? 0), 0)\n let xOffset = 0\n for (const char of stackText.split('')) {\n const stackLayout = getTextLayout(char, fontSize, italic, bold)\n if (stackLayout) {\n const stackPos = {\n x: x - stackLayout.x1 + (width - stackWidth) / 2 + xOffset,\n y: y + stackLayout.y1 + (lineHeight - getLineHeight(content)) + fontSize * 0.2,\n }\n xOffset += stackLayout.width\n children.push(target.renderGroup(stackLayout.commands.map(c => target.renderPathCommands(c, style)), { translate: stackPos }))\n }\n }\n }\n }\n }\n const result = target.renderResult(children, width, actualHeight)\n return (\n <>\n {renderEditor(result)}\n \n \n setSelectedAttributes({ color: v })} />,\n opacity: setSelectedAttributes({ opacity: v })} />,\n fontSize: setSelectedAttributes({ fontSize: v })} />,\n backgroundColor: setSelectedAttributes({ backgroundColor: v === 0xffffff ? undefined : v })} />,\n underline: setSelectedAttributes({ underline: v ? true : undefined })} />,\n passThrough: setSelectedAttributes({ passThrough: v ? true : undefined })} />,\n bold: setSelectedAttributes({ bold: v ? true : undefined })} />,\n italic: setSelectedAttributes({ italic: v ? true : undefined })} />,\n strokeOnly: setStrokeOnly(v)} />,\n sub: setSelectedAttributes({ script: v ? 'sub' : undefined })} />,\n sup: setSelectedAttributes({ script: v ? 'sup' : undefined })} />,\n circle: setSelectedAttributes({ circle: v ? true : undefined })} />,\n stackText: setSelectedAttributes({ stackText: v ? v : undefined })} />,\n actions: ,\n }}\n />\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"attributed-text-editor.story",name:"",Component:o.default,code:"() => {\n type Attribute = Partial<{ color: number, fontFamily: string, bold: boolean, italic: boolean, readonly?: string }>\n const [state, setState] = React.useState[]>([{ insert: 'abc' }, { insert: '123', attributes: { color: 0xff0000, readonly: '1' } }, { insert: 'edf', attributes: { readonly: '1' } }, { insert: 'ghi', attributes: { color: 0x00ff00 } }])\n const [align, setAlign] = React.useState('left')\n const [verticalAlign, setVerticalAlign] = React.useState('top')\n const fontSize = 20\n const getFontFamily = (content?: AttributedText) => content?.attributes?.fontFamily ?? 'monospace'\n const getColor = (content?: AttributedText) => content?.attributes?.color ?? 0x000000\n const getBold = (content?: AttributedText) => content?.attributes?.bold ?? false\n const getItalic = (content?: AttributedText) => content?.attributes?.italic ?? false\n const width = 400\n const lineHeight = fontSize * 1.2\n const getWidth = (content: AttributedText) => getTextSizeFromCache(`${getBold(content) ? 'bold ' : ''}${getItalic(content) ? 'italic ' : ''}${fontSize}px ${getFontFamily(content)}`, content.insert)?.width ?? 0\n const { renderEditor, layoutResult, isSelected, actualHeight, cursorContent, setSelectedAttributes } = useAttributedTextEditor({\n state,\n setState,\n width,\n height: 200,\n lineHeight,\n getWidth,\n align,\n verticalAlign,\n getReadonlyType: attributes => attributes?.readonly,\n })\n const children: CanvasDraw[] = []\n const target = reactCanvasRenderTarget\n for (const { x, y, i, content, visible } of layoutResult) {\n if (!visible) continue\n const textWidth = getWidth(content)\n if (isSelected(i)) {\n children.push(target.renderRect(x, y, textWidth, lineHeight, { fillColor: 0xB3D6FD, strokeWidth: 0 }))\n }\n children.push(target.renderText(x + textWidth / 2, y + fontSize, content.insert, getColor(content), fontSize, getFontFamily(content), {\n textAlign: 'center',\n fontWeight: getBold(content) ? 'bold' : undefined,\n fontStyle: getItalic(content) ? 'italic' : undefined,\n }))\n }\n const result = target.renderResult(children, width, actualHeight)\n return (\n <>\n {renderEditor(result)}\n \n \n setSelectedAttributes({ color: v })} />,\n fontFamily: setSelectedAttributes({ fontFamily: v })} />,\n bold: setSelectedAttributes({ bold: v ? true : undefined })} />,\n italic: setSelectedAttributes({ italic: v ? true : undefined })} />,\n }}\n />\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"audio-record.story",name:"",Component:i.default,code:"() => {\n const { start, stop, duration, volume, audioUrl, recording } = useAudioRecorder()\n const { play, pause, playing, currentTime, audio, duration: audioDuration } = useAudioPlayer(audioUrl)\n return (\n
\n {!recording ? : null}\n {recording ? : null}\n {recording && volume !== undefined ? : null}\n {audioUrl && (\n <>\n \n {currentTime}/{audioDuration}\n {audio}\n \n )}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"bar-chart-3d.story",name:"",Component:a.default,code:"() => {\n const ref = React.useRef(null)\n const renderer = React.useRef>()\n const { x, y, ref: wheelScrollRef } = useWheelScroll()\n const { scale, ref: wheelZoomRef } = useWheelZoom()\n const [rotate, setRotate] = React.useState({ x: 0, y: 0 })\n const { offset, onStart: onStartMoveCanvas, mask: moveCanvasMask, resetDragMove } = useDragMove(() => {\n setRotate((v) => ({ x: v.x + offset.x, y: v.y + offset.y }))\n })\n const size = useWindowSize()\n const width = size.width / 2\n const height = size.height\n const [hovering, setHovering] = React.useState()\n const rotateX = offset.x + rotate.x\n const rotateY = offset.y + rotate.y\n const graphics = React.useRef<(Graphic3d)[]>([])\n const getXLabel = (x: number) => Intl.DateTimeFormat('zh', { month: 'long' }).format(new Date(x.toString()))\n\n React.useEffect(() => {\n if (!ref.current) return\n renderer.current = createWebgl3DRenderer(ref.current)\n }, [ref.current])\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragMove()\n }\n })\n\n React.useEffect(() => {\n const points1 = [65, 59, 80, 81, 56, 55, 40].map((s, i) => [(i + 1) * 20, s, 0] as Vec3)\n const points2 = [55, 49, 70, 71, 46, 45, 30].map((s, i) => [(i + 1) * 20, s, 20] as Vec3)\n const points3 = [45, 39, 60, 61, 36, 35, 20].map((s, i) => [(i + 1) * 20, s, 40] as Vec3)\n const points4 = [75, 69, 90, 91, 66, 65, 50].map((s, i) => [(i + 1) * 20, s, -20] as Vec3)\n const axis = getChartAxis3D([points1, points2, points3, points4], { x: 20, y: 10, z: 20 })\n graphics.current.push(\n ...axis,\n ...points1.map(p => ({ geometry: { type: 'cylinder' as const, radius: 3, height: p[1] }, color: [1, 0, 0, 1] as Vec4, position: [p[0], p[1] / 2, p[2]] as Vec3 })),\n ...points2.map(p => ({ geometry: { type: 'cylinder' as const, radius: 3, height: p[1] }, color: [0, 1, 0, 1] as Vec4, position: [p[0], p[1] / 2, p[2]] as Vec3 })),\n ...points3.map(p => ({ geometry: { type: 'cylinder' as const, radius: 3, height: p[1] }, color: [0, 0, 1, 1] as Vec4, position: [p[0], p[1] / 2, p[2]] as Vec3 })),\n ...points4.map(p => ({ geometry: { type: 'cylinder' as const, radius: 3, height: p[1] }, color: [0, 0, 0, 1] as Vec4, position: [p[0], p[1] / 2, p[2]] as Vec3 })),\n )\n }, [])\n\n React.useEffect(() => {\n const { position, up } = updateCamera(-x, y, 200 / scale, -0.3 * rotateX, -0.3 * rotateY)\n renderer.current?.render?.(\n graphics.current,\n {\n eye: [position.x + 40, position.y + 40, position.z],\n up: [up.x, up.y, up.z],\n target: [-x + 40, y + 40, 0],\n fov: angleToRadian(60),\n near: 0.1,\n far: 2000,\n },\n {\n position: [1000, 1000, 1000],\n color: [1, 1, 1, 1],\n specular: [1, 1, 1, 1],\n shininess: 50,\n specularFactor: 1,\n },\n [1, 1, 1, 1],\n )\n }, [x, y, scale, rotateX, rotateY, hovering, width, height])\n\n return (\n
\n onStartMoveCanvas({ x: e.clientX, y: e.clientY })}\n onMouseMove={e => {\n setHovering(undefined)\n const index = renderer.current?.pick?.(e.clientX, e.clientY, (g) => g.geometry.type === 'cylinder')\n if (index !== undefined) {\n const graphic = graphics.current[index]\n if (graphic.position) {\n setHovering({ value: graphic.position, x: e.clientX, y: e.clientY })\n }\n }\n }}\n />\n {hovering && }\n {moveCanvasMask}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"bar-chart.story",name:"",Component:s.default,code:"() => {\n const size = useWindowSize()\n const width = size.width / 2\n const height = 500\n const target = reactSvgRenderTarget\n const [hovering, setHovering] = React.useState()\n const [result, setResult] = React.useState<{ children: SvgDraw[], select: (p: Position) => Position & { value: { x: number, y: number | number[] } } | undefined }>()\n const getXLabel = (x: number) => Intl.DateTimeFormat('zh', { month: 'long' }).format(new Date((x + 1).toString()))\n\n React.useEffect(() => {\n const datas = [\n [65, 59, 80, 81, 56, 55, 40].map(x => [x]),\n [55, 49, 70, 71, 46, 45, 30].map(x => [x]),\n [45, 39, 60, 61, 36, 35, 30].map(x => [x - 20, x]),\n [65, 59, 80, 81, 56, 55, 40].map(x => [x - 30, x - 15, x - 5, x]),\n ]\n const data1 = [35, 29, 50, 51, 26, 25, 10].map((s, i) => ({ x: i, y: s }))\n const colors = [[0xff0000], [0x00ff00], [0x0000ff], [0xff0000, 0x00ff00, 0x0000ff]]\n const { children, select, tx, ty } = getBarChart(datas, colors, (region, color) => target.renderPolygon(getRoundedRectPoints(region, 5, 30), { fillColor: color, strokeWidth: 0 }), target, { y: 5 }, { width, height }, { left: 25, right: 10, top: 10, bottom: 20 }, {\n getXLabel,\n bounding: getPointsBounding(data1)\n })\n\n const points1 = data1.map(c => ({ x: tx(c.x + 0.5), y: ty(c.y) }))\n children.push(target.renderPolyline(points1, { strokeColor: 0x000000 }))\n children.push(...points1.map(c => target.renderCircle(c.x, c.y, 3, { fillColor: 0x000000, strokeWidth: 0 })))\n\n setResult({\n children,\n select: (p) => {\n const j = points1.findIndex(n => getTwoPointsDistance(n, p) <= 5)\n if (j >= 0) {\n return { ...points1[j], value: data1[j] }\n }\n return select(p)\n }\n })\n }, [width])\n\n if (!result) {\n return null\n }\n let children = result.children\n if (hovering) {\n children = [\n ...result.children,\n ...renderChartTooltip(target, hovering, hovering.value, { getXLabel }),\n ]\n }\n return (\n
\n {target.renderResult(children, width, height, { attributes: { onMouseMove: e => setHovering(result.select({ x: e.clientX, y: e.clientY })) } })}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"circle-arc-click-create.story",name:"",Component:l.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { circle, arc, onClick, onMove, input, reset } = useCircleArcClickCreate('center radius', (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n const arcCircle = circle || arc\n return (\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n style={{ height: '100%' }}\n >\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {arcCircle && }\n {[...contents, arc].map((content, i) => {\n if (content) {\n const start = polarToCartesian(content.x, content.y, content.r, content.endAngle)\n const end = polarToCartesian(content.x, content.y, content.r, content.startAngle)\n return (\n \n )\n }\n return null\n })}\n \n {input}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"circle-arc-edit.story",name:"",Component:c.default,code:"() => {\n const [content, setContent] = React.useState({ x: 200, y: 200, r: 100, startAngle: -30, endAngle: 120 })\n const { offset, onStart, mask, reset } = useCircleArcEdit(() => setContent(circleArc))\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n const circleArc = produce(content, (draft) => {\n if (offset) {\n draft.x += offset.x\n draft.y += offset.y\n draft.r += offset.r\n draft.startAngle += offset.startAngle\n draft.endAngle += offset.endAngle\n normalizeAngleRange(draft)\n }\n })\n const start = polarToCartesian(circleArc.x, circleArc.y, circleArc.r, circleArc.endAngle)\n const end = polarToCartesian(circleArc.x, circleArc.y, circleArc.r, circleArc.startAngle)\n return (\n <>\n \n \n \n onStart(e, { ...circleArc, type, cursor })}\n />\n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"circle-click-create.story",name:"",Component:u.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { circle, onClick, onMove, input, reset } = useCircleClickCreate('center radius', (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n\n return (\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n style={{ height: '100%' }}\n >\n {[...contents, circle].map((content, i) => content && (\n \n \n ))}\n {input}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"circle-edit.story",name:"",Component:d.default,code:"() => {\n const [content, setContent] = React.useState({ x: 300, y: 200, r: 100 })\n const { offset, onStart, mask, reset } = useCircleEdit(() => setContent(circle))\n const circle = produce(content, (draft) => {\n draft.x += offset.x\n draft.y += offset.y\n draft.r += offset.r\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n return (\n <>\n \n \n onStart(e, { ...content, type, cursor })}\n />\n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"drag-move.story",name:"",Component:p.default,code:"() => {\n const [x, setX] = React.useState(0)\n const [y, setY] = React.useState(0)\n const { offset, onStart, mask, resetDragMove } = useDragMove(() => {\n setX((v) => v + offset.x)\n setY((v) => v + offset.y)\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragMove()\n }\n })\n\n return (\n \n onStart({ x: e.clientX, y: e.clientY })}\n >\n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"drag-resize.story",name:"",Component:f.default,code:"() => {\n const [content, setContent] = React.useState({\n x: 200,\n y: 200,\n width: 100,\n height: 100,\n })\n const { offset, onStart, mask, resetDragResize } = useDragResize(\n () => setContent(previewContent),\n {\n centeredScaling: (e) => e.shiftKey,\n keepRatio: (e) => metaKeyIfMacElseCtrlKey(e) ? content.width / content.height : undefined,\n },\n )\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragResize()\n }\n })\n const previewContent = produce(content, (draft) => {\n draft.width += offset.width\n draft.height += offset.height\n draft.x += offset.x\n draft.y += offset.y\n })\n\n return (\n <>\n \n \n \n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"drag-rotate.story",name:"",Component:h.default,code:"() => {\n const [content, setContent] = React.useState({\n x: 200,\n y: 200,\n width: 100,\n height: 100,\n rotate: 0,\n url: 'https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg',\n })\n const { offset, onStart, mask, resetDragRotate } = useDragRotate(\n () => setContent(previewContent),\n {\n transformOffset: (r, e) => {\n if (e && r !== undefined && !e.shiftKey) {\n const snap = Math.round(r / 45) * 45\n if (Math.abs(snap - r) < 5) {\n r = snap\n }\n }\n return r\n },\n }\n )\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragRotate()\n }\n })\n const previewContent = produce(content, (draft) => {\n if (offset?.angle !== undefined) {\n draft.rotate = offset.angle\n }\n })\n\n return (\n <>\n \n onStart({ x: content.x + content.width / 2, y: content.y + content.height / 2 })} />\n \n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"drag-select.story",name:"",Component:g.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { onStartSelect, dragSelectMask, resetDragSelect } = useDragSelect((dragSelectStartPosition, dragSelectEndPosition) => {\n if (dragSelectEndPosition) {\n setContents(produce(contents, (draft) => {\n draft.push({\n x: Math.min(dragSelectStartPosition.x, dragSelectEndPosition.x),\n y: Math.min(dragSelectStartPosition.y, dragSelectEndPosition.y),\n width: Math.abs(dragSelectEndPosition.x - dragSelectStartPosition.x),\n height: Math.abs(dragSelectEndPosition.y - dragSelectStartPosition.y),\n })\n }))\n }\n }, (e) => e.shiftKey)\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragSelect()\n }\n })\n\n return (\n onStartSelect(e, undefined)}\n style={{ height: '100%' }}\n >\n {contents.map((content, i) => (\n \n \n ))}\n {dragSelectMask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"edit.story",name:"",Component:m.default,code:"() => {\n const [content, setContent] = React.useState({ x: 300, y: 200, r: 100 })\n const { editPoint, updateEditPreview, onEditMove, onEditClick, getEditAssistentContents, resetEdit } = useEdit(\n () => setContent(circle),\n (s) => ({\n editPoints: [\n {\n x: s.x,\n y: s.y,\n cursor: 'move',\n update(c, { cursor, start }) {\n c.x += cursor.x - start.x\n c.y += cursor.y - start.y\n }\n },\n { x: s.x - s.r, y: s.y, cursor: 'ew-resize', update(c, { cursor }) { c.r = getTwoPointsDistance(cursor, c) } },\n { x: s.x, y: s.y - s.r, cursor: 'ns-resize', update(c, { cursor }) { c.r = getTwoPointsDistance(cursor, c) } },\n { x: s.x + s.r, y: s.y, cursor: 'ew-resize', update(c, { cursor }) { c.r = getTwoPointsDistance(cursor, c) } },\n { x: s.x, y: s.y + s.r, cursor: 'ns-resize', update(c, { cursor }) { c.r = getTwoPointsDistance(cursor, c) } },\n ],\n }),\n )\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetEdit()\n }\n })\n const assistentContents: Region[] = []\n const newContent = updateEditPreview()\n const circle = newContent?.result ?? content\n assistentContents.push(...getEditAssistentContents(circle, (rect) => rect))\n\n return (\n <>\n onEditMove({ x: e.clientX, y: e.clientY }, [{ content: circle, path: [0] }])}\n onClick={(e) => editPoint && onEditClick({ x: e.clientX, y: e.clientY })}\n >\n \n {assistentContents.map((s, i) => )}\n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"ellipse-arc-click-create.story",name:"",Component:y.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { ellipse, ellipseArc, onClick, onMove, input, reset } = useEllipseArcClickCreate('ellipse center', (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n const arcEllipse = ellipse || ellipseArc\n return (\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n style={{ height: '100%' }}\n >\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {arcEllipse && }\n {[...contents, ellipseArc].map((content, i) => {\n if (content) {\n const points = ellipseArcToPolyline(content, defaultAngleDelta)\n return `${p.x},${p.y}`).join(' ')}\n stroke='#00ff00'\n />\n }\n return null\n })}\n \n {input}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"ellipse-arc-edit.story",name:"",Component:v.default,code:"() => {\n const [content, setContent] = React.useState({ cx: 200, cy: 200, rx: 100, ry: 150, angle: 45, startAngle: -30, endAngle: 120 })\n const { offset, onStart, mask, reset } = useEllipseArcEdit(() => setContent(ellipseArc))\n const ellipseArc = produce(content, (draft) => {\n if (offset) {\n draft.cx += offset.cx\n draft.cy += offset.cy\n draft.rx += offset.rx\n draft.ry += offset.ry\n draft.startAngle += offset.startAngle\n draft.endAngle += offset.endAngle\n normalizeAngleRange(draft)\n }\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n const points = ellipseArcToPolyline(ellipseArc, defaultAngleDelta)\n return (\n <>\n \n `${p.x},${p.y}`).join(' ')}\n stroke='#00ff00'\n />\n \n onStart(e, { ...ellipseArc, type, cursor })}\n />\n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"ellipse-click-create.story",name:"",Component:x.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { ellipse, onClick, onMove, input, reset } = useEllipseClickCreate('ellipse center', (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n\n return (\n
\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {[...contents, ellipse].map((content, i) => content && )}\n \n {input}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"ellipse-edit.story",name:"",Component:b.default,code:"() => {\n const [content, setContent] = React.useState({ cx: 200, cy: 200, rx: 100, ry: 150, angle: 45 })\n const { offset, onStart, mask, reset } = useEllipseEdit(() => setContent(ellipse))\n const ellipse = produce(content, (draft) => {\n if (offset) {\n draft.cx += offset.cx\n draft.cy += offset.cy\n draft.rx += offset.rx\n draft.ry += offset.ry\n }\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n return (\n <>\n \n \n \n onStart(e, { ...ellipse, type, cursor })}\n />\n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"equation-renderer.story",name:"",Component:C.default,code:"() => {\n const [left, setLeft] = React.useState('X1 ** 2 + X2 * X3')\n const [right, setRight] = React.useState('(-X6) ** 0.5 / (X4 - X5 ** 3)')\n const [equation, setEquation] = React.useState()\n const [keepBinaryExpressionOrder, setKeepBinaryExpressionOrder] = React.useState(false)\n React.useEffect(() => {\n try {\n setEquation({\n left: parseExpression(tokenizeExpression(left)),\n right: parseExpression(tokenizeExpression(right)),\n })\n } catch (error) {\n console.info(error)\n }\n }, [left, right])\n return (\n
\n \n \n \n {equation && renderEquation(reactSvgRenderTarget, equation, { keepBinaryExpressionOrder })}\n {equation && {printEquation(equation, { keepBinaryExpressionOrder })}}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"equation-solver.story",name:"",Component:E.default,code:"() => {\n const { value, update, getArrayProps } = useJsonEditorData([\n { equation: 'a * x + b * y = c', variable: 'x' },\n { equation: 'x ** 2 + y ** 2 = r', variable: 'y' },\n ])\n const [isMath, setIsMath] = React.useState(false)\n const [equations, setEquations] = React.useState([])\n const [keepBinaryExpressionOrder, setKeepBinaryExpressionOrder] = React.useState(false)\n const [showText, setShowText] = React.useState(false)\n React.useEffect(() => {\n try {\n const result = solveEquations(value.map(e => {\n const equation = e.equation.split('=')\n return {\n left: parseExpression(tokenizeExpression(isMath ? mathStyleExpressionToExpression(equation[0]) : equation[0])),\n right: parseExpression(tokenizeExpression(isMath ? mathStyleExpressionToExpression(equation[1]) : equation[1])),\n }\n }), new Set(value.map(e => e.variable)))\n setEquations(result.map(e => Object.entries(e).map(([key, e]) => {\n return !Array.isArray(e) ? { left: { type: 'Identifier', name: key }, right: e } : { left: e[0], right: e[1] }\n })))\n } catch (error) {\n console.info(error)\n }\n }, [value, isMath])\n return (\n
\n v, { equation: 'x = 1', variable: 'x' })}\n properties={value.map((f, i) => ({\n equation: draft[i].equation = v)} height={20} width={400} autoHeight />,\n variable: draft[i].variable = v)} />\n }))}\n />\n \n \n \n {equations.map((a, j) => (\n
\n {a.map((e, i) => (\n \n {!showText && renderEquation(reactSvgRenderTarget, e, { keepBinaryExpressionOrder })}\n {showText &&
{printEquation(e, { keepBinaryExpressionOrder })}
}\n
\n ))}\n
\n ))}\n {isMath && equations.map((a, j) => (\n
\n {a.map((e, i) => (\n
{printMathStyleExpression(e.left)} = {printMathStyleExpression(e.right)}
\n ))}\n
\n ))}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"expression-chart.story",name:"",Component:P.default,code:"() => {\n const { value, update, getArrayProps } = useJsonEditorData(['sin(x)'])\n const [hovering, setHovering] = React.useState()\n const [min, setMin] = React.useState(0)\n const [max, setMax] = React.useState(10)\n const [isMath, setIsMath] = React.useState(true)\n const [error, setError] = React.useState()\n\n const size = useWindowSize()\n const width = size.width / 2\n const height = 300\n const target = reactSvgRenderTarget\n const [result, setResult] = React.useState<{ children: SvgDraw[], select: (p: Position) => Position & { value: Position } | undefined }>()\n const parseInputExpression = (v: string) => parseExpression(tokenizeExpression(isMath ? mathStyleExpressionToExpression(v) : v))\n\n const drawChart = () => {\n try {\n if (value.length === 0) return\n const points: Position[][] = []\n const step = (max - min) / 100\n for (const v of value) {\n if (!v) continue\n const p: Position[] = []\n const e = parseInputExpression(v)\n for (let x = min; x <= max; x += step) {\n const y = evaluateExpression(e, {\n sin: Math.sin,\n cos: Math.cos,\n tan: Math.tan,\n x,\n })\n if (typeof y === 'number' && !isNaN(y)) {\n p.push({ x, y })\n }\n }\n if (p.length > 0) {\n points.push(p)\n }\n }\n const r = getLineChart([[{ x: min, y: 0 }, { x: max, y: 0 }], ...points], target, { x: 0.01, y: 0.01 }, { width, height }, { left: 25, right: 25, top: 10, bottom: 20 }, { xLabelDisabled: true, yLabelDisabled: true })\n if (!r) return\n const { points: [axis, ...p], children, select } = r\n children.push(target.renderPolyline(axis, { strokeColor: 0x00ff00 }))\n for (const f of p) {\n children.push(target.renderPolyline(f, { strokeColor: 0xff0000 }))\n }\n setResult({ children, select })\n setError(undefined)\n } catch (error) {\n console.info(error)\n setError(String(error))\n }\n }\n let children: SvgDraw[] | undefined\n if (result) {\n children = result.children\n if (hovering) {\n children = [\n ...result.children,\n ...renderChartTooltip(target, hovering, hovering.value),\n ]\n }\n }\n return (\n
\n {result && children &&
\n {target.renderResult(children, width, height, { attributes: { onMouseMove: e => setHovering(result.select({ x: e.clientX, y: e.clientY })) } })}\n
}\n
\n v, '')}\n inline\n style={{ width: 'calc(50% - 30px)' }}\n items={value.map((f, i) => draft[i] = v)} />)}\n />\n
\n \n
\n
\n \n ~\n \n
\n \n {error &&
{error}
}\n
\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"expression-editor.story",name:"",Component:k.default,code:"() => {\n const [value, setValue] = React.useState('1 + 2 - 3')\n\n return (\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"expression-expansion.story",name:"",Component:w.default,code:"() => {\n const [value, setValue] = React.useState('(x + a)^3')\n const [secondValue, setSecondValue] = React.useState('x')\n const [thirdValue, setThirdValue] = React.useState('')\n const [isMath, setIsMath] = React.useState(true)\n const [outputMath, setOutputMath] = React.useState(true)\n const [error, setError] = React.useState()\n const [factors, setFactors] = React.useState()\n const [expression, setExpression] = React.useState()\n\n const parseInputExpression = (v: string) => parseExpression(tokenizeExpression(isMath ? mathStyleExpressionToExpression(v) : v))\n const outputExpression = (e: Expression2) => outputMath ? printMathStyleExpression(e) : printExpression(e)\n const expandAll = () => {\n try {\n if (!value) return\n const r = expandExpression(parseInputExpression(value))\n let f = expressionToFactors(r)\n if (f) {\n f = optimizeFactors(f)\n sortFactors(f)\n setFactors(f)\n setExpression(undefined)\n } else {\n setExpression(r)\n setFactors(undefined)\n }\n setError(undefined)\n } catch (error) {\n console.info(error)\n setError(String(error))\n setFactors(undefined)\n setExpression(undefined)\n }\n }\n const divideBy = () => {\n try {\n if (!secondValue) return\n if (!factors) return\n const r = parseInputExpression(secondValue)\n const f = expressionToFactors(r)\n if (f) {\n const g = divideFactors(factors, f)\n if (g) {\n setFactors(g)\n }\n }\n setError(undefined)\n } catch (error) {\n setError(String(error))\n }\n }\n const groupBy = () => {\n try {\n if (!secondValue) return\n if (!factors) return\n const r = parseInputExpression(secondValue)\n const f = expressionToFactors(r)\n if (f && f.length === 1) {\n const g = groupFactorsBy(factors, f[0])\n if (g) {\n setExpression(g)\n }\n }\n setError(undefined)\n } catch (error) {\n setError(String(error))\n }\n }\n const replaceWith = () => {\n try {\n if (!secondValue) return\n if (!thirdValue) return\n if (!value) return\n const r1 = parseInputExpression(value)\n const r3 = parseInputExpression(thirdValue)\n const g = composeExpression(r1, { [secondValue]: r3 })\n if (g) {\n setExpression(g)\n }\n setError(undefined)\n } catch (error) {\n setError(String(error))\n }\n }\n const formatStyle = () => {\n try {\n if (!value) return\n const r = parseInputExpression(value)\n setExpression(r)\n setError(undefined)\n } catch (error) {\n setError(String(error))\n setExpression(undefined)\n }\n }\n const groupAll = () => {\n if (!factors) return\n setExpression(groupAllFactors(factors))\n }\n const deriveWith = () => {\n try {\n if (!secondValue) return\n if (!value) return\n const r = parseInputExpression(value)\n const g = optimizeExpression(deriveExpressionWith(r, secondValue), v => expressionHasVariable(v, secondValue))\n setExpression(g)\n setError(undefined)\n } catch (error) {\n setError(String(error))\n setExpression(undefined)\n }\n }\n const optimize = () => {\n try {\n if (!value) return\n const r = parseInputExpression(value)\n const g = optimizeExpression(r)\n setExpression(g)\n setError(undefined)\n } catch (error) {\n setError(String(error))\n setExpression(undefined)\n }\n }\n const groupByVariables = () => {\n try {\n if (!secondValue) return\n if (!factors) return\n const r = parseInputExpression(secondValue)\n const f = expressionToFactors(r)\n if (f && f.length === 1) {\n const g = groupFactorsByVariables(factors, f[0].variables.filter((v): v is string => typeof v === 'string'))\n if (g) {\n setExpression(g)\n }\n }\n setError(undefined)\n } catch (error) {\n setError(String(error))\n }\n }\n const taylorExpand = (toPrimaryFunction: boolean) => {\n try {\n if (!secondValue) return\n if (!value) return\n const r = parseInputExpression(value)\n const g = taylorExpandExpressionWith(r, secondValue, +thirdValue || 5, toPrimaryFunction)\n setExpression(g)\n setError(undefined)\n } catch (error) {\n setError(String(error))\n setExpression(undefined)\n }\n }\n const setText = (text: string) => {\n setValue(text)\n setError(undefined)\n setFactors(undefined)\n setExpression(undefined)\n }\n\n return (\n
\n \n
\n \n \n
\n
\n \n =\n \n
\n \n \n \n \n \n \n \n \n \n \n \n {factors && factors.length > 0 &&
\n {factors.map((f, i) =>
{outputExpression(factorToExpression(f))}
)}\n
}\n {factors &&
\n {outputExpression(factorsToExpression(factors))}\n \n \n
}\n {expression &&
\n {outputExpression(expression)}\n \n \n
}\n {expression && renderExpression(reactSvgRenderTarget, expression)}\n {error &&
{error}
}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"flow-layout-block-editor.story",name:"",Component:_.default,code:"() => {\n const [state, setState] = React.useState(() => new Array(3).fill(0).map(() => ({\n children: new Array(20).fill(0).map(() => ({\n radius: 5 + Math.round(Math.random() * 20),\n color: Math.round(Math.random() * 0xffffff),\n })),\n blockStart: 5,\n blockEnd: 5\n })))\n const [align, setAlign] = React.useState('left')\n const [verticalAlign, setVerticalAlign] = React.useState('top')\n const width = 400\n const { renderEditor, layoutResult, lineHeights, isSelected, actualHeight, inputContent, inputInline, getCopiedContents } = useFlowLayoutBlockEditor<{ radius: number, color: number }>({\n state,\n setState: recipe => setState(produce(state, recipe)),\n width,\n height: 400,\n lineHeight: c => c.radius * 2,\n getWidth: c => c.radius * 2,\n endContent: { radius: 0, color: 0 },\n isNewLineContent: content => content.radius === 0,\n align,\n verticalAlign,\n processInput(e) {\n if (metaKeyIfMacElseCtrlKey(e)) {\n if (e.key === 'v') {\n // eslint-disable-next-line plantain/promise-not-await\n navigator.clipboard.readText().then(v => {\n if (v) {\n const contents: FlowLayoutBlock<{ radius: number, color: number }>[] = JSON.parse(v)\n if (contents.length === 1) {\n inputInline(contents[0].children)\n } else {\n inputContent(contents)\n }\n }\n })\n e.preventDefault()\n return true\n }\n if (e.key === 'c' || e.key === 'x') {\n const contents = getCopiedContents(e.key === 'x')\n if (contents) {\n // eslint-disable-next-line plantain/promise-not-await\n navigator.clipboard.writeText(JSON.stringify(contents))\n }\n return true\n }\n }\n return false\n },\n })\n const target: ReactRenderTarget = reactCanvasRenderTarget\n const children: unknown[] = []\n layoutResult.forEach((r, blockIndex) => {\n r.forEach(({ x, y, content, visible, row }, contentIndex) => {\n if (!visible) return\n if (isSelected([blockIndex, contentIndex])) {\n children.push(target.renderRect(x, y, content.radius * 2, lineHeights[row], { fillColor: 0xB3D6FD, strokeWidth: 0 }))\n }\n children.push(target.renderCircle(x + content.radius, y + lineHeights[row] / 2, content.radius, { fillColor: content.color, strokeWidth: 0 }))\n })\n })\n const result = target.renderResult(children, width, actualHeight)\n return (\n <>\n {renderEditor(result)}\n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"flow-layout-editor.story",name:"",Component:S.default,code:"() => {\n const [state, setState] = React.useState(() => new Array(30).fill(0).map(() => ({\n radius: 5 + Math.round(Math.random() * 20),\n color: Math.round(Math.random() * 0xffffff),\n })))\n const [align, setAlign] = React.useState('left')\n const [verticalAlign, setVerticalAlign] = React.useState('top')\n const width = 400\n const { renderEditor, layoutResult, lineHeights, isSelected, actualHeight, inputContent, getCopiedContents } = useFlowLayoutEditor({\n state,\n setState: recipe => setState(produce(state, recipe)),\n width,\n height: 200,\n lineHeight: c => c.radius * 2,\n getWidth: c => c.radius * 2,\n endContent: { radius: 0, color: 0 },\n isNewLineContent: content => content.radius === 0,\n align,\n verticalAlign,\n processInput(e) {\n if (e.key === 'Enter') {\n inputContent([{ radius: 0, color: 0 }])\n return true\n }\n if (metaKeyIfMacElseCtrlKey(e)) {\n if (e.key === 'v') {\n // eslint-disable-next-line plantain/promise-not-await\n navigator.clipboard.readText().then(v => {\n if (v) {\n inputContent(JSON.parse(v))\n }\n })\n e.preventDefault()\n return true\n }\n if (e.key === 'c' || e.key === 'x') {\n const contents = getCopiedContents(e.key === 'x')\n if (contents) {\n // eslint-disable-next-line plantain/promise-not-await\n navigator.clipboard.writeText(JSON.stringify(contents))\n }\n return true\n }\n }\n return false\n },\n })\n const target: ReactRenderTarget = reactCanvasRenderTarget\n const children: unknown[] = []\n for (const { x, y, i, content, visible, row } of layoutResult) {\n if (!visible) continue\n if (isSelected(i)) {\n children.push(target.renderRect(x, y, content.radius * 2, lineHeights[row], { fillColor: 0xB3D6FD, strokeWidth: 0 }))\n }\n children.push(target.renderCircle(x + content.radius, y + lineHeights[row] / 2, content.radius, { fillColor: content.color, strokeWidth: 0 }))\n }\n const result = target.renderResult(children, width, actualHeight)\n return (\n <>\n {renderEditor(result)}\n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"flow-layout-text-editor.story",name:"",Component:R.default,code:"() => {\n const [state, setState] = React.useState(() => '1 + 2 = 3'.split(''))\n const [align, setAlign] = React.useState('left')\n const [verticalAlign, setVerticalAlign] = React.useState('top')\n const { renderEditor, layoutResult } = useFlowLayoutTextEditor({\n state,\n setState: recipe => setState(produce(state, recipe)),\n width: 400,\n height: 200,\n fontSize: 20,\n fontFamily: 'monospace',\n lineHeight: 20 * 1.2,\n align,\n verticalAlign,\n })\n const getTextColors = (index: number) => {\n if (['+', '-', '*', '/', '='].includes(layoutResult[index].content)) {\n return { color: 0x0000ff }\n }\n return\n }\n\n return (\n <>\n {renderEditor({ target: reactCanvasRenderTarget, getTextColors })}\n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"image-click-create.story",name:"",Component:A.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { image, onClick, onMove, input, reset } = useImageClickCreate(true, (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n\n return (\n
\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {[...contents, image].map((content, i) => content && )}\n \n {input}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"keyboard-zoom.story",name:"",Component:T.default,code:"() => {\n const [scale, setScale] = React.useState(1)\n const { zoomIn, zoomOut } = useZoom(scale, setScale)\n useGlobalKeyDown(e => {\n if (metaKeyIfMacElseCtrlKey(e)) {\n if (e.code === 'Minus') {\n zoomOut(e)\n } else if (e.code === 'Equal') {\n zoomIn(e)\n }\n }\n })\n return (\n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"line-alignment-line.story",name:"",Component:M.default,code:"() => {\n const [contents, setContents] = React.useState(defaultContents)\n const [selectedIndex, setSelectedIndex] = React.useState(0)\n\n const { lineAlignmentX, lineAlignmentY, changeOffsetByLineAlignment, clearLineAlignments } = useLineAlignment(10)\n const { offset, onStart, mask, resetDragResize } = useDragResize(\n () => {\n clearLineAlignments()\n setContents(produce(contents, (draft) => {\n draft[selectedIndex].x += offset.x\n draft[selectedIndex].y += offset.y\n draft[selectedIndex].width += offset.width\n draft[selectedIndex].height += offset.height\n }))\n },\n {\n centeredScaling: (e) => e.shiftKey,\n transformOffset: (f, e, direction) => {\n if (!e?.metaKey && direction) {\n const target = contents[selectedIndex]\n const xLines = contents.filter((t) => t !== target).map((t) => [t.x, t.x + t.width]).flat()\n const yLines = contents.filter((t) => t !== target).map((t) => [t.y, t.y + t.height]).flat()\n changeOffsetByLineAlignment(f, direction, target, xLines, yLines)\n } else {\n clearLineAlignments()\n }\n return f\n },\n }\n )\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragResize()\n }\n })\n return (\n <>\n {contents.map((content, i) => (\n setSelectedIndex(i)}\n >\n \n {selectedIndex === i && }\n \n ))}\n \n \n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"line-chart-3d.story",name:"",Component:L.default,code:"() => {\n const ref = React.useRef(null)\n const renderer = React.useRef>()\n const { x, y, ref: wheelScrollRef } = useWheelScroll()\n const { scale, ref: wheelZoomRef } = useWheelZoom()\n const [rotate, setRotate] = React.useState({ x: 0, y: 0 })\n const { offset, onStart: onStartMoveCanvas, mask: moveCanvasMask, resetDragMove } = useDragMove(() => {\n setRotate((v) => ({ x: v.x + offset.x, y: v.y + offset.y }))\n })\n const size = useWindowSize()\n const width = size.width / 2\n const height = size.height\n const [hovering, setHovering] = React.useState()\n const rotateX = offset.x + rotate.x\n const rotateY = offset.y + rotate.y\n const graphics = React.useRef<(Graphic3d)[]>([])\n const getXLabel = (x: number) => Intl.DateTimeFormat('zh', { month: 'long' }).format(new Date(x.toString()))\n\n React.useEffect(() => {\n if (!ref.current) return\n renderer.current = createWebgl3DRenderer(ref.current)\n }, [ref.current])\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragMove()\n }\n })\n\n React.useEffect(() => {\n const points1 = [65, 59, 80, 81, 56, 55, 40].map((s, i) => [(i + 1) * 20, s, 0] as Vec3)\n const points2 = [55, 49, 70, 71, 46, 45, 30].map((s, i) => [(i + 1) * 20, s, 20] as Vec3)\n const points3 = [45, 39, 60, 61, 36, 35, 20].map((s, i) => [(i + 1) * 20, s, -20] as Vec3)\n const points4 = [75, 69, 90, 91, 66, 65, 50].map((s, i) => [(i + 1) * 20, s, 40] as Vec3)\n const axis = getChartAxis3D([points1, points2, points3, points4], { x: 20, y: 10, z: 20 })\n graphics.current.push(\n ...axis,\n { geometry: { type: 'line strip', points: points1.flat() }, color: [1, 0, 0, 1] },\n ...points1.map(p => ({ geometry: { type: 'sphere' as const, radius: 1 }, color: [1, 0, 0, 1] as Vec4, position: p })),\n { geometry: { type: 'line strip', points: getBezierSplinePoints3D(points2, 20).flat() }, color: [0, 1, 0, 1] },\n ...points2.map(p => ({ geometry: { type: 'sphere' as const, radius: 1 }, color: [0, 1, 0, 1] as Vec4, position: p })),\n { geometry: { type: 'polygon', points: [...points3.flat(), points3[points3.length - 1][0], 0, points3[points3.length - 1][2], points3[0][0], 0, points3[0][2]] }, color: [0, 0, 1, 1] },\n ...points3.map(p => ({ geometry: { type: 'sphere' as const, radius: 1 }, color: [0, 0, 1, 1] as Vec4, position: p })),\n ...points4.map((p, i) => ({ geometry: { type: 'sphere' as const, radius: i / 2 + 1 }, color: [1, 0, 0, 1] as Vec4, position: p })),\n )\n }, [])\n\n React.useEffect(() => {\n const { position, up } = updateCamera(-x, y, 200 / scale, -0.3 * rotateX, -0.3 * rotateY)\n renderer.current?.render?.(\n graphics.current,\n {\n eye: [position.x + 40, position.y + 40, position.z],\n up: [up.x, up.y, up.z],\n target: [-x + 40, y + 40, 0],\n fov: angleToRadian(60),\n near: 0.1,\n far: 2000,\n },\n {\n position: [1000, 1000, 1000],\n color: [1, 1, 1, 1],\n specular: [1, 1, 1, 1],\n shininess: 50,\n specularFactor: 1,\n },\n [1, 1, 1, 1],\n )\n }, [x, y, scale, rotateX, rotateY, hovering, width, height])\n\n return (\n
\n onStartMoveCanvas({ x: e.clientX, y: e.clientY })}\n onMouseMove={e => {\n setHovering(undefined)\n const index = renderer.current?.pick?.(e.clientX, e.clientY, (g) => g.geometry.type === 'sphere')\n if (index !== undefined) {\n const graphic = graphics.current[index]\n if (graphic.position) {\n setHovering({ value: graphic.position, x: e.clientX, y: e.clientY })\n }\n }\n }}\n />\n {hovering && }\n {moveCanvasMask}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"line-chart.story",name:"",Component:I.default,code:"() => {\n const size = useWindowSize()\n const width = size.width / 2\n const height = 300\n const target = reactSvgRenderTarget\n const [hovering, setHovering] = React.useState()\n const [result, setResult] = React.useState<{ children: SvgDraw[], select: (p: Position) => Position & { value: Position } | undefined }>()\n const getXLabel = (x: number) => Intl.DateTimeFormat('zh', { month: 'long' }).format(new Date(x.toString()))\n\n React.useEffect(() => {\n const data1 = [65, 59, 80, 81, 56, 55, 40].map((s, i) => ({ x: i + 1, y: s }))\n const data2 = [55, 49, 70, 71, 46, 45, 30].map((s, i) => ({ x: i + 1, y: s }))\n const data3 = [45, 39, 60, 61, 36, 35, 20].map((s, i) => ({ x: i + 1, y: s }))\n const data4 = [35, 29, 50, 51, 26, 25, 10].map((s, i) => ({ x: i + 1, y: s }))\n const data5 = [75, 69, 90, 91, 66, 65, 50].map((s, i) => ({ x: i + 1, y: s, r: i * 3 + 5 }))\n const r = getLineChart([data1, data2, data3, data4, data5], target, { x: 1, y: 5 }, { width, height }, { left: 25, right: 25, top: 10, bottom: 20 }, {\n getXLabel,\n ySecondary: true,\n })\n if (!r) return\n const { points: [points1, points2, points3, points4, points5], children, select, minY } = r\n\n children.push(target.renderPolyline(points1, { strokeColor: 0xff0000 }))\n children.push(...points1.map(c => target.renderCircle(c.x, c.y, 3, { fillColor: 0xff0000, strokeWidth: 0 })))\n children.push(target.renderPolyline(getBezierSplinePoints(points2, 50), { strokeColor: 0x00ff00 }))\n children.push(...points2.map(c => target.renderCircle(c.x, c.y, 3, { fillColor: 0x00ff00, strokeWidth: 0 })))\n children.push(target.renderPolyline(points3.map((p, i) => {\n const r = [p]\n if (i !== 0) r.unshift({ x: getTwoNumberCenter(p.x, points3[i - 1].x), y: p.y })\n if (i !== points3.length - 1) r.push({ x: getTwoNumberCenter(p.x, points3[i + 1].x), y: p.y })\n return r\n }).flat(), { strokeColor: 0x0000ff }))\n children.push(...points3.map(c => target.renderCircle(c.x, c.y, 3, { fillColor: 0x0000ff, strokeWidth: 0 })))\n children.push(target.renderPolygon([...points4, { x: points4[points4.length - 1].x, y: minY }, { x: points4[0].x, y: minY }], { fillColor: 0xff0000, strokeWidth: 0 }))\n children.push(...points4.map(c => target.renderCircle(c.x, c.y, 3, { fillColor: 0xff0000, strokeWidth: 0 })))\n children.push(...points5.map(c => target.renderCircle(c.x, c.y, c.r ?? 5, { fillColor: 0x00ff00, strokeWidth: 0 })))\n\n setResult({ children, select })\n }, [width])\n\n if (!result) {\n return null\n }\n let children = result.children\n if (hovering) {\n children = [\n ...result.children,\n ...renderChartTooltip(target, hovering, hovering.value, { getXLabel }),\n ]\n }\n return (\n
\n {target.renderResult(children, width, height, { attributes: { onMouseMove: e => setHovering(result.select({ x: e.clientX, y: e.clientY })) } })}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"line-click-create.story",name:"",Component:O.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { line, onClick, onMove, input, reset } = useLineClickCreate(true, (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset(true)\n }\n })\n\n return (\n
\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {[...contents, line].map((content, i) => content && `${p.x},${p.y}`).join(' ')}\n />)}\n \n {input}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"linear-dimension.story",name:"",Component:B.default,code:"() => {\n const dimension: LinearDimension = {\n p1: { x: 200, y: 200 },\n p2: { x: 300, y: 300 },\n position: {\n x: 400,\n y: 100,\n },\n fontFamily: 'monospace',\n fontSize: 16,\n direct: true,\n }\n const { regions, lines } = getLinearDimensionGeometries(\n dimension,\n dimensionStyle,\n (c) => getLinearDimensionTextPosition(c, dimensionStyle.margin, getTextSize)\n )\n const { textPosition, textRotation, text } = getLinearDimensionTextPosition(dimension, dimensionStyle.margin, getTextSize)\n return (\n \n {lines.map((line, i) => `${p.x},${p.y}`).join(' ')} />)}\n {regions[0] && `${p.x},${p.y}`).join(' ')} fill='black' />}\n {regions[1] && `${p.x},${p.y}`).join(' ')} fill='black' />}\n {text}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"menu.story",name:"",Component:F.default,code:"() => {\n return (\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"minimap.story",name:"",Component:D.default,code:"() => {\n const { ref: scrollRef, x, setX, y, setY } = useWheelScroll()\n const { ref: zoomRef, scale } = useWheelZoom({\n onChange(oldScale, newScale, cursor) {\n const result = scaleByCursorPosition({ width, height }, newScale / oldScale, cursor)\n setX(result.setX)\n setY(result.setY)\n }\n })\n const target = reactSvgRenderTarget\n const minimapWidth = 100, minimapHeight = 100\n const size = useWindowSize()\n const width = size.width / 2, height = size.height / 2\n const contentWidth = 1200, contentHeight = 800\n const transform: Transform = {\n x,\n y,\n scale,\n center: {\n x: width / 2,\n y: height / 2,\n },\n }\n const children = [target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 0, 0, contentWidth, contentHeight)]\n const { setMinimapTransform, minimap, getMinimapPosition } = useMinimap({\n width: minimapWidth,\n height: minimapHeight,\n viewport: {\n width: width / transform.scale,\n height: height / transform.scale,\n center: reverseTransformPosition(transform.center, transform),\n },\n children(minimapTransform) {\n return target.renderResult(children, minimapWidth, minimapHeight, {\n transform: minimapTransform, attributes: {\n onClick: e => {\n if (getMinimapPosition) {\n const p = getMinimapPosition(e)\n setX((transform.center.x - p.x) * transform.scale)\n setY((transform.center.y - p.y) * transform.scale)\n }\n }\n }\n })\n },\n })\n React.useEffect(() => {\n const bounding = {\n start: { x: 0, y: 0 },\n end: { x: contentWidth, y: contentHeight },\n }\n const result = zoomToFit(bounding, { width: minimapWidth, height: minimapHeight }, { x: minimapWidth / 2, y: minimapHeight / 2 }, 1)\n if (result) {\n setMinimapTransform({\n bounding,\n ...result,\n })\n }\n }, [])\n return (\n
\n {target.renderResult(children, width, height, { transform, attributes: { style: { border: '1px solid green' } } })}\n {minimap}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"opentype.story",name:"",Component:z.default,code:"() => {\n const size = useWindowSize()\n const width = size.width / 2\n const height = 300\n const { x, y, ref: wheelScrollRef, setX, setY } = useWheelScroll()\n const { scale, setScale, ref: wheelZoomRef } = useWheelZoom({\n onChange(oldScale, newScale, cursor) {\n const result = scaleByCursorPosition({ width, height }, newScale / oldScale, cursor)\n setX(result.setX)\n setY(result.setY)\n }\n })\n const [fonts, setFonts] = React.useState>()\n const [text, setText] = React.useState('测试ABC')\n const [fontFamily, setFontFamily] = React.useState(allFonts[0].name)\n const [fontSize, setFontSize] = React.useState(50)\n const [color, setColor] = React.useState(0x000000)\n const [backgroundColor, setBackgroundColor] = React.useState(0xffffff)\n const [xScale, setXScale] = React.useState(1)\n const [yScale, setYScale] = React.useState(1)\n const [commands, setCommands] = React.useState([])\n const [target, setTarget] = React.useState>(allRenderTargets[0])\n const font = fonts?.[fontFamily]\n\n React.useEffect(() => {\n const fetchFonts = async () => {\n const result: Record = {}\n for (const f of allFonts) {\n const res = await fetch(f.url)\n const buffer = await res.arrayBuffer()\n result[f.name] = opentype.parse(buffer)\n }\n setFonts(result)\n }\n fetchFonts()\n }, [])\n useGlobalKeyDown(e => {\n if (e.code === 'Digit0' && !e.shiftKey && metaKeyIfMacElseCtrlKey(e)) {\n setScale(1)\n setX(0)\n setY(0)\n e.preventDefault()\n }\n })\n\n React.useEffect(() => {\n if (!font) return\n const paths = font.getPaths(text, 0, fontSize, fontSize, { xScale: xScale * fontSize / font.unitsPerEm, yScale: yScale * fontSize / font.unitsPerEm })\n const commands = paths.map(path => opentypeCommandsToPathCommands(path))\n setCommands(commands)\n }, [text, font, fontSize, target, xScale, yScale])\n\n const children = commands.map(c => target.renderPathCommands(c, { fillColor: color, strokeColor: color })).flat()\n children.push(target.renderText(0, fontSize * 2, text, color, fontSize * Math.max(xScale, yScale), fontFamily))\n return (\n
\n {target.renderResult(children, width, height, { transform: { x, y, scale }, backgroundColor })}\n
\n setText(v)} />,\n 'font family': t.name)} setValue={v => setFontFamily(allFonts.find(t => t.name === v)?.name ?? allFonts[0].name)} />,\n 'font size': setFontSize(v)} />,\n 'render target': t.type)} setValue={v => setTarget(allRenderTargets.find(t => t.type === v) ?? allRenderTargets[0])} />,\n color: setColor(v)} />,\n 'background color': setBackgroundColor(v)} />,\n 'x scale': setXScale(v)} />,\n 'y scale': setYScale(v)} />,\n actions: ,\n }}\n />\n
\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"partial-edit.story",name:"",Component:U.default,code:"() => {\n interface Content {\n value: number\n children?: Content[]\n }\n const [content, setContent] = React.useState({\n value: 1,\n children: [\n { value: 10 },\n { value: 100 }\n ]\n })\n const { editingContent, setEditingContentPath, prependPatchPath } = usePartialEdit(content)\n const addOne = () => {\n const [, patches] = produceWithPatches(editingContent, (draft) => {\n draft.value++\n })\n setContent(applyPatches(content, prependPatchPath(patches)))\n }\n\n return (\n <>\n \n \n
\n {editingContent.value}\n {editingContent.children && editingContent.children.map((c, i) => (\n \n ))}\n
\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"patch-based-undo-redo.story",name:"",Component:N.default,code:"() => {\n const { state, setState, undo, redo } = usePatchBasedUndoRedo(initialState, 'a')\n useGlobalKeyDown(e => {\n if (e.code === 'KeyZ' && metaKeyIfMacElseCtrlKey(e)) {\n if (e.shiftKey) {\n redo(e)\n } else {\n undo(e)\n }\n }\n })\n return (\n setState((draft) => { draft.count++ })}\n style={{ width: '200px', height: '100px' }}\n >\n {state.count}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"path-click-create.story",name:"",Component:G.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { preview, onClick, onMove, input, setInputType, reset } = usePathClickCreate(true, (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset(true)\n }\n })\n\n return (\n
\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {[...contents, preview].map((content, i) => content && reactSvgRenderTarget.renderPathCommands(content, { strokeColor: 0x00ff00 })(i, 1, false, 800, 600))}\n \n {(['line', 'arc', 'bezierCurve', 'quadraticCurve', 'close'] as const).map(m => )}\n {input}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"pen-click-create.story",name:"",Component:j.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { points, onClick, onMove, reset } = usePenClickCreate(true, () => {\n setContents(produce(contents, (draft) => {\n draft.push(points)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n\n return (\n
\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {[...contents, points].map((content, i) => content && `${p.x},${p.y}`).join(' ')}\n />)}\n \n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"pendulum.story",name:"",Component:V.default,code:"() => {\n const size = useWindowSize()\n const width = size.width / 2\n const height = size.height\n const target = reactCanvasRenderTarget\n const center = { x: width / 2, y: height / 3 }\n const [length, setLength] = React.useState(width / 2)\n const [editing, setEditing] = React.useState(false)\n const [state, setState] = React.useState({ radian: -Math.PI / 4, speed: 0 })\n const [editingState, setEditingState] = React.useState<(typeof state) & { length: number }>()\n const [running, setRunning, runningRef] = useRefState(false)\n const [runningState, setRunningState, runningStateRef] = useRefState2()\n const currentState = runningState ?? editingState ?? state\n const currentLength = editingState?.length ?? length\n const position = {\n x: center.x - currentLength * Math.sin(currentState.radian),\n y: center.y + currentLength * Math.cos(currentState.radian),\n r: 10,\n }\n const p = getPointByLengthAndRadian(position, currentState.speed * currentLength + position.r * (currentState.speed >= 0 ? 1 : -1), getTwoPointsRadian(position, center) + Math.PI / 2)\n const children = [\n target.renderCircle(center.x, center.y, 5),\n target.renderCircle(position.x, position.y, position.r, { fillColor: 0x000000, strokeWidth: 0 }),\n target.renderPolyline([center, position]),\n target.renderPolyline([position, p])\n ]\n\n const stop = () => {\n setRunning(false)\n setRunningState(undefined)\n }\n const run = () => {\n if (runningRef.current) {\n setRunning(false)\n return\n }\n setRunning(true)\n let lastTime: number | undefined\n const step = (time: number) => {\n if (!runningRef.current) return\n if (lastTime !== undefined) {\n const t = (time - lastTime) * 0.005\n const current = runningStateRef.current ?? state\n const initialY = center.y + currentLength * Math.cos(state.radian)\n const y = center.y + currentLength * Math.cos(current.radian)\n const g = 9.8\n let newSpeed = current.speed - g * Math.sin(current.radian) / currentLength * t\n if (y !== initialY) {\n const newSpeed2 = Math.sqrt(g * Math.abs(y - initialY) * 2) / currentLength\n if (newSpeed2 < Math.abs(newSpeed)) {\n newSpeed = Math.sign(newSpeed) * newSpeed2\n }\n }\n setRunningState({ radian: current.radian + current.speed * t, speed: newSpeed })\n }\n lastTime = time\n requestAnimationFrame(step)\n }\n requestAnimationFrame(step)\n }\n const onClick = useEvent(() => {\n if (editingState) {\n setState(editingState)\n setLength(editingState.length)\n setEditing(false)\n setEditingState(undefined)\n }\n })\n const onMouseMove = useEvent((e: React.MouseEvent) => {\n if (editing) {\n const p = { x: e.clientX, y: e.clientY }\n setEditingState({\n radian: getTwoPointsRadian(p, center) - Math.PI / 2,\n speed: 0,\n length: getTwoPointsDistance(p, center),\n })\n }\n })\n\n return (\n
\n {target.renderResult(children, width, height, { attributes: { onClick } })}\n
\n \n {runningState !== undefined && }\n {runningState === undefined && }\n
\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"pie-chart.story",name:"",Component:W.default,code:"() => {\n const size = useWindowSize()\n const width = size.width / 2\n const height = 350\n const target = reactSvgRenderTarget\n const [hovering, setHovering] = React.useState()\n const [hovering2, setHovering2] = React.useState()\n const [result, setResult] = React.useState<{ children: SvgDraw[], select: (p: Position) => Position & { value: { x: number, y: number } } | undefined }>()\n const [result2, setResult2] = React.useState<{ children: SvgDraw[], select: (p: Position) => Position & { value: { x: number, y: number } } | undefined }>()\n const getXLabel = (x: number) => Intl.DateTimeFormat('zh', { month: 'long' }).format(new Date(x.toString()))\n\n React.useEffect(() => {\n const datas = [\n [65, 59, 80, 81, 56, 55, 40],\n [75, 49, 70, 71, 46, 45, 30],\n [85, 39, 60, 61, 36, 35, 20],\n ]\n const colors = [0xff0000, 0x00ff00, 0x0000ff, 0xff0000, 0x00ff00, 0x0000ff, 0x000000]\n setResult(getPieChart(datas, colors, target, { width, height }, { left: 10, right: 10, top: 10, bottom: 10 }))\n setResult2(getPieChart(datas, colors, target, { width, height }, { left: 10, right: 10, top: 10, bottom: 10 }, { type: 'doughnut' }))\n }, [width])\n\n if (!result || !result2) {\n return null\n }\n let children = result.children\n if (hovering) {\n children = [\n ...result.children,\n ...renderChartTooltip(target, hovering, hovering.value, { getXLabel }),\n ]\n }\n let children2 = result2.children\n if (hovering2) {\n children2 = [\n ...result2.children,\n ...renderChartTooltip(target, hovering2, hovering2.value, { getXLabel }),\n ]\n }\n return (\n
\n {target.renderResult(children, width, height, { attributes: { onMouseMove: e => setHovering(result.select({ x: e.clientX, y: e.clientY })) } })}\n {target.renderResult(children2, width, height, { attributes: { onMouseMove: e => setHovering2(result2.select({ x: e.clientX, y: e.clientY - height })) } })}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"point-snap.story",name:"",Component:H.default,code:"() => {\n const [position, setPosition] = React.useState()\n const startPosition = { x: 500, y: 100 }\n const { getSnapAssistentContents, getSnapPoint } = usePointSnap(\n true,\n (c1, c2) => intersectionPointsCache.get(c1, c2, () => Array.from(iterateIntersectionPoints(c1, c2, contents, () => ({ getGeometries: (c) => ({ lines: [{ type: 'arc', curve: circleToArc(c) }] }) })))),\n allSnapTypes,\n () => ({\n getSnapPoints(c) {\n return [\n { x: c.x, y: c.y, type: 'center' },\n { x: c.x - c.r, y: c.y, type: 'endpoint' },\n { x: c.x + c.r, y: c.y, type: 'endpoint' },\n { x: c.x, y: c.y - c.r, type: 'endpoint' },\n { x: c.x, y: c.y + c.r, type: 'endpoint' },\n ]\n },\n getGeometries(c) {\n return {\n lines: [{ type: 'arc', curve: circleToArc(c) }],\n bounding: {\n start: { x: c.x - c.r, y: c.y - c.r },\n end: { x: c.x + c.r, y: c.y + c.r },\n }\n }\n },\n }),\n )\n const assistentContents = getSnapAssistentContents(\n (circle) => ({ type: 'circle' as const, ...circle }),\n (rect) => ({ type: 'rect' as const, ...rect }),\n (points) => ({ type: 'polyline' as const, points }),\n )\n if (position) {\n assistentContents.push({ type: 'polyline', points: [startPosition, position] })\n }\n\n return (\n <>\n setPosition(getSnapPoint({ x: e.clientX, y: e.clientY }, contents, undefined, startPosition).position)}\n >\n {contents.map((c, i) => )}\n {assistentContents.map((c, i) => {\n if (c.type === 'rect') {\n return \n }\n if (c.type === 'circle') {\n return \n }\n return `${p.x},${p.y}`).join(' ')} stroke='#00ff00' />\n })}\n {position && }\n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"polar-area-chart.story",name:"",Component:q.default,code:"() => {\n const size = useWindowSize()\n const width = size.width / 2\n const height = 350\n const target = reactSvgRenderTarget\n const [hovering, setHovering] = React.useState()\n const [result, setResult] = React.useState<{ children: SvgDraw[], select: (p: Position) => Position & { value: { x: number, y: number } } | undefined }>()\n const getXLabel = (x: number) => Intl.DateTimeFormat('zh', { month: 'long' }).format(new Date((x + 1).toString()))\n\n React.useEffect(() => {\n const datas = [65, 59, 80, 81, 56, 55, 40]\n const colors = [0xff0000, 0x00ff00, 0x0000ff, 0xff0000, 0x00ff00, 0x0000ff, 0x000000]\n const r = getPolarAreaChart(datas, colors, target, { width, height }, 10, { left: 10, right: 10, top: 30, bottom: 10 })\n r.angles.forEach((angle, i) => {\n const p = getArcPointAtAngle({ ...r.circle, r: r.circle.r + 30 }, angle)\n r.children.push(target.renderText(p.x, p.y, getXLabel(i), 0xcccccc, 20, 'monospace', { textAlign: 'center', textBaseline: 'middle' }))\n })\n setResult(r)\n }, [width])\n\n if (!result) {\n return null\n }\n let children = result.children\n if (hovering) {\n children = [\n ...result.children,\n ...renderChartTooltip(target, hovering, hovering.value, { getXLabel }),\n ]\n }\n return (\n
\n {target.renderResult(children, width, height, { attributes: { onMouseMove: e => setHovering(result.select({ x: e.clientX, y: e.clientY })) } })}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"polygon-click-create.story",name:"",Component:$.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { polygon, onClick, onMove, input, reset } = usePolygonClickCreate(true, (c) => {\n const data = c || polygon\n if (data) {\n setContents(produce(contents, (draft) => {\n draft.push(data)\n }))\n }\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n\n return (\n
\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {[...contents, polygon].map((content, i) => content && `${p.x},${p.y}`).join(' ')} />\n )}\n \n {input}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"polyline-edit.story",name:"",Component:Y.default,code:"() => {\n const [content, setContent] = React.useState([\n { x: 100, y: 100 },\n { x: 300, y: 200 },\n { x: 100, y: 200 },\n ])\n const { offset, onStart, mask, reset } = usePolylineEdit(() => setContent(points))\n const points = produce(content, (draft) => {\n if (offset) {\n for (const pointIndex of offset.pointIndexes) {\n draft[pointIndex].x += offset.x\n draft[pointIndex].y += offset.y\n }\n }\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n return (\n <>\n \n `${p.x},${p.y}`).join(' ')} />\n \n onStart(e, pointIndexes)}\n />\n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"radar-chart.story",name:"",Component:K.default,code:"() => {\n const size = useWindowSize()\n const width = size.width / 2\n const height = 350\n const target = reactSvgRenderTarget\n const [hovering, setHovering] = React.useState()\n const [result, setResult] = React.useState<{ children: SvgDraw[], select: (p: Position) => Position & { value: { x: number, y: number } } | undefined }>()\n const getXLabel = (x: number) => Intl.DateTimeFormat('zh', { month: 'long' }).format(new Date((x + 1).toString()))\n\n React.useEffect(() => {\n const datas = [\n [65, 59, 80, 81, 56, 55, 40],\n [45, 39, 60, 61, 36, 35, 20],\n ]\n const colors = [0xff0000, 0x00ff00]\n const r = getRadarChart(datas, colors, target, { width, height }, 20, { left: 10, right: 10, top: 30, bottom: 30 })\n r.angles.forEach((angle, i) => {\n const p = getArcPointAtAngle({ ...r.circle, r: r.circle.r + 15 }, angle)\n r.children.push(target.renderText(p.x, p.y, getXLabel(i), 0xcccccc, 12, 'monospace', { textAlign: 'center', textBaseline: 'middle' }))\n })\n setResult(r)\n }, [width])\n\n if (!result) {\n return null\n }\n let children = result.children\n if (hovering) {\n children = [\n ...result.children,\n ...renderChartTooltip(target, hovering, hovering.value, { getXLabel }),\n ]\n }\n return (\n
\n {target.renderResult(children, width, height, { attributes: { onMouseMove: e => setHovering(result.select({ x: e.clientX, y: e.clientY })) } })}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"radial-dimension.story",name:"",Component:X.default,code:"() => {\n const circle: Circle = {\n x: 200,\n y: 200,\n r: 100,\n }\n const dimension: RadialDimension = {\n position: {\n x: 400,\n y: 300,\n },\n fontFamily: 'monospace',\n fontSize: 16,\n }\n const { regions, lines } = getRadialDimensionGeometries(\n dimension,\n circle,\n dimensionStyle,\n (d, c) => getRadialDimensionTextPosition(d, c, dimensionStyle.margin, getTextSize)\n )\n const { textPosition, textRotation, text } = getRadialDimensionTextPosition(dimension, circle, dimensionStyle.margin, getTextSize)\n return (\n \n \n {lines.map((line, i) => `${p.x},${p.y}`).join(' ')} />)}\n {regions && regions.length > 0 && `${p.x},${p.y}`).join(' ')} fill='black' />}\n {text}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"react-composable-json-editor.story",name:"",Component:Z.default,code:"() => {\n const [readOnly, setReadOnly] = React.useState(false)\n const { value, update, getArrayProps } = useJsonEditorData({\n stringExample: 'a string example',\n booleanExample: false,\n numberExample: 123.4,\n objectExample: {\n propertyExample1: '',\n propertyExample2: 0,\n },\n inlineObjectExample: {\n propertyExample1: '',\n propertyExample2: 0,\n },\n arrayExample: ['item1', 'item2'],\n inlineArrayExample: ['item1', 'item2'],\n optionalExample: undefined as string | undefined,\n enumExample: 'enum 1' as 'enum 1' | 'enum 2',\n colorExample: '#000000',\n textareaExample: '',\n imagePreviewExample: 'http://image2.sina.com.cn/bj/art/2004-08-02/U91P52T4D51657F160DT20040802125523.jpg',\n itemTitleExample: [\n {\n propertyExample1: 'foo',\n propertyExample2: 1,\n },\n {\n propertyExample1: 'bar',\n propertyExample2: 2,\n },\n ],\n inlineObjectArrayExample: [\n {\n propertyExample1: 'foo',\n propertyExample2: 1,\n propertyExample3: {\n propertyExample4: 2,\n propertyExample5: '',\n },\n },\n {\n propertyExample1: 'bar',\n propertyExample2: 2,\n propertyExample3: {\n propertyExample4: 3,\n propertyExample5: '',\n },\n },\n ],\n enumTitlesExample: 'enum 1' as 'enum 1' | 'enum 2',\n enumArrayExample: ['foo'] as ('foo' | 'bar')[],\n })\n const valueHtml = JSON.stringify(value, null, ' ')\n return (\n
\n setReadOnly(v)} /> read only\n
\n
\n draft.stringExample = v)} />,\n 'A boolean example': draft.booleanExample = v)} />,\n 'A number example': draft.numberExample = v)} />,\n 'A object example': draft.objectExample.propertyExample1 = v)} />,\n 'Property example 2': draft.objectExample.propertyExample2 = v)} />,\n }}\n />,\n 'A inline object example': draft.inlineObjectExample.propertyExample1 = v)} />,\n 'Property example 2': draft.inlineObjectExample.propertyExample2 = v)} />,\n }}\n />,\n 'A array example': v.arrayExample, '')}\n items={value.arrayExample.map((f, i) => draft.arrayExample[i] = v)} />)}\n />,\n 'A inline array example': v.inlineArrayExample, '')}\n items={value.inlineArrayExample.map((f, i) => draft.inlineArrayExample[i] = v)} />)}\n />,\n 'A optional example': [\n draft.optionalExample = v ? '' : undefined)} />,\n value.optionalExample !== undefined ? draft.optionalExample = v)} /> : undefined,\n ],\n 'A enum example': draft.enumExample = v)} />,\n 'A enum example 2': draft.enumExample = v)} />,\n 'A color example': draft.colorExample = v)} />,\n 'A textarea example': draft.textareaExample = v)} />,\n 'A image preview example': draft.imagePreviewExample = v)} />,\n 'A item title example': v.itemTitleExample, { propertyExample1: '', propertyExample2: 0 })}\n title={(i) => value.itemTitleExample[i].propertyExample1}\n items={value.itemTitleExample.map((f, i) => draft.itemTitleExample[i].propertyExample1 = v)} />,\n 'Property example 2': draft.itemTitleExample[i].propertyExample2 = v)} />,\n }}\n />)}\n />,\n 'A inline object array example': v.inlineObjectArrayExample, { propertyExample1: '', propertyExample2: 0, propertyExample3: { propertyExample4: 0, propertyExample5: '' } })}\n properties={value.inlineObjectArrayExample.map((f, i) => ({\n 'Property example 1': draft.inlineObjectArrayExample[i].propertyExample1 = v)} />,\n 'Property example 2': draft.inlineObjectArrayExample[i].propertyExample2 = v)} />,\n 'Property example 3': draft.inlineObjectArrayExample[i].propertyExample3.propertyExample4 = v)} />,\n 'Property example 4': draft.inlineObjectArrayExample[i].propertyExample3.propertyExample5 = v)} />,\n }}\n />,\n }))}\n />,\n 'A enum titles example': draft.enumTitlesExample = v)} />,\n 'A enum array example': draft.enumArrayExample = v)} />,\n }}\n readOnly={readOnly}\n />\n
\n
\n
\n
\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"react-render-target.story",name:"",Component:Q.default,code:"() => {\n const renderArcs = (target: ReactRenderTarget) => target.renderResult([\n target.renderArc(40, 20, 50, 0, 120, { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderArc(40, 40, 80, 0, 120, { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderArc(50, 50, 100, 0, 120, { strokeColor: 0x00ff00 }),\n target.renderArc(60, 60, 100, 0, 120, { strokeWidth: 5 }),\n target.renderArc(70, 70, 100, 0, 120, { dashArray: [4] }),\n target.renderArc(170, 170, 30, 0, 120, { counterclockwise: true }),\n target.renderArc(170, 170, 20, 120, 0, { counterclockwise: true }),\n target.renderArc(120, 200, 15, 0, 360,),\n target.renderArc(120, 200, 10, 360, 0, { counterclockwise: true }),\n target.renderArc(170, 170, 10, 0, 120, { closed: true }),\n ], 230, 310)\n\n const renderCircles = (target: ReactRenderTarget) => target.renderResult([\n target.renderCircle(70, 100, 30, { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderCircle(150, 100, 30, { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderCircle(110, 100, 70, { strokeColor: 0x00ff00 }),\n target.renderCircle(110, 100, 80, { strokeWidth: 5 }),\n target.renderCircle(110, 100, 90, { dashArray: [4] }),\n ], 230, 200)\n\n const renderTexts = (target: ReactRenderTarget) => target.renderResult([\n target.renderText(10, 30, 'Hello World!', 0xff0000, 30, 'monospace'),\n target.renderText(10, 60, 'Hello World!', 0xff0000, 30, 'monospace', { fontWeight: 'bold' }),\n target.renderText(10, 90, 'Hello World!', 0xff0000, 30, 'monospace', { fontStyle: 'italic' }),\n target.renderText(10, 150, 'He', { width: 4, height: 4, pattern: () => target.renderPath([[{ x: 0, y: 2 }, { x: 2, y: 0 }], [{ x: 4, y: 2 }, { x: 2, y: 4 }]], { strokeColor: 0x0000ff }) }, 70, 'monospace'),\n target.renderText(90, 150, 'l', undefined, 70, 'monospace', { strokeColor: 0xff0000 }),\n target.renderText(130, 150, 'l', undefined, 70, 'monospace', { strokeColor: 0xff0000, dashArray: [2] }),\n target.renderText(170, 150, 'l', undefined, 70, 'monospace', { strokeColor: 0xff0000, strokeWidth: 3 }),\n target.renderText(10, 200, 'H', 0x00ff00, 70, 'monospace', { strokeColor: 0xff0000, strokeWidth: 3 }),\n target.renderText(50, 200, 'H', 0x00ff00, 70, 'monospace', { strokeColor: 0xff0000, strokeWidth: 3, strokeOpacity: 0.3, fillOpacity: 0.3 }),\n target.renderText(90, 200, 'H', undefined, 70, 'monospace', { strokePattern: { width: 4, height: 4, pattern: () => target.renderPath([[{ x: 0, y: 2 }, { x: 2, y: 0 }], [{ x: 4, y: 2 }, { x: 2, y: 4 }]], { strokeColor: 0x0000ff }) }, strokeWidth: 3 }),\n target.renderText(130, 200, 'H', undefined, 70, 'monospace', { strokeLinearGradient: { start: { x: 150, y: 230 }, end: { x: 190, y: 150 }, stops: [{ offset: 0.2, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 0.8, color: 0x00ff00 }] }, strokeWidth: 3 }),\n target.renderText(170, 200, 'H', undefined, 70, 'monospace', { strokeRadialGradient: { start: { x: 190, y: 185, r: 5 }, end: { x: 190, y: 180, r: 30 }, stops: [{ offset: 0, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 1, color: 0x00ff00 }] }, strokeWidth: 3 }),\n target.renderText(70, 225, 'center', 0x00ff00, 30, 'monospace', { textAlign: 'center' }),\n target.renderText(130, 250, 'right', 0x00ff00, 30, 'monospace', { textAlign: 'right' }),\n target.renderText(130, 250, 'H', undefined, 70, 'monospace', { fillLinearGradient: { start: { x: 150, y: 280 }, end: { x: 190, y: 200 }, stops: [{ offset: 0.2, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 0.8, color: 0x00ff00 }] }, strokeWidth: 3 }),\n target.renderText(170, 250, 'H', undefined, 70, 'monospace', { fillRadialGradient: { start: { x: 190, y: 235, r: 5 }, end: { x: 190, y: 230, r: 30 }, stops: [{ offset: 0, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 1, color: 0x00ff00 }] }, strokeWidth: 3 }),\n target.renderText(10, 300, 'fgj', 0x00ff00, 30, 'monospace', { textBaseline: 'alphabetic' }),\n target.renderText(65, 300, 'fgj', 0x00ff00, 30, 'monospace', { textBaseline: 'top' }),\n target.renderText(120, 300, 'fgj', 0x00ff00, 30, 'monospace', { textBaseline: 'middle' }),\n target.renderText(175, 300, 'fgj', 0x00ff00, 30, 'monospace', { textBaseline: 'bottom' }),\n ], 230, 550)\n\n const renderEllipseArcs = (target: ReactRenderTarget) => target.renderResult([\n target.renderEllipseArc(40, 10, 50, 30, 0, 120, { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderEllipseArc(40, 30, 80, 40, 0, 120, { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderEllipseArc(50, 40, 100, 50, 0, 120, { strokeColor: 0x00ff00 }),\n target.renderEllipseArc(60, 50, 100, 50, 0, 120, { strokeWidth: 5 }),\n target.renderEllipseArc(70, 60, 100, 50, 0, 120, { dashArray: [4] }),\n target.renderEllipseArc(170, 160, 30, 15, 0, 120, { counterclockwise: true }),\n target.renderEllipseArc(170, 160, 30, 25, 120, 20, { counterclockwise: true }),\n target.renderEllipseArc(110, 100, 80, 40, 0, 120, { strokeColor: 0x00ff00, angle: 30 }),\n target.renderEllipseArc(120, 200, 30, 15, 0, 360,),\n target.renderEllipseArc(120, 200, 20, 10, 360, 0, { counterclockwise: true }),\n target.renderEllipseArc(170, 160, 25, 20, 0, 120, { closed: true }),\n ], 230, 330)\n\n const renderEllipses = (target: ReactRenderTarget) => target.renderResult([\n target.renderEllipse(70, 60, 40, 20, { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderEllipse(150, 60, 40, 20, { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderEllipse(110, 60, 90, 45, { strokeColor: 0x00ff00 }),\n target.renderEllipse(110, 60, 100, 50, { strokeWidth: 5 }),\n target.renderEllipse(110, 60, 110, 55, { dashArray: [4] }),\n target.renderEllipse(110, 140, 80, 40, { strokeColor: 0x0000ff, angle: 30 }),\n target.renderEllipse(110, 30, 10, 20, { angle: 60, fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n ], 230, 230)\n\n const renderRects = (target: ReactRenderTarget) => target.renderResult([\n target.renderRect(10, 10, 50, 30, { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderRect(70, 10, 80, 40, { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderRect(90, 60, 100, 140, { strokeColor: 0x00ff00 }),\n target.renderRect(100, 70, 80, 120, { strokeWidth: 5 }),\n target.renderRect(110, 80, 60, 100, { dashArray: [4] }),\n target.renderRect(10, 90, 60, 30, { angle: 60 }),\n ], 230, 220)\n\n const renderPaths = (target: ReactRenderTarget) => target.renderResult([\n target.renderPath([[{ x: 5, y: 10 }, { x: 45, y: 150 }, { x: 45, y: 10 }], [{ x: 25, y: 30 }, { x: 25, y: 70 }, { x: 35, y: 70 }, { x: 35, y: 30 }]], { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) }, strokeWidth: 0 }),\n target.renderPath([[{ x: 50, y: 10 }, { x: 90, y: 150 }, { x: 90, y: 10 }], [{ x: 70, y: 30 }, { x: 70, y: 70 }, { x: 80, y: 70 }, { x: 80, y: 30 }]], { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderPath([[{ x: 95, y: 10 }, { x: 135, y: 150 }, { x: 135, y: 10 }], [{ x: 115, y: 30 }, { x: 115, y: 70 }, { x: 125, y: 70 }, { x: 125, y: 30 }]], { strokeColor: 0x00ff00 }),\n target.renderPath([[{ x: 140, y: 10 }, { x: 180, y: 150 }, { x: 180, y: 10 }], [{ x: 160, y: 30 }, { x: 160, y: 70 }, { x: 170, y: 70 }, { x: 170, y: 30 }]], { fillPattern: { width: 100, height: 100, pattern: () => target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 0, 0, 100, 100, { crossOrigin: '' }) }, strokeWidth: 0 }),\n target.renderPath([[{ x: 185, y: 10 }, { x: 225, y: 150 }, { x: 225, y: 10 }], [{ x: 205, y: 30 }, { x: 205, y: 70 }, { x: 215, y: 70 }, { x: 215, y: 30 }]], { dashArray: [4] }),\n target.renderPath([[{ x: 5, y: 160 }, { x: 35, y: 160 }, { x: 35, y: 190 }]], { strokeColor: 0xff0000, strokeWidth: 5 }),\n target.renderPath([[{ x: 45, y: 160 }, { x: 75, y: 160 }, { x: 75, y: 190 }]], { strokeColor: 0xff0000, strokeWidth: 5, closed: true }),\n target.renderPath([[{ x: 85, y: 160 }, { x: 125, y: 160 }, { x: 125, y: 190 }]], { strokeColor: 0xff0000, strokeWidth: 5, closed: true, miterLimit: 2 }),\n target.renderPath([[{ x: 135, y: 160 }, { x: 175, y: 160 }, { x: 175, y: 190 }]], { strokeColor: 0xff0000, strokeWidth: 10, lineJoin: 'bevel' }),\n target.renderPath([[{ x: 185, y: 160 }, { x: 225, y: 160 }, { x: 225, y: 190 }]], { strokeColor: 0xff0000, strokeWidth: 10, lineJoin: 'round' }),\n target.renderPath([[{ x: 10, y: 210 }, { x: 40, y: 210 }, { x: 40, y: 240 }]], { strokeColor: 0xff0000, strokeWidth: 10, lineCap: 'square' }),\n target.renderPath([[{ x: 55, y: 210 }, { x: 85, y: 210 }, { x: 85, y: 240 }]], { strokeColor: 0xff0000, strokeWidth: 10, lineCap: 'round' }),\n target.renderPath([[{ x: 100, y: 210 }, { x: 220, y: 210 }]], { dashArray: [12, 4] }),\n target.renderPath([[{ x: 100, y: 220 }, { x: 220, y: 220 }]], { dashArray: [12, 4], dashOffset: 4 }),\n target.renderPath([[{ x: 5, y: 250 }, { x: 45, y: 390 }, { x: 45, y: 250 }], [{ x: 25, y: 270 }, { x: 25, y: 310 }, { x: 35, y: 310 }, { x: 35, y: 270 }]], { fillLinearGradient: { start: { x: 5, y: 250 }, end: { x: 45, y: 390 }, stops: [{ offset: 0.2, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 0.8, color: 0x00ff00 }] }, strokeWidth: 0 }),\n target.renderPath([[{ x: 50, y: 250 }, { x: 90, y: 390 }, { x: 90, y: 250 }], [{ x: 70, y: 270 }, { x: 70, y: 310 }, { x: 80, y: 310 }, { x: 80, y: 270 }]], { fillRadialGradient: { start: { x: 70, y: 320, r: 10 }, end: { x: 70, y: 320, r: 70 }, stops: [{ offset: 0, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 1, color: 0x00ff00 }] }, strokeWidth: 0 }),\n target.renderPath([[{ x: 95, y: 250 }, { x: 135, y: 390 }, { x: 135, y: 250 }], [{ x: 115, y: 270 }, { x: 115, y: 310 }, { x: 125, y: 310 }, { x: 125, y: 270 }]], { fillColor: 0xff0000, fillOpacity: 0.3, strokeOpacity: 0.3 }),\n target.renderPath([[{ x: 140, y: 250 }, { x: 180, y: 390 }, { x: 180, y: 250 }], [{ x: 160, y: 270 }, { x: 160, y: 310 }, { x: 170, y: 310 }, { x: 170, y: 270 }]], { fillRadialGradient: { start: { x: 160, y: 320, r: 10 }, end: { x: 160, y: 320, r: 70 }, stops: [{ offset: 0, color: 0xff0000, opacity: 0.3 }, { offset: 0.5, color: 0xffff00, opacity: 0.3 }, { offset: 1, color: 0x00ff00, opacity: 0.3 }] }, strokeWidth: 0 }),\n target.renderPath([[{ x: 185, y: 250 }, { x: 225, y: 390 }, { x: 225, y: 250 }], [{ x: 205, y: 270 }, { x: 205, y: 310 }, { x: 215, y: 310 }, { x: 215, y: 270 }]], { strokePattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) }, strokeWidth: 5 }),\n target.renderPath([[{ x: 5, y: 400 }, { x: 45, y: 540 }, { x: 45, y: 400 }], [{ x: 25, y: 420 }, { x: 25, y: 460 }, { x: 35, y: 460 }, { x: 35, y: 420 }]], { strokeLinearGradient: { start: { x: 5, y: 400 }, end: { x: 45, y: 540 }, stops: [{ offset: 0.2, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 0.8, color: 0x00ff00 }] }, strokeWidth: 5 }),\n target.renderPath([[{ x: 50, y: 400 }, { x: 90, y: 540 }, { x: 90, y: 400 }], [{ x: 70, y: 420 }, { x: 70, y: 460 }, { x: 80, y: 460 }, { x: 80, y: 420 }]], { strokeRadialGradient: { start: { x: 70, y: 470, r: 10 }, end: { x: 70, y: 470, r: 70 }, stops: [{ offset: 0, color: 0xff0000 }, { offset: 0.5, color: 0xffff00 }, { offset: 1, color: 0x00ff00 }] }, strokeWidth: 5 }),\n target.renderPath([[{ x: 110, y: 400 }, { x: 110, y: 470 }, { x: 110, y: 540 }]], { strokeColor: 0xff0000, strokeWidth: 10 }),\n target.renderPath([[{ x: 130, y: 400 }, { x: 130, y: 540 }, { x: 130, y: 470 }]], { strokeColor: 0xff0000, strokeWidth: 10 }),\n ], 230, 620)\n\n const renderImages = (target: ReactRenderTarget) => target.renderResult([\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 0, 0, 75, 65, { crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 77, 0, 75, 65, { opacity: 0.5, crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 154, 0, 75, 65, { filters: [{ type: 'brightness', value: 2 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 0, 70, 75, 65, { filters: [{ type: 'contrast', value: 2 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 77, 70, 75, 65, { filters: [{ type: 'hue-rotate', value: 90 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 154, 70, 75, 65, { filters: [{ type: 'saturate', value: 2 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 0, 140, 75, 65, { filters: [{ type: 'saturate', value: 2 }, { type: 'hue-rotate', value: 90 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 77, 140, 75, 65, { filters: [{ type: 'saturate', value: 2 }, { type: 'hue-rotate', value: 90 }, { type: 'contrast', value: 2 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 154, 140, 75, 65, { filters: [{ type: 'grayscale', value: 1 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 0, 210, 75, 65, { filters: [{ type: 'sepia', value: 1 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 77, 210, 75, 65, { filters: [{ type: 'invert', value: 1 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 154, 210, 75, 65, { filters: [{ type: 'opacity', value: 0.5 }], crossOrigin: '' }),\n target.renderImage('https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg', 0, 280, 75, 65, { filters: [{ type: 'blur', value: 2 }], crossOrigin: '' }),\n ], 230, 370)\n\n const renderPolylines = (target: ReactRenderTarget) => target.renderResult([\n target.renderPolyline([{ x: 5, y: 10 }, { x: 45, y: 150 }, { x: 45, y: 10 }], { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderPolyline([{ x: 50, y: 10 }, { x: 90, y: 150 }, { x: 90, y: 10 }], { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderPolyline([{ x: 95, y: 10 }, { x: 135, y: 150 }, { x: 135, y: 10 }], { strokeColor: 0x00ff00 }),\n target.renderPolyline([{ x: 140, y: 10 }, { x: 180, y: 150 }, { x: 180, y: 10 }], { strokeWidth: 5 }),\n target.renderPolyline([{ x: 185, y: 10 }, { x: 225, y: 150 }, { x: 225, y: 10 }], { dashArray: [4] }),\n target.renderPolyline([{ x: 195, y: 10 }, { x: 215, y: 80 }, { x: 215, y: 10 }], { closed: true }),\n ], 230, 220)\n\n const renderPolygons = (target: ReactRenderTarget) => target.renderResult([\n target.renderPolygon([{ x: 5, y: 10 }, { x: 45, y: 150 }, { x: 45, y: 10 }], { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderPolygon([{ x: 50, y: 10 }, { x: 90, y: 150 }, { x: 90, y: 10 }], { fillColor: 0xff0000, strokeWidth: 0 }),\n target.renderPolygon([{ x: 95, y: 10 }, { x: 135, y: 150 }, { x: 135, y: 10 }], { strokeColor: 0x00ff00 }),\n target.renderPolygon([{ x: 140, y: 10 }, { x: 180, y: 150 }, { x: 180, y: 10 }], { strokeWidth: 5 }),\n target.renderPolygon([{ x: 185, y: 10 }, { x: 225, y: 150 }, { x: 225, y: 10 }], { dashArray: [4] }),\n ], 230, 190)\n\n const renderPathCommands = (target: ReactRenderTarget) => target.renderResult([\n target.renderPathCommands([{ type: 'move', to: { x: 220, y: 10 } }, { type: 'arc', from: { x: 220, y: 80 }, to: { x: 150, y: 10 }, radius: 20 }, { type: 'line', to: { x: 150, y: 10 } }, { type: 'quadraticCurve', cp: { x: 150, y: 90 }, to: { x: 110, y: 70 } }, { type: 'bezierCurve', cp1: { x: 70, y: 20 }, cp2: { x: 40, y: 80 }, to: { x: 10, y: 10 } }, { type: 'ellipseArc', rx: 30, ry: 20, angle: 0, largeArc: false, sweep: true, to: { x: 50, y: 30 } }], { strokeColor: 0x00ff00 }),\n target.renderPathCommands([{ type: 'move', to: { x: 210, y: 10 } }, { type: 'arc', from: { x: 210, y: 80 }, to: { x: 160, y: 10 }, radius: 20 }, { type: 'line', to: { x: 160, y: 10 } }], { closed: true }),\n ], 230, 120)\n\n const renderGroups = (target: ReactRenderTarget) => {\n const items = [\n target.renderCircle(50, 50, 20),\n target.renderCircle(50, 50, 35),\n target.renderText(0, 40, 'abc', 0xff0000, 30, 'monospace'),\n target.renderGroup([target.renderCircle(50, 50, 15),], { translate: { x: 20, y: 20 } })\n ]\n return target.renderResult([\n target.renderGroup(items, { opacity: 0.2, translate: { x: 10, y: 0 } }),\n target.renderRect(120, 10, 80, 80, { clip: () => target.renderGroup(items, { translate: { x: 100, y: 0 } }) }),\n target.renderCircle(180, 150, 50, { clip: () => target.renderGroup(items, { matrix: m3.multiply(m3.translation(150, 150), m3.scaling(0.7, 0.7)) }) }),\n target.renderPath([[{ x: 0, y: 200 }, { x: 120, y: 200 }, { x: 120, y: 300 }, { x: 0, y: 300 }, { x: 0, y: 200 }], [{ x: 55, y: 230 }, { x: 90, y: 220 }, { x: 90, y: 260 }, { x: 50, y: 260 }, { x: 55, y: 230 }]], { clip: () => target.renderGroup(items, { translate: { x: 10, y: 200 } }), strokeWidth: 0 }),\n target.renderPolygon([{ x: 55, y: 230 }, { x: 90, y: 220 }, { x: 90, y: 260 }, { x: 50, y: 260 }]),\n target.renderRect(30, 100, 80, 80, {\n clip: () => target.renderGroup([\n target.renderCircle(90, 50, 20, { fillPattern: { width: 10, height: 10, pattern: () => target.renderPath([[{ x: 0, y: 5 }, { x: 5, y: 0 }], [{ x: 10, y: 5 }, { x: 5, y: 10 }]], { strokeColor: 0x0000ff }) } }),\n target.renderCircle(30, 50, 20),\n ], { translate: { x: 10, y: 90 } })\n }),\n target.renderGroup(items, { translate: { x: 110, y: 200 }, base: { x: 50, y: 50 }, scale: { x: 0.6, y: 0.3 } }),\n ], 230, 550)\n }\n\n const renderRay = (target: ReactRenderTarget) => target.renderResult([\n target.renderRay(50, 50, 30),\n target.renderRay(80, 50, 30, { bidirectional: true }),\n target.renderGroup([\n target.renderRay(60, 60, 30),\n target.renderGroup([\n target.renderRay(60, 60, 30),\n ], { translate: { x: 0, y: -20 } })\n ], { translate: { x: -20, y: 0 } })\n ], 230, 90)\n\n const { setOffset } = React.useContext(OffsetXContext)\n React.useEffect(() => {\n if (navigator.gpu) {\n setOffset?.(230)\n }\n }, [setOffset])\n return (\n
\n
\n {reactSvgRenderTarget.type}\n {reactCanvasRenderTarget.type}\n {reactWebglRenderTarget.type}\n {navigator.gpu && {reactWebgpuRenderTarget.type}}\n
\n {renderArcs(reactSvgRenderTarget)}\n {renderArcs(reactCanvasRenderTarget)}\n {renderArcs(reactWebglRenderTarget)}\n {navigator.gpu && renderArcs(reactWebgpuRenderTarget)}\n
\n {renderCircles(reactSvgRenderTarget)}\n {renderCircles(reactCanvasRenderTarget)}\n {renderCircles(reactWebglRenderTarget)}\n {navigator.gpu && renderCircles(reactWebgpuRenderTarget)}\n
\n {renderTexts(reactSvgRenderTarget)}\n {renderTexts(reactCanvasRenderTarget)}\n {renderTexts(reactWebglRenderTarget)}\n {navigator.gpu && renderTexts(reactWebgpuRenderTarget)}\n
\n {renderEllipseArcs(reactSvgRenderTarget)}\n {renderEllipseArcs(reactCanvasRenderTarget)}\n {renderEllipseArcs(reactWebglRenderTarget)}\n {navigator.gpu && renderEllipseArcs(reactWebgpuRenderTarget)}\n
\n {renderEllipses(reactSvgRenderTarget)}\n {renderEllipses(reactCanvasRenderTarget)}\n {renderEllipses(reactWebglRenderTarget)}\n {navigator.gpu && renderEllipses(reactWebgpuRenderTarget)}\n
\n {renderRects(reactSvgRenderTarget)}\n {renderRects(reactCanvasRenderTarget)}\n {renderRects(reactWebglRenderTarget)}\n {navigator.gpu && renderRects(reactWebgpuRenderTarget)}\n
\n {renderPaths(reactSvgRenderTarget)}\n {renderPaths(reactCanvasRenderTarget)}\n {renderPaths(reactWebglRenderTarget)}\n {navigator.gpu && renderPaths(reactWebgpuRenderTarget)}\n
\n {renderImages(reactSvgRenderTarget)}\n {renderImages(reactCanvasRenderTarget)}\n {renderImages(reactWebglRenderTarget)}\n {navigator.gpu && renderImages(reactWebgpuRenderTarget)}\n
\n {renderPolylines(reactSvgRenderTarget)}\n {renderPolylines(reactCanvasRenderTarget)}\n {renderPolylines(reactWebglRenderTarget)}\n {navigator.gpu && renderPolylines(reactWebgpuRenderTarget)}\n
\n {renderPolygons(reactSvgRenderTarget)}\n {renderPolygons(reactCanvasRenderTarget)}\n {renderPolygons(reactWebglRenderTarget)}\n {navigator.gpu && renderPolygons(reactWebgpuRenderTarget)}\n
\n {renderPathCommands(reactSvgRenderTarget)}\n {renderPathCommands(reactCanvasRenderTarget)}\n {renderPathCommands(reactWebglRenderTarget)}\n {navigator.gpu && renderPathCommands(reactWebgpuRenderTarget)}\n
\n {renderGroups(reactSvgRenderTarget)}\n {renderGroups(reactCanvasRenderTarget)}\n {renderGroups(reactWebglRenderTarget)}\n {navigator.gpu && renderGroups(reactWebgpuRenderTarget)}\n
\n {renderRay(reactSvgRenderTarget)}\n {renderRay(reactCanvasRenderTarget)}\n {renderRay(reactWebglRenderTarget)}\n {navigator.gpu && renderRay(reactWebgpuRenderTarget)}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"region-alignment-line.story",name:"",Component:J.default,code:"() => {\n const [contents, setContents] = React.useState(defaultContents)\n const [selectedIndex, setSelectedIndex] = React.useState(0)\n\n const { regionAlignmentX, regionAlignmentY, changeOffsetByRegionAlignment, clearRegionAlignments } = useRegionAlignment(10)\n const { offset, onStart, mask, startPosition, resetDragMove } = useDragMove(\n () => {\n clearRegionAlignments()\n if (offset.x === 0 && offset.y === 0 && startPosition?.data !== undefined) {\n setSelectedIndex(startPosition.data)\n return\n }\n setContents(produce(contents, (draft) => {\n draft[selectedIndex].x += offset.x\n draft[selectedIndex].y += offset.y\n }))\n },\n {\n transformOffset: (f, e) => {\n if (!e?.shiftKey) {\n changeOffsetByRegionAlignment(f, contents[selectedIndex], contents.filter((_, i) => i !== selectedIndex))\n } else {\n clearRegionAlignments()\n }\n return f\n },\n }\n )\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragMove()\n }\n })\n return (\n <>\n {contents.map((content, i) => (\n onStart({ x: e.clientX, y: e.clientY }, { data: i })}\n >\n \n ))}\n \n \n {mask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"scrollbar.story",name:"",Component:ee.default,code:"() => {\n const [x, setX] = React.useState(0)\n const [y, setY] = React.useState(0)\n return (\n \n \n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"select-before-operate.story",name:"",Component:te.default,code:"() => {\n const { isSelected, addSelection, filterSelection, executeOperation, selectBeforeOperate, message, onSelectBeforeOperateKeyDown } = useSelectBeforeOperate<{ count?: number, selectable?: (index: number[]) => boolean }, 'alert', number[]>({}, (_, s) => {\n alert(s.map(([i]) => i).join(','))\n return true\n })\n useGlobalKeyDown(e => {\n onSelectBeforeOperateKeyDown(e)\n })\n const startOperation = (maxCount?: number, selectable?: (index: number[]) => boolean) => {\n const { result, needSelect } = filterSelection(selectable, maxCount)\n if (needSelect) {\n selectBeforeOperate({ count: maxCount, selectable }, 'alert')\n } else {\n executeOperation('alert', result)\n }\n }\n\n return (\n
\n \n \n \n \n {new Array(10).fill(1).map((_, i) => (\n addSelection([i])}\n >\n {i}\n \n ))}\n {message}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"selected.story",name:"",Component:ne.default,code:"() => {\n const { isSelected, addSelection, onSelectedKeyDown } = useSelected({ maxCount: 3 })\n useGlobalKeyDown(e => {\n onSelectedKeyDown(e)\n })\n\n return (\n
\n {new Array(10).fill(1).map((_, i) => (\n addSelection([[i]])}\n >\n {i}\n \n ))}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"text-click-create.story",name:"",Component:re.default,code:"() => {\n const [contents, setContents] = React.useState([])\n const { text, onClick, onMove, input, reset } = useTextClickCreate(true, (c) => {\n setContents(produce(contents, (draft) => {\n draft.push(c)\n }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n reset()\n }\n })\n\n return (\n
\n onClick({ x: e.clientX, y: e.clientY })}\n onMouseMove={(e) => onMove({ x: e.clientX, y: e.clientY })}\n >\n {[...contents, text].map((content, i) => content && {content.text})}\n \n {input}\n
\n )\n}",props:[],componentName:"",parentComponentName:""},{path:"undo-redo.story",name:"",Component:oe.default,code:"() => {\n const { state, setState, undo, redo } = useUndoRedo({ count: 0 })\n useGlobalKeyDown(e => {\n if (e.code === 'KeyZ' && metaKeyIfMacElseCtrlKey(e)) {\n if (e.shiftKey) {\n redo(e)\n } else {\n undo(e)\n }\n }\n })\n return (\n setState((draft) => { draft.count++ })}\n style={{ width: '200px', height: '100px' }}\n >\n {state.count}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"webgl-3d.story",name:"",Component:ie.default,code:"() => {\n const ref = React.useRef(null)\n const renderer = React.useRef>()\n const { x, y, setX, setY, ref: wheelScrollRef } = useWheelScroll()\n const { scale, setScale, ref: wheelZoomRef } = useWheelZoom()\n const [rotate, setRotate] = React.useState({ x: 0, y: 0 })\n const { offset, onStart: onStartMoveCanvas, mask: moveCanvasMask, resetDragMove } = useDragMove(() => {\n setRotate((v) => ({ x: v.x + offset.x, y: v.y + offset.y }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragMove()\n } else if (e.code === 'Digit0' && !e.shiftKey && metaKeyIfMacElseCtrlKey(e)) {\n setScale(1)\n setX(0)\n setY(0)\n setRotate({ x: 0, y: 0 })\n e.preventDefault()\n }\n })\n const size = useWindowSize()\n const width = size.width / 2\n const height = size.height\n const rotateX = offset.x + rotate.x\n const rotateY = offset.y + rotate.y\n const [hovering, setHovering] = React.useState()\n const graphics = React.useRef([\n ...getAxesGraphics(),\n {\n geometry: {\n type: 'lines',\n points: getDashedLine([0, 0, 0], [100, 100, 100], 6).flat(),\n },\n color: [0, 0, 0, 1],\n },\n {\n geometry: {\n type: 'sphere',\n radius: 100,\n },\n color: [1, 0, 0, 1],\n position: [0, 250, 0],\n },\n {\n geometry: {\n type: 'cube',\n size: 150,\n },\n color: [0, 1, 0, 1],\n position: [250, 0, 0],\n },\n {\n geometry: {\n type: 'cylinder',\n radius: 100,\n height: 200,\n },\n color: [0, 0, 1, 1],\n position: [-250, 0, 0],\n },\n {\n geometry: {\n type: 'cone',\n topRadius: 0,\n bottomRadius: 100,\n height: 200,\n },\n color: [1, 0, 1, 1],\n position: [0, -250, 0],\n },\n {\n geometry: {\n type: 'triangles',\n points: [-50, -50, 50, 50, 50, 50, -50, 50, 50],\n },\n color: [0.5, 0, 0.5, 1],\n position: [250, 250, 250],\n },\n {\n geometry: {\n type: 'vertices',\n vertices: getNurbsSurfaceVertices([\n [[0, 0, -20], [20, 0, 0], [40, 0, 0], [60, 0, 0], [80, 0, 0], [100, 0, 0]],\n [[0, -20, 0], [20, -20, 10], [40, -20, 20], [60, -20, 0], [80, -20, 0], [100, -20, 0]],\n [[0, -40, 0], [20, -40, 10], [40, -40, 20], [60, -40, 0], [80, -40, -4], [100, -40, -24]],\n [[0, -50, 0], [20, -60, 0], [40, -60, -46], [60, -60, 0], [80, -60, 0], [100, -50, 0]],\n [[0, -80, 0], [20, -80, 0], [40, -80, 0], [60, -80, 8], [80, -80, -40], [100, -80, 0]],\n [[0, -100, 24], [20, -100, 0], [40, -100, 40], [60, -100, 0], [100, -100, -20], [100, -100, -30]],\n ], 3, [0, 0, 0, 0, 0.333, 0.666, 1, 1, 1, 1], 3, [0, 0, 0, 0, 0.333, 0.666, 1, 1, 1, 1]),\n },\n color: [0, 0.5, 0, 1],\n position: [-250, 250, 250],\n },\n ])\n\n React.useEffect(() => {\n if (!ref.current) {\n return\n }\n renderer.current = createWebgl3DRenderer(ref.current)\n }, [ref.current])\n\n React.useEffect(() => {\n const { position, up } = updateCamera(-x, y, 1000 / scale, -0.3 * rotateX, -0.3 * rotateY)\n graphics.current.forEach((g, i) => {\n g.color[3] = i === hovering ? 0.5 : 1\n })\n renderer.current?.render?.(\n graphics.current,\n {\n eye: [position.x, position.y, position.z],\n up: [up.x, up.y, up.z],\n target: [-x, y, 0],\n fov: angleToRadian(60),\n near: 0.1,\n far: 20000,\n },\n {\n position: [1000, 1000, 1000],\n color: [1, 1, 1, 1],\n specular: [1, 1, 1, 1],\n shininess: 50,\n specularFactor: 1,\n },\n [1, 1, 1, 1],\n )\n }, [x, y, scale, rotateX, rotateY, hovering, width, height])\n\n return (\n \n onStartMoveCanvas({ x: e.clientX, y: e.clientY })}\n onMouseMove={e => setHovering(renderer.current?.pick?.(e.clientX, e.clientY, (g) => g.geometry.type !== 'lines'))}\n />\n {moveCanvasMask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"webgl.story",name:"",Component:ae.default,code:"() => {\n const ref = React.useRef(null)\n const render = React.useRef<(g: typeof graphics, x: number, y: number, scale: number) => void>()\n const { x, y, ref: wheelScrollRef, setX, setY } = useWheelScroll()\n const { scale, setScale, ref: wheelZoomRef } = useWheelZoom({\n onChange(oldScale, newScale, cursor) {\n const result = scaleByCursorPosition({ width, height }, newScale / oldScale, cursor)\n setX(result.setX)\n setY(result.setY)\n }\n })\n const { zoomIn, zoomOut } = useZoom(scale, setScale)\n const { offset, onStart: onStartMoveCanvas, mask: moveCanvasMask, resetDragMove } = useDragMove(() => {\n setX((v) => v + offset.x)\n setY((v) => v + offset.y)\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragMove()\n } else if (metaKeyIfMacElseCtrlKey(e) ) {\n if (e.code === 'Minus') {\n zoomOut(e)\n } else if (e.code === 'Equal') {\n zoomIn(e)\n }\n }\n })\n const size = useWindowSize()\n const width = size.width / 2\n const height = size.height\n const generateGraphics = () => {\n const canvas = document.createElement(\"canvas\")\n const ctx = canvas.getContext(\"2d\")\n if (ctx) {\n ctx.font = \"50px monospace\";\n const t = ctx.measureText('abc');\n ctx.canvas.width = Math.ceil(t.width) + 2;\n ctx.canvas.height = 50;\n ctx.font = \"50px monospace\";\n ctx.fillStyle = 'white';\n ctx.fillText('abc', 0, ctx.canvas.height);\n }\n const lineWidth = 10\n const miterLimit = 'round'\n const closed = undefined\n return {\n backgroundColor: [Math.random(), Math.random(), Math.random(), 1] as Vec4,\n lines: [\n {\n points: combineStripTriangles([\n getPolylineTriangles([\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n ], lineWidth, closed, miterLimit).points,\n getPolylineTriangles([\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n ], lineWidth, closed, miterLimit).points,\n ]),\n color: [Math.random(), Math.random(), Math.random(), 1],\n },\n {\n points: combineStripTriangles([\n getPolylineTriangles([\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n ], lineWidth, closed, miterLimit).points,\n getPolylineTriangles([\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n { x: Math.random() * 600, y: Math.random() * 400 },\n ], lineWidth, closed, miterLimit).points,\n ]),\n color: [Math.random(), Math.random(), Math.random(), 1],\n },\n ],\n line: [\n Math.random() * 600,\n Math.random() * 400,\n Math.random() * 600,\n Math.random() * 400,\n Math.random() * 600,\n Math.random() * 400,\n ],\n triangles: [\n Math.random() * 600,\n Math.random() * 400,\n Math.random() * 600,\n Math.random() * 400,\n Math.random() * 600,\n Math.random() * 400,\n ],\n triangleColors: [\n Math.random(), Math.random(), Math.random(), 1,\n Math.random(), Math.random(), Math.random(), 1,\n Math.random(), Math.random(), Math.random(), 1,\n ],\n canvas,\n color: [Math.random(), Math.random(), Math.random(), 1],\n position: { x: Math.random() * 600, y: Math.random() * 400 },\n }\n }\n const [graphics, setGraphics] = React.useState(generateGraphics())\n\n React.useEffect(() => {\n if (!ref.current) {\n return\n }\n const canvas = ref.current\n const gl = ref.current.getContext(\"webgl\", { antialias: true, stencil: true });\n if (!gl) {\n return\n }\n gl.enable(gl.BLEND);\n gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);\n const programInfo = twgl.createProgramInfo(gl, [`\n attribute vec4 position;\n uniform mat3 matrix;\n void main() {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy, 0, 1);\n }\n `, `\n precision mediump float;\n uniform vec4 color;\n void main() {\n gl_FragColor = color;\n }`]);\n const programInfo2 = twgl.createProgramInfo(gl, [`\n attribute vec4 position; \n uniform mat3 matrix;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy, 0, 1);\n texcoord = position.xy;\n }\n `, `\n precision mediump float;\n\n varying vec2 texcoord;\n uniform sampler2D texture;\n uniform vec4 color;\n\n void main() {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 ||\n texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n vec4 color = texture2D(texture, texcoord) * color;\n if (color.a < 0.1) {\n discard;\n }\n gl_FragColor = color;\n }`]);\n gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);\n const textBufferInfo = twgl.primitives.createXYQuadBufferInfo(gl);\n const programInfo3 = twgl.createProgramInfo(gl, [`\n attribute vec4 position;\n varying vec2 texcoord;\n void main() {\n gl_Position = position;\n texcoord = position.xy * .5 + .5;\n }\n `, `\n precision mediump float;\n varying vec2 texcoord;\n uniform sampler2D texture;\n void main() {\n gl_FragColor = texture2D(texture, texcoord); \n }\n `]);\n const imageBufferInfo = twgl.primitives.createXYQuadBufferInfo(gl);\n const imageTexture = twgl.createTexture(gl, {\n src: \"https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg\",\n crossOrigin: \"\",\n });\n const gradientProgramInfo = twgl.createProgramInfo(gl, [`\n attribute vec4 position;\n attribute vec4 color;\n uniform mat3 matrix;\n varying vec4 v_color;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy, 0, 1);\n v_color = color;\n }\n `, `\n precision mediump float;\n\n varying vec4 v_color;\n\n void main() {\n gl_FragColor = v_color;\n }`]);\n\n render.current = (gs, x, y, scale) => {\n gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);\n gl.useProgram(programInfo.program);\n twgl.resizeCanvasToDisplaySize(canvas);\n gl.clearColor(...gs.backgroundColor)\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT)\n\n let matrix = m3.projection(gl.canvas.width, gl.canvas.height)\n matrix = m3.multiply(matrix, m3.translation(x, y))\n if (scale !== 1) {\n matrix = m3.multiply(matrix, m3.translation(gl.canvas.width / 2, gl.canvas.height / 2));\n matrix = m3.multiply(matrix, m3.scaling(scale, scale));\n matrix = m3.multiply(matrix, m3.translation(-gl.canvas.width / 2, -gl.canvas.height / 2));\n }\n\n const objectsToDraw: twgl.DrawObject[] = []\n for (const line of gs.lines) {\n objectsToDraw.push({\n programInfo,\n bufferInfo: twgl.createBufferInfoFromArrays(gl, {\n position: {\n numComponents: 2,\n data: line.points\n },\n }),\n uniforms: {\n color: line.color,\n matrix,\n },\n type: gl.TRIANGLE_STRIP,\n })\n }\n const objectsToDraw2 = [{\n programInfo,\n bufferInfo: twgl.createBufferInfoFromArrays(gl, {\n position: {\n numComponents: 2,\n data: gs.line\n },\n }),\n uniforms: {\n color: gs.color,\n matrix,\n },\n type: gl.LINE_STRIP,\n }]\n\n const objectsToDraw3 = [{\n programInfo: gradientProgramInfo,\n bufferInfo: twgl.createBufferInfoFromArrays(gl, {\n position: {\n numComponents: 2,\n data: gs.triangles\n },\n color: {\n numComponents: 4,\n data: gs.triangleColors\n },\n }),\n uniforms: {\n matrix,\n },\n type: gl.TRIANGLES,\n }]\n\n matrix = m3.multiply(matrix, m3.translation(gs.position.x, gs.position.y))\n matrix = m3.multiply(matrix, m3.scaling(gs.canvas.width, gs.canvas.height))\n twgl.drawObjectList(gl, objectsToDraw)\n\n gl.enable(gl.STENCIL_TEST);\n gl.stencilFunc(gl.ALWAYS, 1, 0xFF);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.REPLACE);\n twgl.drawObjectList(gl, [\n {\n programInfo: programInfo2,\n bufferInfo: textBufferInfo,\n uniforms: {\n matrix,\n color: gs.color,\n texture: twgl.createTexture(gl, { src: gs.canvas }),\n },\n },\n {\n programInfo: programInfo2,\n bufferInfo: textBufferInfo,\n uniforms: {\n matrix: m3.multiply(matrix, m3.translation(1, 0)),\n color: gs.color,\n texture: twgl.createTexture(gl, { src: gs.canvas }),\n },\n },\n {\n programInfo: programInfo2,\n bufferInfo: textBufferInfo,\n uniforms: {\n matrix: m3.multiply(matrix, m3.translation(1, 1)),\n color: gs.color,\n texture: twgl.createTexture(gl, { src: gs.canvas }),\n },\n }\n ])\n\n gl.stencilFunc(gl.EQUAL, 1, 0xFF);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);\n twgl.drawObjectList(gl, [{\n programInfo: programInfo3,\n bufferInfo: imageBufferInfo,\n uniforms: {\n texture: imageTexture\n },\n }])\n gl.disable(gl.STENCIL_TEST);\n\n twgl.drawObjectList(gl, objectsToDraw2)\n\n twgl.drawObjectList(gl, objectsToDraw3)\n }\n }, [ref.current])\n\n React.useEffect(() => {\n if (render.current) {\n render.current(graphics, x + offset.x, y + offset.y, scale)\n }\n }, [graphics, render.current, x, y, offset, scale])\n\n return (\n \n onStartMoveCanvas({ x: e.clientX, y: e.clientY })}\n />\n \n {moveCanvasMask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"webgpu-3d.story",name:"",Component:se.default,code:"() => {\n const ref = React.useRef(null)\n const renderer = React.useRef>>()\n const { x, y, setX, setY, ref: wheelScrollRef } = useWheelScroll()\n const { scale, setScale, ref: wheelZoomRef } = useWheelZoom()\n const [rotate, setRotate] = React.useState({ x: 0, y: 0 })\n const { offset, onStart: onStartMoveCanvas, mask: moveCanvasMask, resetDragMove } = useDragMove(() => {\n setRotate((v) => ({ x: v.x + offset.x, y: v.y + offset.y }))\n })\n useGlobalKeyDown(e => {\n if (e.key === 'Escape') {\n resetDragMove()\n } else if (e.code === 'Digit0' && !e.shiftKey && metaKeyIfMacElseCtrlKey(e)) {\n setScale(1)\n setX(0)\n setY(0)\n setRotate({ x: 0, y: 0 })\n e.preventDefault()\n }\n })\n const size = useWindowSize()\n const width = size.width / 2\n const height = size.height\n const rotateX = offset.x + rotate.x\n const rotateY = offset.y + rotate.y\n const [hovering, setHovering] = React.useState()\n const graphics = React.useRef([\n ...getAxesGraphics(),\n {\n geometry: {\n type: 'lines',\n points: getDashedLine([0, 0, 0], [100, 100, 100], 6).flat(),\n },\n color: [0, 0, 0, 1],\n },\n {\n geometry: {\n type: 'sphere',\n radius: 100,\n },\n color: [1, 0, 0, 1],\n position: [0, 250, 0],\n },\n {\n geometry: {\n type: 'cube',\n size: 150,\n },\n color: [0, 1, 0, 1],\n position: [250, 0, 0],\n },\n {\n geometry: {\n type: 'cylinder',\n radius: 100,\n height: 200,\n },\n color: [0, 0, 1, 1],\n position: [-250, 0, 0],\n },\n {\n geometry: {\n type: 'cone',\n topRadius: 0,\n bottomRadius: 100,\n height: 200,\n },\n color: [1, 0, 1, 1],\n position: [0, -250, 0],\n },\n {\n geometry: {\n type: 'triangles',\n points: [-50, -50, 50, 50, 50, 50, -50, 50, 50],\n },\n color: [0.5, 0, 0.5, 1],\n position: [250, 250, 250],\n },\n {\n geometry: {\n type: 'vertices',\n vertices: getNurbsSurfaceVertices([\n [[0, 0, -20], [20, 0, 0], [40, 0, 0], [60, 0, 0], [80, 0, 0], [100, 0, 0]],\n [[0, -20, 0], [20, -20, 10], [40, -20, 20], [60, -20, 0], [80, -20, 0], [100, -20, 0]],\n [[0, -40, 0], [20, -40, 10], [40, -40, 20], [60, -40, 0], [80, -40, -4], [100, -40, -24]],\n [[0, -50, 0], [20, -60, 0], [40, -60, -46], [60, -60, 0], [80, -60, 0], [100, -50, 0]],\n [[0, -80, 0], [20, -80, 0], [40, -80, 0], [60, -80, 8], [80, -80, -40], [100, -80, 0]],\n [[0, -100, 24], [20, -100, 0], [40, -100, 40], [60, -100, 0], [100, -100, -20], [100, -100, -30]],\n ], 3, [0, 0, 0, 0, 0.333, 0.666, 1, 1, 1, 1], 3, [0, 0, 0, 0, 0.333, 0.666, 1, 1, 1, 1]),\n },\n color: [0, 0.5, 0, 1],\n position: [250, 250, -250],\n rotateY: Math.PI,\n },\n ])\n\n React.useEffect(() => {\n if (!ref.current) {\n return\n }\n createWebgpu3DRenderer(ref.current).then(r => {\n renderer.current = r\n setHovering(-1)\n })\n }, [ref.current])\n\n React.useEffect(() => {\n const { position, up } = updateCamera(-x, y, 1000 / scale, -0.3 * rotateX, -0.3 * rotateY)\n graphics.current.forEach((g, i) => {\n g.color[3] = i === hovering ? 0.5 : 1\n })\n renderer.current?.render?.(\n graphics.current,\n {\n eye: [position.x, position.y, position.z],\n up: [up.x, up.y, up.z],\n target: [-x, y, 0],\n fov: angleToRadian(60),\n near: 0.1,\n far: 20000,\n },\n {\n position: [1000, 1000, 1000],\n color: [1, 1, 1, 1],\n specular: [1, 1, 1, 1],\n shininess: 50,\n specularFactor: 1,\n },\n [1, 1, 1, 1],\n )\n }, [x, y, scale, rotateX, rotateY, hovering, width, height])\n\n return (\n \n onStartMoveCanvas({ x: e.clientX, y: e.clientY })}\n onMouseMove={async e => setHovering(await renderer.current?.pick?.(e.clientX, e.clientY, (g) => g.geometry.type !== 'lines' && g.geometry.type !== 'triangles'))}\n />\n {moveCanvasMask}\n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"wheel-scroll.story",name:"",Component:le.default,code:"() => {\n const { ref, x, y } = useWheelScroll({\n maxOffsetX: 250,\n maxOffsetY: 250,\n })\n return (\n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"wheel-zoom.story",name:"",Component:ce.default,code:"() => {\n const { ref, scale } = useWheelZoom()\n return (\n \n \n \n )\n}",props:[],componentName:"",parentComponentName:""},{path:"window-size.story",name:"",Component:ue.default,code:"() => {\n const { width, height } = useWindowSize()\n\n return (\n
\n {Math.round(width)} {Math.round(height)}\n
\n )\n}",props:[],componentName:"",parentComponentName:""}]},3613:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const[e,t]=o().useState(1),{zoomIn:n,zoomOut:r}=(0,i.useZoom)(e,t);return(0,i.useGlobalKeyDown)((e=>{(0,i.metaKeyIfMacElseCtrlKey)(e)&&("Minus"===e.code?r(e):"Equal"===e.code&&n(e))})),o().createElement("div",{style:{width:"300px",height:"300px",overflow:"hidden",position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid green"}},o().createElement("div",{style:{width:"800px",height:"800px",position:"absolute",transform:`scale(${e})`,background:"radial-gradient(50% 50% at 50% 50%, red 0%, white 100%)"}}))}},4565:(e,t,n)=>{"use strict";n.d(t,{default:()=>l});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=n(9299);const l=()=>{const[e,t]=i().useState(s.defaultContents),[n,o]=i().useState(0),{lineAlignmentX:l,lineAlignmentY:c,changeOffsetByLineAlignment:u,clearLineAlignments:d}=(0,a.useLineAlignment)(10),{offset:p,onStart:f,mask:h,resetDragResize:g}=(0,a.useDragResize)((()=>{d(),t((0,r.produce)(e,(e=>{e[n].x+=p.x,e[n].y+=p.y,e[n].width+=p.width,e[n].height+=p.height})))}),{centeredScaling:e=>e.shiftKey,transformOffset:(t,r,o)=>{if(!(null==r?void 0:r.metaKey)&&o){const r=e[n],i=e.filter((e=>e!==r)).map((e=>[e.x,e.x+e.width])).flat(),a=e.filter((e=>e!==r)).map((e=>[e.y,e.y+e.height])).flat();u(t,o,r,i,a)}else d();return t}});return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&g()})),i().createElement(i().Fragment,null,e.map(((e,t)=>i().createElement("div",{key:t,style:{width:`${e.width+(n===t?p.width:0)}px`,height:`${e.height+(n===t?p.height:0)}px`,left:`${e.x+(n===t?p.x:0)}px`,top:`${e.y+(n===t?p.y:0)}px`,position:"absolute",boxSizing:"border-box",border:n===t?"1px solid green":void 0},onClick:()=>o(t)},i().createElement("img",{src:e.url,style:{objectFit:"fill",width:"100%",height:"100%"}}),n===t&&i().createElement(a.ResizeBar,{onMouseDown:f})))),i().createElement(a.AlignmentLine,{type:"x",value:l}),i().createElement(a.AlignmentLine,{type:"y",value:c}),h)}},4855:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const f=()=>{const e=o().useRef(null),t=o().useRef(),{x:n,y:r,ref:a}=(0,i.useWheelScroll)(),{scale:f,ref:h}=(0,i.useWheelZoom)(),[g,m]=o().useState({x:0,y:0}),{offset:y,onStart:v,mask:x,resetDragMove:b}=(0,i.useDragMove)((()=>{m((e=>({x:e.x+y.x,y:e.y+y.y})))})),C=(0,i.useWindowSize)(),E=C.width/2,P=C.height,[k,w]=o().useState(),_=y.x+g.x,S=y.y+g.y,R=o().useRef([]);return o().useEffect((()=>{e.current&&(t.current=(0,i.createWebgl3DRenderer)(e.current))}),[e.current]),(0,i.useGlobalKeyDown)((e=>{"Escape"===e.key&&b()})),o().useEffect((()=>{const e=[65,59,80,81,56,55,40].map(((e,t)=>[20*(t+1),e,0])),t=[55,49,70,71,46,45,30].map(((e,t)=>[20*(t+1),e,20])),n=[45,39,60,61,36,35,20].map(((e,t)=>[20*(t+1),e,-20])),r=[75,69,90,91,66,65,50].map(((e,t)=>[20*(t+1),e,40])),o=(0,i.getChartAxis3D)([e,t,n,r],{x:20,y:10,z:20});R.current.push(...o,{geometry:{type:"line strip",points:e.flat()},color:[1,0,0,1]},...e.map((e=>({geometry:{type:"sphere",radius:1},color:[1,0,0,1],position:e}))),{geometry:{type:"line strip",points:(0,i.getBezierSplinePoints3D)(t,20).flat()},color:[0,1,0,1]},...t.map((e=>({geometry:{type:"sphere",radius:1},color:[0,1,0,1],position:e}))),{geometry:{type:"polygon",points:[...n.flat(),n[n.length-1][0],0,n[n.length-1][2],n[0][0],0,n[0][2]]},color:[0,0,1,1]},...n.map((e=>({geometry:{type:"sphere",radius:1},color:[0,0,1,1],position:e}))),...r.map(((e,t)=>({geometry:{type:"sphere",radius:t/2+1},color:[1,0,0,1],position:e}))))}),[]),o().useEffect((()=>{var e,o;const{position:a,up:s}=(0,i.updateCamera)(-n,r,200/f,-.3*_,-.3*S);null==(o=null==(e=t.current)?void 0:e.render)||o.call(e,R.current,{eye:[a.x+40,a.y+40,a.z],up:[s.x,s.y,s.z],target:[40-n,r+40,0],fov:(0,i.angleToRadian)(60),near:.1,far:2e3},{position:[1e3,1e3,1e3],color:[1,1,1,1],specular:[1,1,1,1],shininess:50,specularFactor:1},[1,1,1,1])}),[n,r,f,_,S,k,E,P]),o().createElement("div",{style:{position:"absolute",inset:"0px"}},o().createElement("canvas",{ref:(0,i.bindMultipleRefs)(a,h,e),width:E,height:P,onMouseDown:e=>v({x:e.clientX,y:e.clientY}),onMouseMove:e=>{var n,r;w(void 0);const o=null==(r=null==(n=t.current)?void 0:n.pick)?void 0:r.call(n,e.clientX,e.clientY,(e=>"sphere"===e.geometry.type));if(void 0!==o){const t=R.current[o];t.position&&w({value:t.position,x:e.clientX,y:e.clientY})}}}),k&&o().createElement(i.ChartTooltip,(A=((e,t)=>{for(var n in t||(t={}))u.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))d.call(t,n)&&p(e,n,t[n]);return e})({},k),T={label:(M=k.value[0]/20,Intl.DateTimeFormat("zh",{month:"long"}).format(new Date(M.toString()))),value:k.value[1]},s(A,l(T)))),x);var A,T,M}},7265:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const e=(0,i.useWindowSize)().width/2,t=i.reactSvgRenderTarget,[n,r]=o().useState(),[a,s]=o().useState(),l=e=>Intl.DateTimeFormat("zh",{month:"long"}).format(new Date(e.toString()));if(o().useEffect((()=>{const n=[65,59,80,81,56,55,40].map(((e,t)=>({x:t+1,y:e}))),r=[55,49,70,71,46,45,30].map(((e,t)=>({x:t+1,y:e}))),o=[45,39,60,61,36,35,20].map(((e,t)=>({x:t+1,y:e}))),a=[35,29,50,51,26,25,10].map(((e,t)=>({x:t+1,y:e}))),c=[75,69,90,91,66,65,50].map(((e,t)=>({x:t+1,y:e,r:3*t+5}))),u=(0,i.getLineChart)([n,r,o,a,c],t,{x:1,y:5},{width:e,height:300},{left:25,right:25,top:10,bottom:20},{getXLabel:l,ySecondary:!0});if(!u)return;const{points:[d,p,f,h,g],children:m,select:y,minY:v}=u;m.push(t.renderPolyline(d,{strokeColor:16711680})),m.push(...d.map((e=>t.renderCircle(e.x,e.y,3,{fillColor:16711680,strokeWidth:0})))),m.push(t.renderPolyline((0,i.getBezierSplinePoints)(p,50),{strokeColor:65280})),m.push(...p.map((e=>t.renderCircle(e.x,e.y,3,{fillColor:65280,strokeWidth:0})))),m.push(t.renderPolyline(f.map(((e,t)=>{const n=[e];return 0!==t&&n.unshift({x:(0,i.getTwoNumberCenter)(e.x,f[t-1].x),y:e.y}),t!==f.length-1&&n.push({x:(0,i.getTwoNumberCenter)(e.x,f[t+1].x),y:e.y}),n})).flat(),{strokeColor:255})),m.push(...f.map((e=>t.renderCircle(e.x,e.y,3,{fillColor:255,strokeWidth:0})))),m.push(t.renderPolygon([...h,{x:h[h.length-1].x,y:v},{x:h[0].x,y:v}],{fillColor:16711680,strokeWidth:0})),m.push(...h.map((e=>t.renderCircle(e.x,e.y,3,{fillColor:16711680,strokeWidth:0})))),m.push(...g.map((e=>{var n;return t.renderCircle(e.x,e.y,null!=(n=e.r)?n:5,{fillColor:65280,strokeWidth:0})}))),s({children:m,select:y})}),[e]),!a)return null;let c=a.children;return n&&(c=[...a.children,...(0,i.renderChartTooltip)(t,n,n.value,{getXLabel:l})]),o().createElement("div",{style:{position:"absolute",inset:"0px"}},t.renderResult(c,e,300,{attributes:{onMouseMove:e=>r(a.select({x:e.clientX,y:e.clientY}))}}))}},2754:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{line:n,onClick:o,onMove:s,input:l,reset:c}=(0,a.useLineClickCreate)(!0,(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c(!0)})),i().createElement("div",{style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY})},[...e,n].map(((e,t)=>e&&i().createElement("polyline",{key:t,stroke:"#00ff00",points:e.map((e=>`${e.x},${e.y}`)).join(" ")})))),l)}},8208:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(4469);const s=()=>{const e={p1:{x:200,y:200},p2:{x:300,y:300},position:{x:400,y:100},fontFamily:"monospace",fontSize:16,direct:!0},{regions:t,lines:n}=(0,i.getLinearDimensionGeometries)(e,a.dimensionStyle,(e=>(0,i.getLinearDimensionTextPosition)(e,a.dimensionStyle.margin,i.getTextSize))),{textPosition:r,textRotation:s,text:l}=(0,i.getLinearDimensionTextPosition)(e,a.dimensionStyle.margin,i.getTextSize);return o().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0}},n.map(((e,t)=>o().createElement("polyline",{key:t,stroke:"black",points:e.map((e=>`${e.x},${e.y}`)).join(" ")}))),t[0]&&o().createElement("polyline",{stroke:"black",points:t[0].points.map((e=>`${e.x},${e.y}`)).join(" "),fill:"black"}),t[1]&&o().createElement("polyline",{stroke:"black",points:t[1].points.map((e=>`${e.x},${e.y}`)).join(" "),fill:"black"}),o().createElement("text",{x:r.x,y:r.y,fill:"black",transform:(0,i.getRotateTransform)(r.x,r.y,{rotation:s}),style:{fontSize:`${e.fontSize}px`,fontFamily:e.fontFamily}},l))}},6821:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>o().createElement(i.Menu,{items:[{title:"item 1",children:[{title:"item 1 child 1"},{title:"item 1 child 2",children:[{title:"item 1 child 2 child 1"},{title:"item 1 child 2 child 2"}]}]},{title:"item 2",children:[{title:"item 2 child 1"},{title:"item 2 child 2 disabled",disabled:!0}]},{type:"divider"},{title:"item 3"}],style:{left:"100px",top:"100px"}})},425:(e,t,n)=>{"use strict";n.d(t,{default:()=>d});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const d=()=>{const{ref:e,x:t,setX:n,y:r,setY:a}=(0,i.useWheelScroll)(),{ref:d,scale:p}=(0,i.useWheelZoom)({onChange(e,t,r){const o=(0,i.scaleByCursorPosition)({width:g,height:m},t/e,r);n(o.setX),a(o.setY)}}),f=i.reactSvgRenderTarget,h=(0,i.useWindowSize)(),g=h.width/2,m=h.height/2,y={x:t,y:r,scale:p,center:{x:g/2,y:m/2}},v=[f.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,0,1200,800)],{setMinimapTransform:x,minimap:b,getMinimapPosition:C}=(0,i.useMinimap)({width:100,height:100,viewport:{width:g/y.scale,height:m/y.scale,center:(0,i.reverseTransformPosition)(y.center,y)},children:e=>f.renderResult(v,100,100,{transform:e,attributes:{onClick:e=>{if(C){const t=C(e);n((y.center.x-t.x)*y.scale),a((y.center.y-t.y)*y.scale)}}}})});return o().useEffect((()=>{const e={start:{x:0,y:0},end:{x:1200,y:800}},t=(0,i.zoomToFit)(e,{width:100,height:100},{x:50,y:50},1);t&&x(((e,t)=>{for(var n in t||(t={}))l.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))c.call(t,n)&&u(e,n,t[n]);return e})({bounding:e},t))}),[]),o().createElement("div",{ref:(0,i.bindMultipleRefs)(e,d),style:{position:"absolute",inset:"0px"}},f.renderResult(v,g,m,{transform:y,attributes:{style:{border:"1px solid green"}}}),b)}},6856:(e,t,n)=>{"use strict";n.d(t,{default:()=>l});var r=n(3696),o=n.n(r),i=n(7469),a=n(9758),s=n(3385);const l=()=>{const e=(0,a.useWindowSize)().width/2,{x:t,y:n,ref:r,setX:l,setY:u}=(0,a.useWheelScroll)(),{scale:d,setScale:p,ref:f}=(0,a.useWheelZoom)({onChange(t,n,r){const o=(0,a.scaleByCursorPosition)({width:e,height:300},n/t,r);l(o.setX),u(o.setY)}}),[h,g]=o().useState(),[m,y]=o().useState("测试ABC"),[v,x]=o().useState(s.allFonts[0].name),[b,C]=o().useState(50),[E,P]=o().useState(0),[k,w]=o().useState(16777215),[_,S]=o().useState(1),[R,A]=o().useState(1),[T,M]=o().useState([]),[L,I]=o().useState(c[0]),O=null==h?void 0:h[v];o().useEffect((()=>{var e;e=function*(){const e={};for(const t of s.allFonts){const n=yield fetch(t.url),r=yield n.arrayBuffer();e[t.name]=i.parse(r)}g(e)},new Promise(((t,n)=>{var r=t=>{try{i(e.next(t))}catch(e){n(e)}},o=t=>{try{i(e.throw(t))}catch(e){n(e)}},i=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,o);i((e=e.apply(undefined,null)).next())}))}),[]),(0,a.useGlobalKeyDown)((e=>{"Digit0"===e.code&&!e.shiftKey&&(0,a.metaKeyIfMacElseCtrlKey)(e)&&(p(1),l(0),u(0),e.preventDefault())})),o().useEffect((()=>{if(!O)return;const e=O.getPaths(m,0,b,b,{xScale:_*b/O.unitsPerEm,yScale:R*b/O.unitsPerEm}).map((e=>(0,s.opentypeCommandsToPathCommands)(e)));M(e)}),[m,O,b,L,_,R]);const B=T.map((e=>L.renderPathCommands(e,{fillColor:E,strokeColor:E}))).flat();return B.push(L.renderText(0,2*b,m,E,b*Math.max(_,R),v)),o().createElement("div",{style:{position:"absolute",inset:"0px"},ref:(0,a.bindMultipleRefs)(f,r)},L.renderResult(B,e,300,{transform:{x:t,y:n,scale:d},backgroundColor:k}),o().createElement("div",{style:{display:"flex",width:`${e}px`}},o().createElement(a.ObjectEditor,{inline:!0,properties:{text:o().createElement(a.StringEditor,{value:m,setValue:e=>y(e)}),"font family":o().createElement(a.EnumEditor,{select:!0,value:v,enums:s.allFonts.map((e=>e.name)),setValue:e=>{var t,n;return x(null!=(n=null==(t=s.allFonts.find((t=>t.name===e)))?void 0:t.name)?n:s.allFonts[0].name)}}),"font size":o().createElement(a.NumberEditor,{value:b,setValue:e=>C(e)}),"render target":o().createElement(a.EnumEditor,{select:!0,value:L.type,enums:c.map((e=>e.type)),setValue:e=>{var t;return I(null!=(t=c.find((t=>t.type===e)))?t:c[0])}}),color:o().createElement(a.NumberEditor,{type:"color",value:E,setValue:e=>P(e)}),"background color":o().createElement(a.NumberEditor,{type:"color",value:k,setValue:e=>w(e)}),"x scale":o().createElement(a.NumberEditor,{value:_,setValue:e=>S(e)}),"y scale":o().createElement(a.NumberEditor,{value:R,setValue:e=>A(e)}),actions:o().createElement(a.Button,{onClick:()=>navigator.clipboard.writeText(JSON.stringify({contents:T.map(((e,t)=>({id:t,content:{type:"path",commands:e,strokeColor:E,fillColor:E}}))),center:{x:0,y:0}}))},"copy as command path")}})))},c=[a.reactCanvasRenderTarget,a.reactSvgRenderTarget,a.reactWebglRenderTarget]},3385:(e,t,n)=>{"use strict";n.d(t,{allFonts:()=>a,opentypeCommandsToPathCommands:()=>o});var r=n(9758);function o(e,t){const n=[];for(const r of e.commands)"M"===r.type?n.push({type:"move",to:i({x:r.x,y:r.y},t)}):"L"===r.type?n.push({type:"line",to:i({x:r.x,y:r.y},t)}):"C"===r.type?n.push({type:"bezierCurve",cp1:i({x:r.x1,y:r.y1},t),cp2:i({x:r.x2,y:r.y2},t),to:i({x:r.x,y:r.y},t)}):"Q"===r.type?n.push({type:"quadraticCurve",cp:i({x:r.x1,y:r.y1},t),to:i({x:r.x,y:r.y},t)}):n.push({type:"close"});return n}function i(e,t){return void 0!==t&&(0,r.skewPoint)(e,{x:0,y:t},-.15),e}const a=[{name:"STSong",url:"https://raw.githubusercontent.com/Haixing-Hu/latex-chinese-fonts/master/chinese/%E5%AE%8B%E4%BD%93/STSong.ttf"},{name:"Arial",url:"https://raw.githubusercontent.com/Haixing-Hu/latex-chinese-fonts/master/english/Sans/Arial.ttf"}]},5047:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState({value:1,children:[{value:10},{value:100}]}),{editingContent:n,setEditingContentPath:o,prependPatchPath:s}=(0,a.usePartialEdit)(e);return i().createElement(i().Fragment,null,i().createElement("button",{onClick:()=>{const[,o]=(0,r.produceWithPatches)(n,(e=>{e.value++}));t((0,r.applyPatches)(e,s(o)))}},"+1"),i().createElement("button",{onClick:()=>o([])},"exit"),i().createElement("div",null,n.value,n.children&&n.children.map(((e,t)=>i().createElement("button",{key:t,style:{width:"50px",height:"50px"},onClick:()=>o(["children",t])},e.value)))))}},5836:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(3696),o=n.n(r),i=n(9758);const a={count:0},s=()=>{const{state:e,setState:t,undo:n,redo:r}=(0,i.usePatchBasedUndoRedo)(a,"a");return(0,i.useGlobalKeyDown)((e=>{"KeyZ"===e.code&&(0,i.metaKeyIfMacElseCtrlKey)(e)&&(e.shiftKey?r(e):n(e))})),o().createElement("button",{onClick:()=>t((e=>{e.count++})),style:{width:"200px",height:"100px"}},e.count)}},5207:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{preview:n,onClick:o,onMove:s,input:l,setInputType:c,reset:u}=(0,a.usePathClickCreate)(!0,(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&u(!0)})),i().createElement("div",{style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY})},[...e,n].map(((e,t)=>e&&a.reactSvgRenderTarget.renderPathCommands(e,{strokeColor:65280})(t,1,!1,800,600)))),["line","arc","bezierCurve","quadraticCurve","close"].map((e=>i().createElement("button",{key:e,style:{position:"relative"},onClick:()=>c(e)},e))),l)}},5779:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{points:n,onClick:o,onMove:s,reset:l}=(0,a.usePenClickCreate)(!0,(()=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()})),i().createElement("div",{style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY})},[...e,n].map(((e,t)=>e&&i().createElement("polyline",{key:t,stroke:"#00ff00",points:e.map((e=>`${e.x},${e.y}`)).join(" ")})))))}},2890:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{var e,t;const n=(0,i.useWindowSize)(),r=n.width/2,a=n.height,s=i.reactCanvasRenderTarget,l={x:r/2,y:a/3},[c,u]=o().useState(r/2),[d,p]=o().useState(!1),[f,h]=o().useState({radian:-Math.PI/4,speed:0}),[g,m]=o().useState(),[y,v,x]=(0,i.useRefState)(!1),[b,C,E]=(0,i.useRefState2)(),P=null!=(e=null!=b?b:g)?e:f,k=null!=(t=null==g?void 0:g.length)?t:c,w={x:l.x-k*Math.sin(P.radian),y:l.y+k*Math.cos(P.radian),r:10},_=(0,i.getPointByLengthAndRadian)(w,P.speed*k+w.r*(P.speed>=0?1:-1),(0,i.getTwoPointsRadian)(w,l)+Math.PI/2),S=[s.renderCircle(l.x,l.y,5),s.renderCircle(w.x,w.y,w.r,{fillColor:0,strokeWidth:0}),s.renderPolyline([l,w]),s.renderPolyline([w,_])],R=(0,i.useEvent)((()=>{g&&(h(g),u(g.length),p(!1),m(void 0))})),A=(0,i.useEvent)((e=>{if(d){const t={x:e.clientX,y:e.clientY};m({radian:(0,i.getTwoPointsRadian)(t,l)-Math.PI/2,speed:0,length:(0,i.getTwoPointsDistance)(t,l)})}}));return o().createElement("div",{style:{position:"absolute",inset:"0px"},onMouseMove:A},s.renderResult(S,r,a,{attributes:{onClick:R}}),o().createElement("div",{style:{position:"absolute",top:"0px"}},o().createElement(i.Button,{onClick:()=>{if(x.current)return void v(!1);let e;v(!0);const t=n=>{var r;if(x.current){if(void 0!==e){const t=.005*(n-e),o=null!=(r=E.current)?r:f,i=l.y+k*Math.cos(f.radian),a=l.y+k*Math.cos(o.radian),s=9.8;let c=o.speed-s*Math.sin(o.radian)/k*t;if(a!==i){const e=Math.sqrt(s*Math.abs(a-i)*2)/k;e{v(!1),C(void 0)}},"stop"),void 0===b&&o().createElement(i.Button,{style:{color:d?"red":void 0},onClick:()=>p(!0)},"edit")))}},1993:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const e=(0,i.useWindowSize)().width/2,t=350,n=i.reactSvgRenderTarget,[r,a]=o().useState(),[s,l]=o().useState(),[c,u]=o().useState(),[d,p]=o().useState(),f=e=>Intl.DateTimeFormat("zh",{month:"long"}).format(new Date(e.toString()));if(o().useEffect((()=>{const r=[[65,59,80,81,56,55,40],[75,49,70,71,46,45,30],[85,39,60,61,36,35,20]],o=[16711680,65280,255,16711680,65280,255,0];u((0,i.getPieChart)(r,o,n,{width:e,height:t},{left:10,right:10,top:10,bottom:10})),p((0,i.getPieChart)(r,o,n,{width:e,height:t},{left:10,right:10,top:10,bottom:10},{type:"doughnut"}))}),[e]),!c||!d)return null;let h=c.children;r&&(h=[...c.children,...(0,i.renderChartTooltip)(n,r,r.value,{getXLabel:f})]);let g=d.children;return s&&(g=[...d.children,...(0,i.renderChartTooltip)(n,s,s.value,{getXLabel:f})]),o().createElement("div",{style:{position:"absolute",inset:"0px",display:"flex",flexDirection:"column"}},n.renderResult(h,e,t,{attributes:{onMouseMove:e=>a(c.select({x:e.clientX,y:e.clientY}))}}),n.renderResult(g,e,t,{attributes:{onMouseMove:e=>l(d.select({x:e.clientX,y:e.clientY-t}))}}))}},7631:(e,t,n)=>{"use strict";n.d(t,{default:()=>h});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))c.call(t,n)&&u(e,n,t[n]);return e};const p=new i.WeakmapCache2,f=[{x:300,y:200,r:100},{x:450,y:350,r:130}],h=()=>{const[e,t]=o().useState(),n={x:500,y:100},{getSnapAssistentContents:r,getSnapPoint:a}=(0,i.usePointSnap)(!0,((e,t)=>p.get(e,t,(()=>Array.from((0,i.iterateIntersectionPoints)(e,t,f,(()=>({getGeometries:e=>({lines:[{type:"arc",curve:(0,i.circleToArc)(e)}]})}))))))),i.allSnapTypes,(()=>({getSnapPoints:e=>[{x:e.x,y:e.y,type:"center"},{x:e.x-e.r,y:e.y,type:"endpoint"},{x:e.x+e.r,y:e.y,type:"endpoint"},{x:e.x,y:e.y-e.r,type:"endpoint"},{x:e.x,y:e.y+e.r,type:"endpoint"}],getGeometries:e=>({lines:[{type:"arc",curve:(0,i.circleToArc)(e)}],bounding:{start:{x:e.x-e.r,y:e.y-e.r},end:{x:e.x+e.r,y:e.y+e.r}}})}))),s=r((e=>d({type:"circle"},e)),(e=>d({type:"rect"},e)),(e=>({type:"polyline",points:e})));return e&&s.push({type:"polyline",points:[n,e]}),o().createElement(o().Fragment,null,o().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onMouseMove:e=>t(a({x:e.clientX,y:e.clientY},f,void 0,n).position)},f.map(((e,t)=>o().createElement("circle",{key:t,cx:e.x,cy:e.y,r:e.r,stroke:"#00ff00"}))),s.map(((e,t)=>"rect"===e.type?o().createElement("rect",{key:t,x:e.x-e.width/2,y:e.y-e.height/2,width:e.width,height:e.height,stroke:"#00ff00"}):"circle"===e.type?o().createElement("circle",{key:t,cx:e.x,cy:e.y,r:e.r,stroke:"#00ff00"}):o().createElement("polyline",{key:t,points:e.points.map((e=>`${e.x},${e.y}`)).join(" "),stroke:"#00ff00"}))),e&&o().createElement("circle",{cx:e.x,cy:e.y,r:5,stroke:"#ff0000"})))}},277:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const f=()=>{const e=(0,i.useWindowSize)().width/2,t=i.reactSvgRenderTarget,[n,r]=o().useState(),[a,f]=o().useState(),h=e=>Intl.DateTimeFormat("zh",{month:"long"}).format(new Date((e+1).toString()));if(o().useEffect((()=>{const n=(0,i.getPolarAreaChart)([65,59,80,81,56,55,40],[16711680,65280,255,16711680,65280,255,0],t,{width:e,height:350},10,{left:10,right:10,top:30,bottom:10});n.angles.forEach(((e,r)=>{const o=(0,i.getArcPointAtAngle)((a=((e,t)=>{for(var n in t||(t={}))u.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))d.call(t,n)&&p(e,n,t[n]);return e})({},n.circle),f={r:n.circle.r+30},s(a,l(f))),e);var a,f;n.children.push(t.renderText(o.x,o.y,h(r),13421772,20,"monospace",{textAlign:"center",textBaseline:"middle"}))})),f(n)}),[e]),!a)return null;let g=a.children;return n&&(g=[...a.children,...(0,i.renderChartTooltip)(t,n,n.value,{getXLabel:h})]),o().createElement("div",{style:{position:"absolute",inset:"0px",display:"flex",flexDirection:"column"}},t.renderResult(g,e,350,{attributes:{onMouseMove:e=>r(a.select({x:e.clientX,y:e.clientY}))}}))}},574:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{polygon:n,onClick:o,onMove:s,input:l,reset:c}=(0,a.usePolygonClickCreate)(!0,(o=>{const i=o||n;i&&t((0,r.produce)(e,(e=>{e.push(i)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()})),i().createElement("div",{style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY})},[...e,n].map(((e,t)=>e&&i().createElement("polygon",{key:t,stroke:"#00ff00",points:e.map((e=>`${e.x},${e.y}`)).join(" ")})))),l)}},597:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([{x:100,y:100},{x:300,y:200},{x:100,y:200}]),{offset:n,onStart:o,mask:s,reset:l}=(0,a.usePolylineEdit)((()=>t(c))),c=(0,r.produce)(e,(e=>{if(n)for(const t of n.pointIndexes)e[t].x+=n.x,e[t].y+=n.y}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&l()})),i().createElement(i().Fragment,null,i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0}},i().createElement("polyline",{stroke:"#00ff00",points:c.map((e=>`${e.x},${e.y}`)).join(" ")})),i().createElement(a.PolylineEditBar,{points:c,onMouseDown:(e,t)=>o(e,t)}),s)}},4623:(e,t,n)=>{"use strict";n.d(t,{default:()=>f});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const f=()=>{const e=(0,i.useWindowSize)().width/2,t=i.reactSvgRenderTarget,[n,r]=o().useState(),[a,f]=o().useState(),h=e=>Intl.DateTimeFormat("zh",{month:"long"}).format(new Date((e+1).toString()));if(o().useEffect((()=>{const n=(0,i.getRadarChart)([[65,59,80,81,56,55,40],[45,39,60,61,36,35,20]],[16711680,65280],t,{width:e,height:350},20,{left:10,right:10,top:30,bottom:30});n.angles.forEach(((e,r)=>{const o=(0,i.getArcPointAtAngle)((a=((e,t)=>{for(var n in t||(t={}))u.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))d.call(t,n)&&p(e,n,t[n]);return e})({},n.circle),f={r:n.circle.r+15},s(a,l(f))),e);var a,f;n.children.push(t.renderText(o.x,o.y,h(r),13421772,12,"monospace",{textAlign:"center",textBaseline:"middle"}))})),f(n)}),[e]),!a)return null;let g=a.children;return n&&(g=[...a.children,...(0,i.renderChartTooltip)(t,n,n.value,{getXLabel:h})]),o().createElement("div",{style:{position:"absolute",inset:"0px",display:"flex",flexDirection:"column"}},t.renderResult(g,e,350,{attributes:{onMouseMove:e=>r(a.select({x:e.clientX,y:e.clientY}))}}))}},4922:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(4469);const s=()=>{const e={x:200,y:200,r:100},t={position:{x:400,y:300},fontFamily:"monospace",fontSize:16},{regions:n,lines:r}=(0,i.getRadialDimensionGeometries)(t,e,a.dimensionStyle,((e,t)=>(0,i.getRadialDimensionTextPosition)(e,t,a.dimensionStyle.margin,i.getTextSize))),{textPosition:s,textRotation:l,text:c}=(0,i.getRadialDimensionTextPosition)(t,e,a.dimensionStyle.margin,i.getTextSize);return o().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0}},o().createElement("circle",{cx:e.x,cy:e.y,r:e.r,stroke:"black"}),r.map(((e,t)=>o().createElement("polyline",{key:t,stroke:"black",points:e.map((e=>`${e.x},${e.y}`)).join(" ")}))),n&&n.length>0&&o().createElement("polyline",{stroke:"black",points:n[0].points.map((e=>`${e.x},${e.y}`)).join(" "),fill:"black"}),o().createElement("text",{x:s.x,y:s.y,fill:"black",transform:(0,i.getRotateTransform)(s.x,s.y,{rotation:l}),style:{fontSize:`${t.fontSize}px`,fontFamily:t.fontFamily}},c))}},5982:(e,t,n)=>{"use strict";n.d(t,{default:()=>h});var r=n(3696),o=n(9758),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))u.call(t,n)&&d(e,n,t[n]);return e},f=(e,t)=>a(e,s(t));const h=()=>{const[e,t]=r.useState(!1),{value:n,update:i,getArrayProps:a}=(0,o.useJsonEditorData)({stringExample:"a string example",booleanExample:!1,numberExample:123.4,objectExample:{propertyExample1:"",propertyExample2:0},inlineObjectExample:{propertyExample1:"",propertyExample2:0},arrayExample:["item1","item2"],inlineArrayExample:["item1","item2"],optionalExample:void 0,enumExample:"enum 1",colorExample:"#000000",textareaExample:"",imagePreviewExample:"http://image2.sina.com.cn/bj/art/2004-08-02/U91P52T4D51657F160DT20040802125523.jpg",itemTitleExample:[{propertyExample1:"foo",propertyExample2:1},{propertyExample1:"bar",propertyExample2:2}],inlineObjectArrayExample:[{propertyExample1:"foo",propertyExample2:1,propertyExample3:{propertyExample4:2,propertyExample5:""}},{propertyExample1:"bar",propertyExample2:2,propertyExample3:{propertyExample4:3,propertyExample5:""}}],enumTitlesExample:"enum 1",enumArrayExample:["foo"]}),s=JSON.stringify(n,null," ");return r.createElement("div",{style:{position:"relative"}},r.createElement(o.BooleanEditor,{style:{display:"inline"},value:e,setValue:e=>t(e)})," read only",r.createElement("br",null),r.createElement("div",{style:{height:"400px",margin:"10px",position:"absolute",overflowY:"auto"}},r.createElement(o.ObjectEditor,{properties:{"A string example":r.createElement(o.StringEditor,{value:n.stringExample,setValue:i(((e,t)=>e.stringExample=t))}),"A boolean example":r.createElement(o.BooleanEditor,{value:n.booleanExample,setValue:i(((e,t)=>e.booleanExample=t))}),"A number example":r.createElement(o.NumberEditor,{value:n.numberExample,setValue:i(((e,t)=>e.numberExample=t))}),"A object example":r.createElement(o.ObjectEditor,{properties:{"Property example 1":r.createElement(o.StringEditor,{value:n.objectExample.propertyExample1,setValue:i(((e,t)=>e.objectExample.propertyExample1=t))}),"Property example 2":r.createElement(o.NumberEditor,{value:n.objectExample.propertyExample2,setValue:i(((e,t)=>e.objectExample.propertyExample2=t))})}}),"A inline object example":r.createElement(o.ObjectEditor,{inline:!0,properties:{"Property example 1":r.createElement(o.StringEditor,{value:n.inlineObjectExample.propertyExample1,setValue:i(((e,t)=>e.inlineObjectExample.propertyExample1=t))}),"Property example 2":r.createElement(o.NumberEditor,{value:n.inlineObjectExample.propertyExample2,setValue:i(((e,t)=>e.inlineObjectExample.propertyExample2=t))})}}),"A array example":r.createElement(o.ArrayEditor,f(p({},a((e=>e.arrayExample),"")),{items:n.arrayExample.map(((e,t)=>r.createElement(o.StringEditor,{value:e,setValue:i(((e,n)=>e.arrayExample[t]=n))})))})),"A inline array example":r.createElement(o.ArrayEditor,f(p({inline:!0},a((e=>e.inlineArrayExample),"")),{items:n.inlineArrayExample.map(((e,t)=>r.createElement(o.StringEditor,{value:e,setValue:i(((e,n)=>e.inlineArrayExample[t]=n))})))})),"A optional example":[r.createElement(o.BooleanEditor,{value:void 0!==n.optionalExample,setValue:i(((e,t)=>e.optionalExample=t?"":void 0))}),void 0!==n.optionalExample?r.createElement(o.StringEditor,{value:n.optionalExample,setValue:i(((e,t)=>e.optionalExample=t))}):void 0],"A enum example":r.createElement(o.EnumEditor,{value:n.enumExample,enums:["enum 1","enum 2"],setValue:i(((e,t)=>e.enumExample=t))}),"A enum example 2":r.createElement(o.EnumEditor,{select:!0,value:n.enumExample,enums:["enum 1","enum 2"],setValue:i(((e,t)=>e.enumExample=t))}),"A color example":r.createElement(o.StringEditor,{type:"color",value:n.colorExample,setValue:i(((e,t)=>e.colorExample=t))}),"A textarea example":r.createElement(o.StringEditor,{textarea:!0,value:n.textareaExample,setValue:i(((e,t)=>e.textareaExample=t))}),"A image preview example":r.createElement(o.StringEditor,{value:n.imagePreviewExample,setValue:i(((e,t)=>e.imagePreviewExample=t))}),"A item title example":r.createElement(o.ArrayEditor,f(p({},a((e=>e.itemTitleExample),{propertyExample1:"",propertyExample2:0})),{title:e=>n.itemTitleExample[e].propertyExample1,items:n.itemTitleExample.map(((e,t)=>r.createElement(o.ObjectEditor,{properties:{"Property example 1":r.createElement(o.StringEditor,{value:e.propertyExample1,setValue:i(((e,n)=>e.itemTitleExample[t].propertyExample1=n))}),"Property example 2":r.createElement(o.NumberEditor,{value:e.propertyExample2,setValue:i(((e,n)=>e.itemTitleExample[t].propertyExample2=n))})}})))})),"A inline object array example":r.createElement(o.ObjectArrayEditor,f(p({},a((e=>e.inlineObjectArrayExample),{propertyExample1:"",propertyExample2:0,propertyExample3:{propertyExample4:0,propertyExample5:""}})),{properties:n.inlineObjectArrayExample.map(((e,t)=>({"Property example 1":r.createElement(o.StringEditor,{value:e.propertyExample1,setValue:i(((e,n)=>e.inlineObjectArrayExample[t].propertyExample1=n))}),"Property example 2":r.createElement(o.NumberEditor,{value:e.propertyExample2,setValue:i(((e,n)=>e.inlineObjectArrayExample[t].propertyExample2=n))}),"Property example 3":r.createElement(o.DialogContainer,null,r.createElement(o.ObjectEditor,{inline:!0,properties:{"Property example 3":r.createElement(o.NumberEditor,{value:e.propertyExample3.propertyExample4,setValue:i(((e,n)=>e.inlineObjectArrayExample[t].propertyExample3.propertyExample4=n))}),"Property example 4":r.createElement(o.StringEditor,{value:e.propertyExample3.propertyExample5,setValue:i(((e,n)=>e.inlineObjectArrayExample[t].propertyExample3.propertyExample5=n))})}}))})))})),"A enum titles example":r.createElement(o.EnumEditor,{enumTitles:["enum title 1","enum title 2"],value:n.enumTitlesExample,enums:["enum 1","enum 2"],setValue:i(((e,t)=>e.enumTitlesExample=t))}),"A enum array example":r.createElement(o.EnumArrayEditor,{enumTitles:["foo title","bar title"],value:n.enumArrayExample,enums:["foo","bar"],setValue:i(((e,t)=>e.enumArrayExample=t))})},readOnly:e})),r.createElement("div",{style:{margin:"10px",position:"absolute",top:"450px"}},r.createElement("pre",{style:{borderColor:"black",padding:"10px"}},r.createElement("code",{dangerouslySetInnerHTML:{__html:s}}))))}},7560:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(5052);const s=()=>{const e=e=>e.renderResult([e.renderArc(40,20,50,0,120,{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderArc(40,40,80,0,120,{fillColor:16711680,strokeWidth:0}),e.renderArc(50,50,100,0,120,{strokeColor:65280}),e.renderArc(60,60,100,0,120,{strokeWidth:5}),e.renderArc(70,70,100,0,120,{dashArray:[4]}),e.renderArc(170,170,30,0,120,{counterclockwise:!0}),e.renderArc(170,170,20,120,0,{counterclockwise:!0}),e.renderArc(120,200,15,0,360),e.renderArc(120,200,10,360,0,{counterclockwise:!0}),e.renderArc(170,170,10,0,120,{closed:!0})],230,310),t=e=>e.renderResult([e.renderCircle(70,100,30,{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderCircle(150,100,30,{fillColor:16711680,strokeWidth:0}),e.renderCircle(110,100,70,{strokeColor:65280}),e.renderCircle(110,100,80,{strokeWidth:5}),e.renderCircle(110,100,90,{dashArray:[4]})],230,200),n=e=>e.renderResult([e.renderText(10,30,"Hello World!",16711680,30,"monospace"),e.renderText(10,60,"Hello World!",16711680,30,"monospace",{fontWeight:"bold"}),e.renderText(10,90,"Hello World!",16711680,30,"monospace",{fontStyle:"italic"}),e.renderText(10,150,"He",{width:4,height:4,pattern:()=>e.renderPath([[{x:0,y:2},{x:2,y:0}],[{x:4,y:2},{x:2,y:4}]],{strokeColor:255})},70,"monospace"),e.renderText(90,150,"l",void 0,70,"monospace",{strokeColor:16711680}),e.renderText(130,150,"l",void 0,70,"monospace",{strokeColor:16711680,dashArray:[2]}),e.renderText(170,150,"l",void 0,70,"monospace",{strokeColor:16711680,strokeWidth:3}),e.renderText(10,200,"H",65280,70,"monospace",{strokeColor:16711680,strokeWidth:3}),e.renderText(50,200,"H",65280,70,"monospace",{strokeColor:16711680,strokeWidth:3,strokeOpacity:.3,fillOpacity:.3}),e.renderText(90,200,"H",void 0,70,"monospace",{strokePattern:{width:4,height:4,pattern:()=>e.renderPath([[{x:0,y:2},{x:2,y:0}],[{x:4,y:2},{x:2,y:4}]],{strokeColor:255})},strokeWidth:3}),e.renderText(130,200,"H",void 0,70,"monospace",{strokeLinearGradient:{start:{x:150,y:230},end:{x:190,y:150},stops:[{offset:.2,color:16711680},{offset:.5,color:16776960},{offset:.8,color:65280}]},strokeWidth:3}),e.renderText(170,200,"H",void 0,70,"monospace",{strokeRadialGradient:{start:{x:190,y:185,r:5},end:{x:190,y:180,r:30},stops:[{offset:0,color:16711680},{offset:.5,color:16776960},{offset:1,color:65280}]},strokeWidth:3}),e.renderText(70,225,"center",65280,30,"monospace",{textAlign:"center"}),e.renderText(130,250,"right",65280,30,"monospace",{textAlign:"right"}),e.renderText(130,250,"H",void 0,70,"monospace",{fillLinearGradient:{start:{x:150,y:280},end:{x:190,y:200},stops:[{offset:.2,color:16711680},{offset:.5,color:16776960},{offset:.8,color:65280}]},strokeWidth:3}),e.renderText(170,250,"H",void 0,70,"monospace",{fillRadialGradient:{start:{x:190,y:235,r:5},end:{x:190,y:230,r:30},stops:[{offset:0,color:16711680},{offset:.5,color:16776960},{offset:1,color:65280}]},strokeWidth:3}),e.renderText(10,300,"fgj",65280,30,"monospace",{textBaseline:"alphabetic"}),e.renderText(65,300,"fgj",65280,30,"monospace",{textBaseline:"top"}),e.renderText(120,300,"fgj",65280,30,"monospace",{textBaseline:"middle"}),e.renderText(175,300,"fgj",65280,30,"monospace",{textBaseline:"bottom"})],230,550),r=e=>e.renderResult([e.renderEllipseArc(40,10,50,30,0,120,{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderEllipseArc(40,30,80,40,0,120,{fillColor:16711680,strokeWidth:0}),e.renderEllipseArc(50,40,100,50,0,120,{strokeColor:65280}),e.renderEllipseArc(60,50,100,50,0,120,{strokeWidth:5}),e.renderEllipseArc(70,60,100,50,0,120,{dashArray:[4]}),e.renderEllipseArc(170,160,30,15,0,120,{counterclockwise:!0}),e.renderEllipseArc(170,160,30,25,120,20,{counterclockwise:!0}),e.renderEllipseArc(110,100,80,40,0,120,{strokeColor:65280,angle:30}),e.renderEllipseArc(120,200,30,15,0,360),e.renderEllipseArc(120,200,20,10,360,0,{counterclockwise:!0}),e.renderEllipseArc(170,160,25,20,0,120,{closed:!0})],230,330),s=e=>e.renderResult([e.renderEllipse(70,60,40,20,{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderEllipse(150,60,40,20,{fillColor:16711680,strokeWidth:0}),e.renderEllipse(110,60,90,45,{strokeColor:65280}),e.renderEllipse(110,60,100,50,{strokeWidth:5}),e.renderEllipse(110,60,110,55,{dashArray:[4]}),e.renderEllipse(110,140,80,40,{strokeColor:255,angle:30}),e.renderEllipse(110,30,10,20,{angle:60,fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}})],230,230),l=e=>e.renderResult([e.renderRect(10,10,50,30,{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderRect(70,10,80,40,{fillColor:16711680,strokeWidth:0}),e.renderRect(90,60,100,140,{strokeColor:65280}),e.renderRect(100,70,80,120,{strokeWidth:5}),e.renderRect(110,80,60,100,{dashArray:[4]}),e.renderRect(10,90,60,30,{angle:60})],230,220),c=e=>e.renderResult([e.renderPath([[{x:5,y:10},{x:45,y:150},{x:45,y:10}],[{x:25,y:30},{x:25,y:70},{x:35,y:70},{x:35,y:30}]],{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})},strokeWidth:0}),e.renderPath([[{x:50,y:10},{x:90,y:150},{x:90,y:10}],[{x:70,y:30},{x:70,y:70},{x:80,y:70},{x:80,y:30}]],{fillColor:16711680,strokeWidth:0}),e.renderPath([[{x:95,y:10},{x:135,y:150},{x:135,y:10}],[{x:115,y:30},{x:115,y:70},{x:125,y:70},{x:125,y:30}]],{strokeColor:65280}),e.renderPath([[{x:140,y:10},{x:180,y:150},{x:180,y:10}],[{x:160,y:30},{x:160,y:70},{x:170,y:70},{x:170,y:30}]],{fillPattern:{width:100,height:100,pattern:()=>e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,0,100,100,{crossOrigin:""})},strokeWidth:0}),e.renderPath([[{x:185,y:10},{x:225,y:150},{x:225,y:10}],[{x:205,y:30},{x:205,y:70},{x:215,y:70},{x:215,y:30}]],{dashArray:[4]}),e.renderPath([[{x:5,y:160},{x:35,y:160},{x:35,y:190}]],{strokeColor:16711680,strokeWidth:5}),e.renderPath([[{x:45,y:160},{x:75,y:160},{x:75,y:190}]],{strokeColor:16711680,strokeWidth:5,closed:!0}),e.renderPath([[{x:85,y:160},{x:125,y:160},{x:125,y:190}]],{strokeColor:16711680,strokeWidth:5,closed:!0,miterLimit:2}),e.renderPath([[{x:135,y:160},{x:175,y:160},{x:175,y:190}]],{strokeColor:16711680,strokeWidth:10,lineJoin:"bevel"}),e.renderPath([[{x:185,y:160},{x:225,y:160},{x:225,y:190}]],{strokeColor:16711680,strokeWidth:10,lineJoin:"round"}),e.renderPath([[{x:10,y:210},{x:40,y:210},{x:40,y:240}]],{strokeColor:16711680,strokeWidth:10,lineCap:"square"}),e.renderPath([[{x:55,y:210},{x:85,y:210},{x:85,y:240}]],{strokeColor:16711680,strokeWidth:10,lineCap:"round"}),e.renderPath([[{x:100,y:210},{x:220,y:210}]],{dashArray:[12,4]}),e.renderPath([[{x:100,y:220},{x:220,y:220}]],{dashArray:[12,4],dashOffset:4}),e.renderPath([[{x:5,y:250},{x:45,y:390},{x:45,y:250}],[{x:25,y:270},{x:25,y:310},{x:35,y:310},{x:35,y:270}]],{fillLinearGradient:{start:{x:5,y:250},end:{x:45,y:390},stops:[{offset:.2,color:16711680},{offset:.5,color:16776960},{offset:.8,color:65280}]},strokeWidth:0}),e.renderPath([[{x:50,y:250},{x:90,y:390},{x:90,y:250}],[{x:70,y:270},{x:70,y:310},{x:80,y:310},{x:80,y:270}]],{fillRadialGradient:{start:{x:70,y:320,r:10},end:{x:70,y:320,r:70},stops:[{offset:0,color:16711680},{offset:.5,color:16776960},{offset:1,color:65280}]},strokeWidth:0}),e.renderPath([[{x:95,y:250},{x:135,y:390},{x:135,y:250}],[{x:115,y:270},{x:115,y:310},{x:125,y:310},{x:125,y:270}]],{fillColor:16711680,fillOpacity:.3,strokeOpacity:.3}),e.renderPath([[{x:140,y:250},{x:180,y:390},{x:180,y:250}],[{x:160,y:270},{x:160,y:310},{x:170,y:310},{x:170,y:270}]],{fillRadialGradient:{start:{x:160,y:320,r:10},end:{x:160,y:320,r:70},stops:[{offset:0,color:16711680,opacity:.3},{offset:.5,color:16776960,opacity:.3},{offset:1,color:65280,opacity:.3}]},strokeWidth:0}),e.renderPath([[{x:185,y:250},{x:225,y:390},{x:225,y:250}],[{x:205,y:270},{x:205,y:310},{x:215,y:310},{x:215,y:270}]],{strokePattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})},strokeWidth:5}),e.renderPath([[{x:5,y:400},{x:45,y:540},{x:45,y:400}],[{x:25,y:420},{x:25,y:460},{x:35,y:460},{x:35,y:420}]],{strokeLinearGradient:{start:{x:5,y:400},end:{x:45,y:540},stops:[{offset:.2,color:16711680},{offset:.5,color:16776960},{offset:.8,color:65280}]},strokeWidth:5}),e.renderPath([[{x:50,y:400},{x:90,y:540},{x:90,y:400}],[{x:70,y:420},{x:70,y:460},{x:80,y:460},{x:80,y:420}]],{strokeRadialGradient:{start:{x:70,y:470,r:10},end:{x:70,y:470,r:70},stops:[{offset:0,color:16711680},{offset:.5,color:16776960},{offset:1,color:65280}]},strokeWidth:5}),e.renderPath([[{x:110,y:400},{x:110,y:470},{x:110,y:540}]],{strokeColor:16711680,strokeWidth:10}),e.renderPath([[{x:130,y:400},{x:130,y:540},{x:130,y:470}]],{strokeColor:16711680,strokeWidth:10})],230,620),u=e=>e.renderResult([e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,0,75,65,{crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",77,0,75,65,{opacity:.5,crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",154,0,75,65,{filters:[{type:"brightness",value:2}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,70,75,65,{filters:[{type:"contrast",value:2}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",77,70,75,65,{filters:[{type:"hue-rotate",value:90}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",154,70,75,65,{filters:[{type:"saturate",value:2}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,140,75,65,{filters:[{type:"saturate",value:2},{type:"hue-rotate",value:90}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",77,140,75,65,{filters:[{type:"saturate",value:2},{type:"hue-rotate",value:90},{type:"contrast",value:2}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",154,140,75,65,{filters:[{type:"grayscale",value:1}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,210,75,65,{filters:[{type:"sepia",value:1}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",77,210,75,65,{filters:[{type:"invert",value:1}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",154,210,75,65,{filters:[{type:"opacity",value:.5}],crossOrigin:""}),e.renderImage("https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",0,280,75,65,{filters:[{type:"blur",value:2}],crossOrigin:""})],230,370),d=e=>e.renderResult([e.renderPolyline([{x:5,y:10},{x:45,y:150},{x:45,y:10}],{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderPolyline([{x:50,y:10},{x:90,y:150},{x:90,y:10}],{fillColor:16711680,strokeWidth:0}),e.renderPolyline([{x:95,y:10},{x:135,y:150},{x:135,y:10}],{strokeColor:65280}),e.renderPolyline([{x:140,y:10},{x:180,y:150},{x:180,y:10}],{strokeWidth:5}),e.renderPolyline([{x:185,y:10},{x:225,y:150},{x:225,y:10}],{dashArray:[4]}),e.renderPolyline([{x:195,y:10},{x:215,y:80},{x:215,y:10}],{closed:!0})],230,220),p=e=>e.renderResult([e.renderPolygon([{x:5,y:10},{x:45,y:150},{x:45,y:10}],{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderPolygon([{x:50,y:10},{x:90,y:150},{x:90,y:10}],{fillColor:16711680,strokeWidth:0}),e.renderPolygon([{x:95,y:10},{x:135,y:150},{x:135,y:10}],{strokeColor:65280}),e.renderPolygon([{x:140,y:10},{x:180,y:150},{x:180,y:10}],{strokeWidth:5}),e.renderPolygon([{x:185,y:10},{x:225,y:150},{x:225,y:10}],{dashArray:[4]})],230,190),f=e=>e.renderResult([e.renderPathCommands([{type:"move",to:{x:220,y:10}},{type:"arc",from:{x:220,y:80},to:{x:150,y:10},radius:20},{type:"line",to:{x:150,y:10}},{type:"quadraticCurve",cp:{x:150,y:90},to:{x:110,y:70}},{type:"bezierCurve",cp1:{x:70,y:20},cp2:{x:40,y:80},to:{x:10,y:10}},{type:"ellipseArc",rx:30,ry:20,angle:0,largeArc:!1,sweep:!0,to:{x:50,y:30}}],{strokeColor:65280}),e.renderPathCommands([{type:"move",to:{x:210,y:10}},{type:"arc",from:{x:210,y:80},to:{x:160,y:10},radius:20},{type:"line",to:{x:160,y:10}}],{closed:!0})],230,120),h=e=>{const t=[e.renderCircle(50,50,20),e.renderCircle(50,50,35),e.renderText(0,40,"abc",16711680,30,"monospace"),e.renderGroup([e.renderCircle(50,50,15)],{translate:{x:20,y:20}})];return e.renderResult([e.renderGroup(t,{opacity:.2,translate:{x:10,y:0}}),e.renderRect(120,10,80,80,{clip:()=>e.renderGroup(t,{translate:{x:100,y:0}})}),e.renderCircle(180,150,50,{clip:()=>e.renderGroup(t,{matrix:i.m3.multiply(i.m3.translation(150,150),i.m3.scaling(.7,.7))})}),e.renderPath([[{x:0,y:200},{x:120,y:200},{x:120,y:300},{x:0,y:300},{x:0,y:200}],[{x:55,y:230},{x:90,y:220},{x:90,y:260},{x:50,y:260},{x:55,y:230}]],{clip:()=>e.renderGroup(t,{translate:{x:10,y:200}}),strokeWidth:0}),e.renderPolygon([{x:55,y:230},{x:90,y:220},{x:90,y:260},{x:50,y:260}]),e.renderRect(30,100,80,80,{clip:()=>e.renderGroup([e.renderCircle(90,50,20,{fillPattern:{width:10,height:10,pattern:()=>e.renderPath([[{x:0,y:5},{x:5,y:0}],[{x:10,y:5},{x:5,y:10}]],{strokeColor:255})}}),e.renderCircle(30,50,20)],{translate:{x:10,y:90}})}),e.renderGroup(t,{translate:{x:110,y:200},base:{x:50,y:50},scale:{x:.6,y:.3}})],230,550)},g=e=>e.renderResult([e.renderRay(50,50,30),e.renderRay(80,50,30,{bidirectional:!0}),e.renderGroup([e.renderRay(60,60,30),e.renderGroup([e.renderRay(60,60,30)],{translate:{x:0,y:-20}})],{translate:{x:-20,y:0}})],230,90),{setOffset:m}=o().useContext(a.OffsetXContext);return o().useEffect((()=>{navigator.gpu&&(null==m||m(230))}),[m]),o().createElement("div",null,o().createElement("div",{style:{display:"flex",height:"40px",alignItems:"center",fontSize:"25px",justifyContent:"space-around"}},o().createElement("span",null,i.reactSvgRenderTarget.type),o().createElement("span",null,i.reactCanvasRenderTarget.type),o().createElement("span",null,i.reactWebglRenderTarget.type),navigator.gpu&&o().createElement("span",null,i.reactWebgpuRenderTarget.type)),e(i.reactSvgRenderTarget),e(i.reactCanvasRenderTarget),e(i.reactWebglRenderTarget),navigator.gpu&&e(i.reactWebgpuRenderTarget),o().createElement("br",null),t(i.reactSvgRenderTarget),t(i.reactCanvasRenderTarget),t(i.reactWebglRenderTarget),navigator.gpu&&t(i.reactWebgpuRenderTarget),o().createElement("br",null),n(i.reactSvgRenderTarget),n(i.reactCanvasRenderTarget),n(i.reactWebglRenderTarget),navigator.gpu&&n(i.reactWebgpuRenderTarget),o().createElement("br",null),r(i.reactSvgRenderTarget),r(i.reactCanvasRenderTarget),r(i.reactWebglRenderTarget),navigator.gpu&&r(i.reactWebgpuRenderTarget),o().createElement("br",null),s(i.reactSvgRenderTarget),s(i.reactCanvasRenderTarget),s(i.reactWebglRenderTarget),navigator.gpu&&s(i.reactWebgpuRenderTarget),o().createElement("br",null),l(i.reactSvgRenderTarget),l(i.reactCanvasRenderTarget),l(i.reactWebglRenderTarget),navigator.gpu&&l(i.reactWebgpuRenderTarget),o().createElement("br",null),c(i.reactSvgRenderTarget),c(i.reactCanvasRenderTarget),c(i.reactWebglRenderTarget),navigator.gpu&&c(i.reactWebgpuRenderTarget),o().createElement("br",null),u(i.reactSvgRenderTarget),u(i.reactCanvasRenderTarget),u(i.reactWebglRenderTarget),navigator.gpu&&u(i.reactWebgpuRenderTarget),o().createElement("br",null),d(i.reactSvgRenderTarget),d(i.reactCanvasRenderTarget),d(i.reactWebglRenderTarget),navigator.gpu&&d(i.reactWebgpuRenderTarget),o().createElement("br",null),p(i.reactSvgRenderTarget),p(i.reactCanvasRenderTarget),p(i.reactWebglRenderTarget),navigator.gpu&&p(i.reactWebgpuRenderTarget),o().createElement("br",null),f(i.reactSvgRenderTarget),f(i.reactCanvasRenderTarget),f(i.reactWebglRenderTarget),navigator.gpu&&f(i.reactWebgpuRenderTarget),o().createElement("br",null),h(i.reactSvgRenderTarget),h(i.reactCanvasRenderTarget),h(i.reactWebglRenderTarget),navigator.gpu&&h(i.reactWebgpuRenderTarget),o().createElement("br",null),g(i.reactSvgRenderTarget),g(i.reactCanvasRenderTarget),g(i.reactWebglRenderTarget),navigator.gpu&&g(i.reactWebgpuRenderTarget))}},4339:(e,t,n)=>{"use strict";n.d(t,{default:()=>l});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758),s=n(9299);const l=()=>{const[e,t]=i().useState(s.defaultContents),[n,o]=i().useState(0),{regionAlignmentX:l,regionAlignmentY:c,changeOffsetByRegionAlignment:u,clearRegionAlignments:d}=(0,a.useRegionAlignment)(10),{offset:p,onStart:f,mask:h,startPosition:g,resetDragMove:m}=(0,a.useDragMove)((()=>{d(),0!==p.x||0!==p.y||void 0===(null==g?void 0:g.data)?t((0,r.produce)(e,(e=>{e[n].x+=p.x,e[n].y+=p.y}))):o(g.data)}),{transformOffset:(t,r)=>((null==r?void 0:r.shiftKey)?d():u(t,e[n],e.filter(((e,t)=>t!==n))),t)});return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&m()})),i().createElement(i().Fragment,null,e.map(((e,t)=>i().createElement("div",{key:t,style:{width:`${e.width}px`,height:`${e.height}px`,left:`${e.x+(n===t?p.x:0)}px`,top:`${e.y+(n===t?p.y:0)}px`,position:"absolute",boxSizing:"border-box",background:`url(${e.url})`,backgroundSize:"contain",border:n===t?"1px solid green":void 0},onMouseDown:e=>f({x:e.clientX,y:e.clientY},{data:t})}))),i().createElement(a.AlignmentLine,{type:"x",value:l}),i().createElement(a.AlignmentLine,{type:"y",value:c}),h)}},6286:(e,t,n)=>{"use strict";n.d(t,{richTextData:()=>r});const r=[{type:"h2",blockStart:13.28,blockEnd:13.28,children:[{text:"G"},{text:"e"},{text:"t"},{text:"t"},{text:"i"},{text:"n"},{text:"g"},{text:" "},{text:"u"},{text:"s"},{text:"e"},{text:"d"},{text:" "},{text:"t"},{text:"o"},{text:" "},{text:"a"},{text:"n"},{text:" "},{text:"e"},{text:"n"},{text:"t"},{text:"i"},{text:"r"},{text:"e"},{text:"l"},{text:"y"}]},{type:"p",blockStart:16,blockEnd:16,children:[{text:"d"},{text:"i"},{text:"f"},{text:"f"},{text:"e"},{text:"r"},{text:"e"},{text:"n"},{text:"t"},{text:" "},{text:"c"},{text:"u"},{text:"l"},{text:"t"},{text:"u"},{text:"r"},{text:"e"},{text:" "},{text:"c"},{text:"a"},{text:"n"},{text:" "},{text:"b"},{text:"e"},{text:" "},{text:"c",underline:!0},{text:"h",underline:!0},{text:"a",underline:!0},{text:"l",underline:!0},{text:"l",underline:!0},{text:"e",underline:!0},{text:"n",underline:!0},{text:"g",underline:!0},{text:"i",underline:!0},{text:"n",underline:!0},{text:"g",underline:!0},{text:"."},{text:"abc",type:"link",targetBlank:!0,url:"abc"},{text:" "},{text:" "},{text:"W"},{text:"h"},{text:"i"},{text:"l"},{text:"e"},{text:" "},{text:"i"},{text:"t"},{text:"’"},{text:"s"},{text:" "},{text:"a"},{text:"l"},{text:"s"},{text:"o"},{text:" "},{text:"n"},{text:"i"},{text:"c"},{text:"e"},{text:" "},{text:"t"},{text:"o"},{text:" "},{text:"l"},{text:"e"},{text:"a"},{text:"r"},{text:"n"},{text:" "},{text:"a"},{text:"b"},{text:"o"},{text:"u"},{text:"t"},{text:" "},{text:"c",type:"code",backgroundColor:15921649},{text:"u",type:"code",backgroundColor:15921649},{text:"l",type:"code",backgroundColor:15921649},{text:"t",type:"code",backgroundColor:15921649},{text:"u",type:"code",backgroundColor:15921649},{text:"r",type:"code",backgroundColor:15921649},{text:"e",type:"code",backgroundColor:15921649},{text:"s",type:"code",backgroundColor:15921649},{text:" "},{text:"o"},{text:"n"},{text:"l"},{text:"i"},{text:"n"},{text:"e"},{text:" "},{text:"o"},{text:"r"},{text:" "},{text:"f"},{text:"r"},{text:"o"},{text:"m"},{text:" "},{text:"b"},{text:"o"},{text:"o"},{text:"k"},{text:"s"},{text:","},{text:" "},{text:"d"},{text:"d"},{text:"d"},{text:" "},{text:"c"},{text:"o"},{text:"m"},{text:"e"},{text:"s"},{text:" "},{text:"c",type:"span"},{text:"l",type:"span"},{text:"o",type:"span"},{text:"s",type:"span"},{text:"e",type:"span"},{text:" "},{text:"t"},{text:"o"},{text:" "},{text:"e",bold:!1},{text:"x",bold:!1},{text:"p",bold:!1},{text:"e",bold:!1},{text:"r",bold:!1},{text:"i",bold:!1},{text:"e",bold:!1},{text:"n",bold:!1},{text:"c",bold:!1},{text:"i",bold:!1},{text:"n",bold:!1},{text:"g",bold:!1},{text:"a",bold:!1},{text:" "},{text:"c"},{text:"u"},{text:"l"},{text:"t"},{text:"u"},{text:"r"},{text:"a"},{text:"l"},{text:" "},{text:"d"},{text:"i"},{text:"v"},{text:"e"},{text:"r"},{text:"s"},{text:"i"},{text:"t"},{text:"y"},{text:" "},{text:"i"},{text:"n"},{text:" "},{text:"p"},{text:"e"},{text:"r"},{text:"s"},{text:"o"},{text:"n"},{text:"."},{text:" "},{text:"Y"},{text:"o"},{text:"u"},{text:"A",type:"circle"},{text:" "},{text:"B",type:"stack",bottomText:"C"},{text:" "},{text:"l"},{text:"e"},{text:"a"},{text:"r"},{text:"n"},{text:"a"},{text:"a"},{text:"啊"},{text:"啊"},{text:" "},{text:"t"},{text:"o"},{text:" "},{text:"a"},{text:"p",bold:!0,italic:!0,underline:!0,passThrough:!0},{text:"p",bold:!0,italic:!0,underline:!0,passThrough:!0},{text:"r",bold:!0,italic:!0,underline:!0,passThrough:!0},{text:"e",bold:!0,italic:!0,underline:!0,passThrough:!0},{text:"c",bold:!0,italic:!0,underline:!0,passThrough:!0},{text:"i",bold:!0,italic:!0,underline:!0,passThrough:!0},{text:"a"},{text:"t"},{text:"e"},{text:" "},{text:"e"},{text:"a"},{text:"c"},{text:"h"},{text:" "},{text:"a"},{text:"n"},{text:"d"},{text:" "},{text:"e"},{text:"v"},{text:"e"},{text:"r"},{text:"y"},{text:" "},{text:"s"},{text:"i"},{text:"n"},{text:"g"},{text:"l"},{text:"e"},{text:" "},{text:"o"},{text:"n"},{text:"e"},{text:" "},{text:"o"},{text:"f"},{text:" "},{text:"t"},{text:"h"},{text:"e"},{text:" "},{text:"d"},{text:"i"},{text:"f"},{text:"f"},{text:"e"},{text:"r"},{text:"e"},{text:"n"},{text:"c"},{text:"e"},{text:"s"},{text:" "},{text:"x"},{text:"2",type:"sub"},{text:"2",type:"sup"},{text:" "},{text:"2"},{text:" "},{text:"w"},{text:"h"},{text:"i"},{text:"l"},{text:"e"},{text:" "},{text:"y"},{text:"o"},{text:"u"},{text:" "},{text:"b"},{text:"e"},{text:"c"},{text:"o"},{text:"m"},{text:"e"},{text:" "},{text:"m"},{text:"o"},{text:"r"},{text:"e"},{text:" "},{text:"c"},{text:"u"},{text:"l"},{text:"t"},{text:"u"},{text:"r"},{text:"a"},{text:"l"},{text:"l"},{text:"y"},{text:" "},{text:"f"},{text:"l"},{text:"u"},{text:"i"},{text:"d"},{text:"."},{text:"<"},{text:"a"},{text:">"},{text:" "},{text:"@aa_2",color:16777215,backgroundColor:255},{text:" "},{text:" "},{text:"s"},{text:"d"},{text:"a"},{text:"d"},{text:" "},{text:"a"},{text:"f"},{text:"f"},{text:"s"},{text:" "},{text:"f"},{text:"d"},{text:"f"},{text:"d"},{text:"s"},{text:"f"},{text:"@aa_1",color:16777215,backgroundColor:255},{text:" "},{text:"@aa_1",color:16777215,backgroundColor:255},{text:" "},{text:"@aa_1",color:16777215,backgroundColor:255},{text:" "}]},{type:"ul",blockStart:16,blockEnd:16,children:[{text:"a"},{text:"a"}],inlineStart:40},{type:"ul",blockStart:16,blockEnd:16,children:[{text:"b"},{text:"b"}],inlineStart:40},{blockStart:.5,blockEnd:.5,void:!0,type:"hr",children:[]},{type:"ol",blockStart:16,blockEnd:16,children:[{text:"a"},{text:"a"},{text:"x"}],inlineStart:40,listStyleType:"decimal"},{type:"ol",blockStart:16,blockEnd:16,children:[{text:"https://stackoverflow.com/",type:"link",underline:!0,color:5577354,targetBlank:!0,url:"https://stackoverflow.com/"}],inlineStart:40,listStyleType:"decimal"},{type:"p",blockStart:16,blockEnd:16,children:[{text:"c",type:"code",backgroundColor:15921649},{text:"o",type:"code",backgroundColor:15921649},{text:"d",type:"code",backgroundColor:15921649},{text:"e",type:"code",backgroundColor:15921649}],fontSize:16},{type:"p",blockStart:16,blockEnd:16,children:[{url:"https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",width:263.0291970802921,height:180.17499999999998,text:" "},{kind:"image",url:"https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",width:192.27007299270085,height:131.705},{url:"https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",width:195.8759124087592,height:134.17499999999998,text:" "},{url:"tyejtey",text:"tyejtey",type:"link",targetBlank:!0},{url:"https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",width:195.8759124087592,height:134.17499999999998,text:" "}],fontSize:16},{type:"p",blockStart:16,blockEnd:16,children:[{text:"a",type:"mark",backgroundColor:16776960},{text:"a",type:"mark",backgroundColor:16776960},{text:"s",type:"mark",backgroundColor:16776960},{text:"a",type:"mark",backgroundColor:16776960},{text:" ",type:"mark",backgroundColor:16776960}],fontSize:16}]},7310:(e,t,n)=>{"use strict";n.d(t,{useAt:()=>d});var r=n(3696),o=n.n(r),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(e,n,t[n]);return e};const d=({cursor:e,cursorHeight:t,inputText:n})=>{const[r,i]=o().useState(""),[a,s]=o().useState(0),l={color:16777215,backgroundColor:255};return{processInput(e){if(r){if(1===e.key.length&&e.key>="a"&&e.key<="z")return i((t=>t+e.key)),e.preventDefault(),!0;if("Enter"===e.key&&r){const e=u({text:r+"_"+a},l);return n([e," "]),i(""),!0}if("Escape"===e.key)return i(""),e.preventDefault(),!0;if("ArrowDown"===e.key)return s((a+1)%5),e.preventDefault(),!0;if("ArrowUp"===e.key)return s((a+4)%5),e.preventDefault(),!0;if("Backspace"===e.key)return r.length>1?i((e=>e.slice(0,e.length-1))):i(""),e.preventDefault(),!0}return"@"===e.key&&(i("@"),e.preventDefault(),!0)},ui:r?o().createElement("div",{style:{position:"absolute",left:e.x+"px",top:e.y+t+"px",background:"white",width:"100px",border:"1px solid black"}},o().createElement("div",null,r),new Array(5).fill(0).map(((e,t)=>o().createElement("div",{key:t,style:{background:a===t?"#ccc":void 0},onMouseDown:e=>{e.preventDefault();const o=u({text:r+"_"+t},l);n([o," "]),i("")}},r+"_"+t)))):void 0}}},5011:(e,t,n)=>{"use strict";n.d(t,{h1:()=>r,h2:()=>o,h3:()=>i,h4:()=>a,h5:()=>s,h6:()=>l,hr:()=>p,ol:()=>d,p:()=>c,ul:()=>u});const r={blockStart:.67,blockEnd:.67},o={blockStart:.83,blockEnd:.83},i={blockStart:1.17,blockEnd:1.17},a={blockStart:1,blockEnd:1},s={blockStart:1,blockEnd:1},l={blockStart:2.33,blockEnd:2.33},c={blockStart:1,blockEnd:1},u={blockStart:1,blockEnd:1,inlineStart:40},d={blockStart:1,blockEnd:1,inlineStart:40},p={blockStart:.5,blockEnd:.5,void:!0}},3685:(e,t,n)=>{"use strict";n.d(t,{circle:()=>g,useCircle:()=>m});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))u.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))d.call(t,n)&&p(e,n,t[n]);return e};function h(e){return(0,i.isHtmlText)(e)&&"circle"===e.type}const g={render(e){var t,n,r;if(h(e)){const a=(0,i.renderHtmlTextStyle)(e),c=1.2*(null!=(t=e.fontSize)?t:i.defaultFontSize);return o().createElement("span",{style:(n=f({},a),r={borderWidth:"1px",borderStyle:"solid",borderColor:a.color,borderRadius:c/2+"px",width:`${c}px`,height:`${c}px`,display:"inline-flex",justifyContent:"center"},s(n,l(r)))},e.text)}}},m=({inputText:e,currentContent:t,updateCurrentContent:n})=>{const[r,a]=o().useState(""),s={"insert circle":o().createElement(i.StringEditor,{value:r,setValue:t=>{t&&(e([{type:"circle",text:t}," "]),a(t),setTimeout((()=>{a("")}),0))}})};return t&&h(t)&&(s["circle text"]=o().createElement(i.StringEditor,{value:t.text,setValue:e=>n((t=>{h(t)&&(t.text=e)}))})),{propertyPanel:s}}},726:(e,t,n)=>{"use strict";n.d(t,{image:()=>s,useImage:()=>l});var r=n(3696),o=n.n(r),i=n(9758);function a(e){return"image"===e.kind}const s={render(e,t){if(a(e))return o().createElement("img",{style:{width:`${e.width+t.width}px`,height:`${e.height+t.height}px`},src:e.url})}},l=({inputText:e,currentContent:t,currentContentLayout:n,updateCurrentContent:r,setResizeOffset:s})=>{const[l,c]=o().useState(""),{offset:u,onStart:d,mask:p,resetDragResize:f}=(0,i.useDragResize)((()=>{r((e=>{a(e)&&(e.width+=u.width,e.height+=u.height)}))}),{keepRatio:t&&a(t)?t.width/t.height:void 0});(0,i.useGlobalKeyDown)((e=>{"Escape"===e.key&&f()})),o().useEffect((()=>{s(u)}),[u.x,u.y]);const h={"insert image":o().createElement(i.StringEditor,{value:l,setValue:t=>{t&&((0,i.getImageFromCache)(t,{callback(n){const r=Math.min(n.width,200),o=Math.round(r/n.width*n.height);e([{kind:"image",url:t,width:r,height:o}," "])}}),c(t),setTimeout((()=>{c("")}),0))}})};return t&&a(t)&&(h["image url"]=o().createElement(i.StringEditor,{value:t.url,setValue:e=>r((t=>{a(t)&&(t.url=e)}))}),h["image width"]=o().createElement(i.NumberEditor,{value:t.width,setValue:e=>r((t=>{a(t)&&(t.width=e)}))}),h["image height"]=o().createElement(i.NumberEditor,{value:t.height,setValue:e=>r((t=>{a(t)&&(t.height=e)}))})),{propertyPanel:h,ui:t&&a(t)&&n?o().createElement("div",{style:{width:`${t.width+u.width}px`,height:`${t.height+u.height}px`,left:`${n.x+u.x}px`,top:`${n.y+u.y}px`,border:"1px solid green",boxSizing:"border-box",position:"absolute"}},o().createElement(i.ResizeBar,{directions:["right-bottom"],onMouseDown:d}),p):void 0}}},4430:(e,t,n)=>{"use strict";n.d(t,{code:()=>o,mark:()=>i,span:()=>r,sub:()=>a,sup:()=>s});const r={},o={backgroundColor:15921649},i={},a={},s={}},2693:(e,t,n)=>{"use strict";n.d(t,{link:()=>s,useLink:()=>l});var r=n(3696),o=n.n(r),i=n(9758);function a(e){return(0,i.isHtmlText)(e)&&"link"===e.type}const s={render(e){if(a(e))return o().createElement("a",{style:(0,i.renderHtmlTextStyle)(e),target:e.targetBlank?"_blank":"",href:e.url},e.text)}},l=({inputText:e,currentContent:t,updateCurrentContent:n})=>{var r;const[s,l]=o().useState(""),c={"insert link":o().createElement(i.StringEditor,{value:s,setValue:t=>{t&&(e([{type:"link",text:t,targetBlank:!0,url:t}," "]),l(t),setTimeout((()=>{l("")}),0))}})};return t&&a(t)&&(c["link text"]=o().createElement(i.StringEditor,{value:t.text,setValue:e=>n((t=>{a(t)&&(t.text=e)}))}),c["link url"]=o().createElement(i.StringEditor,{value:t.url,setValue:e=>n((t=>{a(t)&&(t.url=e)}))}),c["link target blank"]=o().createElement(i.BooleanEditor,{value:null!=(r=t.targetBlank)&&r,setValue:e=>n((t=>{a(t)&&(t.targetBlank=!!e||void 0)}))})),{propertyPanel:c}}},8749:(e,t,n)=>{"use strict";n.d(t,{stack:()=>g,useStack:()=>m});var r=n(3696),o=n.n(r),i=n(9758),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))u.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))d.call(t,n)&&p(e,n,t[n]);return e};function h(e){return(0,i.isHtmlText)(e)&&"stack"===e.type}const g={render(e){if(h(e)){const r=(0,i.renderHtmlTextStyle)(e);return o().createElement("span",{style:(t=f({},r),n={display:"inline-flex",flexDirection:"column",verticalAlign:"middle"},s(t,l(n)))},o().createElement("span",{style:{borderBottomWidth:"1px",borderBottomStyle:"solid",borderBottomColor:r.color}},e.text),o().createElement("span",null,e.bottomText))}var t,n}},m=({inputText:e,currentContent:t,updateCurrentContent:n})=>{const[r,a]=o().useState(""),s={"insert stack":o().createElement(i.StringEditor,{value:r,setValue:t=>{if(t){let n=t,r=t;const o=t.indexOf("/");o>0&&o{a("")}),0)}}})};return t&&h(t)&&(s["stack top"]=o().createElement(i.StringEditor,{value:t.text,setValue:e=>n((t=>{h(t)&&(t.text=e)}))}),s["stack bottom"]=o().createElement(i.StringEditor,{value:t.bottomText,setValue:e=>n((t=>{h(t)&&(t.bottomText=e)}))})),{propertyPanel:s}}},395:(e,t,n)=>{"use strict";n.d(t,{backgroundColor:()=>f,bold:()=>l,color:()=>p,fontFamily:()=>s,fontSize:()=>a,italic:()=>c,passThrough:()=>d,underline:()=>u});var r=n(3696),o=n.n(r),i=n(9758);const a=(e,t,n)=>{var r,a;return o().createElement(i.NumberEditor,{value:null!=(a=null!=(r=null==e?void 0:e.fontSize)?r:null==t?void 0:t.fontSize)?a:i.defaultFontSize,setValue:e=>n((t=>t.fontSize=e)),style:{width:"100px"}})},s=(e,t,n)=>{var r,a;return o().createElement(i.StringEditor,{value:null!=(a=null!=(r=null==e?void 0:e.fontFamily)?r:null==t?void 0:t.fontFamily)?a:i.defaultFontFamily,setValue:e=>n((t=>t.fontFamily=e)),style:{width:"100px"}})},l=(e,t,n)=>{var r;return o().createElement(i.BooleanEditor,{value:!0===(null!=(r=null==e?void 0:e.bold)?r:null==t?void 0:t.bold),setValue:e=>n((t=>t.bold=!!e||void 0))})},c=(e,t,n)=>{var r;return o().createElement(i.BooleanEditor,{value:!0===(null!=(r=null==e?void 0:e.italic)?r:null==t?void 0:t.italic),setValue:e=>n((t=>t.italic=!!e||void 0))})},u=(e,t,n)=>{var r;return o().createElement(i.BooleanEditor,{value:!0===(null!=(r=null==e?void 0:e.underline)?r:null==t?void 0:t.underline),setValue:e=>n((t=>t.underline=!!e||void 0))})},d=(e,t,n)=>{var r;return o().createElement(i.BooleanEditor,{value:!0===(null!=(r=null==e?void 0:e.passThrough)?r:null==t?void 0:t.passThrough),setValue:e=>n((t=>t.passThrough=!!e||void 0))})},p=(e,t,n)=>{var r,a;return o().createElement(i.NumberEditor,{type:"color",value:null!=(a=null!=(r=null==e?void 0:e.color)?r:null==t?void 0:t.color)?a:0,setValue:e=>n((t=>t.color=e||void 0))})},f=(e,t,n)=>{var r,a;return o().createElement(i.NumberEditor,{type:"color",value:null!=(a=null!=(r=null==e?void 0:e.backgroundColor)?r:null==t?void 0:t.backgroundColor)?a:16777215,setValue:e=>n((t=>t.backgroundColor=e||void 0))})}},8214:(e,t,n)=>{"use strict";n.d(t,{RichTextEditor:()=>s});var r=n(3696),o=n.n(r),i=n(9758),a=n(8662);const s=o().forwardRef(((e,t)=>{var n,r,s,l,c;const{state:u,setState:d,undo:p,redo:f,applyPatchFromOtherOperators:h}=(0,i.usePatchBasedUndoRedo)(e.initialState,e.operator,{onApplyPatchesFromSelf:e.onApplyPatchesFromSelf}),[g,m]=o().useState({width:0,height:0}),{renderEditor:y,currentContent:v,currentBlock:x,currentContentLayout:b,inputText:C,layoutResult:E,cursor:P,inputContent:k,location:w,scrollY:_,updateSelection:S,updateTextInline:R,updateParagraph:A,updateCurrentContent:T}=(0,i.useHtmlEditor)({state:u,setState:d,width:e.width,height:e.height,readOnly:e.readOnly,processInput(e){for(const t of M)if(t(e))return!0;return!(!(0,i.metaKeyIfMacElseCtrlKey)(e)||"z"!==e.key||(e.shiftKey?f(e):p(e),0))},onLocationChanged:e.onSendLocation,autoHeight:e.autoHeight,plugin:e.plugin,resizeOffset:g,keepSelectionOnBlur:!0}),M=[],L=[],I={};if(null==(n=e.plugin)?void 0:n.hooks){const t={cursor:P,cursorHeight:P.height,inputText:C,inputContent:k,currentContent:v,currentContentLayout:b,updateCurrentContent:T,setResizeOffset:m};e.plugin.hooks.forEach(((e,n)=>{const{processInput:r,ui:i,propertyPanel:a}=e(t);r&&M.push(r),i&&L.push(o().cloneElement(i,{key:n})),a&&Object.assign(I,a)}))}const[O,B]=o().useState([]);o().useImperativeHandle(t,(()=>({handlePatchesEvent(e){try{h(e.patches,e.reversePatches,e.operator)}catch(e){console.error(e)}},handleLocationEvent(e){B((0,a.produce)(O,(t=>{var n,r;const o=O.findIndex((t=>t.operator===e.operator));o>=0?e.location&&(null==(r=null==(n=u[e.location[0]])?void 0:n.children)?void 0:r[e.location[1]])?t[o].location=e.location:t.splice(o,1):e.location&&t.push({location:e.location,operator:e.operator})})))}})),[h]);const F=[];if(null==(r=null==E?void 0:E.cells)||r.forEach(((e,t)=>{var n;const r=u[t],a=null!=(n=null==r?void 0:r.fontFamily)?n:i.defaultFontFamily;e.forEach((({x:e,y:n,height:r},i)=>{const s=O.filter((e=>e.location[0]===t&&e.location[1]===i));s.length>0&&F.push(o().createElement("div",{style:{position:"absolute",left:e+"px",top:n+_+"px",width:"2px",height:r+"px",backgroundColor:"red"}}),o().createElement("span",{style:{position:"absolute",left:e+"px",top:n+_+r+"px",fontSize:"12px",fontFamily:a,color:"red"}},s.map((e=>e.operator)).join(",")))}))})),(null==(s=e.plugin)?void 0:s.styles)&&v&&(0,i.isHtmlText)(v))for(const t in e.plugin.styles)I[t]=e.plugin.styles[t](v,x,S);return(null==(l=e.plugin)?void 0:l.textInlines)&&(I.textInlines=o().createElement("div",null,(0,i.getKeys)(e.plugin.textInlines).map((e=>o().createElement(i.Button,{key:e,style:{fontWeight:v&&(0,i.isHtmlText)(v)&&v.type===e?"bold":void 0},onClick:()=>R(e)},e))))),(null==(c=e.plugin)?void 0:c.blocks)&&(I.block=o().createElement("div",null,(0,i.getKeys)(e.plugin.blocks).map((e=>{var t;return o().createElement(i.Button,{key:e,style:{fontWeight:(null==(t=u[w[0]])?void 0:t.type)===e?"bold":void 0},onClick:()=>A(e)},e)})))),o().createElement("div",{style:{position:"relative",margin:"10px"}},o().createElement("div",{style:{display:"flex"}},y(o().createElement(o().Fragment,null,F)),o().createElement(i.ObjectEditor,{inline:!0,properties:I})),L)}))},94:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const[e,t]=o().useState(0),[n,r]=o().useState(0);return o().createElement("div",{style:{width:"300px",height:"300px",overflow:"hidden",position:"absolute",display:"flex",alignItems:"center",justifyContent:"center"}},o().createElement("div",{style:{width:"800px",height:"800px",position:"absolute",transform:`translate(${e}px, ${n}px)`,background:"radial-gradient(50% 50% at 50% 50%, red 0%, white 100%)"}}),o().createElement(i.Scrollbar,{value:e,type:"horizontal",containerSize:300,contentSize:800,onChange:t}),o().createElement(i.Scrollbar,{value:n,type:"vertical",containerSize:300,contentSize:800,onChange:r}))}},8751:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const{isSelected:e,addSelection:t,filterSelection:n,executeOperation:r,selectBeforeOperate:a,message:s,onSelectBeforeOperateKeyDown:l}=(0,i.useSelectBeforeOperate)({},((e,t)=>(alert(t.map((([e])=>e)).join(",")),!0)));(0,i.useGlobalKeyDown)((e=>{l(e)}));const c=(e,t)=>{const{result:o,needSelect:i}=n(t,e);i?a({count:e,selectable:t},"alert"):r("alert",o)};return o().createElement("div",null,o().createElement("button",{onClick:()=>c()},"select count ",">"," 0"),o().createElement("button",{onClick:()=>c(3)},"select count = 3"),o().createElement("button",{onClick:()=>c(void 0,(([e])=>e%2==1))},"select count ",">"," 0 && i % 2 === 1"),o().createElement("button",{onClick:()=>c(3,(([e])=>e%2==1))},"select count = 3 && i % 2 === 1"),new Array(10).fill(1).map(((n,r)=>o().createElement("button",{key:r,style:{backgroundColor:e([r])?"green":void 0,width:"50px",height:"50px"},onClick:()=>t([r])},r))),s)}},9967:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const{isSelected:e,addSelection:t,onSelectedKeyDown:n}=(0,i.useSelected)({maxCount:3});return(0,i.useGlobalKeyDown)((e=>{n(e)})),o().createElement("div",null,new Array(10).fill(1).map(((n,r)=>o().createElement("button",{key:r,style:{backgroundColor:e([r])?"green":void 0,width:"50px",height:"50px"},onClick:()=>t([[r]])},r))))}},5052:(e,t,n)=>{"use strict";n.d(t,{OffsetXContext:()=>x});var r=n(7470),o=n(3696),i=n.n(o),a=(n(9532),n(831),n(8941)),s=n(250),l=n(5371),c=n(9758),u=n(6708),d=n(9277),p=n(9456),f=n(7511),h=n(3714),g=n(577),m=n(84);const y=[{path:"whiteboard",name:"whiteboard",component:u.WhiteBoard},{path:"index",name:"combination 1",component:l.App},{path:"combination2",name:"combination 2",component:d.Combination2},{path:"combination3",name:"combination 3",component:p.Combination3},{path:"combination4",name:"combination 4",component:f.Combination4},{path:"combination5",name:"combination 5",component:h.Combination5},{path:"combination6",name:"combination 6",component:g.Combination6},{path:"combination7",name:"combination 7",component:m.Combination7}];function v(){const[,e]=(0,a.useLocation)(i()),[t,n]=i().useState(0),{onStart:r,offset:o,mask:l}=(0,c.useDragMove)((()=>{n((e=>e+o.x))}));if(!e)return i().createElement("ul",{style:{margin:"20px 50px"}},y.map((e=>i().createElement("li",{style:{cursor:"pointer"},key:e.path,onClick:()=>(0,a.navigateTo)(location.pathname+"?p="+e.path)},e.name))),s.stories.map((e=>i().createElement("li",{style:{cursor:"pointer"},key:e.path,onClick:()=>(0,a.navigateTo)(location.pathname+"?p="+e.path)},e.name," ",e.path))));const u=e.substring(3),d=y.find((e=>e.path===u));if(d)return i().createElement(d.component,null);for(const e of s.stories)if(u===e.path)return i().createElement("div",{style:{display:"flex",padding:"20px",height:`calc(${window.innerHeight}px - 40px)`,overflowY:"auto"}},i().createElement("div",{style:{width:`calc(50% + ${t+o.x}px)`}},i().createElement(x.Provider,{value:{offset:t,setOffset:n}},i().createElement(e.Component,null))),i().createElement("div",{style:{width:"5px",cursor:"ew-resize",zIndex:1},onMouseDown:e=>r({x:e.clientX,y:e.clientY})}),i().createElement("div",{style:{width:`calc(50% - 5px - ${t+o.x}px)`}},i().createElement(b,{code:e.code})),l);return null}const x=i().createContext({offset:0});function b(e){const t=i().useRef(null);return i().useEffect((()=>{t.current&&Prism.highlightElement(t.current)}),[e.code,t.current]),i().createElement("pre",{className:"line-numbers"},i().createElement("code",{ref:t,className:"language-tsx"},e.code))}const C=document.querySelector("#container");C&&(0,r.createRoot)(C).render(i().createElement(v,null))},9299:(e,t,n)=>{"use strict";n.d(t,{defaultContents:()=>r});const r=[{x:500,y:100,width:100,height:100,url:"https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg"},{x:20,y:200,width:300,height:300,url:"https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg"},{x:200,y:20,width:200,height:200,url:"https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg"}]},5503:(e,t,n)=>{"use strict";n.d(t,{default:()=>s});var r=n(8662),o=n(3696),i=n.n(o),a=n(9758);const s=()=>{const[e,t]=i().useState([]),{text:n,onClick:o,onMove:s,input:l,reset:c}=(0,a.useTextClickCreate)(!0,(n=>{t((0,r.produce)(e,(e=>{e.push(n)})))}));return(0,a.useGlobalKeyDown)((e=>{"Escape"===e.key&&c()})),i().createElement("div",{style:{height:"100%"}},i().createElement("svg",{viewBox:"0 0 800 600",width:800,height:600,xmlns:"http://www.w3.org/2000/svg",fill:"none",style:{position:"absolute",left:0,top:0},onClick:e=>o({x:e.clientX,y:e.clientY}),onMouseMove:e=>s({x:e.clientX,y:e.clientY})},[...e,n].map(((e,t)=>e&&i().createElement("text",{key:t,x:e.x,y:e.y,style:{fill:(0,a.getColorString)(e.color),fontSize:`${e.fontSize}px`,fontFamily:e.fontFamily}},e.text)))),l)}},8119:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const{state:e,setState:t,undo:n,redo:r}=(0,i.useUndoRedo)({count:0});return(0,i.useGlobalKeyDown)((e=>{"KeyZ"===e.code&&(0,i.metaKeyIfMacElseCtrlKey)(e)&&(e.shiftKey?r(e):n(e))})),o().createElement("button",{onClick:()=>t((e=>{e.count++})),style:{width:"200px",height:"100px"}},e.count)}},8337:(e,t,n)=>{"use strict";n.d(t,{default:()=>i});var r=n(3696),o=n(9758);const i=()=>{const e=r.useRef(null),t=r.useRef(),{x:n,y:i,setX:a,setY:s,ref:l}=(0,o.useWheelScroll)(),{scale:c,setScale:u,ref:d}=(0,o.useWheelZoom)(),[p,f]=r.useState({x:0,y:0}),{offset:h,onStart:g,mask:m,resetDragMove:y}=(0,o.useDragMove)((()=>{f((e=>({x:e.x+h.x,y:e.y+h.y})))}));(0,o.useGlobalKeyDown)((e=>{"Escape"===e.key?y():"Digit0"===e.code&&!e.shiftKey&&(0,o.metaKeyIfMacElseCtrlKey)(e)&&(u(1),a(0),s(0),f({x:0,y:0}),e.preventDefault())}));const v=(0,o.useWindowSize)(),x=v.width/2,b=v.height,C=h.x+p.x,E=h.y+p.y,[P,k]=r.useState(),w=r.useRef([...(0,o.getAxesGraphics)(),{geometry:{type:"lines",points:(0,o.getDashedLine)([0,0,0],[100,100,100],6).flat()},color:[0,0,0,1]},{geometry:{type:"sphere",radius:100},color:[1,0,0,1],position:[0,250,0]},{geometry:{type:"cube",size:150},color:[0,1,0,1],position:[250,0,0]},{geometry:{type:"cylinder",radius:100,height:200},color:[0,0,1,1],position:[-250,0,0]},{geometry:{type:"cone",topRadius:0,bottomRadius:100,height:200},color:[1,0,1,1],position:[0,-250,0]},{geometry:{type:"triangles",points:[-50,-50,50,50,50,50,-50,50,50]},color:[.5,0,.5,1],position:[250,250,250]},{geometry:{type:"vertices",vertices:(0,o.getNurbsSurfaceVertices)([[[0,0,-20],[20,0,0],[40,0,0],[60,0,0],[80,0,0],[100,0,0]],[[0,-20,0],[20,-20,10],[40,-20,20],[60,-20,0],[80,-20,0],[100,-20,0]],[[0,-40,0],[20,-40,10],[40,-40,20],[60,-40,0],[80,-40,-4],[100,-40,-24]],[[0,-50,0],[20,-60,0],[40,-60,-46],[60,-60,0],[80,-60,0],[100,-50,0]],[[0,-80,0],[20,-80,0],[40,-80,0],[60,-80,8],[80,-80,-40],[100,-80,0]],[[0,-100,24],[20,-100,0],[40,-100,40],[60,-100,0],[100,-100,-20],[100,-100,-30]]],3,[0,0,0,0,.333,.666,1,1,1,1],3,[0,0,0,0,.333,.666,1,1,1,1])},color:[0,.5,0,1],position:[-250,250,250]}]);return r.useEffect((()=>{e.current&&(t.current=(0,o.createWebgl3DRenderer)(e.current))}),[e.current]),r.useEffect((()=>{var e,r;const{position:a,up:s}=(0,o.updateCamera)(-n,i,1e3/c,-.3*C,-.3*E);w.current.forEach(((e,t)=>{e.color[3]=t===P?.5:1})),null==(r=null==(e=t.current)?void 0:e.render)||r.call(e,w.current,{eye:[a.x,a.y,a.z],up:[s.x,s.y,s.z],target:[-n,i,0],fov:(0,o.angleToRadian)(60),near:.1,far:2e4},{position:[1e3,1e3,1e3],color:[1,1,1,1],specular:[1,1,1,1],shininess:50,specularFactor:1},[1,1,1,1])}),[n,i,c,C,E,P,x,b]),r.createElement("div",{ref:(0,o.bindMultipleRefs)(l,d),style:{position:"absolute",inset:"0px"}},r.createElement("canvas",{ref:e,width:x,height:b,onMouseDown:e=>g({x:e.clientX,y:e.clientY}),onMouseMove:e=>{var n,r;return k(null==(r=null==(n=t.current)?void 0:n.pick)?void 0:r.call(n,e.clientX,e.clientY,(e=>"lines"!==e.geometry.type)))}}),m)}},1459:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n(9397),i=n(9758);const a=()=>{const e=r.useRef(null),t=r.useRef(),{x:n,y:a,ref:s,setX:l,setY:c}=(0,i.useWheelScroll)(),{scale:u,setScale:d,ref:p}=(0,i.useWheelZoom)({onChange(e,t,n){const r=(0,i.scaleByCursorPosition)({width:b,height:C},t/e,n);l(r.setX),c(r.setY)}}),{zoomIn:f,zoomOut:h}=(0,i.useZoom)(u,d),{offset:g,onStart:m,mask:y,resetDragMove:v}=(0,i.useDragMove)((()=>{l((e=>e+g.x)),c((e=>e+g.y))}));(0,i.useGlobalKeyDown)((e=>{"Escape"===e.key?v():(0,i.metaKeyIfMacElseCtrlKey)(e)&&("Minus"===e.code?h(e):"Equal"===e.code&&f(e))}));const x=(0,i.useWindowSize)(),b=x.width/2,C=x.height,E=()=>{const e=document.createElement("canvas"),t=e.getContext("2d");if(t){t.font="50px monospace";const e=t.measureText("abc");t.canvas.width=Math.ceil(e.width)+2,t.canvas.height=50,t.font="50px monospace",t.fillStyle="white",t.fillText("abc",0,t.canvas.height)}const n="round",r=void 0;return{backgroundColor:[Math.random(),Math.random(),Math.random(),1],lines:[{points:(0,i.combineStripTriangles)([(0,i.getPolylineTriangles)([{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()}],10,r,n).points,(0,i.getPolylineTriangles)([{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()}],10,r,n).points]),color:[Math.random(),Math.random(),Math.random(),1]},{points:(0,i.combineStripTriangles)([(0,i.getPolylineTriangles)([{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()}],10,r,n).points,(0,i.getPolylineTriangles)([{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()},{x:600*Math.random(),y:400*Math.random()}],10,r,n).points]),color:[Math.random(),Math.random(),Math.random(),1]}],line:[600*Math.random(),400*Math.random(),600*Math.random(),400*Math.random(),600*Math.random(),400*Math.random()],triangles:[600*Math.random(),400*Math.random(),600*Math.random(),400*Math.random(),600*Math.random(),400*Math.random()],triangleColors:[Math.random(),Math.random(),Math.random(),1,Math.random(),Math.random(),Math.random(),1,Math.random(),Math.random(),Math.random(),1],canvas:e,color:[Math.random(),Math.random(),Math.random(),1],position:{x:600*Math.random(),y:400*Math.random()}}},[P,k]=r.useState(E());return r.useEffect((()=>{if(!e.current)return;const n=e.current,r=e.current.getContext("webgl",{antialias:!0,stencil:!0});if(!r)return;r.enable(r.BLEND),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA);const a=o.createProgramInfo(r,["\n attribute vec4 position;\n uniform mat3 matrix;\n void main() {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy, 0, 1);\n }\n ","\n precision mediump float;\n uniform vec4 color;\n void main() {\n gl_FragColor = color;\n }"]),s=o.createProgramInfo(r,["\n attribute vec4 position; \n uniform mat3 matrix;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy, 0, 1);\n texcoord = position.xy;\n }\n ","\n precision mediump float;\n\n varying vec2 texcoord;\n uniform sampler2D texture;\n uniform vec4 color;\n\n void main() {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 ||\n texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n vec4 color = texture2D(texture, texcoord) * color;\n if (color.a < 0.1) {\n discard;\n }\n gl_FragColor = color;\n }"]);r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);const l=o.primitives.createXYQuadBufferInfo(r),c=o.createProgramInfo(r,["\n attribute vec4 position;\n varying vec2 texcoord;\n void main() {\n gl_Position = position;\n texcoord = position.xy * .5 + .5;\n }\n ","\n precision mediump float;\n varying vec2 texcoord;\n uniform sampler2D texture;\n void main() {\n gl_FragColor = texture2D(texture, texcoord); \n }\n "]),u=o.primitives.createXYQuadBufferInfo(r),d=o.createTexture(r,{src:"https://farm9.staticflickr.com/8873/18598400202_3af67ef38f_z_d.jpg",crossOrigin:""}),p=o.createProgramInfo(r,["\n attribute vec4 position;\n attribute vec4 color;\n uniform mat3 matrix;\n varying vec4 v_color;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position.xy, 1)).xy, 0, 1);\n v_color = color;\n }\n ","\n precision mediump float;\n\n varying vec4 v_color;\n\n void main() {\n gl_FragColor = v_color;\n }"]);t.current=(e,t,f,h)=>{r.viewport(0,0,r.canvas.width,r.canvas.height),r.useProgram(a.program),o.resizeCanvasToDisplaySize(n),r.clearColor(...e.backgroundColor),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT|r.STENCIL_BUFFER_BIT);let g=i.m3.projection(r.canvas.width,r.canvas.height);g=i.m3.multiply(g,i.m3.translation(t,f)),1!==h&&(g=i.m3.multiply(g,i.m3.translation(r.canvas.width/2,r.canvas.height/2)),g=i.m3.multiply(g,i.m3.scaling(h,h)),g=i.m3.multiply(g,i.m3.translation(-r.canvas.width/2,-r.canvas.height/2)));const m=[];for(const t of e.lines)m.push({programInfo:a,bufferInfo:o.createBufferInfoFromArrays(r,{position:{numComponents:2,data:t.points}}),uniforms:{color:t.color,matrix:g},type:r.TRIANGLE_STRIP});const y=[{programInfo:a,bufferInfo:o.createBufferInfoFromArrays(r,{position:{numComponents:2,data:e.line}}),uniforms:{color:e.color,matrix:g},type:r.LINE_STRIP}],v=[{programInfo:p,bufferInfo:o.createBufferInfoFromArrays(r,{position:{numComponents:2,data:e.triangles},color:{numComponents:4,data:e.triangleColors}}),uniforms:{matrix:g},type:r.TRIANGLES}];g=i.m3.multiply(g,i.m3.translation(e.position.x,e.position.y)),g=i.m3.multiply(g,i.m3.scaling(e.canvas.width,e.canvas.height)),o.drawObjectList(r,m),r.enable(r.STENCIL_TEST),r.stencilFunc(r.ALWAYS,1,255),r.stencilOp(r.KEEP,r.KEEP,r.REPLACE),o.drawObjectList(r,[{programInfo:s,bufferInfo:l,uniforms:{matrix:g,color:e.color,texture:o.createTexture(r,{src:e.canvas})}},{programInfo:s,bufferInfo:l,uniforms:{matrix:i.m3.multiply(g,i.m3.translation(1,0)),color:e.color,texture:o.createTexture(r,{src:e.canvas})}},{programInfo:s,bufferInfo:l,uniforms:{matrix:i.m3.multiply(g,i.m3.translation(1,1)),color:e.color,texture:o.createTexture(r,{src:e.canvas})}}]),r.stencilFunc(r.EQUAL,1,255),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),o.drawObjectList(r,[{programInfo:c,bufferInfo:u,uniforms:{texture:d}}]),r.disable(r.STENCIL_TEST),o.drawObjectList(r,y),o.drawObjectList(r,v)}}),[e.current]),r.useEffect((()=>{t.current&&t.current(P,n+g.x,a+g.y,u)}),[P,t.current,n,a,g,u]),r.createElement("div",{ref:(0,i.bindMultipleRefs)(s,p),style:{position:"absolute",inset:"0px"}},r.createElement("canvas",{ref:e,width:b,height:C,onMouseDown:e=>m({x:e.clientX,y:e.clientY})}),r.createElement("button",{style:{position:"fixed"},onClick:()=>k(E())},"update"),y)}},432:(e,t,n)=>{"use strict";n.d(t,{default:()=>i});var r=n(3696),o=n(9758);const i=()=>{const e=r.useRef(null),t=r.useRef(),{x:n,y:i,setX:a,setY:s,ref:l}=(0,o.useWheelScroll)(),{scale:c,setScale:u,ref:d}=(0,o.useWheelZoom)(),[p,f]=r.useState({x:0,y:0}),{offset:h,onStart:g,mask:m,resetDragMove:y}=(0,o.useDragMove)((()=>{f((e=>({x:e.x+h.x,y:e.y+h.y})))}));(0,o.useGlobalKeyDown)((e=>{"Escape"===e.key?y():"Digit0"===e.code&&!e.shiftKey&&(0,o.metaKeyIfMacElseCtrlKey)(e)&&(u(1),a(0),s(0),f({x:0,y:0}),e.preventDefault())}));const v=(0,o.useWindowSize)(),x=v.width/2,b=v.height,C=h.x+p.x,E=h.y+p.y,[P,k]=r.useState(),w=r.useRef([...(0,o.getAxesGraphics)(),{geometry:{type:"lines",points:(0,o.getDashedLine)([0,0,0],[100,100,100],6).flat()},color:[0,0,0,1]},{geometry:{type:"sphere",radius:100},color:[1,0,0,1],position:[0,250,0]},{geometry:{type:"cube",size:150},color:[0,1,0,1],position:[250,0,0]},{geometry:{type:"cylinder",radius:100,height:200},color:[0,0,1,1],position:[-250,0,0]},{geometry:{type:"cone",topRadius:0,bottomRadius:100,height:200},color:[1,0,1,1],position:[0,-250,0]},{geometry:{type:"triangles",points:[-50,-50,50,50,50,50,-50,50,50]},color:[.5,0,.5,1],position:[250,250,250]},{geometry:{type:"vertices",vertices:(0,o.getNurbsSurfaceVertices)([[[0,0,-20],[20,0,0],[40,0,0],[60,0,0],[80,0,0],[100,0,0]],[[0,-20,0],[20,-20,10],[40,-20,20],[60,-20,0],[80,-20,0],[100,-20,0]],[[0,-40,0],[20,-40,10],[40,-40,20],[60,-40,0],[80,-40,-4],[100,-40,-24]],[[0,-50,0],[20,-60,0],[40,-60,-46],[60,-60,0],[80,-60,0],[100,-50,0]],[[0,-80,0],[20,-80,0],[40,-80,0],[60,-80,8],[80,-80,-40],[100,-80,0]],[[0,-100,24],[20,-100,0],[40,-100,40],[60,-100,0],[100,-100,-20],[100,-100,-30]]],3,[0,0,0,0,.333,.666,1,1,1,1],3,[0,0,0,0,.333,.666,1,1,1,1])},color:[0,.5,0,1],position:[250,250,-250],rotateY:Math.PI}]);return r.useEffect((()=>{e.current&&(0,o.createWebgpu3DRenderer)(e.current).then((e=>{t.current=e,k(-1)}))}),[e.current]),r.useEffect((()=>{var e,r;const{position:a,up:s}=(0,o.updateCamera)(-n,i,1e3/c,-.3*C,-.3*E);w.current.forEach(((e,t)=>{e.color[3]=t===P?.5:1})),null==(r=null==(e=t.current)?void 0:e.render)||r.call(e,w.current,{eye:[a.x,a.y,a.z],up:[s.x,s.y,s.z],target:[-n,i,0],fov:(0,o.angleToRadian)(60),near:.1,far:2e4},{position:[1e3,1e3,1e3],color:[1,1,1,1],specular:[1,1,1,1],shininess:50,specularFactor:1},[1,1,1,1])}),[n,i,c,C,E,P,x,b]),r.createElement("div",{ref:(0,o.bindMultipleRefs)(l,d),style:{position:"absolute",inset:"0px"}},r.createElement("canvas",{ref:e,width:x,height:b,onMouseDown:e=>g({x:e.clientX,y:e.clientY}),onMouseMove:e=>{return void 0,null,n=function*(){var n,r;return k(yield null==(r=null==(n=t.current)?void 0:n.pick)?void 0:r.call(n,e.clientX,e.clientY,(e=>"lines"!==e.geometry.type&&"triangles"!==e.geometry.type)))},new Promise(((e,t)=>{var r=e=>{try{i(n.next(e))}catch(e){t(e)}},o=e=>{try{i(n.throw(e))}catch(e){t(e)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,o);i((n=n.apply(undefined,null)).next())}));var n}}),m)}},5301:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const{ref:e,x:t,y:n}=(0,i.useWheelScroll)({maxOffsetX:250,maxOffsetY:250});return o().createElement("div",{style:{width:"300px",height:"300px",overflow:"hidden",position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid green"},ref:e},o().createElement("div",{style:{width:"800px",height:"800px",position:"absolute",transform:`translate(${t}px, ${n}px)`,background:"radial-gradient(50% 50% at 50% 50%, red 0%, white 100%)"}}))}},7507:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const{ref:e,scale:t}=(0,i.useWheelZoom)();return o().createElement("div",{style:{width:"300px",height:"300px",overflow:"hidden",position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid green"},ref:e},o().createElement("div",{style:{width:"800px",height:"800px",position:"absolute",transform:`scale(${t})`,background:"radial-gradient(50% 50% at 50% 50%, red 0%, white 100%)"}}))}},6708:(e,t,n)=>{"use strict";n.d(t,{WhiteBoard:()=>u});var r=n(3696),o=n.n(r),i=n(9758),a=n(1406),s=n(7449),l=Math.pow;const c=Math.round(15*Math.random()*l(16,3)+l(16,3)).toString(16);function u(){const[,e,t]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard",[]),n=o().useRef(null),[r,l]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard:snaps",i.allSnapTypes),[u,d]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard:print-mode",!1),[p,f]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard:performance-mode",!1),[h,g]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard:render-target","svg"),[m,y]=o().useState(!1),[v,x]=o().useState(!1),[b,C]=(0,i.useLocalStorageState)("composable-editor-canvas-whiteboard:background-color",16777215),[E,P]=o().useState(),{pluginLoaded:k,pluginCommandTypes:w}=(0,a.usePlugins)();return(0,a.useInitialStateValidated)(t,k)?o().createElement("div",null,o().createElement(a.CADEditor,{ref:n,id:"whiteboard",operator:c,initialState:t,snapTypes:r,renderTarget:h,setCanUndo:y,setCanRedo:x,setOperation:P,backgroundColor:b,panelVisible:!0,printMode:u,performanceMode:p,onChange:e}),o().createElement("div",{style:{position:"relative"}},o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:u,onChange:()=>d(!u)}),"print mode"),o().createElement("label",null,o().createElement("input",{type:"checkbox",checked:p,onChange:()=>f(!p)}),"performance mode"),i.allSnapTypes.map((e=>o().createElement("label",{key:e},o().createElement("input",{type:"checkbox",checked:r.includes(e),onChange:t=>l(t.target.checked?[...r,e]:r.filter((t=>t!==e)))}),e))),["move canvas","zoom window"].map((e=>o().createElement("button",{onClick:()=>{var t;return null==(t=n.current)?void 0:t.startOperation({type:"non command",name:e})},key:e,style:{position:"relative",borderColor:E===e?"red":void 0}},e)))),o().createElement("div",{style:{position:"relative"}},w.map((e=>{if(e.icon){const t=o().cloneElement(e.icon,{onClick:()=>{var t;return null==(t=n.current)?void 0:t.startOperation({type:"command",name:e.name})},style:{width:"20px",height:"20px",margin:"5px",cursor:"pointer",color:E===e.name?"red":void 0}});return o().createElement("span",{title:e.name,key:e.name},t)}return null})),o().createElement("input",{type:"color",style:{position:"relative",top:"-5px"},value:(0,i.getColorString)(b),onChange:e=>C((0,i.colorStringToNumber)(e.target.value))}),o().createElement("button",{disabled:!m,onClick:()=>{var e;return null==(e=n.current)?void 0:e.undo()},style:{position:"relative",top:"-10px"}},"undo"),o().createElement("button",{disabled:!v,onClick:()=>{var e;return null==(e=n.current)?void 0:e.redo()},style:{position:"relative",top:"-10px"}},"redo"),o().createElement("select",{value:h,onChange:e=>g(e.target.value),style:{position:"relative",top:"-10px"}},(0,s.getAllRendererTypes)().map((e=>o().createElement("option",{key:e,value:e},e)))))):null}},1986:(e,t,n)=>{"use strict";n.d(t,{default:()=>a});var r=n(3696),o=n.n(r),i=n(9758);const a=()=>{const{width:e,height:t}=(0,i.useWindowSize)();return o().createElement("div",null,Math.round(e)," ",Math.round(t))}},3307:(e,t,n)=>{"use strict";n.r(t),n.d(t,{AlignmentLine:()=>u});var r=n(3696),o=Object.defineProperty,i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c=(e,t)=>{for(var n in t||(t={}))a.call(t,n)&&l(e,n,t[n]);if(i)for(var n of i(t))s.call(t,n)&&l(e,n,t[n]);return e};function u(e){var t,n,o,i;if(void 0===e.value)return null;const a=c({position:"absolute"},e.style);return"x"===e.type?(a.borderLeft="1px dashed black",a.left=(null!=(n=null==(t=e.transformX)?void 0:t.call(e,e.value))?n:e.value)+"px",a.top="0px",a.width="1px",a.height="100%"):(a.borderTop="1px dashed black",a.top=(null!=(i=null==(o=e.transformY)?void 0:o.call(e,e.value))?i:e.value)+"px",a.left="0px",a.width="100%",a.height="1px"),r.createElement("div",{style:a})}},7921:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ChartTooltip:()=>A,getBarChart:()=>w,getChartAxis:()=>P,getChartAxis3D:()=>T,getLineChart:()=>E,getPieChart:()=>_,getPolarAreaChart:()=>S,getRadarChart:()=>R,renderChartTooltip:()=>k});var r=n(3696),o=n.n(r),i=n(2792),a=n(8905),s=n(6842),l=n(5773),c=n(1715),u=n(2318),d=n(7486),p=n(1324),f=Object.defineProperty,h=Object.defineProperties,g=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,x=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&x(e,n,t[n]);if(m)for(var n of m(t))v.call(t,n)&&x(e,n,t[n]);return e},C=(e,t)=>h(e,g(t));function E(e,t,n,r,o,i){const a=(0,s.getPointsBounding)(e.flat());if(!a)return;const{axis:c,tx:u,ty:d,minY:p}=P(t,a,n,r,o,i),f=e.map((e=>e.map((e=>({x:u(e.x),y:d(e.y),r:e.r})))));return{children:c,points:f,select:t=>{for(let n=0;n{var n;return(0,l.getTwoPointsDistance)(e,t)<=(null!=(n=e.r)?n:5)}));if(r>=0)return C(b({},f[n][r]),{value:e[n][r]})}},minY:p}}function P(e,t,n,{width:r,height:o},i,a){var s,l,c,u,d,p,f,h;const g=null!=(s=null==a?void 0:a.axisColor)?s:13421772,m=null!=(l=null==a?void 0:a.textColor)?l:0,y=null!=(c=null==a?void 0:a.textSize)?c:12,v=null!=(u=null==a?void 0:a.fontFamily)?u:"monospace",x=null!=(d=null==a?void 0:a.textLineLength)?d:5,b=e=>{var t,n;return null!=(n=null==(t=null==a?void 0:a.getXLabel)?void 0:t.call(a,e))?n:e.toString()},C=e=>{var t,n;return null!=(n=null==(t=null==a?void 0:a.getYLabel)?void 0:t.call(a,e))?n:e.toString()},E=null!=(p=null==n?void 0:n.x)?p:1,P=null!=(f=null==n?void 0:n.y)?f:1,k=null!=(h=null==a?void 0:a.type)?h:"line",w=Math.floor(t.start.x/E)*E,_=Math.ceil(t.end.x/E)*E,S=Math.floor(t.start.y/P)*P,R=Math.ceil(t.end.y/P)*P,A=(r-i.left-i.right)/(_-w),T=(o-i.top-i.bottom)/(R-S),M=e=>(e-w)*A+i.left,L=e=>(R-e)*T+i.top,I=M(w)-x,O=M(_)+((null==a?void 0:a.ySecondary)?x:0),B=L(S),F=B+x,D=L(R),z=E*A,U=[];if(!(null==a?void 0:a.xLabelDisabled))for(let t=w;t<=_;t+=E){const n=M(t);U.push(e.renderPolyline([{x:n,y:F},{x:n,y:D}],{strokeColor:g})),U.push(e.renderText(n+("bar"===k?z/2:0),F,b(t),m,y,v,{textBaseline:"top",textAlign:"center"}))}if(!(null==a?void 0:a.yLabelDisabled))for(let t=S;t<=R;t+=P){const n=L(t);U.push(e.renderPolyline([{x:I,y:n},{x:O,y:n}],{strokeColor:g})),U.push(e.renderText(I,n,C(t),m,y,v,{textBaseline:"middle",textAlign:"right"})),(null==a?void 0:a.ySecondary)&&U.push(e.renderText(O,n,C(t),m,y,v,{textBaseline:"middle",textAlign:"left"}))}return{axis:U,minY:B,tx:M,ty:L,unitWidth:z,reverseTransform:e=>({x:(e.x-i.left)/A+w,y:R-(e.y-i.top)/T})}}function k(e,{x:t,y:n},r,o){var i,s,l,c,u,f;const h=null!=(i=null==o?void 0:o.textSize)?i:12,g=null!=(s=null==o?void 0:o.fontFamily)?s:"monospace",m=(y=r.x,null!=(x=null==(v=null==o?void 0:o.getXLabel)?void 0:v.call(o,y))?x:y.toString());var y,v,x;const b=(e=>{var t,n;return null!=(n=null==(t=null==o?void 0:o.getYLabel)?void 0:t.call(o,e))?n:e.toString()})(r.y);let C;if(null==o?void 0:o.width)C=o.width;else{const e=(0,p.getTextSizeFromCache)((0,a.getTextStyleFont)({fontFamily:g,fontSize:h}),m),t=(0,p.getTextSizeFromCache)((0,a.getTextStyleFont)({fontFamily:g,fontSize:h}),b);C=e&&t?Math.max(e.width,t.width,40):40}const E=null!=(l=null==o?void 0:o.height)?l:30,P=null!=(c=null==o?void 0:o.textColor)?c:16777215,k=null!=(u=null==o?void 0:o.radius)?u:5,w=null!=(f=null==o?void 0:o.backgroundColor)?f:0;return t+=C/2,n-=E/2,[e.renderPolygon((0,d.getRoundedRectPoints)({x:t,y:n,width:C,height:E},k,30),{fillColor:w}),e.renderText(t,n,m,P,h,g,{textBaseline:"bottom",textAlign:"center"}),e.renderText(t,n,b,P,h,g,{textBaseline:"top",textAlign:"center"})]}function w(e,t,n,r,o,i,a,l){var c,u;let d={start:{x:0,y:0},end:{x:Math.max(...e.map((e=>e.length))),y:0}};for(const t of e.flat(2))td.end.y&&(d.end.y=t);(null==l?void 0:l.bounding)&&(d=(0,s.getPointsBoundingUnsafe)([l.bounding.start,l.bounding.end,d.start,d.end]));const{axis:p,tx:f,ty:h,reverseTransform:g,unitWidth:m}=P(r,d,o,i,a,b({type:"bar"},l)),y=null!=(c=null==l?void 0:l.barPadding)?c:.1,v=null!=(u=null==l?void 0:l.barSpacing)?u:.05,x=(1-2*y-(e.length-1)*v)/e.length,E=x*m,k=x+v;return e.forEach(((e,r)=>{e.forEach(((e,o)=>{1===e.length&&(e=[0,...e]);const i=f(o)+m*(y+r*k)+E/2,a=e.map((e=>h(e)));for(let e=1;e{const n=g(t),r=Math.floor(n.x),o=n.x-r;if(o>=y&&o<=1-y){const i=Math.floor((o-y)/k);if(o-y-i*k<=x&&i>=0&&i=o[a-1]&&n.y<=o[a]){const n=e[i][r];return C(b({},t),{value:{x:r,y:n.length>2?Math.abs(n[a-1]-n[a]):n}})}}}},tx:f,ty:h}}function _(e,t,n,{width:r,height:o},i,a){var s,d;const p=null!=(s=null==a?void 0:a.type)?s:"pie",f=null!=(d=null==a?void 0:a.startAngle)?d:-90,h=e.map((e=>e.reduce(((e,t)=>e+t),0))),g={x:(r+i.left-i.right)/2,y:(o+i.top-i.bottom)/2,r:Math.min((r-i.left-i.right)/2,(o-i.top-i.bottom)/2)},m=g.r*("doughnut"===p?.5:0),y=g.r-m,v=[],x=[];return e.forEach(((r,o)=>{let i=f;const a=[],s=m+y*o/e.length,l=m+y*(o+1)/e.length;r.forEach(((e,r)=>{a.push(i);const c=i+e/h[o]*360;v.push(n.renderPolygon([...(0,u.arcToPolyline)(C(b({},g),{r:s,startAngle:i,endAngle:c}),5),...(0,u.arcToPolyline)(C(b({},g),{r:l,startAngle:c,endAngle:i,counterclockwise:!0}),5)],{fillColor:t[r],strokeColor:16777215,strokeWidth:2})),i=c})),x.push(a)})),{children:v,select:t=>{const n=(0,l.getTwoPointsDistance)(t,g),r=Math.floor((n-m)/y*e.length);if(r>=0&&re>=o));return-1===i&&(i=n.length-1),C(b({},t),{value:{x:i,y:e[r][i]}})}}}}function S(e,t,n,{width:r,height:o},a,s,d){var p,f;const h=null!=(p=null==d?void 0:d.opacity)?p:.5,g=null!=(f=null==d?void 0:d.axisColor)?f:13421772,m=Math.ceil(Math.max(...e)/a)*a,y={x:(r+s.left-s.right)/2,y:(o+s.top-s.bottom)/2,r:Math.min((r-s.left-s.right)/2,(o-s.top-s.bottom)/2)},v=e=>y.r*e/m,x=[];for(let e=a;e<=m;e+=a){const t=v(e);x.push(n.renderCircle(y.x,y.y,t,{strokeColor:g})),x.push(n.renderCircle(y.x,y.y-t,8,{fillColor:16777215,strokeWidth:0})),x.push(n.renderText(y.x,y.y-t,e.toString(),g,12,"monospace",{textAlign:"center",textBaseline:"middle"}))}let E=-90;const P=[];return e.forEach(((r,o)=>{const a=E+360/e.length;P.push((0,i.getTwoNumberCenter)(E,a)),x.push(n.renderPolygon([y,...(0,u.arcToPolyline)(C(b({},y),{r:v(r),startAngle:E,endAngle:a}),5)],{fillColor:t[o],strokeColor:16777215,strokeWidth:2,fillOpacity:h})),E=a})),{children:x,select:t=>{const n=(0,l.getTwoPointsDistance)(t,y);let r=(0,c.radianToAngle)((0,c.getTwoPointsRadian)(t,y))- -90;r<0&&(r+=360);const o=Math.floor(r*e.length/360);if(o>=0&&og.r*e/h,y=e[0].map(((t,n)=>360*n/e[0].length-90)),v=[],x=m(h);for(const e of y){const t=(0,u.getArcPointAtAngle)(C(b({},g),{r:x}),e);v.push(n.renderPolyline([g,t],{strokeColor:f}))}for(let e=i;e<=h;e+=i){const t=m(e),r=[];for(const e of y)r.push((0,u.getArcPointAtAngle)(C(b({},g),{r:t}),e));v.push(n.renderPolygon(r,{strokeColor:f})),v.push(n.renderRect(g.x-10,g.y-t-6,20,12,{fillColor:16777215,strokeWidth:0})),v.push(n.renderText(g.x,g.y-t,e.toString(),f,12,"monospace",{textAlign:"center",textBaseline:"middle"}))}const E=e.map((e=>e.map(((e,t)=>(0,u.getArcPointAtAngle)(C(b({},g),{r:m(e)}),y[t])))));return E.forEach(((e,r)=>{v.push(n.renderPolygon(e,{fillColor:t[r],strokeWidth:0,fillOpacity:p})),v.push(n.renderPolygon(e,{strokeColor:t[r],strokeWidth:2}));for(const o of e)v.push(n.renderCircle(o.x,o.y,3,{fillColor:t[r],strokeWidth:0}))})),{children:v,select:t=>{for(let n=0;n(0,l.getTwoPointsDistance)(e,t)<=3));if(r>=0)return C(b({},E[n][r]),{value:{x:r,y:e[n][r]}})}},circle:g,angles:y}}function A(e){return o().createElement("div",{style:{position:"absolute",top:e.y-35+"px",left:`${e.x}px`,display:"flex",flexDirection:"column",background:"black",color:"white",width:"40px",textAlign:"center",fontSize:"12px",borderRadius:"5px",pointerEvents:"none"}},o().createElement("span",null,e.label),o().createElement("span",null,e.value))}function T(e,t){const{minX:n,minY:r,minZ:o,maxX:i,maxY:a,maxZ:s}=function(e,t={min:1/0,max:-1/0}){let n=t.min,r=t.min,o=t.min,i=t.max,a=t.max,s=t.max;for(const t of e){const e=t[0],l=t[1],c=t[2];ei&&(i=e),la&&(a=l),cs&&(s=c)}return{maxX:i,minX:n,minY:r,maxY:a,minZ:o,maxZ:s}}(e.flat(),{min:0,max:0}),l=Math.floor(n/t.x)*t.x,c=Math.ceil(i/t.x)*t.x,u=Math.floor(r/t.y)*t.y,d=Math.ceil(a/t.y)*t.y,p=Math.floor(o/t.z)*t.z,f=Math.ceil(s/t.z)*t.z,h=[];for(let e=n;e<=c;e+=t.x)h.push({geometry:{type:"lines",points:[e,u,0,e,d,0]},color:[0,1,0,1]}),h.push({geometry:{type:"lines",points:[e,0,p,e,0,f]},color:[0,0,1,1]});for(let e=r;e<=d;e+=t.y)h.push({geometry:{type:"lines",points:[l,e,0,c,e,0]},color:[1,0,0,1]}),h.push({geometry:{type:"lines",points:[0,e,p,0,e,f]},color:[0,0,1,1]});for(let e=o;e<=f;e+=t.z)h.push({geometry:{type:"lines",points:[l,0,e,c,0,e]},color:[1,0,0,1]}),h.push({geometry:{type:"lines",points:[0,u,e,0,d,e]},color:[0,1,0,1]});return h}},6487:(e,t,n)=>{"use strict";n.d(t,{Cursor:()=>f});var r=n(3696),o=n.n(r),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))u.call(t,n)&&d(e,n,t[n]);return e};const f=o().forwardRef(((e,t)=>{var n,r;const[i,l]=o().useState(!1),[c,u]=o().useState(!1),d=o().useRef();return o().useEffect((()=>{u(!0),d.current&&clearTimeout(d.current),d.current=setTimeout((()=>{u(!1)}),500)}),[null==(n=e.style)?void 0:n.left,null==(r=e.style)?void 0:r.top]),o().createElement(o().Fragment,null,o().createElement("input",{ref:t,style:(f=p({},e.style),h={border:0,outline:"none",width:"0px",position:"absolute",opacity:0},a(f,s(h))),readOnly:e.readOnly,onKeyDown:e.onKeyDown,onCompositionEnd:e.onCompositionEnd,onBlur:t=>{var n;null==(n=e.onBlur)||n.call(e,t),l(!1)},autoFocus:e.autoFocus,onFocus:t=>{var n;null==(n=e.onFocus)||n.call(e,t),l(!0)}}),o().createElement("style",null,"@-webkit-keyframes blink {\n 0%, 49.9%, 100% { opacity: 0; }\n 50%, 99.9% { opacity: 1; }\n }"),o().createElement("span",{style:p({display:!i||e.readOnly?"none":"inline-block",position:"absolute",width:"1px",animation:c?void 0:"blink 1s infinite",borderLeft:"1px solid black",userSelect:"none"},e.style)}));var f,h}))},9294:(e,t,n)=>{"use strict";n.r(t),n.d(t,{LinearDimension:()=>a,getLinearDimensionGeometries:()=>o,getLinearDimensionTextPosition:()=>i});var r=n(1324);function o(e,t,n){const o=(0,r.getTwoPointCenter)(e.p1,e.p2);let i,a,s,l,c,u=[];const{textPosition:d,size:p,textRotation:f}=n(e),h=(0,r.getTwoPointsRadian)(e.position,o),g=Math.abs(h);if(e.direct){const n=e.p1.x>e.p2.x?e.p2:e.p1,o=e.p1.x>e.p2.x?e.p1:e.p2,u=(0,r.twoPointLineToGeneralFormLine)(n,o),d=u?(0,r.getPerpendicularDistance)(e.position,u):(0,r.getTwoPointsDistance)(e.position,n),f=(0,r.getTwoPointsRadian)(o,n);let g=f-h;g<-Math.PI&&(g+=2*Math.PI);const m=g>0&&gMath.PI/4&&g<3*Math.PI/4){const n=e.position.y>o.y?1:-1;i=[e.p1,{x:e.p1.x,y:e.position.y+n*t.margin}],a=[e.p2,{x:e.p2.x,y:e.position.y+n*t.margin}];const u={x:e.p1.x,y:e.position.y},d={x:e.p2.x,y:e.position.y};s=[{x:Math.min(e.p1.x,e.p2.x,e.position.x),y:e.position.y},{x:Math.max(e.p1.x,e.p2.x,e.position.x),y:e.position.y}];let f=u.xo.x?1:-1;i=[e.p1,{x:e.position.x+n*t.margin,y:e.p1.y}],a=[e.p2,{x:e.position.x+n*t.margin,y:e.p2.y}];const u={x:e.position.x,y:e.p1.y},d={x:e.position.x,y:e.p2.y};s=[{x:e.position.x,y:Math.min(e.p1.y,e.p2.y,e.position.y)},{x:e.position.x,y:Math.max(e.p1.y,e.p2.y,e.position.y)}];let f=u.y(0,r.rotatePosition)(e,d,f))));const m=[...i,...a,...s,...l,...c,...u];return{lines:[...(0,r.iteratePolylineLines)(i),...(0,r.iteratePolylineLines)(a),...(0,r.iteratePolylineLines)(s)],regions:[{points:l,lines:Array.from((0,r.iteratePolygonLines)(l))},{points:c,lines:Array.from((0,r.iteratePolygonLines)(c))},{points:u,lines:Array.from((0,r.iteratePolygonLines)(u))}],points:m,bounding:(0,r.getPointsBounding)(m),renderingLines:[]}}function i(e,t,n){const o=(0,r.getTwoPointCenter)(e.p1,e.p2);let i,a,s,l=0;const c=(0,r.getTwoPointsRadian)(e.position,o),u=Math.abs(c);if(e.direct){const o=e.p1.x>e.p2.x?e.p2:e.p1,u=e.p1.x>e.p2.x?e.p1:e.p2,d=(0,r.twoPointLineToGeneralFormLine)(o,u),p=d?(0,r.getPerpendicularPoint)(e.position,d):o,f=(0,r.getTwoPointsDistance)(e.position,p);l=(0,r.getTwoPointsRadian)(u,o);let h=(0,r.getTwoPointsRadian)(u,o)-c;h<-Math.PI&&(h+=2*Math.PI);const g=h>0&&hMath.PI/4&&u<3*Math.PI/4?(i={x:e.position.x,y:e.position.y-t},a=(0,r.formatNumber)((0,r.getTwoNumbersDistance)(e.p1.x,e.p2.x)).toString(),s=n((0,r.getTextStyleFont)(e),a),s&&(i.x-=s.width/2)):(i={x:e.position.x-t,y:e.position.y},a=(0,r.formatNumber)((0,r.getTwoNumbersDistance)(e.p1.y,e.p2.y)).toString(),s=n((0,r.getTextStyleFont)(e),a),s&&(i.y+=s.width/2),l=-Math.PI/2);return{text:e.text||a,textPosition:i,size:s,textRotation:l}}const a=(0,r.and)(r.TextStyle,{p1:r.Position,p2:r.Position,position:r.Position,direct:(0,r.optional)(r.boolean),text:(0,r.optional)(r.string)})},6424:(e,t,n)=>{"use strict";n.r(t),n.d(t,{RadialDimension:()=>a,getRadialDimensionGeometries:()=>o,getRadialDimensionTextPosition:()=>i});var r=n(1324);function o(e,t,n,o){const i=(0,r.getPointByLengthAndDirection)(t,t.r,e.position),a=(0,r.getTwoPointsDistance)(t,e.position),s=(0,r.getPointByLengthAndDirection)(i,n.arrowSize,e.position),l=(0,r.rotatePositionByCenter)(s,i,n.arrowAngle),c=(0,r.rotatePositionByCenter)(s,i,-n.arrowAngle),u=[a>t.r?t:i,e.position],d=[i,l,c];let p=[];const{textPosition:f,textRotation:h,size:g}=o(e,t);g&&(p=[{x:f.x,y:f.y-g.height},{x:f.x+g.width,y:f.y-g.height},{x:f.x+g.width,y:f.y},{x:f.x,y:f.y}].map((e=>(0,r.rotatePosition)(e,f,h))));const m=[...u,...d,...p];return{lines:Array.from((0,r.iteratePolylineLines)(u)),regions:[{points:d,lines:Array.from((0,r.iteratePolygonLines)(d))},{points:p,lines:Array.from((0,r.iteratePolygonLines)(p))}],points:m,bounding:(0,r.getPointsBounding)(m),renderingLines:[]}}function i(e,t,n,o){let i=e.position;const a=`R${(0,r.formatNumber)(t.r)}`,s=o((0,r.getTextStyleFont)(e),a);let l=(0,r.getTwoPointsRadian)(e.position,t);return s&&((0,r.getTwoPointsDistance)(t,e.position)>t.r?e.position.x>t.x?i=(0,r.getPointByLengthAndDirection)(e.position,s.width,t):l-=Math.PI:e.position.x{"use strict";n.r(t),n.d(t,{DragMask:()=>u});var r=n(3696),o=Object.defineProperty,i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c=(e,t)=>{for(var n in t||(t={}))a.call(t,n)&&l(e,n,t[n]);if(i)for(var n of i(t))s.call(t,n)&&l(e,n,t[n]);return e};function u(e){return r.createElement("div",{style:c({position:"fixed",inset:"0px",cursor:"grabbing"},e.style),onMouseUp:e.onDragEnd,onMouseMove:e.onDragging,onMouseLeave:e.ignoreLeavingEvent?void 0:e.onDragEnd},e.children)}},4848:(e,t,n)=>{"use strict";n.r(t),n.d(t,{CircleArcEditBar:()=>a});var r=n(3696),o=n(1324),i=n(2286);function a(e){const t=e.x,n=e.y,a=(0,o.angleToRadian)(e.startAngle),s=(0,o.angleToRadian)(e.endAngle),l=(a+s)/2,c=[{data:"center",x:t,y:n,cursor:"move"},{data:"start angle",x:t+e.r*Math.cos(a),y:n+e.r*Math.sin(a),cursor:(0,o.getResizeCursor)(e.startAngle,"top")},{data:"end angle",x:t+e.r*Math.cos(s),y:n+e.r*Math.sin(s),cursor:(0,o.getResizeCursor)(e.endAngle,"top")},{data:"radius",x:t+e.r*Math.cos(l),y:n+e.r*Math.sin(l),cursor:(0,o.getResizeCursor)((e.startAngle+e.endAngle)/2,"right")}];return r.createElement(i.EditBar,{positions:c,scale:e.scale,resizeSize:e.resizeSize,onClick:e.onClick,onMouseDown:e.onMouseDown})}},1369:(e,t,n)=>{"use strict";n.r(t),n.d(t,{CircleEditBar:()=>i});var r=n(3696),o=n(2286);function i(e){const t=e.x,n=e.y,i=[{data:"center",x:t,y:n,cursor:"move"},{data:"edge",x:t-e.radius,y:n,cursor:"ew-resize"},{data:"edge",x:t,y:n-e.radius,cursor:"ns-resize"},{data:"edge",x:t+e.radius,y:n,cursor:"ew-resize"},{data:"edge",x:t,y:n+e.radius,cursor:"ns-resize"}];return r.createElement(o.EditBar,{positions:i,scale:e.scale,resizeSize:e.resizeSize,onClick:e.onClick,onMouseDown:e.onMouseDown})}},2286:(e,t,n)=>{"use strict";n.r(t),n.d(t,{EditBar:()=>o});var r=n(3696);function o(e){var t,n;const o=null!=(t=e.scale)?t:1,i=(null!=(n=e.resizeSize)?n:5)/o,a=1/o;return r.createElement(r.Fragment,null,e.positions.map(((t,n)=>r.createElement("div",{key:n,style:{width:i+"px",height:i+"px",border:`${a}px solid green`,position:"absolute",backgroundColor:"white",boxSizing:"border-box",pointerEvents:"auto",left:t.x-i/2+"px",top:t.y-i/2+"px",cursor:t.cursor},onMouseDown:n=>{var r;return null==(r=e.onMouseDown)?void 0:r.call(e,n,t.data,t.cursor)},onClick:n=>{var r;return null==(r=e.onClick)?void 0:r.call(e,n,t.data,t.cursor)}}))))}},4332:(e,t,n)=>{"use strict";n.r(t),n.d(t,{EllipseArcEditBar:()=>g});var r=n(3696),o=n(1324),i=n(2286),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))u.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))d.call(t,n)&&p(e,n,t[n]);return e},h=(e,t)=>s(e,l(t));function g(e){var t;const n={x:e.cx,y:e.cy},a=(0,o.angleToRadian)(e.startAngle),s=(0,o.angleToRadian)(e.endAngle),l=-(null!=(t=e.angle)?t:0),c=[{data:"center",x:e.cx,y:e.cy,cursor:"move"},h(f({data:"start angle"},(0,o.rotatePositionByCenter)({x:e.cx+e.rx*Math.cos(a),y:e.cy+e.ry*Math.sin(a)},n,l)),{cursor:(0,o.getResizeCursor)(e.startAngle-l,"top")}),h(f({data:"end angle"},(0,o.rotatePositionByCenter)({x:e.cx+e.rx*Math.cos(s),y:e.cy+e.ry*Math.sin(s)},n,l)),{cursor:(0,o.getResizeCursor)(e.endAngle-l,"top")})];return r.createElement(i.EditBar,{positions:c,scale:e.scale,resizeSize:e.resizeSize,onClick:e.onClick,onMouseDown:e.onMouseDown})}},3869:(e,t,n)=>{"use strict";n.r(t),n.d(t,{EllipseEditBar:()=>a});var r=n(3696),o=n(1324),i=n(2286);function a(e){var t;const n={x:e.cx,y:e.cy},a=-(null!=(t=e.angle)?t:0),s=(0,o.rotatePositionByCenter)({x:e.cx-e.rx,y:e.cy},n,a),l=(0,o.rotatePositionByCenter)({x:e.cx+e.rx,y:e.cy},n,a),c=(0,o.rotatePositionByCenter)({x:e.cx,y:e.cy-e.ry},n,a),u=(0,o.rotatePositionByCenter)({x:e.cx,y:e.cy+e.ry},n,a),d=[{data:"center",x:e.cx,y:e.cy,cursor:"move"},{data:"major axis",x:s.x,y:s.y,cursor:(0,o.getResizeCursor)(-a,"left")},{data:"major axis",x:l.x,y:l.y,cursor:(0,o.getResizeCursor)(-a,"right")},{data:"minor axis",x:c.x,y:c.y,cursor:(0,o.getResizeCursor)(-a,"top")},{data:"minor axis",x:u.x,y:u.y,cursor:(0,o.getResizeCursor)(-a,"bottom")}];return r.createElement(i.EditBar,{positions:d,scale:e.scale,resizeSize:e.resizeSize,onClick:e.onClick,onMouseDown:e.onMouseDown})}},4489:(e,t,n)=>{"use strict";n.r(t),n.d(t,{PolylineEditBar:()=>a});var r=n(3696),o=n(1324),i=n(2286);function a(e){const t=e.points,n=!e.isPolygon&&t.length>2&&(0,o.isSamePoint)(t[0],t[t.length-1]),a=[];if(t.forEach(((r,o)=>{if(!e.isPolygon&&o===t.length-1&&n||a.push({data:[o],x:r.x,y:r.y,cursor:"move"}),!e.midpointDisabled&&o!==t.length-1){const e=t[o+1];a.push({data:[o,o+1],x:(r.x+e.x)/2,y:(r.y+e.y)/2,cursor:"move"})}if(e.isPolygon&&o===t.length-1){const e=t[0];a.push({data:[t.length-1,0],x:(r.x+e.x)/2,y:(r.y+e.y)/2,cursor:"move"})}})),n)for(const e of a)e.data.includes(0)?e.data.push(t.length-1):e.data.includes(t.length-1)&&e.data.push(0);return r.createElement(i.EditBar,{positions:a,scale:e.scale,resizeSize:e.resizeSize,onClick:e.onClick,onMouseDown:e.onMouseDown})}},5634:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ResizeBar:()=>d});var r=n(3696),o=n(9758),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(e,n,t[n]);return e};function d(e){var t,n,i;const{resizeSize:a}=e,s=null!=(t=e.scale)?t:1,l=(null!=a?a:5)/s,c=1/s,d=l/2,p=l/2-c,f=null!=(n=e.rotate)?n:0,h=null!=(i=e.directions)?i:o.allDirections,g=[];for(const e of o.allDirections)if(h.includes(e)){const t={cursor:(0,o.getResizeCursor)(f,e)};e.includes("left")&&(t.left=-d+"px"),e.includes("right")&&(t.right=-p+"px"),e.includes("top")&&(t.top=-d+"px"),e.includes("bottom")&&(t.bottom=-p+"px"),"left"!==e&&"right"!==e&&"center"!==e||(t.top=`calc(50% - ${d}px)`),"top"!==e&&"bottom"!==e&&"center"!==e||(t.left=`calc(50% - ${d}px)`),g.push({direction:e,style:t})}return r.createElement(r.Fragment,null,g.map(((t,n)=>r.createElement("div",{key:n,style:u({width:l+"px",height:l+"px",border:`${c}px solid green`,position:"absolute",backgroundColor:"white",boxSizing:"border-box",pointerEvents:"auto"},t.style),onMouseDown:n=>{var r;null==(r=e.onMouseDown)||r.call(e,n,t.direction)},onClick:n=>{var r;null==(r=e.onClick)||r.call(e,n,t.direction)}}))))}},2800:(e,t,n)=>{"use strict";n.r(t),n.d(t,{RotationBar:()=>o});var r=n(3696);function o(e){var t,n,o;const i=null!=(t=e.scale)?t:1,a=(null!=(n=e.rotateStickLength)?n:40)/i,s=1/i,l=(null!=(o=e.rotateCircleSize)?o:10)/i;return r.createElement(r.Fragment,null,r.createElement("div",{style:{left:`calc(50% - ${s/2}px)`,top:-a+"px",width:Math.max(s,1)+"px",height:a+"px",position:"absolute",boxSizing:"border-box",backgroundColor:"green"}}),r.createElement("div",{style:{left:`calc(50% - ${s/2+l/2}px)`,top:-a-l+"px",width:l+"px",height:l+"px",position:"absolute",border:`${Math.max(s,1)}px solid green`,backgroundColor:"white",borderRadius:l/2+"px",cursor:"grab",pointerEvents:"auto"},onMouseDown:e.onMouseDown}))}},2607:(e,t,n)=>{"use strict";n.r(t),n.d(t,{renderEquation:()=>d,renderExpression:()=>p});var r=n(3031),o=n(8905),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(e,n,t[n]);return e};function d(e,t,n={}){const r=u(u({},f),n),{children:i,render:a,font:s}=h(e,r.color,r.fontSize,r.fontFamily,r.paddingOperator,r.keepBinaryExpressionOrder),l=a(t.left),c=a(t.right);let d;if(l&&c){const t=" = ",n=(0,o.getTextSizeFromCache)(s,t);if(n){const o=l.size.width+n.width+c.size.width,a=Math.max(l.size.height,n.height,c.size.height),s=o+2*r.paddingX,u=a+2*r.paddingY,p=u/2;let f=s/2-o/2;l.render(f+l.size.width/2,p),f+=l.size.width,i.push(e.renderText(f+n.width/2,p,t,r.color,r.fontSize,r.fontFamily,{textBaseline:"middle",textAlign:"center"})),f+=n.width,c.render(f+c.size.width/2,p),d=e.renderResult(i,s,u,{attributes:{style:{width:"100%"}}})}}return d}function p(e,t,n={}){const r=u(u({},f),n),{children:o,render:i}=h(e,r.color,r.fontSize,r.fontFamily,r.paddingOperator,r.keepBinaryExpressionOrder),a=i(t);let s;if(a){const t=a.size.width+2*r.paddingX,n=a.size.height+2*r.paddingY;a.render(t/2,n/2),s=e.renderResult(o,t,n,{attributes:{style:{width:"100%"}}})}return s}const f={color:0,fontSize:20,fontFamily:"monospace",paddingX:10,paddingY:10,paddingOperator:5,keepBinaryExpressionOrder:!1};function h(e,t,n,i,a,s){const l=[],c=`${n}px ${i}`,u=(d,p=Number.MAX_SAFE_INTEGER,f=1,h=!1)=>{const g=n*f,m=1===f?c:`${g}px ${i}`;if("BinaryExpression"===d.type){const n="/"===d.operator||"**"===d.operator&&"NumericLiteral"===d.right.type&&.5===d.right.value?Number.MAX_SAFE_INTEGER:r.priorizedBinaryOperators.findIndex((e=>e.includes(d.operator))),c=u(d.left,n,f),h=u(d.right,"+"===d.operator||"*"===d.operator?n:n-.1,"**"===d.operator?.75*f:f);if(c&&h){if("**"===d.operator){if("NumericLiteral"===d.right.type&&.5===d.right.value){const n=c.size.width+2*a,r=c.size.height+a;return{size:{width:n,height:r},render(o,i){c.render(o+a,i+a/2),l.push(e.renderPolyline([{x:o+n/2,y:i-r/2},{x:o-n/2+2*a,y:i-r/2},{x:o-n/2+a,y:i+r/2},{x:o-n/2,y:i+r/2-a}],{strokeColor:t,strokeWidth:1}))}}}const n=c.size.width+h.size.width,r=c.size.height+h.size.height/2;return{size:{width:n,height:r},render(e,t){c.render(e-n/2+c.size.width/2,t+r/2-c.size.height/2-h.size.height/4),h.render(e-n/2+c.size.width+h.size.width/2,t-r/2+h.size.height/2)}}}if("/"===d.operator){let r=Math.max(c.size.width,h.size.width)+2*a;const s=c.size.height+2*a+h.size.height;let u;const d=Math.max(s,g);return n>p&&(u=(0,o.getTextSizeFromCache)(`${d}px ${i}`,"(")),u&&(r+=2*u.width),{size:{width:r,height:s},render(n,o){var p;o=o-s/2+c.size.height+a,u&&l.push(e.renderText(n-r/2+u.width/2,o,"(",t,d,i,{textBaseline:"middle",textAlign:"center"})),c.render(n,o-a-c.size.height/2);const f=null!=(p=null==u?void 0:u.width)?p:0;l.push(e.renderPolyline([{x:n-r/2+f,y:o},{x:n+r/2-f,y:o}],{strokeColor:t,strokeWidth:1})),h.render(n,o+a+h.size.height/2),u&&l.push(e.renderText(n+r/2-u.width/2,o,")",t,d,i,{textBaseline:"middle",textAlign:"center"}))}}}const r="*"===d.operator?"":d.operator,u=(0,o.getTextSizeFromCache)(m,r);if(u){let d=c.size.width+u.width+h.size.width+a*(u.width?2:0);const f=Math.max(c.size.height,u.height,h.size.height);let m;const y=Math.max(f,g);return(n>p||n===p&&s)&&(m=(0,o.getTextSizeFromCache)(`${y}px ${i}`,"(")),m&&(d+=2*m.width),{size:{width:d,height:f},render(n,o){let s=n-d/2;m&&(l.push(e.renderText(s+m.width/2,o,"(",t,y,i,{textBaseline:"middle",textAlign:"center"})),s+=m.width),c.render(s+c.size.width/2,o),s+=c.size.width,u.width&&(s+=a,l.push(e.renderText(s+u.width/2,o,r,t,g,i,{textBaseline:"middle",textAlign:"center"})),s+=u.width+a),h.render(s+h.size.width/2,o),m&&(s+=h.size.width,l.push(e.renderText(s+m.width/2,o,")",t,y,i,{textBaseline:"middle",textAlign:"center"})))}}}}return}if("UnaryExpression"===d.type){const n=(0,o.getTextSizeFromCache)(c,d.operator),r=u(d.argument,-1,f);if(n&&r){let a=n.width+r.size.width;const s=Math.max(n.height,r.size.height);let c;const u=Math.max(s,g);return p<=1&&(c=(0,o.getTextSizeFromCache)(`${u}px ${i}`,"(")),c&&(a+=2*c.width),{size:{width:a,height:s},render(o,s){var p;c&&l.push(e.renderText(o-a/2+c.width/2,s,"(",t,u,i,{textBaseline:"middle",textAlign:"center"}));const f=null!=(p=null==c?void 0:c.width)?p:0;l.push(e.renderText(o-a/2+n.width/2+f,s,d.operator,t,g,i,{textBaseline:"middle",textAlign:"center"})),r.render(o-a/2+n.width+r.size.width/2+f,s),c&&l.push(e.renderText(o+a/2-c.width/2,s,")",t,u,i,{textBaseline:"middle",textAlign:"center"}))}}}return}let y;if("Identifier"===d.type){if(!h&&d.name.length>1){const e=u({type:"Identifier",name:d.name[0]},void 0,f),t=u({type:"Identifier",name:d.name.substring(1)},void 0,.75*f,!0);if(e&&t){const n=e.size.width+t.size.width,r=e.size.height+t.size.height/2;return{size:{width:n,height:r},render(o,i){e.render(o-n/2+e.size.width/2,i-r/2+e.size.height/2+t.size.height/4),t.render(o-n/2+e.size.width+t.size.width/2,i+r/2-t.size.height/2)}}}}y=d.name}else"NumericLiteral"===d.type&&(y=d.value.toString());if(y){const n=(0,o.getTextSizeFromCache)(c,y);if(n){const r=y;return{size:n,render:(n,o)=>l.push(e.renderText(n,o,r,t,g,i,{textBaseline:"middle",textAlign:"center"}))}}}};return{font:c,children:l,render:u}}},123:(e,t,n)=>{"use strict";n.r(t),n.d(t,{divide:()=>i,divideFactors:()=>l,expressionToFactors:()=>f,extractFactors:()=>a,factorToExpression:()=>m,factorsToExpression:()=>g,optimizeFactor:()=>C,optimizeFactors:()=>b,powerFactor:()=>y});var r=n(6072),o=Math.pow;function i(e,t){const n=f(e);if(!n)return;const r=f(t);if(!r)return;const o=l(n,r);return o?g(o):void 0}function a(e,t){let n;for(const r of e){const e=s(r,t);if(!e)return;if(n){const t={variables:{},constant:E(n.constant,e.constant)};for(const[r,o]of Object.entries(e.variables)){const e=n.variables[r];e&&(t.variables[r]=Math.min(e,o))}n=t}else n=e}if(n&&(Object.keys(n.variables).length>0||n.constant>1)){const r={constant:o(n.constant,1/t),variables:[]},i={constant:n.constant,variables:[]};for(const[e,o]of Object.entries(n.variables))r.variables.push(...new Array(o).fill(e)),i.variables.push(...new Array(o*t).fill(e));const a=l(e,[i]);if(!a)return;return{base:r,factors:a}}}function s(e,t){var n,r;const o=new Map;for(const t of e.variables){if("string"!=typeof t)return;o.set(t,(null!=(n=o.get(t))?n:0)+1)}const i=null!=(r=e.constant)?r:1,a={variables:{},constant:Number.isInteger(i)&&i?Math.abs(i):1};for(const[e,n]of o)n>=t&&(a.variables[e]=Math.floor(n/t));if(Object.keys(a.variables).length>0)return a}function l(e,t){for(const n of e){const r=p(n,t[0]);if(r){const n=d(e,t.map((e=>v(e,r))));if(0===n.length)return[r];if(n.length>e.length)continue;const o=l(n,t);if(!o)continue;return[r,...o]}}}function c(e,t){var n,r;const o=p(e,t);if(o&&0===o.variables.length)return(null!=(n=e.constant)?n:1)-(null!=(r=t.constant)?r:1)}function u(e,t){var n,r;const o=p(e,t);if(o&&0===o.variables.length)return(null!=(n=e.constant)?n:1)+(null!=(r=t.constant)?r:1)}function d(e,t){var n;const r=[...e];for(const e of t){let t=!1;for(let n=0;n=0)o.splice(t,1);else{for(let n=0;nx(e)))),[...t,...n]}const t=h(e);if(t)return[t]}function h(e){if("NumericLiteral"===e.type)return{constant:e.value,variables:[]};if("Identifier"===e.type)return{variables:[e.name]};if("UnaryExpression"===e.type&&"-"===e.operator){const t=h(e.argument);if(!t)return;return x(t)}if("BinaryExpression"===e.type){if("*"===e.operator){const t=h(e.left);if(!t)return;const n=h(e.right);if(!n)return;return v(t,n)}if("/"===e.operator){const t=h(e.left);if(!t)return;const n=h(e.right);if(!n)return;return p(t,n)||(t.variables.push({value:[n],power:-1}),t)}if("**"===e.operator){if("NumericLiteral"===e.right.type&&e.right.value<1){const t=f(e.left);if(!t)return;return{variables:[{value:t,power:e.right.value}]}}const t=h(e.left);if(!t)return;if("NumericLiteral"!==e.right.type)return;if(!Number.isInteger(e.right.value))return;if(e.right.value<1)return;return y(t,e.right.value)}}return"CallExpression"===e.type?{variables:[(0,r.printMathStyleExpression)(e)]}:void 0}function g(e){if(0===e.length)return{type:"NumericLiteral",value:0};if(1===e.length)return m(e[0]);const[t,...n]=e;return{type:"BinaryExpression",left:m(t),operator:"+",right:g(n)}}function m(e){var t;if(0===e.variables.length)return{type:"NumericLiteral",value:null!=(t=e.constant)?t:1};if(void 0!==e.constant)return{type:"BinaryExpression",left:{type:"NumericLiteral",value:e.constant},operator:"*",right:m({variables:e.variables})};if(1===e.variables.length){const t=e.variables[0];return"string"!=typeof t?{type:"BinaryExpression",left:g(t.value),operator:"**",right:{type:"NumericLiteral",value:t.power}}:{type:"Identifier",name:t}}const[n,...r]=[...e.variables];return{type:"BinaryExpression",left:m({variables:[n]}),operator:"*",right:m({variables:r})}}function y(e,t){let n=1;const r=[];for(let o=0;o"string"==typeof e));let n=e.constant||1;for(const r of e.variables)if("string"!=typeof r){if(-1===r.power){for(const e of r.value){e.constant&&(n/=e.constant);for(const n of e.variables){const e=t.indexOf(n);e>=0?t.splice(e,1):t.push({power:-1,value:[{variables:[n]}]})}}continue}t.push(r)}return{variables:t,constant:1===n?void 0:n}}function E(e,t){return e<=1||t<=1?1:e===t?e:e>t?E(e%t,t):E(e,t%e)}},4546:(e,t,n)=>{"use strict";n.r(t);var r=n(4281),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(123);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(6277);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(7492);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o)},6277:(e,t,n)=>{"use strict";n.r(t),n.d(t,{expressionHasVariable:()=>p,getReverseOperator:()=>x,iterateEquation:()=>d,iterateExpression:()=>u,optimizeEquation:()=>f,optimizeExpression:()=>v,printEquation:()=>h});var r=n(3031),o=n(2792),i=n(123),a=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),s=Math.pow,l=function(e,t){this[0]=e,this[1]=t},c=e=>{var t,n=e[a("asyncIterator")],r=!1,o={};return null==n?(n=e[a("iterator")](),t=e=>o[e]=t=>n[e](t)):(n=n.call(e),t=e=>o[e]=t=>{if(r){if(r=!1,"throw"===e)throw t;return t}return r=!0,{done:!1,value:new l(new Promise((r=>{var o=n[e](t);if(!(o instanceof Object))throw TypeError("Object expected");r(o)})),1)}}),o[a("iterator")]=()=>o,t("next"),"throw"in n?t("throw"):o.throw=e=>{throw e},"return"in n&&t("return"),o};function*u(e){yield e,"BinaryExpression"===e.type?(yield*c(u(e.left)),yield*c(u(e.right))):"UnaryExpression"===e.type&&(yield*c(u(e.argument)))}function*d(e){yield*c(u(e.left)),yield*c(u(e.right))}function p(e,t){for(const n of u(e))if("Identifier"===n.type&&n.name===t)return!0;return!1}function f(e,t){return e.left=v(e.left,t),e.right=v(e.right,t),e}function h(e,t){return(0,r.printExpression)(e.left,t)+" = "+(0,r.printExpression)(e.right,t)}function g(e,t){return e.type===t.type&&("BinaryExpression"===e.type&&"BinaryExpression"===t.type?e.operator===t.operator&&g(e.left,t.left)&&g(e.right,t.right):"UnaryExpression"===e.type&&"UnaryExpression"===t.type?e.operator===t.operator&&g(e.argument,t.argument):"NumericLiteral"===e.type&&"NumericLiteral"===t.type?e.value===t.value:"Identifier"===e.type&&"Identifier"===t.type?e.name===t.name:"CallExpression"===e.type&&"CallExpression"===t.type&&g(e.callee,t.callee)&&e.arguments.length===t.arguments.length&&e.arguments.every(((e,n)=>g(e,t.arguments[n]))))}function m(e,t){return"UnaryExpression"===e.type?m(e.argument,t):"UnaryExpression"===t.type?m(e,t.argument):"BinaryExpression"===e.type&&"BinaryExpression"===t.type?!!m(e.left,t.left)||!!g(e,t)&&m(e.right,t.right):"Identifier"===e.type&&"Identifier"===t.type&&e.name>t.name}function y(e){return"UnaryExpression"===e.type&&"NumericLiteral"===e.argument.type||"NumericLiteral"===e.type}function v(e,t){const n=e=>{if("BinaryExpression"===e.type){if(e.left=n(e.left),e.right=n(e.right),"NumericLiteral"===e.left.type&&"NumericLiteral"===e.right.type){let t;if("+"===e.operator)t=e.left.value+e.right.value;else if("-"===e.operator)t=e.left.value-e.right.value;else if("*"===e.operator)t=e.left.value*e.right.value;else if("/"===e.operator)t=e.left.value/e.right.value;else{if("**"!==e.operator)throw new Error(`Unsupported operator: ${e.operator}`);t=s(e.left.value,e.right.value)}return{type:"NumericLiteral",value:t}}if("NumericLiteral"===e.left.type&&(0,o.isZero)(e.left.value)){if("+"===e.operator)return e.right;if("-"===e.operator)return n({type:"UnaryExpression",operator:"-",argument:e.right});if("*"===e.operator||"/"===e.operator)return e.left}if("NumericLiteral"===e.right.type&&(0,o.isZero)(e.right.value)){if("+"===e.operator||"-"===e.operator)return e.left;if("*"===e.operator)return e.right;if("**"===e.operator)return{type:"NumericLiteral",value:1}}if("NumericLiteral"===e.right.type&&1===e.right.value&&("*"===e.operator||"/"===e.operator||"**"===e.operator))return e.left;if("NumericLiteral"===e.left.type&&1===e.left.value&&"*"===e.operator)return e.right;if("NumericLiteral"===e.right.type&&-1===e.right.value&&("*"===e.operator||"/"===e.operator))return{type:"UnaryExpression",argument:e.left,operator:"-"};if("NumericLiteral"===e.left.type&&-1===e.left.value&&"*"===e.operator)return{type:"UnaryExpression",argument:e.right,operator:"-"};if(g(e.left,e.right)){if("+"===e.operator)return n({type:"BinaryExpression",left:{type:"NumericLiteral",value:2},operator:"*",right:e.left});if("-"===e.operator)return{type:"NumericLiteral",value:0};if("*"===e.operator)return n({type:"BinaryExpression",left:e.left,operator:"**",right:{type:"NumericLiteral",value:2}});if("/"===e.operator)return{type:"NumericLiteral",value:1}}if("UnaryExpression"===e.left.type&&"-"===e.left.operator&&g(e.left.argument,e.right)){if("+"===e.operator)return{type:"NumericLiteral",value:0};if("-"===e.operator)return n({type:"BinaryExpression",left:{type:"NumericLiteral",value:-2},operator:"*",right:n(e.left.argument)});if("/"===e.operator)return{type:"NumericLiteral",value:-1}}if("-"===e.operator&&"NumericLiteral"===e.right.type)return n({type:"BinaryExpression",left:e.left,operator:"+",right:{type:"NumericLiteral",value:-e.right.value}});if("/"===e.operator&&"NumericLiteral"===e.right.type){const t=(0,i.expressionToFactors)(e.left);if(t){const r=e.right.value;return t.forEach((e=>{var t;e.constant=(null!=(t=e.constant)?t:1)/r})),n((0,i.factorsToExpression)(t))}return{type:"BinaryExpression",left:e.left,operator:"*",right:{type:"NumericLiteral",value:1/e.right.value}}}if("-"===e.operator&&"UnaryExpression"===e.right.type&&"-"===e.right.operator)return n({type:"BinaryExpression",operator:"+",left:e.left,right:n(e.right.argument)});if("-"===e.operator&&"BinaryExpression"===e.right.type&&"*"===e.right.operator&&"NumericLiteral"===e.right.left.type)return n({type:"BinaryExpression",left:e.left,operator:"+",right:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:-e.right.left.value},operator:e.right.operator,right:n(e.right.right)})});if("BinaryExpression"===e.left.type){if("-"===e.operator&&"+"===e.left.operator&&g(e.left.right,e.right))return n(e.left.left);if("-"===e.operator&&"-"===e.left.operator&&g(e.left.left,e.right))return n({type:"UnaryExpression",operator:"-",argument:n(e.left.right)});if("+"===e.operator&&"+"===e.left.operator&&"UnaryExpression"===e.left.right.type&&"-"===e.left.right.operator&&g(e.left.right.argument,e.right))return n(e.left.left);if("+"===e.operator&&"-"===e.left.operator&&g(e.left.right,e.right))return n(e.left.left);if("+"===e.operator&&"+"===e.left.operator&&"UnaryExpression"===e.right.type&&"-"===e.right.operator&&g(e.left.right,e.right.argument))return n(e.left.left);if(!("+"!==e.operator&&"-"!==e.operator||"+"!==e.left.operator&&"-"!==e.left.operator||"NumericLiteral"!==e.left.right.type||"NumericLiteral"!==e.right.type)){const t=e.left.right.value*("-"===e.left.operator?-1:1)+e.right.value*("-"===e.operator?-1:1);return n(0===t?e.left.left:{type:"BinaryExpression",left:n(e.left.left),operator:t>0?"+":"-",right:{type:"NumericLiteral",value:t>0?t:-t}})}if(("+"===e.operator||"*"===e.operator)&&e.left.operator===e.operator&&"NumericLiteral"===e.left.left.type&&"NumericLiteral"===e.right.type)return n({type:"BinaryExpression",operator:e.operator,left:{type:"NumericLiteral",value:"*"===e.operator?e.left.left.value*e.right.value:e.left.left.value+e.right.value},right:n(e.left.right)});if(("+"===e.operator||"*"===e.operator)&&e.left.operator===e.operator&&"NumericLiteral"===e.left.right.type&&"NumericLiteral"===e.right.type)return n({type:"BinaryExpression",operator:e.operator,left:{type:"NumericLiteral",value:"*"===e.operator?e.left.right.value*e.right.value:e.left.right.value+e.right.value},right:n(e.left.left)});if("+"===e.operator&&"+"===e.left.operator&&"NumericLiteral"===e.left.left.type&&"BinaryExpression"===e.left.right.type&&"*"===e.left.right.operator&&"NumericLiteral"===e.left.right.left.type&&g(e.left.right.right,e.right))return n({type:"BinaryExpression",left:e.left.left,operator:"+",right:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:e.left.right.left.value+1},operator:"*",right:n(e.left.right.right)})});if(("+"===e.operator||"-"===e.operator)&&e.left.operator===e.operator&&g(e.left.right,e.right))return n({type:"BinaryExpression",left:n(e.left.left),operator:e.operator,right:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:2},operator:"*",right:n(e.left.right)})});if("-"===e.operator&&"+"===e.left.operator&&"NumericLiteral"===e.left.left.type&&"BinaryExpression"===e.left.right.type&&"*"===e.left.right.operator&&"NumericLiteral"===e.left.right.left.type&&g(e.left.right.right,e.right))return n({type:"BinaryExpression",operator:"+",left:e.left.left,right:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:e.left.right.left.value-1},operator:"*",right:e.right})});if("+"===e.operator&&"+"===e.left.operator&&"NumericLiteral"===e.left.left.type&&"BinaryExpression"===e.left.right.type&&"*"===e.left.right.operator&&"NumericLiteral"===e.left.right.left.type&&"BinaryExpression"===e.right.type&&"*"===e.right.operator&&"NumericLiteral"===e.right.left.type&&g(e.left.right.right,e.right.right))return n({type:"BinaryExpression",left:e.left.left,operator:"+",right:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:e.left.right.left.value+e.right.left.value},operator:"*",right:n(e.left.right.right)})});if("+"===e.operator&&"-"===e.left.operator&&"NumericLiteral"===e.left.left.type&&"BinaryExpression"===e.right.type&&"*"===e.right.operator&&"NumericLiteral"===e.right.left.type&&g(e.left.right,e.right.right))return n({type:"BinaryExpression",left:e.left.left,operator:"+",right:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:-1+e.right.left.value},operator:"*",right:n(e.right.right)})});if(!("+"!==e.operator&&"-"!==e.operator||"+"!==e.left.operator&&"-"!==e.left.operator||"NumericLiteral"!==e.left.right.type))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n(e.left.left),operator:e.operator,right:e.right}),operator:e.left.operator,right:e.left.right});if(("+"===e.operator||"-"===e.operator)&&t&&("+"===e.left.operator||"-"===e.left.operator)&&t(e.right)&&t(e.left.left)&&!t(e.left.right))return n({type:"BinaryExpression",operator:e.left.operator,left:n({type:"BinaryExpression",operator:e.operator,left:n(e.left.left),right:e.right}),right:n(e.left.right)});if(("+"===e.operator||"-"===e.operator)&&t&&"-"===e.left.operator&&t(e.right)&&t(e.left.right)&&!t(e.left.left))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n({type:"UnaryExpression",operator:"-",argument:n(e.left.right)}),operator:e.operator,right:e.right}),operator:"+",right:n(e.left.left)});if(("*"===e.operator||"/"===e.operator)&&"BinaryExpression"===e.left.type&&e.left.operator===e.operator&&(!t||!t(e.left.right))&&m(e.left.right,e.right))return n({type:"BinaryExpression",left:{type:"BinaryExpression",left:n(e.left.left),operator:e.operator,right:e.right},operator:e.left.operator,right:n(e.left.right)});if(!("*"!==e.operator||"BinaryExpression"!==e.left.type||"/"!==e.left.operator||t&&t(e.left.right)))return n({type:"BinaryExpression",left:{type:"BinaryExpression",left:n(e.left.left),operator:e.operator,right:e.right},operator:e.left.operator,right:n(e.left.right)});if(("+"===e.operator||"-"===e.operator)&&"BinaryExpression"===e.left.type&&("+"===e.left.operator||"-"===e.left.operator)&&(!t||!t(e.left.right))&&m(e.left.right,e.right))return n({type:"BinaryExpression",left:{type:"BinaryExpression",left:n(e.left.left),operator:e.operator,right:e.right},operator:e.left.operator,right:n(e.left.right)})}if("BinaryExpression"===e.right.type){if("+"===e.operator&&("+"===e.right.operator||"-"===e.right.operator))return n({type:"BinaryExpression",operator:e.right.operator,left:n({type:"BinaryExpression",operator:"+",left:e.left,right:n(e.right.left)}),right:n(e.right.right)});if("-"===e.operator&&("+"===e.right.operator||"-"===e.right.operator))return n({type:"BinaryExpression",operator:x(e.right.operator),left:n({type:"BinaryExpression",operator:"-",left:e.left,right:n(e.right.left)}),right:n(e.right.right)});if("*"===e.operator&&("*"===e.right.operator||"/"===e.right.operator))return n({type:"BinaryExpression",operator:e.right.operator,left:n({type:"BinaryExpression",operator:"*",left:e.left,right:n(e.right.left)}),right:n(e.right.right)})}if(("+"===e.operator||"*"===e.operator)&&(!t||t(e.left)&&t(e.right)||!t(e.left)&&!t(e.right))&&m(e.left,e.right))return n({type:"BinaryExpression",operator:e.operator,left:e.right,right:e.left});if("*"===e.operator&&t&&t(e.left)&&!t(e.right))return n({type:"BinaryExpression",left:e.right,operator:e.operator,right:e.left});if("+"===e.operator&&t&&!t(e.left)&&t(e.right))return n({type:"BinaryExpression",left:e.right,operator:e.operator,right:e.left});if("UnaryExpression"===e.right.type&&("*"===e.operator||"/"===e.operator)&&"-"===e.right.operator)return n({type:"UnaryExpression",operator:e.right.operator,argument:n({type:"BinaryExpression",left:e.left,right:n(e.right.argument),operator:e.operator})});if("UnaryExpression"===e.left.type&&("*"===e.operator||"/"===e.operator)&&"-"===e.left.operator)return n({type:"UnaryExpression",operator:e.left.operator,argument:n({type:"BinaryExpression",left:n(e.left.argument),right:e.right,operator:e.operator})});if("+"===e.operator||"-"===e.operator){if("BinaryExpression"===e.right.type&&"/"===e.right.operator&&!y(e.right.right))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:e.left,operator:"*",right:n(e.right.right)}),operator:e.operator,right:n(e.right.left)}),operator:"/",right:n(e.right.right)});if("BinaryExpression"===e.left.type&&"/"===e.left.operator&&!y(e.left.right))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n(e.left.left),operator:e.operator,right:n({type:"BinaryExpression",left:n(e.left.right),operator:"*",right:e.right})}),operator:"/",right:n(e.left.right)})}if("*"===e.operator){if(!(t&&t(e.right)||"BinaryExpression"!==e.left.type||"+"!==e.left.operator&&"-"!==e.left.operator))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n(e.left.left),operator:"*",right:e.right}),operator:e.left.operator,right:n({type:"BinaryExpression",left:n(e.left.right),operator:"*",right:e.right})});if(!(t&&t(e.left)||"BinaryExpression"!==e.right.type||"+"!==e.right.operator&&"-"!==e.right.operator))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:e.left,operator:"*",right:n(e.right.left)}),operator:e.right.operator,right:n({type:"BinaryExpression",left:e.left,operator:"*",right:n(e.right.right)})})}if(t&&("+"===e.operator||"-"===e.operator)){if("BinaryExpression"===e.left.type&&"*"===e.left.operator&&"BinaryExpression"===e.right.type&&"*"===e.right.operator&&g(e.left.right,e.right.right)&&!t(e.left.left)&&t(e.left.right)&&!t(e.right.left))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n(e.left.left),right:n(e.right.left),operator:e.operator}),operator:"*",right:n(e.left.right)});if("BinaryExpression"===e.left.type&&"*"===e.left.operator&&!t(e.left.left)&&t(e.left.right)&&g(e.left.right,e.right))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n(e.left.left),right:{type:"NumericLiteral",value:1},operator:e.operator}),operator:"*",right:n(e.left.right)});if("BinaryExpression"===e.right.type&&"*"===e.right.operator&&!t(e.right.left)&&t(e.right.right)&&g(e.left,e.right.right))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:1},right:n(e.right.left),operator:e.operator}),operator:"*",right:e.left});if("BinaryExpression"===e.right.type&&"*"===e.right.operator&&"UnaryExpression"===e.left.type&&"-"===e.left.operator&&!t(e.right.left)&&t(e.right.right)&&g(e.left.argument,e.right.right))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:{type:"NumericLiteral",value:-1},right:n(e.right.left),operator:e.operator}),operator:"*",right:n(e.left.argument)})}if(t&&"**"===e.operator&&!t(e.right)&&"BinaryExpression"===e.left.type&&("*"===e.left.operator||"/"===e.left.operator)&&(t(e.left.left)&&!t(e.left.right)||!t(e.left.left)&&t(e.left.right)))return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n(e.left.left),operator:"**",right:e.right}),operator:e.left.operator,right:n({type:"BinaryExpression",left:n(e.left.right),operator:"**",right:e.right})});if("**"===e.operator&&"NumericLiteral"===e.right.type&&2===e.right.value&&"BinaryExpression"===e.left.type&&("+"===e.left.operator||"-"===e.left.operator)){const t=n(e.left.left),r=n(e.left.right);return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:t,operator:"**",right:e.right}),operator:e.left.operator,right:n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:e.right,operator:"*",right:t}),operator:"*",right:r})}),operator:"+",right:n({type:"BinaryExpression",left:r,operator:"**",right:e.right})})}if("/"===e.operator){const t=(0,i.divide)(e.left,e.right);if(t)return n(t)}if("/"===e.operator&&"BinaryExpression"===e.left.type&&"/"===e.left.operator){const t=(0,i.divide)(e.left.left,e.right);if(t)return n({type:"BinaryExpression",left:n(t),operator:"/",right:n(e.left.right)})}if("+"===e.operator||"-"===e.operator){const t=(0,i.expressionToFactors)(e);if(t){const e=(0,i.optimizeFactors)(t);if(e.length0&&e.right.value<1){const t=1/e.right.value;if(Number.isInteger(t)){const r=(0,i.expressionToFactors)(e.left);if(r){const o=(0,i.extractFactors)(r,t);if(o)return n({type:"BinaryExpression",left:(0,i.factorToExpression)(o.base),operator:"*",right:n({type:"BinaryExpression",left:(0,i.factorsToExpression)(o.factors),operator:"**",right:e.right})})}}}if("/"===e.operator&&"BinaryExpression"===e.right.type&&("+"===e.right.operator||"-"===e.right.operator)){const t=(0,i.expressionToFactors)(e.right);if(t){const r=(0,i.extractFactors)(t,1);if(r)return n({type:"BinaryExpression",left:n({type:"BinaryExpression",left:e.left,operator:"/",right:(0,i.factorToExpression)(r.base)}),operator:"/",right:(0,i.factorsToExpression)(r.factors)})}}}else if("UnaryExpression"===e.type){if(e.argument=n(e.argument),"-"===e.operator){if("NumericLiteral"===e.argument.type)return{type:"NumericLiteral",value:-e.argument.value};if("UnaryExpression"===e.argument.type&&"-"===e.argument.operator)return n(e.argument.argument);if("BinaryExpression"===e.argument.type&&("+"===e.argument.operator||"-"===e.argument.operator))return n({type:"BinaryExpression",left:n({type:"UnaryExpression",operator:"-",argument:n(e.argument.left)}),operator:x(e.argument.operator),right:n(e.argument.right)});if("BinaryExpression"===e.argument.type&&("*"===e.argument.operator||"/"===e.argument.operator)){if("NumericLiteral"===e.argument.left.type)return n({type:"BinaryExpression",left:n({type:"NumericLiteral",value:-e.argument.left.value}),operator:e.argument.operator,right:n(e.argument.right)});if("NumericLiteral"===e.argument.right.type)return n({type:"BinaryExpression",left:n(e.argument.left),operator:"*",right:n({type:"NumericLiteral",value:-e.argument.right.value})})}}}else if("CallExpression"===e.type&&(e.arguments=e.arguments.map((e=>"SpreadElement"===e.type?e:n(e))),"Identifier"===e.callee.type))if("sin"===e.callee.name){if(1===e.arguments.length){const t=e.arguments[0];if("NumericLiteral"===t.type)return{type:"NumericLiteral",value:Math.sin(t.value)}}}else if("cos"===e.callee.name&&1===e.arguments.length){const t=e.arguments[0];if("NumericLiteral"===t.type)return{type:"NumericLiteral",value:Math.cos(t.value)}}return e};return n(e)}function x(e){return"+"===e?"-":"-"===e?"+":"*"===e?"/":"/"===e?"*":e}},7492:(e,t,n)=>{"use strict";n.r(t),n.d(t,{solveQuadraticEquation:()=>o});var r=n(6277);function o(e,t){const n=i(e.left,t);if(n&&n.length>0){n.sort(((e,t)=>t.degree-e.degree));const t=n[0];if(2===t.degree){const r=t.constant;if(2===n.length){const t=n[1];if(1===t.degree)return c(r,t.constant,e.right)}else if(1===n.length)return c(r,{type:"NumericLiteral",value:0},e.right)}else if(1===t.degree)return[{type:"BinaryExpression",left:e.right,operator:"/",right:t.constant}]}}function i(e,t){if("BinaryExpression"===e.type&&("+"===e.operator||"-"===e.operator)){const n=i(e.left,t);if(!n)return;let r=i(e.right,t);if(!r)return;"-"===e.operator&&(r=r.map((e=>l(e))));const o=[...n];for(const e of r){const t=o.find((t=>t.degree===e.degree));t?t.constant={type:"BinaryExpression",left:t.constant,operator:"+",right:e.constant}:o.push(e)}return o}const n=a(e,t);if(n)return[n]}function a(e,t){if("NumericLiteral"===e.type)return{constant:e,degree:0};if(!(0,r.expressionHasVariable)(e,t))return{constant:e,degree:0};if("Identifier"===e.type)return e.name===t?{constant:{type:"NumericLiteral",value:1},degree:1}:{constant:e,degree:0};if("UnaryExpression"===e.type&&"-"===e.operator){const n=a(e.argument,t);if(!n)return;return l(n)}if("BinaryExpression"===e.type){if("*"===e.operator){const n=a(e.left,t);if(!n)return;const r=a(e.right,t);if(!r)return;return s(n,r)}if("**"===e.operator){const n=a(e.left,t);if(!n)return;if("NumericLiteral"!==e.right.type)return;if(!Number.isInteger(e.right.value))return;if(e.right.value<1)return;return{constant:{type:"BinaryExpression",left:n.constant,operator:"**",right:e.right},degree:n.degree*e.right.value}}}}function s(...e){let t,n=0;for(const r of e)t=t?{type:"BinaryExpression",left:t,operator:"*",right:r.constant}:r.constant,n+=r.degree;return{degree:n,constant:t||{type:"NumericLiteral",value:1}}}function l(e){return s(e,{constant:{type:"NumericLiteral",value:-1},degree:0})}function c(e,t,n){return[{type:"BinaryExpression",left:{type:"BinaryExpression",left:{type:"UnaryExpression",operator:"-",argument:t},operator:"+",right:{type:"BinaryExpression",left:{type:"BinaryExpression",left:{type:"BinaryExpression",left:t,operator:"**",right:{type:"NumericLiteral",value:2}},operator:"+",right:{type:"BinaryExpression",left:{type:"BinaryExpression",left:{type:"NumericLiteral",value:4},operator:"*",right:e},operator:"*",right:n}},operator:"**",right:{type:"NumericLiteral",value:.5}}},operator:"/",right:{type:"BinaryExpression",left:{type:"NumericLiteral",value:2},operator:"*",right:e}},{type:"BinaryExpression",left:{type:"BinaryExpression",left:{type:"UnaryExpression",operator:"-",argument:t},operator:"-",right:{type:"BinaryExpression",left:{type:"BinaryExpression",left:{type:"BinaryExpression",left:t,operator:"**",right:{type:"NumericLiteral",value:2}},operator:"+",right:{type:"BinaryExpression",left:{type:"BinaryExpression",left:{type:"NumericLiteral",value:4},operator:"*",right:e},operator:"*",right:n}},operator:"**",right:{type:"NumericLiteral",value:.5}}},operator:"/",right:{type:"BinaryExpression",left:{type:"NumericLiteral",value:2},operator:"*",right:e}}]}},4281:(e,t,n)=>{"use strict";n.r(t),n.d(t,{cloneExpression:()=>k,composeExpression:()=>C,equationHasVariable:()=>m,solveEquation:()=>g,solveEquations:()=>v});var r=n(9292),o=n(6277),i=n(7492),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))u.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))d.call(t,n)&&p(e,n,t[n]);return e},h=(e,t)=>s(e,l(t));function g(e,t){const n=e=>(0,o.expressionHasVariable)(e,t),a=e=>(0,o.optimizeExpression)(e,n),s=e=>{if((0,o.optimizeEquation)(e,n),!n(e.left)){if(!n(e.right))return e;e={left:e.right,right:e.left}}if(!n(e.right)){if("UnaryExpression"===e.left.type&&"-"===e.left.operator)return s({left:a(e.left.argument),right:a({type:"UnaryExpression",argument:e.right,operator:e.left.operator})});if("BinaryExpression"===e.left.type){if(n(e.left.left)&&!n(e.left.right)){const t="**"===e.left.operator?{type:"BinaryExpression",left:{type:"NumericLiteral",value:1},operator:"/",right:e.left.right}:e.left.right;return"**"===e.left.operator&&"NumericLiteral"===e.left.right.type&&e.left.right.value%2==0?[...(0,r.iterateItemOrArray)(s({left:a(e.left.left),right:a({type:"BinaryExpression",left:e.right,right:a(t),operator:(0,o.getReverseOperator)(e.left.operator)})})),...(0,r.iterateItemOrArray)(s({left:a(e.left.left),right:a({type:"UnaryExpression",operator:"-",argument:{type:"BinaryExpression",left:e.right,right:a(t),operator:(0,o.getReverseOperator)(e.left.operator)}})}))]:s({left:a(e.left.left),right:a({type:"BinaryExpression",left:e.right,right:a(t),operator:(0,o.getReverseOperator)(e.left.operator)})})}if(n(e.left.right)&&!n(e.left.left))return"-"===e.left.operator||"/"===e.left.operator?s({left:a(e.left.right),right:a({type:"BinaryExpression",left:a(e.left.left),right:e.right,operator:e.left.operator})}):s({left:a(e.left.right),right:a({type:"BinaryExpression",left:e.right,right:a(e.left.left),operator:(0,o.getReverseOperator)(e.left.operator)})});if("NumericLiteral"===e.right.type&&0===e.right.value&&"/"===e.left.operator)return s({left:a(e.left.left),right:e.right});if("NumericLiteral"===e.right.type&&0===e.right.value&&"*"===e.left.operator)return[...(0,r.iterateItemOrArray)(s({left:a(e.left.left),right:e.right})),...(0,r.iterateItemOrArray)(s({left:a(e.left.right),right:e.right}))];if("+"===e.left.operator||"-"===e.left.operator||"*"===e.left.operator){const n=(0,i.solveQuadraticEquation)(e,t);if(n)return n.map((e=>Array.from((0,r.iterateItemOrArray)(s({left:{type:"Identifier",name:t},right:a(e)}))).flat())).flat()}}return e}return"BinaryExpression"===e.right.type?"/"===e.right.operator?s({left:a({type:"BinaryExpression",left:e.left,right:a(e.right.right),operator:"*"}),right:a(e.right.left)}):s({left:{type:"BinaryExpression",left:e.left,operator:"-",right:e.right},right:{type:"NumericLiteral",value:0}}):"Identifier"===e.right.type?s({left:{type:"BinaryExpression",left:e.left,operator:"-",right:e.right},right:{type:"NumericLiteral",value:0}}):"UnaryExpression"===e.right.type?s({left:{type:"BinaryExpression",left:e.left,operator:"+",right:a(e.right.argument)},right:{type:"NumericLiteral",value:0}}):e};return Array.from((0,r.iterateItemOrArray)(s(e)))}function m(e,t){return(0,o.expressionHasVariable)(e.left,t)||(0,o.expressionHasVariable)(e.right,t)}function y(e){const t=new Set;for(const n of(0,o.iterateEquation)(e))"Identifier"===n.type&&t.add(n.name);return Array.from(t)}function v(e,t,n={}){if(!t){t=new Set;for(const n of e)for(const e of y(n))t.add(e)}const r=[],i=t,a=()=>{let t=e.length;for(;;){const a=[];for(let t=0;ti.has(e)));if(l.length>0){if(1===l.length){(0,o.optimizeEquation)(s,(e=>(0,o.expressionHasVariable)(e,l[0])));const[c,...u]=g(s,l[0]);r.push(...u.map((r=>v([...a.map((e=>P(e))),r,...e.slice(t+1).map((e=>P(e)))],new Set(i),x(n)))).flat()),s=c}if("Identifier"===s.left.type&&"NumericLiteral"===s.right.type){for(const e in n){const t=n[e];Array.isArray(t)?n[e]=[(0,o.optimizeExpression)(C(t[0],{[s.left.name]:s.right}),(t=>(0,o.expressionHasVariable)(t,e))),(0,o.optimizeExpression)(C(t[1],{[s.left.name]:s.right}),(t=>(0,o.expressionHasVariable)(t,e)))]:n[e]=(0,o.optimizeExpression)(C(t,{[s.left.name]:s.right}),(t=>(0,o.expressionHasVariable)(t,e)))}n[s.left.name]=s.right,i.delete(s.left.name)}else a.push(s)}}const s=b(a,n,i);if(e=s.equations,r.push(...s.result),e.length===t)break;t=e.length}};for(a();;){const t=e.shift();if(!t)break;let s=y(t).filter((e=>i.has(e)))[0],[l,...c]=g(t,s);for(;!y(l).includes(s);){const e=y(l).filter((e=>i.has(e)))[0];if(e===s)break;s=e,[l,...c]=g(l,s)}if(r.push(...c.map((t=>v([t,...e.map((e=>P(e)))],new Set(i),x(n)))).flat()),"Identifier"===l.left.type){for(const e in n){const t=n[e];Array.isArray(t)?n[e]=[(0,o.optimizeExpression)(C(t[0],{[s]:l.right}),(t=>(0,o.expressionHasVariable)(t,e))),(0,o.optimizeExpression)(C(t[1],{[s]:l.right}),(t=>(0,o.expressionHasVariable)(t,e)))]:n[e]=(0,o.optimizeExpression)(C(t,{[s]:l.right}),(t=>(0,o.expressionHasVariable)(t,e)))}n[s]=l.right,i.delete(s);const t=b(e,{[s]:l.right},i);e=t.equations,r.push(...t.result),a()}else n[s]=[l.left,l.right],i.delete(s)}return[n,...r]}function x(e){const t={};for(const[n,r]of Object.entries(e))Array.isArray(r)?t[n]=[k(r[0]),k(r[1])]:t[n]=k(r);return t}function b(e,t,n){const r=[],i=[];for(let a=0;an.has(e)));if(l.length>0)if(1===l.length){s=(0,o.optimizeEquation)(s,(e=>(0,o.expressionHasVariable)(e,l[0])));const[c,...u]=g(s,l[0]);i.push(...u.map((o=>v([...r.map((e=>P(e))),o,...e.slice(a+1).map((e=>P(e)))],new Set(n),x(t)))).flat()),r.push(c)}else r.push(s)}return{equations:r,result:i}}function C(e,t){if("BinaryExpression"===e.type)E(e,"left",t),E(e,"right",t);else if("UnaryExpression"===e.type)E(e,"argument",t);else if("Identifier"===e.type){const n=t[e.name];if(n&&!Array.isArray(n))return n}else"CallExpression"===e.type&&e.arguments.forEach(((n,r)=>{"SpreadElement"!==n.type&&(e.arguments[r]=C(n,t))}));return e}function E(e,t,n){const r=e[t];if("Identifier"===r.type){const o=n[r.name];o&&!Array.isArray(o)&&(e[t]=k(o))}else C(r,n)}function P(e){return{left:k(e.left),right:k(e.right)}}function k(e){return"BinaryExpression"===e.type?h(f({},e),{left:k(e.left),right:k(e.right)}):"UnaryExpression"===e.type?h(f({},e),{argument:k(e.argument)}):"CallExpression"===e.type?h(f({},e),{arguments:e.arguments.map((e=>"SpreadElement"===e.type?e:k(e)))}):f({},e)}},6845:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ExpressionEditor:()=>m});var r=n(3696),o=n(1777),i=n(9424),a=n(7670),s=n(8905),l=n(8174),c=n(623),u=Object.defineProperty,d=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&h(e,n,t[n]);if(d)for(var n of d(t))f.call(t,n)&&h(e,n,t[n]);return e};function m(e){var t,n,u,d,p,f,h,m;const y=null!=(t=e.height)?t:100,v=null!=(n=e.target)?n:o.reactCanvasRenderTarget,x=null!=(u=e.fontSize)?u:16,b=null!=(f=null!=(p=null==(d=e.style)?void 0:d.fontFamily)?p:l.controlStyle.fontFamily)?f:"monospace",C=null!=(h=e.numberColor)?h:820234,E=1.2*x,[P,k]=r.useState(null!=(m=e.width)?m:250),{state:w,setState:_,undo:S,redo:R,resetHistory:A}=(0,i.useUndoRedo)(e.value.split("")),[T,M]=r.useState([]),[L,I]=r.useState(0),[O,B]=r.useState(""),[F,D]=r.useState(),[z,U]=r.useState(),{renderEditor:N,layoutResult:G,location:j,cursor:V,setLocation:W,inputText:H}=(0,a.useFlowLayoutTextEditor)({state:w,setState:_,width:P,height:y,fontSize:x,fontFamily:b,lineHeight:E,readOnly:e.readOnly,processInput(t){var n;if("Escape"===t.key)return null==(n=e.onCancel)||n.call(e),!0;if(T.length>0&&!e.readOnly){if("ArrowDown"===t.key)return I((L+1)%T.length),t.preventDefault(),!0;if("ArrowUp"===t.key)return I((L-1+T.length)%T.length),t.preventDefault(),!0;if("Enter"===t.key&&L>=0&&L{setTimeout((()=>{$()}),0)},style:{border:"unset"}});r.useEffect((()=>{var t,n,r,o;if(!e.suggestionSources||e.readOnly)return;if(j-1<0||j-1>=w.length)return;M([]),D(void 0);const i=w[j-1];if((0,s.isLetter)(i)||(0,s.isNumber)(i)||"."==i){let r;for(let e=j-1;e>=0&&et.name===o[e])))?void 0:t.members)?n:[];else{const t=o[e].toLowerCase();i=i.filter((e=>e.name.toLowerCase().includes(t))).sort(((e,n)=>e.name.toLowerCase()===t?-1:n.name.toLowerCase()===t?1:e.name.localeCompare(n.name)))}M(i),I(0),B(o[o.length-1])}else if("("===i){let t;for(let e=j-2;e>=0&&et.name===n[e])))?void 0:r.members)?o:[]:i=a.find((t=>t.name===n[e]));D(i)}}),[w,j]),r.useEffect((()=>{A(e.value.split(""))}),[e.value]),r.useEffect((()=>{var t;U(null==(t=e.validate)?void 0:t.call(e,w.join("")))}),[w,e.validate]);const q=r.useRef(null);r.useEffect((()=>{if(!q.current)return;const e=new ResizeObserver((e=>{for(const t of e)k(t.contentRect.width)}));return e.observe(q.current),()=>e.disconnect()}),[q.current]);const $=()=>{if(!e.readOnly&&e.setValue){const t=w.join("");t!==e.value&&e.setValue(t)}},Y={};e.readOnly&&(Y.opacity=.5);const K=e=>{const t=T[e];_((e=>{e.splice(j-O.length,O.length,...t.name.split(""))})),W(j-O.length+t.name.length),M([])};return r.createElement("div",{ref:q,style:g(g(g({position:"relative"},l.controlStyle),e.style),Y)},N({target:v,getTextColors:t=>{let n=e.color;const r=G[t].content;if(z&&t>=z[0]&&t=0;n--){const t=G[n].content;if((0,s.isNumber)(t))e=!1;else{if(!(0,s.isLetter)(t))break;e=!0}}e||(n=C)}else if("."===r&&t0&&r.createElement("div",{style:{position:"absolute",left:V.x+"px",top:V.y+E+"px",background:"white",width:"200px",border:"1px solid black",maxHeight:"200px",overflowY:"auto"}},T.map(((e,t)=>{const n=e.name.toLowerCase().indexOf(O.toLowerCase());return r.createElement("div",{key:e.name,style:{background:L===t?"#ccc":void 0,cursor:"pointer"},onMouseDown:e=>{e.preventDefault(),K(t)},title:e.comment},e.name.substring(0,n),r.createElement("span",{style:{color:"#0c840a"}},e.name.substring(n,n+O.length)),e.name.substring(n+O.length))}))),(null==F?void 0:F.parameters)&&r.createElement("div",{style:{position:"absolute",left:V.x+"px",top:V.y+E+"px",background:"white",width:"400px",border:"1px solid black",maxHeight:"200px",overflowY:"auto"}},r.createElement("div",{onMouseDown:e=>e.preventDefault()},F.name,"(",F.parameters.map((e=>e.name)).join(", "),")",F.parameters.map((e=>e.comment?r.createElement("div",{key:e.name,style:{fontSize:"12px"}},e.name,": ",e.comment):null)),F.comment&&r.createElement("div",{style:{fontSize:"12px"}},F.comment))))}},3549:(e,t,n)=>{"use strict";n.r(t),n.d(t,{deriveExpressionWith:()=>h,expandExpression:()=>s,groupAllFactors:()=>p,groupFactorsBy:()=>d,groupFactorsByVariables:()=>f,sortFactors:()=>l,taylorExpandExpressionWith:()=>g});var r=n(767),o=n(123),i=n(6277),a=n(4281);function s(e){if("BinaryExpression"===e.type){if("**"===e.operator&&"NumericLiteral"===e.right.type){if(2===e.right.value&&"BinaryExpression"===e.left.type){if("+"===e.left.operator||"-"===e.left.operator)return s({type:"BinaryExpression",operator:"+",left:{type:"BinaryExpression",operator:e.left.operator,left:{type:"BinaryExpression",operator:"*",left:e.left.left,right:e.left.left},right:{type:"BinaryExpression",operator:"*",left:{type:"NumericLiteral",value:2},right:{type:"BinaryExpression",operator:"*",left:e.left.left,right:e.left.right}}},right:{type:"BinaryExpression",operator:"*",left:e.left.right,right:e.left.right}});if("*"===e.left.operator||"/"===e.left.operator)return s({type:"BinaryExpression",operator:e.left.operator,left:{type:"BinaryExpression",operator:e.left.operator,left:{type:"BinaryExpression",operator:"*",left:e.left.left,right:e.left.left},right:e.left.right},right:e.left.right})}if(Number.isInteger(e.right.value)&&e.right.value>=3&&"Identifier"!==e.left.type)return s({type:"BinaryExpression",operator:"*",left:{type:"BinaryExpression",operator:"**",left:e.left,right:{type:"NumericLiteral",value:e.right.value-1}},right:e.left})}if("*"===e.operator){if("BinaryExpression"===e.right.type&&("+"===e.right.operator||"-"===e.right.operator))return s({type:"BinaryExpression",operator:e.right.operator,left:{type:"BinaryExpression",operator:"*",left:e.left,right:e.right.left},right:{type:"BinaryExpression",operator:"*",left:e.left,right:e.right.right}});if("BinaryExpression"===e.left.type){if("+"===e.left.operator||"-"===e.left.operator)return s({type:"BinaryExpression",operator:e.left.operator,left:{type:"BinaryExpression",operator:"*",left:e.left.left,right:e.right},right:{type:"BinaryExpression",operator:"*",left:e.left.right,right:e.right}});if("/"===e.left.operator&&"Identifier"===e.left.right.type){if("Identifier"!==e.right.type)return s({type:"BinaryExpression",operator:"/",left:{type:"BinaryExpression",operator:"*",left:e.left.left,right:e.right},right:e.left.right});if(e.left.right.name===e.right.name)return s(e.left.left)}}}if("/"===e.operator&&"BinaryExpression"===e.left.type&&("+"===e.left.operator||"-"===e.left.operator))return s({type:"BinaryExpression",operator:e.left.operator,left:{type:"BinaryExpression",operator:"/",left:e.left.left,right:e.right},right:{type:"BinaryExpression",operator:"/",left:e.left.right,right:e.right}});const t=s(e.left),n=s(e.right);return t===e.left&&n===e.right?e:s({type:"BinaryExpression",operator:e.operator,left:t,right:n})}if("UnaryExpression"===e.type){if("-"===e.operator&&"BinaryExpression"===e.argument.type&&("+"===e.argument.operator||"-"===e.argument.operator))return s({type:"BinaryExpression",left:{type:"UnaryExpression",operator:"-",argument:e.argument.left},operator:(0,i.getReverseOperator)(e.argument.operator),right:e.argument.right});const t=s(e.argument);return t===e.argument?e:s({type:"UnaryExpression",operator:e.operator,argument:t})}return e}function l(e){e.forEach((e=>{e.variables.sort(c)})),e.sort(((e,t)=>{for(let n=0;nt.count===e));a?a.factors.push(...i):n.push({count:e,factors:i})}return n.sort(((e,t)=>t.count-e.count)),n}function d(e,t){return function(e,t){let n;for(const r of e){let e;for(const t of r.factors){const n=(0,o.factorToExpression)(t);e=e?{type:"BinaryExpression",operator:"+",left:e,right:n}:n}if(r.count>0){const n=(0,o.factorToExpression)((0,o.powerFactor)(t,r.count));e=e?{type:"BinaryExpression",operator:"*",left:e,right:n}:n}e&&(n=n?{type:"BinaryExpression",operator:"+",left:n,right:e}:e)}return n}(u(e,t),t)}function p(e){const t=[];for(const n of e)for(const e of n.variables)if("string"==typeof e){const n=t.find((t=>t.name===e));n?n.count++:t.push({name:e,count:1})}return t.sort(((e,t)=>t.count-e.count)),f(e,t.map((e=>e.name)))}function f(e,t){const n=(e,r)=>{if(e.length<=1)return;if(!t[r])return;const i={variables:[t[r]]},a=u(e,i);let s;for(const e of a){let t=n(e.factors,r+1);if(!t)for(const n of e.factors){const e=(0,o.factorToExpression)(n);t=t?{type:"BinaryExpression",operator:"+",left:t,right:e}:e}if(e.count>0){const n=(0,o.factorToExpression)((0,o.powerFactor)(i,e.count));t=t?{type:"BinaryExpression",operator:"*",left:t,right:n}:n}t&&(s=s?{type:"BinaryExpression",operator:"+",left:s,right:t}:t)}return s};return n(e,0)}function h(e,t){if("BinaryExpression"===e.type){if("+"===e.operator||"-"===e.operator)return{type:"BinaryExpression",operator:e.operator,left:h(e.left,t),right:h(e.right,t)};if("*"===e.operator)return{type:"BinaryExpression",operator:"+",left:{type:"BinaryExpression",operator:"*",left:h(e.left,t),right:e.right},right:{type:"BinaryExpression",operator:"*",left:e.left,right:h(e.right,t)}};if("/"===e.operator)return{type:"BinaryExpression",operator:"/",left:{type:"BinaryExpression",operator:"/",left:{type:"BinaryExpression",operator:"-",left:{type:"BinaryExpression",operator:"*",left:h(e.left,t),right:e.right},right:{type:"BinaryExpression",operator:"*",left:e.left,right:h(e.right,t)}},right:e.right},right:e.right};if("**"===e.operator&&(0,i.expressionHasVariable)(e.left,t)&&!(0,i.expressionHasVariable)(e.right,t))return{type:"BinaryExpression",operator:"*",left:{type:"BinaryExpression",operator:"*",left:h(e.left,t),right:e.right},right:{type:"BinaryExpression",operator:"**",left:e.left,right:{type:"BinaryExpression",operator:"-",left:e.right,right:{type:"NumericLiteral",value:1}}}}}if("UnaryExpression"===e.type)return{type:"UnaryExpression",operator:e.operator,argument:h(e.argument,t)};if("CallExpression"===e.type){let n;"Identifier"===e.callee.type?n=e.callee.name:"MemberExpression"===e.callee.type&&"Identifier"===e.callee.object.type&&"Math"===e.callee.object.name&&"Identifier"===e.callee.property.type&&e.callee.property.name;const r=e.arguments[0];if(n&&r&&"SpreadElement"!==r.type&&(0,i.expressionHasVariable)(r,t)){if("sin"===n)return{type:"BinaryExpression",operator:"*",left:{type:"CallExpression",callee:{type:"Identifier",name:"cos"},arguments:e.arguments},right:h(r,t)};if("cos"===n)return{type:"UnaryExpression",operator:"-",argument:{type:"BinaryExpression",operator:"*",left:{type:"CallExpression",callee:{type:"Identifier",name:"sin"},arguments:e.arguments},right:h(r,t)}}}}return"NumericLiteral"===e.type?{type:"NumericLiteral",value:0}:"Identifier"===e.type?{type:"NumericLiteral",value:e.name===t?1:0}:e}function g(e,t,n,o){const s=e=>(0,i.expressionHasVariable)(e,t);let l=(0,i.optimizeExpression)((0,a.composeExpression)((0,a.cloneExpression)(e),{[t]:{type:"NumericLiteral",value:0}}),s);o&&(l=(0,i.optimizeExpression)({type:"BinaryExpression",operator:"*",left:l,right:{type:"Identifier",name:t}},s));for(let c=1;c{"use strict";n.r(t);var r=n(3158),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(8907);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(3331);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(9182);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o);var l=n(4104);o={};for(const e in l)"default"!==e&&(o[e]=()=>l[e]);n.d(t,o);var c=n(9424);o={};for(const e in c)"default"!==e&&(o[e]=()=>c[e]);n.d(t,o);var u=n(2931);o={};for(const e in u)"default"!==e&&(o[e]=()=>u[e]);n.d(t,o);var d=n(370);o={};for(const e in d)"default"!==e&&(o[e]=()=>d[e]);n.d(t,o);var p=n(2789);o={};for(const e in p)"default"!==e&&(o[e]=()=>p[e]);n.d(t,o);var f=n(2800);o={};for(const e in f)"default"!==e&&(o[e]=()=>f[e]);n.d(t,o);var h=n(5634);o={};for(const e in h)"default"!==e&&(o[e]=()=>h[e]);n.d(t,o);var g=n(1412);o={};for(const e in g)"default"!==e&&(o[e]=()=>g[e]);n.d(t,o);var m=n(9160);o={};for(const e in m)"default"!==e&&(o[e]=()=>m[e]);n.d(t,o);var y=n(3307);o={};for(const e in y)"default"!==e&&(o[e]=()=>y[e]);n.d(t,o);var v=n(7923);o={};for(const e in v)"default"!==e&&(o[e]=()=>v[e]);n.d(t,o);var x=n(6545);o={};for(const e in x)"default"!==e&&(o[e]=()=>x[e]);n.d(t,o);var b=n(5644);o={};for(const e in b)"default"!==e&&(o[e]=()=>b[e]);n.d(t,o);var C=n(7662);o={};for(const e in C)"default"!==e&&(o[e]=()=>C[e]);n.d(t,o);var E=n(5970);o={};for(const e in E)"default"!==e&&(o[e]=()=>E[e]);n.d(t,o);var P=n(1369);o={};for(const e in P)"default"!==e&&(o[e]=()=>P[e]);n.d(t,o);var k=n(8285);o={};for(const e in k)"default"!==e&&(o[e]=()=>k[e]);n.d(t,o);var w=n(4489);o={};for(const e in w)"default"!==e&&(o[e]=()=>w[e]);n.d(t,o);var _=n(341);o={};for(const e in _)"default"!==e&&(o[e]=()=>_[e]);n.d(t,o);var S=n(4840);o={};for(const e in S)"default"!==e&&(o[e]=()=>S[e]);n.d(t,o);var R=n(2628);o={};for(const e in R)"default"!==e&&(o[e]=()=>R[e]);n.d(t,o);var A=n(5072);o={};for(const e in A)"default"!==e&&(o[e]=()=>A[e]);n.d(t,o);var T=n(2817);o={};for(const e in T)"default"!==e&&(o[e]=()=>T[e]);n.d(t,o);var M=n(3869);o={};for(const e in M)"default"!==e&&(o[e]=()=>M[e]);n.d(t,o);var L=n(1749);o={};for(const e in L)"default"!==e&&(o[e]=()=>L[e]);n.d(t,o);var I=n(4848);o={};for(const e in I)"default"!==e&&(o[e]=()=>I[e]);n.d(t,o);var O=n(3404);o={};for(const e in O)"default"!==e&&(o[e]=()=>O[e]);n.d(t,o);var B=n(9345);o={};for(const e in B)"default"!==e&&(o[e]=()=>B[e]);n.d(t,o);var F=n(4970);o={};for(const e in F)"default"!==e&&(o[e]=()=>F[e]);n.d(t,o);var D=n(5115);o={};for(const e in D)"default"!==e&&(o[e]=()=>D[e]);n.d(t,o);var z=n(2286);o={};for(const e in z)"default"!==e&&(o[e]=()=>z[e]);n.d(t,o);var U=n(4332);o={};for(const e in U)"default"!==e&&(o[e]=()=>U[e]);n.d(t,o);var N=n(5384);o={};for(const e in N)"default"!==e&&(o[e]=()=>N[e]);n.d(t,o);var G=n(6421);o={};for(const e in G)"default"!==e&&(o[e]=()=>G[e]);n.d(t,o);var j=n(7332);o={};for(const e in j)"default"!==e&&(o[e]=()=>j[e]);n.d(t,o);var V=n(5632);o={};for(const e in V)"default"!==e&&(o[e]=()=>V[e]);n.d(t,o);var W=n(9055);o={};for(const e in W)"default"!==e&&(o[e]=()=>W[e]);n.d(t,o);var H=n(2244);o={};for(const e in H)"default"!==e&&(o[e]=()=>H[e]);n.d(t,o);var q=n(6424);o={};for(const e in q)"default"!==e&&(o[e]=()=>q[e]);n.d(t,o);var $=n(9294);o={};for(const e in $)"default"!==e&&(o[e]=()=>$[e]);n.d(t,o);var Y=n(69);o={};for(const e in Y)"default"!==e&&(o[e]=()=>Y[e]);n.d(t,o);var K=n(4399);o={};for(const e in K)"default"!==e&&(o[e]=()=>K[e]);n.d(t,o);var X=n(6278);o={};for(const e in X)"default"!==e&&(o[e]=()=>X[e]);n.d(t,o);var Z=n(6845);o={};for(const e in Z)"default"!==e&&(o[e]=()=>Z[e]);n.d(t,o);var Q=n(3175);o={};for(const e in Q)"default"!==e&&(o[e]=()=>Q[e]);n.d(t,o);var J=n(7195);o={};for(const e in J)"default"!==e&&(o[e]=()=>J[e]);n.d(t,o);var ee=n(7658);o={};for(const e in ee)"default"!==e&&(o[e]=()=>ee[e]);n.d(t,o);var te=n(327);o={};for(const e in te)"default"!==e&&(o[e]=()=>te[e]);n.d(t,o);var ne=n(4205);o={};for(const e in ne)"default"!==e&&(o[e]=()=>ne[e]);n.d(t,o);var re=n(4844);o={};for(const e in re)"default"!==e&&(o[e]=()=>re[e]);n.d(t,o);var oe=n(7670);o={};for(const e in oe)"default"!==e&&(o[e]=()=>oe[e]);n.d(t,o);var ie=n(135);o={};for(const e in ie)"default"!==e&&(o[e]=()=>ie[e]);n.d(t,o);var ae=n(7816);o={};for(const e in ae)"default"!==e&&(o[e]=()=>ae[e]);n.d(t,o);var se=n(2432);o={};for(const e in se)"default"!==e&&(o[e]=()=>se[e]);n.d(t,o);var le=n(4740);o={};for(const e in le)"default"!==e&&(o[e]=()=>le[e]);n.d(t,o);var ce=n(8174);o={};for(const e in ce)"default"!==e&&(o[e]=()=>ce[e]);n.d(t,o);var ue=n(2607);o={};for(const e in ue)"default"!==e&&(o[e]=()=>ue[e]);n.d(t,o);var de=n(4546);o={};for(const e in de)"default"!==e&&(o[e]=()=>de[e]);n.d(t,o);var pe=n(9436);o={};for(const e in pe)"default"!==e&&(o[e]=()=>pe[e]);n.d(t,o);var fe=n(2978);o={};for(const e in fe)"default"!==e&&(o[e]=()=>fe[e]);n.d(t,o);var he=n(3274);o={};for(const e in he)"default"!==e&&(o[e]=()=>he[e]);n.d(t,o);var ge=n(2087);o={};for(const e in ge)"default"!==e&&(o[e]=()=>ge[e]);n.d(t,o);var me=n(5936);o={};for(const e in me)"default"!==e&&(o[e]=()=>me[e]);n.d(t,o);var ye=n(2202);o={};for(const e in ye)"default"!==e&&(o[e]=()=>ye[e]);n.d(t,o);var ve=n(7921);o={};for(const e in ve)"default"!==e&&(o[e]=()=>ve[e]);n.d(t,o);var xe=n(8454);o={};for(const e in xe)"default"!==e&&(o[e]=()=>xe[e]);n.d(t,o);var be=n(9201);o={};for(const e in be)"default"!==e&&(o[e]=()=>be[e]);n.d(t,o);var Ce=n(1121);o={};for(const e in Ce)"default"!==e&&(o[e]=()=>Ce[e]);n.d(t,o);var Ee=n(3549);o={};for(const e in Ee)"default"!==e&&(o[e]=()=>Ee[e]);n.d(t,o);var Pe=n(6376);o={};for(const e in Pe)"default"!==e&&(o[e]=()=>Pe[e]);n.d(t,o)},6376:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Menu:()=>d});var r=n(3696),o=n.n(r),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(e,n,t[n]);return e};function d(e){const[t,n]=o().useState(-1);return o().createElement("ul",{style:u({position:"absolute",boxShadow:"0 0.5rem 1rem rgba(0, 0, 0, 0.15)",borderRadius:"0.375rem",border:"1px solid rgba(0, 0, 0, 0.175)",background:"white",padding:"0.5em 0"},e.style),onMouseLeave:()=>n(-1)},e.items.map(((e,r)=>"divider"===e.type?o().createElement("li",{key:r,style:{listStyle:"none"}},o().createElement("hr",{style:{height:0,margin:"0.5em 0",border:0,borderTop:"1px solid rgba(0, 0, 0, 0.175)"}})):o().createElement("li",{key:r,style:{padding:"0 0.5em",paddingRight:"1.5em",position:"relative",listStyle:"none",background:t===r?"#f8f9fa":void 0,color:e.disabled?"rgba(33, 37, 41, 0.5)":void 0,cursor:e.disabled?"not-allowed":"pointer",whiteSpace:"nowrap",lineHeight:"32px"},onMouseEnter:()=>n(r),onClick:e.onClick},o().createElement("span",null,e.title),e.children&&e.children.length>0&&o().createElement("svg",{style:{right:"0.5em",height:"100%",position:"absolute"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 10 10",width:"10",height:"10"},o().createElement("polyline",{points:"2,0 8,5 2,10",stroke:"currentColor",fill:"none"})),t===r&&e.children&&e.children.length>0&&o().createElement(d,{items:e.children,style:{top:0,left:"100%"}})))))}},6199:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ArrayEditor:()=>p,ObjectArrayEditor:()=>f});var r=n(3696),o=n(8640),i=n(7749),a=Object.defineProperty,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))c.call(t,n)&&u(e,n,t[n]);return e};function p(e){return e.inline?r.createElement("div",{style:d(d({},i.groupStyle),e.style)},r.createElement("div",null,e.items.map(((t,n)=>r.createElement("div",{key:n,style:{display:"flex",alignItems:"center",marginBottom:"3px"}},r.createElement("div",{style:{paddingRight:"5px",width:"14px"}},n+1),r.createElement("div",{style:{flex:1,display:"flex"}},r.cloneElement(t,(0,i.getChildProps)(e))),!e.readOnly&&r.createElement("div",null,e.remove&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.remove)?void 0:t.call(e,n)}},g),e.copy&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.copy)?void 0:t.call(e,n)}},v),n>0&&e.moveUp&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.moveUp)?void 0:t.call(e,n)}},m),n{var t;return null==(t=e.moveDown)?void 0:t.call(e,n)}},y)))))),!e.readOnly&&e.add&&r.createElement(o.Button,{onClick:e.add},h)):r.createElement("div",{style:d(d({},i.groupStyle),e.style)},e.items.map(((t,n)=>{var a,s;return r.createElement(r.Fragment,{key:n},r.createElement("div",{style:{marginBottom:"5px",marginTop:"5px"}},null!=(s=null==(a=e.title)?void 0:a.call(e,n))?s:n+1,!e.readOnly&&e.remove&&r.createElement(o.Button,{style:{marginLeft:"5px"},onClick:()=>{var t;return null==(t=e.remove)?void 0:t.call(e,n)}},g),!e.readOnly&&e.copy&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.copy)?void 0:t.call(e,n)}},v),!e.readOnly&&e.moveUp&&n>0&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.moveUp)?void 0:t.call(e,n)}},m),!e.readOnly&&e.moveDown&&n{var t;return null==(t=e.moveDown)?void 0:t.call(e,n)}},y)),r.createElement("div",{style:{display:"flex"}},r.cloneElement(t,(0,i.getChildProps)(e))))})),!e.readOnly&&e.add&&r.createElement(o.Button,{onClick:e.add},h))}function f(e){return 0===e.properties.length?null:r.createElement("div",{style:d(d({},i.groupStyle),e.style)},r.createElement("table",null,r.createElement("thead",null,r.createElement("tr",null,r.createElement("td",null),Object.entries(e.properties[0]).map((([e])=>r.createElement("td",{key:e},e))),!e.readOnly&&r.createElement("td",null))),r.createElement("tbody",null,e.properties.map(((t,n)=>r.createElement("tr",{key:n},r.createElement("td",{style:{paddingRight:"5px"}},n+1),Object.values(t).map(((t,n)=>r.createElement("td",{key:n},r.cloneElement(t,(0,i.getChildProps)(e))))),!e.readOnly&&r.createElement("td",null,e.remove&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.remove)?void 0:t.call(e,n)}},g),e.copy&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.copy)?void 0:t.call(e,n)}},v),e.moveUp&&n>0&&r.createElement(o.Button,{onClick:()=>{var t;return null==(t=e.moveUp)?void 0:t.call(e,n)}},m),e.moveDown&&n{var t;return null==(t=e.moveDown)?void 0:t.call(e,n)}},y))))))),!e.readOnly&&e.add&&r.createElement(o.Button,{onClick:e.add},h))}const h=r.createElement("svg",{style:{width:"20px",height:"20px"},viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},r.createElement("path",{fill:"currentColor",d:"M480 480V128a32 32 0 0 1 64 0v352h352a32 32 0 1 1 0 64H544v352a32 32 0 1 1-64 0V544H128a32 32 0 0 1 0-64h352z"})),g=r.createElement("svg",{style:{width:"20px",height:"20px"},viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},r.createElement("path",{fill:"currentColor",d:"M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"})),m=r.createElement("svg",{style:{width:"20px",height:"20px"},viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},r.createElement("path",{fill:"currentColor",d:"M572.235 205.282v600.365a30.118 30.118 0 1 1-60.235 0V205.282L292.382 438.633a28.913 28.913 0 0 1-42.646 0 33.43 33.43 0 0 1 0-45.236l271.058-288.045a28.913 28.913 0 0 1 42.647 0L834.5 393.397a33.43 33.43 0 0 1 0 45.176 28.913 28.913 0 0 1-42.647 0l-219.618-233.23z"})),y=r.createElement("svg",{style:{width:"20px",height:"20px"},viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},r.createElement("path",{fill:"currentColor",d:"M544 805.888V168a32 32 0 1 0-64 0v637.888L246.656 557.952a30.72 30.72 0 0 0-45.312 0 35.52 35.52 0 0 0 0 48.064l288 306.048a30.72 30.72 0 0 0 45.312 0l288-306.048a35.52 35.52 0 0 0 0-48 30.72 30.72 0 0 0-45.312 0L544 805.824z"})),v=r.createElement("svg",{style:{width:"20px",height:"20px"},viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},r.createElement("path",{fill:"currentColor",d:"M128 320v576h576V320H128zm-32-64h640a32 32 0 0 1 32 32v640a32 32 0 0 1-32 32H96a32 32 0 0 1-32-32V288a32 32 0 0 1 32-32zM960 96v704a32 32 0 0 1-32 32h-96v-64h64V128H384v64h-64V96a32 32 0 0 1 32-32h576a32 32 0 0 1 32 32zM256 672h320v64H256v-64zm0-192h320v64H256v-64z"}))},2290:(e,t,n)=>{"use strict";n.r(t),n.d(t,{BooleanEditor:()=>o});var r=n(3696);function o(e){return r.createElement("div",{style:e.style},r.createElement("input",{type:"checkbox",disabled:e.readOnly||!e.setValue,checked:e.value,onChange:t=>{!e.readOnly&&e.setValue&&e.setValue(t.target.checked)}}))}},8640:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Button:()=>h,Label:()=>g});var r=n(3696),o=n(7749),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))u.call(t,n)&&d(e,n,t[n]);return e},f=(e,t)=>a(e,s(t));function h(e){return r.createElement("button",f(p({},e),{style:p(p(p({},o.buttonStyle),e.style),e.disabled?o.disabledStyle:{})})," ",e.children)}function g(e){return r.createElement("span",f(p({},e),{style:p(p({},o.labelStyle),e.style)})," ",e.children)}},7749:(e,t,n)=>{"use strict";n.r(t),n.d(t,{buttonStyle:()=>d,controlStyle:()=>u,disabledStyle:()=>p,getChildProps:()=>g,groupStyle:()=>h,labelStyle:()=>f});var r=Object.defineProperty,o=Object.defineProperties,i=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const u={outline:0,padding:"0.375rem 0.75rem",fontSize:"1rem",fontWeight:400,fontFamily:"monospace",lineHeight:1.5,color:"#212529",backgroundColor:"#fff",backgroundClip:"padding-box",border:"1px solid #ced4da",appearance:"none",borderRadius:"0.25rem",flex:1,marginBottom:"3px"},d={display:"inline-block",fontWeight:400,lineHeight:1,color:"#212529",textAlign:"center",textDecoration:"none",verticalAlign:"middle",cursor:"pointer",userSelect:"none",backgroundColor:"transparent",border:"1px solid transparent",padding:"0.375rem 0.75rem",fontSize:"1rem",borderRadius:"0.25rem"},p={cursor:"not-allowed",opacity:.5},f=o(((e,t)=>{for(var n in t||(t={}))s.call(t,n)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(e,n,t[n]);return e})({},d),i({cursor:void 0}));const h={padding:"10px",border:"1px solid rgba(0,0,0,.125)",borderRadius:"0.25rem",flex:1,marginBottom:"3px"};function g(e){const t={};return void 0!==e.readOnly&&(t.readOnly=e.readOnly),t}},1030:(e,t,n)=>{"use strict";n.r(t),n.d(t,{DialogContainer:()=>a});var r=n(3696),o=n(8640),i=n(7749);function a(e){const[t,n]=r.useState(!1);return r.createElement(r.Fragment,null,r.createElement(o.Button,{onClick:()=>n(!0)},s),t&&r.createElement("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",justifyContent:"center",alignItems:"center",zIndex:2},onClick:()=>n(!1)},r.createElement("div",{style:{width:"600px",display:"flex",background:"white"},onClick:e=>e.stopPropagation()},r.cloneElement(e.children,(0,i.getChildProps)(e)))))}const s=r.createElement("svg",{style:{width:"20px",height:"20px"},viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},r.createElement("path",{fill:"currentColor",d:"M832 512a32 32 0 1 1 64 0v352a32 32 0 0 1-32 32H160a32 32 0 0 1-32-32V160a32 32 0 0 1 32-32h352a32 32 0 0 1 0 64H192v640h640V512z"}),r.createElement("path",{fill:"currentColor",d:"m469.952 554.24 52.8-7.552L847.104 222.4a32 32 0 1 0-45.248-45.248L477.44 501.44l-7.552 52.8zm422.4-422.4a96 96 0 0 1 0 135.808l-331.84 331.84a32 32 0 0 1-18.112 9.088L436.8 623.68a32 32 0 0 1-36.224-36.224l15.104-105.6a32 32 0 0 1 9.024-18.112l331.904-331.84a96 96 0 0 1 135.744 0z"}))},6209:(e,t,n)=>{"use strict";n.r(t),n.d(t,{EnumArrayEditor:()=>p,EnumEditor:()=>f});var r=n(3696),o=n(8662),i=n(7749),a=Object.defineProperty,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))c.call(t,n)&&u(e,n,t[n]);return e};function p(e){return r.createElement("div",{style:e.style},e.enums.map(((t,n)=>{var i,a;return r.createElement("label",{key:t,style:{marginRight:"10px"}},r.createElement("input",{type:"checkbox",checked:e.value.includes(t),style:{marginRight:"5px"},disabled:e.readOnly||!e.setValue,onChange:()=>{if(e.readOnly||!e.setValue)return;const n=e.value.indexOf(t);e.setValue((0,o.produce)(e.value,(e=>{n>=0?e.splice(n,1):e.push((0,o.castDraft)(t))})))}}),null!=(a=null==(i=e.enumTitles)?void 0:i[n])?a:t)})))}function f(e){return e.select?r.createElement("select",{style:d(d({},i.controlStyle),e.style),disabled:e.readOnly||!e.setValue,value:e.value,onChange:t=>{if(e.readOnly||!e.setValue)return;let n=t.target.value;"number"==typeof e.enums[0]&&(n=+n),e.setValue(n)}},e.enums.map(((t,n)=>{var o,i;return r.createElement("option",{key:t,value:t},null!=(i=null==(o=e.enumTitles)?void 0:o[n])?i:t)}))):r.createElement("div",{style:e.style},e.enums.map(((t,n)=>{var o,i;return r.createElement("label",{key:t,style:{marginRight:"10px"}},r.createElement("input",{type:"radio",disabled:e.readOnly||!e.setValue,checked:e.value===t,style:{marginRight:"5px"},onChange:()=>{!e.readOnly&&e.setValue&&e.setValue(t)}}),null!=(i=null==(o=e.enumTitles)?void 0:o[n])?i:t)})))}},8174:(e,t,n)=>{"use strict";n.r(t);var r=n(6199),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(2290);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(1030);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(6209);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o);var l=n(4993);o={};for(const e in l)"default"!==e&&(o[e]=()=>l[e]);n.d(t,o);var c=n(6467);o={};for(const e in c)"default"!==e&&(o[e]=()=>c[e]);n.d(t,o);var u=n(2729);o={};for(const e in u)"default"!==e&&(o[e]=()=>u[e]);n.d(t,o);var d=n(3675);o={};for(const e in d)"default"!==e&&(o[e]=()=>d[e]);n.d(t,o);var p=n(8640);o={};for(const e in p)"default"!==e&&(o[e]=()=>p[e]);n.d(t,o);var f=n(7749);o={};for(const e in f)"default"!==e&&(o[e]=()=>f[e]);n.d(t,o)},4993:(e,t,n)=>{"use strict";n.r(t),n.d(t,{NumberEditor:()=>p});var r=n(3696),o=n(3975),i=n(7749),a=Object.defineProperty,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))c.call(t,n)&&u(e,n,t[n]);return e};function p(e){var t;const[n,a]=r.useState("color"===e.type?(0,o.getColorString)(e.value):e.value.toString());r.useEffect((()=>{a("color"===e.type?(0,o.getColorString)(e.value):e.value.toString())}),[e.value]);const s=()=>{if(e.readOnly||!e.setValue)return;let t;t="color"===e.type?(0,o.colorStringToNumber)(n):+n,isNaN(t)||t===e.value||e.setValue(t)};let l={};return"color"===e.type&&(l={flex:"unset",padding:0}),!e.readOnly&&e.setValue||(l.opacity=.5),r.createElement("input",{value:n,type:null!=(t=e.type)?t:"number",disabled:e.readOnly||!e.setValue,onChange:t=>{!e.readOnly&&e.setValue&&a(t.target.value)},style:d(d(d({},i.controlStyle),e.style),l),onKeyDown:t=>{var n;"Enter"===t.key&&s(),"Escape"!==t.key?t.stopPropagation():null==(n=e.onCancel)||n.call(e)},onBlur:()=>{setTimeout((()=>{s()}),0)}})}},6467:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ObjectEditor:()=>d});var r=n(3696),o=n(7749),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(e,n,t[n]);return e};function d(e){const t=Object.entries(e.properties).map((([t,n])=>[t,Array.isArray(n)?n.map(((t,n)=>t?r.cloneElement(t,u({key:n},(0,o.getChildProps)(e))):null)):r.cloneElement(n,(0,o.getChildProps)(e))]));return e.inline?r.createElement("table",{style:o.groupStyle},r.createElement("thead",null),r.createElement("tbody",null,t.map((([e,t])=>r.createElement("tr",{key:e},r.createElement("td",{style:{paddingRight:"5px"}},e),r.createElement("td",{style:{display:"flex",flexDirection:"column"}},t)))))):r.createElement("div",{style:o.groupStyle},t.map((([e,t])=>r.createElement(r.Fragment,{key:e},r.createElement("div",{style:{marginTop:"5px",marginBottom:"5px"}},e),r.createElement("div",{style:{display:"flex",flexDirection:"column"}},t)))))}},2729:(e,t,n)=>{"use strict";n.r(t),n.d(t,{StringEditor:()=>d});var r=n(3696),o=n(7749),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(e,n,t[n]);return e};function d(e){var t;const[n,i]=r.useState(e.value);r.useEffect((()=>{i(e.value)}),[e.value]);const a=()=>{!e.readOnly&&e.setValue&&n!==e.value&&e.setValue(n)};let s,l={};return"color"===e.type&&(l={flex:"unset",padding:0}),!e.readOnly&&e.setValue||(l.opacity=.5),e.textarea?r.createElement("textarea",{value:n,disabled:e.readOnly||!e.setValue,onChange:t=>{!e.readOnly&&e.setValue&&i(t.target.value)},onKeyDown:t=>{var n;"Escape"!==t.key?t.stopPropagation():null==(n=e.onCancel)||n.call(e)},autoFocus:e.autoFocus,onBlur:()=>{setTimeout((()=>{a()}),0)},style:u(u(u({},o.controlStyle),e.style),l)}):((function(e){if(!e||e.length<=8)return!1;if("http://"!==e.substr(0,7)&&"https://"!==e.substr(0,8))return!1;const t=e.substr(e.length-4,4);return-1!==p.indexOf(t)}(e.value)||!!(c=e.value)&&0===c.indexOf("data:image/")&&-1!==c.indexOf(";base64,"))&&(s=r.createElement("img",{src:e.value,style:{display:"block",height:"auto",margin:"6px 0px",maxWidth:"100%"}})),r.createElement(r.Fragment,null,r.createElement("input",{value:n,disabled:e.readOnly||!e.setValue,type:null!=(t=e.type)?t:"text",onChange:t=>{!e.readOnly&&e.setValue&&i(t.target.value)},onKeyDown:t=>{var n;"Enter"===t.key&&a(),"Escape"!==t.key?t.stopPropagation():null==(n=e.onCancel)||n.call(e)},onBlur:()=>{setTimeout((()=>{a()}),0)},style:u(u(u({},o.controlStyle),e.style),l)}),s));var c}const p=[".png",".jpg",".bmp",".gif"]},3675:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getArrayEditorProps:()=>a,useJsonEditorData:()=>i});var r=n(8662),o=n(3696);function i(e){const[t,n]=o.useState(e);return{value:t,update:e=>o=>{n((0,r.produce)(t,(t=>{e(t,o)})))},getArrayProps:(e,o)=>a(e,o,(e=>{n((0,r.produce)(t,(t=>{e(t)})))}))}}function a(e,t,n){return{add:()=>n((n=>{e(n).push("function"==typeof t?t():t)})),remove:t=>n((n=>{e(n).splice(t,1)})),copy:t=>n((n=>{const r=e(n);r.splice(t,0,r[t])})),moveUp:t=>n((n=>{const r=e(n);r.splice(t-1,0,r[t]),r.splice(t+1,1)})),moveDown:t=>n((n=>{const r=e(n);r.splice(t+2,0,r[t]),r.splice(t,1)}))}}},6176:(e,t,n)=>{"use strict";n.r(t),n.d(t,{codeRenderTarget:()=>o});var r=n(7727);const o={type:"code",renderResult:(e,t,n,r)=>`target.renderResult([\n${e.map((e=>" "+e)).join(",\n")}\n], ${t}, ${n}, ${i(r)})`,renderEmpty:()=>"target.renderEmpty()",renderGroup:(e,t)=>`target.renderGroup([\n${e.map((e=>" "+e)).join(",\n")}\n], ${i(t)})`,renderRect:(e,t,n,r,o)=>`target.renderRect(${e}, ${t}, ${n}, ${r}, ${i(o)})`,renderPolyline:(e,t)=>`target.renderPolyline(${i(e)}, ${i(t)})`,renderPolygon:(e,t)=>`target.renderPolygon(${i(e)}, ${i(t)})`,renderCircle:(e,t,n,r)=>`target.renderCircle(${e}, ${t}, ${n}, ${i(r)})`,renderEllipse:(e,t,n,r,o)=>`target.renderEllipse(${e}, ${t}, ${n}, ${r}, ${i(o)})`,renderArc:(e,t,n,r,o,a)=>`target.renderArc(${e}, ${t}, ${n}, ${r}, ${o}, ${i(a)})`,renderEllipseArc:(e,t,n,r,o,a,s)=>`target.renderEllipseArc(${e}, ${t}, ${n}, ${r}, ${o}, ${a}, ${i(s)})`,renderPathCommands:(e,t)=>`target.renderPathCommands(${i(e)}, ${i(t)})`,renderText:(e,t,n,r,o,a,s)=>`target.renderText(${e}, ${t}, ${i(n)}, ${i(r)}, ${o}, ${i(a)}, ${i(s)})`,renderImage:(e,t,n,r,o,a)=>`target.renderImage(${i(e)}, ${t}, ${n}, ${r}, ${o}, ${i(a)})`,renderPath:(e,t)=>`target.renderPath(${i(e)}, ${i(t)})`,renderRay:(e,t,n,r)=>`target.renderRay(${e}, ${t}, ${n}, ${i(r)})`};function i(e){return(0,r.printJsToCode)(e,{functionPrinter:e=>"() => "+e()})}},3876:(e,t,n)=>{"use strict";n.r(t),n.d(t,{createWebglRenderer:()=>S,defaultVec4Color:()=>A,forEachPatternGraphicRepeatedGraphic:()=>j,getImageGraphic:()=>M,getNumArrayPointsBounding:()=>G,getPathGraphics:()=>T,getTextGraphic:()=>R,getTextureGraphicMatrix:()=>V,getWorldMatrix:()=>W,setCanvasLineDash:()=>D});var r=n(9397),o=n(5230),i=n.n(o),a=n(7237),s=n(3975),l=n(5147),c=n(2792),u=n(5773),d=n(1796),p=n(2318),f=n(7713),h=n(1715),g=n(7764),m=n(8392),y=n(3793),v=Object.defineProperty,x=Object.defineProperties,b=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertySymbols,E=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,k=(e,t,n)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))E.call(t,n)&&k(e,n,t[n]);if(C)for(var n of C(t))P.call(t,n)&&k(e,n,t[n]);return e},_=(e,t)=>x(e,b(t));function S(e){const t=e.getContext("webgl",{antialias:!0,stencil:!0,premultipliedAlpha:!1});if(!t)return;t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA);const n=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n uniform mat3 matrix;\n uniform float flipY;\n void main() {\n gl_Position = vec4((matrix * vec3(position, 1)).xy * vec2(1, flipY), 0, 1);\n }\n ","\n precision mediump float;\n uniform vec4 color;\n void main() {\n gl_FragColor = color;\n }"]))),o=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n attribute vec2 base;\n uniform mat3 matrix;\n uniform float flipY;\n uniform float scale;\n void main() {\n vec2 p = (position - base) * scale + base;\n gl_Position = vec4((matrix * vec3(p, 1)).xy * vec2(1, flipY), 0, 1);\n }\n ","\n precision mediump float;\n uniform vec4 color;\n void main() {\n gl_FragColor = color;\n }"]))),i=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n uniform mat3 matrix;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position, 1)).xy, 0, 1);\n texcoord = position;\n }\n ","\n precision mediump float;\n\n varying vec2 texcoord;\n uniform sampler2D texture;\n uniform vec4 color;\n\n void main() {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 ||\n texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n vec4 color = texture2D(texture, texcoord) * color;\n if (color.a < 0.1) {\n discard;\n }\n gl_FragColor = color;\n }"]))),a=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n uniform mat3 matrix;\n uniform float flipY;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position, 1)).xy * vec2(1, flipY), 0, 1);\n texcoord = position;\n }\n ","\n precision mediump float;\n\n varying vec2 texcoord;\n uniform sampler2D texture;\n uniform float opacity;\n\n void main() {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 ||\n texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n gl_FragColor = texture2D(texture, texcoord) * vec4(1, 1, 1, opacity);\n }"]))),c=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n uniform mat3 matrix;\n uniform float flipY;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position, 1)).xy * vec2(1, flipY), 0, 1);\n texcoord = position;\n }\n ","\n precision mediump float;\n\n varying vec2 texcoord;\n uniform sampler2D texture;\n uniform float opacity;\n uniform float colorMatrix[20];\n\n void main() {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 ||\n texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n vec4 c = texture2D(texture, texcoord) * vec4(1, 1, 1, opacity);\n\t\t\tgl_FragColor.r = colorMatrix[0] * c.r + colorMatrix[1] * c.g + colorMatrix[2] * c.b + colorMatrix[3] * c.a + colorMatrix[4];\n\t\t\tgl_FragColor.g = colorMatrix[5] * c.r + colorMatrix[6] * c.g + colorMatrix[7] * c.b + colorMatrix[8] * c.a + colorMatrix[9];\n\t\t\tgl_FragColor.b = colorMatrix[10] * c.r + colorMatrix[11] * c.g + colorMatrix[12] * c.b + colorMatrix[13] * c.a + colorMatrix[14];\n\t\t\tgl_FragColor.a = colorMatrix[15] * c.r + colorMatrix[16] * c.g + colorMatrix[17] * c.b + colorMatrix[18] * c.a + colorMatrix[19];\n }"]))),u=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n uniform mat3 matrix;\n uniform float flipY;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position, 1)).xy * vec2(1, flipY), 0, 1);\n texcoord = position;\n }\n ","\n precision mediump float;\n\n varying vec2 texcoord;\n uniform sampler2D texture;\n uniform float opacity;\n uniform vec2 px;\n\n void main() {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 ||\n texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n\t\t\tgl_FragColor = vec4(0.0);\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2(-7.0*px.x, -7.0*px.y))*0.0044299121055113265;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2(-6.0*px.x, -6.0*px.y))*0.00895781211794;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2(-5.0*px.x, -5.0*px.y))*0.0215963866053;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2(-4.0*px.x, -4.0*px.y))*0.0443683338718;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2(-3.0*px.x, -3.0*px.y))*0.0776744219933;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2(-2.0*px.x, -2.0*px.y))*0.115876621105;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2(-1.0*px.x, -1.0*px.y))*0.147308056121;\n\t\t\tgl_FragColor += texture2D(texture, texcoord )*0.159576912161;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2( 1.0*px.x, 1.0*px.y))*0.147308056121;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2( 2.0*px.x, 2.0*px.y))*0.115876621105;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2( 3.0*px.x, 3.0*px.y))*0.0776744219933;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2( 4.0*px.x, 4.0*px.y))*0.0443683338718;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2( 5.0*px.x, 5.0*px.y))*0.0215963866053;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2( 6.0*px.x, 6.0*px.y))*0.00895781211794;\n\t\t\tgl_FragColor += texture2D(texture, texcoord + vec2( 7.0*px.x, 7.0*px.y))*0.0044299121055113265;\n }"]))),d=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n uniform mat3 matrix;\n varying vec2 texcoord;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position, 1)).xy, 0, 1);\n texcoord = position;\n }\n ","\n precision mediump float;\n\n varying vec2 texcoord;\n uniform sampler2D texture;\n uniform vec4 color;\n\n void main() {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 ||\n texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n vec4 color2 = texture2D(texture, texcoord);\n vec4 color3 = color2 * color;\n if (color3.a < 0.1) {\n discard;\n }\n gl_FragColor = color2;\n }"]))),p=new g.Lazy((()=>r.createProgramInfo(t,["\n attribute vec2 position;\n attribute vec4 color;\n uniform mat3 matrix;\n uniform float flipY;\n varying vec4 v_color;\n\n void main () {\n gl_Position = vec4((matrix * vec3(position, 1)).xy * vec2(1, flipY), 0, 1);\n v_color = color;\n }\n ","\n precision mediump float;\n\n varying vec4 v_color;\n\n void main() {\n gl_FragColor = v_color;\n }"]))),h=r.primitives.createXYQuadBufferInfo(t),m=new f.WeakmapCache,y=new f.WeakmapCache,v=e=>{const t={};let n;return"color matrix"===e.type?(n=c.instance,t.colorMatrix=e.value):(n=u.instance,t.px=e.value),{programInfo:n,filterUniforms:t}},x=()=>{r.drawObjectList(t,b),b=[]};let b=[];const C=(n,o,i,s,c)=>{let u;if(x(),n.graphics.some((e=>e.pattern))){const a=r.createFramebufferInfo(t,void 0,e.width,e.height);r.bindFramebufferInfo(t,a),j(n,o,i,((e,t)=>{E(e,t,c)})),x(),u=a.attachments[0],t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,t.canvas.width,t.canvas.height)}t.clearStencil(0),t.clear(t.STENCIL_BUFFER_BIT),t.colorMask(!1,!1,!1,!1),t.enable(t.STENCIL_TEST),t.stencilFunc(t.ALWAYS,1,255),t.stencilOp(t.KEEP,t.KEEP,t.REPLACE),r.drawObjectList(t,[s]),t.stencilFunc(t.EQUAL,1,255),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.colorMask(!0,!0,!0,!0),u?r.drawObjectList(t,[{programInfo:a.instance,bufferInfo:h,uniforms:{matrix:l.m3.projection(1,1),opacity:null!=c?c:1,texture:u,flipY:-1}}]):(j(n,o,i,((e,t)=>{E(e,t,c)})),x()),t.disable(t.STENCIL_TEST)},E=(e,c,u,f)=>{var g,E;const P=(0,s.mergeOpacities)(e.opacity,u),k=(0,s.mergeOpacityToColor)(e.color,P);if("texture"===e.type){const{textureMatrix:n,width:o,height:s}=V(c,e);let u=m.get(e.src,(()=>r.createTexture(t,{src:e.src})));if(e.filters&&e.filters.length>1){x();const n=[];for(let o=0;o0){const t=v(e.filters[e.filters.length-1]);p=t.programInfo,f=t.filterUniforms}else p=e.pattern?d.instance:e.color?i.instance:a.instance;const y={programInfo:p,bufferInfo:h,uniforms:_(w({matrix:n,color:k,opacity:null!=(E=e.opacity)?E:1,texture:u},f),{flipY:1})};e.pattern?C(e.pattern,c,{xMin:e.x,yMin:e.y,xMax:e.x+o,yMax:e.y+s},y,P):b.push(y)}else{const i={programInfo:e.colors?p.instance:e.basePoints&&f?o.instance:n.instance,bufferInfo:y.get(e.points,(()=>{const n={position:{numComponents:2,data:e.points}};return e.colors&&(n.color={numComponents:4,data:e.colors}),e.basePoints&&f&&(n.base={numComponents:2,data:e.basePoints}),r.createBufferInfoFromArrays(t,n)})),uniforms:{color:k,matrix:c,flipY:1,scale:f?1/f:void 0},type:"triangles"===e.type?t.TRIANGLES:"line strip"===e.type?t.LINE_STRIP:"lines"===e.type?t.LINES:t.TRIANGLE_STRIP};if(e.pattern){const t=G(e.points);C(e.pattern,c,t,i,P)}else b.push(i)}};return(n,o,i,a,s,c)=>{t.viewport(0,0,t.canvas.width,t.canvas.height),r.resizeCanvasToDisplaySize(e),t.clearColor(...o),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT);const u=W(t.canvas,i,a,s,c);for(const e of n){const t=e.matrix?l.m3.multiply(u,e.matrix):u;E(e,t,void 0,s)}x()}}function R(e,t,n,r,o,i,a){var l;const c=null!=(l=null==a?void 0:a.strokeWidth)?l:0,u=()=>{var e,t;const l=document.createElement("canvas"),u=l.getContext("2d");if(!u)return;const d=`${null!=(e=null==a?void 0:a.fontWeight)?e:"normal"} ${null!=(t=null==a?void 0:a.fontStyle)?t:"normal"} ${o}px ${i}`;u.font=d;const p=u.measureText(n);return u.canvas.width=Math.ceil(p.width)+2,u.canvas.height=o+p.actualBoundingBoxDescent,u.font=d,(void 0!==r||(null==a?void 0:a.fillLinearGradient)||(null==a?void 0:a.fillRadialGradient))&&(u.fillStyle=void 0!==(null==a?void 0:a.strokeColor)&&"number"==typeof r?(0,s.getColorString)(r,a.fillOpacity):"white",u.fillText(n,0,o)),void 0!==(null==a?void 0:a.strokeColor)?(u.strokeStyle=void 0!==r&&"number"==typeof r?(0,s.getColorString)(a.strokeColor,a.strokeOpacity):"white",void 0!==a.strokeWidth&&(u.lineWidth=a.strokeWidth),D(u,a),u.strokeText(n,0,o)):((null==a?void 0:a.strokePattern)||(null==a?void 0:a.strokeLinearGradient)||(null==a?void 0:a.strokeRadialGradient))&&(u.strokeStyle="white",void 0!==a.strokeWidth&&(u.lineWidth=a.strokeWidth-1),D(u,a),u.strokeText(n,0,o-c)),{textMetrics:p,imageData:u.getImageData(0,0,l.width,l.height),canvas:l}},d=(null==a?void 0:a.cacheKey)?L.get(a.cacheKey,n,u):u();if(!d)return;const{imageData:p,textMetrics:f,canvas:h}=d;let g=t-p.height+c+f.actualBoundingBoxDescent;"top"===(null==a?void 0:a.textBaseline)?g+=f.actualBoundingBoxAscent+f.actualBoundingBoxDescent/2:"middle"===(null==a?void 0:a.textBaseline)?g+=(f.actualBoundingBoxAscent-f.actualBoundingBoxDescent)/2:"bottom"===(null==a?void 0:a.textBaseline)&&(g-=f.fontBoundingBoxDescent);let m,y=e;if("right"===(null==a?void 0:a.textAlign)?y-=p.width:"center"===(null==a?void 0:a.textAlign)&&(y-=p.width/2),(null==a?void 0:a.strokePattern)?m=a.strokePattern:(null==a?void 0:a.strokeLinearGradient)?m={graphics:[z(a.strokeLinearGradient,[{x:y,y:g},{x:y+p.width,y:g},{x:y,y:t},{x:y+p.width,y:t}])]}:(null==a?void 0:a.strokeRadialGradient)?m={graphics:[U(a.strokeRadialGradient,[{x:y,y:g},{x:y+p.width,y:g},{x:y,y:t},{x:y+p.width,y:t}])]}:(null==a?void 0:a.fillLinearGradient)?m={graphics:[z(a.fillLinearGradient,[{x:y,y:g},{x:y+p.width,y:g},{x:y,y:t},{x:y+p.width,y:t}])]}:(null==a?void 0:a.fillRadialGradient)&&(m={graphics:[U(a.fillRadialGradient,[{x:y,y:g},{x:y+p.width,y:g},{x:y,y:t},{x:y+p.width,y:t}])]}),m)return{type:"texture",x:y,y:g,src:p,canvas:h,color:A,pattern:m};if(void 0!==r&&"number"!=typeof r)return{type:"texture",x:y,y:g,src:p,canvas:h,color:A,pattern:r};if(void 0===r){if(void 0===(null==a?void 0:a.strokeColor))return;return{type:"texture",x:y,y:g,color:(0,s.colorNumberToRec)(a.strokeColor,a.strokeOpacity),src:p,canvas:h}}return void 0!==(null==a?void 0:a.strokeColor)?{type:"texture",x:y,y:g,src:p,canvas:h}:{type:"texture",x:y,y:g,color:(0,s.colorNumberToRec)(r,null==a?void 0:a.fillOpacity),src:p,canvas:h}}const A=[0,0,0,1];function T(e,t,n){var r,o,a,l,u;const p=null!=(r=null==n?void 0:n.strokeWidth)?r:1,f=!!(null==n?void 0:n.closed)||(null!=(o=null==n?void 0:n.lineCap)?o:y.defaultLineCap),h=null!=(a=null==n?void 0:n.lineJoin)?a:y.defaultLineJoin,g="miter"===h?null!=(l=null==n?void 0:n.miterLimit)?l:y.defaultMiterLimit:h,m=(0,s.colorNumberToRec)(null!=(u=null==n?void 0:n.strokeColor)?u:0,null==n?void 0:n.strokeOpacity),v=[];if(p){if(null==n?void 0:n.dashArray){const t=n.dashArray;e=e.map((e=>(!0===f&&(e=(0,d.polygonToPolyline)(e)),(0,d.dashedPolylineToLines)(e,t,void 0,n.dashOffset)))).flat()}if(t&&(0,c.isSameNumber)(p,1))v.push({type:"lines",points:F.get(e,f,(()=>e.map((e=>B.get(e,f,(()=>{!0===f&&(e=(0,d.polygonToPolyline)(e));const t=[];for(let n=1;n{const t={points:[],base:[]};for(const n of e){const e=I.get(n,p,f,g,(()=>{const e=(0,y.getPolylineTriangles)(n,p,f,g);return{points:(0,y.triangleStripToTriangles)(e.points),base:(0,y.triangleStripToTriangles)(e.base)}}));t.points.push(...e.points),t.base.push(...e.base)}return t}));let o,i=m;(null==n?void 0:n.strokePattern)?(o=n.strokePattern,i=[0,0,0,0]):(null==n?void 0:n.strokeLinearGradient)?(o={graphics:[z(n.strokeLinearGradient,N(r.points))]},i=[0,0,0,0]):(null==n?void 0:n.strokeRadialGradient)&&(o={graphics:[U(n.strokeRadialGradient,N(r.points))]},i=[0,0,0,0]),v.push({type:"triangles",points:r.points,basePoints:t?r.base:void 0,color:i,pattern:o})}}if(void 0!==(null==n?void 0:n.fillColor)||void 0!==(null==n?void 0:n.fillPattern)||void 0!==(null==n?void 0:n.fillLinearGradient)||void 0!==(null==n?void 0:n.fillRadialGradient)){const t=[],r=[];for(let n=0;n[e.x,e.y])).flat());const o=i()(t,r),a=[];for(let e=0;e0&&s.filters.forEach((e=>{if("brightness"===e.type)c.push({type:"color matrix",value:[e.value,0,0,0,0,0,e.value,0,0,0,0,0,e.value,0,0,0,0,0,1,0]});else if("contrast"===e.type){const t=.5*(1-e.value);c.push({type:"color matrix",value:[e.value,0,0,0,t,0,e.value,0,0,t,0,0,e.value,0,t,0,0,0,1,0]})}else if("hue-rotate"===e.type){const t=(0,h.angleToRadian)(e.value),n=Math.cos(t),r=Math.sin(t),o=.213,i=.715,a=.072;c.push({type:"color matrix",value:[o+n*(1-o)+r*-o,i+n*-i+r*-i,a+n*-a+r*(1-a),0,0,o+n*-o+.143*r,i+n*(1-i)+.14*r,a+n*-a+-.283*r,0,0,o+n*-o+r*-(1-o),i+n*-i+r*i,a+n*(1-a)+r*a,0,0,0,0,0,1,0]})}else if("saturate"===e.type){const t=2*(e.value-1)/3+1,n=-.5*(t-1);c.push({type:"color matrix",value:[t,n,n,0,0,n,t,n,0,0,n,n,t,0,0,0,0,0,1,0]})}else if("grayscale"===e.type){const t=1-e.value;c.push({type:"color matrix",value:[.2126+.7874*t,.7152-.7152*t,.0722-.0722*t,0,0,.2126-.2126*t,.7152+.2848*t,.0722-.0722*t,0,0,.2126-.2126*t,.7152-.7152*t,.0722+.9278*t,0,0,0,0,0,1,0]})}else if("sepia"===e.type){const t=1-e.value;c.push({type:"color matrix",value:[.393+.607*t,.769-.769*t,.189-.189*t,0,0,.349-.349*t,.686+.314*t,.168-.168*t,0,0,.272-.272*t,.534-.534*t,.131+.869*t,0,0,0,0,0,1,0]})}else if("invert"===e.type){const t=1-2*e.value;c.push({type:"color matrix",value:[t,0,0,0,e.value,0,t,0,0,e.value,0,0,t,0,e.value,0,0,0,1,0]})}else"opacity"===e.type?c.push({type:"color matrix",value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,e.value,0]}):"blur"===e.type&&c.push({type:"blur",value:[0,3*e.value/7/o]},{type:"blur",value:[3*e.value/7/r,0]})})),{type:"texture",x:t,y:n,width:r,height:o,src:l,opacity:null==s?void 0:s.opacity,filters:c.length>0?c:void 0}}const L=new f.WeakmapMapCache,I=new f.WeakmapMap3Cache,O=new f.WeakmapMap3Cache,B=new f.WeakmapMapCache,F=new f.WeakmapMapCache;function D(e,t){(null==t?void 0:t.dashArray)&&(e.setLineDash(t.dashArray),t.dashOffset&&(e.lineDashOffset=t.dashOffset))}function z(e,t){const{start:n,end:r}=e,o=r.x-n.x,i=r.y-n.y,a=(0,d.twoPointLineToGeneralFormLine)(n,r);if(!a)return{type:"triangle strip",points:[],colors:[]};const l=e.stops.slice(0).sort(((e,t)=>e.offset-t.offset)),p=[];let f=l[0].offset,h=l[l.length-1].offset;t.forEach((e=>{const t=(0,m.getPerpendicularPoint)(e,a),r=(0,d.getPointSideOfLine)(e,a);if((0,c.isZero)(r))p.push(0);else{const n=(0,u.getTwoPointsDistance)(t,e);r>0?p.push(n):r<0&&p.push(-n)}const s=(0,c.isSameNumber)(t.x,n.x)?(t.y-n.y)/i:(t.x-n.x)/o;sh&&(h=s)})),(0,c.isSameNumber)(f,l[0].offset)||l.unshift({offset:f,color:l[0].color}),(0,c.isSameNumber)(h,l[l.length-1].offset)||l.push({offset:h,color:l[l.length-1].color});const g=(0,d.getParallelLinesByDistance)(a,Math.max(...p))[1],y=(0,d.getParallelLinesByDistance)(a,Math.min(...p))[1],v=[],x=[];return l.forEach((e=>{const t={x:n.x+o*e.offset,y:n.y+i*e.offset},r=(0,m.getPerpendicularPoint)(t,g),a=(0,m.getPerpendicularPoint)(t,y),l=(0,s.colorNumberToRec)(e.color,e.opacity);v.push(r.x,r.y,a.x,a.y),x.push(...l,...l)})),{type:"triangle strip",points:v,colors:x}}function U(e,t){let{start:n,end:r,stops:o}=e;if(n.r>r.r){const e=n;n=r,r=e,o=o.map((e=>({offset:1-e.offset,color:e.color})))}const i=r.x-n.x,a=r.y-n.y,l=r.r-n.r,c=o.slice(0).sort(((e,t)=>e.offset-t.offset)).map((e=>{const t={x:n.x+i*e.offset,y:n.y+a*e.offset,r:n.r+l*e.offset};return{color:(0,s.colorNumberToRec)(e.color,e.opacity),points:(0,p.arcToPolyline)((0,p.circleToArc)(t),5)}})),d=Math.max(...t.map((e=>(0,u.getTwoPointsDistance)(e,r))));d>r.r&&c.push({color:c[c.length-1].color,points:(0,p.arcToPolyline)((0,p.circleToArc)({x:r.x,y:r.y,r:d}),5)});const f=[],h=[];if(n.r>0){const e=c[0],t=[],r=[];e.points.forEach((o=>{t.push(o.x,o.y,n.x,n.y),r.push(...e.color,...e.color)})),f.push(t),h.push(r)}for(let e=1;e{const a=n.points[i];r.unshift(e.x,e.y,a.x,a.y),o.unshift(...t.color,...n.color)})),f.push(r),h.push(o)}return{type:"triangle strip",points:(0,y.combineStripTriangles)(f),colors:(0,y.combineStripTriangleColors)(h)}}function N(e){const t=[];for(let n=0;nr&&(r=a),so&&(o=s)}return{xMax:r,xMin:t,yMin:n,yMax:o}}function j(e,t,n,r){var o,i;const{xMin:a,yMin:s,xMax:c,yMax:u}=n,d=null!=(o=e.width)?o:Number.MAX_SAFE_INTEGER,p=null!=(i=e.height)?i:Number.MAX_SAFE_INTEGER,f=Math.floor(a/d),h=Math.floor(c/d),g=Math.floor(s/p),m=Math.floor(u/p);for(let n=f;n<=h;n++)for(let o=g;o<=m;o++){const i=l.m3.multiply(t,l.m3.translation(n*d,o*p));for(const t of e.graphics)r(t,t.matrix?l.m3.multiply(i,t.matrix):i)}}function V(e,t){var n,r;const o=l.m3.multiply(e,l.m3.translation(t.x,t.y)),i=null!=(n=t.width)?n:t.src.width,a=null!=(r=t.height)?r:t.src.height;return{textureMatrix:l.m3.multiply(o,l.m3.scaling(i,a)),width:i,height:a}}function W(e,t,n,r,o){let i=l.m3.projection(e.width,e.height);return i=l.m3.multiply(i,l.m3.translation(t,n)),1!==r&&(i=l.m3.multiply(i,l.m3.translation(e.width/2,e.height/2)),i=l.m3.multiply(i,l.m3.scaling(r,r)),i=l.m3.multiply(i,l.m3.translation(-e.width/2,-e.height/2))),o&&(i=l.m3.multiply(i,l.m3.rotation(-o))),i}},7191:(e,t,n)=>{"use strict";n.r(t),n.d(t,{createUniformsBuffer:()=>d,createWebgpuRenderer:()=>u});var r=n(7764),o=n(3975),i=n(5147),a=n(6300),s=n(7713),l=n(3876),c=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{s(n.next(e))}catch(e){o(e)}},a=e=>{try{s(n.throw(e))}catch(e){o(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())}));function u(e){return c(this,null,(function*(){if(!navigator.gpu)return;const t=e.getContext("webgpu");if(!t)return;const n=yield navigator.gpu.requestAdapter();if(!n)return;const a=yield n.requestDevice(),c=navigator.gpu.getPreferredCanvasFormat();t.configure({device:a,format:c});const u={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"},alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"}},f=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n color: vec4f,\n matrix: mat3x3f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n \n @vertex\n fn vertex_main(@location(0) position: vec2f) -> @builtin(position) vec4f\n {\n return vec4f((uniforms.matrix * vec3(position, 1)).xy, 0, 1);\n }\n \n @fragment\n fn fragment_main() -> @location(0) vec4f\n {\n return uniforms.color;\n }"}))),h=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n color: vec4f,\n matrix: mat3x3f,\n scale: f32,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n \n @vertex\n fn vertex_main(@location(0) position: vec2f, @location(1) base: vec2f) -> @builtin(position) vec4f\n {\n let p = (position - base) * uniforms.scale + base;\n return vec4f((uniforms.matrix * vec3(p, 1)).xy, 0, 1);\n }\n \n @fragment\n fn fragment_main() -> @location(0) vec4f\n {\n return uniforms.color;\n }"}))),g=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n color: vec4f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n var color = textureSample(myTexture, mySampler, texcoord) * uniforms.color;\n if (color.a < 0.1) {\n discard;\n }\n return color;\n }"}))),m=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n opacity: f32,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n return textureSample(myTexture, mySampler, texcoord) * vec4f(1, 1, 1, uniforms.opacity);\n }"}))),y=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n opacity: f32,\n colorMatrix: array,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n var c = textureSample(myTexture, mySampler, texcoord) * vec4f(1, 1, 1, uniforms.opacity);\n var r = uniforms.colorMatrix[0][0] * c.r + uniforms.colorMatrix[0][1] * c.g + uniforms.colorMatrix[0][2] * c.b + uniforms.colorMatrix[0][3] * c.a + uniforms.colorMatrix[1][0];\n var g = uniforms.colorMatrix[1][1] * c.r + uniforms.colorMatrix[1][2] * c.g + uniforms.colorMatrix[1][3] * c.b + uniforms.colorMatrix[2][0] * c.a + uniforms.colorMatrix[2][1];\n var b = uniforms.colorMatrix[2][2] * c.r + uniforms.colorMatrix[2][3] * c.g + uniforms.colorMatrix[3][0] * c.b + uniforms.colorMatrix[3][1] * c.a + uniforms.colorMatrix[3][2];\n var a = uniforms.colorMatrix[3][3] * c.r + uniforms.colorMatrix[4][0] * c.g + uniforms.colorMatrix[4][1] * c.b + uniforms.colorMatrix[4][2] * c.a + uniforms.colorMatrix[4][3];\n return vec4f(r, g, b, a);\n }"}))),v=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n opacity: f32,\n px: vec4f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n var r = vec4f(0.0);\n r += textureSample(myTexture, mySampler, texcoord + vec2(-7.0*uniforms.px.x, -7.0*uniforms.px.y))*0.0044299121055113265;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-6.0*uniforms.px.x, -6.0*uniforms.px.y))*0.00895781211794;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-5.0*uniforms.px.x, -5.0*uniforms.px.y))*0.0215963866053;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-4.0*uniforms.px.x, -4.0*uniforms.px.y))*0.0443683338718;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-3.0*uniforms.px.x, -3.0*uniforms.px.y))*0.0776744219933;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-2.0*uniforms.px.x, -2.0*uniforms.px.y))*0.115876621105;\n r += textureSample(myTexture, mySampler, texcoord + vec2(-1.0*uniforms.px.x, -1.0*uniforms.px.y))*0.147308056121;\n r += textureSample(myTexture, mySampler, texcoord )*0.159576912161;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 1.0*uniforms.px.x, 1.0*uniforms.px.y))*0.147308056121;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 2.0*uniforms.px.x, 2.0*uniforms.px.y))*0.115876621105;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 3.0*uniforms.px.x, 3.0*uniforms.px.y))*0.0776744219933;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 4.0*uniforms.px.x, 4.0*uniforms.px.y))*0.0443683338718;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 5.0*uniforms.px.x, 5.0*uniforms.px.y))*0.0215963866053;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 6.0*uniforms.px.x, 6.0*uniforms.px.y))*0.00895781211794;\n r += textureSample(myTexture, mySampler, texcoord + vec2( 7.0*uniforms.px.x, 7.0*uniforms.px.y))*0.0044299121055113265;\n return r;\n }"}))),x=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n matrix: mat3x3f,\n color: vec4f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n \n @vertex\n fn vertex_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput\n {\n var pos = array(\n vec2f(0.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 0.0),\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(1.0, 0.0),\n );\n let xy = pos[vertexIndex];\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(xy, 1)).xy, 0, 1);\n vsOut.texcoord = xy;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) texcoord: vec2f) -> @location(0) vec4f\n {\n if (texcoord.x < 0.0 || texcoord.x > 1.0 || texcoord.y < 0.0 || texcoord.y > 1.0) {\n discard;\n }\n var color = textureSample(myTexture, mySampler, texcoord);\n var color2 = color * uniforms.color;\n if (color2.a < 0.1) {\n discard;\n }\n return color;\n }"}))),b=new r.Lazy((()=>a.createShaderModule({code:"struct Uniforms {\n color: vec4f,\n matrix: mat3x3f,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) color: vec4f,\n };\n \n @vertex\n fn vertex_main(@location(0) position: vec2f, @location(1) color: vec4f) -> VertexOutput\n {\n var vsOut: VertexOutput;\n vsOut.position = vec4f((uniforms.matrix * vec3(position, 1)).xy, 0, 1);\n vsOut.color = color;\n return vsOut;\n }\n \n @fragment\n fn fragment_main(@location(0) color: vec4f) -> @location(0) vec4f\n {\n return color;\n }"}))),C=new r.Lazy((()=>a.createSampler({magFilter:"nearest",minFilter:"nearest"}))),E=new r.Lazy((()=>a.createTexture({size:[e.width,e.height],sampleCount:4,format:c,usage:GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),P=new r.Lazy((()=>a.createTexture({format:"stencil8",sampleCount:4,size:[e.width,e.height],usage:GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),k=new s.WeakmapCache,w=new s.WeakmapCache2,_=new s.WeakmapCache2,S=new s.WeakmapMap2Cache,R=new s.WeakmapCache,A=new s.MapCache2,T=e=>"color matrix"===e.type?{shaderModule:y.instance,input:{type:"vec4 array",count:5,value:e.value}}:{shaderModule:v.instance,input:{type:"vec2",value:e.value}},M=(e,t,n,r)=>a.createRenderPipeline({vertex:{module:e,entryPoint:"vertex_main",buffers:r?[r]:void 0},fragment:{module:e,entryPoint:"fragment_main",targets:"mask"===t?[]:[{format:c,blend:u}]},depthStencil:"mask"===t?{format:"stencil8",depthCompare:"always",depthWriteEnabled:!1,stencilFront:{passOp:"replace"}}:"masked"===t?{depthCompare:"always",depthWriteEnabled:!1,format:"stencil8",stencilFront:{compare:"equal"}}:void 0,primitive:n?{topology:"triangles"===n?"triangle-list":"line strip"===n?"line-strip":"lines"===n?"line-list":"triangle-strip"}:void 0,multisample:{count:4},label:t,layout:"auto"}),L=(e,t,n)=>{e.setPipeline(t),e.setBindGroup(0,a.createBindGroup({layout:t.getBindGroupLayout(0),entries:n.map(((e,t)=>({binding:t,resource:e})))}))},I=(e,t,n,r,o="normal")=>{const i=A.get(e,o,(()=>M(e,o)));L(t,i,[{buffer:d(a,n)},C.instance,r.createView()]),t.draw(6)},O=(e,t)=>a.createTexture({size:[e,t],format:c,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),B=(e,n=t.getCurrentTexture(),r)=>e.beginRenderPass({colorAttachments:[{clearValue:r,loadOp:r?"clear":"load",storeOp:"store",view:E.instance.createView(),resolveTarget:n.createView()}],label:"normal"}),F=(e,n=t.getCurrentTexture(),r=1)=>{const o=e.beginRenderPass({colorAttachments:[{view:E.instance.createView(),resolveTarget:n.createView(),loadOp:0===r?"clear":"load",storeOp:"store"}],depthStencilAttachment:{view:P.instance.createView(),stencilLoadOp:"load",stencilStoreOp:"store"},label:"masked"});return o.setStencilReference(r),o},D=(t,n,r,o,s,c)=>{let u;if(t.graphics.some((e=>e.pattern))){u=O(e.width,e.height);const o=a.createCommandEncoder();let i=F(o,u,0);(0,l.forEachPatternGraphicRepeatedGraphic)(t,n,r,((e,t)=>{i=z(e,t,i,o,!0,s,u)})),i.end(),a.queue.submit([o.finish()])}let d=F(o);return u?I(m.instance,d,[{type:"mat3x3",value:i.m3.projection(1,1)},{type:"number",value:null!=s?s:1}],u,"masked"):(0,l.forEachPatternGraphicRepeatedGraphic)(t,n,r,((e,t)=>{d=z(e,t,d,o,!0,s,c)})),d.end(),B(o,c)},z=(t,n,r,s,c=!1,u,y,v)=>{var C,E,A;const F=(0,o.mergeOpacities)(t.opacity,u),z=(0,o.mergeOpacityToColor)(t.pattern?l.defaultVec4Color:t.color,F);t.pattern&&(r.end(),r=(e=>{const t=e.beginRenderPass({colorAttachments:[],depthStencilAttachment:{view:P.instance.createView(),stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"},label:"mask"});return t.setStencilReference(1),t})(s));const U=t.pattern?"mask":c&&"masked"===r.label?"masked":"normal";if("texture"===t.type){const{textureMatrix:o,width:c,height:u}=(0,l.getTextureGraphicMatrix)(n,t);let d,p=R.get(t.src,(()=>{const e=O(t.src.width,t.src.height),n=t.src instanceof ImageBitmap?t.src:t.canvas;return n&&a.queue.copyExternalImageToTexture({source:n},{texture:e},{width:t.src.width,height:t.src.height}),e}));if(t.filters&&t.filters.length>1){const n=[];for(let r=0;r0){const e=T(t.filters[t.filters.length-1]);d=e.shaderModule,f.push({type:"number",value:null!=(E=t.opacity)?E:1},e.input)}else t.pattern?(d=x.instance,f.push({type:"vec4",value:null!=z?z:l.defaultVec4Color})):t.color?(d=g.instance,f.push({type:"vec4",value:null!=z?z:l.defaultVec4Color})):(d=m.instance,f.push({type:"number",value:null!=(A=t.opacity)?A:1}));I(d,r,f,p,U),t.pattern&&(r.end(),r=D(t.pattern,n,{xMin:t.x,yMin:t.y,xMax:t.x+c,yMax:t.y+u},s,F,y))}else{const e=t.colors?b.instance:t.basePoints&&v?h.instance:f.instance,o=S.get(e,t.type,U,(()=>{const n=t.colors?{attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x4"}],arrayStride:24,stepMode:"vertex"}:t.basePoints&&v?{attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x2"}],arrayStride:16,stepMode:"vertex"}:{attributes:[{shaderLocation:0,offset:0,format:"float32x2"}],arrayStride:8,stepMode:"vertex"};return M(e,U,t.type,n)})),i=[{type:"vec4",value:z||l.defaultVec4Color},{type:"mat3x3",value:n}];if(t.basePoints&&v&&i.push({type:"number",value:1/v}),L(r,o,[{buffer:d(a,i)}]),t.colors){const e=t.colors;r.setVertexBuffer(0,_.get(t.points,e,(()=>{const n=p([{data:t.points,num:2},{data:e,num:4}]),r=new Float32Array(n),o=a.createBuffer({size:r.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});return a.queue.writeBuffer(o,0,r,0,r.length),o})))}else if(t.basePoints&&v){const e=t.basePoints;r.setVertexBuffer(0,w.get(t.points,e,(()=>{const n=p([{data:t.points,num:2},{data:e,num:2}]),r=new Float32Array(n),o=a.createBuffer({size:r.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});return a.queue.writeBuffer(o,0,r,0,r.length),o})))}else r.setVertexBuffer(0,k.get(t.points,(()=>{const e=new Float32Array(t.points),n=a.createBuffer({size:e.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});return a.queue.writeBuffer(n,0,e,0,e.length),n})));if(r.draw(t.points.length/2),t.pattern){r.end();const e=(0,l.getNumArrayPointsBounding)(t.points);r=D(t.pattern,n,e,s,F,y)}}return r};return(t,n,r,o,s,c)=>{!E.instanced||e.width===E.instance.width&&e.height===E.instance.height||E.reset(),!P.instanced||e.width===P.instance.width&&e.height===P.instance.height||P.reset();const u=(0,l.getWorldMatrix)(e,r,o,s,c),d=a.createCommandEncoder();let p=B(d,void 0,n);for(const e of t){const t=e.matrix?i.m3.multiply(u,e.matrix):u;p=z(e,t,p,d,void 0,void 0,void 0,s)}p.end(),a.queue.submit([d.finish()])}}))}function d(e,t){const n=(0,a.createMemoryLayoutArray)(...t),r=e.createBuffer({size:n.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});return e.queue.writeBuffer(r,0,n),r}function p(e){const t=[],n=Math.min(...e.map((e=>e.data.length/e.num)));for(let r=0;r{"use strict";n.r(t),n.d(t,{getImageFromCache:()=>o});const r=new Map;function o(e,t){var n;const o=r.get(e);return o?Array.isArray(o)?void o.push((()=>{var e;null==(e=null==t?void 0:t.rerender)||e.call(t)})):(null==(n=null==t?void 0:t.callback)||n.call(t,o),o):(r.set(e,[]),void function(e,t){return new Promise(((n,r)=>{const o=new Image;void 0!==t&&(o.crossOrigin=t),o.onload=()=>{n(o)},o.onerror=()=>{r()},o.src=e}))}(e,null==t?void 0:t.crossOrigin).then((n=>{createImageBitmap(n).then((n=>{var o,i;const a=r.get(e);r.set(e,n),Array.isArray(a)&&a.forEach((e=>{e()})),null==(o=null==t?void 0:t.callback)||o.call(t,n),null==(i=null==t?void 0:t.rerender)||i.call(t)}))})))}},4840:(e,t,n)=>{"use strict";n.r(t);var r=n(8012),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(9289);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(1777);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(7428);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o);var l=n(7529);o={};for(const e in l)"default"!==e&&(o[e]=()=>l[e]);n.d(t,o);var c=n(3876);o={};for(const e in c)"default"!==e&&(o[e]=()=>c[e]);n.d(t,o);var u=n(7191);o={};for(const e in u)"default"!==e&&(o[e]=()=>u[e]);n.d(t,o);var d=n(7237);o={};for(const e in d)"default"!==e&&(o[e]=()=>d[e]);n.d(t,o);var p=n(6176);o={};for(const e in p)"default"!==e&&(o[e]=()=>p[e]);n.d(t,o)},1777:(e,t,n)=>{"use strict";n.r(t),n.d(t,{CanvasDrawCanvas:()=>S,reactCanvasRenderTarget:()=>E});var r=n(3696),o=n(5147),i=n(3876),a=n(7237),s=n(8012),l=n(1796),c=n(2298),u=n(3975),d=n(1715),p=n(3793),f=Object.defineProperty,h=Object.defineProperties,g=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,x=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&x(e,n,t[n]);if(m)for(var n of m(t))v.call(t,n)&&x(e,n,t[n]);return e},C=(e,t)=>h(e,g(t));const E={type:"canvas",renderResult:(e,t,n,o)=>r.createElement(S,{width:t,height:n,attributes:null==o?void 0:o.attributes,draws:e,transform:null==o?void 0:o.transform,backgroundColor:null==o?void 0:o.backgroundColor,debug:null==o?void 0:o.debug,strokeWidthFixed:null==o?void 0:o.strokeWidthFixed}),renderEmpty:()=>()=>{},renderGroup:(e,t)=>(n,r,i,a,s,l,c)=>{const u=n.globalAlpha;if(n.save(),void 0!==(null==t?void 0:t.opacity)&&(n.globalAlpha=u*t.opacity),(null==t?void 0:t.translate)&&n.translate(t.translate.x,t.translate.y),void 0!==(null==t?void 0:t.base)){const e=(0,o.getRotationOptionsAngle)(t,!0);e&&(n.translate(t.base.x,t.base.y),n.rotate(e),n.translate(-t.base.x,-t.base.y));const r=(0,o.getScaleOptionsScale)(t);r&&(n.translate(t.base.x,t.base.y),n.scale(r.x,r.y),n.translate(-t.base.x,-t.base.y))}(null==t?void 0:t.matrix)&&n.setTransform(n.getTransform().multiply(o.m3.getTransformInit(t.matrix)));const d=(0,o.multiplyMatrix)(c,(0,o.getRenderOptionsMatrix)(t));e.forEach((e=>{e(n,r,i,a,s,l,d)})),n.restore()},renderRect:(e,t,n,r,o)=>(a,s,l,c,u,p,f)=>{a.save(),a.beginPath(),(0,i.setCanvasLineDash)(a,o),(null==o?void 0:o.angle)&&(a.translate(e+n/2,t+r/2),a.rotate((0,d.angleToRadian)(o.angle)),a.translate(-(e+n/2),-(t+r/2))),(null==o?void 0:o.rotation)&&(a.translate(e+n/2,t+r/2),a.rotate(o.rotation),a.translate(-(e+n/2),-(t+r/2))),a.rect(e,t,n,r),P(a,s,l,c,u,p,f,o),w(a,s,l,c,u,p,f,o),a.restore()},renderPolyline(e,t){const n=null!=t?t:{},{partsStyles:r}=n,o=((e,t)=>{var n={};for(var r in e)y.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&m)for(var r of m(e))t.indexOf(r)<0&&v.call(e,r)&&(n[r]=e[r]);return n})(n,["partsStyles"]);return r&&r.length>0?(0,s.renderPartStyledPolyline)(this,r,e,o):(n,r,o,a,s,l,c)=>{var u;n.save(),n.beginPath(),(0,i.setCanvasLineDash)(n,t);for(let r=0;r(o,a,s,l,c,u,d)=>{o.save(),o.beginPath(),(0,i.setCanvasLineDash)(o,r),o.arc(e,t,n,0,2*Math.PI),P(o,a,s,l,c,u,d,r),w(o,a,s,l,c,u,d,r),o.restore()},renderEllipse:(e,t,n,r,o)=>(a,s,l,c,u,p,f)=>{var h;a.save(),a.beginPath(),(0,i.setCanvasLineDash)(a,o);const g=null!=(h=null==o?void 0:o.rotation)?h:(0,d.angleToRadian)(null==o?void 0:o.angle);a.ellipse(e,t,n,r,g,0,2*Math.PI),P(a,s,l,c,u,p,f,o),w(a,s,l,c,u,p,f,o),a.restore()},renderArc:(e,t,n,r,o,a)=>(s,l,c,u,p,f,h)=>{s.save(),s.beginPath(),(0,i.setCanvasLineDash)(s,a),s.arc(e,t,n,(0,d.angleToRadian)(r),(0,d.angleToRadian)(o),null==a?void 0:a.counterclockwise),(null==a?void 0:a.closed)&&s.closePath(),P(s,l,c,u,p,f,h,a),w(s,l,c,u,p,f,h,a),s.restore()},renderEllipseArc:(e,t,n,r,o,a,s)=>(l,c,u,p,f,h,g)=>{var m;l.save(),l.beginPath(),(0,i.setCanvasLineDash)(l,s);const y=null!=(m=null==s?void 0:s.rotation)?m:(0,d.angleToRadian)(null==s?void 0:s.angle);l.ellipse(e,t,n,r,y,(0,d.angleToRadian)(o),(0,d.angleToRadian)(a),null==s?void 0:s.counterclockwise),(null==s?void 0:s.closed)&&l.closePath(),P(l,c,u,p,f,h,g,s),w(l,c,u,p,f,h,g,s),l.restore()},renderPathCommands:(e,t)=>(n,r,o,a,s,l,u)=>{let p;n.save(),n.beginPath(),(0,i.setCanvasLineDash)(n,t);for(const t of e){if("move"===t.type)n.moveTo(t.to.x,t.to.y);else if("line"===t.type)n.lineTo(t.to.x,t.to.y);else if("arc"===t.type)n.arcTo(t.from.x,t.from.y,t.to.x,t.to.y,t.radius);else if("ellipseArc"===t.type){if(p){const e=(0,c.getEllipseArcByStartEnd)(p,t.rx,t.ry,t.angle,t.largeArc,t.sweep,t.to);e&&n.ellipse(e.cx,e.cy,e.rx,e.ry,(0,d.angleToRadian)(e.angle),(0,d.angleToRadian)(e.startAngle),(0,d.angleToRadian)(e.endAngle),e.counterclockwise)}}else"bezierCurve"===t.type?n.bezierCurveTo(t.cp1.x,t.cp1.y,t.cp2.x,t.cp2.y,t.to.x,t.to.y):"quadraticCurve"===t.type?n.quadraticCurveTo(t.cp.x,t.cp.y,t.to.x,t.to.y):"close"===t.type&&n.closePath();"close"!==t.type&&(p=t.to)}(null==t?void 0:t.closed)&&n.closePath(),P(n,r,o,a,s,l,u,t),w(n,r,o,a,s,l,u,t),n.restore()},renderText:(e,t,n,r,o,a,s)=>(l,c,d,p,f,h,g)=>{var m,y,v,x;l.save(),l.font=`${null!=(m=null==s?void 0:s.fontWeight)?m:"normal"} ${null!=(y=null==s?void 0:s.fontStyle)?y:"normal"} ${o}px ${a}`,l.textAlign=null!=(v=null==s?void 0:s.textAlign)?v:"left",l.textBaseline=null!=(x=null==s?void 0:s.textBaseline)?x:"alphabetic",w(l,c,d,p,f,h,g,C(b({},s),{fillColor:"number"==typeof r?r:void 0,fillPattern:void 0!==r&&"number"!=typeof r?r:void 0}),(()=>l.fillText(n,e,t))),(void 0!==(null==s?void 0:s.strokeColor)||(null==s?void 0:s.strokePattern)||(null==s?void 0:s.strokeLinearGradient)||(null==s?void 0:s.strokeRadialGradient))&&(void 0!==(null==s?void 0:s.strokeColor)?l.strokeStyle=(0,u.getColorString)(s.strokeColor,s.strokeOpacity):_(l,c,d,p,f,h,g,s),void 0!==s.strokeWidth&&(l.lineWidth=s.strokeWidth),(0,i.setCanvasLineDash)(l,s),l.strokeText(n,e,t)),l.restore()},renderImage:(e,t,n,r,o,i)=>(s,l,c)=>{const u=(0,a.getImageFromCache)(e,{rerender:c,crossOrigin:null==i?void 0:i.crossOrigin});if(u){const e=s.globalAlpha;s.save(),void 0!==(null==i?void 0:i.opacity)&&(s.globalAlpha=e*i.opacity),function(e,t){if(t&&t.length>0){const n=[];t.forEach((e=>{"hue-rotate"===e.type?n.push(`hue-rotate(${e.value}deg)`):"blur"===e.type?n.push(`blur(${e.value}px)`):"brightness"!==e.type&&"contrast"!==e.type&&"saturate"!==e.type&&"grayscale"!==e.type&&"invert"!==e.type&&"opacity"!==e.type&&"sepia"!==e.type||n.push(`${e.type}(${e.value})`)})),e.filter=n.join(" ")}}(s,null==i?void 0:i.filters),s.drawImage(u,t,n,r,o),s.restore()}},renderPath:(e,t)=>(n,r,o,a,s,l,c)=>{n.save(),n.beginPath(),(0,i.setCanvasLineDash)(n,t);for(const t of e)for(let e=0;e{const p=(0,l.getRayTransformedLineSegment)({x:e,y:t,angle:n,bidirectional:null==r?void 0:r.bidirectional},s,c,u,d);p&&this.renderPath([p],r)(o,i,a,s,c,u,d)}}};function P(e,t,n,r,o,i,a,s){var l,c,d,f,h;const g=(null!=(l=null==s?void 0:s.strokeWidth)?l:1)/t;g&&(e.lineWidth=g,e.strokeStyle=(0,u.getColorString)(null!=(c=null==s?void 0:s.strokeColor)?c:0,null==s?void 0:s.strokeOpacity),e.miterLimit=null!=(d=null==s?void 0:s.miterLimit)?d:p.defaultMiterLimit,e.lineJoin=null!=(f=null==s?void 0:s.lineJoin)?f:p.defaultLineJoin,e.lineCap=null!=(h=null==s?void 0:s.lineCap)?h:p.defaultLineCap,_(e,t,n,r,o,i,a,s),e.stroke())}function k(e,t,n,r,o,i,a,s){const l=document.createElement("canvas");l.width=t.width,l.height=t.height;const c=l.getContext("2d");if(c){t.pattern()(c,n,r,o,i,a,s);const u=e.createPattern(l,null);if(u)return u}}function w(e,t,n,r,o,i,a,s,l){if(void 0!==(null==s?void 0:s.clip)&&(e.clip("evenodd"),s.clip()(e,t,n,r,o,i,a)),void 0!==(null==s?void 0:s.fillColor)||void 0!==(null==s?void 0:s.fillPattern)||void 0!==(null==s?void 0:s.fillLinearGradient)||void 0!==(null==s?void 0:s.fillRadialGradient)){if(void 0!==s.fillPattern){const l=k(e,s.fillPattern,t,n,r,o,i,a);l&&(e.fillStyle=l)}else if(void 0!==s.fillColor)e.fillStyle=(0,u.getColorString)(s.fillColor,s.fillOpacity);else if(void 0!==s.fillLinearGradient){const{start:t,end:n,stops:r}=s.fillLinearGradient,o=e.createLinearGradient(t.x,t.y,n.x,n.y);r.forEach((e=>{o.addColorStop(e.offset,(0,u.getColorString)(e.color,e.opacity))})),e.fillStyle=o}else if(void 0!==s.fillRadialGradient){const{start:t,end:n,stops:r}=s.fillRadialGradient,o=e.createRadialGradient(t.x,t.y,t.r,n.x,n.y,n.r);r.forEach((e=>{o.addColorStop(e.offset,(0,u.getColorString)(e.color,e.opacity))})),e.fillStyle=o}l?l():e.fill("evenodd")}}function _(e,t,n,r,o,i,a,s){if(null==s?void 0:s.strokePattern){const l=k(e,s.strokePattern,t,n,r,o,i,a);l&&(e.strokeStyle=l)}else if(void 0!==(null==s?void 0:s.strokeLinearGradient)){const{start:t,end:n,stops:r}=s.strokeLinearGradient,o=e.createLinearGradient(t.x,t.y,n.x,n.y);r.forEach((e=>{o.addColorStop(e.offset,(0,u.getColorString)(e.color,e.opacity))})),e.strokeStyle=o}else if(void 0!==(null==s?void 0:s.strokeRadialGradient)){const{start:t,end:n,stops:r}=s.strokeRadialGradient,o=e.createRadialGradient(t.x,t.y,t.r,n.x,n.y,n.r);r.forEach((e=>{o.addColorStop(e.offset,(0,u.getColorString)(e.color,e.opacity))})),e.strokeStyle=o}}function S(e){const t=r.useRef(null),[n,o]=r.useState(0);return r.useEffect((()=>{t.current&&(t.current.width=e.width,t.current.height=e.height)}),[e.width,e.height]),r.useEffect((()=>{var n,r,i;if(t.current){const a=t.current.getContext("2d");if(a){const t=Date.now();a.fillStyle=(0,u.getColorString)(null!=(n=e.backgroundColor)?n:16777215),a.fillRect(0,0,a.canvas.width,a.canvas.height),a.save(),e.transform&&(a.translate(e.width/2,e.height/2),a.scale(e.transform.scale,e.transform.scale),a.translate(e.transform.x/e.transform.scale-e.width/2,e.transform.y/e.transform.scale-e.height/2),e.transform.rotate&&a.rotate(e.transform.rotate));const s=()=>o((e=>e+1)),l=e.strokeWidthFixed&&(null==(r=e.transform)?void 0:r.scale)?e.transform.scale:1;for(const t of e.draws)t(a,l,s,e.width,e.height,e.transform);a.restore(),e.debug&&console.info(Date.now()-t),null==(i=e.onRender)||i.call(e)}}}),[e.draws,t.current,e.transform,e.backgroundColor,n,e.width,e.height,e.onRender]),r.createElement("canvas",b({ref:t,width:e.width,height:e.height},e.attributes))}},8012:(e,t,n)=>{"use strict";n.r(t),n.d(t,{renderPartStyledPolyline:()=>p});var r=Object.defineProperty,o=Object.defineProperties,i=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(e,n,t[n]);return e},d=(e,t)=>o(e,i(t));function p(e,t,n,r){return e.renderGroup([e.renderPolyline(n,d(u({},r),{skippedLines:t.map((e=>e.index))})),...t.map((({index:t,color:o,opacity:i})=>e.renderPolyline([n[t],n[t+1]],d(u({},r),{strokeColor:o,strokeOpacity:i}))))])}},9289:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ellipsePolarToCartesian:()=>M,getRotateTransform:()=>I,getScaleTransform:()=>L,polarToCartesian:()=>T,reactSvgRenderTarget:()=>k});var r=n(3696),o=n(3975),i=n(2792),a=n(8831),s=n(1796),l=n(5147),c=n(7713),u=n(8012),d=n(1715),p=n(491),f=n(8392),h=n(3793),g=Object.defineProperty,m=Object.defineProperties,y=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable,C=(e,t,n)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||(t={}))x.call(t,n)&&C(e,n,t[n]);if(v)for(var n of v(t))b.call(t,n)&&C(e,n,t[n]);return e},P=(e,t)=>m(e,y(t));const k={type:"svg",renderResult(e,t,n,i){var a,s,l,c,u,d,p,f,h,g;const m=null!=(s=null==(a=null==i?void 0:i.transform)?void 0:a.x)?s:0,y=null!=(c=null==(l=null==i?void 0:i.transform)?void 0:l.y)?c:0,v=null!=(d=null==(u=null==i?void 0:i.transform)?void 0:u.scale)?d:1,x=t/v,b=n/v,C=(t-x)/2-m/v,k=(n-b)/2-y/v,w=null!=(p=null==i?void 0:i.strokeWidthFixed)&&p,_=null!=(h=null==(f=null==i?void 0:i.transform)?void 0:f.rotate)?h:0;return r.createElement("svg",P(E({version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:`${C} ${k} ${x} ${b}`,width:t,height:n,colorInterpolationFilters:"sRGB"},null==i?void 0:i.attributes),{style:P(E({},null==(g=null==i?void 0:i.attributes)?void 0:g.style),{backgroundColor:void 0!==(null==i?void 0:i.backgroundColor)?(0,o.getColorString)(i.backgroundColor):void 0})}),r.createElement("g",{style:{rotate:`${_}rad`}},e.map(((e,r)=>e(r,v,w,t,n,null==i?void 0:i.transform)))))},renderEmpty:()=>()=>r.createElement(r.Fragment,null),renderGroup(e,t){const n=[];if((null==t?void 0:t.translate)&&n.push(`translate(${t.translate.x}, ${t.translate.y})`),null==t?void 0:t.base){const e=I(t.base.x,t.base.y,t);e&&n.push(e);const r=L(t.base.x,t.base.y,t);r&&n.push(r)}return(null==t?void 0:t.matrix)&&n.push(`matrix(${l.m3.getTransform(t.matrix).join(" ")})`),(o,i,a,s,c,u,d)=>{const p=(0,l.multiplyMatrix)(d,(0,l.getRenderOptionsMatrix)(t));return r.createElement("g",{transform:n.join(" "),key:o,opacity:null==t?void 0:t.opacity},e.map(((e,t)=>e(t,i,a,s,c,u,p))))}},renderRect:(e,t,n,o,i)=>w(((a,s,l,c)=>r.createElement("rect",P(E({x:e,y:t,width:n,height:o},R(l,c,i)),{fill:a,stroke:s,transform:I(e+n/2,t+o/2,i)}))),i),renderPolyline(e,t){const n=null!=t?t:{},{partsStyles:o}=n,i=((e,t)=>{var n={};for(var r in e)x.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&v)for(var r of v(e))t.indexOf(r)<0&&b.call(e,r)&&(n[r]=e[r]);return n})(n,["partsStyles"]);if(o&&o.length>0)return(0,u.renderPartStyledPolyline)(this,o,e,i);const a=null==t?void 0:t.skippedLines;if(a&&a.length>0){const n=e.map(((e,t)=>0===t||a.includes(t-1)?`M ${e.x} ${e.y}`:`L ${e.x} ${e.y}`)).join(" ");return w(((e,o,i,a)=>r.createElement("path",P(E({d:n},R(i,a,t)),{fill:e,stroke:o}))),t)}const s=e.map((e=>`${e.x},${e.y}`)).join(" ");return w(((e,n,o,i)=>r.createElement((null==t?void 0:t.closed)?"polygon":"polyline",P(E({points:s},R(o,i,t)),{fill:e,stroke:n}))),t)},renderPolygon(e,t){return this.renderPolyline(e,P(E({},t),{closed:!0}))},renderCircle:(e,t,n,o)=>w(((i,a,s,l)=>r.createElement("circle",P(E({cx:e,cy:t,r:n},R(s,l,o)),{fill:i,stroke:a}))),o),renderEllipse:(e,t,n,o,i)=>w(((a,s,l,c)=>r.createElement("ellipse",P(E({cx:e,cy:t,rx:n,ry:o},R(l,c,i)),{fill:a,stroke:s,transform:I(e,t,i)}))),i),renderArc(e,t,n,o,s,l){if(null==l?void 0:l.counterclockwise){if((0,i.largerOrEqual)(o-s,360))return this.renderCircle(e,t,n,l)}else if((0,i.largerOrEqual)(s-o,360))return this.renderCircle(e,t,n,l);const c=T(e,t,n,s),u=T(e,t,n,o),d=(0,a.getLargeArc)({startAngle:o,endAngle:s,counterclockwise:null==l?void 0:l.counterclockwise})?"1":"0",p=(null==l?void 0:l.counterclockwise)?"1":"0";return w(((e,t,o,i)=>r.createElement("path",P(E({d:`M ${c.x} ${c.y} A ${n} ${n} 0 ${d} ${p} ${u.x} ${u.y}${(null==l?void 0:l.closed)?" Z":""}`},R(o,i,l)),{fill:e,stroke:t}))),l)},renderEllipseArc(e,t,n,o,s,l,c){if(null==c?void 0:c.counterclockwise){if((0,i.largerOrEqual)(s-l,360))return this.renderEllipse(e,t,n,o,c)}else if((0,i.largerOrEqual)(l-s,360))return this.renderEllipse(e,t,n,o,c);const u=M(e,t,n,o,l),d=M(e,t,n,o,s),p=(0,a.getLargeArc)({startAngle:s,endAngle:l,counterclockwise:null==c?void 0:c.counterclockwise})?"1":"0",f=(null==c?void 0:c.counterclockwise)?"1":"0";return w(((i,a,s,l)=>r.createElement("path",P(E({d:`M ${u.x} ${u.y} A ${n} ${o} 0 ${p} ${f} ${d.x} ${d.y}${(null==c?void 0:c.closed)?" Z":""}`},R(s,l,c)),{fill:i,stroke:a,transform:I(e,t,c)}))),c)},renderPathCommands(e,t){let n,o="";for(const t of e)if("move"===t.type)o+=` M ${t.to.x} ${t.to.y}`,n=t.to;else if("line"===t.type)o+=` L ${t.to.x} ${t.to.y}`,n=t.to;else if("arc"===t.type){if(n){const e=t.from,r=t.to,a=(0,s.twoPointLineToGeneralFormLine)(n,e),l=(0,s.twoPointLineToGeneralFormLine)(e,r),c=a?(0,s.getPointSideOfLine)(r,a):0;if(!(0,i.isZero)(c)&&a&&l){const e=c<0?0:1,r=(0,p.getTwoGeneralFormLinesIntersectionPoint)((0,s.getParallelLinesByDistance)(a,t.radius)[e],(0,s.getParallelLinesByDistance)(l,t.radius)[e]);if(r){const e=(0,f.getPerpendicularPoint)(r,a),i=(0,f.getPerpendicularPoint)(r,l);o+=` L ${e.x} ${e.y} A ${t.radius} ${t.radius} 0 0 ${c<0?1:0} ${i.x} ${i.y}`,n=i}}else o+=` L ${r.x} ${r.y}`,n=r}}else"ellipseArc"===t.type?(o+=` A ${t.rx} ${t.ry} ${t.angle} ${t.largeArc?1:0} ${t.sweep?1:0} ${t.to.x} ${t.to.y}`,n=t.to):"bezierCurve"===t.type?(o+=` C ${t.cp1.x} ${t.cp1.y}, ${t.cp2.x} ${t.cp2.y}, ${t.to.x} ${t.to.y}`,n=t.to):"quadraticCurve"===t.type?(o+=` Q ${t.cp.x} ${t.cp.y}, ${t.to.x} ${t.to.y}`,n=t.to):"close"===t.type&&(o+=" Z");return(null==t?void 0:t.closed)&&(o+=" Z"),w(((e,n,i,a)=>r.createElement("path",P(E({d:o},R(i,a,t)),{fill:e,stroke:n}))),t)},renderText:(e,t,n,o,i,a,s)=>w(((o,l,c,u)=>{var d;return r.createElement("text",{x:e,y:t,textAnchor:"center"===(null==s?void 0:s.textAlign)?"middle":"right"===(null==s?void 0:s.textAlign)?"end":"start",alignmentBaseline:"top"===(null==s?void 0:s.textBaseline)?"before-edge":"bottom"===(null==s?void 0:s.textBaseline)?"after-edge":null!=(d=null==s?void 0:s.textBaseline)?d:"alphabetic",style:{fill:o,fontWeight:null==s?void 0:s.fontWeight,fontSize:`${i}px`,fontStyle:null==s?void 0:s.fontStyle,fontFamily:a,strokeWidth:null==s?void 0:s.strokeWidth,stroke:l,strokeDasharray:A(c,u,s),strokeDashoffset:null==s?void 0:s.dashOffset,fillOpacity:null==s?void 0:s.fillOpacity,strokeOpacity:null==s?void 0:s.strokeOpacity}},n)}),P(E({},s),{fillColor:"number"==typeof o?o:void 0,fillPattern:void 0!==o&&"number"!=typeof o?o:void 0}),!0),renderImage(e,t,n,o,i,a){return s=s=>r.createElement("image",{filter:s,href:e,x:t,y:n,width:o,height:i,preserveAspectRatio:"none",crossOrigin:null==a?void 0:a.crossOrigin,opacity:null==a?void 0:a.opacity}),l=null==a?void 0:a.filters,e=>{let t,n;if(l&&l.length>0){const e=S(l),o=[];l.forEach(((e,t)=>{if("brightness"===e.type)o.push(r.createElement("feComponentTransfer",{key:t},r.createElement("feFuncR",{type:"linear",slope:e.value}),r.createElement("feFuncG",{type:"linear",slope:e.value}),r.createElement("feFuncB",{type:"linear",slope:e.value})));else if("contrast"===e.type){const n=.5*(1-e.value);o.push(r.createElement("feComponentTransfer",{key:t},r.createElement("feFuncR",{type:"linear",slope:e.value,intercept:n}),r.createElement("feFuncG",{type:"linear",slope:e.value,intercept:n}),r.createElement("feFuncB",{type:"linear",slope:e.value,intercept:n})))}else if("hue-rotate"===e.type)o.push(r.createElement("feColorMatrix",{key:t,type:"hueRotate",values:e.value.toString()}));else if("saturate"===e.type)o.push(r.createElement("feColorMatrix",{key:t,type:"saturate",values:e.value.toString()}));else if("grayscale"===e.type){const n=1-e.value;o.push(r.createElement("feColorMatrix",{key:t,type:"matrix",values:`\n ${.2126+.7874*n} ${.7152-.7152*n} ${.0722-.0722*n} 0 0\n ${.2126-.2126*n} ${.7152+.2848*n} ${.0722-.0722*n} 0 0\n ${.2126-.2126*n} ${.7152-.7152*n} ${.0722+.9278*n} 0 0\n 0 0 0 1 0`}))}else if("invert"===e.type){const n=`${e.value} ${1-e.value}`;o.push(r.createElement("feComponentTransfer",{key:t},r.createElement("feFuncR",{type:"table",tableValues:n}),r.createElement("feFuncG",{type:"table",tableValues:n}),r.createElement("feFuncB",{type:"table",tableValues:n})))}else if("sepia"===e.type){const n=1-e.value;o.push(r.createElement("feColorMatrix",{key:t,type:"matrix",values:`\n ${.393+.607*n} ${.769-.769*n} ${.189-.189*n} 0 0\n ${.349-.349*n} ${.686+.314*n} ${.168-.168*n} 0 0\n ${.272-.272*n} ${.534-.534*n} ${.131+.869*n} 0 0\n 0 0 0 1 0`}))}else"opacity"===e.type?o.push(r.createElement("feComponentTransfer",{key:t},r.createElement("feFuncA",{type:"table",tableValues:`0 ${e.value}`}))):"blur"===e.type&&o.push(r.createElement("feGaussianBlur",{key:t,in:"SourceGraphic",stdDeviation:e.value}))})),t=r.createElement("filter",{id:e},o),n=`url(#${e})`}return r.createElement(r.Fragment,{key:e},t,s(n))};var s,l},renderPath(e,t){const n=e.map((e=>e.map(((e,t)=>0===t?`M ${e.x} ${e.y}`:`L ${e.x} ${e.y}`)).join(" "))),o=(null==t?void 0:t.clip)&&n.length>1,i=o?n.slice(1).map(((e,t)=>r.createElement("path",{key:t,d:e,fill:"black"}))):void 0;return w(((e,i,a,s)=>{let l;return o?l=n[0]:(l=n.join(" "),(null==t?void 0:t.closed)&&(l+=" Z")),r.createElement("path",P(E({d:l},R(a,s,t)),{fill:e,stroke:i,fillRule:"evenodd"}))}),t,void 0,i)},renderRay:(e,t,n,o)=>w(((i,a,l,c,u,d,p,f)=>{const h=(0,s.getRayTransformedLineSegment)({x:e,y:t,angle:n,bidirectional:null==o?void 0:o.bidirectional},u,d,p,f);return h?r.createElement("line",P(E({x1:h[0].x,y1:h[0].y,x2:h[1].x,y2:h[1].y},R(l,c,o)),{fill:i,stroke:a})):r.createElement(r.Fragment,null)}),o)};function w(e,t,n,i){return(a,s,l,c,u,d,p)=>{let f,h,g,m=void 0!==(null==t?void 0:t.fillColor)?(0,o.getColorString)(t.fillColor):"none",y=void 0!==(null==t?void 0:t.strokeColor)?(0,o.getColorString)(t.strokeColor):n?void 0:(0,o.getColorString)(0);if(null==t?void 0:t.strokePattern){const e=S(t.strokePattern);h=r.createElement("pattern",{id:e,patternUnits:"userSpaceOnUse",patternTransform:O(t),width:t.strokePattern.width,height:t.strokePattern.height},t.strokePattern.pattern()(e,s,!1,c,u,d,p)),y=`url(#${e})`}else if(null==t?void 0:t.strokeLinearGradient){const e=S(t.strokeLinearGradient);h=r.createElement("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:t.strokeLinearGradient.start.x,y1:t.strokeLinearGradient.start.y,x2:t.strokeLinearGradient.end.x,y2:t.strokeLinearGradient.end.y},t.strokeLinearGradient.stops.map((e=>r.createElement("stop",{key:e.offset,offset:e.offset,stopColor:(0,o.getColorString)(e.color,e.opacity)})))),y=`url(#${e})`}else if(null==t?void 0:t.strokeRadialGradient){const e=S(t.strokeRadialGradient);h=r.createElement("radialGradient",{id:e,gradientUnits:"userSpaceOnUse",fx:t.strokeRadialGradient.start.x,fy:t.strokeRadialGradient.start.y,fr:t.strokeRadialGradient.start.r,cx:t.strokeRadialGradient.end.x,cy:t.strokeRadialGradient.end.y,r:t.strokeRadialGradient.end.r},t.strokeRadialGradient.stops.map((e=>r.createElement("stop",{key:e.offset,offset:e.offset,stopColor:(0,o.getColorString)(e.color,e.opacity)})))),y=`url(#${e})`}if(null==t?void 0:t.fillPattern){const e=S(t.fillPattern);f=r.createElement("pattern",{id:e,patternUnits:"userSpaceOnUse",patternTransform:O(t),width:t.fillPattern.width,height:t.fillPattern.height},t.fillPattern.pattern()(e,s,!1,c,u,d,p)),m=`url(#${e})`}else if(null==t?void 0:t.fillLinearGradient){const e=S(t.fillLinearGradient);f=r.createElement("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:t.fillLinearGradient.start.x,y1:t.fillLinearGradient.start.y,x2:t.fillLinearGradient.end.x,y2:t.fillLinearGradient.end.y},t.fillLinearGradient.stops.map((e=>r.createElement("stop",{key:e.offset,offset:e.offset,stopColor:(0,o.getColorString)(e.color,e.opacity)})))),m=`url(#${e})`}else if(null==t?void 0:t.fillRadialGradient){const e=S(t.fillRadialGradient);f=r.createElement("radialGradient",{id:e,gradientUnits:"userSpaceOnUse",fx:t.fillRadialGradient.start.x,fy:t.fillRadialGradient.start.y,fr:t.fillRadialGradient.start.r,cx:t.fillRadialGradient.end.x,cy:t.fillRadialGradient.end.y,r:t.fillRadialGradient.end.r},t.fillRadialGradient.stops.map((e=>r.createElement("stop",{key:e.offset,offset:e.offset,stopColor:(0,o.getColorString)(e.color,e.opacity)})))),m=`url(#${e})`}const v=e(m,y,s,l,c,u,d,p);if(null==t?void 0:t.clip){const n=S(t.clip),o=t.clip()(n,s,l,c,u,d,p);i?(f=r.createElement(r.Fragment,null,r.createElement("mask",{id:n},e("white",y,s,l,c,u,d,p),i),v),g=r.createElement("g",{mask:`url(#${n})`},o)):(f=r.createElement(r.Fragment,null,r.createElement("clipPath",{id:n},v),v),g=r.createElement("g",{clipPath:`url(#${n})`},o))}else g=v;return r.createElement(r.Fragment,{key:a},f,h,g)}}const _=new c.WeakmapCache;function S(e){return _.get(e,(()=>Math.random().toString()))}function R(e,t,n){var r,o,i,a;return{strokeWidth:null!=(r=null==n?void 0:n.strokeWidth)?r:1,vectorEffect:t?"non-scaling-stroke":void 0,strokeDasharray:A(e,t,n),strokeDashoffset:null==n?void 0:n.dashOffset,strokeMiterlimit:null!=(o=null==n?void 0:n.miterLimit)?o:h.defaultMiterLimit,strokeLinejoin:null!=(i=null==n?void 0:n.lineJoin)?i:h.defaultLineJoin,strokeLinecap:null!=(a=null==n?void 0:n.lineCap)?a:h.defaultLineCap,fillOpacity:null==n?void 0:n.fillOpacity,strokeOpacity:null==n?void 0:n.strokeOpacity}}function A(e,t,n){if((null==n?void 0:n.dashArray)&&n.dashArray.length>0)return n.dashArray.map((n=>n*(t?e:1))).join(" ")}function T(e,t,n,r){return M(e,t,n,n,r)}function M(e,t,n,r,o){const i=(0,d.angleToRadian)(o);return{x:e+n*Math.cos(i),y:t+r*Math.sin(i)}}function L(e,t,n){const r=(0,l.getScaleOptionsScale)(n);if(r)return`translate(${e},${t}) scale(${r.x},${r.y}) translate(${-e},${-t})`}function I(e,t,n){const r=(0,l.getRotationOptionsAngle)(n);if(r)return`rotate(${r},${e},${t})`}function O(e){const t=(0,l.getRotationOptionsAngle)(e);if(t)return`rotate(${-t})`}},7428:(e,t,n)=>{"use strict";n.r(t),n.d(t,{reactWebglRenderTarget:()=>w});var r=n(3696),o=n(5773),i=n(1796),a=n(2318),s=n(2298),l=n(8012),c=n(1401),u=n(3876),d=n(5147),p=n(3975),f=n(1715),h=n(2792),g=Object.defineProperty,m=Object.defineProperties,y=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable,C=(e,t,n)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||(t={}))x.call(t,n)&&C(e,n,t[n]);if(v)for(var n of v(t))b.call(t,n)&&C(e,n,t[n]);return e},P=(e,t)=>m(e,y(t)),k=(e,t)=>{var n={};for(var r in e)x.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&v)for(var r of v(e))t.indexOf(r)<0&&b.call(e,r)&&(n[r]=e[r]);return n};const w={type:"webgl",renderResult:(e,t,n,o)=>r.createElement(_,{width:t,height:n,attributes:null==o?void 0:o.attributes,graphics:e,transform:null==o?void 0:o.transform,backgroundColor:null==o?void 0:o.backgroundColor,debug:null==o?void 0:o.debug,strokeWidthFixed:null==o?void 0:o.strokeWidthFixed}),renderEmpty:()=>()=>[],renderGroup:(e,t)=>(n,r,o,i,a,s,l)=>{const c=(0,d.getRenderOptionsMatrix)(t),u=(0,d.multiplyMatrix)(s,c);return l=(0,h.multiplyOpacity)(l,null==t?void 0:t.opacity),e.map((e=>e(n,r,o,i,a,u))).flat().map((e=>P(E({},e),{matrix:(0,d.multiplyMatrix)(c,e.matrix),opacity:(0,h.multiplyOpacity)(l,e.opacity)})))},renderRect(e,t,n,r,i){let a=[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r}],s=0;if((null==i?void 0:i.angle)?s=(0,f.angleToRadian)(i.angle):(null==i?void 0:i.rotation)&&(s=i.rotation),s){const i={x:e+n/2,y:t+r/2};a=a.map((e=>(0,o.rotatePosition)(e,i,s)))}return this.renderPolygon(a,i)},renderPolyline(e,t){const n=null!=t?t:{},{partsStyles:r}=n,o=k(n,["partsStyles"]);if(r&&r.length>0)return(0,l.renderPartStyledPolyline)(this,r,e,o);const a=null!=t?t:{},{dashArray:s,closed:c}=a,u=k(a,["dashArray","closed"]);c&&(e=(0,i.polygonToPolyline)(e));const d=(0,i.dashedPolylineToLines)(e,s,null==t?void 0:t.skippedLines,null==t?void 0:t.dashOffset);return this.renderPath(d,u)},renderPolygon(e,t){return this.renderPolyline(e,P(E({},t),{closed:!0}))},renderCircle(e,t,n,r){const o=(0,a.arcToPolyline)((0,a.circleToArc)({x:e,y:t,r:n}),5);return this.renderPolyline(o,r)},renderEllipse(e,t,n,r,o){let i=0;(null==o?void 0:o.angle)?i=o.angle:(null==o?void 0:o.rotation)&&(i=(0,f.radianToAngle)(o.rotation));const a=(0,s.ellipseToPolygon)({cx:e,cy:t,rx:n,ry:r,angle:i},5);return this.renderPolygon(a,o)},renderArc(e,t,n,r,o,i){const s=(0,a.arcToPolyline)({x:e,y:t,r:n,startAngle:r,endAngle:o,counterclockwise:null==i?void 0:i.counterclockwise},5);return this.renderPolyline(s,i)},renderEllipseArc(e,t,n,r,o,i,a){let l=0;(null==a?void 0:a.angle)?l=a.angle:(null==a?void 0:a.rotation)&&(l=(0,f.radianToAngle)(a.rotation));const c=(0,s.ellipseArcToPolyline)({cx:e,cy:t,rx:n,ry:r,startAngle:o,endAngle:i,angle:l,counterclockwise:null==a?void 0:a.counterclockwise},5);return this.renderPolyline(c,a)},renderPathCommands(e,t){const n=(0,c.getPathCommandsPoints)(e),r=(0,c.pathCommandPointsToPath)(n);return this.renderGroup(r.map((e=>this.renderPath(e,t))))},renderText:(e,t,n,r,o,i,a)=>(s,l,c,d,p)=>{let f,h;f=void 0!==r&&"number"!=typeof r?{graphics:r.pattern()(s,l,c,d,p),width:r.width,height:r.height}:r,void 0!==(null==a?void 0:a.strokePattern)&&(h={graphics:a.strokePattern.pattern()(s,l,c,d,p),width:a.strokePattern.width,height:a.strokePattern.height});const g=(0,u.getTextGraphic)(e,t,n,f,o,i,P(E({},a),{strokePattern:h}));return g?[g]:[]},renderImage:(e,t,n,r,o,i)=>(a,s)=>{const l=(0,u.getImageGraphic)(e,t,n,r,o,s,i);return l?[l]:[]},renderPath:(e,t)=>(n,r,o,i,a)=>{let s,l;return void 0!==(null==t?void 0:t.clip)&&(s={graphics:t.clip()(n,r,o,i,a)}),void 0!==(null==t?void 0:t.fillPattern)&&(s={graphics:t.fillPattern.pattern()(n,r,o,i,a),width:t.fillPattern.width,height:t.fillPattern.height}),void 0!==(null==t?void 0:t.strokePattern)&&(l={graphics:t.strokePattern.pattern()(n,r,o,i,a),width:t.strokePattern.width,height:t.strokePattern.height}),(0,u.getPathGraphics)(e,n,P(E({},t),{fillPattern:s,strokePattern:l}))},renderRay(e,t,n,r){return(o,a,s,l,c,u)=>{const d=(0,i.getRayTransformedLineSegment)({x:e,y:t,angle:n,bidirectional:null==r?void 0:r.bidirectional},s,l,c,u);return d?this.renderPath([d],r)(o,a,s,l,c):[]}}};function _(e){const t=r.useRef(null),[n,o]=r.useState(0),i=r.useRef();return r.useEffect((()=>{t.current&&(t.current.width=e.width,t.current.height=e.height)}),[e.width,e.height]),r.useEffect((()=>{if(!t.current)return;const n=(0,u.createWebglRenderer)(t.current);if(!n)return;const r=()=>o((e=>e+1));i.current=(t,o,i,a,s,l,c,u,d)=>{const p=performance.now();n(t.map((e=>e(l,r,c,u,d))).flat(),o,i,a,s,null==d?void 0:d.rotate),e.debug&&console.info(Math.round(performance.now()-p))}}),[t.current,e.debug]),r.useEffect((()=>{var t,n,r,o,a,s,l,c,u;if(i.current){const d=null!=(n=null==(t=e.transform)?void 0:t.x)?n:0,f=null!=(o=null==(r=e.transform)?void 0:r.y)?o:0,h=null!=(s=null==(a=e.transform)?void 0:a.scale)?s:1,g=(0,p.colorNumberToRec)(null!=(l=e.backgroundColor)?l:16777215),m=null!=(c=e.strokeWidthFixed)&&c;i.current(e.graphics,g,d,f,h,m,e.width,e.height,e.transform),null==(u=e.onRender)||u.call(e)}}),[e.graphics,e.backgroundColor,i.current,e.transform,n,e.width,e.height,e.onRender]),r.createElement("canvas",E({ref:t,width:e.width,height:e.height},e.attributes))}},7529:(e,t,n)=>{"use strict";n.r(t),n.d(t,{WebgpuDrawCanvas:()=>m,reactWebgpuRenderTarget:()=>g});var r=n(3696),o=n(3975),i=n(7191),a=n(7428),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e};const g=l(h({},a.reactWebglRenderTarget),c({type:"webgpu",renderResult:(e,t,n,o)=>r.createElement(m,{width:t,height:n,attributes:null==o?void 0:o.attributes,graphics:e,transform:null==o?void 0:o.transform,backgroundColor:null==o?void 0:o.backgroundColor,debug:null==o?void 0:o.debug,strokeWidthFixed:null==o?void 0:o.strokeWidthFixed})}));function m(e){const t=r.useRef(null),[n,a]=r.useState(0),s=r.useRef();return r.useEffect((()=>{t.current&&(t.current.width=e.width,t.current.height=e.height)}),[e.width,e.height]),r.useEffect((()=>{t.current&&(0,i.createWebgpuRenderer)(t.current).then((t=>{if(!t)return;const n=()=>a((e=>e+1));s.current=(r,o,i,a,s,l,c,u,d)=>{const p=performance.now();t(r.map((e=>e(l,n,c,u,d))).flat(),o,i,a,s,null==d?void 0:d.rotate),e.debug&&console.info(Math.round(performance.now()-p))},n()}))}),[t.current,e.debug]),r.useEffect((()=>{var t,n,r,i,a,l,c,u,d;if(s.current){const p=null!=(n=null==(t=e.transform)?void 0:t.x)?n:0,f=null!=(i=null==(r=e.transform)?void 0:r.y)?i:0,h=null!=(l=null==(a=e.transform)?void 0:a.scale)?l:1,g=(0,o.colorNumberToRec)(null!=(c=e.backgroundColor)?c:16777215),m=null!=(u=e.strokeWidthFixed)&&u;s.current(e.graphics,g,p,f,h,m,e.width,e.height,e.transform),null==(d=e.onRender)||d.call(e)}}),[e.graphics,e.backgroundColor,s.current,e.transform,n,e.width,e.height,e.onRender]),r.createElement("canvas",h({ref:t,width:e.width,height:e.height},e.attributes))}},3331:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Scrollbar:()=>d});var r=n(3696),o=n(8907),i=Object.defineProperty,a=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&c(e,n,t[n]);if(a)for(var n of a(t))l.call(t,n)&&c(e,n,t[n]);return e};function d(e){const{type:t,containerSize:n,contentSize:i}=e,{onStart:a,mask:s}=(0,o.useDragMove)(void 0,{transformOffset:({x:r,y:o})=>{const i=Math.max(Math.min("vertical"===t?o:r,n-l),0);return i!==p&&e.onChange((i-c)*d),{x:r,y:o}}});if(n>=i)return null;const l=Math.max(12,i?n*n/i:0),c=(n/2-l/2)*("head"===e.align?0:"tail"===e.align?2:1),d=-(i-n)/(n-l),p=e.value/d+c,f=u({position:"absolute",userSelect:"none"},e.style),h={background:"rgba(0, 0, 0, 0.3)",borderRadius:"4px",position:"absolute",cursor:"grab"};return"vertical"===t?(f.width="8px",f.height=`${n}px`,f.right="0px",f.top="0px",h.width="8px",h.height=`${l}px`,h.top=`${p}px`):(f.height="8px",f.width=`${n}px`,f.left="0px",f.bottom="0px",h.height="8px",h.width=`${l}px`,h.left=`${p}px`),r.createElement("div",{style:f},r.createElement("div",{style:h,onMouseDown:e=>a({x:e.clientX,y:e.clientY},{["vertical"===t?"y":"x"]:p})}),s)}},1121:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useAttributedTextEditor:()=>P});var r=n(3696),o=n(6301),i=n(2792),a=n(6487),s=n(3331),l=n(4399),c=n(135),u=n(623),d=n(9182),p=n(7670),f=n(8905),h=Object.defineProperty,g=Object.defineProperties,m=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,b=(e,t,n)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))v.call(t,n)&&b(e,n,t[n]);if(y)for(var n of y(t))x.call(t,n)&&b(e,n,t[n]);return e},E=(e,t)=>g(e,m(t));function P(e){var t,n;const[h,g]=r.useState(0),[m,y]=r.useState(),v=r.useRef(null),[x,b]=r.useState(0),[P,k]=r.useState(),[w,_]=r.useState(!1),{onComposing:S,getCompositionCountThenEnd:R}=(0,p.useTextComposing)(),A=(t,n)=>{var r,o;if(e.readOnly)return;let i,a,s=P;ie?(a=ie.min,i=M(ie),fe.attributes&&!(null==(r=e.getReadonlyType)?void 0:r.call(e,fe.attributes))&&(s={attributes:fe.attributes,index:ie.min})):n?(a=h-n,i=M({min:h-n,max:h}),fe.attributes&&!(null==(o=e.getReadonlyType)?void 0:o.call(e,fe.attributes))&&(s={attributes:fe.attributes,index:a})):(a=h,i=e.state),g(a+t.length);const l=[];let c=0,u=!1;const d=Q.some((e=>e.min===a)),p=Q.some((e=>e.max===a));for(const e of i){const n=a-c,r=B(e);if(n>=0&&(p?n0&&l.push({attributes:e.attributes,insert:e.insert.slice(0,n)}),l.push({attributes:C(C({},e.attributes),s.attributes),insert:t}),n{if(e.readOnly)return;let o,i;ie?(i=ie.min,o=M(ie)):(i=h,o=e.state),void 0!==r&&(i=r),g(i+n);const a=[];let s=0,l=!1;for(const e of o){const r=i-s,o=B(e);r>=0&&r<=o&&!l?(a.push({attributes:e.attributes,insert:e.insert.slice(0,r)}),a.push(...t),s+=n,a.push({attributes:e.attributes,insert:e.insert.slice(r)}),l=!0):a.push(e),s+=o}l||a.push(...t),e.setState(a)},M=t=>{g(t.min),y(void 0);const n=[];let r=0;for(const o of e.state){const e=t.min-r,i=t.max-r,a=B(o);e<0?i>=a||(i>=0?i0&&n.push({attributes:o.attributes,insert:o.insert.slice(0,e)}),i{if(e.readOnly)return;if(ie)return void e.setState(M(ie));if(0===h)return;const t=Q.find((e=>h===e.max));if(t)return g(t.min),void e.setState(M(t));g(h-1);const n=[];let r=0,o=!1;for(const t of e.state){const e=h-r,i=B(t);e>=0&&e<=i&&!o?(n.push({attributes:t.attributes,insert:t.insert.slice(0,e-1)+t.insert.slice(e)}),o=!0):n.push(t),r+=i}e.setState(n)},I=t=>{const n=[];let r=0;for(const o of e.state){const e=t.min-r,i=t.max-r,a=B(o);e<0?i>=a?n.push(o):i>=0&&i>0&&n.push({attributes:o.attributes,insert:o.insert.slice(0,i)}):e{if(void 0===ie)return;const n=I(ie);return t&&e.setState(M(ie)),n},B=t=>{var n;return!0===(null==(n=e.getReadonlyType)?void 0:n.call(e,t.attributes))?1:t.insert.length},F=e=>{const t=V(j(e)).location,{newSelectionStart:n,newLocation:r}=(0,p.getWordByDoubleClick)(Z,t,(e=>e.insert));void 0!==n&&y(J({location:n},"min")),void 0!==r&&g(J({location:r},"max"))},D=t=>{var n;if(t.nativeEvent.isComposing)S(t,A,L);else if(229!==t.keyCode){if(!(null==(n=e.processInput)?void 0:n.call(e,t))&&!["CapsLock","Tab","Shift","Meta","Escape","Control"].includes(t.key)){if("Backspace"===t.key)return L();if("Delete"===t.key)return(()=>{if(e.readOnly)return;if(ie)return void e.setState(M(ie));if(h===Z.length)return;const t=Q.find((e=>h===e.min));if(t)return void e.setState(M(t));const n=[];let r=0,o=!1;for(const t of e.state){const e=h-r+1,i=B(t);e>=0&&e<=i&&!o?(n.push({attributes:t.attributes,insert:t.insert.slice(0,e-1)+t.insert.slice(e)}),o=!0):n.push(t),r+=i}e.setState(n)})();if("ArrowLeft"===t.key)return((e=!1)=>{if(!e&&ie)return y(void 0),void g(ie.min);0!==h&&(e&&void 0===m&&y(h),g(J({location:h-1},"min")))})(t.shiftKey);if("ArrowRight"===t.key)return((e=!1)=>{if(!e&&ie)return y(void 0),void g(ie.max);h!==Z.length&&(e&&void 0===m&&y(h),g(J({location:h+1},"max")))})(t.shiftKey);if("ArrowUp"===t.key)return((e=!1)=>{if(!e&&ie)return y(void 0),void g(ie.min);e&&void 0===m&&y(h),g(ue{if(!e&&ie)return y(void 0),void g(ie.max);e&&void 0===m&&y(h),de>=ne.length-1?g(Z.length):g(J(V({x:ce,y:ue+ne[de]+ne[de+1]/2+Y},!1),"max"))})(t.shiftKey);if("Enter"===t.key)return A("\n");if((0,u.metaKeyIfMacElseCtrlKey)(t)){if("a"===t.key)return y(0),void g(Z.length);if("v"===t.key)return e.readOnly||navigator.clipboard.readText().then((e=>{if(e){A(e);try{const t=JSON.parse(e);T(t,function(e){let t=0;for(const n of e)t+=n.insert.length;return t}(t))}catch(t){A(e)}}})),void t.preventDefault();if("c"===t.key||"x"===t.key){const e=O("x"===t.key);return void(e&&navigator.clipboard.writeText(JSON.stringify(e)))}}else t.preventDefault(),1===t.key.length&&A(t.key)}}else S(t,A,L)},z=()=>{var t,n;null==(t=e.onLocationChanged)||t.call(e,-1),null==(n=e.onBlur)||n.call(e)},U=r.useRef(),[N,G]=r.useState(),j=e=>{const t=e.target.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},V=(t,n=!0)=>{const r=(0,o.getFlowLayoutLocation)(t,ne,ee,Y,e.getWidth,n);return r?(_(r.lineEnd),r):{location:ee.length-1}},W=t=>{t.preventDefault();const n=j(t),r=J(V(n),"nearest");if(t.shiftKey)(void 0===m||Math.abs(m-r){if(ie)for(let n=ie.min;nr.x&&t.y>r.y&&t.x{if(void 0===U.current)return void(void 0!==N&&G(V(j(t),!1).location));const n=j(t),r=J(V(n,!1),"farthest");g(r),r===U.current?y(void 0):y(U.current),e.autoHeight||(n.y>=0&&n.y<=re?K((e=>X(e+2))):n.y<=e.height&&n.y>=e.height-oe&&K((e=>X(e-2))))},q=e=>{var t;H(e),void 0!==N&&ie&&(Nie.max&&(T(I(ie),ie.size,N-ie.size),y(N-ie.size)),G(void 0)),null==(t=v.current)||t.focus()};(0,c.useGlobalMouseUp)((0,l.useEvent)((()=>{U.current=void 0,G(void 0)})));const{ref:$,y:Y,setY:K,filterY:X}=(0,d.useWheelScroll)({minY:e.autoHeight?0:x>e.height?e.height-x:0,maxY:0,disabled:e.autoHeight});r.useEffect((()=>{e.autoHeight&&K(0)}),[e.autoHeight,K]);const Z=[],Q=[];for(const n of e.state){const r=null==(t=e.getReadonlyType)?void 0:t.call(e,n.attributes);if(r){const e=Z.length,t=Z.length+B(n);if(!0===r){Q.push({min:e,max:t}),Z.push({insert:n.insert,attributes:n.attributes});continue}const o=Q.find((t=>t.type===r&&t.max===e));o?o.max=t:Q.push({min:e,max:t,type:r})}for(const e of n.insert)Z.push({insert:e,attributes:n.attributes})}const J=(e,t)=>{var n;let r;return"farthest"!==t&&"nearest"!==t||(r=e.fromRight?Q.find((t=>!t.type&&e.location===t.min)):Q.find((t=>!t.type&&e.location===t.max))),r||(r=Q.find((t=>e.location>t.min&&e.location(r.max+r.min)/2?r.min:r.max:"nearest"===t?e.location>(r.max+r.min)/2?r.max:r.min:r[t]:e.location},{layoutResult:ee,newContentHeight:te,lineHeights:ne}=(0,o.flowLayout)({state:Z,width:e.width,height:e.autoHeight?void 0:e.height,lineHeight:e.lineHeight,getWidth:e.getWidth,isNewLineContent:e=>"\n"===e.insert,isPartOfComposition:e=>(0,f.isWordCharactor)(e.insert),getComposition:t=>(0,p.getTextComposition)(t,Z,e.getWidth,(e=>e.insert)),endContent:{insert:""},scrollY:Y,align:e.align,verticalAlign:e.verticalAlign});x0&&ee[ae-1];se&&ae--;const le=null!=(n=ee[ae])?n:ee[ee.length-1],ce=le.x+(se?e.getWidth(ee[ae].content):0),ue=le.y-Y,de=le.row,pe=ie?ie.min+1:h;let fe=Z[pe>0?pe-1:pe];P&&!ie&&P.index===h&&(fe=E(C({},fe),{attributes:C(C({},fe.attributes),P.attributes)}));const he=r.useRef(),ge=r.useRef();r.useEffect((()=>{if((0,i.equals)(he.current,h)&&(0,i.equals)(ge.current,ue)||e.autoHeight)return;const t=ue+Y;t<0?K(-ue):t>e.height-oe&&K(e.height-oe-ue),he.current=h,ge.current=ue}),[h,ue,Y,oe]),r.useEffect((()=>{var t;null==(t=e.onLocationChanged)||t.call(e,h)}),[h]),r.useEffect((()=>{P&&h!==(null==P?void 0:P.index)&&k(void 0)}),[h,P,k]);let me=e.height;return e.autoHeight&&x>e.height&&(me=x),{ref:v,range:ie,layoutResult:ee,lineHeights:ne,cursor:{x:ce,y:ue+Y,row:de},inputText:A,inputContent:T,location:h,setLocation:g,getCopiedContents:O,isSelected:e=>ie&&e>=ie.min&&e{var n;if(!ie)return void("function"!=typeof t&&((null==P?void 0:P.index)===h&&(t=C(C({},P.attributes),t)),k({index:h,attributes:t})));const r=e=>"function"==typeof t?t(e):C(C({},e),t),o=[];let i=0;for(const t of e.state){const a=ie.min-i,s=ie.max-i,l=B(t);!0===(null==(n=e.getReadonlyType)?void 0:n.call(e,t.attributes))&&0===a?o.push({attributes:r(t.attributes),insert:t.insert}):a<0?s>=l?o.push({insert:t.insert,attributes:r(t.attributes)}):s>=0?(s>0&&o.push({attributes:r(t.attributes),insert:t.insert.slice(0,s)}),s0&&o.push({attributes:t.attributes,insert:t.insert.slice(0,a)}),o.push({attributes:r(t.attributes),insert:t.insert.slice(a,s)}),sr.createElement("div",{style:C({position:"relative",width:e.width+"px",height:me+"px",border:"1px solid black",clipPath:"inset(0px 0px)"},e.style),onMouseLeave:q,ref:$},r.createElement(a.Cursor,{ref:v,onKeyDown:D,onCompositionEnd:e=>{A(e.data,R()),v.current&&(v.current.value="")},onBlur:z,onFocus:e.onFocus,readOnly:e.readOnly,autoFocus:e.autoFocus,style:{left:ce+"px",top:ue+Y+"px",height:ne[de]+"px"}}),t,r.createElement("div",{onMouseDown:W,onMouseMove:H,onMouseUp:q,onDoubleClick:F,style:{inset:"0px",cursor:"text",position:"absolute"}}),!e.autoHeight&&r.createElement(s.Scrollbar,{value:Y,type:"vertical",containerSize:e.height,contentSize:x,onChange:K,align:"head"}))}}},2087:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useAudioPlayer:()=>i});var r=n(3696),o=n.n(r);function i(e){const[t,n]=o().useState(0),[r,i]=o().useState(0),[a,s]=o().useState(!1),l=o().useRef(null);return{currentTime:t,duration:r,playing:a,play(){l.current&&(l.current.play(),s(!0))},pause(){l.current&&(l.current.pause(),s(!1))},audio:e&&o().createElement("audio",{onTimeUpdate:()=>{l.current&&n(l.current.currentTime)},onEnded:()=>{s(!1)},preload:"auto",onDurationChange:()=>{l.current&&i(l.current.duration)},ref:l,src:e})}}},3274:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useAudioRecorder:()=>a});var r=n(3696),o=n.n(r),i=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{s(n.next(e))}catch(e){o(e)}},a=e=>{try{s(n.throw(e))}catch(e){o(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())}));function a(){const e=o().useRef(),t=o().useRef(),n=o().useRef(),[r,a]=o().useState(),[s,l]=o().useState(0),[c,u]=o().useState(),[d,p]=o().useState(!1),f=o().useRef([]);return{audioUrl:r,duration:s,volume:c,start:()=>i(this,null,(function*(){const r=yield navigator.mediaDevices.getUserMedia({audio:!0});e.current=new MediaRecorder(r),e.current.ondataavailable=e=>{f.current.push(e.data)};const o=new AudioContext,i=o.createMediaStreamSource(r);n.current=o.createAnalyser(),i.connect(n.current);const s=Date.now();t.current=setInterval((()=>{if(l(Date.now()-s),n.current){const e=new Float32Array(n.current.fftSize);n.current.getFloatTimeDomainData(e);let t=0;for(const n of e)t=Math.max(t,Math.abs(n));u(Math.min(2*t,1))}}),20),a(void 0),l(0),f.current=[],p(!0),e.current.start(100)})),stop:()=>{e.current&&(e.current.stop(),e.current.stream.getAudioTracks().forEach((e=>{e.stop()})),t.current&&(clearInterval(t.current),t.current=void 0),u(void 0),p(!1),a(window.URL.createObjectURL(new Blob(f.current,{type:"audio/ogg; codecs=opus"}))))},recording:d,chunks:f.current}}},1749:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCircleArcClickCreate:()=>m});var r=n(3696),o=n(1324),i=n(8638),a=n(5644),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e},g=(e,t)=>l(e,c(t));function m(e,t,n){const[s,l]=r.useState(),[c,u]=r.useState();let d;s&&(d=void 0===c?"specify start angle by click or input angle":"specify end angle by click or input angle");const{circle:p,onClick:f,onMove:m,input:y,setInputPosition:v,startPosition:x,middlePosition:b,cursorPosition:C,setCursorPosition:E,clearText:P}=(0,a.useCircleClickCreate)(e,(e=>l(e?g(h({},e),{startAngle:0,endAngle:0}):void 0)),g(h({},n),{message:d,onKeyDown:s?(e,n)=>{if("Enter"===e.key){let e=+n;isNaN(e)||(void 0===c?(u(e),l(g(h({},s),{startAngle:e,endAngle:e})),P()):(e{u(void 0),E(void 0),l(void 0),P()};return{circle:p,arc:s,startPosition:x,middlePosition:b,cursorPosition:C,onClick(r){if(e)if(s)if(r=(0,i.getAngleSnapPosition)(s,r,null==n?void 0:n.getAngleSnap),void 0===c){const e=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(r,s));u(e),l(g(h({},s),{startAngle:e,endAngle:e}))}else{let e=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(r,s));e{"use strict";n.r(t),n.d(t,{useCircleClickCreate:()=>y});var r=n(3696),o=n(5773),i=n(2318),a=n(8638),s=n(5970),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&h(e,n,t[n]);if(d)for(var n of d(t))f.call(t,n)&&h(e,n,t[n]);return e},m=(e,t)=>c(e,u(t));function y(e,t,n){const[i,l]=r.useState(),[c,u]=r.useState(),[d,p]=r.useState();let f="";e&&(f=c?"3 points"===e?d?"specify third point by click":"specify second point by click":"2 points"===e?"specify second point by click, input position or input length":"specify circle edge point by click, input position or input length":"2 points"===e||"3 points"===e?"specify first point by click or input position":"specify circle center point by click or input position",(null==n?void 0:n.message)&&(f=n.message));const{input:h,setCursorPosition:y,clearText:x,cursorPosition:b,setInputPosition:C,resetInput:E}=(0,s.useCursorInput)(f,"center radius"===e||"center diameter"===e||"2 points"===e?(r,i,a)=>{if(null==n?void 0:n.onKeyDown)n.onKeyDown(r,i,a);else if("Enter"===r.key){const n=i.split(",");if(c){if("2 points"===e&&2===n.length){const e=+n[0],r=+n[1];if(!isNaN(e)&&!isNaN(r)){const n={x:c.x+e/2,y:c.y+r/2};t(m(g({},n),{r:(0,o.getTwoPointsDistance)(n,c)})),P()}return}const r=+i;if(!isNaN(r)&&r>0){let n=c.x,i=c.y;if("2 points"===e){const e=(0,o.getPointByLengthAndDirection)(c,r/2,a);n=e.x,i=e.y}t({x:n,y:i,r:"center diameter"===e||"2 points"===e?r/2:r}),P()}}else if(2===n.length){const t=+n[0],r=+n[1];if(!isNaN(t)&&!isNaN(r)){if(u({x:t,y:r}),e){const n=v(e,{x:t,y:r},void 0,a);n&&l(n)}x()}}}}:void 0),P=()=>{u(void 0),p(void 0),l(void 0),E()};return{circle:i,startPosition:c,middlePosition:d,cursorPosition:b,setCursorPosition:y,setInputPosition:C,clearText:x,onClick(r){if(e)if(y(r),c)if("3 points"!==e||d){const o=v(e,c,d,(0,a.getAngleSnapPosition)(c,r,null==n?void 0:n.getAngleSnap));o&&t(o),P()}else p((0,a.getAngleSnapPosition)(c,r,null==n?void 0:n.getAngleSnap));else u(r)},onMove(t,r){if(C(null!=r?r:t),e&&(t=(0,a.getAngleSnapPosition)(c,t,null==n?void 0:n.getAngleSnap),y(t),c)){const n=v(e,c,d,t);n&&l(n)}},input:h,reset:P}}function v(e,t,n,r){if("2 points"===e){const e={x:(t.x+r.x)/2,y:(t.y+r.y)/2};return m(g({},e),{r:(0,o.getTwoPointsDistance)(e,t)})}return"center radius"===e||"center diameter"===e?m(g({},t),{r:(0,o.getTwoPointsDistance)(r,t)}):n?(0,i.getThreePointsCircle)(t,n,r):void 0}},9345:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEllipseArcClickCreate:()=>m});var r=n(3696),o=n(7875),i=n(1324),a=n(8638),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e},g=(e,t)=>l(e,c(t));function m(e,t,n){const[s,l]=r.useState(),[c,u]=r.useState();let d;s&&(d=void 0===c?"specify start angle by click or input angle":"specify end angle by click or input angle");const{ellipse:p,onClick:f,onMove:m,input:y,startPosition:v,middlePosition:x,cursorPosition:b,setCursorPosition:C,clearText:E,setInputPosition:P}=(0,o.useEllipseClickCreate)(e,(e=>l(e?g(h({},e),{startAngle:0,endAngle:0}):void 0)),g(h({},n),{message:d,onKeyDown:s?(e,n)=>{if("Enter"===e.key){let e=+n;isNaN(e)||(void 0===c?(u(e),l(g(h({},s),{startAngle:e,endAngle:e})),E()):(e{l(void 0),u(void 0),C(void 0),E()};return{ellipse:p,ellipseArc:s,startPosition:v,middlePosition:x,cursorPosition:b,reset:k,onClick(r){if(e)if(s){r=(0,a.getAngleSnapPosition)({x:s.cx,y:s.cy},r,null==n?void 0:n.getAngleSnap);let e=(0,i.getEllipseAngle)(r,s);void 0===c?(u(e),l(g(h({},s),{startAngle:e,endAngle:e}))):(e{"use strict";n.r(t),n.d(t,{useEllipseClickCreate:()=>s});var r=n(3696),o=n(7875),i=n(1324),a=n(8638);function s(e,t,n){const[s,c]=r.useState(),[u,d]=r.useState(),[p,f]=r.useState();let h="";e&&(h=u?p?"specify secondary semi-axis by click, input position or input length":"specify end point by click, input position or input length":"ellipse endpoint"===e?"specify first point by click or input position":"specify ellipse center point by click or input position",(null==n?void 0:n.message)&&(h=n.message));const{input:g,setCursorPosition:m,clearText:y,cursorPosition:v,setInputPosition:x,resetInput:b}=(0,o.useCursorInput)(h,e?(r,o,a)=>{if(null==n?void 0:n.onKeyDown)n.onKeyDown(r,o,a);else if("Enter"===r.key&&e){const n=o.split(",");if(!u){if(2===n.length){const e=+n[0],t=+n[1];isNaN(e)||isNaN(t)||(d({x:e,y:t}),y())}return}if(!p){if(2===n.length){const e=+n[0],t=+n[1];isNaN(e)||isNaN(t)||(f({x:e,y:t}),y())}else{const e=+o;!isNaN(e)&&e>0&&(f((0,i.getPointByLengthAndDirection)(u,e,a)),y())}return}if(2===n.length){const r=+n[0],o=+n[1];isNaN(r)||isNaN(o)||(t(l(e,u,p,{x:r,y:o})),C())}else{const n=+o;!isNaN(n)&&n>0&&(t(l(e,u,p,n)),C())}}}:void 0),C=()=>{d(void 0),f(void 0),c(void 0),b()};return{ellipse:s,startPosition:u,middlePosition:p,cursorPosition:v,setCursorPosition:m,setInputPosition:x,clearText:y,reset:C,onClick(r){if(e)if(m(r),u)if(p){const o="ellipse center"===e?u:{x:(u.x+p.x)/2,y:(u.y+p.y)/2};r=(0,a.getAngleSnapPosition)(o,r,null==n?void 0:n.getAngleSnap),t(l(e,u,p,r)),C()}else{const e=(0,a.getAngleSnapPosition)(u,r,null==n?void 0:n.getAngleSnap);f(e)}else d(r)},onMove(t,r){if(x(r||t),!e)return;let o;if(u&&p){const r="ellipse center"===e?u:{x:(u.x+p.x)/2,y:(u.y+p.y)/2};o=(0,a.getAngleSnapPosition)(r,t,null==n?void 0:n.getAngleSnap)}else o=(0,a.getAngleSnapPosition)(u,t,null==n?void 0:n.getAngleSnap);m(o),u&&p&&c(l(e,u,p,o))},input:g}}function l(e,t,n,r){const o="ellipse center"===e?t:{x:(t.x+n.x)/2,y:(t.y+n.y)/2};return{cx:o.x,cy:o.y,rx:(0,i.getTwoPointsDistance)(o,n),ry:"number"==typeof r?r:(0,i.getTwoPointsDistance)(o,r),angle:(0,i.radianToAngle)((0,i.getTwoPointsRadian)(n,o))}}},7195:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useImageClickCreate:()=>g});var r=n(3696),o=n(7875),i=n(7237),a=Object.defineProperty,s=Object.defineProperties,l=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,p=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))u.call(t,n)&&p(e,n,t[n]);if(c)for(var n of c(t))d.call(t,n)&&p(e,n,t[n]);return e},h=(e,t)=>s(e,l(t));function g(e,t){const[n,a]=r.useState(),s=r.useRef(null);let l="";e&&(l=n?"specify image position":"click to select image");const{input:c,setInputPosition:u}=(0,o.useCursorInput)(l),d=()=>{a(void 0)};return r.useEffect((()=>{var t;e&&(null==(t=s.current)||t.click())}),[e]),{image:n,reset:d,onClick(r){var o;e&&(n?(u(r),t(n),d()):null==(o=s.current)||o.click())},onMove(e,t){u(t||e),n&&a(h(f({},n),{x:e.x,y:e.y}))},input:r.createElement(r.Fragment,null,r.createElement("input",{type:"file",ref:s,accept:"image/*",style:{display:"none"},onChange:e=>{var t;const n=null==(t=e.currentTarget.files)?void 0:t.item(0);if(n){const e=new FileReader;e.onloadend=()=>{const t=e.result;"string"==typeof t&&(0,i.getImageFromCache)(t,{callback(e){a({x:0,y:0,width:e.width,height:e.height,url:t})}})},e.readAsDataURL(n)}e.target.value=null}}),c)}}},7662:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useLineClickCreate:()=>s});var r=n(3696),o=n(7875),i=n(1324),a=n(8638);function s(e,t,n){const[s,u]=r.useState(),[d,p]=r.useState([]),[f,h]=r.useState([]),[g,m]=r.useState(0),[y,v]=r.useState(),[x,b]=r.useState(),C=l[g],E=(g+1)%l.length,P=void 0!==y?()=>y:null==n?void 0:n.getAngleSnap,k=void 0!==x?()=>x:null==n?void 0:n.getLengthSnap;let w="";s&&(w=1===s.length?"specify start point by click, input position":`specify next point by click, input position or input ${C}, press tab to input ${l[E]}`);const{input:_,setCursorPosition:S,clearText:R,setInputPosition:A,resetInput:T,cursorPosition:M}=(0,o.useCursorInput)(w,e?(e,r,o)=>{if("Enter"===e.key){if("angle"===C){const e=+r;if(!isNaN(e)&&(R(),s&&s.length>1)){const t=s[s.length-2],n=s[s.length-1];let r=(0,a.getAngleSnapPosition)(t,n,(()=>e));r=c(t,r,k),p([...d,r]),h([...f,void 0]),u([...d,r,{x:o.x,y:o.y}]),v(void 0),b(void 0)}return}const e=r.split(",");if(2===e.length){const r=+e[0],i=+e[1];if(!isNaN(r)&&!isNaN(r)){const e=d[d.length-1]||{x:0,y:0},a=e.x+r,s=e.y+i;if((null==n?void 0:n.once)&&d.length>0)return t([d[0],{x:a,y:s}],f),void L();p([...d,{x:a,y:s}]),h([...f,void 0]),u([...d,{x:a,y:s},{x:o.x,y:o.y}]),R(),v(void 0),b(void 0)}return}if(d.length>0){const e=+r;if(!isNaN(e)&&e>0){const r=(0,i.getPointByLengthAndDirection)(d[d.length-1],e,o);if((null==n?void 0:n.once)&&d.length>0)return t([d[0],r],f),void L();p([...d,r]),h([...f,void 0]),u([...d,r,{x:o.x,y:o.y}]),R(),v(void 0),b(void 0)}}}else if("Tab"===e.key){if(e.stopPropagation(),e.preventDefault(),r){const e=+r;isNaN(e)||("angle"===C?(v(e),b(void 0),R()):e>0&&(b(e),v(void 0),R()))}m(E)}}:void 0),L=e=>{e&&d.length>1&&t(d,f),p([]),u(void 0),T(),v(void 0),b(void 0),m(0),h([])};return{line:s,positionTargets:f,inputMode:C,lastPosition:null==s?void 0:s[s.length-2],cursorPosition:M,onClick(r,o){if(!e)return;let i=(0,a.getAngleSnapPosition)(d[d.length-1],r,P);if(i=c(d[d.length-1],i,k),S(i),v(void 0),b(void 0),(null==n?void 0:n.once)&&d.length>0)return t([d[0],i],f),void L();p([...d,i]),h([...f,o])},onMove(t,r){if(A(r||t),!e)return;let o=(0,a.getAngleSnapPosition)(d[d.length-1],t,P);o=c(d[d.length-1],o,k),S(o),(null==n?void 0:n.once)&&0===d.length||u([...d,o])},input:_,reset:L,positions:d}}const l=["length","angle"];function c(e,t,n){if(n&&e){const r=(0,i.getTwoPointsDistance)(e,t),o=n(r);void 0!==o&&o!==r&&(t=(0,i.getPointByLengthAndDirection)(e,o,t))}return t}},327:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePathClickCreate:()=>i});var r=n(3696),o=n(7875);function i(e,t){const[n,i]=r.useState([]),[a,s]=r.useState(),[l,c]=r.useState("move"),[u,d]=r.useState(),[p,f]=r.useState(),[h,g]=r.useState();let m="";"move"===l?m="specify start point by click":"line"===l?m="specify end point by click":"quadraticCurve"===l?m=u?"specify end point by click":"specify control point by click":"bezierCurve"===l?m=u?p?"specify end point by click":"specify control point 2 by click":"specify control point 1 by click":"arc"===l&&(m=u?p?"input radius":"specify end point by click, or input radius":"specify start point by click, or input radius");const{input:y,setCursorPosition:v,cursorPosition:x,clearText:b,setInputPosition:C,resetInput:E}=(0,o.useCursorInput)(e?m:"",e?(e,t,r)=>{if("Enter"===e.key){const e=t.split(",");if(2===e.length){const t=+e[0],n=+e[1];isNaN(t)||isNaN(n)||(k({x:t,y:n}),w(r),b())}else if(1===e.length&&"arc"===l){const e=+t;!isNaN(e)&&e>0&&(u&&p?(i([...n,{type:"arc",from:u,to:p,radius:e}]),s(void 0),d(void 0),f(void 0)):g(e),b())}}}:void 0),P=e=>{e&&n.length>1&&t(n),i([]),s(void 0),E(),c("move"),b(),d(void 0),f(void 0),g(void 0)},k=e=>{v(e),"move"===l?(i([...n,{type:"move",to:e}]),c("line")):"line"===l?(i([...n,{type:"line",to:e}]),s(void 0)):"quadraticCurve"===l?u?(i([...n,{type:"quadraticCurve",cp:u,to:e}]),s(void 0),d(void 0)):d(e):"bezierCurve"===l?u?p?(i([...n,{type:"bezierCurve",cp1:u,cp2:p,to:e}]),s(void 0),d(void 0),f(void 0)):f(e):d(e):"arc"===l&&(u?h?(i([...n,{type:"arc",from:u,to:e,radius:h}]),s(void 0),d(void 0),g(void 0)):p||f(void 0):d(e))},w=e=>{"line"===l?s({type:"line",to:e}):"quadraticCurve"===l?s(u?{type:"quadraticCurve",cp:u,to:e}:void 0):"bezierCurve"===l?s(u&&p?{type:"bezierCurve",cp1:u,cp2:p,to:e}:void 0):"arc"===l&&s(u&&h?{type:"arc",from:u,radius:h,to:e}:void 0)};return{path:n,preview:a?[...n,a]:n,controlPoint:u,controlPoint2:p,onClick(t){e&&k(t)},onMove(t,n){C(n||t),e&&(v(t),w(t))},input:y,reset:P,setInputType(e){"close"===e?(t([...n,{type:"close"}]),P()):c(e)},cursorPosition:x}}},4205:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePenClickCreate:()=>a});var r=n(8662),o=n(3696),i=n(1324);function a(e,t){const[n,a]=o.useState([]),s=()=>{a([])};return{points:n,onClick(r){e&&(0!==n.length?(t(),s()):a([{x:Math.round(r.x),y:Math.round(r.y)}]))},onMove(t){if(!e||0===n.length)return;const o=n[n.length-1];if(t={x:Math.round(t.x),y:Math.round(t.y)},!(0,i.isSamePoint)(o,t)){if(n.length>1){const e=n[n.length-2];if((0,i.pointIsOnLine)(o,e,t)&&(0,i.pointIsOnLineSegment)(o,e,t))return void a((0,r.produce)(n,(e=>{e[n.length-1]=t})))}a((0,r.produce)(n,(e=>{e.push(t)})))}},reset:s}}},2628:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePolygonClickCreate:()=>s});var r=n(3696),o=n(7875),i=n(1324),a=n(8638);function s(e,t,n){const[s,l]=r.useState(),[c,u]=r.useState(),[d,p]=r.useState("radius"),[f,h]=r.useState(6);let g="";e&&(g="sides"===d?"specify sides number by input":c?(null==n?void 0:n.toEdge)?"specify edge point by click or input length":"specify end point by click or input length":"specify center point by click");const{input:m,setCursorPosition:y,clearText:v,cursorPosition:x,setInputPosition:b,resetInput:C}=(0,o.useCursorInput)(g,e?(e,r,o)=>{if("Enter"===e.key){if((null==n?void 0:n.setSidesKey)&&r.toLowerCase()===n.setSidesKey.toLowerCase())return p("sides"),void v();if((null==n?void 0:n.switchTypeKey)&&n.switchType&&r.toLowerCase()===n.switchTypeKey.toLowerCase())return n.switchType(),void v();const e=+r;if(!isNaN(e)&&e>0)if("radius"===d){if(c){const r=(0,i.getPointByLengthAndDirection)(c,e,o);t((0,i.getPolygonPoints)(r,c,f,null==n?void 0:n.toEdge)),E()}}else"sides"===d&&Number.isInteger(e)&&e>=3&&(h(e),p("radius"),v(),c&&l((0,i.getPolygonPoints)(o,c,e,null==n?void 0:n.toEdge)))}}:void 0),E=()=>{u(void 0),l(void 0),C()};return r.useEffect((()=>{c&&x&&l((0,i.getPolygonPoints)(x,c,f,null==n?void 0:n.toEdge))}),[null==n?void 0:n.toEdge]),{polygon:s,startPosition:c,cursorPosition:x,reset:E,onClick(r){if(e)if(y(r),c){const e=(0,a.getAngleSnapPosition)(c,r,null==n?void 0:n.getAngleSnap);t((0,i.getPolygonPoints)(e,c,f,null==n?void 0:n.toEdge)),E()}else u(r)},onMove(t,r){if(b(r||t),!e)return;const o=(0,a.getAngleSnapPosition)(c,t,null==n?void 0:n.getAngleSnap);y(o),c&&l((0,i.getPolygonPoints)(o,c,f,null==n?void 0:n.toEdge))},input:m,startSetSides(){p("sides")}}}},3175:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useTextClickCreate:()=>h});var r=n(3696),o=n(7875),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))u.call(t,n)&&d(e,n,t[n]);return e},f=(e,t)=>a(e,s(t));function h(e,t,n){const[i,a]=r.useState();let s="";e&&(s=i?"specify text position":"input text");const{input:l,setCursorPosition:c,clearText:u,setInputPosition:d,resetInput:h}=(0,o.useCursorInput)(s,e?(e,t,r)=>{var o;"Enter"===e.key&&(a({x:r.x,y:r.y,text:t,color:0,fontSize:16/(null!=(o=null==n?void 0:n.scale)?o:1),fontFamily:"monospace"}),u())}:void 0),g=()=>{a(void 0),h()};return{text:i,onClick(n){e&&i&&(c(n),t(i),g())},onMove(e,t){d(t||e),c(e),i&&a(f(p({},i),{x:e.x,y:e.y}))},input:l,reset:g}}},5970:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCursorInput:()=>u});var r=n(3696),o=Object.defineProperty,i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,l=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c=(e,t)=>{for(var n in t||(t={}))a.call(t,n)&&l(e,n,t[n]);if(i)for(var n of i(t))s.call(t,n)&&l(e,n,t[n]);return e};function u(e,t,n){const[o,i]=r.useState(""),[a,s]=r.useState(),[l,u]=r.useState(),d=r.useRef(null);return r.useLayoutEffect((()=>{var e,t;const n=null==(e=document.activeElement)?void 0:e.tagName;"INPUT"!==n&&"TEXTAREA"!==n&&(null==(t=d.current)||t.focus())})),{resetInput:()=>{s(void 0),u(void 0),i("")},cursorPosition:a,inputPosition:l,setCursorPosition:s,setInputPosition:u,clearText(){i("")},input:l&&(e||t&&a)?r.createElement("span",{style:{position:"absolute",left:`${Math.min(l.x+10,window.innerWidth-54)}px`,top:`${Math.min(l.y-5,window.innerHeight-22)}px`}},e&&r.createElement("span",null,e),t&&a&&r.createElement("input",{ref:d,value:o,autoComplete:"false",style:c({width:"50px",opacity:(null==n?void 0:n.hideIfNoInput)&&!o?0:void 0},null==n?void 0:n.inputStyle),onChange:e=>i(e.target.value),onKeyDown:e=>t(e,o,a)})):void 0}}},2978:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDelayedAction:()=>o});var r=n(3696);function o(e,t,n){const o=r.useRef();e&&(o.current&&clearTimeout(o.current),o.current=setTimeout((()=>{n()}),t))}},8907:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragMove:()=>s});var r=n(3696),o=n(8638),i=n(3158),a=n(1715);function s(e,t){var n;const[s,l]=r.useState({x:0,y:0}),[c,u]=r.useState(),d=null!=(n=null==t?void 0:t.scale)?n:1,p=-(0,a.angleToRadian)(null==t?void 0:t.parentRotate),f=()=>{l({x:0,y:0}),u(void 0)};return{offset:s,resetDragMove:f,startPosition:c,onStart(e,t){var n,r;u({x:e.x-(null!=(n=null==t?void 0:t.x)?n:0),y:e.y-(null!=(r=null==t?void 0:t.y)?r:0),data:null==t?void 0:t.data})},mask:c&&r.createElement(i.DragMask,{ignoreLeavingEvent:null==t?void 0:t.ignoreLeavingEvent,onDragging:e=>{var n,r,i,a;const s={x:e.clientX,y:e.clientY};let u=null!=(r=null==(n=null==t?void 0:t.transform)?void 0:n.call(t,s))?r:s;u=(0,o.getAngleSnapPosition)(c,u,null==t?void 0:t.getAngleSnap);const f=(u.x-c.x)/d,h=(u.y-c.y)/d,g=Math.sin(p),m=Math.cos(p),y={x:m*f-g*h,y:g*f+m*h};l(null!=(a=null==(i=null==t?void 0:t.transformOffset)?void 0:i.call(t,y,e))?a:y)},onDragEnd:()=>{null==e||e(),(null==t?void 0:t.repeatedly)||f()}})}}},1412:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getResizeOffset:()=>v,useDragResize:()=>y});var r=n(3696),o=n(4676),i=n(8638),a=n(3158),s=n(1715),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&h(e,n,t[n]);if(d)for(var n of d(t))f.call(t,n)&&h(e,n,t[n]);return e},m=(e,t)=>c(e,u(t));function y(e,t){var n,l;const[c,u]=r.useState({x:0,y:0,width:0,height:0}),[d,p]=r.useState(),f=-(0,s.angleToRadian)(null==t?void 0:t.rotate),h=-(0,s.angleToRadian)(null==t?void 0:t.parentRotate),[y,x]=r.useState(),b=()=>{u({x:0,y:0,width:0,height:0}),p(void 0)};return{offset:c,cursorPosition:y,startPosition:d,onStart(e,n){var r,o;e.stopPropagation();const i={x:e.clientX,y:e.clientY};p(m(g({},null!=(o=null==(r=null==t?void 0:t.transform)?void 0:r.call(t,i))?o:i),{direction:n}))},resetDragResize:b,mask:d&&r.createElement(a.DragMask,{onDragging:e=>{var n,r,o,a,s,l;let c={x:e.clientX,y:e.clientY};c=null!=(r=null==(n=null==t?void 0:t.transform)?void 0:n.call(t,c))?r:c,c=(0,i.getAngleSnapPosition)(d,c,null==t?void 0:t.getAngleSnap),x(c);const p="boolean"==typeof(null==t?void 0:t.centeredScaling)?t.centeredScaling:null==(o=null==t?void 0:t.centeredScaling)?void 0:o.call(t,e),g="number"==typeof(null==t?void 0:t.keepRatio)?t.keepRatio:null==(a=null==t?void 0:t.keepRatio)?void 0:a.call(t,e),m=v(d,c,d.direction,f,p,g,h);m&&u(null!=(l=null==(s=null==t?void 0:t.transformOffset)?void 0:s.call(t,m,e,d.direction))?l:m)},onDragEnd:()=>{e(),b()},style:{cursor:(0,o.getResizeCursor)((null!=(n=null==t?void 0:t.rotate)?n:0)+(null!=(l=null==t?void 0:t.parentRotate)?l:0),d.direction)}})}}function v(e,t,n,r=0,o,i,a=0){const s=t.x-e.x,l=t.y-e.y,c=Math.sin(a),u=Math.cos(a),d=u*s-c*l,p=c*s+u*l;if("center"===n)return{x:d,y:p,width:0,height:0};const f=Math.sin(r),h=Math.cos(r);let g=h*d-f*p,m=f*d+h*p;const y=n.includes("right")?1:n.includes("left")?-1:0,v=n.includes("bottom")?1:n.includes("top")?-1:0;if(i){if("left"===n||"right"===n||"top"===n||"bottom"===n)return;const e=g*y,t=m*v;g=Math.min(t*i,e)*y,m=Math.min(e/i,t)*v}const x={x:0,y:0,width:0,height:0};return x.width=g*(o?2:1)*y,x.height=m*(o?2:1)*v,o?(x.x-=g*y,x.y-=m*v):(n.includes("left")&&(x.x+=(h+1)*g/2,x.y-=f*g/2),n.includes("right")&&(x.x+=(h-1)*g/2,x.y-=f*g/2),n.includes("top")&&(x.x+=f*m/2,x.y+=(h+1)*m/2),n.includes("bottom")&&(x.x+=f*m/2,x.y+=(h-1)*m/2)),x}},2789:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragRotate:()=>m});var r=n(3696),o=n(1715),i=n(8638),a=n(3158),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e},g=(e,t)=>l(e,c(t));function m(e,t){var n;const[s,l]=r.useState(),[c,u]=r.useState(),d=null!=(n=null==t?void 0:t.parentRotate)?n:0,p=()=>{l(void 0),u(void 0)};return{offset:s,center:c,onStart:u,resetDragRotate:p,mask:c&&r.createElement(a.DragMask,{ignoreLeavingEvent:null==t?void 0:t.ignoreLeavingEvent,onDragging:e=>{var n,r,a,s;const u={x:e.clientX,y:e.clientY};let p=null!=(r=null==(n=null==t?void 0:t.transform)?void 0:n.call(t,u))?r:u;p=(0,i.getAngleSnapPosition)(c,p,null==t?void 0:t.getAngleSnap);const f=((0,o.radianToAngle)((0,o.getTwoPointsRadian)(p,c))+450-d)%360;l(g(h({},p),{angle:null!=(s=null==(a=null==t?void 0:t.transformOffset)?void 0:a.call(t,f,e))?s:f}))},onDragEnd:()=>{null==e||e(),p()}})}}},9160:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragSelect:()=>i});var r=n(3696),o=n(3158);function i(e,t){const[n,i]=r.useState(),[a,s]=r.useState(),l=()=>{i(void 0),s(void 0)},c=t=>{n&&e(n,a,t),l()};return{dragSelectStartPosition:n,onStartSelect(e,t){i({x:e.clientX,y:e.clientY,data:t})},endDragSelect:c,resetDragSelect:l,dragSelectMask:n&&r.createElement(o.DragMask,{onDragging:e=>{if("boolean"==typeof t?t:t?t(e):void 0){const t=e.clientX-n.x,r=e.clientY-n.y,o=Math.min(Math.abs(t),Math.abs(r));s({x:t>0?n.x+o:n.x-o,y:r>0?n.y+o:n.y-o})}else s({x:e.clientX,y:e.clientY})},onDragEnd:c,style:{cursor:a?"crosshair":"default"}},a&&r.createElement("div",{style:{position:"absolute",border:"1px dashed black",left:Math.min(n.x,a.x)+"px",top:Math.min(n.y,a.y)+"px",width:Math.abs(n.x-a.x)+"px",height:Math.abs(n.y-a.y)+"px"}}))}}},5115:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEdit:()=>y});var r=n(8662),o=n(3696),i=n(1324),a=n(8638),s=n(9055),l=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))p.call(t,n)&&h(e,n,t[n]);if(d)for(var n of d(t))f.call(t,n)&&h(e,n,t[n]);return e},m=(e,t)=>c(e,u(t));function y(e,t,n){var l,c,u;const[d,p]=o.useState(),[f,h]=o.useState(),[y,v]=o.useState(),[x,b]=o.useState(),[C,E]=o.useState(),[P,k]=o.useState(),w=5/(null!=(l=null==n?void 0:n.scale)?l:1),_=null!=(c=null==n?void 0:n.readOnly)&&c,S=()=>{p(void 0),v(void 0),b(void 0),E(void 0),k(void 0),h(void 0)};return o.useEffect((()=>{!1===_&&S()}),[_]),{editPoint:d,editLastPosition:null!=(u=null==d?void 0:d.angleSnapStartPoint)?u:y,getEditAssistentContents(e,r){var o;const i=[];if(!_&&!(null==(o=null==n?void 0:n.contentReadOnly)?void 0:o.call(n,e))){const n=null==t?void 0:t(e);n&&i.push(...n.editPoints.map((e=>r({x:e.x,y:e.y,width:w,height:w}))))}return i},updateEditPreview(){if(f&&y&&x){const e=[],t=[],o=[],[i,a,l]=(0,r.produceWithPatches)(f.content,(r=>{var i,a;const s=null==(a=f.update)?void 0:a.call(f,r,{cursor:x,start:y,scale:null!=(i=null==n?void 0:n.scale)?i:1,target:C});if((null==s?void 0:s.assistentContents)&&e.push(...s.assistentContents),null==s?void 0:s.updateRelatedContents){const e=s.updateRelatedContents();t.push(...e.patches),o.push(...e.reversePatches)}}));return{content:f.content,result:i,patches:[...(0,s.prependPatchPath)(a,f.path),...t],reversePatches:[...(0,s.prependPatchPath)(l,f.path),...o],assistentContents:e,relatedEditPointResults:new Map}}if(d&&y&&x&&d.update){const e=[],t=[],o=[],[i,a,l]=(0,r.produceWithPatches)(d.content,(r=>{var i,a;const s=null==(a=d.update)?void 0:a.call(d,r,{cursor:x,start:y,scale:null!=(i=null==n?void 0:n.scale)?i:1,target:C});if((null==s?void 0:s.assistentContents)&&e.push(...s.assistentContents),null==s?void 0:s.updateRelatedContents){const e=s.updateRelatedContents();t.push(...e.patches),o.push(...e.reversePatches)}})),c={content:d.content,result:i,patches:[...(0,s.prependPatchPath)(a,d.path),...t],reversePatches:[...(0,s.prependPatchPath)(l,d.path),...o],assistentContents:e,relatedEditPointResults:new Map};for(const t of d.relatedEditPoints){const[o,i,a]=(0,r.produceWithPatches)(t.content,(r=>{var o,i;const a=null==(i=t.update)?void 0:i.call(t,r,{cursor:x,start:y,scale:null!=(o=null==n?void 0:n.scale)?o:1});(null==a?void 0:a.assistentContents)&&e.push(...a.assistentContents)}));c.patches.push(...(0,s.prependPatchPath)(i,t.path)),c.reversePatches.push(...(0,s.prependPatchPath)(a,t.path)),c.relatedEditPointResults.set(t.content,o)}return c}},onEditMove(e,r,o){var s;if(_)return;if((null==d?void 0:d.angleSnapStartPoint)?e=(0,a.getAngleSnapPosition)(d.angleSnapStartPoint,e,null==n?void 0:n.getAngleSnap):y&&(e=(0,a.getAngleSnapPosition)(y,e,null==n?void 0:n.getAngleSnap)),y)return b(e),void E(o);let l;for(const{content:o,path:a}of r){if(null==(s=null==n?void 0:n.contentReadOnly)?void 0:s.call(n,o))continue;const r=null==t?void 0:t(o);if(r){const t=r.editPoints.find((t=>(0,i.getTwoNumbersDistance)(t.x,e.x)<=w&&(0,i.getTwoNumbersDistance)(t.y,e.y)<=w));t&&(l?l.relatedEditPoints.push(m(g({},t),{content:o,path:a})):l=m(g({},t),{content:o,path:a,angleSnapStartPoint:r.angleSnapStartPoint,relatedEditPoints:[]}))}}p(l)},onEditClick(t){if(f)return e([],[]),void S();if(d)if(d.execute){const[,t,n]=(0,r.produceWithPatches)(d.content,(e=>{var t;null==(t=d.execute)||t.call(d,e)}));e((0,s.prependPatchPath)(t,d.path),(0,s.prependPatchPath)(n,d.path))}else y?(e([],[]),S()):v(t)},onEditContextMenu(t,n){(null==d?void 0:d.menu)&&k(n(d.menu,(n=>()=>{if(k(void 0),n.execute){const[,t,o]=(0,r.produceWithPatches)(d.content,(e=>{var t;null==(t=n.execute)||t.call(n,e)}));e((0,s.prependPatchPath)(t,d.path),(0,s.prependPatchPath)(o,d.path))}else n.update&&(v(t),b(t),h({content:d.content,path:d.path,update:n.update}),p(d))})))},editMenu:P,resetEdit:S}}},3404:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCircleArcEdit:()=>s});var r=n(3696),o=n(1324),i=n(8638),a=n(4970);function s(e,t){const[n,s]=r.useState({x:0,y:0,r:0,startAngle:0,endAngle:0}),[l,c]=r.useState(),{onStart:u,mask:d,reset:p}=(0,a.useDragEdit)((()=>{s({x:0,y:0,r:0,startAngle:0,endAngle:0}),e()}),((e,n)=>{if(n=(0,i.getAngleSnapPosition)(e.data,n,null==t?void 0:t.getAngleSnap),c(n),"center"===e.data.type){const t=n.x-e.x,r=n.y-e.y;s({x:t,y:r,r:0,startAngle:0,endAngle:0,data:e.data.data})}else if("radius"===e.data.type){const t=(0,o.getTwoPointsDistance)(n,e.data)-e.data.r;s({x:0,y:0,r:t,startAngle:0,endAngle:0,data:e.data.data})}else if("start angle"===e.data.type){const t=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(n,e.data))-e.data.startAngle;s({x:0,y:0,r:0,startAngle:t,endAngle:0,data:e.data.data})}else if("end angle"===e.data.type){const t=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(n,e.data))-e.data.endAngle;s({x:0,y:0,r:0,startAngle:0,endAngle:t,data:e.data.data})}}),t);return{offset:n,onStart:u,mask:d,cursorPosition:l,reset(){s({x:0,y:0,r:0,startAngle:0,endAngle:0}),p()}}}},8285:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useCircleEdit:()=>s});var r=n(3696),o=n(1324),i=n(8638),a=n(4970);function s(e,t){const[n,s]=r.useState({x:0,y:0,r:0}),[l,c]=r.useState(),{onStart:u,mask:d,reset:p}=(0,a.useDragEdit)((()=>{s({x:0,y:0,r:0}),e()}),((e,n)=>{if(n=(0,i.getAngleSnapPosition)(e.data,n,null==t?void 0:t.getAngleSnap),c(n),"center"===e.data.type){const t=n.x-e.x,r=n.y-e.y;s({x:t,y:r,r:0,data:e.data.data})}else{const t=(0,o.getTwoPointsDistance)(n,e.data)-e.data.r;s({x:0,y:0,r:t,data:e.data.data})}}),t);return{cursorPosition:l,offset:n,onStart:u,mask:d,reset(){s({x:0,y:0,r:0}),p()}}}},4970:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useDragEdit:()=>h});var r=n(3696),o=n(7875),i=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,d=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&d(e,n,t[n]);if(l)for(var n of l(t))u.call(t,n)&&d(e,n,t[n]);return e},f=(e,t)=>a(e,s(t));function h(e,t,n){const[i,a]=r.useState();return{dragStartPosition:i,onStart(e,t){var r,o;e.stopPropagation(),a(f(p({},null!=(o=null==(r=null==n?void 0:n.transform)?void 0:r.call(n,{x:e.clientX,y:e.clientY}))?o:{x:e.clientX,y:e.clientY}),{data:t}))},reset(){a(void 0)},mask:i&&r.createElement(o.DragMask,{onDragging:e=>{var r,o;e.stopPropagation();let a={x:e.clientX,y:e.clientY};a=null!=(o=null==(r=null==n?void 0:n.transform)?void 0:r.call(n,a))?o:a,t(i,a)},onDragEnd:()=>{e(),a(void 0)},style:{cursor:i.data.cursor}})}}},5384:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEllipseArcEdit:()=>s});var r=n(3696),o=n(1324),i=n(8638),a=n(4970);function s(e,t){const[n,s]=r.useState({cx:0,cy:0,rx:0,ry:0,startAngle:0,endAngle:0}),[l,c]=r.useState(),{onStart:u,mask:d,reset:p}=(0,a.useDragEdit)((()=>{s({cx:0,cy:0,rx:0,ry:0,startAngle:0,endAngle:0}),e()}),((e,n)=>{var r,a;if(n=(0,i.getAngleSnapPosition)({x:e.data.cx,y:e.data.cy},n,null==t?void 0:t.getAngleSnap),c(n),"center"===e.data.type){const t=n.x-e.x,r=n.y-e.y;s({cx:t,cy:r,rx:0,ry:0,startAngle:0,endAngle:0,data:e.data.data})}else if("start angle"===e.data.type){const t=(0,o.rotatePositionByCenter)(n,{x:e.data.cx,y:e.data.cy},null!=(r=e.data.angle)?r:0),i=(0,o.getEllipseAngle)(t,e.data)-e.data.startAngle;s({cx:0,cy:0,rx:0,ry:0,startAngle:i,endAngle:0,data:e.data.data})}else if("end angle"===e.data.type){const t=(0,o.rotatePositionByCenter)(n,{x:e.data.cx,y:e.data.cy},null!=(a=e.data.angle)?a:0),r=(0,o.getEllipseAngle)(t,e.data)-e.data.endAngle;s({cx:0,cy:0,rx:0,ry:0,startAngle:0,endAngle:r,data:e.data.data})}}),t);return{offset:n,onStart:u,mask:d,cursorPosition:l,reset(){s({cx:0,cy:0,rx:0,ry:0,startAngle:0,endAngle:0}),p()}}}},2817:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEllipseEdit:()=>s});var r=n(3696),o=n(1324),i=n(8638),a=n(4970);function s(e,t){const[n,s]=r.useState({cx:0,cy:0,rx:0,ry:0}),[l,c]=r.useState(),{onStart:u,mask:d,reset:p}=(0,a.useDragEdit)((()=>{s({cx:0,cy:0,rx:0,ry:0}),e()}),((e,n)=>{if(n=(0,i.getAngleSnapPosition)({x:e.data.cx,y:e.data.cy},n,null==t?void 0:t.getAngleSnap),c(n),"center"===e.data.type){const t=n.x-e.x,r=n.y-e.y;s({cx:t,cy:r,rx:0,ry:0,data:e.data.data})}else{const t=(0,o.getTwoPointsDistance)(n,{x:e.data.cx,y:e.data.cy});"major axis"===e.data.type?s({cx:0,cy:0,rx:t-e.data.rx,ry:0,data:e.data.data}):s({cx:0,cy:0,rx:0,ry:t-e.data.ry,data:e.data.data})}}),t);return{offset:n,onStart:u,mask:d,cursorPosition:l,reset(){s({cx:0,cy:0,rx:0,ry:0}),p()}}}},341:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePolylineEdit:()=>a});var r=n(3696),o=n(8638),i=n(4970);function a(e,t){const[n,a]=r.useState(),[s,l]=r.useState(),{onStart:c,mask:u,dragStartPosition:d,reset:p}=(0,i.useDragEdit)((()=>{a(void 0),e()}),((e,n)=>{n=(0,o.getAngleSnapPosition)(e,n,null==t?void 0:t.getAngleSnap),l(n);const r=n.x-e.x,i=n.y-e.y;a({x:r,y:i,pointIndexes:e.data.pointIndexes,data:e.data.data})}),t);return{offset:n,onStart(e,t,n){c(e,{pointIndexes:t,data:n,cursor:"move"})},mask:u,cursorPosition:s,dragStartPosition:d,reset(){a(void 0),p()}}}},4399:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useEvent:()=>o});var r=n(3696);function o(e){const t=r.useRef();return r.useLayoutEffect((()=>{t.current=e})),r.useCallback((e=>{var n;null==(n=t.current)||n.call(t,e)}),[])}},2432:(e,t,n)=>{"use strict";n.r(t),n.d(t,{compareLocations:()=>C,useFlowLayoutBlockEditor:()=>b,useFlowLayoutBlockOperation:()=>E});var r=n(8662),o=n(3696),i=n(7875),a=n(1324),s=n(6487),l=n(3331),c=n(623),u=n(9182),d=Object.defineProperty,p=Object.defineProperties,f=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,y=(e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))g.call(t,n)&&y(e,n,t[n]);if(h)for(var n of h(t))m.call(t,n)&&y(e,n,t[n]);return e},x=(e,t)=>p(e,f(t));function b(e){var t,n,r,i,c;const{range:u,inputContent:d,inputInline:p,getCopiedContents:f,skipVoidBlock:h,scrollRef:g,scrollY:m,dragLocation:y,setY:x,selectionStart:b,setSelectionStart:P,ref:k,setLocation:w,location:_,contentHeight:S,setContentHeight:R,blockLocation:A,contentLocation:T,actualHeight:M,isSelected:L,onBlur:I,onMouseUp:O,onMouseDown:B,onMouseMove:F,onKeyDown:D}=E(e),[z,U]=o.useState(!1),N=(e=!1)=>{if(!e&&u)return P(void 0),void w(u.min);e&&void 0===b&&P(_),w(ue{if(!t&&u)return P(void 0),void w(u.max);t&&void 0===b&&P(_),de>=Z.length-1?w([e.state.length-1,e.state[e.state.length-1].children.length]):w(W({x:ce,y:ue+Z[de]+Z[de+1]/2+m},!1))},j=e=>{D(e,N,G)},V=e=>{const t=e.target.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},W=(t,n=!0,r)=>{for(let o=0;o0&&K[o][0].y>t.y)return h([o,0],r);const i=(0,a.getFlowLayoutLocation)(t,Z,K[o],m,(t=>e.getWidth(t,e.state[o])),n,e.getHeight);if(void 0!==i)return U(i.lineEnd),h([o,i.location],r)}return[e.state.length-1,e.state[e.state.length-1].children.length]},H=t=>{if(u)for(let n=0;n=0&&C(r,u.max)<0&&t.x>i.x&&t.y>i.y&&t.x{B(e,V,W,H)},$=e=>{F(e,V,(e=>W(e,!1)),0,ne,re)},Y=e=>{$(e),O()},K=[];let X=0;const Z=[];let Q=0,J=0;const ee=e.getComposition,te=e.lineHeight;if(e.state.forEach(((t,n)=>{var r,o,i,s;const l=t.listStyleType&&(null==(r=e.isSameType)?void 0:r.call(e,t,e.state[n-1]))?0:null!=(o=t.blockStart)?o:0,c=t.listStyleType&&(null==(i=e.isSameType)?void 0:i.call(e,t,e.state[n+1]))?0:null!=(s=t.blockEnd)?s:0,u=Math.max(l,J),d=(0,a.flowLayout)({state:t.children,width:e.width,height:e.autoHeight?void 0:e.height,lineHeight:"number"==typeof te?te:e=>te(e,t),getWidth:n=>e.getWidth(n,t),isNewLineContent:e.isNewLineContent,isPartOfComposition:e.isPartOfComposition,getComposition:ee?e=>ee(n,e):void 0,endContent:e.endContent,scrollX:t.inlineStart,scrollY:m+X+u,row:Q,align:e.align});K.push(d.layoutResult),t.void||(X+=d.newContentHeight),X+=u,Z.push(...d.lineHeights),Q+=d.lineHeights.length,J=c})),X+=J,e.height&&("middle"===e.verticalAlign||"bottom"===e.verticalAlign)){let t=e.height-X;t>0&&("middle"===e.verticalAlign&&(t/=2),K.forEach((e=>{e.forEach((e=>{e.y+=t}))})))}S0&&(null==ae?void 0:ae[oe-1]);se&&oe--;const le=null==ae?void 0:ae[oe],ce=(null!=(r=null==le?void 0:le.x)?r:0)+(se?e.getWidth(null==ae?void 0:ae[oe].content,e.state[ie]):0),ue=(null!=(i=null==le?void 0:le.y)?i:0)-m,de=null!=(c=null==le?void 0:le.row)?c:0,pe=o.useRef(),fe=o.useRef();return o.useEffect((()=>{var t,n;if((0,a.equals)(null==(t=pe.current)?void 0:t[0],_[0])&&(0,a.equals)(null==(n=pe.current)?void 0:n[1],_[1])&&(0,a.equals)(fe.current,ue)||e.autoHeight)return;const r=ue+m;r<0?x(-ue):r>e.height-re&&x(e.height-re-ue),pe.current=_,fe.current=ue}),[_,ue,m,re]),{ref:k,range:u,layoutResult:K,lineHeights:Z,cursor:{x:ce,y:ue+m,row:de},inputContent:d,inputInline:p,location:_,setLocation:w,getCopiedContents:f,isSelected:L,actualHeight:M,setSelectionStart:P,getPosition:V,positionToLocation:W,scrollY:m,renderEditor:t=>o.createElement("div",{style:v({position:"relative",width:e.width+"px",height:M+"px",border:"1px solid black",clipPath:"inset(0px 0px)"},e.style),onMouseLeave:Y,ref:g},o.createElement(s.Cursor,{ref:k,onKeyDown:j,onCompositionEnd:e.onCompositionEnd,onBlur:I,onFocus:e.onFocus,readOnly:e.readOnly,style:{left:ce+"px",top:ue+m+"px",height:Z[de]+"px"}}),t,o.createElement("div",{onMouseDown:q,onMouseMove:$,onMouseUp:Y,onDoubleClick:e.onDoubleClick,style:{inset:"0px",cursor:"text",position:"absolute"}}),!e.autoHeight&&o.createElement(l.Scrollbar,{value:m,type:"vertical",containerSize:e.height,contentSize:S,onChange:x,align:"head"}))}}function C(e,t){return e[0]t[0]?1:e[1]t[1]?1:0}function E(e){const[t,n]=o.useState([0,0]),[a,s]=t,[l,d]=o.useState(),p=o.useRef(null),[f,h]=o.useState(0),g=void 0!==l?C(l,t)>0?{min:t,max:l}:{min:l,max:t}:void 0,m=r=>{if(!e.readOnly){if(g)return d(void 0),n([g.min[0]+r.length+1,0]),void e.setState((e=>{y(e,r)}));n([a+r.length+1,0]),e.setState((e=>{b(e,r,t)}))}},y=(t,n)=>{if(!g)return;const[o,i]=g.min,[a,s]=g.max;t[o].children.splice(i,e.state[o].children.length),a>o?(t[a].children.splice(0,s),t.splice(o+1,a-o-1,...(0,r.castDraft)(n))):t.splice(o+1,0,...(0,r.castDraft)(n),(0,r.castDraft)(x(v({},e.state[o]),{children:e.state[o].children.slice(s)})))},b=(t,n,o)=>{t[o[0]].children.splice(o[1],e.state[o[0]].children.length-o[1]),t.splice(o[0]+1,0,...(0,r.castDraft)(n),(0,r.castDraft)(x(v({},e.state[o[0]]),{children:e.state[o[0]].children.slice(o[1])})))},E=(t,n)=>{if(!g)return;const[o,i]=g.min,[a,s]=g.max,l=a>o?[...n,...e.state[a].children.slice(s)]:n,c=(o===a?s:e.state[o].children.length)-i;t[o].children.splice(i,c,...(0,r.castDraft)(l)),a>o&&t.splice(o+1,a-o)},P=(e,t,n,o=0)=>{e[n[0]].children.splice(n[1]-o,o,...(0,r.castDraft)(t))},k=()=>{if(!e.readOnly)return g?(n(g.min),d(void 0),void e.setState((e=>{E(e,[])}))):void(0===a&&0===s||(0!==s?(n([a,s-1]),e.setState((e=>{e[a].children.splice(s-1,1)}))):(n([a-1,e.state[a-1].children.length]),e.setState((e=>{e[a-1].children.push(...e[a].children),e.splice(a,1)})))))},w=t=>{const[n,r]=t.min,[o,i]=t.max,a=n===o?i:e.state[n].children.length,s=[x(v({},e.state[n]),{children:e.state[n].children.slice(r,a)})];for(let t=n+1;tn&&s.push(x(v({},e.state[o]),{children:e.state[o].children.slice(0,i)})),s},_=([t,n],r)=>{for(;e.state[t].void;)r?(t--,n=e.state[t].children.length):(t++,n=0);return[t,n]},S=o.useRef(),[R,A]=o.useState();(0,i.useGlobalMouseUp)((0,i.useEvent)((()=>{S.current=void 0,A(void 0)})));const{ref:T,y:M,setY:L,filterY:I}=(0,u.useWheelScroll)({minY:e.autoHeight?0:f>e.height?e.height-f:0,maxY:0,disabled:e.autoHeight});o.useEffect((()=>{e.autoHeight&&L(0)}),[e.autoHeight,L]);let O=e.height;return e.autoHeight&&f>e.height&&(O=f),o.useEffect((()=>{var n;null==(n=e.onLocationChanged)||n.call(e,t)}),[t]),{range:g,inputContent:m,inputInline:(r,o=0)=>{if(!e.readOnly){if(g){const[t,o]=g.min;return d(void 0),n([t,o+r.length]),void e.setState((e=>{E(e,r)}))}n([a,s+r.length-o]),e.setState((e=>{P(e,r,t,o)}))}},getCopiedContents:(e=!1)=>{if(void 0!==g)return e&&k(),w(g)},skipVoidBlock:_,scrollRef:T,backspace:k,scrollY:M,dragLocation:R,setY:L,selectionStart:l,setSelectionStart:d,ref:p,setLocation:n,location:t,contentHeight:f,setContentHeight:h,blockLocation:a,contentLocation:s,isSelected:e=>g&&C(e,g.min)>=0&&C(e,g.max)<0,actualHeight:O,onBlur:()=>{var t,n;e.keepSelectionOnBlur||d(void 0),null==(t=e.onLocationChanged)||t.call(e),null==(n=e.onBlur)||n.call(e)},onMouseUp:()=>{var t;if(void 0!==R&&g){if(C(R,g.min)<0){const t=w(g);if(1===t.length){const r=t[0].children;e.setState((e=>{E(e,[]),P(e,r,R)})),n([R[0],R[1]+r.length]),d(R)}else e.setState((e=>{E(e,[]),b(e,t,R)})),n([R[0]+t.length+1,0]),d([R[0]+1,0])}else if(C(R,g.max)>0){const t=w(g);if(1===t.length){const r=t[0].children;e.setState((e=>{P(e,r,R),E(e,[])})),d([R[0],R[1]-r.length]),n(R)}else e.setState((e=>{b(e,t,R),E(e,[])})),n([R[0]+2,0]),d([R[0]-t.length+2,0])}A(void 0)}null==(t=p.current)||t.focus()},onMouseDown:(e,r,o,i)=>{e.preventDefault();const a=r(e),s=o(a);if(e.shiftKey)void 0===l&&d(t),n(s);else{if(i(a))return void A(s);S.current=s}},onMouseMove:(t,r,o,i,a,s)=>{if(void 0===S.current)return void(void 0!==R&&A(o(r(t))));const l=r(t),c=o(l);if(n(c),c[0]===S.current[0]&&c[1]===S.current[1]?d(void 0):d(S.current),!e.autoHeight){const t=l.y+i;t>=0&&t<=a?L((e=>I(e+2))):t<=e.height&&t>=e.height-s&&L((e=>I(e-2)))}},onKeyDown:(r,o,i,u)=>{var p,f,h;if(r.nativeEvent.isComposing)null==(p=e.onComposing)||p.call(e,r);else if(229!==r.keyCode){if(!(null==(h=e.processInput)?void 0:h.call(e,r))){if("Enter"===r.key)return m([]),!0;if(!["CapsLock","Tab","Shift","Meta","Escape","Control"].includes(r.key)){if("Backspace"===r.key)return k();if("Delete"===r.key)return(()=>{if(!e.readOnly)return g?(n(g.min),d(void 0),void e.setState((e=>{E(e,[])}))):void(a===e.state.length-1&&s===e.state[e.state.length-1].children.length||(s!==e.state[a].children.length?e.setState((e=>{e[a].children.splice(s,1)})):e.setState((e=>{e[a].children.push(...e[a+1].children),e.splice(a+1,1)}))))})();if("ArrowLeft"===r.key)return((r=!1)=>{if(!r&&g)return d(void 0),void n(g.min);0===a&&0===s||(r&&void 0===l&&d(t),n(0!==s?[a,s-1]:_([a-1,e.state[a-1].children.length],!0)))})(r.shiftKey);if("ArrowRight"===r.key)return((r=!1)=>{if(!r&&g)return d(void 0),void n(g.max);a===e.state.length-1&&s===e.state[e.state.length-1].children.length||(r&&void 0===l&&d(t),s!==e.state[a].children.length?n([a,s+1]):n(_([a+1,0])))})(r.shiftKey);if("ArrowUp"===r.key)return o(r.shiftKey);if("ArrowDown"===r.key)return i(r.shiftKey);if((0,c.metaKeyIfMacElseCtrlKey)(r)){if("a"===r.key)return d([0,0]),void n([e.state.length-1,e.state[e.state.length-1].children.length])}else r.preventDefault();null==u||u()}}}else null==(f=e.onComposing)||f.call(e,r)}}}},4844:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useFlowLayoutEditor:()=>v});var r=n(3696),o=n(6301),i=n(2792),a=n(6487),s=n(3331),l=n(4399),c=n(135),u=n(623),d=n(9182),p=Object.defineProperty,f=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,m=(e,t,n)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))h.call(t,n)&&m(e,n,t[n]);if(f)for(var n of f(t))g.call(t,n)&&m(e,n,t[n]);return e};function v(e){var t;const[n,p]=r.useState(0),[f,h]=r.useState(),g=r.useRef(null),[m,v]=r.useState(0),[x,b]=r.useState(!1),C=()=>{if(!e.readOnly)return G?(p(G.min),h(void 0),void e.setState((e=>{e.splice(G.min,G.size)}))):void(0!==n&&(p(n-1),e.setState((e=>{e.splice(n-1,1)}))))},E=t=>{var r,o,i;if(t.nativeEvent.isComposing)null==(r=e.onComposing)||r.call(e,t);else if(229!==t.keyCode){if(!(null==(i=e.processInput)?void 0:i.call(e,t))&&!["CapsLock","Tab","Shift","Meta","Escape","Control"].includes(t.key)){if("Backspace"===t.key)return C();if("Delete"===t.key)return(()=>{if(!e.readOnly)return G?(p(G.min),h(void 0),void e.setState((e=>{e.splice(G.min,G.size)}))):void(n!==e.state.length&&e.setState((e=>{e.splice(n,1)})))})();if("ArrowLeft"===t.key)return((e=!1)=>{if(!e&&G)return h(void 0),void p(G.min);0!==n&&(e&&void 0===f&&h(n),p(n-1))})(t.shiftKey);if("ArrowRight"===t.key)return((t=!1)=>{if(!t&&G)return h(void 0),void p(G.max);n!==e.state.length&&(t&&void 0===f&&h(n),p(n+1))})(t.shiftKey);if("ArrowUp"===t.key)return((e=!1)=>{if(!e&&G)return h(void 0),void p(G.min);e&&void 0===f&&h(n),p(q{if(!t&&G)return h(void 0),void p(G.max);t&&void 0===f&&h(n),$>=z.length-1?p(e.state.length):p(R({x:H,y:q+z[$]+z[$+1]/2+I},!1))})(t.shiftKey);if((0,u.metaKeyIfMacElseCtrlKey)(t)){if("a"===t.key)return h(0),void p(e.state.length)}else t.preventDefault()}}else null==(o=e.onComposing)||o.call(e,t)},P=()=>{var t,n;e.keepSelectionOnBlur||h(void 0),null==(t=e.onLocationChanged)||t.call(e,-1),null==(n=e.onBlur)||n.call(e)},k=r.useRef(),[w,_]=r.useState(),S=e=>{const t=e.target.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},R=(t,n=!0)=>{const r=(0,o.getFlowLayoutLocation)(t,z,F,I,e.getWidth,n);return r?(b(r.lineEnd),r.location):F.length-1},A=t=>{t.preventDefault();const r=S(t),o=R(r);if(t.shiftKey)(void 0===f||Math.abs(f-o){if(G)for(let n=G.min;nr.x&&t.y>r.y&&t.x{if(void 0===k.current)return void(void 0!==w&&_(R(S(t),!1)));const n=S(t),r=R(n,!1);p(r),r===k.current?h(void 0):h(k.current),e.autoHeight||(n.y>=0&&n.y<=U?O((e=>B(e+2))):n.y<=e.height&&n.y>=e.height-N&&O((e=>B(e-2))))},M=t=>{var n;T(t),void 0!==w&&G&&(w{e.splice(w,0,...e.splice(G.min,G.size))})),p(w+G.size),h(w)):w>G.max&&(e.setState((e=>{e.splice(w-G.size,0,...e.splice(G.min,G.size))})),p(w),h(w-G.size)),_(void 0)),null==(n=g.current)||n.focus()};(0,c.useGlobalMouseUp)((0,l.useEvent)((()=>{k.current=void 0,_(void 0)})));const{ref:L,y:I,setY:O,filterY:B}=(0,d.useWheelScroll)({minY:e.autoHeight?0:m>e.height?e.height-m:0,maxY:0,disabled:e.autoHeight});r.useEffect((()=>{e.autoHeight&&O(0)}),[e.autoHeight,O]);const{layoutResult:F,newContentHeight:D,lineHeights:z}=(0,o.flowLayout)({state:e.state,width:e.width,height:e.autoHeight?void 0:e.height,lineHeight:e.lineHeight,getWidth:e.getWidth,isNewLineContent:e.isNewLineContent,isPartOfComposition:e.isPartOfComposition,getComposition:e.getComposition,endContent:e.endContent,scrollY:I,align:e.align,verticalAlign:e.verticalAlign});m0&&F[j-1];V&&j--;const W=null!=(t=F[j])?t:F[F.length-1],H=W.x+(V?e.getWidth(F[j].content):0),q=W.y-I,$=W.row,Y=r.useRef(),K=r.useRef();r.useEffect((()=>{if((0,i.equals)(Y.current,n)&&(0,i.equals)(K.current,q)||e.autoHeight)return;const t=q+I;t<0?O(-q):t>e.height-N&&O(e.height-N-q),Y.current=n,K.current=q}),[n,q,I,N]),r.useEffect((()=>{var t;null==(t=e.onLocationChanged)||t.call(e,n)}),[n]);let X=e.height;return e.autoHeight&&m>e.height&&(X=m),{ref:g,range:G,layoutResult:F,lineHeights:z,cursor:{x:H,y:q+I,row:$},backspace:C,inputContent:(t,r=t.length,o=0)=>{if(!e.readOnly){if(G)return p(G.min+r),h(void 0),void e.setState((e=>{e.splice(G.min,G.size,...t)}));p(n+r-o),e.setState((e=>{e.splice(n-o,o,...t)}))}},location:n,setLocation:p,getCopiedContents:(t=!1)=>{if(void 0!==G)return t&&C(),e.state.slice(G.min,G.max)},isSelected:e=>G&&e>=G.min&&er.createElement("div",{style:y({position:"relative",width:e.width+"px",height:X+"px",border:"1px solid black",clipPath:"inset(0px 0px)"},e.style),onMouseLeave:M,ref:L},r.createElement(a.Cursor,{ref:g,onKeyDown:E,onCompositionEnd:e.onCompositionEnd,onBlur:P,onFocus:e.onFocus,readOnly:e.readOnly,autoFocus:e.autoFocus,style:{left:H+"px",top:q+I+"px",height:z[$]+"px"}}),t,r.createElement("div",{onMouseDown:A,onMouseMove:T,onMouseUp:M,onDoubleClick:e.onDoubleClick,style:{inset:"0px",cursor:"text",position:"absolute"}}),!e.autoHeight&&r.createElement(s.Scrollbar,{value:I,type:"vertical",containerSize:e.height,contentSize:m,onChange:O,align:"head"}))}}},7670:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getTextComposition:()=>u,getWordByDoubleClick:()=>c,useFlowLayoutTextEditor:()=>s,useTextComposing:()=>l});var r=n(3696),o=n(8905),i=n(4844),a=n(623);function s(e){const t=`${e.fontSize}px ${e.fontFamily}`,n=e=>{var n,r;return null!=(r=null==(n=(0,o.getTextSizeFromCache)(t,e))?void 0:n.width)?r:0},{onComposing:r,getCompositionCountThenEnd:s}=l(),{inputContent:d,getCopiedContents:p,ref:f,layoutResult:h,cursor:g,location:m,setLocation:y,isSelected:v,renderEditor:x,actualHeight:b,setSelectionStart:C,positionToLocation:E,getPosition:P,backspace:k}=(0,i.useFlowLayoutEditor)({state:e.state,width:e.width,height:e.height,lineHeight:e.lineHeight,setState:e.setState,getWidth:n,processInput(t){var n;if(null==(n=e.processInput)?void 0:n.call(e,t))return!0;if("Enter"===t.key)return w("\n"),!0;if((0,a.metaKeyIfMacElseCtrlKey)(t)){if("v"===t.key)return _(),t.preventDefault(),!0;if("c"===t.key||"x"===t.key){const e=p("x"===t.key);return e&&navigator.clipboard.writeText(e.join("")),!0}}else if(1===t.key.length)return t.preventDefault(),w(t.key),!0;return!1},onLocationChanged:e.onLocationChanged,style:e.style,autoHeight:e.autoHeight,readOnly:e.readOnly,autoFocus:e.autoFocus,onBlur:e.onBlur,onFocus:e.onFocus,isNewLineContent:e=>"\n"===e,isPartOfComposition:e=>(0,o.isWordCharactor)(e),getComposition:t=>u(t,e.state,n,(e=>e)),endContent:"",align:e.align,verticalAlign:e.verticalAlign,onCompositionEnd(e){w(e.data,void 0,s()),f.current&&(f.current.value="")},onDoubleClick(t){const n=E(P(t)),{newSelectionStart:r,newLocation:o}=c(e.state,n,(e=>e));void 0!==r&&C(r),void 0!==o&&y(o)},onComposing(e){r(e,w,k)}}),w=(t,n=t.length,r)=>{if(e.readOnly)return;const o=[];for(const e of t)o.push(e);d(o,n,r)},_=()=>{e.readOnly||navigator.clipboard.readText().then((e=>{e&&w(e)}))};return{layoutResult:h,cursor:g,inputText:w,location:m,setLocation:y,renderEditor:t=>{var r,o,i;const a=[];for(const{x:s,y:l,i:c,content:u,visible:d}of h){if(!d)continue;const p=null!=(o=null==(r=t.getTextColors)?void 0:r.call(t,c))?o:{};v(c)&&(p.backgroundColor=11785981);const f=n(u);void 0!==p.backgroundColor&&a.push(t.target.renderRect(s,l,f,e.lineHeight,{fillColor:p.backgroundColor,strokeWidth:0})),a.push(t.target.renderText(s+f/2,l+e.fontSize,u,null!=(i=p.color)?i:0,e.fontSize,e.fontFamily,{textAlign:"center"}))}t.children&&a.push(...t.children);const s=t.target.renderResult(a,e.width,b);return x(s)}}}function l(){const e=r.useRef(0);return{getCompositionCountThenEnd(){const t=e.current;return e.current=0,t},onComposing(t,n,r){if("Backspace"===t.code&&e.current>0)return e.current--,void r();for(const r of["Key","Digit"])if(t.code.startsWith(r)){const o=t.code.slice(r.length)[0].toLocaleLowerCase();if(o)return e.current+=o.length,void n(o)}}}}function c(e,t,n){let r,i,a,s;for(let i=t-1;i>=0;i--){const t=n(e[i]);if(!t||!(0,o.isWordCharactor)(t))break;r=i}for(let r=t;r{"use strict";n.r(t),n.d(t,{useGlobalKeyDown:()=>o,useGlobalKeyUp:()=>i});var r=n(3696);function o(e){r.useEffect((()=>(window.addEventListener("keydown",e,{passive:!1}),()=>{window.removeEventListener("keydown",e)})),[e])}function i(e){r.useEffect((()=>(window.addEventListener("keyup",e,{passive:!1}),()=>{window.removeEventListener("keyup",e)})),[e])}},135:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useGlobalMouseUp:()=>o});var r=n(3696);function o(e){r.useEffect((()=>(window.addEventListener("mouseup",e,{passive:!1}),()=>{window.removeEventListener("mouseup",e)})),[e])}},4740:(e,t,n)=>{"use strict";n.r(t),n.d(t,{defaultFontFamily:()=>_,defaultFontSize:()=>w,isHtmlText:()=>S,renderHtmlTextStyle:()=>R,useHtmlEditor:()=>C});var r=n(8662),o=n(3696),i=n(2852),a=n(7875),s=n(1324),l=n(6487),c=n(3331),u=n(623),d=n(2432),p=Object.defineProperty,f=Object.defineProperties,h=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,v=(e,t,n)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))m.call(t,n)&&v(e,n,t[n]);if(g)for(var n of g(t))y.call(t,n)&&v(e,n,t[n]);return e},b=(e,t)=>f(e,h(t));function C(e){var t,n,p,f,h,g,m,y,v,C,k,R,A,T,L,I,O,B,F;const D=o.useRef(null),[z,U]=o.useState(),N=o.useRef(),[G,j]=o.useState(!1),[V,W]=o.useState(),{onComposing:H,getCompositionCountThenEnd:q}=(0,a.useTextComposing)(),{range:$,inputContent:Y,inputInline:K,getCopiedContents:X,scrollRef:Z,scrollY:Q,dragLocation:J,setY:ee,selectionStart:te,setSelectionStart:ne,ref:re,setLocation:oe,location:ie,contentHeight:ae,setContentHeight:se,blockLocation:le,contentLocation:ce,actualHeight:ue,isSelected:de,onBlur:pe,onMouseUp:fe,onMouseDown:he,onMouseMove:ge,onKeyDown:me,backspace:ye}=(0,d.useFlowLayoutBlockOperation)(b(x({},e),{onComposing(e){H(e,ke,ye)}})),ve=e=>{var t;const n=$?$.min[0]:ie[0],r=e[n],o=r?ie[1]<=0?0:ie[1]-1:void 0;return{currentBlock:r,currentContent:void 0!==o?r.children[o]:void 0,currentContentLayout:void 0!==n&&void 0!==o&&N.current?null==(t=N.current.cells[n])?void 0:t[o]:void 0}},{currentBlock:xe,currentContent:be,currentContentLayout:Ce}=ve(e.state);let Ee;Ee=be&&V&&!$&&0===(0,a.compareLocations)(V.index,ie)&&S(be)?x(x({},be),V.style):be;const Pe=t=>{var n,r;if(null==(n=e.plugin)?void 0:n.inlines)for(const n of e.plugin.inlines){const o=null==(r=null==n?void 0:n.render)?void 0:r.call(n,t,e.resizeOffset);if(void 0!==o)return o}},ke=(t,n)=>{if(e.readOnly)return;const r=[];for(const e of t)if("string"==typeof e){const t=b(x({},be),{text:e,kind:void 0});V?r.push(x(x({},t),V.style)):r.push(t)}else r.push(x(x({},be),e));K(r,n)},we=(e=!1)=>{var t;if(!e&&$)return ne(void 0),void oe($.min);if(e&&void 0===te&&ne(ie),Ue=0;e--){const t=N.current.rows[e];if(t.y+t.height/2{var t,n;if(!e&&$)return ne(void 0),void oe($.max);e&&void 0===te&&ne(ie);const r=null==(t=N.current)?void 0:t.rows.find((e=>e.y>Ue+Ne/2)),o=r?r.y+r.height/2:Ue+1.5*Ne;oe(Ae({x:ze-(null!=(n=null==z?void 0:z.width)?n:0)/2,y:o+Q}))},Se=t=>{me(t,we,_e,(()=>{if((0,u.metaKeyIfMacElseCtrlKey)(t)){if("v"===t.key)return e.readOnly||navigator.clipboard.readText().then((e=>{if(e)try{const t=JSON.parse(e);1===t.length?K(t[0].children):Y(t)}catch(t){K(e.split("").map((e=>({text:e,kind:void 0}))))}})),void t.preventDefault();if("c"===t.key||"x"===t.key){const e=X("x"===t.key);if(e){const t=(0,i.renderToStaticMarkup)(o.createElement(o.Fragment,null,E(e,(()=>!1),Pe)));navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([JSON.stringify(e)],{type:"text/plain"}),"text/html":new Blob([t],{type:"text/html"})})])}return}}else 1===t.key.length&&ke(t.key)}))},Re=e=>{var t,n,r;const o=null==(t=D.current)?void 0:t.getBoundingClientRect();return{x:e.clientX-(null!=(n=null==o?void 0:o.left)?n:0),y:e.clientY-(null!=(r=null==o?void 0:o.top)?r:0)}},Ae=t=>{if(j(!1),N.current){let n;for(let r=0;r=a.x&&t.y>=a.y&&t.x<=a.x+a.width&&t.y<=a.y+a.height)return S(e.state[r].children[i])&&t.x{if($&&N.current)for(let t=0;t=0&&(0,a.compareLocations)(i,$.max)<0&&e.x>o.x&&e.y>o.y&&e.x{he(e,Re,Ae,Te)},Le=e=>{ge(e,Re,Ae,Q,Be,Fe)},Ie=e=>{Le(e),fe()};o.useLayoutEffect((()=>{D.current&&(N.current=P(D.current.children))}),[e.state,D.current]),o.useEffect((()=>{var e,t;if(!N.current)return;const n=N.current.cells[null!=(e=null==J?void 0:J[0])?e:le];let r;if(n){const e=null!=(t=null==J?void 0:J[1])?t:ce;if(0===e)r=n[0];else if(G){const t=n[e-1];t&&(r=b(x({},t),{x:t.x+t.width}))}else r=n[e]}U(r)}),[N.current,le,ce,J,G]);const Oe=null==(t=D.current)?void 0:t.offsetHeight;Oe&&ae{var t,n;(0,s.equals)(null==(t=Ge.current)?void 0:t[0],ie[0])&&(0,s.equals)(null==(n=Ge.current)?void 0:n[1],ie[1])&&(0,s.equals)(je.current,Ue)||e.autoHeight||(Ue+Q<0&&ee(-Ue),Ge.current=ie,je.current=Ue)}),[ie,Ue,Q]);const Ve=E(e.state,de,Pe);return o.useEffect((()=>{V&&0!==(0,a.compareLocations)(ie,V.index)&&W(void 0)}),[ie,V,W]),{currentContent:Ee,currentBlock:xe,currentContentLayout:Ce,updateSelection:t=>{if($)e.setState((e=>{for(let n=$.min[0];n<=$.max[0];n++){const r=e[n],o=n===$.min[0]?$.min[1]:0,i=n===$.max[0]?$.max[1]:r.children.length;if(0!==o||i!==r.children.length)for(let e=o;e{t(e)}))})}},updateTextInline:t=>{var n;if(!(null==(n=e.plugin)?void 0:n.textInlines))return;const r=e.plugin.textInlines[t];r&&$&&e.setState((e=>{var n;for(let o=$.min[0];o<=$.max[0];o++){const i=e[o],a=o===$.min[0]?$.min[1]:0,s=o===$.max[0]?$.max[1]:i.children.length,l=r.fontSize?r.fontSize*(null!=(n=i.fontSize)?n:w):void 0;for(let e=a;e{var n;if(!(null==(n=e.plugin)?void 0:n.blocks))return;const r=e.plugin.blocks[t];if(!r)return;if(r.void)return void Y([b(x({},r),{type:t,children:[]})]);const o=e=>{var n,o,i;e.type=t;const a=w*(null!=(n=r.fontSize)?n:1);e.blockStart=a*(null!=(o=r.blockStart)?o:0),e.blockEnd=a*(null!=(i=r.blockEnd)?i:0),e.inlineStart=r.inlineStart,e.listStyleType=r.listStyleType,M(e,r),e.fontSize=r.fontSize?a:void 0};$?e.setState((e=>{const t=$.min[0],n=$.max[0];for(let r=t;r<=n;r++)o(e[r])})):e.setState((e=>{const t=ie[0];o(e[t])}))},updateCurrentContent:t=>{e.setState((e=>{const n=ve(e);n.currentContent&&t(n.currentContent)}))},inputText:ke,layoutResult:N.current,cursor:{x:ze,y:Ue+Q,height:Ne},inputContent:Y,location:ie,scrollY:Q,renderEditor:t=>o.createElement("div",{style:x({position:"relative",width:e.width+"px",height:ue+"px",border:"1px solid black",clipPath:"inset(0px 0px)"},e.style),onMouseLeave:Ie,ref:Z},o.createElement(l.Cursor,{ref:re,onKeyDown:Se,onCompositionEnd:e=>{ke(e.data,q()),re.current&&(re.current.value="")},onBlur:pe,onFocus:e.onFocus,readOnly:e.readOnly,style:z?{left:z.x+"px",top:z.y+Q+"px",height:z.height+"px"}:void 0}),o.createElement("div",{style:{width:e.width+"px",position:"absolute",fontFamily:_,fontSize:w+"px",top:`${Q}px`,whiteSpace:"pre-wrap",overflowWrap:"break-word"},onMouseDown:Me,onMouseMove:Le,onMouseUp:Ie,onDoubleClick:t=>{const[n,r]=Ae(Re(t)),{newSelectionStart:o,newLocation:i}=(0,a.getWordByDoubleClick)(e.state[n].children,r,(e=>S(e)?e.text:void 0));void 0!==o&&ne([n,o]),void 0!==i&&oe([n,i])},ref:D},Ve),t,!e.autoHeight&&o.createElement(c.Scrollbar,{value:Q,type:"vertical",containerSize:e.height,contentSize:ae,onChange:ee,align:"head"}))}}function E(e,t,n){const r=[],i=new s.Merger((e=>{const t=A(e.type.block),n=e.target.map((e=>o.createElement("li",{key:e.index},e.children)));r.push(o.createElement(e.type.block.type,{key:e.type.index,style:t},n))}),((e,t)=>e.block.type===t.block.type),(e=>({index:e.index,children:T(e.block,(n=>t([e.index,n])),n)})));for(let a=0;at([a,e])),n);"ul"!==s.type&&"ol"!==s.type?(i.flushLast(),r.push(o.createElement(s.type,{key:a,style:l},c))):i.push({index:a,block:s})}return r}function P(e,t=0){const n={rows:[],cells:[]},r=new s.Reducer((e=>n.rows.push(e)),((e,t)=>t.y>=e.y+e.height),((e,t)=>{t.ye.y+e.height&&(e.height=t.y+t.height-e.y)}));for(let o=0;o0&&(t.textDecoration=n.join(" ")),t}function A(e){const t=R(e);return e.blockStart&&(t.marginBlockStart=`${e.blockStart}px`),e.blockEnd&&(t.marginBlockEnd=`${e.blockEnd}px`),e.inlineStart&&(t.paddingInlineStart=`${e.inlineStart}px`),t}function T(e,t,n){const r=[];return e.children.forEach(((e,i)=>{const a=function(e,t,n,r){var i;const a=null==r?void 0:r(e);if(a)return o.cloneElement(a,{key:t});if(S(e)){const r=R(e);return o.createElement(null!=(i=e.type)?i:"span",{key:t,style:b(x({},r),{backgroundColor:n?"#B3D6FD":r.backgroundColor})},e.text)}}(e,i,t(i),n);a&&r.push(a)})),r.push(o.createElement("span",{key:-1},"​")),r}function M(e,t){e.bold=t.bold,e.italic=t.italic,e.fontFamily=t.fontFamily,e.underline=t.underline,e.passThrough=t.passThrough,e.color=t.color,e.backgroundColor=t.backgroundColor,e.verticalAlign=t.verticalAlign}},9436:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useInterval:()=>o});var r=n(3696);function o(e,t){const n=r.useRef();r.useEffect((()=>{n.current=e}),[e]),r.useEffect((()=>{const e=setInterval((()=>{var e;null==(e=n.current)||e.call(n)}),t);return()=>clearInterval(e)}),[t])}},6278:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useLastValidValue:()=>o});var r=n(3696);function o(e,t,n=e){const o=r.useRef(n);return t(e)&&(o.current=e),o.current}},6545:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useLineAlignment:()=>o});var r=n(3696);function o(e){const[t,n]=r.useState(),[o,i]=r.useState();return{lineAlignmentX:t,lineAlignmentY:o,changeOffsetByLineAlignment(t,r,o,a,s){if(r.includes("bottom")){const n=o.y+o.height+t.y+t.height,r=s.find((t=>Math.abs(t-n)Math.abs(t-n)Math.abs(t-r)Math.abs(t-r){"use strict";n.r(t),n.d(t,{useLocalStorageState:()=>o});var r=n(3696);function o(e,t){const[n,o]=r.useState((()=>{if(!e)return t;const n=localStorage.getItem(e);if(n)try{return JSON.parse(n)}catch(e){return t}return t})),i=r.useRef(n);return r.useEffect((()=>{e&&localStorage.setItem(e,JSON.stringify(n))}),[n,e]),[n,o,i.current]}},8454:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useMinimap:()=>a});var r=n(3696),o=n.n(r),i=n(5773);function a(e){const[t,n]=o().useState();if(!t)return{setMinimapTransform:n};const r=t.bounding.end.x-t.bounding.start.x,a=t.bounding.end.y-t.bounding.start.y,s=Math.min(e.width/r,e.height/a),l=Math.max(0,(e.width-s*r)/2),c=Math.max(0,(e.height-s*a)/2);return{setMinimapTransform:n,xOffset:l,yOffset:c,ratio:s,contentWidth:r,contentHeight:a,getMinimapPosition(n){let r={x:t.bounding.start.x+(n.nativeEvent.offsetX-l)/s,y:t.bounding.start.y+(n.nativeEvent.offsetY-c)/s};return e.viewport.rotate&&(r=(0,i.rotatePosition)(r,{x:0,y:0},e.viewport.rotate)),r},minimap:o().createElement("div",{style:{position:"absolute",left:"1px",bottom:"1px",width:`${e.width}px`,height:`${e.height}px`,clipPath:"inset(0)",border:"1px solid blue"}},e.children(t),o().createElement("div",{style:{position:"absolute",border:"1px solid red",left:`${l+s*(e.viewport.center.x-e.viewport.width/2-t.bounding.start.x)}px`,top:`${c+s*(e.viewport.center.y-e.viewport.height/2-t.bounding.start.y)}px`,width:s*e.viewport.width+"px",height:s*e.viewport.height+"px",cursor:"default",rotate:e.viewport.rotate?`${e.viewport.rotate}rad`:void 0,pointerEvents:"none"}}))}}},9055:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getByPath:()=>g,getItemByPath:()=>m,prependPatchPath:()=>h,usePartialEdit:()=>f});var r=n(3696),o=Object.defineProperty,i=Object.defineProperties,a=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&u(e,n,t[n]);if(s)for(var n of s(t))c.call(t,n)&&u(e,n,t[n]);return e},p=(e,t)=>i(e,a(t));function f(e,t){const[n,o]=r.useState();return{editingContent:g(e,n),setEditingContentPath:n=>{var r;null==(r=null==t?void 0:t.onEditingContentPathChange)||r.call(t,g(e,n)),o(n)},prependPatchPath:(e,t)=>h(h(e,t),n),trimPatchPath:e=>function(e,t){return t&&t.length>0?e.map((e=>p(d({},e),{path:e.path.slice(t.length)}))):e}(e,n),getContentByPath:e=>g(e,n)}}function h(e,t){return t&&t.length>0?e.map((e=>p(d({},e),{path:[...t,...e.path]}))):e}function g(e,t){return t?m(e,t):e}function m(e,t){let n=e;for(const e of t)n=n[e];return n}},2931:(e,t,n)=>{"use strict";n.r(t),n.d(t,{usePatchBasedUndoRedo:()=>a});var r=n(3696),o=n(8662),i=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{s(n.next(e))}catch(e){o(e)}},a=e=>{try{s(n.throw(e))}catch(e){o(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())}));function a(e,t,n){const[a,s]=r.useState({state:e,patchIndex:-1,patches:[]}),l=function(e,n,r){for(let r=e;r>=0;r--)if(n[r][2]===t)return r;return-1/0}(a.patchIndex,a.patches),c=function(e,n,r){for(let r=e;r=0,d=c{var i;const l=(0,o.applyPatches)(a.state,e);if(!1===(null==(i=null==n?void 0:n.onChange)?void 0:i.call(n,{patches:e,oldState:a.state,newState:l})))return a.state;const c=a.patchIndex+1;return s((0,o.produce)(a,(n=>{n.patches.splice(c,n.patches.length,[e,t,(0,o.castDraft)(r)]),n.patchIndex=c,n.state=(0,o.castDraft)(l)}))),l},f=(e,r)=>i(this,null,(function*(){var o;const i=yield null==(o=null==n?void 0:n.onApplyPatchesFromSelf)?void 0:o.call(n,e,r);return i&&(e=i[0],r=i[1]),p(e,r,t)}));return{state:a.state,applyPatchFromOtherOperators:p,applyPatchFromSelf:f,setState:e=>(0,o.produce)(a.state,e,((e,t)=>{0!==e.length&&f(e,t)})),canUndo:u,canRedo:d,undo:e=>i(this,null,(function*(){var t,r;if(null==e||e.preventDefault(),u){let[e,i]=a.patches[l];const c=yield null==(t=null==n?void 0:n.onApplyPatchesFromSelf)?void 0:t.call(n,i,e);c&&(i=c[0],e=c[1],a.patches[l][0]=e,a.patches[l][1]=i);const u=(0,o.applyPatches)(a.state,i);if(!1===(null==(r=null==n?void 0:n.onChange)?void 0:r.call(n,{patches:i,oldState:a.state,newState:u})))return;s((0,o.produce)(a,(e=>{e.patchIndex=l-1,e.state=(0,o.castDraft)(u)})))}})),redo:e=>i(this,null,(function*(){var t,r;if(null==e||e.preventDefault(),d){let[e,i]=a.patches[c];const u=yield null==(t=null==n?void 0:n.onApplyPatchesFromSelf)?void 0:t.call(n,e,i);u&&(e=u[0],i=u[1],a.patches[l][0]=e,a.patches[l][1]=i);const d=(0,o.applyPatches)(a.state,e);if(!1===(null==(r=null==n?void 0:n.onChange)?void 0:r.call(n,{patches:e,oldState:a.state,newState:d})))return;s((0,o.produce)(a,(e=>{e.patchIndex=c,e.state=(0,o.castDraft)(d)})))}})),stateIndex:a.patchIndex}}},2244:(e,t,n)=>{"use strict";n.r(t),n.d(t,{allSnapTypes:()=>_,usePointSnap:()=>w});var r=n(3696),o=n(8638),i=n(5773),a=n(5717),s=n(7486),l=n(2792),c=n(1796),u=n(8392),d=n(8230),p=n(8831),f=n(1715),h=n(2298),g=n(5689),m=Object.defineProperty,y=Object.defineProperties,v=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,b=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,E=(e,t,n)=>t in e?m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))b.call(t,n)&&E(e,n,t[n]);if(x)for(var n of x(t))C.call(t,n)&&E(e,n,t[n]);return e},k=(e,t)=>y(e,v(t));function w(e,t,n,m,y,v=5,x=(e=>({x:Math.round(e.x),y:Math.round(e.y)})),b=(e=>{const t=45*Math.round(e/45);if(t!==e&&Math.abs(t-e)<5)return t})){const[C,E]=r.useState();r.useEffect((()=>{!1===e&&E(void 0)}),[e]);const w=e=>y?{position:{x:e.x+y.x,y:e.y+y.y}}:{position:e},_=(e,t,n,r)=>{var o;const i=null==(o=null==e?void 0:e.getGeometries)?void 0:o.call(e,t,r).lines;if(!i)return;const s=(0,a.getGeometryLinesParamAtPoint)(n,i);return void 0!==s?{target:{snapIndex:-1,content:t,param:s}}:void 0},S=(e,t)=>e?k(P({},t),{position:e(t.position)}):t,R=(e,t)=>{E(t&&e?P(P({},t),e(t)):t)};return{snapPoint:C,getSnapAssistentContents(e,t,n){const r=[],o=[];C&&(o.push(C),y&&o.push(k(P({},C),{x:C.x+y.x,y:C.y+y.y})));for(const i of o){const o=2*v;"center"===i.type?r.push(e({x:i.x,y:i.y,r:o})):"endpoint"===i.type?r.push(t({x:i.x,y:i.y,width:2*o,height:2*o})):"midpoint"===i.type?r.push(n([{x:i.x-o,y:i.y+o},{x:i.x+o,y:i.y+o},{x:i.x,y:i.y-o},{x:i.x-o,y:i.y+o}])):"intersection"===i.type?r.push(n([{x:i.x-o,y:i.y-o},{x:i.x+o,y:i.y+o}]),n([{x:i.x-o,y:i.y+o},{x:i.x+o,y:i.y-o}])):"nearest"===i.type?r.push(n([{x:i.x-o,y:i.y-o},{x:i.x+o,y:i.y+o},{x:i.x-o,y:i.y+o},{x:i.x+o,y:i.y-o},{x:i.x-o,y:i.y-o}])):"perpendicular"===i.type?(r.push(n([{x:i.x-1.5*o,y:i.y},{x:i.x+1.5*o,y:i.y}])),r.push(n([{x:i.x,y:i.y-1.5*o},{x:i.x,y:i.y}]))):"tangency"===i.type&&(r.push(e({x:i.x,y:i.y+.5*o,r:o})),r.push(n([{x:i.x-1.5*o,y:i.y-.5*o},{x:i.x+1.5*o,y:i.y-.5*o}])))}return r},getSnapPoint(r,a,y,C,E){var A,T;if(!e)return R(E,void 0),S(E,w(r));let M=a;y&&(M=y({start:{x:r.x-v,y:r.y-v},end:{x:r.x+v,y:r.y+v}}));for(const e of M){if(!e)continue;const t=null==(T=null==(A=m(e))?void 0:A.getSnapPoints)?void 0:T.call(A,e,a);if(t)for(let o=0;o{"use strict";n.r(t),n.d(t,{useRefState:()=>i,useRefState2:()=>a});var r=n(3696),o=n.n(r);function i(e){const[t,n]=o().useState(e),r=o().useRef(e);return[t,e=>{n(e),r.current=e},r]}function a(){const[e,t]=o().useState(),n=o().useRef();return[e,e=>{t(e),n.current=e},n]}},7923:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useRegionAlignment:()=>o});var r=n(3696);function o(e){const[t,n]=r.useState(),[o,i]=r.useState();return{regionAlignmentX:t,regionAlignmentY:o,changeOffsetByRegionAlignment(t,r,o){const a=function(e,t,n,r){const o=n.x+e.x,i=n.y+e.y,a={};for(const{field:e,value:s,sizeField:l}of[{field:"x",value:o,sizeField:"width"},{field:"y",value:i,sizeField:"height"}]){let o=r.find((n=>Math.abs(n[e]-s)Math.abs(n[e]+n[l]/2-i)Math.abs(n[e]+n[l]-i){"use strict";n.r(t),n.d(t,{useSelectBeforeOperate:()=>i});var r=n(3696),o=n(7332);function i(e,t,n){const{selected:i,isSelected:a,addSelection:s,removeSelection:l,filterSelection:c,setSelected:u,onSelectedKeyDown:d}=(0,o.useSelected)(n),[p,f]=r.useState({type:"select",select:e}),h=()=>{f({type:"select",select:e})},g=(e=i)=>{if("select then operate"===p.type){if(t(p.operate,e))return;f({type:"operate",operate:p.operate})}};let m="";"select then operate"===p.type&&(m=void 0!==p.select.count?`${i.length} selected, extra ${p.select.count-i.length} targets are needed`:i.length?`${i.length} selected, press Enter to finish selection`:"select targets");const y=e=>{var t,n,r;return!a(e)&&"operate"!==p.type&&(null==(r=null==(n=(t=p.select).selectable)?void 0:n.call(t,e))||r)};return{message:m,selected:i,isSelected:a,addSelection(...e){s(e,"operate"!==p.type?p.select.count:void 0,g,y)},removeSelection(...e){l(e)},setSelected:u,filterSelection:c,isSelectable:y,operations:p,executeOperation:t,startNextOperation:g,resetOperation:h,onSelectBeforeOperateKeyDown(e){"Escape"===e.key?h():"Enter"===e.key&&g(),d(e)},selectBeforeOperate(e,t){f({type:"select then operate",select:e,operate:t})},operate(e){f({type:"operate",operate:e})}}}},7332:(e,t,n)=>{"use strict";n.r(t),n.d(t,{isSamePath:()=>a,isSelected:()=>i,useSelected:()=>o});var r=n(3696);function o(e){const[t,n]=r.useState([]);return r.useEffect((()=>{var n;null==(n=null==e?void 0:e.onChange)||n.call(e,t)}),[t]),{selected:t,filterSelection:(r,o=(null==e?void 0:e.maxCount),i=t)=>{let a=r?i.filter(r):i;return void 0!==o&&(a=a.slice(-o)),n(a),{result:a,needSelect:void 0===o?0===a.length:a.lengthi(e,n),addSelection:(r,o=(null==e?void 0:e.maxCount),s,l)=>{if((r=r.filter((e=>{var n;return!i(e,t)&&(null==(n=null==l?void 0:l(e))||n)&&t.every((t=>!a(t,e)))}))).length>0){let e=[...t,...r];void 0!==o&&(e=e.slice(-o)),n(e),void 0!==o&&o===e.length&&(null==s||s(e))}},removeSelection:e=>{n(t.filter((t=>e.every((e=>!a(e,t))))))},onSelectedKeyDown(e){"Escape"===e.key&&n([])},setSelected(...e){const r=e.filter((e=>void 0!==e));0===r.length&&0===t.length||n(r)}}}function i(e,t){return t.some((t=>a(e,t)))}function a(e,t){if(e&&t){if(e.length!==t.length)return!1;for(let n=0;n{"use strict";n.r(t),n.d(t,{useUndoRedo:()=>i});var r=n(3696),o=n(8662);function i(e){const[t,n]=r.useState({states:[e],stateIndex:0}),{stateIndex:i,states:a}=t,s=i>0,l=i{const r=(0,o.produce)(c,e);if(r===c)return c;const a=i+1;return n((0,o.produce)(t,(e=>{e.states.splice(a,e.states.length,(0,o.castDraft)(r)),e.stateIndex=a}))),r},canUndo:s,canRedo:l,undo:e=>{null==e||e.preventDefault(),s&&n((0,o.produce)(t,(e=>{e.stateIndex=i-1})))},redo:e=>{null==e||e.preventDefault(),l&&n((0,o.produce)(t,(e=>{e.stateIndex=i+1})))},resetHistory:(t=e)=>{n({states:[t],stateIndex:0})}}}},69:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useValueChanged:()=>o});var r=n(3696);function o(e,t){const n=r.useRef(e);n.current!==e&&(t(n.current)||(n.current=e))}},9182:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useWheelScroll:()=>i});var r=n(3696),o=n(7658);function i(e){var t,n,i,a,s,l;const c=null!=(t=null==e?void 0:e.maxOffsetX)?t:-1,u=null!=(n=null==e?void 0:e.maxOffsetY)?n:-1,d=null==e?void 0:e.minX,p=null==e?void 0:e.maxX,f=null==e?void 0:e.minY,h=null==e?void 0:e.maxY,[g,m]=(0,o.useLocalStorageState)(null==e?void 0:e.localStorageXKey,null!=(a=null==(i=null==e?void 0:e.initialPosition)?void 0:i.x)?a:0),[y,v]=(0,o.useLocalStorageState)(null==e?void 0:e.localStorageYKey,null!=(l=null==(s=null==e?void 0:e.initialPosition)?void 0:s.y)?l:0),x=r.useRef(null),b=e=>(void 0!==d&&(e=Math.max(d,e)),void 0!==p&&(e=Math.min(p,e)),c>=0&&(e=Math.max(-c,Math.min(c,e))),e),C=e=>(void 0!==f&&(e=Math.max(f,e)),void 0!==h&&(e=Math.min(h,e)),u>=0&&(e=Math.max(-u,Math.min(u,e))),e);return r.useEffect((()=>{if(!x.current||(null==e?void 0:e.disabled))return;const t=t=>{t.ctrlKey||(t.preventDefault(),(null==e?void 0:e.setXOffset)?e.setXOffset(-t.deltaX):m((e=>b(e-t.deltaX))),(null==e?void 0:e.setYOffset)?e.setYOffset(-t.deltaY):v((e=>C(e-t.deltaY))))};return x.current.addEventListener("wheel",t,{passive:!1}),()=>{var e;null==(e=x.current)||e.removeEventListener("wheel",t)}}),[x.current,b,C,null==e?void 0:e.disabled]),{ref:x,x:g,y,setX:m,setY:v,filterX:b,filterY:C}}},4104:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useWheelZoom:()=>a});var r=n(3696),o=n(7658),i=n(370);function a(e){var t;const[n,a]=(0,o.useLocalStorageState)(null==e?void 0:e.localStorageKey,null!=(t=null==e?void 0:e.initialValue)?t:1),s=r.useRef(null),{min:l,max:c}=(0,i.getDefaultZoomOption)(e);return r.useEffect((()=>{if(!s.current)return;const t=t=>{if(t.ctrlKey){if(t.preventDefault(),null==e?void 0:e.setScaleOffset)return void e.setScaleOffset(Math.exp(-t.deltaY/100),{x:t.clientX,y:t.clientY});a((n=>{var r;const o=Math.min(Math.max(l,n*Math.exp(-t.deltaY/100)),c);return n!==o&&(null==(r=null==e?void 0:e.onChange)||r.call(e,n,o,{x:t.clientX,y:t.clientY})),o}))}};return s.current.addEventListener("wheel",t,{passive:!1}),()=>{var e;null==(e=s.current)||e.removeEventListener("wheel",t)}}),[s.current,null==e?void 0:e.setScaleOffset]),{ref:s,scale:n,setScale:a}}},6421:(e,t,n)=>{"use strict";n.r(t),n.d(t,{useWindowSize:()=>o});var r=n(3696);function o(){const[e,t]=r.useState({width:window.innerWidth,height:window.innerHeight}),n=r.useRef();return window.addEventListener("resize",(()=>{n.current&&clearTimeout(n.current),n.current=setTimeout((()=>{t({width:window.innerWidth,height:window.innerHeight})}),500)})),e}},370:(e,t,n)=>{"use strict";function r(e,t,n){var r;const{min:i,max:a}=o(n),s=null!=(r=null==n?void 0:n.step)?r:1.25,l=n=>{n!==e&&(n>a?n=a:ni,zoomIn:t=>{null==t||t.preventDefault(),l(e*s)},zoomOut:t=>{null==t||t.preventDefault(),l(e/s)}}}function o(e){var t,n;return{min:null!=(t=null==e?void 0:e.min)?t:.1,max:null!=(n=null==e?void 0:e.max)?n:10}}n.r(t),n.d(t,{getDefaultZoomOption:()=>o,useZoom:()=>r})},2202:(e,t,n)=>{"use strict";n.r(t),n.d(t,{createWebgl3DRenderer:()=>v,get3dPolygonTriangles:()=>x,getAxesGraphics:()=>C,getDashedLine:()=>b});var r=n(9397),o=n(5230),i=n.n(o),a=n(3975),s=n(7713),l=n(7764),c=Object.defineProperty,u=Object.defineProperties,d=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))f.call(t,n)&&g(e,n,t[n]);if(p)for(var n of p(t))h.call(t,n)&&g(e,n,t[n]);return e},y=(e,t)=>u(e,d(t));function v(e){const t=e.getContext("webgl",{antialias:!0,stencil:!0,premultipliedAlpha:!1});if(!t)return;t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA);const n=new l.Lazy((()=>r.createProgramInfo(t,["\n uniform mat4 u_worldViewProjection;\n uniform vec3 u_lightWorldPos;\n uniform mat4 u_world;\n uniform mat4 u_viewInverse;\n uniform mat4 u_worldInverseTranspose;\n\n attribute vec4 position;\n attribute vec3 normal;\n attribute vec2 texcoord;\n\n varying vec4 v_position;\n varying vec2 v_texCoord;\n varying vec3 v_normal;\n varying vec3 v_surfaceToLight;\n varying vec3 v_surfaceToView;\n\n void main() {\n v_texCoord = texcoord;\n v_position = (u_worldViewProjection * position);\n v_normal = (u_worldInverseTranspose * vec4(normal, 0)).xyz;\n v_surfaceToLight = u_lightWorldPos - (u_world * position).xyz;\n v_surfaceToView = (u_viewInverse[3] - (u_world * position)).xyz;\n gl_Position = v_position;\n }\n ","\n precision mediump float;\n\n varying vec4 v_position;\n varying vec2 v_texCoord;\n varying vec3 v_normal;\n varying vec3 v_surfaceToLight;\n varying vec3 v_surfaceToView;\n\n uniform vec4 u_lightColor;\n uniform vec4 u_diffuseMult;\n uniform sampler2D u_diffuse;\n uniform vec4 u_specular;\n uniform float u_shininess;\n uniform float u_specularFactor;\n\n vec4 lit(float l ,float h, float m) {\n return vec4(1.0,\n abs(l),//max(l, 0.0),\n (l > 0.0) ? pow(max(0.0, h), m) : 0.0,\n 1.0);\n }\n\n void main() {\n vec4 diffuseColor = texture2D(u_diffuse, v_texCoord) * u_diffuseMult;\n vec3 normal = normalize(v_normal);\n vec3 surfaceToLight = normalize(v_surfaceToLight);\n vec3 surfaceToView = normalize(v_surfaceToView);\n vec3 halfVector = normalize(surfaceToLight + surfaceToView);\n vec4 litR = lit(dot(normal, surfaceToLight),\n dot(normal, halfVector), u_shininess);\n vec4 outColor = vec4((\n u_lightColor * (diffuseColor * litR.y +\n u_specular * litR.z * u_specularFactor)).rgb,\n diffuseColor.a);\n gl_FragColor = outColor;\n }"]))),o=new l.Lazy((()=>r.createProgramInfo(t,["\n uniform mat4 u_worldViewProjection;\n attribute vec4 position;\n\n void main() {\n gl_Position = u_worldViewProjection * position;\n }\n ","\n precision mediump float;\n uniform vec4 u_diffuseMult;\n\n void main() {\n gl_FragColor = u_diffuseMult;\n }"]))),i=new l.Lazy((()=>r.createProgramInfo(t,["\n uniform mat4 u_worldViewProjection;\n\n attribute vec4 position;\n attribute vec2 texcoord;\n\n varying vec2 v_texCoord;\n\n void main() {\n v_texCoord = texcoord;\n gl_Position = u_worldViewProjection * position;\n }\n ","\n precision mediump float;\n\n varying vec2 v_texCoord;\n\n uniform float u_threshhold;\n uniform vec4 u_pickColor;\n uniform vec4 u_diffuseMult;\n uniform sampler2D u_diffuse;\n\n void main() {\n vec4 diffuseColor = texture2D(u_diffuse, v_texCoord) * u_diffuseMult;\n if (diffuseColor.a <= u_threshhold) {\n discard;\n }\n gl_FragColor = u_pickColor;\n }\n "]))),c=r.createTexture(t,{min:t.NEAREST,mag:t.NEAREST,src:[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]}),u=new s.WeakmapCache,d=r.createFramebufferInfo(t);let p=[];return{render:(s,{eye:l,up:d,fov:f,near:h,far:g,target:v},b,C)=>{r.resizeCanvasToDisplaySize(e),r.bindFramebufferInfo(t,null),t.viewport(0,0,t.canvas.width,t.canvas.height),t.enable(t.DEPTH_TEST),t.clearColor(...C),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT);const E=r.m4.perspective(f,e.clientWidth/e.clientHeight,h,g),P=r.m4.lookAt(l,v,d),k=r.m4.multiply(E,r.m4.inverse(P)),w={u_lightWorldPos:b.position,u_lightColor:b.color,u_specular:b.specular,u_shininess:b.shininess,u_specularFactor:b.specularFactor,u_diffuse:c,u_viewInverse:P,u_threshhold:.1},_=[];p=[],s.forEach(((e,s)=>{if(!e)return void p.push(void 0);let l,c=r.m4.identity();e.rotateY&&(c=r.m4.rotateY(c,e.rotateY)),e.position&&(c=r.m4.translate(c,e.position)),l="lines"===e.geometry.type||"line strip"===e.geometry.type||"triangles"===e.geometry.type||"triangle strip"===e.geometry.type||"polygon"===e.geometry.type?o.instance:n.instance;const d={programInfo:l,bufferInfo:u.get(e.geometry,(()=>"sphere"===e.geometry.type?r.primitives.createSphereBufferInfo(t,e.geometry.radius,72,36):"cube"===e.geometry.type?r.primitives.createCubeBufferInfo(t,e.geometry.size):"cylinder"===e.geometry.type?r.primitives.createCylinderBufferInfo(t,e.geometry.radius,e.geometry.height,36,4):"cone"===e.geometry.type?r.primitives.createTruncatedConeBufferInfo(t,e.geometry.bottomRadius,e.geometry.topRadius,e.geometry.height,36,4):"polygon"===e.geometry.type?r.createBufferInfoFromArrays(t,{position:{numComponents:3,data:x(e.geometry.points)}}):"vertices"===e.geometry.type?r.createBufferInfoFromArrays(t,e.geometry.vertices):r.createBufferInfoFromArrays(t,{position:{numComponents:3,data:e.geometry.points}}))),type:"lines"===e.geometry.type?t.LINES:"line strip"===e.geometry.type?t.LINE_STRIP:"triangle strip"===e.geometry.type?t.TRIANGLE_STRIP:t.TRIANGLES,uniforms:y(m({},w),{u_diffuseMult:e.color,u_world:c,u_worldInverseTranspose:r.m4.transpose(r.m4.inverse(c)),u_worldViewProjection:r.m4.multiply(k,c),u_pickColor:(0,a.colorNumberToRec)(s)})};_.push(d),p.push({graphic:e,index:s,drawObject:y(m({},d),{programInfo:i.instance})})})),r.drawObjectList(t,_)},pick:(n,o,i=(()=>!0))=>{const s=e.getBoundingClientRect(),l=e.clientWidth,c=e.clientHeight,u=(n-s.left)*t.canvas.width/l|0,f=t.canvas.height-((o-s.top)*t.canvas.height/c|0)-1;r.resizeFramebufferInfo(t,d),r.bindFramebufferInfo(t,d),t.clearColor(1,1,1,1),t.enable(t.DEPTH_TEST),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT),r.drawObjectList(t,p.filter((e=>!!e&&i(e.graphic,e.index))).map((e=>e.drawObject)));const h=new Uint8Array(4);t.readPixels(u,f,1,1,t.RGBA,t.UNSIGNED_BYTE,h);const g=(0,a.pixelColorToColorNumber)(h);return 16777215===g?void 0:g}}}function x(e){const t=i()(e,void 0,3),n=[];for(let r=0;ri){s.push(l,t);break}const o=r.v3.add(e,r.v3.mulScalar(a,c));if(s.push(l,[o[0],o[1],o[2]]),c+=n,c>=i)break;const u=r.v3.add(e,r.v3.mulScalar(a,c));l=[u[0],u[1],u[2]]}return s}const C=(e=100)=>[{geometry:{type:"lines",points:[0,0,0,e,0,0]},color:[1,0,0,1]},{geometry:{type:"lines",points:[0,0,0,0,e,0]},color:[0,1,0,1]},{geometry:{type:"lines",points:[0,0,0,0,0,e]},color:[0,0,1,1]}]},9201:(e,t,n)=>{"use strict";n.r(t),n.d(t,{createWebgpu3DRenderer:()=>u});var r=n(9397),o=n(7713),i=n(2202),a=n(7764),s=n(4840),l=n(3975),c=(e,t,n)=>new Promise(((r,o)=>{var i=e=>{try{s(n.next(e))}catch(e){o(e)}},a=e=>{try{s(n.throw(e))}catch(e){o(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,a);s((n=n.apply(e,t)).next())}));function u(e){return c(this,null,(function*(){if(!navigator.gpu)return;const t=e.getContext("webgpu");if(!t)return;const n=yield navigator.gpu.requestAdapter();if(!n)return;const u=yield n.requestDevice(),f=navigator.gpu.getPreferredCanvasFormat();t.configure({device:u,format:f});const h={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"},alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha"}},g=new a.Lazy((()=>u.createShaderModule({code:"struct Uniforms {\n worldViewProjection: mat4x4f,\n lightWorldPos: vec3f,\n world: mat4x4f,\n viewInverse: mat4x4f,\n worldInverseTranspose: mat4x4f,\n lightColor: vec4f,\n diffuseMult: vec4f,\n shininess: f32,\n specular: vec4f,\n specularFactor: f32,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexInput {\n @location(0) position: vec4f,\n @location(1) normal: vec3f,\n @location(2) texcoord: vec2f,\n };\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n @location(1) normal: vec3f,\n @location(2) surfaceToLight: vec3f,\n @location(3) surfaceToView: vec3f,\n };\n\n fn lit(l: f32, h: f32, m: f32) -> vec4f {\n var a: f32 = 0.0;\n if l > 0.0 {\n a = pow(max(0.0, h), m);\n }\n return vec4f(1.0, abs(l), a, 1.0);\n }\n \n @vertex\n fn vertex_main(v: VertexInput) -> VertexOutput {\n var vsOut: VertexOutput;\n vsOut.position = uniforms.worldViewProjection * v.position;\n vsOut.texcoord = v.texcoord;\n vsOut.normal = (uniforms.worldInverseTranspose * vec4f(v.normal, 0.0)).xyz;\n vsOut.surfaceToLight = uniforms.lightWorldPos - (uniforms.world * v.position).xyz;\n vsOut.surfaceToView = (uniforms.viewInverse[3] - (uniforms.world * v.position)).xyz;\n return vsOut;\n }\n\n @fragment\n fn fragment_main(v: VertexOutput) -> @location(0) vec4f {\n var diffuseColor = textureSample(myTexture, mySampler, v.texcoord) * uniforms.diffuseMult;\n var normal = normalize(v.normal);\n var surfaceToLight = normalize(v.surfaceToLight);\n var surfaceToView = normalize(v.surfaceToView);\n var halfVector = normalize(surfaceToLight + surfaceToView);\n var litR = lit(dot(normal, surfaceToLight), dot(normal, halfVector), uniforms.shininess);\n return vec4((uniforms.lightColor * (diffuseColor * litR.y + uniforms.specular * litR.z * uniforms.specularFactor)).rgb, diffuseColor.a);\n }"}))),m=new a.Lazy((()=>u.createShaderModule({code:"struct Uniforms {\n worldViewProjection: mat4x4f,\n lightWorldPos: vec3f,\n world: mat4x4f,\n viewInverse: mat4x4f,\n worldInverseTranspose: mat4x4f,\n lightColor: vec4f,\n diffuseMult: vec4f,\n shininess: f32,\n specular: vec4f,\n specularFactor: f32,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n\n @vertex\n fn vertex_main(@location(0) position: vec4f) -> @builtin(position) vec4f\n {\n return uniforms.worldViewProjection * position;\n }\n\n @fragment\n fn fragment_main() -> @location(0) vec4f\n {\n return uniforms.diffuseMult;\n }"}))),y=new a.Lazy((()=>u.createShaderModule({code:"struct Uniforms {\n worldViewProjection: mat4x4f,\n lightWorldPos: vec3f,\n world: mat4x4f,\n viewInverse: mat4x4f,\n worldInverseTranspose: mat4x4f,\n lightColor: vec4f,\n diffuseMult: vec4f,\n shininess: f32,\n specular: vec4f,\n specularFactor: f32,\n pickColor: vec4f,\n threshhold: f32,\n };\n @group(0) @binding(0) var uniforms: Uniforms;\n @group(0) @binding(1) var mySampler: sampler;\n @group(0) @binding(2) var myTexture: texture_2d;\n\n struct VertexInput {\n @location(0) position: vec4f,\n @location(1) texcoord: vec2f,\n };\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) texcoord: vec2f,\n };\n\n @vertex\n fn vertex_main(v: VertexInput) -> VertexOutput {\n var vsOut: VertexOutput;\n vsOut.position = uniforms.worldViewProjection * v.position;\n vsOut.texcoord = v.texcoord;\n return vsOut;\n }\n\n @fragment\n fn fragment_main(v: VertexOutput) -> @location(0) vec4f {\n var diffuseColor = textureSample(myTexture, mySampler, v.texcoord) * uniforms.diffuseMult;\n if (diffuseColor.a <= uniforms.threshhold) {\n discard;\n }\n return uniforms.pickColor;\n }"}))),v=u.createSampler({magFilter:"nearest",minFilter:"nearest"}),x=new a.Lazy((()=>u.createTexture({size:[e.width,e.height],sampleCount:4,format:f,usage:GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),b=new a.Lazy((()=>u.createTexture({size:[e.width,e.height],format:"depth24plus",sampleCount:4,usage:GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),C=u.createTexture({size:[2,2],format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST});u.queue.writeTexture({texture:C},new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]),{bytesPerRow:8,rowsPerImage:2},{width:2,height:2});const E=new a.Lazy((()=>u.createTexture({size:[e.width,e.height],format:f,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT})),(e=>e.destroy())),P=new o.MapCache,k=new o.MapCache,w=new o.WeakmapCache;let _=[];return{render:(n,{eye:o,up:a,fov:c,near:y,far:k,target:S},R,A)=>{e.width===x.instance.width&&e.height===x.instance.height||(x.reset(),b.reset(),E.reset());const T=u.createCommandEncoder(),M=T.beginRenderPass({colorAttachments:[{clearValue:A,loadOp:"clear",storeOp:"store",view:x.instance.createView(),resolveTarget:t.getCurrentTexture().createView()}],depthStencilAttachment:{view:b.instance.createView(),depthClearValue:1,depthLoadOp:"clear",depthStoreOp:"store"}}),L=r.m4.perspective(c,e.clientWidth/e.clientHeight,y,k),I=r.m4.lookAt(o,S,a),O=r.m4.multiply(L,r.m4.inverse(I));_=[],n.forEach(((e,t)=>{if(!e)return void _.push(void 0);let n=r.m4.identity();e.rotateY&&(n=r.m4.rotateY(n,e.rotateY)),e.position&&(n=r.m4.translate(n,e.position));const o=P.get(e.geometry.type,(()=>{let t;const n=[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]}];return"lines"===e.geometry.type||"line strip"===e.geometry.type||"triangles"===e.geometry.type||"triangle strip"===e.geometry.type||"polygon"===e.geometry.type?t=m.instance:(t=g.instance,n.push({arrayStride:12,attributes:[{shaderLocation:1,offset:0,format:"float32x3"}]},{arrayStride:8,attributes:[{shaderLocation:2,offset:0,format:"float32x2"}]})),u.createRenderPipeline({vertex:{module:t,entryPoint:"vertex_main",buffers:n},fragment:{module:t,entryPoint:"fragment_main",targets:[{format:f,blend:h}]},primitive:{cullMode:"back",topology:"lines"===e.geometry.type?"line-list":"line strip"===e.geometry.type?"line-strip":"triangle strip"===e.geometry.type?"triangle-strip":"triangle-list"},depthStencil:{depthWriteEnabled:!0,depthCompare:"less",format:"depth24plus"},multisample:{count:4},layout:"auto"})}));M.setPipeline(o);const a=[{binding:0,resource:{buffer:(0,s.createUniformsBuffer)(u,[{type:"mat4x4",value:r.m4.multiply(O,n)},{type:"vec3",value:R.position},{type:"mat4x4",value:n},{type:"mat4x4",value:I},{type:"mat4x4",value:r.m4.transpose(r.m4.inverse(n))},{type:"vec4",value:R.color},{type:"vec4",value:e.color},{type:"number",value:R.shininess},{type:"vec4",value:R.specular},{type:"number",value:R.specularFactor},{type:"vec4",value:(0,l.colorNumberToRec)(t)},{type:"number",value:.1}])}}];"lines"!==e.geometry.type&&"line strip"!==e.geometry.type&&"triangles"!==e.geometry.type&&"triangle strip"!==e.geometry.type&&"polygon"!==e.geometry.type&&a.push({binding:1,resource:v},{binding:2,resource:C.createView()}),M.setBindGroup(0,u.createBindGroup({layout:o.getBindGroupLayout(0),entries:a}));const{positionBuffer:c,primaryBuffers:y,count:x}=w.get(e.geometry,(()=>"sphere"===e.geometry.type?p(u,r.primitives.createSphereVertices(e.geometry.radius,72,36)):"cube"===e.geometry.type?p(u,r.primitives.createCubeVertices(e.geometry.size)):"cylinder"===e.geometry.type?p(u,r.primitives.createCylinderVertices(e.geometry.radius,e.geometry.height,36,4)):"cone"===e.geometry.type?p(u,r.primitives.createTruncatedConeVertices(e.geometry.bottomRadius,e.geometry.topRadius,e.geometry.height,36,4)):"polygon"===e.geometry.type?{positionBuffer:d(u,new Float32Array((0,i.get3dPolygonTriangles)(e.geometry.points))),count:e.geometry.points.length/3}:"vertices"===e.geometry.type?p(u,e.geometry.vertices):{positionBuffer:d(u,new Float32Array(e.geometry.points)),count:e.geometry.points.length/3}));M.setVertexBuffer(0,c),y?(M.setVertexBuffer(1,y.normalBuffer),M.setVertexBuffer(2,y.texcoordBuffer),M.setIndexBuffer(y.indicesBuffer,"uint16"),M.drawIndexed(x)):M.draw(x),_.push({graphic:e,index:t,bindGroupEntries:a,positionBuffer:c,primaryBuffers:y,count:x})})),M.end(),u.queue.submit([T.finish()])},pick:(t,n,r=(()=>!0))=>c(this,null,(function*(){const o=e.getBoundingClientRect(),i=e.clientWidth,a=e.clientHeight,s=(t-o.left)*e.width/i|0,c=(n-o.top)*e.height/a|0,d=u.createCommandEncoder(),p=d.beginRenderPass({colorAttachments:[{clearValue:[1,1,1,1],loadOp:"clear",storeOp:"store",view:x.instance.createView(),resolveTarget:E.instance.createView()}],depthStencilAttachment:{view:b.instance.createView(),depthClearValue:1,depthLoadOp:"clear",depthStoreOp:"store"}});for(const e of _)if(e&&r(e.graphic,e.index)){const t=e.graphic,n=k.get(t.geometry.type,(()=>{const e=y.instance;return u.createRenderPipeline({vertex:{module:e,entryPoint:"vertex_main",buffers:[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]},{arrayStride:8,attributes:[{shaderLocation:1,offset:0,format:"float32x2"}]}]},fragment:{module:e,entryPoint:"fragment_main",targets:[{format:f,blend:h}]},primitive:{cullMode:"back",topology:"lines"===t.geometry.type?"line-list":"line strip"===t.geometry.type?"line-strip":"triangle strip"===t.geometry.type?"triangle-strip":"triangle-list"},depthStencil:{depthWriteEnabled:!0,depthCompare:"less",format:"depth24plus"},multisample:{count:4},layout:"auto"})}));p.setPipeline(n),p.setBindGroup(0,u.createBindGroup({layout:n.getBindGroupLayout(0),entries:e.bindGroupEntries})),p.setVertexBuffer(0,e.positionBuffer),e.primaryBuffers?(p.setVertexBuffer(1,e.primaryBuffers.texcoordBuffer),p.setIndexBuffer(e.primaryBuffers.indicesBuffer,"uint16"),p.drawIndexed(e.count)):p.draw(e.count)}p.end(),u.queue.submit([d.finish()]);const g=u.createCommandEncoder(),m=u.createBuffer({size:4,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST});g.copyTextureToBuffer({texture:E.instance,origin:{x:s,y:c}},{buffer:m},{width:1,height:1}),u.queue.submit([g.finish()]),yield m.mapAsync(1,0,4);const v=new Uint8Array(m.getMappedRange(0,4)),C=(0,l.pixelColorToColorNumber)([v[2],v[1],v[0]]);return 16777215===C?void 0:C}))}}))}function d(e,t){const n=e.createBuffer({size:t.byteLength,usage:GPUBufferUsage.VERTEX,mappedAtCreation:!0});return new Float32Array(n.getMappedRange()).set(t),n.unmap(),n}function p(e,t){const{position:n,normal:r,texcoord:o,indices:i}=t,a=d(e,n),s=d(e,r),l=d(e,o),c=function(e,t){const n=e.createBuffer({size:t.byteLength,usage:GPUBufferUsage.INDEX,mappedAtCreation:!0});return new Uint16Array(n.getMappedRange()).set(t),n.unmap(),n}(e,i);return{positionBuffer:a,primaryBuffers:{normalBuffer:s,texcoordBuffer:l,indicesBuffer:c},count:i.length}}},9758:(e,t,n)=>{"use strict";n.r(t);var r=n(7875),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(1324);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o)},8831:(e,t,n)=>{"use strict";n.r(t),n.d(t,{AngleRange:()=>m,angleInRange:()=>v,getAngleInRange:()=>y,getAngleRange:()=>h,getFormattedEndAngle:()=>p,getFormattedStartAngle:()=>d,getLargeArc:()=>f,isAngleRangeClosed:()=>g,normalizeAngle:()=>s,normalizeAngleInRange:()=>i,normalizeAngleRange:()=>u,normalizeRadian:()=>a,twoAnglesSameDirection:()=>c,twoRadiansSameDirection:()=>l});var r=n(2792),o=n(5569);function i(e,t){for(;(0,r.largerThan)(e,t.endAngle);)e-=360;for(;(0,r.lessThan)(e,t.startAngle);)e+=360;return e}function a(e){for(;(0,r.largerThan)(e,Math.PI);)e-=2*Math.PI;for(;(0,r.lessThan)(e,-Math.PI);)e+=2*Math.PI;return e}function s(e){for(;(0,r.largerThan)(e,180);)e-=360;for(;(0,r.lessThan)(e,-180);)e+=360;return e}function l(e,t){const n=a(e-t);return Math.abs(n){"use strict";n.r(t),n.d(t,{getArrow:()=>i});var r=n(5773),o=n(1715);function i(e,t,n,i,a=1){const s=(0,r.getPointByLengthAndDirection)(t,n,e),l=a/2/Math.tan((0,o.angleToRadian)(i));return{arrowPoints:[t,(0,r.rotatePositionByCenter)(s,t,i),(0,r.rotatePositionByCenter)(s,t,-i)],distance:l,endPoint:(0,r.getPointByLengthAndDirection)(t,l,e)}}},5629:(e,t,n)=>{"use strict";n.r(t),n.d(t,{BezierCurve:()=>l,QuadraticCurve:()=>c,getBezierCurveCurvatureAtParam:()=>O,getBezierCurveDerivatives:()=>L,getBezierCurvePercentAtPoint:()=>v,getBezierCurvePointAtPercent:()=>x,getBezierCurvePoints:()=>b,getBezierCurvePoints3D:()=>C,getBezierSplineControlPointsOfPoints:()=>_,getBezierSplineControlPointsOfPoints3D:()=>S,getBezierSplineCurves:()=>E,getBezierSplinePoints:()=>k,getBezierSplinePoints3D:()=>w,getPartOfBezierCurve:()=>T,getPartOfQuadraticCurve:()=>A,getQuadraticCurveCurvatureAtParam:()=>I,getQuadraticCurveDerivatives:()=>M,getQuadraticCurvePercentAtPoint:()=>f,getQuadraticCurvePointAtPercent:()=>h,getQuadraticCurvePoints:()=>g,getQuadraticSplineCurves:()=>P,interpolate2:()=>u,interpolate3:()=>d,interpolate4:()=>p,pointIsOnBezierCurve:()=>y,pointIsOnQuadraticCurve:()=>m});var r=n(1475),o=n(2792),i=n(5773),a=n(8230),s=Math.pow;const l={from:i.Position,cp1:i.Position,cp2:i.Position,to:i.Position},c={from:i.Position,cp:i.Position,to:i.Position};function u(e,t,n){return e+(t-e)*n}function d(e,t,n,r){return u(u(e,t,r),u(t,n,r),r)}function p(e,t,n,r,o){return d(u(e,t,o),u(t,n,o),u(n,r,o),o)}function f({from:{x:e,y:t},cp:{x:n,y:i},to:{x:a,y:s}},l){const c=n-e,u=a-n-c,d=i-t,p=s-i-d,f=c*p-u*d;return(0,o.isZero)(f)?(0,r.calculateEquation2)(u,2*c,e-l.x).filter((e=>(0,o.isSameNumber)(p*e*e+2*d*e+t,l.y,o.delta3)))[0]:-((e-l.x)*p-(t-l.y)*u)/2/f}function h(e,t,n,r){return{x:d(e.x,t.x,n.x,r),y:d(e.y,t.y,n.y,r)}}function g(e,t,n,r){const o=[];for(let i=0;i<=r;i++)o.push(h(e,t,n,i/r));return o}function m(e,{from:{x:t,y:n},cp:{x:i,y:a},to:{x:s,y:l}}){const c=i-t,u=s-i-c,d=a-n,p=l-a-d;return(0,r.calculateEquation2)(u,2*c,t-e.x).filter((t=>(0,o.isValidPercent)(t)&&(0,o.isSameNumber)(p*t*t+2*d*t+n,e.y,o.delta3))).length>0}function y(e,{from:{x:t,y:n},cp1:{x:i,y:a},cp2:{x:s,y:l},to:{x:c,y:u}}){const d=3*i-t+-3*s+c,p=3*(t-2*i+s),f=3*(i-t),h=3*a-n+-3*l+u,g=3*(n-2*a+l),m=3*(a-n);return(0,r.calculateEquation3)(d,p,f,t-e.x).filter((t=>(0,o.isValidPercent)(t)&&(0,o.isSameNumber)(h*t*t*t+g*t*t+m*t+n,e.y,o.delta3))).length>0}function v({from:{x:e,y:t},cp1:{x:n,y:i},cp2:{x:a,y:s},to:{x:l,y:c}},u){const d=3*n-e+-3*a+l,p=3*(e-2*n+a),f=3*(n-e),h=3*i-t+-3*s+c,g=3*(t-2*i+s),m=3*(i-t);return(0,r.calculateEquation3)(d,p,f,e-u.x).filter((e=>(0,o.isSameNumber)(h*e*e*e+g*e*e+m*e+t,u.y,o.delta3)))[0]}function x(e,t,n,r,o){return{x:p(e.x,t.x,n.x,r.x,o),y:p(e.y,t.y,n.y,r.y,o)}}function b(e,t,n,r,o){const i=[];for(let a=0;a<=o;a++)i.push(x(e,t,n,r,a/o));return i}function C(e,t,n,r,o){const i=[];for(let a=0;a<=o;a++){const s=a/o,l=p(e[0],t[0],n[0],r[0],s),c=p(e[1],t[1],n[1],r[1],s),u=p(e[2],t[2],n[2],r[2],s);i.push([l,c,u])}return i}function E(e,t=!0){const n=[];if(!t){const t=e.map((e=>e.x)),r=e.map((e=>e.y));for(let o=1;o{n.push({from:e[r],cp1:t[0],cp2:t[1],to:e[r+1]})})),n}function P(e){const t=[];for(let n=1;nb(e.from,e.cp1,e.cp2,e.to,t))).flat()}function w(e,t){const n=[];return S(e).forEach(((r,o)=>{n.push(...C(e[o],...r,e[o+1],t))})),n}function _(e){const t=R(e.map((e=>e.x))),n=R(e.map((e=>e.y)));return t.p1.map(((e,r)=>[{x:t.p1[r],y:n.p1[r]},{x:t.p2[r],y:n.p2[r]}]))}function S(e){const t=R(e.map((e=>e[0]))),n=R(e.map((e=>e[1]))),r=R(e.map((e=>e[2])));return t.p1.map(((e,o)=>[[t.p1[o],n.p1[o],r.p1[o]],[t.p2[o],n.p2[o],r.p2[o]]]))}function R(e){const t=[],n=[],r=e.length-1,o=[],i=[],a=[],s=[];o[0]=0,i[0]=2,a[0]=1,s[0]=e[0]+2*e[1];for(let t=1;t=0;--e)t[e]=(s[e]-a[e]*t[e+1])/i[e];for(let o=0;o({x:l*s(n,2)+2*a*n+e,y:u*s(n,2)+2*c*n+t}),e=>({x:2*l*e+2*a,y:2*u*e+2*c}),()=>({x:2*l,y:2*u})]}function L({from:{x:e,y:t},cp1:{x:n,y:r},cp2:{x:o,y:i},to:{x:a,y:l}}){const c=3*n-e+-3*o+a,u=3*(e-2*n+o),d=3*(n-e),p=3*r-t+-3*i+l,f=3*(t-2*r+i),h=3*(r-t);return[n=>({x:c*s(n,3)+u*s(n,2)+d*n+e,y:p*s(n,3)+f*s(n,2)+h*n+t}),e=>({x:3*c*s(e,2)+2*u*e+d,y:3*p*s(e,2)+2*f*e+h}),e=>({x:6*c*e+2*u,y:6*p*e+2*f}),()=>({x:6*c,y:6*p})]}function I(e,t){const n=M(e),{x:r,y:o}=n[1](t),{x:i,y:a}=n[2](t);return(r*a-o*i)/s(s(r,2)+s(o,2),1.5)}function O(e,t){const n=L(e),{x:r,y:o}=n[1](t),{x:i,y:a}=n[2](t);return(r*a-o*i)/s(s(r,2)+s(o,2),1.5)}},6842:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Bounding:()=>d,getArcBounding:()=>v,getBezierCurveBounding:()=>P,getCircleBounding:()=>y,getCircleQuadrantPoints:()=>m,getEllipseArcBounding:()=>C,getEllipseBounding:()=>b,getEllipseBoundingRadians:()=>x,getGeometryLineBounding:()=>w,getGeometryLinesBounding:()=>k,getPointsBounding:()=>p,getPointsBoundingUnsafe:()=>g,getQuadraticCurveBounding:()=>E,mergeBoundings:()=>h,mergeBoundingsUnsafe:()=>f});var r=n(1475),o=n(2792),i=n(8831),a=n(2298),s=n(2318),l=n(8230),c=n(1715),u=n(5569);const d={xMin:u.number,xMax:u.number,yMin:u.number,yMax:u.number};function p(e){if(0!==e.length)return g(e)}function f(e){return g(e.map((e=>[e.start,e.end])).flat())}function h(e){const t=[];for(const n of e)n&&t.push(n.start,n.end);if(0!==t.length)return g(t)}function g(e){const t={start:{x:e[0].x,y:e[0].y},end:{x:e[0].x,y:e[0].y}};for(let n=1;nt.end.x&&(t.end.x=r.x),r.y>t.end.y&&(t.end.y=r.y)}return t}function m(e){return[{x:e.x-e.r,y:e.y,radian:Math.PI},{x:e.x,y:e.y-e.r,radian:-Math.PI/2},{x:e.x+e.r,y:e.y,radian:0},{x:e.x,y:e.y+e.r,radian:Math.PI/2}]}function y(e){return g(m(e))}function v(e){const t=m(e).filter((t=>(0,s.pointIsOnArc)(t,e))),{start:n,end:r}=(0,s.getArcStartAndEnd)(e);return g([...t,n,r])}function x(e){const{rx:t,ry:n,angle:r}=e,o=(0,c.angleToRadian)(r),i=Math.sin(o),a=Math.cos(o),s=Math.atan2(-i*n,a*t),l=Math.atan2(a*n,i*t);return[s,l,s+Math.PI,l+Math.PI]}function b(e){return g(x(e).map((t=>(0,a.getEllipsePointAtRadian)(e,t))))}function C(e){const{start:t,end:n}=(0,a.getEllipseArcStartAndEnd)(e),r=[t,n];for(const t of x(e))(0,i.angleInRange)((0,c.radianToAngle)(t),e)&&r.push((0,a.getEllipsePointAtRadian)(e,t));return g([...r,t,n])}function E({from:{x:e,y:t},cp:{x:n,y:r},to:{x:i,y:a}}){const s=n-e,l=i-n-s,c=r-t,u=a-r-c,d=[{x:e,y:t},{x:i,y:a}];if(!(0,o.isZero)(l)){const n=-s/l;(0,o.isValidPercent)(n)&&d.push({x:l*n*n+2*s*n+e,y:u*n*n+2*c*n+t})}if(!(0,o.isZero)(u)){const n=-c/u;(0,o.isValidPercent)(n)&&d.push({x:l*n*n+2*s*n+e,y:u*n*n+2*c*n+t})}return g(d)}function P({from:{x:e,y:t},cp1:{x:n,y:i},cp2:{x:a,y:s},to:{x:l,y:c}}){const u=3*n-e+-3*a+l,d=3*(e-2*n+a),p=3*(n-e),f=3*i-t+-3*s+c,h=3*(t-2*i+s),m=3*(i-t),y=[{x:e,y:t},{x:l,y:c}];for(const n of(0,r.calculateEquation2)(3*u,2*d,p))(0,o.isValidPercent)(n)&&y.push({x:u*n*n*n+d*n*n+p*n+e,y:f*n*n*n+h*n*n+m*n+t});for(const n of(0,r.calculateEquation2)(3*f,2*h,m))(0,o.isValidPercent)(n)&&y.push({x:u*n*n*n+d*n*n+p*n+e,y:f*n*n*n+h*n*n+m*n+t});return g(y)}function k(e,t=100){const n=[];for(const r of e){const e=w(r,t);if(!e)return;n.push(e)}return h(n)}function w(e,t=100){return Array.isArray(e)?g(e):"arc"===e.type?v(e.curve):"ellipse arc"===e.type?C(e.curve):"quadratic curve"===e.type?E(e.curve):"bezier curve"===e.type?P(e.curve):"ray"!==e.type?p((0,l.getNurbsPoints)(e.curve.degree,e.curve.points,e.curve.knots,e.curve.weights,t)):void 0}},1451:(e,t,n)=>{"use strict";n.r(t),n.d(t,{breakGeometryLines:()=>k,breakPolylineToPolylines:()=>E,mergeGeometryLines:()=>w,mergePolylinesToPolyline:()=>P});var r=n(5629),o=n(5773),i=n(8831),a=n(1796),s=n(2318),l=n(2298),c=n(5717),u=n(8230),d=n(1715),p=n(8306),f=Object.defineProperty,h=Object.defineProperties,g=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,x=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&x(e,n,t[n]);if(m)for(var n of m(t))v.call(t,n)&&x(e,n,t[n]);return e},C=(e,t)=>h(e,g(t));function E(e,t){const n=[];let r=[e[0][0]];if(e.forEach((e=>{const i=t.filter((t=>(0,a.pointIsOnLine)(t,...e)&&(0,a.pointIsOnLineSegment)(t,...e)));0===i.length?r.push(e[1]):(i.sort(((t,n)=>(0,o.getTwoPointsDistance)(t,e[0])-(0,o.getTwoPointsDistance)(n,e[0]))),i.forEach((e=>{(0,o.isSamePoint)(r[r.length-1],e)||r.push(e),r.length>1&&n.push(r),r=[e]})),(0,o.isSamePoint)(r[r.length-1],e[1])||r.push(e[1]))})),r.length>1&&n.push(r),n.length>1){const e=n[0][0],r=n[n.length-1];if((0,o.isSamePoint)(e,r[r.length-1])&&t.every((t=>!(0,o.isSamePoint)(e,t))))return n[0].unshift(...r.slice(0,r.length-1)),n.slice(0,n.length-1)}return n}function P(e){for(let t=e.length-1;t>0;t--)for(let n=t-1;n>=0;n--){const r=e[n],i=e[t];if((0,o.isSamePoint)(i.points[0],r.points[r.points.length-1])){e.splice(t,1),r.points.push(...i.points.slice(1));break}if((0,o.isSamePoint)(i.points[0],r.points[0])){e.splice(t,1),r.points.unshift(...i.points.slice(1).reverse());break}if((0,o.isSamePoint)(i.points[i.points.length-1],r.points[r.points.length-1])){e.splice(t,1),r.points.push(...i.points.reverse().slice(1));break}if((0,o.isSamePoint)(i.points[i.points.length-1],r.points[0])){e.splice(t,1),r.points.unshift(...i.points.slice(0,i.points.length-1));break}}}function k(e,t){const n=[];let f,h,g=[];const m=()=>{g.length>0&&(n.push(g),g=[])};for(const n of e){const{start:e,end:y}=(0,c.getGeometryLineStartAndEnd)(n);let v;if(f||(f=e),Array.isArray(n)?v={breakLine(t){t.sort(((e,t)=>(0,o.getTwoPointsDistance)(e,n[0])-(0,o.getTwoPointsDistance)(t,n[0]))),e&&t.unshift(e),y&&t.push(y);for(let e=1;e(0,i.getAngleInRange)((0,d.radianToAngle)((0,s.getCircleRadian)(e,n.curve)),n.curve)));t.sort(((e,t)=>e-t)),t.unshift(n.curve.startAngle),t.push(n.curve.endAngle);for(let e=1;e(0,i.getAngleInRange)((0,l.getEllipseAngle)(e,n.curve),n.curve)));t.sort(((e,t)=>e-t)),t.unshift(n.curve.startAngle),t.push(n.curve.endAngle);for(let e=1;e(0,r.getQuadraticCurvePercentAtPoint)(n.curve,e)));t.sort(((e,t)=>e-t)),t.unshift(0),t.push(1);for(let e=1;e(0,r.getBezierCurvePercentAtPoint)(n.curve,e)));t.sort(((e,t)=>e-t)),t.unshift(0),t.push(1);for(let e=1;e(0,u.getNurbsCurveParamAtPoint)(n.curve,e)));t.sort(((e,t)=>e-t)),t.unshift(0),t.push((0,u.getNurbsMaxParam)(n.curve));for(let e=1;e(0,a.getRayParamAtPoint)(n.line,e)));if(n.line.bidirectional||t.push(0),t.sort(((e,t)=>e-t)),n.line.bidirectional){const e=(0,a.getRayPointAtDistance)(n.line,t[0]);g.push({type:"ray",line:(0,p.reverseRay)(C(b({},n.line),{x:e.x,y:e.y,bidirectional:!1}))}),m()}for(let e=1;e(0,o.isSamePoint)(t,e)))&&m();const i=t.filter((t=>(!e||!(0,o.isSamePoint)(t,e))&&(!y||!(0,o.isSamePoint)(t,y))&&(0,c.pointIsOnGeometryLine)(t,n)));0===i.length?g.push(n):r(i),y&&t.some((e=>(0,o.isSamePoint)(e,y)))&&m()}h=y}if(m(),n.length>1&&f&&h){const e=f;if((0,o.isSamePoint)(e,h)&&t.every((t=>!(0,o.isSamePoint)(e,t)))){const e=n.splice(n.length-1,1);n[0].unshift(...e[0])}}return n}function w(e,t){const n=(0,c.getGeometryLineStartAndEnd)(e[0]).start;if(!n)return;const r=(0,c.getGeometryLineStartAndEnd)(e[e.length-1]).end;if(!r)return;const i=(0,c.getGeometryLineStartAndEnd)(t[0]).start;if(!i)return;const a=(0,c.getGeometryLineStartAndEnd)(t[t.length-1]).end;return a?(0,o.isSamePoint)(r,i)?[...e,...t]:(0,o.isSamePoint)(r,a)?[...e,...(0,p.reverseGeometryLines)(t)]:(0,o.isSamePoint)(n,a)?[...t,...e]:(0,o.isSamePoint)(n,i)?[...(0,p.reverseGeometryLines)(e),...t]:void 0:void 0}},9793:(e,t,n)=>{"use strict";n.r(t),n.d(t,{updateCamera:()=>o});var r=n(5773);function o(e,t,n,r,o){return{position:i(e,t,n,r,o),up:i(0,1,0,r,o)}}function i(e,t,n,o,i){const a=(0,r.rotatePositionByCenter)({x:n,y:t},{x:0,y:0},i);n=a.x,t=a.y;const s=(0,r.rotatePositionByCenter)({x:e,y:n},{x:0,y:0},o);return{x:e=s.x,y:t,z:n=s.y}}},2318:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Arc:()=>w,Circle:()=>k,arcToPolyline:()=>R,circleToArc:()=>L,getArcBulge:()=>D,getArcBulgeByStartEndPoint:()=>z,getArcBulgeByStartEndRadius:()=>F,getArcByStartEnd:()=>I,getArcByStartEndBulge:()=>B,getArcControlPoint:()=>O,getArcCurvature:()=>G,getArcPointAtAngle:()=>T,getArcStartAndEnd:()=>A,getCircleCurvature:()=>N,getCircleDerivatives:()=>U,getCirclePointAtRadian:()=>M,getCircleRadian:()=>S,getThreePointsCircle:()=>P,isSameCircle:()=>_,pointIsOnArc:()=>C,pointIsOnCircle:()=>E});var r=n(8831),o=n(1715),i=n(2792),a=n(5773),s=n(5569),l=n(491),c=n(1796),u=n(8392),d=Object.defineProperty,p=Object.defineProperties,f=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,y=Math.pow,v=(e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))g.call(t,n)&&v(e,n,t[n]);if(h)for(var n of h(t))m.call(t,n)&&v(e,n,t[n]);return e},b=(e,t)=>p(e,f(t));function C(e,t){const n=S(e,t);return(0,r.angleInRange)((0,o.radianToAngle)(n),t)}function E(e,t){return(0,i.isSameNumber)((0,a.getTwoPointsDistance)(e,t),t.r)}function P(e,t,n){const r=t.x-e.x,o=t.y-e.y,i=n.x-t.x,s=n.y-t.y,l=y(t.x,2)-y(e.x,2)+y(t.y,2)-y(e.y,2),c=y(n.x,2)-y(t.x,2)+y(n.y,2)-y(t.y,2),u={x:(l*s-c*o)/(r*s-i*o)/2,y:(i*l-c*r)/(i*o-s*r)/2};return b(x({},u),{r:(0,a.getTwoPointsDistance)(u,e)})}const k=(0,s.and)(a.Position,{r:(0,s.minimum)(0,s.number)}),w=(0,s.and)(k,r.AngleRange);function _(e,t){return(0,a.isSamePoint)(e,t)&&(0,i.isSameNumber)(e.r,t.r)}function S(e,t){return(0,o.getTwoPointsRadian)(e,t)}function R(e,t){return(0,r.getAngleRange)(e,t).map((t=>T(e,t)))}function A(e){return{start:T(e,e.startAngle),end:T(e,e.endAngle)}}function T(e,t){return M(e,(0,o.angleToRadian)(t))}function M(e,t){return(0,a.getPointByLengthAndRadian)(e,e.r,t)}function L(e){return b(x({},e),{startAngle:0,endAngle:360})}function I(e,t,n,r,s){const l=(0,a.getTwoPointCenter)(e,s),c=(0,a.getTwoPointsDistance)(e,s)/2;if((0,i.isZero)(c))return;let u;if(c>t&&(t=c),(0,i.isSameNumber)(c,t))u=l;else{const i=Math.sqrt(y(t,2)-y(c,2)),d=(0,o.getTwoPointsRadian)(s,e);u=(0,a.getPointByLengthAndRadian)(l,i,d+Math.PI/2*(n===r?-1:1))}const d={x:u.x,y:u.y,r:t};return b(x({},d),{startAngle:(0,o.radianToAngle)(S(e,d)),endAngle:(0,o.radianToAngle)(S(s,d)),counterclockwise:!r})}function O(e){const t=M(e,(0,o.angleToRadian)(e.startAngle)),n=(0,c.twoPointLineToGeneralFormLine)(e,t);if(!n)return;const r=M(e,(0,o.angleToRadian)(e.endAngle)),i=(0,c.twoPointLineToGeneralFormLine)(e,r);if(!i)return;const a=(0,u.getPerpendicularLine)(t,n),s=(0,u.getPerpendicularLine)(r,i);return(0,l.getTwoGeneralFormLinesIntersectionPoint)(a,s)}function B(e,t,n){const r=P(e,t,(0,a.getPointByLengthAndRadian)((0,a.getTwoPointCenter)(e,t),n*(0,a.getTwoPointsDistance)(e,t)/2,(0,o.getTwoPointsRadian)(t,e)-Math.PI/2));return b(x({},r),{startAngle:(0,o.radianToAngle)((0,o.getTwoPointsRadian)(e,r)),endAngle:(0,o.radianToAngle)((0,o.getTwoPointsRadian)(t,r)),counterclockwise:n<0})}function F(e,t,n,r){let o=Math.asin((0,a.getTwoPointsDistance)(e,t)/2/n);return r&&(Math.abs(r)>1&&(o=Math.PI-o),r<0&&(o=-o)),Math.tan(o/2)}function D(e,t,n){t||(t=T(e,e.startAngle)),n||(n=T(e,e.endAngle));let o=F(t,n,e.r);return(0,r.getLargeArc)(e)&&(o=1/o),e.counterclockwise&&(o=-o),o}function z(e,t,n){const r=P(e,t,n),i=(0,o.radianToAngle)(S(e,r)),a=(0,o.radianToAngle)(S(t,r)),s=[b(x({},r),{startAngle:i,endAngle:a,counterclockwise:!1}),b(x({},r),{startAngle:i,endAngle:a,counterclockwise:!0})].find((e=>C(n,e)));if(s)return D(s,e,t)}function U({x:e,y:t,r:n}){return[r=>({x:e+n*Math.cos(r),y:t+n*Math.sin(r)}),e=>({x:-n*Math.sin(e),y:n*Math.cos(e)}),e=>({x:-n*Math.cos(e),y:-n*Math.sin(e)}),e=>({x:n*Math.sin(e),y:-n*Math.cos(e)}),e=>({x:n*Math.cos(e),y:n*Math.sin(e)})]}function N(e){return 1/e.r}function G(e){const t=N(e);return e.counterclockwise?-t:t}},3975:(e,t,n)=>{"use strict";function r(e){return+`0x${e.slice(1)}`}function o(e,t){const n=e.toString(16);let r="";if(void 0!==t){const e=Math.floor(255*t).toString(16);r="0".repeat(2-e.length)+e}return`#${"0".repeat(6-n.length)}${n}${r}`}function i(e,t=1){const[n,r,o]=l(e);return[n/255,r/255,o/255,t]}function a(e){return s([Math.round(255*e[0]),Math.round(255*e[1]),Math.round(255*e[2])])}function s(e){return 256*(256*e[0]+e[1])+e[2]}function l(e){const t=[0,0,e%256];return e=Math.floor(e/256),t[1]=e%256,t[0]=Math.floor(e/256),t}function c(e,t){return void 0===t?e:void 0!==e?[e[0],e[1],e[2],e[3]*t]:void 0}function u(e,t){return void 0===e?t:void 0===t?e:e*t}n.r(t),n.d(t,{colorNumberToPixelColor:()=>l,colorNumberToRec:()=>i,colorStringToNumber:()=>r,getColorString:()=>o,mergeOpacities:()=>u,mergeOpacityToColor:()=>c,pixelColorToColorNumber:()=>s,recToColorNumber:()=>a})},4676:(e,t,n)=>{"use strict";function r(e,t){if("center"===t)return"move";let n=0;return(e%=180)>22.5?e<67.5?n+=1:e<112.5?n+=2:e<157.5&&(n+=3):e<-22.5&&(e>-67.5?n+=3:e>-112.5?n+=2:e>-157.5&&(n+=1)),"top"===t||"bottom"===t?i[(n+2)%4]:"right"===t||"left"===t?i[n%4]:"right-top"===t||"left-bottom"===t?i[(n+3)%4]:i[(n+1)%4]}n.r(t),n.d(t,{allDirections:()=>o,getResizeCursor:()=>r});const o=["left","right","top","bottom","left-bottom","left-top","right-top","right-bottom","center"],i=["ew-resize","nwse-resize","ns-resize","nesw-resize"]},23:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Debug:()=>a,printArc:()=>u,printBezierCurve:()=>f,printEllipseArc:()=>d,printGeometryLine:()=>m,printLine:()=>c,printNurbsCurve:()=>h,printParam:()=>s,printPoint:()=>l,printQuadraticCurve:()=>p,printRay:()=>g});var r=n(2298),o=Object.defineProperty,i=(e,t,n)=>(((e,t,n)=>{t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);class a{constructor(e){this.enabled=e,i(this,"last",performance.now()),i(this,"result",{})}add(e,t){this.enabled&&(this.result[e]=t)}mark(e){this.enabled&&(this.result[e]=Math.round(performance.now()-this.last),this.last=performance.now())}print(e="end"){return this.mark(e),Object.values(this.result).join(" ")}}function s(e){return e.toFixed(1)}function l(e){return`(${Math.round(e.x)},${Math.round(e.y)})`}function c(e){return`${l(e[0])}->${l(e[1])}`}function u(e){return`${l(e)} R${Math.round(e.r)} A${Math.round(e.startAngle)}${e.counterclockwise?"<-":"->"}${Math.round(e.endAngle)}`}function d(e){return`${l((0,r.getEllipseCenter)(e))} R${Math.round(e.rx)},${Math.round(e.ry)} A${Math.round(e.startAngle+(e.angle||0))}${e.counterclockwise?"<-":"->"}${Math.round(e.endAngle+(e.angle||0))}`}function p(e){return`${l(e.from)}->${l(e.cp)}->${l(e.to)}`}function f(e){return`${l(e.from)}->${l(e.cp1)}->${l(e.cp2)}->${l(e.to)}`}function h(e){return e.points.map((e=>l(e))).join("->")}function g(e){return`${l(e)}${e.bidirectional?"<->":e.reversed?"<-":"->"}${Math.round(e.angle)}`}function m(e){return Array.isArray(e)?c(e):"arc"===e.type?u(e.curve):"ellipse arc"===e.type?d(e.curve):"quadratic curve"===e.type?p(e.curve):"bezier curve"===e.type?f(e.curve):"ray"===e.type?g(e.line):h(e.curve)}},2298:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Ellipse:()=>k,EllipseArc:()=>w,arcToEllipseArc:()=>F,ellipseArcToPolyline:()=>L,ellipseToEllipseArc:()=>B,ellipseToPolygon:()=>M,getEllipseAngle:()=>S,getEllipseArcByStartEnd:()=>D,getEllipseArcCurvatureAtRadian:()=>N,getEllipseArcPointAtAngle:()=>I,getEllipseArcStartAndEnd:()=>O,getEllipseCenter:()=>A,getEllipseCurvatureAtRadian:()=>U,getEllipseDerivatives:()=>z,getEllipsePointAtRadian:()=>T,getEllipseRadian:()=>R,getEllipseRadiusOfAngle:()=>P,isSameEllipse:()=>_,pointIsOnEllipse:()=>C,pointIsOnEllipseArc:()=>b,rotatePositionByEllipseCenter:()=>E});var r=n(5773),o=n(8831),i=n(1715),a=n(2792),s=n(5569),l=n(1475),c=n(1796),u=Object.defineProperty,d=Object.defineProperties,p=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,m=Math.pow,y=(e,t,n)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))h.call(t,n)&&y(e,n,t[n]);if(f)for(var n of f(t))g.call(t,n)&&y(e,n,t[n]);return e},x=(e,t)=>d(e,p(t));function b(e,t){const n=S(e,t);return(0,o.angleInRange)(n,t)}function C({x:e,y:t},{cx:n,cy:r,rx:o,ry:s,angle:l}){const c=(0,i.angleToRadian)(l),u=Math.sin(c),d=Math.cos(c);return(0,a.isSameNumber)(m(d*(e-n)+u*(t-r),2)/o/o+m(-u*(e-n)+d*(t-r),2)/s/s,1)}function E(e,t){var n;return(0,r.rotatePositionByCenter)(e,A(t),-(null!=(n=t.angle)?n:0))}function P(e,t){return e.angle&&(t-=(0,i.angleToRadian)(e.angle)),e.rx*e.ry/Math.sqrt(m(e.rx*Math.sin(t),2)+m(e.ry*Math.cos(t),2))}const k={cx:s.number,cy:s.number,rx:(0,s.minimum)(0,s.number),ry:(0,s.minimum)(0,s.number),angle:(0,s.optional)(s.number)},w=(0,s.and)(k,o.AngleRange);function _(e,t){return(0,a.isSameNumber)(e.cx,t.cx)&&(0,a.isSameNumber)(e.cy,t.cy)&&(0,a.isSameNumber)(e.rx,t.rx)&&(0,a.isSameNumber)(e.ry,t.ry)&&(0,a.equals)(e.angle,t.angle)}function S(e,t){return(0,i.radianToAngle)(R(e,t))}function R(e,t){var n;const o=(0,r.rotatePositionByCenter)(e,A(t),null!=(n=t.angle)?n:0);return Math.atan2((o.y-t.cy)/t.ry,(o.x-t.cx)/t.rx)}function A(e){return{x:e.cx,y:e.cy}}function T(e,t){const n=(0,i.getDirectionByRadian)(t),o={x:e.cx+e.rx*n.x,y:e.cy+e.ry*n.y};return e.angle?(0,r.rotatePosition)(o,A(e),(0,i.angleToRadian)(e.angle)):o}function M(e,t){const n=360/t,r=[];for(let o=0;oI(e,t)))}function I(e,t){return T(e,(0,i.angleToRadian)(t))}function O(e){return{start:I(e,e.startAngle),end:I(e,e.endAngle)}}function B(e){return x(v({},e),{startAngle:0,endAngle:360})}function F(e){return x(v({},e),{cx:e.x,cy:e.y,rx:e.r,ry:e.r})}function D(e,t,n,r,o,a,s){const u=(0,i.angleToRadian)(r),d=Math.sin(u),p=Math.cos(u),f=1/t/t,h=1/n/n,g=e.x,m=e.y,y=s.x,b=s.y,C=y-g,E=b-m,P=p*p*f+d*d*h,k=d*d*f+p*p*h,w=f-h,_=2*(w*d*p*C+k*E),R=2*(P*C+w*d*p*E)/_,A=(P*C*C+2*d*p*w*C*E+k*E*E)/_,T=(0,l.calculateEquation2)(P-2*d*p*w*R+k*R*R,-2*d*p*w*A+2*k*R*A,k*A*A-1);if(0===T.length)return;const M=T.map((e=>({x:g-e,y:m+R*e+A})));let L;if(1===M.length)L=0;else{const t=(0,c.twoPointLineToGeneralFormLine)(e,s);if(!t)return;L=(0,c.getPointSideOfLine)(M[0],t)>0?o===a?0:1:o!==a?0:1}const I=M[L],O={cx:I.x,cy:I.y,rx:t,ry:n,angle:r};return x(v({},O),{startAngle:S(e,O),endAngle:S(s,O),counterclockwise:!a})}function z({rx:e,ry:t,cx:n,cy:r,angle:o}){const a=(0,i.angleToRadian)(o),s=Math.sin(a),l=Math.cos(a);return[o=>({x:l*e*Math.cos(o)-s*t*Math.sin(o)+n,y:s*e*Math.cos(o)+l*t*Math.sin(o)+r}),n=>({x:-l*e*Math.sin(n)-s*t*Math.cos(n),y:-s*e*Math.sin(n)+l*t*Math.cos(n)}),n=>({x:s*t*Math.sin(n)+-l*e*Math.cos(n),y:-s*e*Math.cos(n)+-l*t*Math.sin(n)}),n=>({x:s*t*Math.cos(n)+l*e*Math.sin(n),y:s*e*Math.sin(n)+-l*t*Math.cos(n)}),n=>({x:l*e*Math.cos(n)-s*t*Math.sin(n),y:s*e*Math.cos(n)+l*t*Math.sin(n)})]}function U({rx:e,ry:t},n){return e*t/m(m(e*Math.sin(n),2)+m(t*Math.cos(n),2),1.5)}function N(e,t){const n=U(e,t);return e.counterclockwise?-n:n}},1475:(e,t,n)=>{"use strict";n.r(t),n.d(t,{calculateEquation1:()=>i,calculateEquation2:()=>a,calculateEquation3:()=>s,calculateEquation4:()=>l,calculateEquation5:()=>c,newtonIterate:()=>u});var r=n(2792),o=Math.pow;function i(e,t,n){return(0,r.isZero)(e,n)?[]:[-t/e]}function a(e,t,n,a){if((0,r.isZero)(e,a))return i(t,n,a);if((0,r.isZero)(n,a)){const n=i(e,t,a);return n.some((e=>(0,r.isZero)(e,a)))?n:[0,...n]}1!==e&&(t/=e,n/=e);const s=o(t,2)-4*n;if((0,r.lessThan)(s,0,a))return[];if((0,r.isZero)(s,a))return[-t/2];const l=Math.sqrt(s);return[(-t+l)/2,(-t-l)/2]}function s(e,t,n,o,i){if((0,r.isZero)(e,i))return a(t,n,o,i);if((0,r.isZero)(o,i)){const o=a(e,t,n,i);return o.some((e=>(0,r.isZero)(e,i)))?o:[0,...o]}1!==e&&(t/=e,n/=e,o/=e);const s=t*t-3*n,l=t*n-9*o,c=n*n-3*t*o;if((0,r.isZero)(s,i)&&(0,r.isZero)(l,i))return[-t/3];const u=l*l-4*s*c;if((0,r.isZero)(u,i)){const e=l/s;return[-t+e,-e/2]}const d=s*t;if(u>0){const e=Math.sqrt(u),n=d+1.5*(-l+e),o=d+1.5*(-l-e);return[(-t-(0,r.sqrt3)(n)-(0,r.sqrt3)(o))/3]}const p=Math.sqrt(s),f=(d-1.5*l)/s/p,h=Math.acos(f)/3,g=Math.cos(h),m=Math.sqrt(3)*Math.sin(h);return[(-t-2*p*g)/3,(p*(g+m)-t)/3,(p*(g-m)-t)/3]}function l(e,t,n,i,a,l){if((0,r.isZero)(e,l))return s(t,n,i,a,l);if((0,r.isZero)(a,l)){const o=s(e,t,n,i,l);return o.some((e=>(0,r.isZero)(e,l)))?o:[0,...o]}1!==e&&(t/=e,n/=e,i/=e,a/=e);const c=o(t,2),u=c*t,d=3*c-8*n,p=4*n*t-u-8*i,f=3*u*t+16*o(n,2)-16*n*c+16*t*i-64*a;if((0,r.isZero)(p,l)&&(0,r.isZero)(f,l)){if((0,r.isZero)(d,l))return[-t/4];if(d<0)return[];const e=Math.sqrt(d);return[(-t+e)/4,(-t-e)/4]}const h=o(p,2),g=o(d,2),m=g-3*f,y=d*f-9*h,v=o(f,2)-3*d*h;if((0,r.isZero)(m,l)&&(0,r.isZero)(y,l)&&(0,r.isZero)(v,l)){const e=t*d,n=4*d;return[(9*p-e)/n,(-e-3*p)/n]}const x=o(y,2)-4*m*v;if((0,r.isZero)(x,l)){const e=2*m*p/y,n=-(t+e)/4;if(Math.sign(y)!==Math.sign(m))return[n];const r=Math.sqrt(2*y/m),o=-t+e;return[(o+r)/4,(o-r)/4,n]}if(x>0){const e=Math.sqrt(x),n=m*d,i=n-1.5*(y-e),a=n-1.5*(y+e),s=(0,r.sqrt3)(i)+(0,r.sqrt3)(a),l=g-d*s+o(s,2)-3*m,c=-t+Math.sign(p)*Math.sqrt((d+s)/3),u=Math.sqrt((2*d-s+2*Math.sqrt(l))/3);return[(c+u)/4,(c-u)/4]}if((0,r.largerThan)(d,0,l)&&(0,r.largerThan)(f,0,l)){if((0,r.isZero)(p,l)){const e=2*Math.sqrt(f),n=Math.sqrt(d+e),r=Math.sqrt(d-e);return[(-t+n)/4,(-t-n)/4,(-t+r)/4,(-t-r)/4]}const e=Math.sqrt(m),n=Math.acos((3*y-2*m*d)/2/m/e),o=Math.cos(n/3),i=Math.sign(p)*Math.sqrt((d-2*e*o)/3),a=Math.sqrt(3)*Math.sin(n/3),s=Math.sqrt((d+e*(o+a))/3),c=Math.sqrt((d+e*(o-a))/3),u=s+c,h=s-c;return[(-t+i+u)/4,(-t+i-u)/4,(-t-i+h)/4,(-t-i-h)/4]}return[]}function c(e,t,n=r.delta2,o){if(e.length<=5)return l(e[e.length-5]||0,e[e.length-4]||0,e[e.length-3]||0,e[e.length-2]||0,e[e.length-1]||0,n);if((0,r.isZero)(e[e.length-1],n)){const t=c(e.slice(0,e.length-1),n);return t.some((e=>(0,r.isZero)(e,n)))?t:[0,...t]}const i=u(t,(t=>{let n=0;for(const r of e)n=n*t+r;return n}),(t=>{let n=0;for(let r=0;r(0,r.isSameNumber)(e,i,n)))?s:[i,...s]}function u(e,t,n,r,o=100){let i=e,a=0;for(;;){const e=t(i);if(Math.abs(e)o)return;i-=e/n(i),a++}return i}},6072:(e,t,n)=>{"use strict";n.r(t),n.d(t,{mathFunctions:()=>s,mathStyleExpressionToExpression:()=>a,printMathStyleExpression:()=>l,validateExpression:()=>i});var r=n(3031),o=n(8905);function i(e){try{(0,r.parseExpression)((0,r.tokenizeExpression)(e))}catch(e){if(e instanceof r.ExpressionError)return e.range}}function a(e){let t="";for(let n=0;n0&&n0&&s.every((e=>!t.endsWith(e)))&&((0,o.isLetter)(e[n-1])||(0,o.isNumber)(e[n-1])||")"===e[n-1])?t+="*(":")"===r&&n{if("NumericLiteral"===e.type)return e.value.toString();if("Identifier"===e.type)return e.name;if("UnaryExpression"===e.type){const n=t(e.argument,-1);return`(${e.operator+n})`}if("BinaryExpression"===e.type){const o=r.priorizedBinaryOperators.findIndex((t=>t.includes(e.operator))),i="+"===e.operator||"*"===e.operator?o:o-.1,a="*"===e.operator?" ":"**"===e.operator?"^":" "+e.operator+" ",s=t(e.left,o),l=t(e.right,i),c="-1"===s&&" "==a?"-"+l:s+a+l;return o>n?`(${c})`:c}return"CallExpression"===e.type?t(e.callee)+"("+e.arguments.map((e=>t(e))).join(", ")+")":""};return t(e)}},767:(e,t,n)=>{"use strict";function r(e){for(let t=o.length;t<=e;t++)o.push(t*o[t-1]);return o[e]}n.r(t),n.d(t,{factorial:()=>r});const o=[1]},6301:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Align:()=>a,VerticalAlign:()=>l,aligns:()=>i,flowLayout:()=>o,getFlowLayoutLocation:()=>c,verticalAligns:()=>s});var r=n(5569);function o(e){var t,n,r,o,i;const a=t=>void 0===e.height||(!(l.length>0)||t>=-l[0])&&t<=e.height,s=[],l=[];let c=null!=(t=e.scrollX)?t:0;const u=null!=(n=e.scrollY)?n:0;let d=u,p=0,f=null!=(r=e.row)?r:0,h=0,g=a(d),m=0,y=0;const v=()=>{if("center"===e.align||"right"===e.align){const t=s[s.length-1];let n=e.width-t.x-e.getWidth(t.content);"center"===e.align&&(n/=2);for(let e=y;e{d+=m,l.push(m),g=a(d),c=0,f++,h=0,m=0,v(),1===l.length&&s.forEach((e=>{e.visible&&!a(e.y)&&(e.visible=!1)})),y=s.length},b=t=>"number"==typeof e.lineHeight?e.lineHeight:e.lineHeight(t),C=t=>{const n=e.state[p],r=b(n);r>m&&(m=r),s.push({x:c,y:d,i:p,content:n,visible:g,row:f,column:h}),t?x():c+=e.getWidth(n),p++,h++};for(;p0&&x(),t.width<=e.width){for(;pe.width&&x(),C(!1)}else c+e.getWidth(t)>e.width&&x(),C(!1)}if(0===m&&(m=b(e.endContent)),l.push(m),s.push({x:c,y:d,i:p,content:e.endContent,visible:g,row:f,column:h}),v(),e.height&&("middle"===e.verticalAlign||"bottom"===e.verticalAlign)){let t=e.height-l.reduce(((e,t)=>e+t));t>0&&("middle"===e.verticalAlign&&(t/=2),s.forEach((e=>{e.y+=t})))}return{layoutResult:s,newContentHeight:d+m-u,lineHeights:l}}const i=["left","center","right"],a=(0,r.or)(...i),s=["top","middle","bottom"],l=(0,r.or)(...s);function c({x:e,y:t},n,r,o,i,a=!0,s){if(t0&&t=u.y+d-p&&t<=u.y+d&&e>=u.x&&e<=u.x+i(u.content))return{location:u.i+1,lineEnd:!1};if(t>=u.y&&t<=u.y+d){if(e<=u.x+i(u.content)/2&&(!l||l.x+i(l.content)/2<=e))return{location:u.i,lineEnd:!1,fromRight:e>u.x};l=u}else if(void 0!==l&&o!==r.length-1)return{location:l.i+1,lineEnd:!0}}var c;return void 0!==l?{location:l.i,lineEnd:!1}:void 0}},5717:(e,t,n)=>{"use strict";n.r(t),n.d(t,{GeometryLine:()=>T,boldGeometryLines:()=>Z,geometryLineInPolygon:()=>M,getGeometryLineByStartEndBulge:()=>$,getGeometryLineCurvatureAtParam:()=>J,getGeometryLineParamAtPoint:()=>D,getGeometryLinePointAndTangentRadianAtParam:()=>j,getGeometryLinePointAtParam:()=>N,getGeometryLineStartAndEnd:()=>L,getGeometryLineTangentRadianAtParam:()=>G,getGeometryLinesParamAtPoint:()=>z,getGeometryLinesPointAtParam:()=>V,getGeometryLinesStartAndEnd:()=>I,getNearestGeometryLines:()=>ee,getPartOfGeometryLine:()=>H,getPartOfGeometryLines:()=>q,getSeparatedGeometryLines:()=>te,isGeometryLinesClosed:()=>O,iterateGeometryLinesParamsAtPoint:()=>U,optimizeGeometryLine:()=>K,optimizeGeometryLines:()=>X,pointIsOnGeometryLine:()=>F,pointIsOnGeometryLines:()=>B,splitGeometryLines:()=>Y,trimGeometryLines:()=>Q});var r=n(491),o=n(5629),i=n(2318),a=n(2298),s=n(1074),l=n(6022),c=n(1796),u=n(8230),d=n(5773),p=n(5569),f=n(8831),h=n(2792),g=n(1715),m=n(5689),y=n(8306),v=n(8258),x=n(1785),b=n(8392),C=Object.defineProperty,E=Object.defineProperties,P=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable,S=(e,t,n)=>t in e?C(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,R=(e,t)=>{for(var n in t||(t={}))w.call(t,n)&&S(e,n,t[n]);if(k)for(var n of k(t))_.call(t,n)&&S(e,n,t[n]);return e},A=(e,t)=>E(e,P(t));const T=(e,t)=>(0,s.isArray)(e)?(0,p.validate)(e,(0,p.tuple)(d.Position,d.Position),t):(0,l.isRecord)(e)?"arc"===e.type?(0,p.validate)(e,{type:"arc",curve:i.Arc},t):"ellipse arc"===e.type?(0,p.validate)(e,{type:"ellipse arc",curve:a.EllipseArc},t):"quadratic curve"===e.type?(0,p.validate)(e,{type:"quadratic curve",curve:o.QuadraticCurve},t):"bezier curve"===e.type?(0,p.validate)(e,{type:"bezier curve",curve:o.BezierCurve},t):"nurbs curve"===e.type?(0,p.validate)(e,{type:"nurbs curve",curve:u.NurbsCurve},t):"ray"===e.type?(0,p.validate)(e,{type:"ray",line:c.Ray},t):{path:[...t,"type"],expect:"or",args:["arc","ellipse arc","quadratic curve","bezier curve","nurbs curve","ray"]}:{path:t,expect:"object"};function M(e,t){if(Array.isArray(e))return(0,c.pointInPolygon)(e[0],t)&&(0,c.pointInPolygon)(e[1],t);let n;if("arc"===e.type)n=(0,i.getArcStartAndEnd)(e.curve);else if("ellipse arc"===e.type)n=(0,a.getEllipseArcStartAndEnd)(e.curve);else if("nurbs curve"===e.type)n=(0,u.getNurbsCurveStartAndEnd)(e.curve);else{if("ray"===e.type)return!1;n={start:e.curve.from,end:e.curve.to}}return(0,c.pointInPolygon)(n.start,t)&&(0,c.pointInPolygon)(n.end,t)&&!(0,r.geometryLineIntersectWithPolygon)(e,t)}function L(e){return Array.isArray(e)?{start:e[0],end:e[1]}:"quadratic curve"===e.type||"bezier curve"===e.type?{start:e.curve.from,end:e.curve.to}:"arc"===e.type?(0,i.getArcStartAndEnd)(e.curve):"nurbs curve"===e.type?(0,u.getNurbsCurveStartAndEnd)(e.curve):"ray"===e.type?(0,c.getRayStartAndEnd)(e.line):(0,a.getEllipseArcStartAndEnd)(e.curve)}function I(e){return{start:L(e[0]).start,end:L(e[e.length-1]).end}}function O(e){const{start:t,end:n}=I(e);return!(!t||!n)&&(0,d.isSamePoint)(t,n)}function B(e,t){return t.some((t=>F(e,t)))}function F(e,t){return Array.isArray(t)?(0,c.pointIsOnLine)(e,...t)&&(0,c.pointIsOnLineSegment)(e,...t):"arc"===t.type?(0,i.pointIsOnCircle)(e,t.curve)&&(0,i.pointIsOnArc)(e,t.curve):"ellipse arc"===t.type?(0,a.pointIsOnEllipse)(e,t.curve)&&(0,a.pointIsOnEllipseArc)(e,t.curve):"quadratic curve"===t.type?(0,o.pointIsOnQuadraticCurve)(e,t.curve):"bezier curve"===t.type?(0,o.pointIsOnBezierCurve)(e,t.curve):"ray"===t.type?(0,c.pointIsOnRay)(e,t.line):(0,u.pointIsOnNurbsCurve)(e,t.curve)}function D(e,t,n){if(Array.isArray(t))return(0,c.getLineParamAtPoint)(...t,e);if("arc"===t.type){const r=(0,f.getAngleInRange)((0,g.radianToAngle)((0,g.getTwoPointsRadian)(e,t.curve)),t.curve),o=t.curve.endAngle-t.curve.startAngle,i=(r-t.curve.startAngle)/o;return i>1&&n?i-360/o:i}if("ellipse arc"===t.type){const r=(0,f.getAngleInRange)((0,a.getEllipseAngle)(e,t.curve),t.curve),o=t.curve.endAngle-t.curve.startAngle,i=(r-t.curve.startAngle)/o;return i>1&&n?i-360/o:i}return"quadratic curve"===t.type?(0,o.getQuadraticCurvePercentAtPoint)(t.curve,e):"bezier curve"===t.type?(0,o.getBezierCurvePercentAtPoint)(t.curve,e):"ray"===t.type?(0,c.getRayParamAtPoint)(t.line,e):(0,u.getNurbsCurveParamAtPoint)(t.curve,e)/(0,u.getNurbsMaxParam)(t.curve)}function z(e,t){var n;return null!=(n=(0,h.first)(U(e,t)))?n:0}function*U(e,t){for(let n=0;nt)return(0,y.reverseGeometryLines)(q(t,e,n));const r=[],o=Math.max(0,Math.floor(e)),i=Math.min(n.length-1,Math.floor(t));for(let a=o;a<=i;a++){const o=n[a],i=e-a,s=t-a;(0,h.isBetween)(i,0,1)?(0,h.isBetween)(s,0,1)?(0,h.equals)(i,s)||r.push(H(i,s,o)):(0,h.equals)(i,1)||r.push(H(i,1,o)):(0,h.isBetween)(s,0,1)?(0,h.equals)(s,0)||r.push(H(0,s,o)):r.push(o)}return r}function $(e,t,n){return(0,h.isZero)(n)?[e,t]:{type:"arc",curve:(0,i.getArcByStartEndBulge)(e,t,n)}}function Y(e){const t=(0,d.deduplicatePosition)(Array.from((0,r.iterateGeometryLinesSelfIntersectionPoints)(e)));for(const n of t){const t=(0,h.deduplicate)(Array.from(U(n,e)),h.isSameNumber);if(t.length<2)continue;const r=[],o=[...q(t[1],e.length,e),...q(0,t[0],e)];if(0===o.length)continue;const i=q(t[0],t[1],e);if(0===i.length)continue;const a=(0,c.getPolygonArea)((0,v.getGeometryLinesPoints)(o));if(!(0,h.isZero)(a)){if(a<0)continue;r.push(...Y(o))}const s=(0,c.getPolygonArea)((0,v.getGeometryLinesPoints)(i));if(!(0,h.isZero)(s)){if(s<0)continue;r.push(...Y(i))}return r}return[e]}function K(e){if(Array.isArray(e)){if((0,d.isSamePoint)(...e))return}else if("arc"===e.type){if((0,h.isSameNumber)(e.curve.startAngle,e.curve.endAngle))return;if((0,h.lessOrEqual)(e.curve.r,0))return}else if("ellipse arc"===e.type){if((0,h.isSameNumber)(e.curve.startAngle,e.curve.endAngle))return;if((0,h.lessOrEqual)(e.curve.rx,0))return;if((0,h.lessOrEqual)(e.curve.ry,0))return;if((0,h.isSameNumber)(e.curve.rx,e.curve.ry))return K({type:"arc",curve:{r:e.curve.rx,x:e.curve.cx,y:e.curve.cy,startAngle:e.curve.startAngle,endAngle:e.curve.endAngle,counterclockwise:e.curve.counterclockwise}})}else if("quadratic curve"===e.type){if((0,c.pointIsOnLine)(e.curve.cp,e.curve.from,e.curve.to))return K([e.curve.from,e.curve.to])}else if("bezier curve"===e.type){if((0,c.pointIsOnLine)(e.curve.cp1,e.curve.from,e.curve.to)&&(0,c.pointIsOnLine)(e.curve.cp2,e.curve.from,e.curve.to))return K([e.curve.from,e.curve.to])}else if("nurbs curve"===e.type){if(e.curve.points.length<2)return;if(2===e.curve.points.length)return K([e.curve.points[0],e.curve.points[1]])}return e}function X(e){const t=[];for(const n of e){const e=K(n);e&&t.push(e)}return t}function Z(e,t=1){const n=e.map((e=>{const t=(0,d.deduplicatePosition)((0,v.getGeometryLinesPoints)(e,10));return{points:t,lines:e,direction:Math.sign((0,c.getPolygonArea)(t))}})),r=(n.find((e=>n.every((t=>t===e||!(0,c.pointInPolygon)(e.points[0],t.points)))))||n[0]).direction,o=[];for(const e of n){const n=e.direction;o.push((0,x.getParallelGeometryLinesByDistanceDirectionIndex)(e.lines,n===r?t:-t,(0,x.pointSideToIndex)(n),"bevel"))}return o.map((e=>Q(e)))}function Q(e){const t=(0,y.reverseClosedGeometryLinesIfAreaIsNegative)(e),n=t!==e;return e=t,e=(0,h.maxmiumBy)(Y(e).map((e=>({lines:e,area:Math.abs((0,c.getPolygonArea)((0,v.getGeometryLinesPoints)(e,10)))}))),(e=>e.area)).lines,n&&(e=(0,y.reverseGeometryLines)(e)),e}function J(e,t){if(Array.isArray(e)||"ray"===e.type)return 0;if("arc"===e.type)return(0,i.getArcCurvature)(e.curve);if("ellipse arc"===e.type){const n=(0,g.angleToRadian)(W(t,e.curve));return(0,a.getEllipseArcCurvatureAtRadian)(e.curve,n)}return"quadratic curve"===e.type?(0,o.getQuadraticCurveCurvatureAtParam)(e.curve,t):"bezier curve"===e.type?(0,o.getBezierCurveCurvatureAtParam)(e.curve,t):(0,u.getNurbsCurveCurvatureAtParam)(e.curve,t*(0,u.getNurbsMaxParam)(e.curve))}function ee(e,t){let n=(0,h.minimumsBy)(t.map((t=>A(R({},(0,b.getPointAndGeometryLineNearestPointAndDistance)(e,t)),{line:t}))),(e=>e.distance));if(n.length>1){const t=(0,h.maxmiumsBy)(n.map((t=>{const n=D(t.point,t.line);let r=(0,f.normalizeRadian)((0,g.getTwoPointsRadian)(t.point,e)-G(n,t.line)),o=!1;return r>Math.PI/2?(r-=Math.PI,o=!0):r<-Math.PI/2?r+=Math.PI:(0,h.largerThan)(r,0)&&(o=!0),A(R({},t),{reversed:o,param:n,radian:Math.abs(r)})})),(e=>e.radian));n=t.length>1?(0,h.maxmiumsBy)(t.map((e=>A(R({},e),{curvature:J(e.line,e.param)*(e.reversed?-1:1)}))),(e=>e.curvature)):t}return n.map((e=>e.line))}function te(e){const t=[];let n,r=[];for(const o of e){const{start:e,end:i}=L(o);!(r.length>0)||n&&e&&(0,d.isSamePoint)(n,e)||(t.push(r),r=[]),r.push(o),n=i}return r.length>0&&t.push(r),t}},5065:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getKeys:()=>r});const r=Object.keys},8258:(e,t,n)=>{"use strict";n.r(t),n.d(t,{boldHatch:()=>U,geometryLinesToHatches:()=>z,getGeometryLinesPoints:()=>M,getHatchByPosition:()=>S,getHatchHoles:()=>A,getRightSideGeometryLineAtPoint:()=>N,mergeHatchBorderAndBorder:()=>B,mergeHatchBorderAndHole:()=>L,mergeHatchBorders:()=>F,mergeHatches:()=>D,optimizeHatch:()=>I,optimizeHatchInternally:()=>O});var r=n(5629),o=n(5717),i=n(23),a=n(2792),s=n(5773),l=n(6842),c=n(1715),u=n(1796),d=n(2298),p=n(2318),f=n(491),h=n(2572),g=n(8230),m=n(1785),y=n(8306),v=Object.defineProperty,x=Object.defineProperties,b=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertySymbols,E=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,k=(e,t,n)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))E.call(t,n)&&k(e,n,t[n]);if(C)for(var n of C(t))P.call(t,n)&&k(e,n,t[n]);return e},_=(e,t)=>x(e,b(t));function S(e,t,n,r){const o=void 0!==n&&n>e.x?[e,{x:n,y:e.y}]:{type:"ray",line:{x:e.x,y:e.y,angle:0}},i=[],a=t(o);for(const t of a)if(t)for(const n of t.lines){const r=(0,f.getTwoGeometryLinesIntersectionPoint)(n,o);i.push(...r.filter((t=>!(0,s.isSamePoint)(t,e))).map((e=>({line:n,point:e,id:t.id}))))}if(0!=i.length){i.sort(((e,t)=>e.point.x-t.point.x));for(const n of i){const o=R(n,0,t,r);if(o.lines.length>0&&(0,u.pointInPolygon)(e,M(o.lines)))return o}}}function R(e,t,n,r){r&&console.info(`Line ${(0,i.printGeometryLine)(e.line)}`),function(e,t){const n=(0,o.getGeometryLineParamAtPoint)(t.point,t.line);if((0,a.isZero)(n))return;if((0,a.isSameNumber)(n,1))return void(t.line=(0,y.reverseGeometryLine)(t.line));const r=(0,o.getGeometryLineTangentRadianAtParam)(n,t.line);1===(0,m.getRadianSideOfRadian)(e,r)&&(t.line=(0,y.reverseGeometryLine)(t.line))}(t,e);const l=(0,o.isGeometryLinesClosed)([e.line]);let c=T(e,n(e.line),r);const u=[],d=new Set;let p=0;for(;;){if(p++>=30){console.info(e.point,u);break}if(!c)break;const t=(0,o.getGeometryLineStartAndEnd)(c.line).start;if(t&&!(0,s.isSamePoint)(t,e.point)&&c.next&&(0,o.pointIsOnGeometryLine)(e.point,c.line)){u.push((0,o.getPartOfGeometryLine)(0,(0,o.getGeometryLineParamAtPoint)(e.point,c.line),c.line,l)),d.add(e.id);break}if(u.some((e=>(0,a.deepEquals)(e,null==c?void 0:c.line))))return{lines:[],ids:[]};if(u.push(c.line),d.add(c.id),!c.next)break;c=T(c.next,n(c.next.line),r)}if(0===u.length)return{lines:[],ids:[]};if(!(0,o.isGeometryLinesClosed)(u))return{lines:[],ids:[]};if(u.length>1){const e=(0,h.mergeGeometryLine)(u[u.length-1],u[0]);e&&(u.splice(0,1),u.splice(u.length-1,1,e))}return{lines:u,ids:Array.from(d)}}function A(e,t,n){const r=M(e),i=t((0,l.getPointsBoundingUnsafe)(r)),d=[];for(const t of i)if(t)for(const n of t.lines){const i=(0,o.getGeometryLineStartAndEnd)(n).start;i&&(0,u.pointInPolygon)(i,r)&&e.every((e=>!(0,o.pointIsOnGeometryLine)(i,e)))&&d.push({lines:[n],start:i,id:t.id})}if(0===d.length)return;const p=[],h=new Set;for(const e of d){if(p.length>0&&p.some((t=>(0,u.pointInPolygon)(e.start,M(t))||t.some((t=>(0,o.pointIsOnGeometryLine)(e.start,t))))))continue;const t=[r[0],e.start],i=[];for(const e of d)for(const n of e.lines){const r=(0,f.getTwoGeometryLinesIntersectionPoint)(n,t);i.push(...r.map((r=>({line:n,point:r,distance:(0,s.getTwoPointsDistance)(t[0],r),id:e.id}))))}if(0==i.length)continue;const l=R((0,a.minimumBy)(i,(e=>e.distance)),(0,c.getTwoPointsRadian)(t[1],t[0]),(()=>d),n);if(0!==l.lines.length){p.push(l.lines);for(const e of l.ids)h.add(e)}}return{holes:p,ids:Array.from(h)}}function T(e,t,n){const r=(0,o.isGeometryLinesClosed)([e.line]),s=(0,o.getGeometryLineParamAtPoint)(e.point,e.line);if(void 0===s)return;n&&console.info(`Target ${(0,i.printGeometryLine)(e.line)} at ${(0,i.printParam)(s)} ${(0,i.printPoint)(e.point)}`);let l=[];for(const n of t)if(n)for(const t of n.lines){const i=(0,f.getTwoGeometryLinesIntersectionPoint)(t,e.line);for(const c of i){const i=(0,o.getGeometryLineParamAtPoint)(c,e.line);(0,a.largerThan)(i,s)?l.push({line:t,param:i,point:c,id:n.id}):r&&l.push({line:t,param:i+1,point:c,id:n.id})}}let c,u=[];for(;!c;){if(u.length>0&&(l=l.filter((e=>!u.includes(e)))),0===l.length)return r?{line:e.line,id:e.id}:void 0;u=(0,a.minimumsBy)(l,(e=>e.param));const t=u[0].point,{line:n,reversed:o}=N(t,e.line,u.map((e=>e.line))),i=u.find((e=>e.line===n));i&&(c={line:o?(0,y.reverseGeometryLine)(n):n,point:t,id:i.id})}const d=(0,o.getGeometryLineParamAtPoint)(c.point,e.line),p=(0,o.getPartOfGeometryLine)(s,d,e.line,r);return n&&console.info(`Result ${(0,i.printParam)(s)}->${(0,i.printParam)(d)} ${(0,i.printGeometryLine)(p)}`),n&&console.info(`Line ${(0,i.printGeometryLine)(c.line)}`),{line:p,id:e.id,next:c}}function M(e,t=100,n=5){const o=[];for(const i of e)Array.isArray(i)?(0===o.length&&o.push(i[0]),o.push(i[1])):"arc"===i.type?o.push(...(0,p.arcToPolyline)(i.curve,n)):"ellipse arc"===i.type?o.push(...(0,d.ellipseArcToPolyline)(i.curve,n)):"quadratic curve"===i.type?o.push(...(0,r.getQuadraticCurvePoints)(i.curve.from,i.curve.cp,i.curve.to,t)):"bezier curve"===i.type?o.push(...(0,r.getBezierCurvePoints)(i.curve.from,i.curve.cp1,i.curve.cp2,i.curve.to,t)):"nurbs curve"===i.type&&o.push(...(0,g.getNurbsPoints)(i.curve.degree,i.curve.points,i.curve.knots,i.curve.weights,t));return o}function L(e,t){const n=(0,a.first)((0,f.iterateGeometryLinesIntersectionPoints)(e,t));if(n){const r=(0,o.getGeometryLinesParamAtPoint)(n,e),i=(0,o.getGeometryLinesParamAtPoint)(n,t);return[...(0,o.getPartOfGeometryLines)(0,r,e),...(0,o.getPartOfGeometryLines)(i,0,t),...(0,o.getPartOfGeometryLines)(t.length,i,t),...(0,o.getPartOfGeometryLines)(r,e.length,e)]}}function I(e,t){return O(e=(0,y.reverseClosedGeometryLinesIfAreaIsNegative)(e),t=t.map((e=>(0,y.reverseClosedGeometryLinesIfAreaIsNegative)(e))))}function O(e,t){for(let n=0;nO(e,t))).flat()}return[{border:e,holes:t}]}function B(e,t){const n=(0,a.first)((0,f.iterateGeometryLinesIntersectionPoints)(e,t));if(n){const r=(0,o.getGeometryLinesParamAtPoint)(n,e),i=(0,o.getGeometryLinesParamAtPoint)(n,t);return[...(0,o.getPartOfGeometryLines)(0,r,e),...(0,o.getPartOfGeometryLines)(i,t.length,t),...(0,o.getPartOfGeometryLines)(0,i,t),...(0,o.getPartOfGeometryLines)(r,e.length,e)]}}function F(e,t){const n=B(e=(0,y.reverseClosedGeometryLinesIfAreaIsNegative)(e),t=(0,y.reverseClosedGeometryLinesIfAreaIsNegative)(t));if(n){const e=(0,o.splitGeometryLines)(n);return e.length<2?e[0]:(0,a.maxmiumBy)(e.map((e=>({line:e,area:(0,u.getPolygonArea)(M(e))}))),(e=>e.area)).line}}function D(e,t){const n=F(e.border,t.border);if(n)return I(n,[...e.holes,...t.holes])}function z(e){if(0===e.length)return[];if(1===e.length)return[{border:(0,y.reverseClosedGeometryLinesIfAreaIsNegative)(e[0]),holes:[]}];const t=e.map((e=>(e=(0,y.reverseClosedGeometryLinesIfAreaIsNegative)(e),{points:(0,s.deduplicatePosition)(M(e,10)),lines:e})));let n=[];for(const e of t){const t=n.find((t=>(0,u.pointInPolygon)(e.points[0],t.border.points)&&t.holes.every((t=>!(0,u.pointInPolygon)(e.points[0],t.points)))));if(t)t.holes.push(e);else{const t=[],r=[];for(const o of n)(0,u.pointInPolygon)(o.border.points[0],e.points)?(r.push(o.border),t.push(...o.holes.map((e=>({border:e,holes:[]}))))):t.push(o);n=t,n.push({border:e,holes:r})}}return n.map((e=>({border:e.border.lines,holes:e.holes.map((e=>(0,y.reverseGeometryLines)(e.lines)))})))}function U(e,t=1){return{border:(0,o.trimGeometryLines)((0,m.getParallelGeometryLinesByDistanceDirectionIndex)(e.border,t,1,"bevel")),holes:e.holes.map((e=>(0,o.trimGeometryLines)((0,m.getParallelGeometryLinesByDistanceDirectionIndex)(e,-t,0,"bevel"))))}}function N(e,t,n){const r=(0,o.getGeometryLineParamAtPoint)(e,t);(0,a.isZero)(r)||(0,a.equals)(r,1)||(n=[...n,t]);let i=(0,o.getGeometryLineTangentRadianAtParam)(r,t),s=(0,o.getGeometryLineCurvatureAtParam)(t,r);(0,a.isZero)(r)||(i=(0,y.reverseRadian)(i),s=-s);const l=(0,a.maxmiumsBy)(n.map((t=>{const n=(0,o.getGeometryLineParamAtPoint)(e,t),r=(0,o.getGeometryLineTangentRadianAtParam)(n,t),l=[];(0,o.isGeometryLinesClosed)([t])?l.push({radian:r,reversed:!1},{radian:(0,y.reverseRadian)(r),reversed:!0}):(0,a.isZero)(n)?l.push({radian:r,reversed:!1}):(0,a.equals)(n,1)?l.push({radian:(0,y.reverseRadian)(r),reversed:!0}):l.push({radian:r,reversed:!1},{radian:(0,y.reverseRadian)(r),reversed:!0});for(const e of l){for(;(0,a.lessOrEqual)(e.radian,i-2*Math.PI);)e.radian+=2*Math.PI;for(;(0,a.largerThan)(e.radian,i);)e.radian-=2*Math.PI;(0,a.equals)(e.radian,i)&&(e.curvature=(0,o.getGeometryLineCurvatureAtParam)(t,n)*(e.reversed?-1:1),(0,a.largerOrEqual)(e.curvature,s)&&(e.radian-=2*Math.PI))}return _(w({},(0,a.maxmiumBy)(l,(e=>e.radian))),{line:t,param:n})})),(e=>e.radian));let c=l[0];return l.length>1&&(c=(0,a.maxmiumBy)(l.map((e=>{var t;return _(w({},e),{curvature:null!=(t=e.curvature)?t:(0,o.getGeometryLineCurvatureAtParam)(e.line,e.param)*(e.reversed?-1:1)})})),(e=>e.curvature))),{line:c.line,reversed:c.reversed}}},1324:(e,t,n)=>{"use strict";n.r(t);var r=n(5773),o={};for(const e in r)"default"!==e&&(o[e]=()=>r[e]);n.d(t,o);var i=n(3537);o={};for(const e in i)"default"!==e&&(o[e]=()=>i[e]);n.d(t,o);var a=n(4676);o={};for(const e in a)"default"!==e&&(o[e]=()=>a[e]);n.d(t,o);var s=n(2792);o={};for(const e in s)"default"!==e&&(o[e]=()=>s[e]);n.d(t,o);var l=n(7713);o={};for(const e in l)"default"!==e&&(o[e]=()=>l[e]);n.d(t,o);var c=n(5974);o={};for(const e in c)"default"!==e&&(o[e]=()=>c[e]);n.d(t,o);var u=n(491);o={};for(const e in u)"default"!==e&&(o[e]=()=>u[e]);n.d(t,o);var d=n(8905);o={};for(const e in d)"default"!==e&&(o[e]=()=>d[e]);n.d(t,o);var p=n(5775);o={};for(const e in p)"default"!==e&&(o[e]=()=>p[e]);n.d(t,o);var f=n(5147);o={};for(const e in f)"default"!==e&&(o[e]=()=>f[e]);n.d(t,o);var h=n(2301);o={};for(const e in h)"default"!==e&&(o[e]=()=>h[e]);n.d(t,o);var g=n(4461);o={};for(const e in g)"default"!==e&&(o[e]=()=>g[e]);n.d(t,o);var m=n(1451);o={};for(const e in m)"default"!==e&&(o[e]=()=>m[e]);n.d(t,o);var y=n(23);o={};for(const e in y)"default"!==e&&(o[e]=()=>y[e]);n.d(t,o);var v=n(6301);o={};for(const e in v)"default"!==e&&(o[e]=()=>v[e]);n.d(t,o);var x=n(9596);o={};for(const e in x)"default"!==e&&(o[e]=()=>x[e]);n.d(t,o);var b=n(5065);o={};for(const e in b)"default"!==e&&(o[e]=()=>b[e]);n.d(t,o);var C=n(6928);o={};for(const e in C)"default"!==e&&(o[e]=()=>C[e]);n.d(t,o);var E=n(6022);o={};for(const e in E)"default"!==e&&(o[e]=()=>E[e]);n.d(t,o);var P=n(1074);o={};for(const e in P)"default"!==e&&(o[e]=()=>P[e]);n.d(t,o);var k=n(5569);o={};for(const e in k)"default"!==e&&(o[e]=()=>k[e]);n.d(t,o);var w=n(3975);o={};for(const e in w)"default"!==e&&(o[e]=()=>w[e]);n.d(t,o);var _=n(8638);o={};for(const e in _)"default"!==e&&(o[e]=()=>_[e]);n.d(t,o);var S=n(623);o={};for(const e in S)"default"!==e&&(o[e]=()=>S[e]);n.d(t,o);var R=n(9292);o={};for(const e in R)"default"!==e&&(o[e]=()=>R[e]);n.d(t,o);var A=n(4061);o={};for(const e in A)"default"!==e&&(o[e]=()=>A[e]);n.d(t,o);var T=n(6072);o={};for(const e in T)"default"!==e&&(o[e]=()=>T[e]);n.d(t,o);var M=n(9793);o={};for(const e in M)"default"!==e&&(o[e]=()=>M[e]);n.d(t,o);var L=n(1715);o={};for(const e in L)"default"!==e&&(o[e]=()=>L[e]);n.d(t,o);var I=n(6300);o={};for(const e in I)"default"!==e&&(o[e]=()=>I[e]);n.d(t,o);var O=n(7764);o={};for(const e in O)"default"!==e&&(o[e]=()=>O[e]);n.d(t,o);var B=n(1475);o={};for(const e in B)"default"!==e&&(o[e]=()=>B[e]);n.d(t,o);var F=n(3549);o={};for(const e in F)"default"!==e&&(o[e]=()=>F[e]);n.d(t,o);var D=n(5689);o={};for(const e in D)"default"!==e&&(o[e]=()=>D[e]);n.d(t,o);var z=n(8392);o={};for(const e in z)"default"!==e&&(o[e]=()=>z[e]);n.d(t,o);var U=n(5629);o={};for(const e in U)"default"!==e&&(o[e]=()=>U[e]);n.d(t,o);var N=n(3793);o={};for(const e in N)"default"!==e&&(o[e]=()=>N[e]);n.d(t,o);var G=n(8230);o={};for(const e in G)"default"!==e&&(o[e]=()=>G[e]);n.d(t,o);var j=n(1785);o={};for(const e in j)"default"!==e&&(o[e]=()=>j[e]);n.d(t,o);var V=n(767);o={};for(const e in V)"default"!==e&&(o[e]=()=>V[e]);n.d(t,o);var W=n(7558);o={};for(const e in W)"default"!==e&&(o[e]=()=>W[e]);n.d(t,o);var H=n(8306);o={};for(const e in H)"default"!==e&&(o[e]=()=>H[e]);n.d(t,o);var q=n(2572);o={};for(const e in q)"default"!==e&&(o[e]=()=>q[e]);n.d(t,o);var $=n(8258);o={};for(const e in $)"default"!==e&&(o[e]=()=>$[e]);n.d(t,o);var Y=n(4575);o={};for(const e in Y)"default"!==e&&(o[e]=()=>Y[e]);n.d(t,o);var K=n(6842);o={};for(const e in K)"default"!==e&&(o[e]=()=>K[e]);n.d(t,o);var X=n(2318);o={};for(const e in X)"default"!==e&&(o[e]=()=>X[e]);n.d(t,o);var Z=n(2298);o={};for(const e in Z)"default"!==e&&(o[e]=()=>Z[e]);n.d(t,o);var Q=n(1796);o={};for(const e in Q)"default"!==e&&(o[e]=()=>Q[e]);n.d(t,o);var J=n(8831);o={};for(const e in J)"default"!==e&&(o[e]=()=>J[e]);n.d(t,o);var ee=n(7486);o={};for(const e in ee)"default"!==e&&(o[e]=()=>ee[e]);n.d(t,o);var te=n(1401);o={};for(const e in te)"default"!==e&&(o[e]=()=>te[e]);n.d(t,o);var ne=n(5717);o={};for(const e in ne)"default"!==e&&(o[e]=()=>ne[e]);n.d(t,o);var re=n(360);o={};for(const e in re)"default"!==e&&(o[e]=()=>re[e]);n.d(t,o);var oe=n(2683);o={};for(const e in oe)"default"!==e&&(o[e]=()=>oe[e]);n.d(t,o);var ie=n(7727);o={};for(const e in ie)"default"!==e&&(o[e]=()=>ie[e]);n.d(t,o)},491:(e,t,n)=>{"use strict";n.r(t),n.d(t,{geometryLineIntersectWithPolygon:()=>B,getArcBezierCurveIntersectionPoints:()=>re,getArcEllipseArcIntersectionPoints:()=>V,getArcEllipseIntersectionPoints:()=>j,getArcQuadraticCurveIntersectionPoints:()=>X,getCircleBezierCurveIntersectionPoints:()=>ne,getCircleEllipseIntersectionPoints:()=>G,getCircleQuadraticCurveIntersectionPoints:()=>K,getEllipseArcBezierCurveIntersectionPoints:()=>ie,getEllipseArcEllipseIntersectionPoints:()=>H,getEllipseArcQuadraticCurveIntersectionPoints:()=>Q,getEllipseBezierCurveIntersectionPoints:()=>oe,getEllipseQuadraticCurveIntersectionPoints:()=>Z,getGeneralFormLineCircleIntersectionPoints:()=>I,getLineBezierCurveIntersectionPoints:()=>ee,getLineCircleIntersectionPoints:()=>L,getLineEllipseIntersectionPoints:()=>z,getLineQuadraticCurveIntersectionPoints:()=>$,getLineSegmentArcIntersectionPoints:()=>T,getLineSegmentBezierCurveIntersectionPoints:()=>te,getLineSegmentCircleIntersectionPoints:()=>A,getLineSegmentEllipseArcIntersectionPoints:()=>N,getLineSegmentEllipseIntersectionPoints:()=>U,getLineSegmentQuadraticCurveIntersectionPoints:()=>Y,getQuadraticCurveBezierCurveIntersectionPoints:()=>ae,getTwoArcIntersectionPoints:()=>M,getTwoBezierCurveIntersectionPoints:()=>se,getTwoCircleIntersectionPoints:()=>R,getTwoEllipseArcIntersectionPoints:()=>q,getTwoEllipseIntersectionPoints:()=>W,getTwoGeneralFormLinesIntersectionPoint:()=>S,getTwoGeometryLinesIntersectionLine:()=>le,getTwoGeometryLinesIntersectionPoint:()=>w,getTwoLineSegmentsIntersectionPoint:()=>k,getTwoLinesIntersectionPoint:()=>_,getTwoQuadraticCurveIntersectionPoints:()=>J,iterateGeometryLinesIntersectionPoints:()=>E,iterateGeometryLinesSelfIntersectionPoints:()=>P,iterateIntersectionPoints:()=>C,lineIntersectWithPolygon:()=>O,lineIntersectWithTwoPointsFormRegion:()=>D});var r=n(5629),o=n(1475),i=n(2792),a=n(5773),s=n(7486),l=n(1796),c=n(2298),u=n(2318),d=n(8230),p=n(1715),f=n(5717),h=n(6842),g=n(8831),m=n(8306),y=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),v=Math.pow,x=function(e,t){this[0]=e,this[1]=t},b=e=>{var t,n=e[y("asyncIterator")],r=!1,o={};return null==n?(n=e[y("iterator")](),t=e=>o[e]=t=>n[e](t)):(n=n.call(e),t=e=>o[e]=t=>{if(r){if(r=!1,"throw"===e)throw t;return t}return r=!0,{done:!1,value:new x(new Promise((r=>{var o=n[e](t);if(!(o instanceof Object))throw TypeError("Object expected");r(o)})),1)}}),o[y("iterator")]=()=>o,t("next"),"throw"in n?t("throw"):o.throw=e=>{throw e},"return"in n&&t("return"),o};function*C(e,t,n,r){const o=r(e),i=r(t);if(o&&i&&o.getGeometries&&i.getGeometries){const r=o.getGeometries(e,n).lines,a=i.getGeometries(t,n).lines;yield*b(E(r,a))}}function*E(e,t){for(const n of e)for(const e of t)yield*b(w(n,e))}function*P(e){var t,n;const r=(0,f.isGeometryLinesClosed)(e);for(let o=0;o!(0,a.isSamePoint)(e,n))))}if(r&&0===o&&i===e.length-1){const t=null==(n=(0,f.getGeometryLineStartAndEnd)(e[o]))?void 0:n.start;t&&(s=s.filter((e=>!(0,a.isSamePoint)(e,t))))}yield*b(s)}}function k(e,t,n,r){const o=_(e,t,n,r);if(o&&(0,l.pointIsOnLineSegment)(o,e,t)&&(0,l.pointIsOnLineSegment)(o,n,r))return o}function w(e,t,n=!1,r=i.delta2){if(Array.isArray(e)){if(Array.isArray(t)){const r=n?_(...e,...t):k(...e,...t);return r?[r]:[]}if("arc"===t.type)return n?L(...e,t.curve,r):T(...e,t.curve);if("ellipse arc"===t.type)return n?z(...e,t.curve):N(...e,t.curve);if("quadratic curve"===t.type)return n?$(...e,t.curve,!0):Y(...e,t.curve);if("bezier curve"===t.type)return n?ee(...e,t.curve,!0):te(...e,t.curve);if("ray"===t.type){const r=(0,l.twoPointLineToGeneralFormLine)(...e);if(!r)return[];const o=S(r,(0,l.pointAndDirectionToGeneralFormLine)(t.line,(0,p.angleToRadian)(t.line.angle)));return o&&(n||(0,l.pointIsOnLineSegment)(o,...e)&&(0,l.pointIsOnRay)(o,t.line))?[o]:[]}return(0,d.getLineSegmentNurbsCurveIntersectionPoints)(...e,t.curve)}if(Array.isArray(t))return w(t,e,n);if("arc"===e.type){if("arc"===t.type)return n?R(e.curve,t.curve):M(e.curve,t.curve);if("ellipse arc"===t.type)return n?G(e.curve,t.curve):V(e.curve,t.curve);if("quadratic curve"===t.type)return n?K(e.curve,t.curve,!0):X(e.curve,t.curve);if("bezier curve"===t.type)return n?ne(e.curve,t.curve,void 0,!0):re(e.curve,t.curve);if("ray"===t.type){let o=L(t.line,(0,l.getRayPointAtDistance)(t.line,1),e.curve,r);return n||(o=o.filter((n=>(0,u.pointIsOnArc)(n,e.curve)&&(0,l.pointIsOnRay)(n,t.line)))),o}return(0,d.getArcNurbsCurveIntersectionPoints)(e.curve,t.curve)}if("arc"===t.type)return w(t,e,n);if("ellipse arc"===e.type){if("ellipse arc"===t.type)return n?W(e.curve,t.curve):q(e.curve,t.curve);if("quadratic curve"===t.type)return n?Z(e.curve,t.curve,!0):Q(e.curve,t.curve);if("bezier curve"===t.type)return n?oe(e.curve,t.curve,void 0,!0):ie(e.curve,t.curve);if("ray"===t.type){let r=z(t.line,(0,l.getRayPointAtDistance)(t.line,1),e.curve);return n||(r=r.filter((n=>(0,c.pointIsOnEllipseArc)(n,e.curve)&&(0,l.pointIsOnRay)(n,t.line)))),r}return(0,d.getEllipseArcNurbsCurveIntersectionPoints)(e.curve,t.curve)}if("ellipse arc"===t.type)return w(t,e,n);if("quadratic curve"===e.type){if("quadratic curve"===t.type)return J(e.curve,t.curve,n);if("bezier curve"===t.type)return ae(e.curve,t.curve,void 0,n);if("ray"===t.type){let r=$(t.line,(0,l.getRayPointAtDistance)(t.line,1),e.curve,n);return n||(r=r.filter((e=>(0,l.pointIsOnRay)(e,t.line)))),r}return(0,d.getQuadraticCurveNurbsCurveIntersectionPoints)(e.curve,t.curve)}if("quadratic curve"===t.type)return w(t,e,n);if("bezier curve"===e.type){if("bezier curve"===t.type)return se(e.curve,t.curve,void 0,n);if("ray"===t.type){let r=ee(t.line,(0,l.getRayPointAtDistance)(t.line,1),e.curve,n);return n||(r=r.filter((e=>(0,l.pointIsOnRay)(e,t.line)))),r}return(0,d.getBezierCurveNurbsCurveIntersectionPoints)(e.curve,t.curve)}if("bezier curve"===t.type)return w(t,e,n);if("ray"===e.type){if("ray"===t.type){const r=S((0,l.pointAndDirectionToGeneralFormLine)(e.line,(0,p.angleToRadian)(e.line.angle)),(0,l.pointAndDirectionToGeneralFormLine)(t.line,(0,p.angleToRadian)(t.line.angle)));return r&&(n||(0,l.pointIsOnRay)(r,e.line)&&(0,l.pointIsOnRay)(r,t.line))?[r]:[]}const r=(0,h.getGeometryLineBounding)(t);if(r){const n=(0,l.rayToLineSegment)(e.line,(0,s.getPolygonFromTwoPointsFormRegion)(r));if(n)return(0,d.getLineSegmentNurbsCurveIntersectionPoints)(...n,t.curve)}return[]}return"ray"===t.type?w(t,e,n):(0,d.getTwoNurbsCurveIntersectionPoints)(e.curve,t.curve)}function _(e,t,n,r){const o=(0,l.twoPointLineToGeneralFormLine)(e,t);if(!o)return;const i=(0,l.twoPointLineToGeneralFormLine)(n,r);return i?S(o,i):void 0}function S(e,t){const{a:n,b:r,c:o}=e,{a,b:s,c:l}=t,c=a*r-n*s;if(!(0,i.isZero)(c))return{x:(o*s-r*l)/c,y:(l*n-o*a)/c}}function R({x:e,y:t,r:n},{x:r,y:o,r:a}){const s=v(n,2),l=v(a,2),c=r-e,u=o-t,d=v(c,2)+v(u,2),p=Math.sqrt(d),f=(d+s-l)/2/p,h=s-v(f,2);if((0,i.lessThan)(h,0))return[];const g=f/p,m=g*c+e,y=g*u+t;if((0,i.isZero)(h))return[{x:m,y}];const x=Math.sqrt(h)/p,b=x*u,C=x*c;return[{x:m+b,y:y-C},{x:m-b,y:y+C}]}function A(e,t,n){return L(e,t,n).filter((n=>(0,l.pointIsOnLineSegment)(n,e,t)))}function T(e,t,n){return A(e,t,n).filter((e=>(0,u.pointIsOnArc)(e,n)))}function M(e,t){return R(e,t).filter((n=>(0,u.pointIsOnArc)(n,e)&&(0,u.pointIsOnArc)(n,t)))}function L({x:e,y:t},{x:n,y:r},{x:o,y:a,r:s},l=i.delta2){const c=n-e,u=r-t,d=u*(o-e)-c*(a-t),p=v(c,2)+v(u,2),f=s*s*p-d*d;if((0,i.lessThan)(f,0,l))return[];const h=-u*d/p+o,g=c*d/p+a;if((0,i.isZero)(f,l))return[{x:h,y:g}];const m=Math.sqrt(f),y=m*c/p,x=m*u/p;return[{x:h-y,y:g-x},{x:h+y,y:g+x}]}function I(e,t){return L(...(0,l.generalFormLineToTwoPointLine)(e),t)}function O(e,t,n){for(const r of(0,l.getPolygonLine)(n))if(F(e,t,...r))return!0;return!1}function B(e,t){for(const n of(0,l.getPolygonLine)(t))if(Array.isArray(e)){if(F(...e,...n))return!0}else if("arc"===e.type){if(T(...n,e.curve).length>0)return!0}else if("ellipse arc"===e.type){if(N(...n,e.curve).length>0)return!0}else if("quadratic curve"===e.type){if(Y(...n,e.curve).length>0)return!0}else if("bezier curve"===e.type){if(te(...n,e.curve).length>0)return!0}else if("nurbs curve"===e.type){if((0,d.getLineSegmentNurbsCurveIntersectionPoints)(...n,e.curve).length>0)return!0}else if("ray"===e.type){const t=(0,l.twoPointLineToGeneralFormLine)(...n);if(!t){if((0,l.pointIsOnRay)(n[0],e.line))return!0;continue}const r=S(t,(0,l.pointAndDirectionToGeneralFormLine)(e.line,(0,p.angleToRadian)(e.line.angle)));if(r&&(0,l.pointIsOnRay)(r,e.line)&&(0,l.pointIsOnLineSegment)(r,...n))return!0}return!1}function F(e,t,n,r){if(!((0,i.lessOrEqual)(Math.min(e.x,t.x),Math.max(n.x,r.x))&&(0,i.lessOrEqual)(Math.min(n.y,r.y),Math.max(e.y,t.y))&&(0,i.lessOrEqual)(Math.min(n.x,r.x),Math.max(e.x,t.x))&&(0,i.lessOrEqual)(Math.min(e.y,t.y),Math.max(n.y,r.y))))return!1;const o=(n.x-e.x)*(t.y-e.y)-(t.x-e.x)*(n.y-e.y),a=(r.x-e.x)*(t.y-e.y)-(t.x-e.x)*(r.y-e.y),s=(e.x-n.x)*(r.y-n.y)-(r.x-n.x)*(e.y-n.y),l=(t.x-n.x)*(r.y-n.y)-(r.x-n.x)*(t.y-n.y);return(0,i.lessOrEqual)(o*a,0)&&(0,i.lessOrEqual)(s*l,0)}function D(e,t,n){return O(e,t,(0,s.getPolygonFromTwoPointsFormRegion)(n))}function z({x:e,y:t},{x:n,y:r},{rx:o,ry:a,cx:s,cy:l,angle:c}){const u=(0,p.angleToRadian)(c),d=Math.sin(u),f=Math.cos(u),h=n-e,g=r-t,m=g*(s-e)-h*(l-t),y=f*h+d*g,v=f*g-d*h,x=a*a*y,b=o*o*v,C=x*y+b*v,E=C-m*m;if((0,i.lessThan)(E,0))return[];const P=s-m*(x*d+b*f)/C,k=l+m*(x*f-b*d)/C;if((0,i.isZero)(E))return[{x:P,y:k}];const w=o*a*Math.sqrt(E)/C,_=h*w,S=g*w;return[{x:P+_,y:k+S},{x:P-_,y:k-S}]}function U(e,t,n){return z(e,t,n).filter((n=>(0,l.pointIsOnLineSegment)(n,e,t)))}function N(e,t,n){return U(e,t,n).filter((e=>(0,c.pointIsOnEllipseArc)(e,n)))}function G({x:e,y:t,r:n},{rx:r,ry:a,cx:s,cy:l,angle:c}){if((0,i.isSameNumber)(r,a))return R({x:e,y:t,r:n},{x:s,y:l,r});const u=(0,p.angleToRadian)(c),d=Math.sin(u),f=Math.cos(u),h=1/r/r,g=1/a/a,m=d*d*h+f*f*g,y=(2*d*f*h-2*d*f*g)/m,x=(f*f*h+d*d*g)/m,b=-1/m,C=v(n,2),E=s-e,P=l-t,k=1-x,w=E*E+P*P-C-b,_=y*y*k+y*y*x+k*k,S=-2*P*y*k+2*E*y*y+-4*P*y*x+4*E*k,A=-4*E*P*y+4*P*P*x+4*E*E+y*y*b+2*k*w+y*y*w,T=4*E*w+-4*P*y*b+-2*P*y*w,M=w*w+4*P*P*b;return(0,o.calculateEquation4)(_,S,A,T,M).map((e=>({x:e+s,y:-(w+2*E*e+k*e*e)/(2*P-y*e)+l})))}function j(e,t){return G(e,t).filter((t=>(0,u.pointIsOnArc)(t,e)))}function V(e,t){return j(e,t).filter((e=>(0,c.pointIsOnEllipseArc)(e,t)))}function W({rx:e,ry:t,cx:n,cy:r,angle:a},{rx:s,ry:l,cx:c,cy:u,angle:d}){if((0,i.isSameNumber)(e,t))return G({x:n,y:r,r:e},{rx:s,ry:l,cx:c,cy:u,angle:d});if((0,i.isSameNumber)(s,l))return G({x:c,y:u,r:s},{rx:e,ry:t,cx:n,cy:r,angle:a});const f=(0,p.angleToRadian)(a),h=(0,p.angleToRadian)(d),g=Math.sin(f),m=Math.cos(f),y=Math.sin(h),v=Math.cos(h),x=1/e/e,b=1/t/t,C=g*g*x+m*m*b,E=2*g*m*x/C,P=2*g*m*b/C,k=(m*m*x+g*g*b)/C,w=-1/C,_=1/s/s,S=1/l/l,R=n-c,A=r-u,T=y*y*_+v*v*S,M=(2*y*v*_*R-2*y*v*S*R+2*y*y*_*A+2*v*v*S*A)/T,L=(2*v*v*_*R+2*y*y*S*R+2*y*v*_*A-2*y*v*S*A)/T,I=P+-E+(2*y*v*_-2*y*v*S)/T,O=(v*v*_+y*y*S)/T-k,B=(v*v*_*R*R+y*y*S*R*R+2*y*v*_*R*A+-2*y*v*S*R*A+y*y*_*A*A+v*v*S*A*A-1)/T-w,F=k*I*I+P*I*O+O*O+-E*I*O,D=2*k*M*I+-E*L*I+2*L*O+P*L*I+-E*M*O+P*M*O,z=k*M*M+-E*M*L+P*M*L+w*I*I+L*L+P*I*B+2*O*B+-E*I*B,U=2*w*M*I+2*L*B+-E*M*B+P*M*B,N=w*M*M+B*B;return(0,o.calculateEquation4)(F,D,z,U,N).map((e=>({x:e+n,y:-(L*e+O*e*e+B)/(I*e+M)+r})))}function H(e,t){return W(e,t).filter((t=>(0,c.pointIsOnEllipseArc)(t,e)))}function q(e,t){return H(e,t).filter((e=>(0,c.pointIsOnEllipseArc)(e,t)))}function $({x:e,y:t},{x:n,y:r},{from:{x:a,y:s},cp:{x:l,y:c},to:{x:u,y:d}},p=!1){const f=l-a,h=u-l-f,g=c-s,m=d-c-g,y=n-e,v=r-t;let x=(0,o.calculateEquation2)(-1*m*y+h*v,-2*g*y+2*f*v,-s*y+a*v+-v*e+y*t);return p||(x=x.filter((e=>(0,i.isValidPercent)(e)))),x.map((e=>({x:h*e*e+2*f*e+a,y:m*e*e+2*g*e+s})))}function Y(e,t,n){return $(e,t,n).filter((n=>(0,l.pointIsOnLineSegment)(n,e,t)))}function K({x:e,y:t,r:n},{from:{x:r,y:a},cp:{x:s,y:l},to:{x:c,y:u}},d=!1){const p=s-r,f=c-s-p,h=l-a,g=u-l-h;let m=(0,o.calculateEquation4)(f*f+g*g,4*(p*f+h*g),2*(2*p*p+r*f+2*h*h+a*g-f*e-g*t),4*(r*p+a*h+-1*p*e+-1*h*t),r*r+a*a+-n*n+-2*r*e+e*e+-2*a*t+t*t);return d||(m=m.filter((e=>(0,i.isValidPercent)(e)))),m.map((e=>({x:f*e*e+2*p*e+r,y:g*e*e+2*h*e+a})))}function X(e,t){return K(e,t).filter((t=>(0,u.pointIsOnArc)(t,e)))}function Z({rx:e,ry:t,cx:n,cy:r,angle:a},{from:{x:s,y:l},cp:{x:c,y:u},to:{x:d,y:f}},h=!1){const g=c-s,m=d-c-g,y=u-l,x=f-u-y,b=(0,p.angleToRadian)(a),C=Math.sin(b),E=Math.cos(b),P=1/e/e,k=1/t/t,w=s-n,_=l-r,S=y*C+g*E,R=g*C-y*E,A=x*C+m*E,T=m*C-x*E,M=C*k*w-E*k*_,L=E*P*w+C*P*_;let I=(0,o.calculateEquation4)(v(A,2)*P+v(T,2)*k,4*(S*A*P+R*T*k),2*(2*v(S,2)*P+2*v(R,2)*k+A*L+T*M),4*(S*L+R*M),v(E*w+C*_,2)*P+v(C*w+-E*_,2)*k-1);return h||(I=I.filter((e=>(0,i.isValidPercent)(e)))),I.map((e=>({x:m*e*e+2*g*e+s,y:x*e*e+2*y*e+l})))}function Q(e,t){return Z(e,t).filter((t=>(0,c.pointIsOnEllipseArc)(t,e)))}function J(e,{from:{x:t,y:n},cp:{x:a,y:s},to:{x:l,y:c}},u=!1){const{from:{x:d,y:p},cp:{x:f,y:h},to:{x:g,y:m}}=e,y=f-d,v=g-f-y,x=h-p,b=m-h-x,C=a-t,E=l-a-C,P=s-n,k=c-s-P,w=(d-t)/v,_=2*y/v,S=E/v,R=2*C/v,A=2*x/b-_,T=(-k/b+S)/A,M=(R+-2*P/b)/A,L=((p-n)/b-w)/A;let I=(0,o.calculateEquation4)(T*T,2*T*M,-_*T+M*M+2*T*L-S,-_*M+2*M*L-R,w+-_*L+L*L);u||(I=I.filter((e=>(0,i.isValidPercent)(e))));let O=I.map((e=>({x:E*e*e+2*C*e+t,y:k*e*e+2*P*e+n})));return u||(O=O.filter((t=>(0,i.isValidPercent)((0,r.getQuadraticCurvePercentAtPoint)(e,t))))),O}function ee({x:e,y:t},{x:n,y:r},{from:{x:a,y:s},cp1:{x:l,y:c},cp2:{x:u,y:d},to:{x:p,y:f}},h=!1){const g=3*l-a+-3*u+p,m=3*(a-2*l+u),y=3*(l-a),v=3*c-s+-3*d+f,x=3*(s-2*c+d),b=3*(c-s),C=n-e,E=r-t;let P=(0,o.calculateEquation3)(-v*C+g*E,-x*C+m*E,-b*C+y*E,-s*C+a*E+-E*e+C*t);return h||(P=P.filter((e=>(0,i.isValidPercent)(e)))),P.map((e=>({x:g*e*e*e+m*e*e+y*e+a,y:v*e*e*e+x*e*e+b*e+s})))}function te(e,t,n){return ee(e,t,n).filter((n=>(0,l.pointIsOnLineSegment)(n,e,t)))}function ne({x:e,y:t,r:n},{from:{x:r,y:a},cp1:{x:s,y:l},cp2:{x:c,y:u},to:{x:d,y:p}},f,h=!1){const g=3*s-r+-3*c+d,m=3*(r-2*s+c),y=3*(s-r),x=3*l-a+-3*u+p,b=3*(a-2*l+u),C=3*(l-a),E=r-e,P=a-t,k=v(n,2),w=g*g+x*x,_=g*m+x*b,S=m*m+2*g*y+b*b+2*x*C,R=m*y+g*E+b*C+x*P,A=y*y+2*m*E+C*C+2*b*P,T=2*(y*E+C*P);let M=(0,o.calculateEquation5)([w,2*_,S,2*R,A,T,E*E+P*P-k],.5,f);return h||(M=M.filter((e=>(0,i.isValidPercent)(e)))),M.map((e=>({x:g*e*e*e+m*e*e+y*e+r,y:x*e*e*e+b*e*e+C*e+a})))}function re(e,t){return ne(e,t).filter((t=>(0,u.pointIsOnArc)(t,e)))}function oe({rx:e,ry:t,cx:n,cy:r,angle:a},{from:{x:s,y:l},cp1:{x:c,y:u},cp2:{x:d,y:f},to:{x:h,y:g}},m,y=!1){const x=3*c-s+-3*d+h,b=3*(s-2*c+d),C=3*(c-s),E=3*u-l+-3*f+g,P=3*(l-2*u+f),k=3*(u-l),w=(0,p.angleToRadian)(a),_=Math.sin(w),S=Math.cos(w),R=1/e/e,A=1/t/t,T=s-n,M=l-r,L=E*_+x*S,I=x*_-E*S,O=_*T-S*M,B=S*T+_*M,F=k*_+C*S,D=C*_-k*S,z=P*_+b*S,U=b*_-P*S,N=z*R,G=U*A,j=D*A,V=F*R,W=B*R,H=O*A;let q=(0,o.calculateEquation5)([v(L,2)*R+v(I,2)*A,2*(N*L+I*G),z*N+U*G+2*(V*L+j*I),2*(F*N+D*G+L*W+I*H),F*V+D*j+2*((N*S+G*_)*T+(N*_-G*S)*M),2*((V*S+j*_)*T+(V*_-j*S)*M),O*H+B*W-1],.5,m);return y||(q=q.filter((e=>(0,i.isValidPercent)(e)))),q.map((e=>({x:x*e*e*e+b*e*e+C*e+s,y:E*e*e*e+P*e*e+k*e+l})))}function ie(e,t){return oe(e,t).filter((t=>(0,c.pointIsOnEllipseArc)(t,e)))}function ae(e,{from:{x:t,y:n},cp1:{x:a,y:s},cp2:{x:l,y:c},to:{x:u,y:d}},p,f=!1){const{from:{x:h,y:g},cp:{x:m,y},to:{x:v,y:x}}=e,b=3*a-t+-3*l+u,C=3*(t-2*a+l),E=3*(a-t),P=3*s-n+-3*c+d,k=3*(n-2*s+c),w=3*(s-n),_=m-h,S=v-m-_,R=y-g,A=x-y-R,T=2*_/S,M=b/S,L=C/S,I=E/S,O=h/S-t/S,B=2*R/A-T,F=M-P/A,D=L-k/A,z=I-w/A,U=g/A-n/A-O;let N=(0,o.calculateEquation5)([F*F,2*F*D,D*D+2*F*z,-M*B*B+-T*B*F+2*D*z+2*F*U,-L*B*B+-T*B*D+z*z+2*D*U,-I*B*B+-T*B*z+2*z*U,O*B*B+-T*B*U+U*U],.5,p);f||(N=N.filter((e=>(0,i.isValidPercent)(e))));let G=N.map((e=>({x:b*e*e*e+C*e*e+E*e+t,y:P*e*e*e+k*e*e+w*e+n})));return f||(G=G.filter((t=>(0,i.isValidPercent)((0,r.getQuadraticCurvePercentAtPoint)(e,t))))),G}function se(e,{from:{x:t,y:n},cp1:{x:a,y:s},cp2:{x:l,y:c},to:{x:u,y:d}},p,f=!1){const{from:{x:h,y:g},cp1:{x:m,y},cp2:{x:v,y:x},to:{x:b,y:C}}=e,E=3*a-t+-3*l+u,P=3*(t-2*a+l),k=3*(a-t),w=3*s-n+-3*c+d,_=3*(n-2*s+c),S=3*(s-n),R=3*m-h+-3*v+b,A=3*y-g+-3*x+C,T=3*(h-2*m+v)/R,M=3*(m-h)/R,L=E/R,I=P/R,O=k/R,B=h/R-t/R,F=3*(g-2*y+x)/A-T,D=(3*(y-g)/A-M)/F/2,z=(L-w/A)/F,U=(I-_/A)/F,N=(O-S/A)/F,G=D*D-(g/A-n/A-B)/F,j=T-3*D,V=G+(-2*T*D+3*D*D+M),W=-z*j-L,H=-U*j-I,q=-N*j-O,$=G*j+(T*D*D+-M*D+B+-D*D*D);let Y=(0,o.calculateEquation5)([z*z*z,3*z*z*U,3*z*U*U+3*z*z*N,W*W+U*U*U+6*z*U*N+-z*z*G+-2*z*z*V,2*W*H+3*U*U*N+3*z*N*N+-2*z*U*G+-4*z*U*V,H*H+2*W*q+3*U*N*N+-U*U*G+-2*z*N*G+-2*U*U*V+-4*z*N*V,2*H*q+2*W*$+N*N*N+-2*U*N*G+-4*U*N*V+2*z*G*V+z*V*V,q*q+2*H*$+-N*N*G+-2*N*N*V+2*U*G*V+U*V*V,2*q*$+2*N*G*V+N*V*V,$*$+-G*V*V],.5,p);f||(Y=Y.filter((e=>(0,i.isValidPercent)(e))));let K=Y.map((e=>({x:E*e*e*e+P*e*e+k*e+t,y:w*e*e*e+_*e*e+S*e+n})));return f||(K=K.filter((t=>(0,i.isValidPercent)((0,r.getBezierCurvePercentAtPoint)(e,t))))),K}function le(e,t){if(Array.isArray(e)){const n=(0,l.twoPointLineToGeneralFormLine)(...e);if(!n)return;if(Array.isArray(t)){const r=(0,l.twoPointLineToGeneralFormLine)(...t);if(!r)return;if(!(0,l.isSameLine)(n,r))return;const o=(0,a.deduplicatePosition)([...e.filter((e=>(0,l.pointIsOnLineSegment)(e,...t))),...t.filter((t=>(0,l.pointIsOnLineSegment)(t,...e)))]);return o.length>=2?(0,f.getPartOfGeometryLine)((0,f.getGeometryLineParamAtPoint)(o[0],e),(0,f.getGeometryLineParamAtPoint)(o[1],e),e):void 0}if("ray"===t.type){const r=(0,l.pointAndDirectionToGeneralFormLine)(t.line,(0,p.angleToRadian)(t.line.angle));if(!(0,l.isSameLine)(n,r))return;if(t.line.bidirectional)return e;const o=(0,a.deduplicatePosition)([...e.filter((e=>(0,l.pointIsOnRay)(e,t.line))),...(0,l.pointIsOnLineSegment)(t.line,...e)?[t.line]:[]]);return o.length>=2?(0,f.getPartOfGeometryLine)((0,f.getGeometryLineParamAtPoint)(o[0],e),(0,f.getGeometryLineParamAtPoint)(o[1],e),e):void 0}}else{if(Array.isArray(t))return le(t,e);if("arc"!==e.type){if("arc"===t.type)return le(t,e);if("ellipse arc"!==e.type){if("ellipse arc"===t.type)return le(t,e);if("ray"!==e.type)return"ray"===t.type?le(t,e):void 0;if("ray"===t.type){const n=(0,l.pointAndDirectionToGeneralFormLine)(e.line,(0,p.angleToRadian)(e.line.angle)),r=(0,l.pointAndDirectionToGeneralFormLine)(t.line,(0,p.angleToRadian)(t.line.angle));if(!(0,l.isSameLine)(n,r))return;if(e.line.bidirectional)return t;if(t.line.bidirectional)return e;const o=e.line.reversed?(0,m.reverseAngle)(e.line.angle):e.line.angle,i=t.line.reversed?(0,m.reverseAngle)(t.line.angle):t.line.angle;if((0,g.twoAnglesSameDirection)(o,i))return(0,l.pointIsOnRay)(e.line,t.line)?e:t;const s=(0,a.deduplicatePosition)([...(0,l.pointIsOnRay)(e.line,t.line)?[e.line]:[],...(0,l.pointIsOnRay)(t.line,e.line)?[t.line]:[]]);return s.length>=2?(0,f.getPartOfGeometryLine)((0,f.getGeometryLineParamAtPoint)(s[0],e),(0,f.getGeometryLineParamAtPoint)(s[1],e),e):void 0}}else if("ellipse arc"===t.type){if(!(0,c.isSameEllipse)(e.curve,t.curve))return;const n=(0,c.getEllipseArcStartAndEnd)(e.curve),r=(0,c.getEllipseArcStartAndEnd)(t.curve),o=(0,a.deduplicatePosition)([...[n.start,n.end].filter((e=>(0,c.pointIsOnEllipseArc)(e,t.curve))),...[r.start,r.end].filter((t=>(0,c.pointIsOnEllipseArc)(t,e.curve)))]);return o.length>=2?(0,f.getPartOfGeometryLine)((0,f.getGeometryLineParamAtPoint)(o[0],e),(0,f.getGeometryLineParamAtPoint)(o[1],e),e):void 0}}else if("arc"===t.type){if(!(0,u.isSameCircle)(e.curve,t.curve))return;const n=(0,u.getArcStartAndEnd)(e.curve),r=(0,u.getArcStartAndEnd)(t.curve),o=(0,a.deduplicatePosition)([...[n.start,n.end].filter((e=>(0,u.pointIsOnArc)(e,t.curve))),...[r.start,r.end].filter((t=>(0,u.pointIsOnArc)(t,e.curve)))]);return o.length>=2?(0,f.getPartOfGeometryLine)((0,f.getGeometryLineParamAtPoint)(o[0],e),(0,f.getGeometryLineParamAtPoint)(o[1],e),e):void 0}}}},1074:(e,t,n)=>{"use strict";function r(e){return Array.isArray(e)}n.r(t),n.d(t,{isArray:()=>r})},6022:(e,t,n)=>{"use strict";function r(e){return"object"==typeof e&&null!==e}function o(e){return"function"==typeof e}n.r(t),n.d(t,{isFunction:()=>o,isRecord:()=>r})},9292:(e,t,n)=>{"use strict";function*r(e){if(Array.isArray(e))for(const t of e)t&&(yield t);else yield e}function o(e){return void 0===e?[]:Array.isArray(e)?e:[e]}n.r(t),n.d(t,{itemToArray:()=>o,iterateItemOrArray:()=>r})},623:(e,t,n)=>{"use strict";n.r(t),n.d(t,{metaKeyIfMacElseCtrlKey:()=>o});const r="undefined"!=typeof navigator&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function o(e){return r?e.metaKey:e.ctrlKey}},7764:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Lazy:()=>o});var r=Object.defineProperty;class o{constructor(e,t){var n,o;this.getInstance=e,this.destroy=t,((e,t,n)=>{t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(this,"symbol"!=typeof(n="_instance")?n+"":n,o)}get instance(){return void 0===this._instance&&(this._instance=this.getInstance()),this._instance}get instanced(){return void 0!==this._instance}reset(){var e;this._instance&&(null==(e=this.destroy)||e.call(this,this._instance)),this._instance=void 0}}},7558:(e,t,n)=>{"use strict";n.r(t),n.d(t,{cotesIntegral:()=>R,getArcLength:()=>P,getArcRadianByLength:()=>L,getBezierCurveLength:()=>S,getBezierCurvePercentByLength:()=>F,getCircleLength:()=>E,getCircleRadianByLength:()=>M,getEllipseArcLength:()=>w,getEllipseArcRadianByLength:()=>O,getEllipseLength:()=>k,getEllipseRadianByLength:()=>I,getGeometryLineLength:()=>U,getGeometryLineParamByLength:()=>z,getGeometryLinesLength:()=>N,getGeometryLinesPointAndTangentRadianByLength:()=>D,getLineParamByLength:()=>T,getQuadraticCurveLength:()=>_,getQuadraticCurvePercentByLength:()=>B,rombergIntegral:()=>A});var r=n(5629),o=n(1475),i=n(2792),a=n(5773),s=n(8831),l=n(2298),c=n(5717),u=n(8230),d=n(1715),p=Object.defineProperty,f=Object.defineProperties,h=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,v=Math.pow,x=(e,t,n)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))m.call(t,n)&&x(e,n,t[n]);if(g)for(var n of g(t))y.call(t,n)&&x(e,n,t[n]);return e},C=(e,t)=>f(e,h(t));function E(e){return 2*Math.PI*e.r}function P(e){const t=(0,s.getFormattedEndAngle)(e);return e.r*(0,d.angleToRadian)(Math.abs(t-e.startAngle))}function k(e,t){return w((0,l.ellipseToEllipseArc)(e),t)}function w(e,t){const n=v(e.rx,2),r=v(e.ry,2),o=(0,d.angleToRadian)(e.startAngle),i=(0,d.angleToRadian)((0,s.getFormattedEndAngle)(e));return A(Math.min(o,i),Math.max(o,i),(e=>Math.sqrt(n*v(Math.sin(e),2)+r*v(Math.cos(e),2))),t)}function _({from:{x:e,y:t},cp:{x:n,y:r},to:{x:o,y:i}},a){const s=n-e,l=o-n-s,c=r-t,u=i-r-c,d=l*l+u*u,p=2*s*l+2*c*u,f=s*s+c*c;return A(0,1,(e=>2*Math.sqrt(d*e*e+p*e+f)),a)}function S({from:{x:e,y:t},cp1:{x:n,y:r},cp2:{x:o,y:i},to:{x:a,y:s}}){const l=3*n-e+-3*o+a,c=3*(e-2*n+o),u=3*(n-e),d=3*r-t+-3*i+s,p=3*(t-2*r+i),f=3*(r-t),h=9*l*l+9*d*d,g=12*l*c+12*d*p,m=4*c*c+6*l*u+4*p*p+6*d*f,y=4*c*u+4*p*f,v=u*u+f*f;return A(0,1,(e=>Math.sqrt(h*e*e*e*e+g*e*e*e+m*e*e+y*e+v)))}function R(e,t,n,r){if(r&&Number.isInteger(r)&&r>1){let o=0;const i=(t-e)/r;for(let t=0;tw(C(b({},e),{endAngle:(0,d.radianToAngle)(n)}))-t),(e=>Math.sqrt(r*v(Math.sin(e),2)+a*v(Math.cos(e),2))),n)}function B(e,t,n=i.delta2){const{from:{x:a,y:s},cp:{x:l,y:c},to:{x:u,y:d}}=e,p=l-a,f=u-l-p,h=c-s,g=d-c-h,m=f*f+g*g,y=2*p*f+2*h*g,v=p*p+h*h;return(0,o.newtonIterate)(.5,(n=>_((0,r.getPartOfQuadraticCurve)(e,0,n))-t),(e=>2*Math.sqrt(m*e*e+y*e+v)),n)}function F(e,t,n=i.delta2){const{from:{x:a,y:s},cp1:{x:l,y:c},cp2:{x:u,y:d},to:{x:p,y:f}}=e,h=3*l-a+-3*u+p,g=3*(a-2*l+u),m=3*(l-a),y=3*c-s+-3*d+f,v=3*(s-2*c+d),x=3*(c-s),b=9*h*h+9*y*y,C=12*h*g+12*y*v,E=4*g*g+6*h*m+4*v*v+6*y*x,P=4*g*m+4*v*x,k=m*m+x*x;return(0,o.newtonIterate)(.5,(n=>S((0,r.getPartOfBezierCurve)(e,0,n))-t),(e=>Math.sqrt(b*e*e*e*e+C*e*e*e+E*e*e+P*e+k)),n)}function D(e,t,n){for(const[r,o]of e.entries()){const e=n?n[r]:U(o);if(void 0===e)return;if((0,i.lessOrEqual)(t,e)){const e=z(o,t);if(void 0===e)return;return(0,c.getGeometryLinePointAndTangentRadianAtParam)(e,o)}t-=e}}function z(e,t){if(Array.isArray(e))return T(...e,t);if("arc"===e.type)return((0,d.radianToAngle)(L(e.curve,t))-e.curve.startAngle)/(e.curve.endAngle-e.curve.startAngle);if("ellipse arc"===e.type){if(void 0===O(e.curve,t))return;return((0,d.radianToAngle)()-e.curve.startAngle)/(e.curve.endAngle-e.curve.startAngle)}return"quadratic curve"===e.type?B(e.curve,t):"bezier curve"===e.type?F(e.curve,t):"nurbs curve"===e.type?(0,u.getNurbsCurveParamByLength)(e.curve,t)/(0,u.getNurbsMaxParam)(e.curve):void 0}function U(e){return Array.isArray(e)?(0,a.getTwoPointsDistance)(...e):"arc"===e.type?P(e.curve):"ellipse arc"===e.type?w(e.curve):"quadratic curve"===e.type?_(e.curve):"bezier curve"===e.type?S(e.curve):"ray"!==e.type?(0,u.getNurbsCurveLength)(e.curve):void 0}function N(e){let t=0;for(const n of e){const e=U(n);if(void 0===e)return;t+=e}return t}},1796:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Ray:()=>E,dashedPolylineToLines:()=>L,drawDashedLine:()=>O,drawDashedPolyline:()=>I,generalFormLineToTwoPointLine:()=>M,getGeneralFormLineRadian:()=>z,getLineParamAtPoint:()=>Q,getParallelLineSegmentsByDistance:()=>F,getParallelLinesByDistance:()=>B,getParallelRaysByDistance:()=>D,getPointSideOfLine:()=>R,getPolygonArea:()=>W,getPolygonLine:()=>H,getPolygonPoints:()=>q,getRayLineSegmentIntersectionDistance:()=>K,getRayParamAtPoint:()=>J,getRayPointAtDistance:()=>$,getRayStartAndEnd:()=>Z,getRayTransformedLineSegment:()=>X,getSymmetryPoint:()=>U,isSameLine:()=>S,iteratePolygonLines:()=>j,iteratePolylineLines:()=>G,pointAndDirectionToGeneralFormLine:()=>T,pointInPolygon:()=>N,pointIsOnGeneralFormLine:()=>w,pointIsOnLine:()=>k,pointIsOnLineSegment:()=>P,pointIsOnRay:()=>_,polygonToPolyline:()=>V,rayToLineSegment:()=>Y,twoPointLineToGeneralFormLine:()=>A});var r=n(5773),o=n(1715),i=n(2792),a=n(5569),s=n(360),l=n(5147),c=Object.defineProperty,u=Object.defineProperties,d=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,g=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),m=Math.pow,y=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))f.call(t,n)&&y(e,n,t[n]);if(p)for(var n of p(t))h.call(t,n)&&y(e,n,t[n]);return e},x=(e,t)=>u(e,d(t)),b=function(e,t){this[0]=e,this[1]=t},C=e=>{var t,n=e[g("asyncIterator")],r=!1,o={};return null==n?(n=e[g("iterator")](),t=e=>o[e]=t=>n[e](t)):(n=n.call(e),t=e=>o[e]=t=>{if(r){if(r=!1,"throw"===e)throw t;return t}return r=!0,{done:!1,value:new b(new Promise((r=>{var o=n[e](t);if(!(o instanceof Object))throw TypeError("Object expected");r(o)})),1)}}),o[g("iterator")]=()=>o,t("next"),"throw"in n?t("throw"):o.throw=e=>{throw e},"return"in n&&t("return"),o};const E=(0,a.and)(r.Position,{angle:a.number,bidirectional:(0,a.optional)(a.boolean),reversed:(0,a.optional)(a.boolean)});function P(e,t,n){return!((0,i.isSameNumber)(t.x,n.x)||!(0,i.isBetween)(e.x,t.x,n.x))||!((0,i.isSameNumber)(t.y,n.y)||!(0,i.isBetween)(e.y,t.y,n.y))}function k(e,t,n){const r=A(t,n);return!!r&&w(e,r)}function w(e,{a:t,b:n,c:r}){return(0,i.isZero)(t*e.x+n*e.y+r)}function _(e,t){const n=(0,o.angleToRadian)(t.angle);return t.bidirectional?w(e,T(e,n)):(0,r.isSamePoint)(e,t)||(0,i.isSameNumber)(n,(0,o.getTwoPointsRadian)(e,t))}function S(e,t){return!!(0,i.equals)(e.a*t.b,t.a*e.b)&&((0,i.isZero)(e.a)?(0,i.equals)(e.b*t.c,t.b*e.c):(0,i.equals)(e.a*t.c,t.a*e.c))}function R(e,t){return t.a*e.x+t.b*e.y+t.c}function A(e,t){if((0,r.isSamePoint)(e,t))return;const n=t.x-e.x,o=t.y-e.y;return{a:o,b:-n,c:-e.x*o+e.y*n}}function T(e,t){const n=Math.cos(t),r=Math.sin(t);return{a:r,b:-n,c:-e.x*r+e.y*n}}function M({a:e,b:t,c:n}){return(0,i.isZero)(e)?[{x:0,y:-n/t},{x:1,y:-n/t}]:(0,i.isZero)(t)?[{x:-n/e,y:0},{x:-n/e,y:1}]:[{x:0,y:-n/t},{x:-n/e,y:0}]}function L(e,t,n,r=0){if(!t||0===t.length)return[e];const o=[];let i=[];return I({moveTo(e,t){i.length>1&&o.push(i),i=[{x:e,y:t}]},lineTo(e,t){0===i.length&&i.push({x:0,y:0}),i.push({x:e,y:t})}},e,t,n,r),i.length>1&&o.push(i),o}function I(e,t,n,r,o=0){n.length%2==1&&(n=[...n,...n]),n.reduce(((e,t)=>e+t))<=0||t.forEach(((i,a)=>{0===a||(null==r?void 0:r.includes(a-1))?e.moveTo(i.x,i.y):o=O(e,t[a-1],i,n,o)}))}function O(e,t,n,o,i=0){o.length%2==1&&(o=[...o,...o]);const a=o.reduce(((e,t)=>e+t));if(a<=0)return i;let s=(0,r.getTwoPointsDistance)(t,n);const l=(i+s)%a;let c=t;for(;s>0;)for(let t=0;t0){if(a<=i){i-=a;continue}a-=i,i=0}const u=t%2==0?"lineTo":"moveTo";if(a>=s)return e[u](n.x,n.y),l;const d=(0,r.getPointByLengthAndDirection)(c,a,n);e[u](d.x,d.y),s-=a,c=d}return l}function B(e,t){if((0,i.isZero)(t))return[e,e];const n=t*Math.sqrt(m(e.a,2)+m(e.b,2));return[x(v({},e),{c:e.c+n}),x(v({},e),{c:e.c-n})]}function F(e,t){if((0,i.isZero)(t))return[e,e];if((0,r.isSamePoint)(...e))return;const n=(0,o.getTwoPointsRadian)(e[1],e[0]),a=n-Math.PI/2,s=n+Math.PI/2;return[[(0,r.getPointByLengthAndRadian)(e[0],t,s),(0,r.getPointByLengthAndRadian)(e[1],t,s)],[(0,r.getPointByLengthAndRadian)(e[0],t,a),(0,r.getPointByLengthAndRadian)(e[1],t,a)]]}function D(e,t){if((0,i.isZero)(t))return[e,e];const n=(0,o.angleToRadian)(e.angle);return[v(v({},e),(0,r.getPointByLengthAndRadian)(e,t,n+Math.PI/2)),v(v({},e),(0,r.getPointByLengthAndRadian)(e,t,n-Math.PI/2))]}function z({a:e,b:t}){return Math.atan2(e,-t)}function U(e,{a:t,b:n,c:r}){const o=m(t,2),i=m(n,2),a=o+i,s=-2*t*n,l=i-o;return{x:(l*e.x+s*e.y-2*t*r)/a,y:(s*e.x-l*e.y-2*n*r)/a}}function N({x:e,y:t},n){let r=!1;for(let o=0,a=n.length-1;oe-t)),[$(e,n[0]),$(e,n[n.length-1])])}function K({x:e,y:t,angle:n,bidirectional:r},a){const s=A(...a);if(!s)return;const l=(0,o.angleToRadian)(n),c=Math.cos(l),u=Math.sin(l),{a:d,b:p,c:f}=s,h=d*c+p*u;if((0,i.isZero)(h))return;const g=-(d*e+p*t+f)/h;return!r&&(0,i.lessOrEqual)(g,0)||!P({x:e+g*c,y:t+g*u},...a)?void 0:g}function X(e,t,n,r,o){let i=[{x:0,y:0},{x:t,y:0},{x:t,y:n},{x:0,y:n}];if(r){const e=x(v({},r),{center:{x:t/2,y:n/2}});i=i.map((t=>(0,s.reverseTransformPosition)(t,e)))}if(o){const e=l.m3.inverse(o);i=i.map((t=>{const n=l.m3.multiplyVec3(e,[t.x,t.y,1]);return{x:n[0],y:n[1]}}))}return Y(e,i)}function Z(e){return{start:e.bidirectional||e.reversed?void 0:e,end:!e.bidirectional&&e.reversed?e:void 0}}function Q(e,t,n){return(0,i.isSameNumber)(e.x,t.x)?(n.y-e.y)/(t.y-e.y):(n.x-e.x)/(t.x-e.x)}function J(e,t){const n=(0,r.getTwoPointsDistance)(e,t);return(0,i.isZero)(n)?0:n*((0,i.isSameNumber)((0,o.angleToRadian)(e.angle),(0,o.getTwoPointsRadian)(t,e))?1:-1)*(e.reversed?-1:1)}},2792:(e,t,n)=>{"use strict";n.r(t),n.d(t,{deduplicate:()=>b,deepEquals:()=>h,delta1:()=>o,delta2:()=>i,delta3:()=>a,equals:()=>C,findFrom:()=>M,findIndexFrom:()=>T,first:()=>R,formatNumber:()=>P,getTwoNumberCenter:()=>y,getTwoNumbersDistance:()=>m,isBetween:()=>v,isSameNumber:()=>E,isValidPercent:()=>p,isZero:()=>s,largerOrEqual:()=>u,largerThan:()=>c,lessOrEqual:()=>d,lessThan:()=>l,maxmiumBy:()=>w,maxmiumsBy:()=>S,minimumBy:()=>k,minimumsBy:()=>_,multiplyOpacity:()=>A,numberRangeIsOverlapped:()=>x,shallowEquals:()=>g,sqrt3:()=>f});var r=n(6022);const o=1e-8,i=1e-5,a=.001;function s(e,t=o){return Math.abs(e)t&&!E(e,t,n)}function u(e,t,n){return e>t||E(e,t,n)}function d(e,t,n){return e!t(e,r)))&&n.push(r);return n}function C(e,t){return void 0===e&&void 0===t||void 0!==e&&void 0!==t&&E(e,t)}function E(e,t,n){return s(e-t,n)}function P(e,t=100){return Math.round(e*t)/t}function k(e,t){let n=e[0];for(let r=1;r=0;r--)if(n(e[r]))return r;if(null==r?void 0:r.closed)for(let r=e.length-1;r>t;r--)if(n(e[r]))return r}else{for(let r=t;r{"use strict";n.r(t),n.d(t,{getRenderOptionsMatrix:()=>s,getRotationOptionsAngle:()=>i,getScaleOptionsScale:()=>a,m3:()=>o,multiplyMatrix:()=>l});var r=n(1715);const o={projection:(e,t)=>[2/e,0,0,0,-2/t,0,-1,1,1],identity:()=>[1,0,0,0,1,0,0,0,1],translation:(e,t)=>[1,0,0,0,1,0,e,t,1],rotation(e){const t=Math.cos(e),n=Math.sin(e);return[t,-n,0,n,t,0,0,0,1]},scaling:(e,t)=>[e,0,0,0,t,0,0,0,1],multiply:(e,t)=>[t[0]*e[0]+t[1]*e[3]+t[2]*e[6],t[0]*e[1]+t[1]*e[4]+t[2]*e[7],t[0]*e[2]+t[1]*e[5]+t[2]*e[8],t[3]*e[0]+t[4]*e[3]+t[5]*e[6],t[3]*e[1]+t[4]*e[4]+t[5]*e[7],t[3]*e[2]+t[4]*e[5]+t[5]*e[8],t[6]*e[0]+t[7]*e[3]+t[8]*e[6],t[6]*e[1]+t[7]*e[4]+t[8]*e[7],t[6]*e[2]+t[7]*e[5]+t[8]*e[8]],multiplyVec3:(e,t)=>[t[0]*e[0]+t[1]*e[3]+t[2]*e[6],t[0]*e[1]+t[1]*e[4]+t[2]*e[7],t[0]*e[2]+t[1]*e[5]+t[2]*e[8]],inverse([e,t,n,r,o,i,a,s,l]){const c=o*l-i*s,u=t*i-n*o,d=n*s-t*l,p=u*a+r*d+e*c;return[c/p,d/p,u/p,(i*a-r*l)/p,(-n*a+e*l)/p,(n*r-e*i)/p,(r*s-o*a)/p,(t*a-e*s)/p,(e*o-t*r)/p]},getTransform:e=>[e[0],e[1],e[3],e[4],e[6],e[7]],getTransformInit:e=>({a:e[0],b:e[1],c:e[3],d:e[4],e:e[6],f:e[7]})};function i(e,t=!1){return(null==e?void 0:e.angle)?t?(0,r.angleToRadian)(e.angle):e.angle:(null==e?void 0:e.rotation)?t?e.rotation:(0,r.radianToAngle)(e.rotation):void 0}function a(e){if(null==e?void 0:e.scale)return"number"==typeof e.scale?{x:e.scale,y:e.scale}:e.scale}function s(e){if(!e)return;let t=o.identity();if(e.translate&&(t=o.multiply(t,o.translation(e.translate.x,e.translate.y))),e.base){const n=i(e,!0);n&&(t=o.multiply(t,o.translation(e.base.x,e.base.y)),t=o.multiply(t,o.rotation(-n)),t=o.multiply(t,o.translation(-e.base.x,-e.base.y)));const r=a(e);r&&(t=o.multiply(t,o.translation(e.base.x,e.base.y)),t=o.multiply(t,o.scaling(r.x,r.y)),t=o.multiply(t,o.translation(-e.base.x,-e.base.y)))}return e.matrix&&(t=o.multiply(t,e.matrix)),t}function l(e,t){return void 0===e?t:void 0===t?e:o.multiply(e,t)}},6300:(e,t,n)=>{"use strict";function r(...e){let t=0;for(const n of e)t+=o(n);const n=new Float32Array(t);let r=0;for(const t of e){if("mat3x3"===t.type)n.set(t.value.slice(0,3),r),n.set(t.value.slice(3,6),r+4),n.set(t.value.slice(6,9),r+8);else if("mat4x4"===t.type)n.set(t.value.slice(0,16),r);else if("vec4"===t.type||"vec3"===t.type||"vec2"===t.type)n.set(t.value,r);else if("number"===t.type)n.set([t.value],r);else if("vec4 array"===t.type)n.set(t.value,r);else if("inline"===t.type){let e=0;for(const o of t.children)"number"===o.type?(n.set([o.value],r+e),e++):(n.set(o.value,r+e),"vec2"===o.type?e+=2:"vec3"===o.type&&(e+=3))}r+=o(t)}return n}function o(e){return"mat3x3"===e.type?12:"mat4x4"===e.type?16:"vec4"===e.type||"number"===e.type||"vec2"===e.type||"vec3"===e.type||"inline"===e.type?4:"vec4 array"===e.type?4*e.count:0}n.r(t),n.d(t,{createMemoryLayoutArray:()=>r})},2572:(e,t,n)=>{"use strict";n.r(t),n.d(t,{isSameDerivative:()=>I,mergeArc:()=>b,mergeBezierCurve:()=>R,mergeBezierCurvesToBezierSpline:()=>L,mergeEllipseArc:()=>C,mergeGeometryLine:()=>O,mergeLineSegment:()=>x,mergeQuadraticCurve:()=>P,mergeQuadraticCurvesToQuadraticSpline:()=>S});var r=n(5629),o=n(2792),i=n(5773),a=n(1796),s=n(2298),l=n(2318),c=n(8306),u=Object.defineProperty,d=Object.defineProperties,p=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,m=(e,t,n)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))h.call(t,n)&&m(e,n,t[n]);if(f)for(var n of f(t))g.call(t,n)&&m(e,n,t[n]);return e},v=(e,t)=>d(e,p(t));function x(e,t){return(0,i.isSamePoint)(e[1],t[0])?(0,a.pointIsOnLine)(t[1],...e)?[e[0],t[1]]:void 0:x(t,e)}function b(e,t){if((0,l.isSameCircle)(e,t))return e.counterclockwise!==t.counterclockwise&&(t=(0,c.reverseArc)(t)),E(e,t)}function C(e,t){if((0,s.isSameEllipse)(e,t))return e.counterclockwise!==t.counterclockwise&&(t=(0,c.reverseEllipseArc)(t)),E(e,t)}function E(e,t){return(0,o.isZero)(Math.abs(e.endAngle-t.startAngle)%360)?(0,o.isZero)(Math.abs(e.startAngle-t.endAngle)%360)?v(y({},e),{startAngle:0,endAngle:360}):v(y({},e),{endAngle:t.endAngle}):(0,o.isZero)(Math.abs(e.startAngle-t.endAngle)%360)?v(y({},e),{startAngle:t.startAngle}):void 0}function P(e,t){const n=(0,r.getQuadraticCurveDerivatives)(e),o=(0,r.getQuadraticCurveDerivatives)(t);if(w(n,o)&&_(n,o))return k(e,t)}function k(e,t){const n=(0,r.getQuadraticCurvePercentAtPoint)(e,t.to);return(0,r.getPartOfQuadraticCurve)(e,0,n)}function w(e,t){return I(e[0](1),t[0](0))&&I(e[1](1),t[1](0))}function _(e,t){return I(e[2](1),t[2](0))}function S(e){if(0===e.length)return;const t=e[0];if(1===e.length)return[t.from,t.cp,t.to];const n=[(0,r.getQuadraticCurveDerivatives)(t)],o=[t.from,t.cp];for(let t=1;;t++){if(n.push((0,r.getQuadraticCurveDerivatives)(e[t])),!w(n[t-1],n[t]))return;if(_(n[t-1],n[t]))return S([...e.slice(0,t-1),k(e[t-1],e[t]),...e.slice(t+1)]);if(!(0,i.isSamePoint)((0,i.getTwoPointCenter)(e[t-1].cp,e[t].cp),e[t-1].to))return;if(o.push(e[t].cp),e.length===t+1)return[...o,e[e.length-1].to]}}function R(e,t){const n=(0,r.getBezierCurveDerivatives)(e),o=(0,r.getBezierCurveDerivatives)(t);if(T(n,o)&&M(n,o))return A(e,t)}function A(e,t){const n=(0,r.getBezierCurvePercentAtPoint)(e,t.to);return(0,r.getPartOfBezierCurve)(e,0,n)}function T(e,t){return I(e[0](1),t[0](0))&&I(e[1](1),t[1](0))&&I(e[2](1),t[2](0))}function M(e,t){return I(e[3](1),t[3](0))}function L(e){if(0===e.length)return;const t=e[0];if(1===e.length)return[t.from,t.cp1,t.cp2,t.to];const n=[(0,r.getBezierCurveDerivatives)(t)],o=[t.from,t.cp1];for(let t=1;;t++){if(n.push((0,r.getBezierCurveDerivatives)(e[t])),!T(n[t-1],n[t]))return;if(M(n[t-1],n[t]))return L([...e.slice(0,t-1),A(e[t-1],e[t]),...e.slice(t+1)]);if(!(0,i.isSamePoint)((0,i.getTwoPointCenter)(e[t-1].cp2,e[t].cp1),e[t-1].to))return;if(o.push({x:2*e[t].cp1.x-e[t].cp2.x,y:2*e[t].cp1.y-e[t].cp2.y}),e.length===t+1)return[...o,e[e.length-1].cp2,e[e.length-1].to]}}function I(e,t){return(0,o.isSameNumber)(e.x*t.y,e.y*t.x)}function O(e,t){if(Array.isArray(e)&&Array.isArray(t))return x(e,t);if(!Array.isArray(e)&&!Array.isArray(t)){if("arc"===e.type&&"arc"===t.type){const n=b(e.curve,t.curve);if(!n)return;return{type:"arc",curve:n}}if("ellipse arc"===e.type&&"ellipse arc"===t.type){const n=C(e.curve,t.curve);if(!n)return;return{type:"ellipse arc",curve:n}}if("quadratic curve"===e.type&&"quadratic curve"===t.type){const n=P(e.curve,t.curve);if(!n)return;return{type:"quadratic curve",curve:n}}if("bezier curve"===e.type&&"bezier curve"===t.type){const n=R(e.curve,t.curve);if(!n)return;return{type:"bezier curve",curve:n}}}}},9596:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Merger:()=>o});var r=Object.defineProperty;class o{constructor(e,t,n){var o,i;this.flush=e,this.equals=t,this.getTarget=n,((e,t,n)=>{t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(this,"symbol"!=typeof(o="last")?o+"":o,i)}flushLast(){this.last&&this.last.target.length>0&&(this.flush(this.last),this.last=void 0)}push(e){this.last?this.equals(this.last.type,e)?this.last.target.push(this.getTarget(e)):(this.flushLast(),this.push(e)):this.last={type:e,target:[this.getTarget(e)]}}}},4575:(e,t,n)=>{"use strict";n.r(t),n.d(t,{extendGeometryLines:()=>G,mirrorArc:()=>R,mirrorEllipse:()=>A,mirrorGeometryLine:()=>T,mirrorPoint:()=>S,moveEllipse:()=>C,moveGeometryLine:()=>E,movePoint:()=>b,rotateArc:()=>k,rotateEllipse:()=>w,rotateGeometryLine:()=>_,rotatePoint:()=>P,scaleEllipse:()=>L,scaleEllipseArc:()=>I,scaleGeometryLine:()=>O,scaleGeometryLines:()=>B,scalePoint:()=>M,skewEllipse:()=>D,skewEllipseArc:()=>z,skewGeometryLine:()=>U,skewGeometryLines:()=>N,skewPoint:()=>F});var r=n(5773),o=n(1796),i=n(2298),a=n(2318),s=n(1715),l=n(2792),c=n(1475),u=n(5629),d=Object.defineProperty,p=Object.defineProperties,f=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,y=(e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))g.call(t,n)&&y(e,n,t[n]);if(h)for(var n of h(t))m.call(t,n)&&y(e,n,t[n]);return e},x=(e,t)=>p(e,f(t));function b(e,t){e.x+=t.x,e.y+=t.y}function C(e,t){e.cx+=t.x,e.cy+=t.y}function E(e,t){if(Array.isArray(e))b(e[0],t),b(e[1],t);else if("arc"===e.type)b(e.curve,t);else if("ellipse arc"===e.type)C(e.curve,t);else if("quadratic curve"===e.type)b(e.curve.from,t),b(e.curve.cp,t),b(e.curve.to,t);else if("bezier curve"===e.type)b(e.curve.from,t),b(e.curve.cp1,t),b(e.curve.cp2,t),b(e.curve.to,t);else if("nurbs curve"===e.type)for(const n of e.curve.points)b(n,t)}function P(e,t,n){const o=(0,r.rotatePositionByCenter)(e,t,-n);return e.x=o.x,e.y=o.y,o}function k(e,t,n){P(e,t,n),e.startAngle+=n,e.endAngle+=n}function w(e,t,n){var r;const o=P((0,i.getEllipseCenter)(e),t,n);e.cx=o.x,e.cy=o.y,e.angle=(null!=(r=e.angle)?r:0)+n}function _(e,t,n){if(Array.isArray(e))P(e[0],t,n),P(e[1],t,n);else if("arc"===e.type)k(e.curve,t,n);else if("ellipse arc"===e.type)w(e.curve,t,n);else if("quadratic curve"===e.type)P(e.curve.from,t,n),P(e.curve.cp,t,n),P(e.curve.to,t,n);else if("bezier curve"===e.type)P(e.curve.from,t,n),P(e.curve.cp1,t,n),P(e.curve.cp2,t,n),P(e.curve.to,t,n);else if("nurbs curve"===e.type)for(const r of e.curve.points)P(r,t,n)}function S(e,t){const n=(0,o.getSymmetryPoint)(e,t);return e.x=n.x,e.y=n.y,n}function R(e,t,n){S(e,t);const r=2*n-e.endAngle,o=2*n-e.startAngle;e.startAngle=r,e.endAngle=o}function A(e,t,n){var r;const o=S((0,i.getEllipseCenter)(e),t);e.cx=o.x,e.cy=o.y,e.angle=2*n-(null!=(r=e.angle)?r:0)}function T(e,t,n){if(Array.isArray(e))S(e[0],t),S(e[1],t);else if("arc"===e.type)R(e.curve,t,n);else if("ellipse arc"===e.type)A(e.curve,t,n);else if("quadratic curve"===e.type)S(e.curve.from,t),S(e.curve.cp,t),S(e.curve.to,t);else if("bezier curve"===e.type)S(e.curve.from,t),S(e.curve.cp1,t),S(e.curve.cp2,t),S(e.curve.to,t);else if("nurbs curve"===e.type)for(const n of e.curve.points)S(n,t)}function M(e,t,n,r=n){e.x=(e.x-t.x)*n+t.x,e.y=(e.y-t.y)*r+t.y}function L(e,t,n,r=n){if(e.cx=(e.cx-t.x)*n+t.x,e.cy=(e.cy-t.y)*r+t.y,(0,l.equals)(n,r))return e.rx*=Math.abs(n),void(e.ry*=Math.abs(r));const o=(0,s.angleToRadian)(e.angle),i=Math.sin(o);if((0,l.isZero)(i))return e.rx*=Math.abs(n),void(e.ry*=Math.abs(r));const a=Math.cos(o);if((0,l.isZero)(a))return e.rx*=Math.abs(r),void(e.ry*=Math.abs(n));const u=a/n/e.rx,d=i/r/e.rx,p=-i/n/e.ry,f=a/r/e.ry,h=u*u+p*p,g=u*d+p*f,m=d*d+f*f,y=Math.atan((0,c.calculateEquation2)(g,h-m,-g)[0]);e.angle=(0,s.radianToAngle)(y);const v=Math.sin(y),x=Math.cos(y);e.rx=Math.sqrt((x*x-v*v)/(h*x*x-m*v*v)),e.ry=Math.sqrt((x*x-v*v)/(m*x*x-h*v*v))}function I(e,t,n,r=n){const o=(0,i.getEllipseArcPointAtAngle)(e,e.startAngle),a=(0,i.getEllipseArcPointAtAngle)(e,e.endAngle);M(o,t,n,r),M(a,t,n,r),L(e,t,n,r),e.startAngle=(0,i.getEllipseAngle)(o,e),e.endAngle=(0,i.getEllipseAngle)(a,e)}function O(e,t,n,r=n){if(Array.isArray(e))M(e[0],t,n,r),M(e[1],t,n,r);else if("arc"===e.type){if(n!==r&&!(0,l.isZero)(n+r)){const o=(0,i.arcToEllipseArc)(e.curve);return I(o,t,n,r),{type:"ellipse arc",curve:o}}M(e.curve,t,n,r),e.curve.r*=Math.abs(n)}else if("ellipse arc"===e.type)I(e.curve,t,n,r);else if("quadratic curve"===e.type)M(e.curve.from,t,n,r),M(e.curve.cp,t,n,r),M(e.curve.to,t,n,r);else if("bezier curve"===e.type)M(e.curve.from,t,n,r),M(e.curve.cp1,t,n,r),M(e.curve.cp2,t,n,r),M(e.curve.to,t,n,r);else if("nurbs curve"===e.type)for(const o of e.curve.points)M(o,t,n,r)}function B(e,t,n,r=n){for(let o=0;o{"use strict";n.r(t),n.d(t,{Nurbs:()=>P,NurbsCurve:()=>F,getArcNurbsCurveIntersectionPoints:()=>re,getBezierCurveNurbsCurveIntersectionPoints:()=>ae,getDefaultNurbsKnots:()=>T,getDefaultWeights:()=>M,getEllipseArcNurbsCurveIntersectionPoints:()=>oe,getLineSegmentNurbsCurveIntersectionPoints:()=>ne,getNurbsCurveCurvatureAtParam:()=>de,getNurbsCurveDerivatives:()=>K,getNurbsCurveLength:()=>Z,getNurbsCurveLengthByParam:()=>Q,getNurbsCurveParamAtPoint:()=>V,getNurbsCurveParamByLength:()=>J,getNurbsCurvePointAtParam:()=>W,getNurbsCurvePoints:()=>q,getNurbsCurveStartAndEnd:()=>H,getNurbsMaxParam:()=>j,getNurbsPoints:()=>L,getNurbsPoints3D:()=>I,getNurbsSurfaceTrianglePoints:()=>O,getNurbsSurfaceVertices:()=>B,getParallelNurbsCurvesByDistance:()=>ue,getPartOfNurbsCurve:()=>te,getPerpendicularParamToNurbsCurve:()=>$,getPointAndNurbsCurveNearestPointAndDistance:()=>X,getPointSideOfNurbsCurve:()=>ce,getQuadraticCurveNurbsCurveIntersectionPoints:()=>ie,getTangencyParamToNurbsCurve:()=>Y,getTwoNurbsCurveIntersectionPoints:()=>se,interpolateBSpline:()=>k,interpolateNurbs:()=>w,interpolateNurbs2:()=>R,interpolateNurbs3:()=>A,pointIsOnNurbsCurve:()=>G,reverseNurbsCurve:()=>le,splitNurbsCurve:()=>ee,toBezierCurves:()=>_,toQuadraticCurves:()=>S});var r=n(670),o=n(9397),i=n(2792),a=n(5773),s=n(1796),l=n(2298),c=n(5569),u=n(1715),d=n(1475),p=n(1785),f=Object.defineProperty,h=Object.defineProperties,g=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,x=Math.pow,b=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&b(e,n,t[n]);if(m)for(var n of m(t))v.call(t,n)&&b(e,n,t[n]);return e},E=(e,t)=>h(e,g(t));const P={points:[a.Position],degree:(0,c.minimum)(1,c.integer),knots:(0,c.optional)([c.number]),weights:(0,c.optional)([c.number])};function k(e,t,n,r=T(n.length,t)){const o=t,i=r.length-1-t;e=e*(r[i]-r[o])+r[o];const a=r.findIndex(((t,n)=>n>=o&&n=e)),s=[...n];for(let t=o;t>=0;t--)for(let n=a;n>a-t;n--){const o=(e-r[n])/(r[n+t]-r[n]);s[n]=(1-o)*s[n-1]+o*s[n]}return s[a]}function w(e,t,n,r=T(n.length,t),o){return o?k(e,t,n.map(((e,t)=>n[t]*o[t])),r)/k(e,t,o,r):k(e,t,n,r)}function _(e,t){return 1===t?4===e.length?{from:e[0],cp1:e[1],cp2:e[2],to:e[3]}:5===e.length?{from:e[0],cp1:e[1],cp2:e[1]/2+e[2]/2,to:e[1]/4+e[2]/2+e[3]/4}:{from:e[0],cp1:e[1],cp2:.5*e[2]+.5*e[1],to:e[3]/6+7/12*e[2]+e[1]/4}:2===t?5===e.length?{from:.25*e[1]+.25*e[3]+.5*e[2],cp1:.5*e[2]+.5*e[3],cp2:e[3],to:e[4]}:6===e.length?{from:7/12*e[2]+e[3]/6+.25*e[1],cp1:2/3*e[2]+e[3]/3,cp2:e[2]/3+2/3*e[3],to:e[2]/6+7/12*e[3]+e[4]/4}:{from:e[1]/4+e[3]/6+7/12*e[2],cp1:e[3]/3+2*e[2]/3,cp2:2/3*e[3]+e[2]/3,to:e[4]/6+2/3*e[3]+e[2]/6}:t===e.length-4?{from:e[e.length-5]/6+2/3*e[e.length-4]+e[e.length-3]/6,cp1:e[e.length-3]/3+2/3*e[e.length-4],cp2:2/3*e[e.length-3]+e[e.length-4]/3,to:e[e.length-2]/4+7/12*e[e.length-3]+e[e.length-4]/6}:t===e.length-3?{from:e[e.length-4]/6+7/12*e[e.length-3]+e[e.length-2]/4,cp1:e[e.length-2]/2+e[e.length-3]/2,cp2:e[e.length-2],to:e[e.length-1]}:{from:e[t+1]/6+2/3*e[t]+e[t-1]/6,cp1:e[t+1]/3+2*e[t]/3,cp2:2*e[t+1]/3+e[t]/3,to:e[t+2]/6+2/3*e[t+1]+e[t]/6}}function S(e,t){return{from:1===t?e[0]:(e[t-1]+e[t])/2,cp:e[t],to:t===e.length-2?e[e.length-1]:(e[t]+e[t+1])/2}}function R(e,t,n,r=T(n.length,t),o){return[w(e,t,n.map((e=>e[0])),r,o),w(e,t,n.map((e=>e[1])),r,o)]}function A(e,t,n,r=T(n.length,t),o){return[w(e,t,n.map((e=>e[0])),r,o),w(e,t,n.map((e=>e[1])),r,o),w(e,t,n.map((e=>e[2])),r,o)]}function T(e,t){const n=[];for(let e=0;ee.x)),s=t.map((e=>e.y));for(let t=0;t<=o;t++){const l=t/o;i.push({x:w(l,e,a,n,r),y:w(l,e,s,n,r)})}return i}function I(e,t,n=T(t.length,e),r,o=100){const i=[],a=t.map((e=>e[0])),s=t.map((e=>e[1])),l=t.map((e=>e[2]));for(let t=0;t<=o;t++){const c=t/o;i.push([w(c,e,a,n,r),w(c,e,s,n,r),w(c,e,l,n,r)])}return i}function O(e,t,n=T(e.length,t),r=t,o=T(e[0].length,t),i=20){const a=[];let s;for(let l=0;l<=i;l++){const c=l/i,u=e.map((e=>A(c,t,e,n))),d=u.map((e=>e[0])),p=u.map((e=>e[1])),f=u.map((e=>e[2])),h=[];for(let e=0;e<=i;e++){const t=e/i;h.push([w(t,r,d,o),w(t,r,p,o),w(t,r,f,o)]),s&&e>0&&a.push(...s[e-1],...s[e],...h[e-1],...h[e-1],...s[e],...h[e])}s=h}return a}function B(e,t,n=T(e.length,t),i=t,a=T(e[0].length,t),s){const l=r.geom.NurbsSurface.byKnotsControlPointsWeights(t,i,n,a,e,s).tessellate(),c=o.primitives.createAugmentedTypedArray(3,l.points.length),u=o.primitives.createAugmentedTypedArray(3,l.normals.length),d=o.primitives.createAugmentedTypedArray(2,l.uvs.length),p=l.faces.length%2==1?l.faces.length+1:l.faces.length,f=o.primitives.createAugmentedTypedArray(3,p,Uint16Array);return c.push(...l.points),u.push(...l.normals),d.push(...l.uvs),f.push(...l.faces),{position:c,normal:u,texcoord:d,indices:f}}const F={points:[a.Position],degree:c.number,knots:[c.number],weights:(0,c.optional)([c.number])};function D(e){return{points:e.controlPoints().map((e=>U(e))),degree:e.degree(),knots:e.knots(),weights:e.weights()}}function z(e){return r.geom.NurbsCurve.byKnotsControlPointsWeights(e.degree,e.knots,e.points.map((e=>N(e))),e.weights)}function U(e){return{x:e[0],y:e[1]}}function N(e){return[e.x,e.y]}function G(e,t){const n=z(t).closestPoint(N(e));return(0,i.isZero)((0,a.getTwoPointsDistance)(e,U(n)),i.delta3)}function j(e){return e.points.length-e.degree}function V(e,t){return z(e).closestParam(N(t))}function W(e,t){return U(z(e).point(t))}function H(e){return{start:W(e,0),end:W(e,j(e))}}function q(e,t){const n=z(e),r=[];for(let e=0;e<=t;e++)r.push(U(n.point(e/t)));return r}function $({x:e,y:t},n,r,o=i.delta2){const a=z(n),s=r?a.closestParam(N(r)):j(n)/2;return(0,d.newtonIterate)(s,(n=>{const[[r,o],[i,s]]=a.derivatives(n);return i*(r-e)+s*(o-t)}),(n=>{const[[r,o],[i,s],[l,c]]=a.derivatives(n,2);return i*i+l*(r-e)+s*s+c*(o-t)}),o)}function Y({x:e,y:t},n,r,o=i.delta2){const a=z(n),s=r?a.closestParam(N(r)):j(n)/2;return(0,d.newtonIterate)(s,(n=>{const[[r,o],[i,s]]=a.derivatives(n);return s*(r-e)-i*(o-t)}),(n=>{const[[r,o],[i,s],[l,c]]=a.derivatives(n,2);return s*i+c*(r-e)-(i*s+l*(o-t))}),o)}function K(e,t){const n=z(e),[[r,o],[i,a]]=n.derivatives(t);return[{x:r,y:o},{x:i,y:a}]}function X(e,t){const n=z(t),r=n.closestParam(N(e)),o=U(n.point(r));return{param:r,point:o,distance:(0,a.getTwoPointsDistance)(e,o)}}function Z(e){return z(e).length()}function Q(e,t){return z(e).lengthAtParam(t)}function J(e,t){return z(e).paramAtLength(t)}function ee(e,t){const[n,r]=z(e).split(t);return[D(n),D(r)]}function te(e,t,n){let r=z(e);return(0,i.isZero)(t)||(r=r.split(t)[1]),(0,i.isZero)(n)||(r=r.split(n)[0]),D(r)}function ne(e,t,n){const o=new r.geom.Line(N(e),N(t)),i=z(n);return r.geom.Intersect.curves(o,i).map((e=>U(e.point0)))}function re(e,t){const n=(0,u.angleToRadian)(e.startAngle),o=(0,u.angleToRadian)(e.endAngle),i=new r.geom.Arc(N(e),[1,0],[0,1],e.r,e.counterclockwise?o:n,e.counterclockwise?n:o),a=z(t);return r.geom.Intersect.curves(i,a).map((e=>U(e.point0)))}function oe(e,t){const n=(0,u.angleToRadian)(e.angle),o=Math.cos(n),i=Math.sin(n),a=new r.geom.Ellipse([e.cx,e.cy],[e.rx*o,e.rx*i],[-e.ry*i,e.ry*o]),s=z(t);return r.geom.Intersect.curves(a,s).map((e=>U(e.point0))).filter((t=>(0,l.pointIsOnEllipseArc)(t,e)))}function ie(e,t){const n=new r.geom.BezierCurve([N(e.from),N(e.cp),N(e.to)]),o=z(t);return r.geom.Intersect.curves(n,o).map((e=>U(e.point0)))}function ae(e,t){const n=new r.geom.BezierCurve([N(e.from),N(e.cp1),N(e.cp2),N(e.to)]),o=z(t);return r.geom.Intersect.curves(n,o).map((e=>U(e.point0)))}function se(e,t){const n=z(e),o=z(t);return r.geom.Intersect.curves(n,o).map((e=>U(e.point0)))}function le(e){return D(z(e).reverse())}function ce(e,t){const n=X(e,t),[r,o]=z(t).tangent(n.param),i=Math.atan2(o,r),a=(0,s.pointAndDirectionToGeneralFormLine)(n.point,i);return(0,s.getPointSideOfLine)(e,a)}function ue(e,t){if((0,i.isZero)(t))return[e,e];const[n,r]=(0,p.getParallelPolylinesByDistance)(e.points,t,!1);return[E(C({},e),{points:n.length===e.points.length?n:e}),E(C({},e),{points:r.length===e.points.length?r:e})]}function de(e,t){const n=z(e),[,[r,o],[i,a]]=n.derivatives(t,2);return(r*a-o*i)/x(x(r,2)+x(o,2),1.5)}},1785:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getLinesOffsetDirection:()=>N,getParallelArcsByDistance:()=>S,getParallelBezierCurvesByDistance:()=>M,getParallelCirclesByDistance:()=>_,getParallelEllipseArcsByDistance:()=>A,getParallelEllipsesByDistance:()=>R,getParallelGeometryLinesByDistance:()=>j,getParallelGeometryLinesByDistanceDirectionIndex:()=>W,getParallelGeometryLinesByDistancePoint:()=>V,getParallelLineSegmentsPoints:()=>Y,getParallelPolylineByDistance:()=>q,getParallelPolylinesByDistance:()=>$,getParallelQuadraticCurvesByDistance:()=>T,getPointSideOfArc:()=>I,getPointSideOfBezierCurve:()=>D,getPointSideOfCircle:()=>L,getPointSideOfEllipse:()=>O,getPointSideOfEllipseArc:()=>B,getPointSideOfGeometryLine:()=>z,getPointSideOfQuadraticCurve:()=>F,getRadianSideOfRadian:()=>U,pointSideToIndex:()=>G});var r=n(5629),o=n(5717),i=n(2792),a=n(5773),s=n(1715),l=n(8831),c=n(1796),u=n(2298),d=n(491),p=n(8230),f=n(8392),h=n(5689),g=n(3793),m=Object.defineProperty,y=Object.defineProperties,v=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,b=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,E=Math.pow,P=(e,t,n)=>t in e?m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,k=(e,t)=>{for(var n in t||(t={}))b.call(t,n)&&P(e,n,t[n]);if(x)for(var n of x(t))C.call(t,n)&&P(e,n,t[n]);return e},w=(e,t)=>y(e,v(t));function _(e,t){return(0,i.isZero)(t)?[e,e]:[w(k({},e),{r:e.r-t}),w(k({},e),{r:e.r+t})]}function S(e,t){const n=_(e,t);return e.counterclockwise?[n[1],n[0]]:n}function R(e,t){return(0,i.isZero)(t)?[e,e]:[w(k({},e),{rx:e.rx-t,ry:e.ry-t}),w(k({},e),{rx:e.rx+t,ry:e.ry+t})]}function A(e,t){const n=R(e,t);return e.counterclockwise?[n[1],n[0]]:n}function T(e,t){if((0,i.isZero)(t))return[e,e];const[n,r]=$([e.from,e.cp,e.to],t,!1);return[w(k({},e),{from:n[0],cp:n[1],to:n[2]}),w(k({},e),{from:r[0],cp:r[1],to:r[2]})]}function M(e,t){if((0,i.isZero)(t))return[e,e];const[n,r]=$([e.from,e.cp1,e.cp2,e.to],t,!1);return[w(k({},e),{from:n[0],cp1:n[1],cp2:n[2],to:n[3]}),w(k({},e),{from:r[0],cp1:r[1],cp2:r[2],to:r[3]})]}function L(e,t){const n=(0,a.getTwoPointsDistance)(e,t);return(0,i.isSameNumber)(n,t.r)?0:n>t.r?1:-1}function I(e,t){return L(e,t)*(t.counterclockwise?-1:1)}function O(e,{rx:t,ry:n,cx:r,cy:o,angle:a}){const l=(0,s.angleToRadian)(a),c=Math.sin(l),u=Math.cos(l),d=E(u*(e.x-r)+c*(e.y-o),2)/t/t+E(-c*(e.x-r)+u*(e.y-o),2)/n/n;return(0,i.isSameNumber)(d,1)?0:d>1?1:-1}function B(e,t){return O(e,t)*(t.counterclockwise?-1:1)}function F(e,t){const n=(0,f.getPointAndQuadraticCurveNearestPointAndDistance)(e,t,!0),r=(0,h.getQuadraticCurveTangentRadianAtPercent)(t,n.percent),o=(0,c.pointAndDirectionToGeneralFormLine)(n.point,r);return(0,c.getPointSideOfLine)(e,o)}function D(e,t){const n=(0,f.getPointAndBezierCurveNearestPointAndDistance)(e,t,!0),r=(0,h.getBezierCurveTangentRadianAtPercent)(t,n.percent),o=(0,c.pointAndDirectionToGeneralFormLine)(n.point,r);return(0,c.getPointSideOfLine)(e,o)}function z(e,t){if(Array.isArray(t)){const n=(0,c.twoPointLineToGeneralFormLine)(...t);return n?(0,c.getPointSideOfLine)(e,n):0}return"arc"===t.type?I(e,t.curve):"ellipse arc"===t.type?B(e,t.curve):"quadratic curve"===t.type?F(e,t.curve):"bezier curve"===t.type?D(e,t.curve):"ray"===t.type?(0,c.getPointSideOfLine)(e,(0,c.pointAndDirectionToGeneralFormLine)(t.line,(0,s.angleToRadian)(t.line.angle))):(0,p.getPointSideOfNurbsCurve)(e,t.curve)}function U(e,t){let n=t-e;return n=(0,l.normalizeRadian)(n),(0,i.isZero)(n)?0:n>0?-1:1}function N(e,t){return G(z(e,(0,o.getNearestGeometryLines)(e,t)[0]))}function G(e){return e>0?1:0}function j(e,t){if(Array.isArray(e))return(0,c.getParallelLineSegmentsByDistance)(e,t);if("arc"===e.type){const n=S(e.curve,t);return[{type:"arc",curve:n[0]},{type:"arc",curve:n[1]}]}if("ellipse arc"===e.type){const n=A(e.curve,t);return[{type:"ellipse arc",curve:n[0]},{type:"ellipse arc",curve:n[1]}]}if("quadratic curve"===e.type){const n=T(e.curve,t);return[{type:"quadratic curve",curve:n[0]},{type:"quadratic curve",curve:n[1]}]}if("bezier curve"===e.type){const n=M(e.curve,t);return[{type:"bezier curve",curve:n[0]},{type:"bezier curve",curve:n[1]}]}if("ray"===e.type){const n=(0,c.getParallelRaysByDistance)(e.line,t);return[{type:"ray",line:n[0]},{type:"ray",line:n[1]}]}const n=(0,p.getParallelNurbsCurvesByDistance)(e.curve,t);return[{type:"nurbs curve",curve:n[0]},{type:"nurbs curve",curve:n[1]}]}function V(e,t,n,r){return n||(n=Math.min(...t.map((t=>(0,f.getPointAndGeometryLineMinimumDistance)(e,t))))),W(t,n,N(e,t),r)}function W(e,t,n,a=g.defaultLineJoin){if((0,i.isZero)(t))return e;const c=(0,o.isGeometryLinesClosed)(e)&&e.length>1,d=e.map((e=>{var r;return null==(r=j(e,t))?void 0:r[n]}));if(1===d.length){const e=d[0];return e?[e]:[]}const f=[];let h;for(let n=0;nvoid 0!==e),{closed:c,reverse:!0}),m=void 0!==g?d[g]:void 0,y=(0,i.findFrom)(d,n,(e=>void 0!==e),{closed:c});let v,x;if(m?v=y?H(m,y):(0,o.getGeometryLineStartAndEnd)(m).end:y&&(v=(0,o.getGeometryLineStartAndEnd)(y).start),m&&y&&("miter"===a||!v||(0,o.pointIsOnGeometryLine)(v,m)&&(0,o.pointIsOnGeometryLine)(v,y)||(v=void 0),!v)){if(!Array.isArray(y)&&"arc"===y.type&&y.curve.r<=0){e=e.toSpliced(n,1),d.splice(n,1),n--;continue}if("miter"===a&&Array.isArray(m)&&Array.isArray(y))v=y[0];else if("bevel"===a){v=(0,o.getGeometryLineStartAndEnd)(m).end;const e=(0,o.getGeometryLineStartAndEnd)(y).start;v&&e&&(x={current:e,line:[v,e]})}else if(void 0!==g){const n=e[g],r=(0,o.getGeometryLineStartAndEnd)(n).end;v=(0,o.getGeometryLineStartAndEnd)(m).end;const i=(0,o.getGeometryLineStartAndEnd)(y).start;if(r&&v&&i){const e={x:r.x,y:r.y,r:t,startAngle:(0,s.radianToAngle)((0,s.getTwoPointsRadian)(v,r)),endAngle:(0,s.radianToAngle)((0,s.getTwoPointsRadian)(i,r))};x={current:i,line:{type:"arc",curve:w(k({},e),{counterclockwise:!(0,l.twoRadiansSameDirection)((0,o.getGeometryLineTangentRadianAtParam)(0,{type:"arc",curve:e}),(0,o.getGeometryLineTangentRadianAtParam)(1,n))||void 0})}}}}}if(v&&h&&m){const e=m;Array.isArray(e)?f.push([h,v]):"arc"===e.type?f.push({type:"arc",curve:w(k({},e.curve),{startAngle:(0,s.radianToAngle)((0,s.getTwoPointsRadian)(h,e.curve)),endAngle:(0,s.radianToAngle)((0,s.getTwoPointsRadian)(v,e.curve))})}):"ellipse arc"===e.type?f.push({type:"ellipse arc",curve:w(k({},e.curve),{startAngle:(0,u.getEllipseAngle)(h,e.curve),endAngle:(0,u.getEllipseAngle)(v,e.curve)})}):"quadratic curve"===e.type?f.push({type:"quadratic curve",curve:(0,r.getPartOfQuadraticCurve)(e.curve,(0,r.getQuadraticCurvePercentAtPoint)(e.curve,h),(0,r.getQuadraticCurvePercentAtPoint)(e.curve,v))}):"bezier curve"===e.type?f.push({type:"bezier curve",curve:(0,r.getPartOfBezierCurve)(e.curve,(0,r.getBezierCurvePercentAtPoint)(e.curve,h),(0,r.getBezierCurvePercentAtPoint)(e.curve,v))}):"nurbs curve"===e.type&&f.push({type:"nurbs curve",curve:(0,p.getPartOfNurbsCurve)(e.curve,(0,p.getNurbsCurveParamAtPoint)(e.curve,h),(0,p.getNurbsCurveParamAtPoint)(e.curve,v))})}h=v,x&&(f.push(x.line),h=x.current)}return f}function H(e,t){var n;const r=(0,d.getTwoGeometryLinesIntersectionPoint)(e,t,!0);if(r.length>1){const t=r.map((t=>({point:t,param:(0,o.getGeometryLineParamAtPoint)(t,e)}))).filter((e=>e.param>=0));return t.length>1?(0,i.minimumBy)(t,(e=>e.param)).point:null==(n=t[0])?void 0:n.point}return r[0]}function q(e,t,n){const r=(0,a.isSamePoint)(e[0][0],e[e.length-1][1])&&e.length>1;return Y(e.map((e=>{var r;return null==(r=(0,c.getParallelLineSegmentsByDistance)(e,t))?void 0:r[n]})),r)}function $(e,t,n){const r=Array.from((0,c.iteratePolylineLines)(e)).map((e=>(0,c.getParallelLineSegmentsByDistance)(e,t)));return[Y(r.map((e=>null==e?void 0:e[0])),n),Y(r.map((e=>null==e?void 0:e[1])),n)]}function Y(e,t){const n=[];for(let r=0;rvoid 0!==e),{closed:t,reverse:!0}),a=(0,i.findFrom)(e,r,(e=>void 0!==e),{closed:t});let s;o?s=a?(0,d.getTwoLinesIntersectionPoint)(...o,...a):o[1]:a&&(s=a[0]),s&&n.push(s)}return n}},4461:(e,t,n)=>{"use strict";n.r(t),n.d(t,{applyImmutablePatches:()=>i});var r=n(8662),o=n(9758);function i(e,t){const n=[],i=[];return t.forEach(((t,a)=>{const s=t.value;e=(0,r.produce)(e,(r=>{const l=t.path.slice(0,t.path.length-1),c=t.path[t.path.length-1],u=(0,o.getByPath)(r,l);if(Array.isArray(u))if("add"===t.op){const e=[...l,u.length];n.push({op:"replace",path:e,value:s}),i.unshift({op:"replace",path:e,value:void 0}),u.push(s)}else{if("replace"!==t.op||"number"!=typeof c)throw console.info(t),new Error(`Operation not supported for patch at index ${a}`);n.push(t),i.unshift({op:"replace",path:t.path,value:(0,o.getByPath)(e,t.path)}),c===u.length-1&&null==s?u.pop():u[c]=s}else{if("object"!=typeof u||null===u)throw console.info(t),new Error(`Invalid path for patch at index ${a}`);{const r=u;n.push(t),i.unshift({op:"replace",path:t.path,value:(0,o.getByPath)(e,t.path)}),void 0===s?delete r[c]:r[c]=s}}}))})),{patches:n,reversePatches:i,result:e}}},1401:(e,t,n)=>{"use strict";n.r(t),n.d(t,{PathCommand:()=>m,geometryLineToPathCommands:()=>C,getPathCommandEndPoint:()=>y,getPathCommandsPoints:()=>x,pathCommandPointsToPath:()=>v,pathCommandsToGeometryLines:()=>b});var r=n(8831),o=n(5717),i=n(2318),a=n(2298),s=n(8258),l=n(491),c=n(6022),u=n(1796),d=n(2792),p=n(8392),f=n(5773),h=n(1715),g=n(5569);const m=(e,t)=>(0,c.isRecord)(e)?"move"===e.type?(0,g.validate)(e,{type:"move",to:f.Position},t):"line"===e.type?(0,g.validate)(e,{type:"line",to:f.Position},t):"arc"===e.type?(0,g.validate)(e,{type:"arc",from:f.Position,to:f.Position,radius:g.number},t):"ellipseArc"===e.type?(0,g.validate)(e,{type:"ellipseArc",rx:g.number,ry:g.number,angle:g.number,largeArc:g.boolean,sweep:g.boolean,to:f.Position},t):"bezierCurve"===e.type?(0,g.validate)(e,{type:"bezierCurve",cp1:f.Position,cp2:f.Position,to:f.Position},t):"quadraticCurve"===e.type?(0,g.validate)(e,{type:"quadraticCurve",cp:f.Position,to:f.Position},t):"close"===e.type?(0,g.validate)(e,{type:"close"},t):{path:[...t,"type"],expect:"or",args:["move","line","arc","ellipseArc","bezierCurve","quadraticCurve","close"]}:{path:t,expect:"object"};function y(e,t){if(t>=0){const n=e[t];if("close"!==n.type){if("arc"!==n.type)return n.to;const r=y(e,t-1);if(r){const e=n.from,t=n.to,o=(0,u.twoPointLineToGeneralFormLine)(r,e),i=(0,u.twoPointLineToGeneralFormLine)(e,t),a=o?(0,u.getPointSideOfLine)(t,o):0;if((0,d.isZero)(a)||!o||!i)return n.to;const s=a<0?0:1,c=(0,l.getTwoGeneralFormLinesIntersectionPoint)((0,u.getParallelLinesByDistance)(o,n.radius)[s],(0,u.getParallelLinesByDistance)(i,n.radius)[s]);if(c){const e=(0,p.getPerpendicularPoint)(c,i),t=(0,h.getTwoPointsRadian)(e,c);return{x:c.x+n.radius*Math.cos(t),y:c.y+n.radius*Math.sin(t)}}}}}}function v(e){const t=[];let n;for(const r of e)n?(0,u.pointInPolygon)(r[0],n.polygon)?n.holes.push(r):(n&&t.push([n.polygon,...n.holes]),n={polygon:r,holes:[]}):n={polygon:r,holes:[]};return n&&t.push([n.polygon,...n.holes]),t}function x(e){const t=[],n=b(e);for(const e of n)t.push((0,s.getGeometryLinesPoints)(e));return t}function b(e){const t=[];let n,r,i=[];for(const o of e)if("move"===o.type)i.length>0&&(i.length>1&&t.push(i),i=[],n=void 0),r=o.to,n||(n=o.to);else if("line"===o.type)r&&i.push([r,o.to]),r=o.to;else if("arc"===o.type){if(r){const e=o.from,t=o.to,n=(0,u.twoPointLineToGeneralFormLine)(r,e),a=(0,u.twoPointLineToGeneralFormLine)(e,t),s=n?(0,u.getPointSideOfLine)(t,n):0;if(!(0,d.isZero)(s)&&n&&a){const e=s<0?0:1,t=(0,l.getTwoGeneralFormLinesIntersectionPoint)((0,u.getParallelLinesByDistance)(n,o.radius)[e],(0,u.getParallelLinesByDistance)(a,o.radius)[e]);if(t){const e=(0,p.getPerpendicularPoint)(t,n),l=(0,p.getPerpendicularPoint)(t,a);r&&((0,f.isSamePoint)(r,e)||i.push([r,{x:e.x,y:e.y}]),r=l);const c=(0,h.radianToAngle)((0,h.getTwoPointsRadian)(e,t)),u=(0,h.radianToAngle)((0,h.getTwoPointsRadian)(l,t));i.push({type:"arc",curve:{x:t.x,y:t.y,startAngle:c,endAngle:u,r:o.radius,counterclockwise:s>0}})}}else r&&(i.push([r,t]),r=t)}}else if("ellipseArc"===o.type){if(r){const e=(0,a.getEllipseArcByStartEnd)(r,o.rx,o.ry,o.angle,o.largeArc,o.sweep,o.to);e&&i.push({type:"ellipse arc",curve:e})}r=o.to}else"bezierCurve"===o.type?(r&&i.push({type:"bezier curve",curve:{from:r,cp1:o.cp1,cp2:o.cp2,to:o.to}}),r=o.to):"quadraticCurve"===o.type?(r&&i.push({type:"quadratic curve",curve:{from:r,cp:o.cp,to:o.to}}),r=o.to):"close"===o.type&&i.length>0&&(i.length>1&&(n&&r&&!(0,f.isSamePoint)(n,r)&&i.push([r,n]),t.push(i)),i=[],n=void 0);return i.length>0&&t.push(i),t.map((e=>(0,o.optimizeGeometryLines)(e)))}function C(e){const t=[];let n,a;for(let s=0;s{"use strict";n.r(t),n.d(t,{getPerpendicularDistance:()=>C,getPerpendicularLine:()=>m,getPerpendicularLineToGeometryLine:()=>y,getPerpendicularPercentToBezierCurve:()=>_,getPerpendicularPercentToQuadraticCurve:()=>k,getPerpendicularPoint:()=>b,getPerpendicularPointRadianToEllipse:()=>P,getPerpendicularPointToBezierCurve:()=>S,getPerpendicularPointToCircle:()=>E,getPerpendicularPointToGeometryLine:()=>v,getPerpendicularPointToGeometryLines:()=>x,getPerpendicularPointToQuadraticCurve:()=>w,getPointAndArcMinimumDistance:()=>U,getPointAndArcNearestPointAndDistance:()=>M,getPointAndBezierCurveNearestPointAndDistance:()=>O,getPointAndEllipseArcNearestPointAndDistance:()=>L,getPointAndGeometryLineMinimumDistance:()=>B,getPointAndGeometryLineNearestPointAndDistance:()=>T,getPointAndLineSegmentMinimumDistance:()=>F,getPointAndLineSegmentNearestPointAndDistance:()=>R,getPointAndPolygonMinimumDistance:()=>z,getPointAndQuadraticCurveNearestPointAndDistance:()=>I,getPointAndRayNearestPointAndDistance:()=>A,getPointAndRegionMinimumDistance:()=>D});var r=n(5629),o=n(1475),i=n(2792),a=n(7486),s=n(5773),l=n(1715),c=n(8831),u=n(1796),d=n(2298),p=n(2318),f=n(5717),h=n(8230),g=Math.pow;function m(e,t){return{a:-t.b,b:t.a,c:e.x*t.b-t.a*e.y}}function y(e,t){const n=v(e,t);if(n)return(0,u.twoPointLineToGeneralFormLine)(e,n)}function v(e,t){if(Array.isArray(t)){const n=(0,u.twoPointLineToGeneralFormLine)(...t);if(!n)return;return b(e,n)}let n;if("arc"===t.type)n=E(e,t.curve).point;else if("ellipse arc"===t.type){const r=P(e,t.curve);void 0!==r&&(n=(0,d.getEllipsePointAtRadian)(t.curve,r))}else if("quadratic curve"===t.type){const o=k(e,t.curve)[0];void 0!==o&&(n=(0,r.getQuadraticCurvePointAtPercent)(t.curve.from,t.curve.cp,t.curve.to,o))}else if("bezier curve"===t.type){const o=_(e,t.curve)[0];void 0!==o&&(n=(0,r.getBezierCurvePointAtPercent)(t.curve.from,t.curve.cp1,t.curve.cp2,t.curve.to,o))}else if("nurbs curve"===t.type){const r=(0,h.getPerpendicularParamToNurbsCurve)(e,t.curve);void 0!==r&&(n=(0,h.getNurbsCurvePointAtParam)(t.curve,r))}else"ray"===t.type&&(n=b(e,(0,u.pointAndDirectionToGeneralFormLine)(t.line,(0,l.angleToRadian)(t.line.angle))));return n}function x(e,t){const n=[],r=[];for(const o of t){const t=v(e,o);t&&((0,f.pointIsOnGeometryLine)(t,o)?n.push({point:t,distance:(0,s.getTwoPointsDistance)(t,e)}):r.push({point:t,distance:(0,s.getTwoPointsDistance)(t,e),line:o}))}return n.length>0?(0,i.minimumBy)(n,(e=>e.distance)):(0,i.minimumBy)(r,(e=>e.distance))}function b(e,{a:t,b:n,c:r}){const o=g(t,2),i=g(n,2),a=o+i,s=-t*n;return{x:(i*e.x+s*e.y-t*r)/a,y:(s*e.x+o*e.y-n*r)/a}}function C({x:e,y:t},{a:n,b:r,c:o}){return Math.abs(n*e+r*t+o)/Math.sqrt(g(n,2)+g(r,2))}function E(e,t,n=e){let r=(0,l.getTwoPointsRadian)(e,t);if(e!==n){const o=t.x-e.x,i=t.y-e.y,a={a:o,b:i,c:-i*t.y-o*t.x};Math.sign((0,u.getPointSideOfLine)(e,a))!==Math.sign((0,u.getPointSideOfLine)(n,a))&&(r+=Math.PI)}const o=(0,p.getCirclePointAtRadian)(t,r);return{point:o,distance:(0,s.getTwoPointsDistance)(e,o),radian:r}}function P(e,t,n=e,r=i.delta2){const{rx:a,ry:s,cx:c,cy:u,angle:p}=t,f=(0,d.getEllipseRadian)(n,t),h=(0,l.angleToRadian)(p),g=Math.sin(h),m=Math.cos(h),y=e.x-c,v=e.y-u,x=(y*g-m*v)*s,b=s*s-a*a,C=(y*m+g*v)*a;return(0,o.newtonIterate)(f,(e=>{return t=Math.cos(e),n=Math.sin(e),x*t+b*n*t+C*n;var t,n}),(e=>{return t=Math.cos(e),n=Math.sin(e),x*-n+b*(t*t-n*n)+C*t;var t,n}),r)}function k({x:e,y:t},{from:{x:n,y:r},cp:{x:a,y:s},to:{x:l,y:c}},u=i.delta2){const d=a-n,p=l-a-d,f=s-r,h=c-s-f,g=n-e,m=r-t;return(0,o.calculateEquation3)(p*p+h*h,3*(d*p+f*h),2*d*d+g*p+2*f*f+m*h,g*d+m*f,u)}function w(e,t,n=i.delta2){return k(e,t,n).filter((e=>(0,i.isValidPercent)(e))).map((e=>(0,r.getQuadraticCurvePointAtPercent)(t.from,t.cp,t.to,e)))}function _({x:e,y:t},{from:{x:n,y:r},cp1:{x:a,y:s},cp2:{x:l,y:c},to:{x:u,y:d}},p=i.delta2){const f=3*a-n+-3*l+u,h=3*(n-2*a+l),g=3*(a-n),m=3*s-r+-3*c+d,y=3*(r-2*s+c),v=3*(s-r),x=r-t,b=n-e;return(0,o.calculateEquation5)([3*(m*m+f*f),5*(m*y+f*h),2*(h*h+2*f*g+y*y+2*m*v),3*(h*g+y*v+m*x+f*b),g*g+v*v+2*y*x+2*h*b,v*x+g*b],p)}function S(e,t,n=i.delta2){return _(e,t,n).filter((e=>(0,i.isValidPercent)(e))).map((e=>(0,r.getBezierCurvePointAtPercent)(t.from,t.cp1,t.cp2,t.to,e)))}function R(e,t,n,r=!1){const o=(0,u.twoPointLineToGeneralFormLine)(t,n),a=o?b(e,o):t;return r||(0,u.pointIsOnLineSegment)(a,t,n)?{point:a,distance:(0,s.getTwoPointsDistance)(e,a)}:(0,i.minimumBy)([{point:t,distance:(0,s.getTwoPointsDistance)(e,t)},{point:n,distance:(0,s.getTwoPointsDistance)(e,n)}],(e=>e.distance))}function A(e,t,n=!1){const r=b(e,(0,u.pointAndDirectionToGeneralFormLine)(t,(0,l.angleToRadian)(t.angle)));return n||t.bidirectional||(0,u.pointIsOnRay)(r,t)?{point:r,distance:(0,s.getTwoPointsDistance)(e,r)}:{point:t,distance:(0,s.getTwoPointsDistance)(e,t)}}function T(e,t){return Array.isArray(t)?R(e,...t):"arc"===t.type?M(e,t.curve):"ellipse arc"===t.type?L(e,t.curve):"quadratic curve"===t.type?I(e,t.curve):"bezier curve"===t.type?O(e,t.curve):"ray"===t.type?A(e,t.line):(0,h.getPointAndNurbsCurveNearestPointAndDistance)(e,t.curve)}function M(e,t,n=!1){const{point:r,distance:o,radian:a}=E(e,t);if(n||(0,c.angleInRange)((0,l.radianToAngle)(a),t))return{point:r,distance:o};const{start:u,end:d}=(0,p.getArcStartAndEnd)(t);return(0,i.minimumBy)([{point:u,distance:(0,s.getTwoPointsDistance)(e,u)},{point:d,distance:(0,s.getTwoPointsDistance)(e,d)}],(e=>e.distance))}function L(e,t,n=!1){const r=P(e,t);if(void 0!==r&&(n||(0,c.angleInRange)((0,l.radianToAngle)(r),t))){const n=(0,d.getEllipsePointAtRadian)(t,r);return{point:n,distance:(0,s.getTwoPointsDistance)(e,n)}}const{start:o,end:a}=(0,d.getEllipseArcStartAndEnd)(t);return(0,i.minimumBy)([{point:o,distance:(0,s.getTwoPointsDistance)(e,o)},{point:a,distance:(0,s.getTwoPointsDistance)(e,a)}],(e=>e.distance))}function I(e,t,n=!1){let o=k(e,t);n||(o=o.filter((e=>(0,i.isValidPercent)(e))));const a=o.map((e=>({u:e,p:(0,r.getQuadraticCurvePointAtPercent)(t.from,t.cp,t.to,e)})));a.push({u:0,p:t.from},{u:1,p:t.to});const l=a.map((t=>({percent:t.u,point:t.p,distance:(0,s.getTwoPointsDistance)(e,t.p)})));return(0,i.minimumBy)(l,(e=>e.distance))}function O(e,t,n=!1){let o=_(e,t);n||(o=o.filter((e=>(0,i.isValidPercent)(e))));const a=o.map((e=>({u:e,p:(0,r.getBezierCurvePointAtPercent)(t.from,t.cp1,t.cp2,t.to,e)})));a.push({u:0,p:t.from},{u:1,p:t.to});const l=a.map((t=>({percent:t.u,point:t.p,distance:(0,s.getTwoPointsDistance)(e,t.p)})));return(0,i.minimumBy)(l,(e=>e.distance))}function B(e,t,n=!1){return Array.isArray(t)?F(e,...t,n):"arc"===t.type?U(e,t.curve,n):"ellipse arc"===t.type?L(e,t.curve,n).distance:"quadratic curve"===t.type?I(e,t.curve,n).distance:"bezier curve"===t.type?O(e,t.curve,n).distance:"ray"===t.type?A(e,t.line,n).distance:(0,h.getPointAndNurbsCurveNearestPointAndDistance)(e,t.curve).distance}function F(e,t,n,r=!1){const{distance:o}=R(e,t,n,r);return o}function D(e,t){return z(e,(0,a.getPolygonFromTwoPointsFormRegion)(t))}function z(e,t){const n=Array.from((0,u.getPolygonLine)(t));return Math.min(...n.map((t=>F(e,...t))))}function U(e,t,n=!1){const{distance:r}=M(e,t,n);return r}},5773:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Position:()=>s,deduplicatePosition:()=>y,getPointAndPolygonMaximumDistance:()=>f,getPointByLengthAndDirection:()=>l,getPointByLengthAndDirectionSafely:()=>c,getPointByLengthAndRadian:()=>d,getTwoPointCenter:()=>m,getTwoPointsDistance:()=>h,getTwoPointsDistanceSquare:()=>g,isSamePoint:()=>u,multipleDirection:()=>p,rotatePosition:()=>x,rotatePositionByCenter:()=>v});var r=n(2792),o=n(1715),i=n(5569),a=Math.pow;const s={x:i.number,y:i.number};function l(e,t,n){let o=n.x-e.x,i=n.y-e.y;if((0,r.isZero)(t))return e;if(t<0&&(t=-t,o=-o,i=-i),(0,r.isZero)(o))return{x:e.x,y:e.y+t*(i>0?1:-1)};const s=Math.sqrt(a(t,2)*a(o,2)/(a(o,2)+a(i,2)))*(o>0?1:-1);return{x:e.x+s,y:e.y+i/o*s}}function c(e,t,n){if(!u(e,n))return l(e,t,n)}function u(e,t,n){return(0,r.isSameNumber)(e.x,t.x,n)&&(0,r.isSameNumber)(e.y,t.y,n)}function d(e,t,n){const r=p((0,o.getDirectionByRadian)(n),t);return{x:e.x+r.x,y:e.y+r.y}}function p(e,t){return{x:e.x*t,y:e.y*t}}function f(e,t){return Math.max(...t.map((t=>h(e,t))))}function h(e,t={x:0,y:0}){return Math.sqrt(g(e,t))}function g(e,t={x:0,y:0}){return a(e.x-t.x,2)+a(e.y-t.y,2)}function m(e,t){return{x:(0,r.getTwoNumberCenter)(e.x,t.x),y:(0,r.getTwoNumberCenter)(e.y,t.y)}}function y(e){return(0,r.deduplicate)(e,u)}function v(e,t,n){return n?x(e,t,-(0,o.angleToRadian)(n)):e}function x(e,t,n){if(!n)return e;const r=e.x-t.x,o=e.y-t.y,i=Math.sin(n),a=Math.cos(n);return{x:a*r-i*o+t.x,y:i*r+a*o+t.y}}},7727:(e,t,n)=>{"use strict";n.r(t),n.d(t,{printJsToCode:()=>o});var r=n(6022);function o(e,t){const n=null==t?void 0:t.space;let r;if("number"==typeof n&&!isNaN(n)&&n>=1){r="";const e=Math.min(Math.floor(n),10);for(let t=0;t0&&(a+=`\n${r}`),a+"]"}(e,t,n,o,a):(0,r.isRecord)(e)?function(e,t,n,r,o){let a="{",s=!1;for(const r in e){const c=e[r];if(void 0===c||"function"==typeof c&&!t)continue;s&&(a+=",");const u=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u.test(r)?r:l(r);a+=void 0!==n?`\n${o}${u}: `:`${u}:`,s=!0,a+=i(c,t,n,o)}return void 0!==n&&Object.keys(e).length>0&&(a+=`\n${r}`),a+"}"}(e,t,n,o,a):""}const a=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function l(e){return a.lastIndex=0,a.test(e)?'"'+e.replace(a,(e=>{const t=s[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}))+'"':'"'+e+'"'}},1715:(e,t,n)=>{"use strict";function r(e=0){return 180*e/Math.PI}function o(e=0){return e*Math.PI/180}function i(e,t={x:0,y:0}){return Math.atan2(e.y-t.y,e.x-t.x)}function a(e){return{x:Math.cos(e),y:Math.sin(e)}}n.r(t),n.d(t,{angleToRadian:()=>o,getDirectionByRadian:()=>a,getTwoPointsRadian:()=>i,radianToAngle:()=>r})},6928:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Reducer:()=>o});var r=Object.defineProperty;class o{constructor(e,t,n){var o,i;this.flush=e,this.newItem=t,this.reduceItem=n,((e,t,n)=>{t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(this,"symbol"!=typeof(o="last")?o+"":o,i)}flushLast(){this.last&&(this.flush(this.last),this.last=void 0)}push(e){this.last?this.newItem(this.last,e)?(this.flushLast(),this.push(e)):this.reduceItem(this.last,e):this.last=e}}},3537:(e,t,n)=>{"use strict";function r(...e){return t=>{for(const n of e)"function"==typeof n?n(t):n&&(n.current=t)}}n.r(t),n.d(t,{bindMultipleRefs:()=>r})},7486:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Region:()=>l,Size:()=>s,getPointAndRegionMaximumDistance:()=>f,getPolygonFromTwoPointsFormRegion:()=>p,getRegion:()=>u,getRoundedRectPoints:()=>h,getTwoPointsFormRegion:()=>c,pointIsInRegion:()=>d});var r=n(2318),o=n(2792),i=n(5773),a=n(5569);const s={width:(0,a.minimum)(0,a.number),height:(0,a.minimum)(0,a.number)},l=(0,a.and)(i.Position,s);function c(e,t){return{start:{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y)},end:{x:Math.max(e.x,t.x),y:Math.max(e.y,t.y)}}}function u(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:(0,o.getTwoNumbersDistance)(e.x,t.x),height:(0,o.getTwoNumbersDistance)(e.y,t.y)}}function d(e,t){return(0,o.largerOrEqual)(e.x,t.start.x)&&(0,o.largerOrEqual)(e.y,t.start.y)&&(0,o.lessOrEqual)(e.x,t.end.x)&&(0,o.lessOrEqual)(e.y,t.end.y)}function p(e){return[e.start,{x:e.start.x,y:e.end.y},e.end,{x:e.end.x,y:e.start.y}]}function f(e,t){return(0,i.getPointAndPolygonMaximumDistance)(e,p(t))}function h(e,t,n){return[...(0,r.arcToPolyline)({x:e.x+e.width/2-t,y:e.y-e.height/2+t,r:t,startAngle:-90,endAngle:0},n),...(0,r.arcToPolyline)({x:e.x+e.width/2-t,y:e.y+e.height/2-t,r:t,startAngle:0,endAngle:90},n),...(0,r.arcToPolyline)({x:e.x-e.width/2+t,y:e.y+e.height/2-t,r:t,startAngle:90,endAngle:180},n),...(0,r.arcToPolyline)({x:e.x-e.width/2+t,y:e.y-e.height/2+t,r:t,startAngle:180,endAngle:270},n)]}},8306:(e,t,n)=>{"use strict";n.r(t),n.d(t,{reverseAngle:()=>_,reverseArc:()=>y,reverseBezierCurve:()=>b,reverseClosedGeometryLinesIfAreaIsNegative:()=>P,reverseEllipseArc:()=>v,reverseGeometryLine:()=>C,reverseGeometryLines:()=>E,reverseLineSegment:()=>m,reverseNurbs:()=>R,reverseQuadraticCurve:()=>x,reverseRadian:()=>w,reverseRay:()=>k});var r=n(8230),o=n(1796),i=n(8831),a=n(8258),s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(u)for(var n of u(t))p.call(t,n)&&f(e,n,t[n]);return e},g=(e,t)=>l(e,c(t));function m(e){return[e[1],e[0]]}function y(e){return g(h({},e),{startAngle:e.endAngle,endAngle:e.startAngle,counterclockwise:!e.counterclockwise})}function v(e){return g(h({},e),{startAngle:e.endAngle,endAngle:e.startAngle,counterclockwise:!e.counterclockwise})}function x(e){return g(h({},e),{from:e.to,to:e.from})}function b(e){return g(h({},e),{from:e.to,cp1:e.cp2,cp2:e.cp1,to:e.from})}function C(e){return Array.isArray(e)?m(e):"arc"===e.type?g(h({},e),{curve:y(e.curve)}):"ellipse arc"===e.type?g(h({},e),{curve:v(e.curve)}):"quadratic curve"===e.type?g(h({},e),{curve:x(e.curve)}):"bezier curve"===e.type?g(h({},e),{curve:b(e.curve)}):"ray"===e.type?g(h({},e),{line:k(e.line)}):g(h({},e),{curve:(0,r.reverseNurbsCurve)(e.curve)})}function E(e){return e.map((e=>C(e))).reverse()}function P(e){return(0,o.getPolygonArea)((0,a.getGeometryLinesPoints)(e))<0?E(e):e}function k(e){return e.bidirectional?g(h({},e),{angle:(0,i.normalizeAngle)(e.angle+180)}):g(h({},e),{reversed:!e.reversed})}function w(e){return(0,i.normalizeRadian)(e+Math.PI)}function _(e){return(0,i.normalizeAngle)(e+180)}function S(e){const t=[e[0]];for(let n=0;n{"use strict";n.r(t),n.d(t,{ContentPath:()=>h,getContentByClickPosition:()=>u,getContentsByClickPosition:()=>d,getContentsByClickTwoPositions:()=>p,getContentsByRegion:()=>f});var r=n(2792),o=n(7486),i=n(1796),a=n(491),s=n(5717),l=n(8392),c=n(5569);function u(e,t,n,r,o=!1,a,s=e.map(((e,t)=>t)),c=3){for(let u=s.length-1;u>=0;u--){const d=s[u],p=e[d];if(!p)continue;if(a&&!a(p))continue;const f=r(p);if(null==f?void 0:f.getGeometries){const{lines:r,regions:a}=f.getGeometries(p,e);for(let e=0;e(0,i.pointInPolygon)(t,e))))&&(0,i.pointInPolygon)(t,s.points)){if(o&&f.canSelectPart&&n([d,e]))return[d,e+r.length];if(n([d]))return[d]}}}}}function d(e,t,n,r,o,a=3){const s=[];return e.forEach(((c,u)=>{if(!c)return;if(o&&!o(c))return;const d=r(c);if(null==d?void 0:d.getGeometries){const{lines:r,regions:o}=d.getGeometries(c,e);for(let e=0;e(0,i.pointInPolygon)(t,e))))return;if((0,i.pointInPolygon)(t,r.points)&&n([u]))return void s.push([u])}}})),s}function p(e,t,n,i,a,s){const l=(0,o.getTwoPointsFormRegion)(t,n),c=(0,r.largerThan)(t.x,n.x);return f(e,(0,o.getPolygonFromTwoPointsFormRegion)(l),c,!1,i,a,s)}function f(e,t,n,r,o,l,c){const u=[];return e.forEach(((d,p)=>{if(d&&(!c||c(d))&&(!l||l([p]))){const l=o(d);if(null==l?void 0:l.getGeometries){const{lines:o,bounding:c,regions:f}=l.getGeometries(d,e);if(r?o.every((e=>(0,s.geometryLineInPolygon)(e,t)))&&(!f||f.every((e=>e.points.every((e=>(0,i.pointInPolygon)(e,t)))))):c&&(0,i.pointInPolygon)(c.start,t)&&(0,i.pointInPolygon)(c.end,t))u.push([p]);else if(n){for(const e of o)if((0,a.geometryLineIntersectWithPolygon)(e,t))return void u.push([p]);if(f)for(const e of f)for(const n of e.lines)if((0,a.geometryLineIntersectWithPolygon)(n,t))return void u.push([p])}}}})),u}const h=(0,c.minItems)(1,(0,c.maxItems)(2,[c.number]))},2683:(e,t,n)=>{"use strict";function r(e){return new Promise((t=>{setTimeout((()=>{t()}),e)}))}n.r(t),n.d(t,{sleep:()=>r})},8638:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getAngleSnapPosition:()=>i});var r=n(5773),o=n(1715);function i(e,t,n){if(n&&e){const i=(0,o.radianToAngle)((0,o.getTwoPointsRadian)(t,e)),a=n(i);void 0!==a&&a!==i&&(t=(0,r.rotatePositionByCenter)(t,e,i-a))}return t}},5689:(e,t,n)=>{"use strict";n.r(t),n.d(t,{getArcTangentRadianAtRadian:()=>F,getBezierCurveTangentRadianAtPercent:()=>N,getCircleTangentRadianAtRadian:()=>B,getCirclesTangentTo2Circles:()=>k,getCirclesTangentTo2Lines:()=>E,getCirclesTangentTo3Circles:()=>T,getCirclesTangentTo3Lines:()=>S,getCirclesTangentToLineAndCircle:()=>P,getCirclesTangentToLineCircleCircle:()=>A,getCirclesTangentToLineLineCircle:()=>R,getEllipseArcTangentRadianAtRadian:()=>z,getEllipseTangentRadianAtRadian:()=>D,getLinesTangentTo2Circles:()=>w,getQuadraticCurveTangentRadianAtPercent:()=>U,getTangencyPointToBezierCurve:()=>O,getTangencyPointToCircle:()=>M,getTangencyPointToEllipse:()=>L,getTangencyPointToQuadraticCurve:()=>I,getTwoLinesCenterLines:()=>_});var r=n(1475),o=n(2792),i=n(5773),a=n(1715),s=n(8831),l=n(1796),c=n(2318),u=n(491),d=n(8392),p=Object.defineProperty,f=Object.defineProperties,h=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,v=Math.pow,x=(e,t,n)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))m.call(t,n)&&x(e,n,t[n]);if(g)for(var n of g(t))y.call(t,n)&&x(e,n,t[n]);return e},C=(e,t)=>f(e,h(t));function E(e,t,n){const r=[],o=(0,l.getParallelLinesByDistance)(e,n),i=(0,l.getParallelLinesByDistance)(t,n);for(const e of o)for(const t of i){const n=(0,u.getTwoGeneralFormLinesIntersectionPoint)(e,t);n&&r.push(n)}return r}function P(e,t,n){const r=[],o=(0,l.getParallelLinesByDistance)(e,n),i=[t.r+n,Math.abs(t.r-n)];for(const e of o)for(const n of i)r.push(...(0,u.getGeneralFormLineCircleIntersectionPoints)(e,C(b({},t),{r:n})));return r}function k(e,t,n){const r=[],o=[e.r+n,Math.abs(e.r-n)],i=[t.r+n,Math.abs(t.r-n)];for(const n of o)for(const o of i)r.push(...(0,u.getTwoCircleIntersectionPoints)(C(b({},e),{r:n}),C(b({},t),{r:o})));return r}function w(e,t){const n=[],r=t.r-e.r,s=(0,i.getTwoPointsDistance)(e,t);if((0,o.lessThan)(Math.abs(r),s)){const i=(0,a.getTwoPointsRadian)(t,e),l=Math.asin(r/s)+Math.PI/2,u=i-l,d=i+l;n.push([(0,c.getCirclePointAtRadian)(e,u),(0,c.getCirclePointAtRadian)(t,u)],[(0,c.getCirclePointAtRadian)(e,d),(0,c.getCirclePointAtRadian)(t,d)]);const p=e.r+t.r;if((0,o.lessThan)(p,s)){const r=Math.asin(p/s);n.push([(0,c.getCirclePointAtRadian)(e,i+r-Math.PI/2),(0,c.getCirclePointAtRadian)(t,i+r+Math.PI/2)],[(0,c.getCirclePointAtRadian)(e,i-r+Math.PI/2),(0,c.getCirclePointAtRadian)(t,i-r-Math.PI/2)])}}return n}function _(e,t){const n=(0,l.getGeneralFormLineRadian)(e),r=(0,l.getGeneralFormLineRadian)(t),a=(0,u.getTwoGeneralFormLinesIntersectionPoint)(e,t);if(!a){const r=(0,l.generalFormLineToTwoPointLine)(e)[0],o=(0,l.generalFormLineToTwoPointLine)(t)[0];return[(0,l.pointAndDirectionToGeneralFormLine)((0,i.getTwoPointCenter)(r,o),n)]}const s=(0,o.getTwoNumberCenter)(n,r);return[s,s+Math.PI/2].map((e=>(0,l.pointAndDirectionToGeneralFormLine)(a,e)))}function S(e,t,n){const r=[],o=_(e,t),i=_(e,n);for(const t of o)for(const n of i){const o=(0,u.getTwoGeneralFormLinesIntersectionPoint)(t,n);o&&r.push(C(b({},o),{r:(0,d.getPerpendicularDistance)(o,e)}))}return r}function R(e,t,{x:n,y:i,r:a}){const s=[],l=_(e,t),{a:c,b:u,c:d}=e,p=v(c,2)+v(u,2),f=Math.sqrt(p),h=c/f,g=u/f,m=h*n+g*i+d/f,y=h*h,x=g*g,b=2*h*g,C=2*h*m,E=2*g*m,P=m*m,k=1-y,w=1-x,S=a*a,R=S+P;for(const{a:e,b:t,c:a}of l){const l=e*n+t*i+a;if((0,o.isZero)(t)){const t=-l/e,o=-b*t-E,a=k*t*t+-C*t-R,c=4*x*S,u=-4*b*S*t+-4*E*S,d=-4*y*S*t*t+-4*C*S*t+-4*P*S,p=(0,r.calculateEquation4)(w*w,2*w*o,o*o+2*w*a-c,2*o*a+u,a*a+d);s.push(...p.map((e=>({x:t+n,y:e+i,r:Math.abs(h*t+g*e+m)}))))}else{const o=-e/t,a=l/t,c=-b*o+w*o*o+k,u=b*a-C+-2*w*o*a+-E*o,d=w*a*a+E*a-R,p=-4*x*S*o*o+-4*b*S*o+-4*y*S,f=8*x*S*o*a+-4*E*S*o+4*b*S*a+-4*C*S,v=-4*x*S*a*a+4*E*S*a+-4*P*S,_=(0,r.calculateEquation4)(c*c,2*c*u,u*u+2*c*d+p,2*u*d+f,d*d+v);s.push(..._.map((e=>{const t=o*e-a;return{x:e+n,y:t+i,r:Math.abs(h*e+g*t+m)}})))}}return s}function A({a:e,b:t,c:n},{x:i,y:a,r:s},{x:l,y:c,r:u}){const d=[],p=v(e,2)+v(t,2),f=Math.sqrt(p),h=e/f,g=t/f,m=i-l,y=a-c,x=h*i+g*a+n/f;for(const e of[1,-1]){const t=e*h,n=e*g,l=1-t*t,c=1-n*n;for(const p of[s,-s]){const s=e*x+p;for(const e of[u,-u]){const u=p-e,f=u*t+m,h=u*n+y,g=u*s+(m*m+y*y-u*u)/2;if((0,o.isZero)(h)){const e=-g/f,u=(0,r.calculateEquation2)(c,-2*t*n*e+-2*n*s,-2*t*s*e+-1*s*s+l*e*e);for(const r of u){const l=t*e+n*r+s-p;(0,o.largerThan)(l,0)&&d.push({x:e+i,y:r+a,r:l})}continue}const v=-f/h,x=-g/h,b=(0,r.calculateEquation2)(-2*t*n*v+v*v*c+l,-2*n*s*v+-2*t*n*x+2*v*x*c+-2*t*s,-2*n*s*x+-1*s*s+x*x*c);for(const e of b){const r=v*e+x,l=t*e+n*r+s-p;(0,o.largerThan)(l,0)&&d.push({x:e+i,y:r+a,r:l})}}}}return d}function T({x:e,y:t,r:n},{x:i,y:a,r:s},{x:l,y:c,r:u}){const d=[],p=e-i,f=e-l,h=t-a,g=t-c;for(const i of[n,-n])for(const n of[s,-s])for(const a of[u,-u]){const s=n-i,l=a-i,c=(p*p+h*h+-s*s)/2,u=(f*f+g*g+-l*l)/2;if((0,o.isZero)(h)){if((0,o.isZero)(g)){const n=(l*c-s*u)/(f*s-p*l),r=(0,o.isZero)(s)?(f*n+u)/l:(p*n+c)/s,a=r-i;if((0,o.largerThan)(a,0)){const i=r*r-n*n;if((0,o.isZero)(i))d.push({x:n+e,y:t,r:a});else if((0,o.largerThan)(i,0)){const r=Math.sqrt(i);d.push({x:n+e,y:r+t,r:a},{x:n+e,y:-r+t,r:a})}}continue}const n=f*f+g*g,a=l*l-g*g,h=(0,r.calculateEquation2)(-2*p*f*s*l+s*s*n+p*p*a,-2*f*s*l*c+2*f*s*s*u+-2*p*s*l*u+2*p*c*a,-2*s*l*c*u+s*s*u*u+c*c*a);for(const n of h){const r=(0,o.isZero)(s)?(f*n+u)/l:(p*n+c)/s,a=r-i;if((0,o.largerThan)(a,0)){const o=(l*r-f*n-u)/g;d.push({x:n+e,y:o+t,r:a})}}continue}const m=-f*h+p*g,y=-g*s+h*l,v=g*c+-h*u,x=p*p+h*h,b=-h*h+s*s;if((0,o.isZero)(y)){const n=-v/m,a=(0,r.calculateEquation2)(b,-2*p*s*n+-2*s*c,2*p*c*n+c*c+x*n*n);for(const r of a){const a=r-i;if((0,o.largerThan)(a,0)){const o=(s*r-p*n-c)/h;d.push({x:n+e,y:o+t,r:a})}}continue}const C=(0,r.calculateEquation2)(2*p*s*m*y+y*y*x+m*m*b,2*s*c*m*y+2*p*c*y*y+2*p*s*y*v+2*m*v*b,c*c*y*y+2*s*c*y*v+v*v*b);for(const n of C){const r=(-m*n-v)/y,a=r-i;if((0,o.largerThan)(a,0)){const o=(s*r-p*n-c)/h;d.push({x:n+e,y:o+t,r:a})}}}return d}function M({x:e,y:t},{x:n,y:r,r:i}){const a=v(i,2),s=n-e,l=r-t,c=v(s,2)+v(l,2),u=c-a;if((0,o.lessThan)(u,0))return[];const d=n+-s*a/c,p=r+-l*a/c;if((0,o.isZero)(u))return[{x:d,y:p}];const f=i*Math.sqrt(u)/c,h=l*f,g=s*f;return[{x:d+h,y:p-g},{x:d-h,y:p+g}]}function L({x:e,y:t},{cx:n,cy:i,rx:s,ry:l,angle:c},u=o.delta2){const d=(0,a.angleToRadian)(c),p=Math.sin(d),f=Math.cos(d),h=n-e,g=i-t,m=s*s,y=l*l,v=f*f*m+p*p*y,x=(-2*p*f*m+2*p*f*y)/v,b=(p*p*m+f*f*y)/v,C=-m*y/v,E=-h*h;let P,k,w,_,S,R,A=2*h*g,T=-2*p*f*h*m+2*f*f*g*m+2*p*f*h*y+2*p*p*g*y,M=-g*g,L=2*p*p*h*m+-2*p*f*g*m+2*f*f*h*y+2*p*f*g*y,I=p*p*h*h*m+-2*p*f*h*g*m+f*f*g*g*m+f*f*h*h*y+2*p*f*h*g*y+p*p*g*g*y+m*y;if((0,o.isZero)(h,u))P=M*M+-A*M*x+A*A*b,k=2*M*L+-T*M*x+-A*L*x+2*A*T*b,w=L*L+2*M*I+-T*L*x+-A*I*x+T*T*b+A*A*C,_=2*L*I+-T*I*x+2*A*T*C,S=I*I+T*T*C,R=e=>{const t=A*e+T;return(0,o.isZero)(t,u)?(0,r.calculateEquation2)(1,x*e,b*e*e+C,u)[0]:-(M*e*e+L*e+I)/t};else{A/=E,T/=E,M/=E,L/=E,I/=E;const e=A-x,t=M-b,n=I-C;P=b*e*e+t*t+-x*e*t,k=-L*x*e+2*T*b*e+2*L*t+-T*x*t,w=-T*L*x+T*T*b+C*e*e+-x*e*n+L*L+2*t*n,_=2*T*C*e+-T*x*n+2*L*n,S=T*T*C+n*n,R=i=>{const a=e*i+T;return(0,o.isZero)(a,u)?(0,r.calculateEquation2)(1,x*i,b*i*i+C,u)[0]:-(t*i*i+L*i+n)/a}}return(0,r.calculateEquation4)(P,k,w,_,S,u).map((e=>{const t=R(e);return{x:e+n,y:t+i}}))}function I({x:e,y:t},{from:{x:n,y:i},cp:{x:a,y:s},to:{x:l,y:c}},u=o.delta2){const d=a-n,p=l-a-d,f=s-i,h=c-s-f,g=n-e,m=i-t;return(0,r.calculateEquation2)(d*h-p*f,g*h-m*p,g*f-m*d,u).filter((e=>(0,o.isValidPercent)(e))).map((e=>({x:p*e*e+2*d*e+n,y:h*e*e+2*f*e+i})))}function O({x:e,y:t},{from:{x:n,y:i},cp1:{x:a,y:s},cp2:{x:l,y:c},to:{x:u,y:d}},p=o.delta2){const f=3*a-n+-3*l+u,h=3*(n-2*a+l),g=3*(a-n),m=3*s-i+-3*c+d,y=3*(i-2*s+c),v=3*(s-i),x=i-t,b=n-e;return(0,r.calculateEquation4)(h*m-f*y,2*(g*m+-f*v),g*y+-h*v+-3*f*x+3*m*b,2*(y*b-h*x),v*b-g*x,p).filter((e=>(0,o.isValidPercent)(e))).map((e=>({x:f*e*e*e+h*e*e+g*e+n,y:m*e*e*e+y*e*e+v*e+i})))}function B(e,t){return(0,s.normalizeRadian)(t+Math.PI/2)}function F(e,t){return(0,s.normalizeRadian)(t+Math.PI/2*(e.counterclockwise?-1:1))}function D(e,t){const{rx:n,ry:r,angle:o}=e,i=(0,a.angleToRadian)(o),s=Math.sin(i),l=Math.cos(i),c=Math.cos(t)*r,u=Math.sin(t)*n;return Math.atan2(c*l-s*u,-c*s-l*u)}function z(e,t){return(0,s.normalizeRadian)(D(e,t)+(e.counterclockwise?Math.PI:0))}function U({from:{x:e,y:t},cp:{x:n,y:r},to:{x:o,y:i}},a){const s=n-e,l=o-n-s,c=r-t,u=i-r-c;return Math.atan2(u*a+c,l*a+s)}function N({from:{x:e,y:t},cp1:{x:n,y:r},cp2:{x:o,y:i},to:{x:a,y:s}},l){const c=3*n-e+-3*o+a,u=3*(e-2*n+o),d=3*(n-e),p=3*r-t+-3*i+s,f=3*(t-2*r+i),h=3*(r-t);return Math.atan2(3*p*v(l,2)+2*f*l+h,3*c*v(l,2)+2*u*l+d)}},8905:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Image:()=>p,Text:()=>d,TextStyle:()=>c,getTextSize:()=>a,getTextSizeFromCache:()=>l,getTextStyleFont:()=>u,isLetter:()=>h,isNumber:()=>g,isWordCharactor:()=>f});var r=n(5773),o=n(7486),i=n(5569);function a(e,t){const n=new OffscreenCanvas(0,0).getContext("2d");if(n){n.font=e;const r=n.measureText(t),o=r.actualBoundingBoxAscent+r.actualBoundingBoxDescent;return{width:r.width,height:o}}}const s=new(n(7713).MapCache2);function l(e,t){return s.get(e,t,(()=>a(e,t)))}const c={fontSize:i.number,fontFamily:i.string};function u(e){return`${e.fontSize}px ${e.fontFamily}`}const d=(0,i.and)(r.Position,c,{text:i.string,color:i.number}),p=(0,i.and)(o.Region,{url:i.string});function f(e){return"."===e||!!h(e)||!!g(e)}function h(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}function g(e){return e>="0"&&e<="9"}},360:(e,t,n)=>{"use strict";n.r(t),n.d(t,{reverseTransformPosition:()=>a,scaleByCursorPosition:()=>u,transformPosition:()=>s,zoomToFit:()=>l,zoomToFitPoints:()=>c});var r=n(2792),o=n(5773),i=n(6842);function a(e,t){return t?(e={x:(e.x-t.center.x-t.x)/t.scale+t.center.x,y:(e.y-t.center.y-t.y)/t.scale+t.center.y},t.rotate&&(e=(0,o.rotatePosition)(e,{x:0,y:0},-t.rotate)),e):e}function s(e,t){return t?(t.rotate&&(e=(0,o.rotatePosition)(e,{x:0,y:0},t.rotate)),{x:(e.x-t.center.x)*t.scale+t.center.x+t.x,y:(e.y-t.center.y)*t.scale+t.center.y+t.y}):e}function l(e,{width:t,height:n},o,i=.8){if(e&&!(0,r.isSameNumber)(e.start.x,e.end.x)&&!(0,r.isSameNumber)(e.start.y,e.end.y)){const a=Math.min(t/Math.abs(e.end.x-e.start.x),n/Math.abs(e.end.y-e.start.y))*i;return{scale:a,x:(o.x-(0,r.getTwoNumberCenter)(e.start.x,e.end.x))*a,y:(o.y-(0,r.getTwoNumberCenter)(e.start.y,e.end.y))*a}}}function c(e,{width:t,height:n},a,s=.8,l){const c=(0,i.getPointsBoundingUnsafe)(e);if(c&&!(0,r.isSameNumber)(c.start.x,c.end.x)&&!(0,r.isSameNumber)(c.start.y,c.end.y)){let r,u;if(l){const t=(0,i.getPointsBoundingUnsafe)(e.map((e=>(0,o.rotatePosition)(e,{x:0,y:0},l))));r=Math.abs(t.end.x-t.start.x),u=Math.abs(t.end.y-t.start.y)}else r=Math.abs(c.end.x-c.start.x),u=Math.abs(c.end.y-c.start.y);const d=Math.min(t/r,n/u)*s;let p=(0,o.getTwoPointCenter)(c.start,c.end);return l&&(p=(0,o.rotatePosition)(p,{x:0,y:0},l)),{scale:d,x:(a.x-p.x)*d,y:(a.y-p.y)*d}}}function u({width:e,height:t},n,r){return{setX:t=>r.x-e/2-(r.x-e/2-t)*n,setY:e=>r.y-t/2-(r.y-t/2-e)*n}}},3793:(e,t,n)=>{"use strict";n.r(t),n.d(t,{combineStripTriangleColors:()=>h,combineStripTriangles:()=>p,defaultLineCap:()=>y,defaultLineJoin:()=>m,defaultMiterLimit:()=>g,getPolylineTriangles:()=>d,triangleStripToTriangles:()=>f});var r=n(2792),o=n(5773),i=n(1715),a=n(8831),s=n(1796),l=n(2318),c=n(491),u=n(8392);function d(e,t,n=y,d=g){const p=t/2;!0===n?e=(0,s.polygonToPolyline)(e):(0,o.isSamePoint)(e[0],e[e.length-1])&&(n=!0);const f=[e[0]],h=[],m=[];for(let t=1;t{"use strict";n.r(t),n.d(t,{Nullable:()=>o});var r=n(5569);const o=e=>(0,r.or)(void 0,null,e)},5569:(e,t,n)=>{"use strict";n.r(t),n.d(t,{and:()=>w,bigint:()=>s,boolean:()=>c,exclusiveMaximum:()=>E,exclusiveMinimum:()=>C,integer:()=>l,is:()=>A,maxItems:()=>g,maxLength:()=>y,maximum:()=>b,minItems:()=>h,minLength:()=>m,minimum:()=>x,multipleOf:()=>P,never:()=>p,number:()=>a,optional:()=>f,or:()=>k,pattern:()=>v,record:()=>_,string:()=>i,symbol:()=>u,tuple:()=>S,unknown:()=>d,validate:()=>R});var r=n(6022),o=n(1074);const i=(e,t)=>"string"==typeof e||{path:t,expect:"string"},a=(e,t)=>"number"==typeof e&&!isNaN(e)||{path:t,expect:"number"},s=(e,t)=>"bigint"==typeof e||{path:t,expect:"bigint"},l=(e,t)=>!!Number.isInteger(e)||{path:t,expect:"integer"},c=(e,t)=>"boolean"==typeof e||{path:t,expect:"boolean"},u=(e,t)=>"symbol"==typeof e||{path:t,expect:"symbol"},d=()=>!0,p=(e,t)=>({path:t,expect:"never"}),f=e=>(t,n)=>void 0===t||R(t,e,n),h=(e,t)=>(n,r)=>(0,o.isArray)(n)?n.length>=e?R(n,t,r):{path:r,expect:"minItems",args:[e]}:{path:r,expect:"array"},g=(e,t)=>(n,r)=>(0,o.isArray)(n)?n.length<=e?R(n,t,r):{path:r,expect:"maxItems",args:[e]}:{path:r,expect:"array"},m=(e,t)=>(n,r)=>"string"!=typeof n?{path:r,expect:"string"}:n.length>=e?R(n,t,r):{path:r,expect:"minLength",args:[e]},y=(e,t)=>(n,r)=>"string"!=typeof n?{path:r,expect:"string"}:n.length<=e?R(n,t,r):{path:r,expect:"maxLength",args:[e]},v=(e,t)=>(n,r)=>"string"!=typeof n?{path:r,expect:"string"}:n.match(e)?R(n,t,r):{path:r,expect:"pattern",args:[e]},x=(e,t)=>(n,r)=>"number"!=typeof n||isNaN(n)?{path:r,expect:"number"}:n>=e?R(n,t,r):{path:r,expect:"minimum",args:[e]},b=(e,t)=>(n,r)=>"number"!=typeof n||isNaN(n)?{path:r,expect:"number"}:n<=e?R(n,t,r):{path:r,expect:"maximum",args:[e]},C=(e,t)=>(n,r)=>"number"!=typeof n||isNaN(n)?{path:r,expect:"number"}:n>e?R(n,t,r):{path:r,expect:"exclusiveMinimum",args:[e]},E=(e,t)=>(n,r)=>"number"!=typeof n||isNaN(n)?{path:r,expect:"number"}:n(n,r)=>"number"!=typeof n?{path:r,expect:"number"}:Number.isInteger(n)?n%e==0?R(n,t,r):{path:r,expect:"multipleOf",args:[e]}:{path:r,expect:"integer"},k=(...e)=>(t,n)=>{const r=[];for(const n of e){const e=R(t,n);if(!0===e)return!0;r.push(e)}return{path:n,expect:"or",args:r}},w=(...e)=>Object.assign({},...e),_=(e,t)=>(n,o)=>{if(!(0,r.isRecord)(n))return{path:o,expect:"object"};for(const[r,i]of Object.entries(n)){const n=[...o,r],a=R(r,e,n);if(!0!==a)return a;const s=R(i,t,n);if(!0!==s)return s}return!0},S=(...e)=>(t,n)=>{if(!(0,o.isArray)(t))return{path:n,expect:"array"};if(e.length!==t.length)return{path:n,expect:"length",args:[e.length]};for(let r=0;r{"use strict";n.r(t),n.d(t,{MapCache:()=>g,MapCache2:()=>m,MapCache3:()=>y,MapCache4:()=>v,WeakmapCache:()=>a,WeakmapCache2:()=>s,WeakmapCache3:()=>l,WeakmapCache4:()=>c,WeakmapMap2Cache:()=>p,WeakmapMap3Cache:()=>f,WeakmapMap4Cache:()=>h,WeakmapMapCache:()=>d,WeakmapValuesCache:()=>u});var r=n(5775),o=Object.defineProperty,i=(e,t,n)=>(((e,t,n)=>{t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);class a{constructor(){i(this,"cache",new WeakMap)}get(e,t){let n=this.cache.get(e);return void 0===n&&(n=t(),this.cache.set(e,n)),n}clear(){this.cache=new WeakMap}}class s{constructor(){i(this,"cache",new WeakMap)}get(e,t,n){let r=this.cache.get(e);r||(r=new WeakMap,this.cache.set(e,r));let o=r.get(t);return void 0===o&&(o=n(),r.set(t,o)),o}clear(){this.cache=new WeakMap}}class l{constructor(){i(this,"cache",new WeakMap)}get(e,t,n,r){let o=this.cache.get(e);o||(o=new WeakMap,this.cache.set(e,o));let i=o.get(t);i||(i=new WeakMap,o.set(t,i));let a=i.get(n);return void 0===a&&(a=r(),i.set(n,a)),a}clear(){this.cache=new WeakMap}}class c{constructor(){i(this,"cache",new WeakMap)}get(e,t,n,r,o){let i=this.cache.get(e);return i||(i=new l,this.cache.set(e,i)),i.get(t,n,r,o)}clear(){this.cache=new WeakMap}}class u{constructor(){i(this,"caches",new WeakMap)}get(e,t,n){let o=this.caches.get(e);return o||(o=new r.WeakValuesChangedCache,this.caches.set(e,o)),o.get(t,n)}clear(){this.caches=new WeakMap}}class d{constructor(){i(this,"cache",new WeakMap)}get(e,t,n){let r=this.cache.get(e);r||(r=new Map,this.cache.set(e,r));let o=r.get(t);return void 0===o&&(o=n(),r.set(t,o)),o}clear(){this.cache=new WeakMap}}class p{constructor(){i(this,"cache",new WeakMap)}get(e,t,n,r){let o=this.cache.get(e);o||(o=new Map,this.cache.set(e,o));let i=o.get(t);i||(i=new Map,o.set(t,i));let a=i.get(n);return void 0===a&&(a=r(),i.set(n,a)),a}clear(){this.cache=new WeakMap}}class f{constructor(){i(this,"cache",new WeakMap)}get(e,t,n,r,o){let i=this.cache.get(e);i||(i=new Map,this.cache.set(e,i));let a=i.get(t);a||(a=new Map,i.set(t,a));let s=a.get(n);s||(s=new Map,a.set(n,s));let l=s.get(r);return void 0===l&&(l=o(),s.set(r,l)),l}clear(){this.cache=new WeakMap}}class h{constructor(){i(this,"cache",new WeakMap)}get(e,t,n,r,o,i){let a=this.cache.get(e);a||(a=new Map,this.cache.set(e,a));let s=a.get(t);s||(s=new Map,a.set(t,s));let l=s.get(n);l||(l=new Map,s.set(n,l));let c=l.get(r);c||(c=new Map,l.set(r,c));let u=c.get(o);return void 0===u&&(u=i(),c.set(o,u)),u}clear(){this.cache=new WeakMap}}class g{constructor(){i(this,"cache",new Map)}get(e,t){let n=this.cache.get(e);return void 0===n&&(n=t(),this.cache.set(e,n)),n}clear(){this.cache.clear()}values(){return this.cache.values()}}class m{constructor(){i(this,"cache",new Map)}get(e,t,n){let r=this.cache.get(e);r||(r=new Map,this.cache.set(e,r));let o=r.get(t);if(void 0===o){if(!n)return;o=n(),r.set(t,o)}return o}}class y{constructor(){i(this,"cache",new Map)}get(e,t,n,r){let o=this.cache.get(e);o||(o=new Map,this.cache.set(e,o));let i=o.get(t);i||(i=new Map,o.set(t,i));let a=i.get(n);if(void 0===a){if(!r)return;a=r(),i.set(n,a)}return a}}class v{constructor(){i(this,"cache",new Map)}get(e,t,n,r,o){let i=this.cache.get(e);i||(i=new Map,this.cache.set(e,i));let a=i.get(t);a||(a=new Map,i.set(t,a));let s=a.get(n);s||(s=new Map,a.set(n,s));let l=s.get(r);if(void 0===l){if(!o)return;l=o(),s.set(r,l)}return l}}},5775:(e,t,n)=>{"use strict";n.r(t),n.d(t,{WeakValuesChangedCache:()=>a,WeaksetCache:()=>i});var r=Object.defineProperty,o=(e,t,n)=>(((e,t,n)=>{t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);class i{constructor(){o(this,"cache",new WeakSet),o(this,"count",0)}clear(){this.cache=new WeakSet,this.count=0}add(...e){for(const t of e)this.cache.add(t);this.count+=e.length}has(e){return this.cache.has(e)}delete(e){return this.count--,this.cache.delete(e)}get size(){return this.count}}class a{constructor(){o(this,"cache")}get(e,t){if(Array.isArray(e)&&(e=new Set(e)),void 0===this.cache||e.size!==this.cache.size)return this.cache={keys:new WeakSet(e),value:t(),size:e.size},this.cache.value;for(const n of e)if(!this.cache.keys.has(n))return this.cache={keys:new WeakSet(e),value:t(),size:e.size},this.cache.value;return this.cache.value}clear(){this.cache=void 0}}},1717:(e,t,n)=>{"use strict";n.d(t,{ExpressionError:()=>r});class r extends Error{constructor(e,t){super(e),this.range=t}}},4486:(e,t,n)=>{"use strict";n.d(t,{evaluateExpression:()=>o});var r=n(3031);function o(e,t,n,r){return new(u(e)?a:i)(n,Array.isArray(r)?e=>r.some((t=>e instanceof t)):r).evalutate(e,t,!0)}class i{constructor(e,t){this.isCustomData=t,this.locale=(0,r.getLocale)(e)}evalutate(e,t,n){return s(e,t,n,this)}evaluateBinaryExpression(e,t){return l(e,this.evalutate(e.left,t,!0),this.evalutate(e.right,t,!0),this.locale,this.isCustomData)}evaluateLogicalExpression(e,t){const n=this.evalutate(e.left,t,!0);if("&&"===e.operator)return n&&this.evalutate(e.right,t,!0);if("||"===e.operator)return n||this.evalutate(e.right,t,!0);if("??"===e.operator)return null!=n?n:this.evalutate(e.right,t,!0);throw new r.ExpressionError(this.locale.unexpectToken,e.range)}evaluateUnaryExpression(e,t){return c(e,this.evalutate(e.argument,t,!0),this.locale)}}class a{constructor(e,t){this.isCustomData=t,this.locale=(0,r.getLocale)(e)}evalutate(e,t,n){return s(e,t,n,this)}async evaluateBinaryExpression(e,t){return l(e,await this.evalutate(e.left,t,!0),await this.evalutate(e.right,t,!0),this.locale,this.isCustomData)}evaluateLogicalExpression(e,t){const n=this.evalutate(e.left,t,!0);if("&&"===e.operator)return n&&this.evalutate(e.right,t,!0);if("||"===e.operator)return n||this.evalutate(e.right,t,!0);if("??"===e.operator)return null!=n?n:this.evalutate(e.right,t,!0);throw new r.ExpressionError(this.locale.unexpectToken,e.range)}async evaluateUnaryExpression(e,t){return c(e,await this.evalutate(e.argument,t,!0),this.locale)}}function s(e,t,n,o){if("BinaryExpression"===e.type)return o.evaluateBinaryExpression(e,t);if("MemberExpression"===e.type){const n=o.evalutate(e.object,t,!0),i=o.evalutate(e.property,t,!1);if(e.optional&&!n)return;if(!["length","name","toString","valueOf","toLocaleString"].includes(i)&&(i in Object.prototype||i in Function.prototype))throw new r.ExpressionError(`No access to property "${i}"`,e.property.range);const a=n[i];return"function"==typeof a?a.bind(n):a}if("ConditionalExpression"===e.type)return o.evalutate(e.test,t,!0)?o.evalutate(e.consequent,t,!0):o.evalutate(e.alternate,t,!0);if("CallExpression"===e.type){const n=o.evalutate(e.callee,t,!0),r=[];for(const n of e.arguments)"SpreadElement"===n.type?r.push(...o.evalutate(n.argument,t,!0)):r.push(o.evalutate(n,t,!0));return n(...r)}if("LogicalExpression"===e.type)return o.evaluateLogicalExpression(e,t);if("UnaryExpression"===e.type)return o.evaluateUnaryExpression(e,t);if("Identifier"===e.type||"ThisExpression"===e.type){const r="Identifier"===e.type?e.name:"this";return n?t[r]:r}if("NumericLiteral"===e.type)return e.value;if("StringLiteral"===e.type)return e.value;if("NullLiteral"===e.type)return null;if("BooleanLiteral"===e.type)return e.value;if("ArrayExpression"===e.type){const n=[];for(const r of e.elements)"SpreadElement"===r.type?n.push(...o.evalutate(r.argument,t,!0)):n.push(o.evalutate(r,t,!0));return n}if("ObjectExpression"===e.type){const n={};for(const r of e.properties)"Property"===r.type?n["Identifier"===r.key.type?r.key.name:r.key.value]=o.evalutate(r.value,t,!0):Object.assign(n,o.evalutate(r.argument,t,!0));return n}if("ArrowFunctionExpression"===e.type)return(...n)=>{let r;if(0===n.length)r=t;else{r={...t};for(let t=0;t"===e.operator&&t.greaterThan)return t.greaterThan(n);if("<="===e.operator&&t.lessThanOrEqual)return t.lessThanOrEqual(n);if(">"===e.operator&&t.greaterThanOrEqual)return t.greaterThanOrEqual(n)}if(i(n)){if("+"===e.operator&&n.added)return n.added(t);if("-"===e.operator&&n.subtracted)return n.subtracted(t);if("*"===e.operator&&n.multiplied)return n.multiplied(t);if("/"===e.operator&&n.divided)return n.divided(t);if("%"===e.operator&&n.remainered)return n.remainered(t);if("**"===e.operator&&n.powered)return n.powered(t);if(("=="===e.operator||"==="===e.operator)&&n.equal)return n.equal(t);if(("!="===e.operator||"!=="===e.operator)&&n.equal)return!n.equal(t);if("<"===e.operator&&n.greaterThanOrEqual)return n.greaterThanOrEqual(t);if(">"===e.operator&&n.lessThanOrEqual)return n.lessThanOrEqual(t);if("<="===e.operator&&n.greaterThan)return n.greaterThan(t);if(">="===e.operator&&n.lessThan)return n.lessThan(t)}}if("+"===e.operator){if("string"==typeof t)return t+n;if("number"!=typeof t||isNaN(t))throw new r.ExpressionError((0,r.replaceLocaleParameters)(o.expect,"Number",e.left.range[0]),e.left.range);if("string"==typeof n)return t+n;if("number"!=typeof n||isNaN(n))throw new r.ExpressionError((0,r.replaceLocaleParameters)(o.expect,"Number",e.right.range[0]),e.right.range);return t+n}if("=="===e.operator||"==="===e.operator||"!="===e.operator||"!=="===e.operator)return"=="===e.operator||"==="===e.operator?t===n:t!==n;if("string"==typeof t&&"string"==typeof n){if(">"===e.operator)return t>n;if(">="===e.operator)return t>=n;if("<"===e.operator)return t"===e.operator)return n(t);if("number"!=typeof t)throw new r.ExpressionError((0,r.replaceLocaleParameters)(o.expect,"Number",e.left.range[0]),e.left.range);if("number"!=typeof n)throw new r.ExpressionError((0,r.replaceLocaleParameters)(o.expect,"Number",e.right.range[0]),e.right.range);if("-"===e.operator)return t-n;if("*"===e.operator)return t*n;if("/"===e.operator)return t/n;if("%"===e.operator)return t%n;if(">"===e.operator)return t>n;if(">="===e.operator)return t>=n;if("<"===e.operator)return t>"===e.operator)return t>>n;if("<<"===e.operator)return t<>>"===e.operator)return t>>>n;if("&"===e.operator)return t&n;if("^"===e.operator)return t^n;if("|"===e.operator)return t|n;throw new r.ExpressionError(o.unexpectToken,e.range)}function c(e,t,n){if("!"===e.operator)return!t;if("+"===e.operator&&("number"==typeof t||"string"==typeof t))return+t;if("number"!=typeof t||isNaN(t))throw new r.ExpressionError((0,r.replaceLocaleParameters)(n.expect,"Number",e.argument.range[0]),e.argument.range);if("-"===e.operator)return-t;if("~"===e.operator)return~t;if("%"===e.operator)return t/100;if("await"===e.operator)return t;throw new r.ExpressionError(n.unexpectToken,e.range)}function u(e){return"NumericLiteral"!==e.type&&"StringLiteral"!==e.type&&"Identifier"!==e.type&&"ThisExpression"!==e.type&&"NullLiteral"!==e.type&&"BooleanLiteral"!==e.type&&("SpreadElement"===e.type||"RestElement"===e.type?u(e.argument):"AssignmentPattern"===e.type?u(e.left)||u(e.right):"ArrayExpression"===e.type?e.elements.some((e=>u(e))):"ArrowFunctionExpression"===e.type?e.params.some((e=>u(e)))||u(e.body):"UnaryExpression"===e.type?"await"===e.operator||u(e.argument):"BinaryExpression"===e.type||"LogicalExpression"===e.type?u(e.left)||u(e.right):"MemberExpression"===e.type?u(e.object)||u(e.property):"CallExpression"===e.type?e.arguments.some((e=>u(e)))||u(e.callee):"ConditionalExpression"===e.type?u(e.test)||u(e.consequent)||u(e.alternate):"Property"===e.type?u(e.key)||u(e.value):"ObjectExpression"===e.type?e.properties.some((e=>u(e))):e.params.some((e=>u(e))))}},3031:(e,t,n)=>{"use strict";var r=n(1283);n.o(r,"ExpressionError")&&n.d(t,{ExpressionError:function(){return r.ExpressionError}}),n.o(r,"evaluateExpression")&&n.d(t,{evaluateExpression:function(){return r.evaluateExpression}}),n.o(r,"getLocale")&&n.d(t,{getLocale:function(){return r.getLocale}}),n.o(r,"parseExpression")&&n.d(t,{parseExpression:function(){return r.parseExpression}}),n.o(r,"postfixUnaryOperators")&&n.d(t,{postfixUnaryOperators:function(){return r.postfixUnaryOperators}}),n.o(r,"printExpression")&&n.d(t,{printExpression:function(){return r.printExpression}}),n.o(r,"priorizedBinaryOperators")&&n.d(t,{priorizedBinaryOperators:function(){return r.priorizedBinaryOperators}}),n.o(r,"replaceLocaleParameters")&&n.d(t,{replaceLocaleParameters:function(){return r.replaceLocaleParameters}}),n.o(r,"tokenizeExpression")&&n.d(t,{tokenizeExpression:function(){return r.tokenizeExpression}});var o=n(5138);n.o(o,"ExpressionError")&&n.d(t,{ExpressionError:function(){return o.ExpressionError}}),n.o(o,"evaluateExpression")&&n.d(t,{evaluateExpression:function(){return o.evaluateExpression}}),n.o(o,"getLocale")&&n.d(t,{getLocale:function(){return o.getLocale}}),n.o(o,"parseExpression")&&n.d(t,{parseExpression:function(){return o.parseExpression}}),n.o(o,"postfixUnaryOperators")&&n.d(t,{postfixUnaryOperators:function(){return o.postfixUnaryOperators}}),n.o(o,"printExpression")&&n.d(t,{printExpression:function(){return o.printExpression}}),n.o(o,"priorizedBinaryOperators")&&n.d(t,{priorizedBinaryOperators:function(){return o.priorizedBinaryOperators}}),n.o(o,"replaceLocaleParameters")&&n.d(t,{replaceLocaleParameters:function(){return o.replaceLocaleParameters}}),n.o(o,"tokenizeExpression")&&n.d(t,{tokenizeExpression:function(){return o.tokenizeExpression}});var i=n(8296);n.o(i,"ExpressionError")&&n.d(t,{ExpressionError:function(){return i.ExpressionError}}),n.o(i,"evaluateExpression")&&n.d(t,{evaluateExpression:function(){return i.evaluateExpression}}),n.o(i,"getLocale")&&n.d(t,{getLocale:function(){return i.getLocale}}),n.o(i,"parseExpression")&&n.d(t,{parseExpression:function(){return i.parseExpression}}),n.o(i,"postfixUnaryOperators")&&n.d(t,{postfixUnaryOperators:function(){return i.postfixUnaryOperators}}),n.o(i,"printExpression")&&n.d(t,{printExpression:function(){return i.printExpression}}),n.o(i,"priorizedBinaryOperators")&&n.d(t,{priorizedBinaryOperators:function(){return i.priorizedBinaryOperators}}),n.o(i,"replaceLocaleParameters")&&n.d(t,{replaceLocaleParameters:function(){return i.replaceLocaleParameters}}),n.o(i,"tokenizeExpression")&&n.d(t,{tokenizeExpression:function(){return i.tokenizeExpression}});var a=n(6257);n.o(a,"ExpressionError")&&n.d(t,{ExpressionError:function(){return a.ExpressionError}}),n.o(a,"evaluateExpression")&&n.d(t,{evaluateExpression:function(){return a.evaluateExpression}}),n.o(a,"getLocale")&&n.d(t,{getLocale:function(){return a.getLocale}}),n.o(a,"parseExpression")&&n.d(t,{parseExpression:function(){return a.parseExpression}}),n.o(a,"postfixUnaryOperators")&&n.d(t,{postfixUnaryOperators:function(){return a.postfixUnaryOperators}}),n.o(a,"printExpression")&&n.d(t,{printExpression:function(){return a.printExpression}}),n.o(a,"priorizedBinaryOperators")&&n.d(t,{priorizedBinaryOperators:function(){return a.priorizedBinaryOperators}}),n.o(a,"replaceLocaleParameters")&&n.d(t,{replaceLocaleParameters:function(){return a.replaceLocaleParameters}}),n.o(a,"tokenizeExpression")&&n.d(t,{tokenizeExpression:function(){return a.tokenizeExpression}});var s=n(4486);n.o(s,"ExpressionError")&&n.d(t,{ExpressionError:function(){return s.ExpressionError}}),n.o(s,"evaluateExpression")&&n.d(t,{evaluateExpression:function(){return s.evaluateExpression}}),n.o(s,"getLocale")&&n.d(t,{getLocale:function(){return s.getLocale}}),n.o(s,"parseExpression")&&n.d(t,{parseExpression:function(){return s.parseExpression}}),n.o(s,"postfixUnaryOperators")&&n.d(t,{postfixUnaryOperators:function(){return s.postfixUnaryOperators}}),n.o(s,"printExpression")&&n.d(t,{printExpression:function(){return s.printExpression}}),n.o(s,"priorizedBinaryOperators")&&n.d(t,{priorizedBinaryOperators:function(){return s.priorizedBinaryOperators}}),n.o(s,"replaceLocaleParameters")&&n.d(t,{replaceLocaleParameters:function(){return s.replaceLocaleParameters}}),n.o(s,"tokenizeExpression")&&n.d(t,{tokenizeExpression:function(){return s.tokenizeExpression}});var l=n(856);n.o(l,"ExpressionError")&&n.d(t,{ExpressionError:function(){return l.ExpressionError}}),n.o(l,"evaluateExpression")&&n.d(t,{evaluateExpression:function(){return l.evaluateExpression}}),n.o(l,"getLocale")&&n.d(t,{getLocale:function(){return l.getLocale}}),n.o(l,"parseExpression")&&n.d(t,{parseExpression:function(){return l.parseExpression}}),n.o(l,"postfixUnaryOperators")&&n.d(t,{postfixUnaryOperators:function(){return l.postfixUnaryOperators}}),n.o(l,"printExpression")&&n.d(t,{printExpression:function(){return l.printExpression}}),n.o(l,"priorizedBinaryOperators")&&n.d(t,{priorizedBinaryOperators:function(){return l.priorizedBinaryOperators}}),n.o(l,"replaceLocaleParameters")&&n.d(t,{replaceLocaleParameters:function(){return l.replaceLocaleParameters}}),n.o(l,"tokenizeExpression")&&n.d(t,{tokenizeExpression:function(){return l.tokenizeExpression}});var c=n(1717);n.o(c,"ExpressionError")&&n.d(t,{ExpressionError:function(){return c.ExpressionError}}),n.o(c,"evaluateExpression")&&n.d(t,{evaluateExpression:function(){return c.evaluateExpression}}),n.o(c,"getLocale")&&n.d(t,{getLocale:function(){return c.getLocale}}),n.o(c,"parseExpression")&&n.d(t,{parseExpression:function(){return c.parseExpression}}),n.o(c,"postfixUnaryOperators")&&n.d(t,{postfixUnaryOperators:function(){return c.postfixUnaryOperators}}),n.o(c,"printExpression")&&n.d(t,{printExpression:function(){return c.printExpression}}),n.o(c,"priorizedBinaryOperators")&&n.d(t,{priorizedBinaryOperators:function(){return c.priorizedBinaryOperators}}),n.o(c,"replaceLocaleParameters")&&n.d(t,{replaceLocaleParameters:function(){return c.replaceLocaleParameters}}),n.o(c,"tokenizeExpression")&&n.d(t,{tokenizeExpression:function(){return c.tokenizeExpression}})},1283:()=>{},6257:(e,t,n)=>{"use strict";n.d(t,{getLocale:()=>o,replaceLocaleParameters:()=>i});const r={multipleDecimalPoint:"Multiple decimal point: {0}",expect:"Expect {0}: {1}",unexpectToken:"Unexpected token: {0} {1}",expectUnaryOperator:"Expect unary operator: {0}",expectConditionalOperator:"Expect conditional operator: {0} {1}",invalidPropertyName:"Invalid property name: {0}",emptyExpression:"Empty expression",invalidFunctionParameter:"Invalid function parameter: {0}"};function o(e){return e||r}function i(e,...t){for(let n=0;n{"use strict";n.d(t,{parseExpression:()=>o,postfixUnaryOperators:()=>u,priorizedBinaryOperators:()=>l});var r=n(3031);function o(e,t){return new i(t).parseExpression(e,a(e))}class i{constructor(e){this.locale=(0,r.getLocale)(e)}parseExpression(e,t,n){if(0===e.length)throw new r.ExpressionError(this.locale.emptyExpression,[0,0]);if(1===e.length)return this.parseLiteral(e[0]);if(2===e.length)return this.parseUnaryExpression(e,null!=n?n:t);const o=e[0],i=e[e.length-1];if("PunctuatorToken"===o.type&&"{"===o.value&&"PunctuatorToken"===i.type&&"}"===i.value)return this.parseObjectLiteral(e,t);if(3===e.length){const[r,o,i]=e;if("PunctuatorToken"===o.type){if(d.includes(o.value))return this.parseMemberExpression(r,o,i,t);if("=>"===o.value)return{type:"ArrowFunctionExpression",params:"FunctionParamsExpression"===r.type?r.params:[r],body:i,range:t};if(l.some((e=>e.some((e=>e===o.value)))))return this.parseBinaryExpression(r,o,i,t,n)}else if("PunctuatorToken"===i.type&&u.includes(i.value)){const e=this.parseExpression([o,i],[o.range[0],t[1]]);return this.parseExpression([r,e],t)}}if(e.some((e=>"PunctuatorToken"===e.type&&"("===e.value))){const t=this.parseGroup(e);if(t.length!==e.length)return this.parseExpression(t,a(e))}if(e.some((e=>"PunctuatorToken"===e.type&&"["===e.value))){const t=this.parseArrayLiteral(e);if(t.length!==e.length)return this.parseExpression(t,a(e))}if(e.some((e=>"PunctuatorToken"===e.type&&(d.includes(e.value)||"("===e.value||"["===e.value))))return this.parseMemberOrCallExpression(e);const c=this.getPostfixUnaryOperatorIndex(e);if(c>=0){const n=e[c-1],r=e[c],o=[n.range[0],r.range[1]],i=this.parseExpression([n,r],o);return e.splice(c-1,2,i),this.parseExpression(e,t)}const p=this.getPrefixUnaryOperatorIndex(e);if(p>=0){const n=e[p],r=e[p+1],o=[n.range[0],r.range[1]],i=this.parseExpression([n,r],o);return e.splice(p,2,i),this.parseExpression(e,t)}for(const n of l)if(e.some((e=>"PunctuatorToken"===e.type&&n.includes(e.value))))return this.parsePreviousExpression(e,n,t);if(5===e.length)return this.parseConditionalExpression(e,t);const f=s(0,e);if(f>=0){const n=this.parseFunctionParameters(e.slice(0,f),[e[0].range[0],e[f-1].range[1]]),r=this.parseExpression(e.slice(f+1),[e[f+1].range[0],e[e.length-1].range[1]]);return{type:"ArrowFunctionExpression",params:n.params,body:r,range:t}}throw new r.ExpressionError((0,r.replaceLocaleParameters)(this.locale.unexpectToken,t[0],t[1]),t)}parseObjectLiteral(e,t){const n=[];let r=[],o=[],i=!0;const a=(...e)=>{i?r.push(...e):o.push(...e)};for(let t=1;t0&&n.push(this.parseProperty(r,o)),{type:"ObjectExpression",properties:n,range:t}}parseProperty(e,t){if(2===e.length&&0===t.length){const[t,n]=e;if("PunctuatorToken"===t.type&&"..."===t.value&&!h(n))return{type:"SpreadElement",argument:n,range:[t.range[0],n.range[1]]}}const n=this.parseExpression(e,a(e));if("Identifier"!==n.type&&"StringLiteral"!==n.type&&"NumericLiteral"!==n.type)throw new r.ExpressionError((0,r.replaceLocaleParameters)(this.locale.invalidPropertyName,n.range[0]),n.range);if(0===t.length)return{type:"Property",key:n,shorthand:!0,value:n,range:n.range};const o=this.parseExpression(t,a(t));return{type:"Property",key:n,shorthand:!1,value:o,range:[n.range[0],o.range[1]]}}parseMemberExpression(e,t,n,r){const o={type:"MemberExpression",object:this.parseTokenOrExpression(e),property:this.parseTokenOrExpression(n),range:r};return"?."===t.value&&(o.optional=!0),o}parseGroup(e){const t=[];for(let n=0;n=0;t--){const n=e[t];if("PunctuatorToken"===n.type&&c.includes(n.value)&&(0===t||"PunctuatorToken"===e[t-1].type)&&"PunctuatorToken"!==e[t+1].type)return t}return-1}getPostfixUnaryOperatorIndex(e){for(let t=1;t1){const n=e[t-2];return"PunctuatorToken"!==n.type||")"===n.value||"]"===n.value}return!1}parseItems(e,t,n){const r=[];let o=[];for(let i=t+1;i0&&r.push(this.parseMayBeSpreadExpression(o,a(o))),r}parseMayBeSpreadExpression(e,t){if(2===e.length){const[n,r]=e;if("PunctuatorToken"===n.type&&"..."===n.value&&!h(r))return{type:"SpreadElement",argument:r,range:t}}return this.parseExpression(e,t)}parseConditionalExpression(e,t){const[n,o,i,a,s]=e;if("PunctuatorToken"===o.type&&"?"===o.value&&"PunctuatorToken"===a.type&&":"===a.value)return n.range[1]=o.range[0]-1,{type:"ConditionalExpression",test:this.parseTokenOrExpression(n),consequent:this.parseTokenOrExpression(i),alternate:this.parseTokenOrExpression(s),range:t};throw new r.ExpressionError((0,r.replaceLocaleParameters)(this.locale.expectConditionalOperator,o.range[0],a.range[0]),[o.range[0],a.range[0]])}parseTokenOrExpression(e){return h(e)?this.parseExpression([e],e.range):e}findGroupEnd(e,t,n){const o=p[n];let i=1;for(let r=t+1;r"===n.value)return e+1}return-1}const l=[["**"],["*","/","%"],["+","-"],["<<",">>",">>>"],[">","<",">=","<="],["==","!=","===","!=="],["&&"],["&"],["^"],["|"],["||","??"],["|>"]],c=["+","-","!","~","await"],u=["%"],d=[".","?."],p={"{":"}","[":"]","(":")"},f=Object.keys(p);function h(e){return"EOFToken"===e.type||"PunctuatorToken"===e.type||"KeywordToken"===e.type}},856:(e,t,n)=>{"use strict";n.d(t,{printExpression:()=>o});var r=n(3031);function o(e,t){const n=(e,o=Number.MAX_SAFE_INTEGER)=>{if("NumericLiteral"===e.type)return e.value.toString();if("StringLiteral"===e.type)return`'${e.value}'`;if("Identifier"===e.type)return e.name;if("ThisExpression"===e.type)return"this";if("NullLiteral"===e.type)return"null";if("BooleanLiteral"===e.type)return e.value?"true":"false";if("SpreadElement"===e.type||"RestElement"===e.type)return"..."+n(e.argument);if("AssignmentPattern"===e.type)return n(e.left)+" = "+n(e.right);if("ArrayExpression"===e.type)return"["+e.elements.map((e=>n(e))).join(", ")+"]";if("ArrowFunctionExpression"===e.type){const t=e.params.map((e=>n(e))).join(", "),r=n(e.body);return 1===e.params.length&&"Identifier"===e.params[0].type?`${t} => ${r}`:`(${t}) => ${r}`}if("UnaryExpression"===e.type){const t=n(e.argument,-1);return r.postfixUnaryOperators.includes(e.operator)?t+e.operator:"await"===e.operator?e.operator+" "+t:e.operator+t}if("BinaryExpression"===e.type||"LogicalExpression"===e.type){const i=r.priorizedBinaryOperators.findIndex((t=>t.includes(e.operator))),a="+"===e.operator||"*"===e.operator?i:i-.1,s=n(e.left,i)+" "+e.operator+" "+n(e.right,a);return i>o||i===o&&(null==t?void 0:t.keepBinaryExpressionOrder)?`(${s})`:s}if("MemberExpression"===e.type){const t=n(e.object),r=n(e.property);return"Identifier"===e.property.type?e.optional?t+"?."+r:t+"."+r:e.optional?t+"?.["+r+"]":t+"["+r+"]"}return"CallExpression"===e.type?e.optional?n(e.callee)+"?.("+e.arguments.map((e=>n(e))).join(", ")+")":n(e.callee)+"("+e.arguments.map((e=>n(e))).join(", ")+")":"ConditionalExpression"===e.type?n(e.test)+" ? "+n(e.consequent)+" : "+n(e.alternate):"Property"===e.type?e.shorthand?n(e.key):n(e.key)+": "+n(e.value):"ObjectExpression"===e.type?0===e.properties.length?"{}":"{ "+e.properties.map((e=>n(e))).join(", ")+" }":e.params.map((e=>n(e))).join(", ")};return n(e)}},5138:(e,t,n)=>{"use strict";n.d(t,{tokenizeExpression:()=>o});var r=n(3031);function o(e){return new i(e).toTokens()}class i{constructor(e,t){this.source=e,this.index=0,this.previousToken={type:"EOFToken",range:[0,0]},this.locale=(0,r.getLocale)(t)}toTokens(){const e=[];let t=this.nextToken();for(;"EOFToken"!==t.type;)e.push(t),t=this.nextToken();return e}nextToken(){if(this.index>=this.source.length)this.previousToken={type:"EOFToken",range:[this.source.length,this.source.length]};else{const e=this.source[this.index];" "===e?(this.index++,this.previousToken=this.nextToken()):'"'===e||"'"===e?this.previousToken=this.nextStringToken(e):"."===e?"."===this.source[this.index+1]&&"."===this.source[this.index+2]?this.previousToken=this.nextPunctuator(e):"EOFToken"===this.previousToken.type||"PunctuatorToken"===this.previousToken.type&&a.includes(this.previousToken.value)?this.previousToken=this.nextNumericToken(!0):this.previousToken=this.nextPunctuator(e):e>="0"&&e<="9"?this.previousToken=this.nextNumericToken(!1):s.includes(e)?this.previousToken=this.nextPunctuator(e):this.previousToken=this.nextIdentifierToken()}return this.previousToken}nextPunctuator(e){const t=this.index;return">"===e||"<"===e||"="===e||"!"===e?"="===this.source[this.index+1]?"="!==e&&"!"!==e||"="!==this.source[this.index+2]?(e+="=",this.index++):(e+="==",this.index+=2):">"===e&&">"===this.source[this.index+1]?">"===this.source[this.index+2]?(e+=">>",this.index+=2):(e+=">",this.index++):"<"===e&&"<"===this.source[this.index+1]?(e+="<",this.index++):"="===e&&">"===this.source[this.index+1]&&(e+=">",this.index++):"&"!==e&&"|"!==e||this.source[this.index+1]!==e?"*"===e&&"*"===this.source[this.index+1]?(e+="*",this.index++):"?"!==e||"."!==this.source[this.index+1]&&"?"!==this.source[this.index+1]?"."===e&&"."===this.source[this.index+1]&&"."===this.source[this.index+1]?(e+="..",this.index+=2):"|"===e&&">"===this.source[this.index+1]&&(e+=">",this.index++):(e+=this.source[this.index+1],this.index++):(e+=e,this.index++),this.index++,{type:"PunctuatorToken",value:e,range:[t,this.index]}}nextIdentifierToken(){const e=this.findEndOfIdentifier();if(void 0===e){const e=[this.index,this.source.length],t=this.getExplicitIdentifierToken(this.source.substring(this.index),e);return this.index=this.source.length,t}const t=[this.index,e],n=this.getExplicitIdentifierToken(this.source.substring(this.index,e),t);return this.index=e,n}getExplicitIdentifierToken(e,t){return"true"===e||"false"===e?{type:"BooleanLiteral",value:"true"===e,range:t}:"this"===e?{type:"KeywordToken",name:e,range:t}:"null"===e?{type:"NullLiteral",range:t}:"and"===e?{type:"PunctuatorToken",value:"&&",range:t}:"or"===e?{type:"PunctuatorToken",value:"||",range:t}:"not"===e?{type:"PunctuatorToken",value:"!",range:t}:"await"===e?{type:"PunctuatorToken",value:e,range:t}:{type:"Identifier",name:e,range:t}}findEndOfIdentifier(){for(let e=this.index;ee>="0"&&e<="9",i=this.index;for(let a=this.index+1;ae>="0"&&e<="9"||e>="a"&&e<="f":"b"===s||"B"===s?e=>e>="0"&&e<="1":e=>e>="0"&&e<="7"}}const a=void 0===n?this.getNumber(this.index):n*10**this.getNumber(i);return this.index=this.source.length,{type:"NumericLiteral",value:a,range:[t,this.index]}}getNumber(e,t){return+Array.from(this.source.substring(e,t)).filter((e=>"_"!==e)).join("")}nextStringToken(e){const t=this.index;this.index++;const n=this.findEndOfString(e);if(void 0===n)throw new r.ExpressionError((0,r.replaceLocaleParameters)(this.locale.expect,e,t),[t,this.source.length]);const o=this.source.substring(this.index,n);return this.index=n+1,{type:"StringLiteral",value:o,range:[t,this.index]}}findEndOfString(e){for(let t=this.index;t","<","=","!","&","^","|"],s=["(",")","[","]","{","}",...a,"?",":",",","~"]},7469:(e,t,n)=>{"use strict";var r,o;n.d(t,{parse:()=>Mr}),String.prototype.codePointAt||(o=function(e){if(null==this)throw TypeError();var t=String(this),n=t.length,r=e?Number(e):0;if(r!=r&&(r=0),!(r<0||r>=n)){var o,i=t.charCodeAt(r);return i>=55296&&i<=56319&&n>r+1&&(o=t.charCodeAt(r+1))>=56320&&o<=57343?1024*(i-55296)+o-56320+65536:i}},(r=function(){try{var e={},t=Object.defineProperty,n=t(e,e,e)&&t}catch(e){}return n}())?r(String.prototype,"codePointAt",{value:o,configurable:!0,writable:!0}):String.prototype.codePointAt=o);function i(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function a(e,t){this.source=e,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new i,this.dtree=new i}var s=new i,l=new i,c=new Uint8Array(30),u=new Uint16Array(30),d=new Uint8Array(30),p=new Uint16Array(30),f=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),h=new i,g=new Uint8Array(320);function m(e,t,n,r){var o,i;for(o=0;o>>=1,t}function b(e,t,n){if(!t)return n;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>16-t;return e.tag>>>=t,e.bitcount-=t,r+n}function C(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>=1,++o,n+=t.table[o],r-=t.table[o]}while(r>=0);return e.tag=i,e.bitcount-=o,t.trans[n+r]}function E(e,t,n){var r,o,i,a,s,l;for(r=b(e,5,257),o=b(e,5,1),i=b(e,4,4),a=0;a<19;++a)g[a]=0;for(a=0;a8;)e.sourceIndex--,e.bitcount-=8;if((t=256*(t=e.source[e.sourceIndex+1])+e.source[e.sourceIndex])!==(65535&~(256*e.source[e.sourceIndex+3]+e.source[e.sourceIndex+2])))return-3;for(e.sourceIndex+=4,n=t;n;--n)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,0}!function(e,t){var n;for(n=0;n<7;++n)e.table[n]=0;for(e.table[7]=24,e.table[8]=152,e.table[9]=112,n=0;n<24;++n)e.trans[n]=256+n;for(n=0;n<144;++n)e.trans[24+n]=n;for(n=0;n<8;++n)e.trans[168+n]=280+n;for(n=0;n<112;++n)e.trans[176+n]=144+n;for(n=0;n<5;++n)t.table[n]=0;for(t.table[5]=32,n=0;n<32;++n)t.trans[n]=n}(s,l),m(c,u,4,3),m(d,p,2,1),c[28]=0,u[28]=258;var w=function(e,t){var n,r,o=new a(e,t);do{switch(n=x(o),b(o,2,0)){case 0:r=k(o);break;case 1:r=P(o,s,l);break;case 2:E(o,o.ltree,o.dtree),r=P(o,o.ltree,o.dtree);break;default:r=-3}if(0!==r)throw new Error("Data error")}while(!n);return o.destLenthis.x2&&(this.x2=e)),"number"==typeof t&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=t,this.y2=t),tthis.y2&&(this.y2=t))},S.prototype.addX=function(e){this.addPoint(e,null)},S.prototype.addY=function(e){this.addPoint(null,e)},S.prototype.addBezier=function(e,t,n,r,o,i,a,s){var l=[e,t],c=[n,r],u=[o,i],d=[a,s];this.addPoint(e,t),this.addPoint(a,s);for(var p=0;p<=1;p++){var f=6*l[p]-12*c[p]+6*u[p],h=-3*l[p]+9*c[p]-9*u[p]+3*d[p],g=3*c[p]-3*l[p];if(0!==h){var m=Math.pow(f,2)-4*g*h;if(!(m<0)){var y=(-f+Math.sqrt(m))/(2*h);0=0&&r>0&&(n+=" "),n+=t(o)}return n}e=void 0!==e?e:2;for(var r="",o=0;o"},R.prototype.toDOMElement=function(e){var t=this.toPathData(e),n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",t),n};var M={fail:A,argument:T,assert:T},L=2147483648,I={},O={},B={};function F(e){return function(){return e}}O.BYTE=function(e){return M.argument(e>=0&&e<=255,"Byte value should be between 0 and 255."),[e]},B.BYTE=F(1),O.CHAR=function(e){return[e.charCodeAt(0)]},B.CHAR=F(1),O.CHARARRAY=function(e){void 0===e&&(e="",console.warn("Undefined CHARARRAY encountered and treated as an empty string. This is probably caused by a missing glyph name."));for(var t=[],n=0;n>8&255,255&e]},B.USHORT=F(2),O.SHORT=function(e){return e>=32768&&(e=-(65536-e)),[e>>8&255,255&e]},B.SHORT=F(2),O.UINT24=function(e){return[e>>16&255,e>>8&255,255&e]},B.UINT24=F(3),O.ULONG=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]},B.ULONG=F(4),O.LONG=function(e){return e>=L&&(e=-(2*L-e)),[e>>24&255,e>>16&255,e>>8&255,255&e]},B.LONG=F(4),O.FIXED=O.ULONG,B.FIXED=B.ULONG,O.FWORD=O.SHORT,B.FWORD=B.SHORT,O.UFWORD=O.USHORT,B.UFWORD=B.USHORT,O.LONGDATETIME=function(e){return[0,0,0,0,e>>24&255,e>>16&255,e>>8&255,255&e]},B.LONGDATETIME=F(8),O.TAG=function(e){return M.argument(4===e.length,"Tag should be exactly 4 ASCII characters."),[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]},B.TAG=F(4),O.Card8=O.BYTE,B.Card8=B.BYTE,O.Card16=O.USHORT,B.Card16=B.USHORT,O.OffSize=O.BYTE,B.OffSize=B.BYTE,O.SID=O.USHORT,B.SID=B.USHORT,O.NUMBER=function(e){return e>=-107&&e<=107?[e+139]:e>=108&&e<=1131?[247+((e-=108)>>8),255&e]:e>=-1131&&e<=-108?[251+((e=-e-108)>>8),255&e]:e>=-32768&&e<=32767?O.NUMBER16(e):O.NUMBER32(e)},B.NUMBER=function(e){return O.NUMBER(e).length},O.NUMBER16=function(e){return[28,e>>8&255,255&e]},B.NUMBER16=F(3),O.NUMBER32=function(e){return[29,e>>24&255,e>>16&255,e>>8&255,255&e]},B.NUMBER32=F(5),O.REAL=function(e){var t=e.toString(),n=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(t);if(n){var r=parseFloat("1e"+((n[2]?+n[2]:0)+n[1].length));t=(Math.round(e*r)/r).toString()}for(var o="",i=0,a=t.length;i>8&255,t[t.length]=255&r}return t},B.UTF16=function(e){return 2*e.length};var D={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈Ć«Č… ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüÝ°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};I.MACSTRING=function(e,t,n,r){var o=D[r];if(void 0!==o){for(var i="",a=0;a=-128&&e<=127}function G(e,t,n){for(var r=0,o=e.length;t>8&255,l+256&255)}return i}O.MACSTRING=function(e,t){var n=function(e){if(!z)for(var t in z={},D)z[t]=new String(t);var n=z[e];if(void 0!==n){if(U){var r=U.get(n);if(void 0!==r)return r}var o=D[e];if(void 0!==o){for(var i={},a=0;a=128&&void 0===(i=n[i]))return;r[o]=i}return r}},B.MACSTRING=function(e,t){var n=O.MACSTRING(e,t);return void 0!==n?n.length:0},O.VARDELTAS=function(e){for(var t=0,n=[];t=-128&&r<=127?j(e,t,n):V(e,t,n)}return n},O.INDEX=function(e){for(var t=1,n=[t],r=[],o=0;o>8,t[d+1]=255&p,t=t.concat(r[u])}return t},B.TABLE=function(e){for(var t=0,n=e.fields.length,r=0;r0)return new ie(this.data,this.offset+t).parseStruct(e)},ie.prototype.parsePointer32=function(e){var t=this.parseOffset32();if(t>0)return new ie(this.data,this.offset+t).parseStruct(e)},ie.prototype.parseListOfLists=function(e){for(var t=this.parseOffset16List(),n=t.length,r=this.relativeOffset,o=new Array(n),i=0;i=0;o-=1){var i=se.getUShort(e,t+4+8*o),a=se.getUShort(e,t+4+8*o+2);if(3===i&&(0===a||1===a||10===a)||0===i&&(0===a||1===a||2===a||3===a||4===a)){r=se.getULong(e,t+4+8*o+4);break}}if(-1===r)throw new Error("No valid cmap sub-tables found.");var s=new se.Parser(e,t+r);if(n.format=s.parseUShort(),12===n.format)!function(e,t){var n;t.parseUShort(),e.length=t.parseULong(),e.language=t.parseULong(),e.groupCount=n=t.parseULong(),e.glyphIndexMap={};for(var r=0;r>1,t.skip("uShort",3),e.glyphIndexMap={};for(var a=new se.Parser(n,r+o+14),s=new se.Parser(n,r+o+16+2*i),l=new se.Parser(n,r+o+16+4*i),c=new se.Parser(n,r+o+16+6*i),u=r+o+16+8*i,d=0;d0;t-=1)if(e.get(t).unicode>65535){console.log("Adding CMAP format 12 (needed!)"),n=!1;break}var r=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:n?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:n?12:20}];n||(r=r.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),r=r.concat([{name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);var o=new J.Table("cmap",r);for(o.segments=[],t=0;t>4,i=15&r;if(15===o)break;if(t+=n[o],15===i)break;t+=n[i]}return parseFloat(t)}(e);if(t>=32&&t<=246)return t-139;if(t>=247&&t<=250)return 256*(t-247)+e.parseByte()+108;if(t>=251&&t<=254)return 256*-(t-251)-e.parseByte()-108;throw new Error("Invalid b0 "+t)}function Se(e,t,n){t=void 0!==t?t:0;var r=new se.Parser(e,t),o=[],i=[];for(n=void 0!==n?n:e.length;r.relativeOffset>1,p.length=0,h=!0}return function n(c){for(var v,x,P,k,w,_,S,R,A,T,M,L,I=0;I1&&!h&&(b=p.shift()+u,h=!0),y+=p.pop(),C(m,y);break;case 5:for(;p.length>0;)m+=p.shift(),y+=p.shift(),d.lineTo(m,y);break;case 6:for(;p.length>0&&(m+=p.shift(),d.lineTo(m,y),0!==p.length);)y+=p.shift(),d.lineTo(m,y);break;case 7:for(;p.length>0&&(y+=p.shift(),d.lineTo(m,y),0!==p.length);)m+=p.shift(),d.lineTo(m,y);break;case 8:for(;p.length>0;)r=m+p.shift(),o=y+p.shift(),i=r+p.shift(),a=o+p.shift(),m=i+p.shift(),y=a+p.shift(),d.curveTo(r,o,i,a,m,y);break;case 10:w=p.pop()+l,(_=s[w])&&n(_);break;case 11:return;case 12:switch(O=c[I],I+=1,O){case 35:r=m+p.shift(),o=y+p.shift(),i=r+p.shift(),a=o+p.shift(),S=i+p.shift(),R=a+p.shift(),A=S+p.shift(),T=R+p.shift(),M=A+p.shift(),L=T+p.shift(),m=M+p.shift(),y=L+p.shift(),p.shift(),d.curveTo(r,o,i,a,S,R),d.curveTo(A,T,M,L,m,y);break;case 34:r=m+p.shift(),o=y,i=r+p.shift(),a=o+p.shift(),S=i+p.shift(),R=a,A=S+p.shift(),T=a,M=A+p.shift(),L=y,m=M+p.shift(),d.curveTo(r,o,i,a,S,R),d.curveTo(A,T,M,L,m,y);break;case 36:r=m+p.shift(),o=y+p.shift(),i=r+p.shift(),a=o+p.shift(),S=i+p.shift(),R=a,A=S+p.shift(),T=a,M=A+p.shift(),L=T+p.shift(),m=M+p.shift(),d.curveTo(r,o,i,a,S,R),d.curveTo(A,T,M,L,m,y);break;case 37:r=m+p.shift(),o=y+p.shift(),i=r+p.shift(),a=o+p.shift(),S=i+p.shift(),R=a+p.shift(),A=S+p.shift(),T=R+p.shift(),M=A+p.shift(),L=T+p.shift(),Math.abs(M-m)>Math.abs(L-y)?m=M+p.shift():y=L+p.shift(),d.curveTo(r,o,i,a,S,R),d.curveTo(A,T,M,L,m,y);break;default:console.log("Glyph "+t.index+": unknown operator 1200"+O),p.length=0}break;case 14:p.length>0&&!h&&(b=p.shift()+u,h=!0),g&&(d.closePath(),g=!1);break;case 19:case 20:E(),I+=f+7>>3;break;case 21:p.length>2&&!h&&(b=p.shift()+u,h=!0),y+=p.pop(),C(m+=p.pop(),y);break;case 22:p.length>1&&!h&&(b=p.shift()+u,h=!0),C(m+=p.pop(),y);break;case 24:for(;p.length>2;)r=m+p.shift(),o=y+p.shift(),i=r+p.shift(),a=o+p.shift(),m=i+p.shift(),y=a+p.shift(),d.curveTo(r,o,i,a,m,y);m+=p.shift(),y+=p.shift(),d.lineTo(m,y);break;case 25:for(;p.length>6;)m+=p.shift(),y+=p.shift(),d.lineTo(m,y);r=m+p.shift(),o=y+p.shift(),i=r+p.shift(),a=o+p.shift(),m=i+p.shift(),y=a+p.shift(),d.curveTo(r,o,i,a,m,y);break;case 26:for(p.length%2&&(m+=p.shift());p.length>0;)r=m,o=y+p.shift(),i=r+p.shift(),a=o+p.shift(),m=i,y=a+p.shift(),d.curveTo(r,o,i,a,m,y);break;case 27:for(p.length%2&&(y+=p.shift());p.length>0;)r=m+p.shift(),o=y,i=r+p.shift(),a=o+p.shift(),m=i+p.shift(),y=a,d.curveTo(r,o,i,a,m,y);break;case 28:v=c[I],x=c[I+1],p.push((v<<24|x<<16)>>16),I+=2;break;case 29:w=p.pop()+e.gsubrsBias,(_=e.gsubrs[w])&&n(_);break;case 30:for(;p.length>0&&(r=m,o=y+p.shift(),i=r+p.shift(),a=o+p.shift(),m=i+p.shift(),y=a+(1===p.length?p.shift():0),d.curveTo(r,o,i,a,m,y),0!==p.length);)r=m+p.shift(),o=y,i=r+p.shift(),a=o+p.shift(),y=a+p.shift(),m=i+(1===p.length?p.shift():0),d.curveTo(r,o,i,a,m,y);break;case 31:for(;p.length>0&&(r=m+p.shift(),o=y,i=r+p.shift(),a=o+p.shift(),y=a+p.shift(),m=i+(1===p.length?p.shift():0),d.curveTo(r,o,i,a,m,y),0!==p.length);)r=m,o=y+p.shift(),i=r+p.shift(),a=o+p.shift(),m=i+p.shift(),y=a+(1===p.length?p.shift():0),d.curveTo(r,o,i,a,m,y);break;default:O<32?console.log("Glyph "+t.index+": unknown operator "+O):O<247?p.push(O-139):O<251?(v=c[I],I+=1,p.push(256*(O-247)+v+108)):O<255?(v=c[I],I+=1,p.push(256*-(O-251)-v-108)):(v=c[I],x=c[I+1],P=c[I+2],k=c[I+3],I+=4,p.push((v<<24|x<<16|P<<8|k)/65536))}}}(n),t.advanceWidth=b,d}function Fe(e,t){var n,r=ue.indexOf(e);return r>=0&&(n=r),(r=t.indexOf(e))>=0?n=r+ue.length:(n=ue.length+t.length,t.push(e)),n}function De(e,t,n){for(var r={},o=0;o=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+o+" (FD count "+r+")");i.push(o)}else{if(3!==s)throw new Error("CFF Table CID Font FDSelect table has unsupported format "+s);var c,u=a.parseCard16(),d=a.parseCard16();if(0!==d)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+d);for(var p=0;p=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+o+" (FD count "+r+")");if(c>n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+c);for(;d=1&&(n.ulCodePageRange1=r.parseULong(),n.ulCodePageRange2=r.parseULong()),n.version>=2&&(n.sxHeight=r.parseShort(),n.sCapHeight=r.parseShort(),n.usDefaultChar=r.parseUShort(),n.usBreakChar=r.parseUShort(),n.usMaxContent=r.parseUShort()),n},make:function(e){return new J.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],e)},unicodeRanges:at,getUnicodeRange:function(e){for(var t=0;t=n.begin&&e=fe.length){var a=r.parseChar();n.names.push(r.parseString(a))}break;case 2.5:n.numberOfGlyphs=r.parseUShort(),n.offset=new Array(n.numberOfGlyphs);for(var s=0;st.value.tag?1:-1})),t.fields=t.fields.concat(r),t.fields=t.fields.concat(o),t}function vt(e,t,n){for(var r=0;r0)return e.glyphs.get(o).getMetrics()}return n}function xt(e){for(var t=0,n=0;nm||void 0===t)&&m>0&&(t=m),c 123 are reserved for internal usage");f|=1<0?He.make(L):void 0,B=lt.make(),F=Ge.make(e.glyphs,{version:e.getEnglishName("version"),fullName:R,familyName:_,weightName:S,postScriptName:A,unitsPerEm:e.unitsPerEm,fontBBox:[0,x.yMin,x.ascender,x.advanceWidthMax]}),D=e.metas&&Object.keys(e.metas).length>0?ft.make(e.metas):void 0,z=[b,C,E,P,I,w,B,F,k];O&&z.push(O),e.tables.gsub&&z.push(pt.make(e.tables.gsub)),D&&z.push(D);for(var U=yt(z),N=gt(U.encode()),G=U.fields,j=!1,V=0;V>>1,i=e[o].tag;if(i===t)return o;i>>1,i=e[o];if(i===t)return o;i>>1,a=(n=e[i]).start;if(a===t)return n;a0)return t>(n=e[r-1]).end?0:n}function kt(e,t){this.font=e,this.tableName=t}function wt(e){kt.call(this,e,"gpos")}function _t(e){kt.call(this,e,"gsub")}function St(e,t){var n=e.length;if(n!==t.length)return!1;for(var r=0;r0?(i=e.parseByte(),0==(t&o)&&(i=-i),i=n+i):i=(t&o)>0?n:n+e.parseShort(),i}function Mt(e,t,n){var r,o,i=new se.Parser(t,n);if(e.numberOfContours=i.parseShort(),e._xMin=i.parseShort(),e._yMin=i.parseShort(),e._xMax=i.parseShort(),e._yMax=i.parseShort(),e.numberOfContours>0){for(var a=e.endPointIndices=[],s=0;s0)for(var d=i.parseByte(),p=0;p0){var f,h=[];if(c>0){for(var g=0;g=0,h.push(f);for(var m=0,y=0;y0?(2&r)>0?(C.dx=i.parseShort(),C.dy=i.parseShort()):C.matchedPoints=[i.parseUShort(),i.parseUShort()]:(2&r)>0?(C.dx=i.parseChar(),C.dy=i.parseChar()):C.matchedPoints=[i.parseByte(),i.parseByte()],(8&r)>0?C.xScale=C.yScale=i.parseF2Dot14():(64&r)>0?(C.xScale=i.parseF2Dot14(),C.yScale=i.parseF2Dot14()):(128&r)>0&&(C.xScale=i.parseF2Dot14(),C.scale01=i.parseF2Dot14(),C.scale10=i.parseF2Dot14(),C.yScale=i.parseF2Dot14()),e.components.push(C),b=!!(32&r)}if(256&r){e.instructionLength=i.parseUShort(),e.instructions=[];for(var E=0;Et.points.length-1||r.matchedPoints[1]>o.points.length-1)throw Error("Matched points out of range in "+t.name);var a=t.points[r.matchedPoints[0]],s=o.points[r.matchedPoints[1]],l={xScale:r.xScale,scale01:r.scale01,scale10:r.scale10,yScale:r.yScale,dx:0,dy:0};s=Lt([s],l)[0],l.dx=a.x-s.x,l.dy=a.y-s.y,i=Lt(o.points,l)}t.points=t.points.concat(i)}}return It(t.points)}kt.prototype={searchTag:Ct,binSearch:Et,getTable:function(e){var t=this.font.tables[this.tableName];return!t&&e&&(t=this.font.tables[this.tableName]=this.createDefaultTable()),t},getScriptNames:function(){var e=this.getTable();return e?e.scripts.map((function(e){return e.tag})):[]},getDefaultScriptName:function(){var e=this.getTable();if(e){for(var t=!1,n=0;n=0)return r[o].script;if(t){var i={tag:e,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return r.splice(-1-o,0,i),i.script}}},getLangSysTable:function(e,t,n){var r=this.getScriptTable(e,n);if(r){if(!t||"dflt"===t||"DFLT"===t)return r.defaultLangSys;var o=Ct(r.langSysRecords,t);if(o>=0)return r.langSysRecords[o].langSys;if(n){var i={tag:t,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return r.langSysRecords.splice(-1-o,0,i),i.langSys}}},getFeatureTable:function(e,t,n,r){var o=this.getLangSysTable(e,t,r);if(o){for(var i,a=o.featureIndexes,s=this.font.tables[this.tableName].features,l=0;l=s[c-1].tag,"Features must be added in alphabetical order."),i={tag:n,feature:{params:0,lookupListIndexes:[]}},s.push(i),a.push(c),i.feature}}},getLookupTables:function(e,t,n,r,o){var i=this.getFeatureTable(e,t,n,o),a=[];if(i){for(var s,l=i.lookupListIndexes,c=this.font.tables[this.tableName].lookups,u=0;u=0?n:-1;case 2:var r=Pt(e.ranges,t);return r?r.index+t-r.start:-1}},expandCoverage:function(e){if(1===e.format)return e.glyphs;for(var t=[],n=e.ranges,r=0;r1,'Multiple: "by" must be an array of two or more ids');var o=Rt(this.getLookupTables(n,r,e,2,!0)[0],1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});M.assert(1===o.coverage.format,"Multiple: unable to modify coverage table format "+o.coverage.format);var i=t.sub,a=this.binSearch(o.coverage.glyphs,i);a<0&&(a=-1-a,o.coverage.glyphs.splice(a,0,i),o.sequences.splice(a,0,0)),o.sequences[a]=t.by},_t.prototype.addAlternate=function(e,t,n,r){var o=Rt(this.getLookupTables(n,r,e,3,!0)[0],1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});M.assert(1===o.coverage.format,"Alternate: unable to modify coverage table format "+o.coverage.format);var i=t.sub,a=this.binSearch(o.coverage.glyphs,i);a<0&&(a=-1-a,o.coverage.glyphs.splice(a,0,i),o.alternateSets.splice(a,0,0)),o.alternateSets[a]=t.by},_t.prototype.addLigature=function(e,t,n,r){var o=this.getLookupTables(n,r,e,4,!0)[0],i=o.subtables[0];i||(i={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},o.subtables[0]=i),M.assert(1===i.coverage.format,"Ligature: unable to modify coverage table format "+i.coverage.format);var a=t.sub[0],s=t.sub.slice(1),l={ligGlyph:t.by,components:s},c=this.binSearch(i.coverage.glyphs,a);if(c>=0){for(var u=i.ligatureSets[c],d=0;d=176&&n<=183)o+=n-176+1;else if(n>=184&&n<=191)o+=2*(n-184+1);else if(t&&1===i&&27===n)break}while(i>0);e.ip=o}function on(e,t){exports.DEBUG&&console.log(t.step,"SVTCA["+e.axis+"]"),t.fv=t.pv=t.dpv=e}function an(e,t){exports.DEBUG&&console.log(t.step,"SPVTCA["+e.axis+"]"),t.pv=t.dpv=e}function sn(e,t){exports.DEBUG&&console.log(t.step,"SFVTCA["+e.axis+"]"),t.fv=e}function ln(e,t){var n,r,o=t.stack,i=o.pop(),a=o.pop(),s=t.z2[i],l=t.z1[a];exports.DEBUG&&console.log("SPVTL["+e+"]",i,a),e?(n=s.y-l.y,r=l.x-s.x):(n=l.x-s.x,r=l.y-s.y),t.pv=t.dpv=Zt(n,r)}function cn(e,t){var n,r,o=t.stack,i=o.pop(),a=o.pop(),s=t.z2[i],l=t.z1[a];exports.DEBUG&&console.log("SFVTL["+e+"]",i,a),e?(n=s.y-l.y,r=l.x-s.x):(n=l.x-s.x,r=l.y-s.y),t.fv=Zt(n,r)}function un(e){exports.DEBUG&&console.log(e.step,"POP[]"),e.stack.pop()}function dn(e,t){var n=t.stack.pop(),r=t.z0[n],o=t.fv,i=t.pv;exports.DEBUG&&console.log(t.step,"MDAP["+e+"]",n);var a=i.distance(r,Jt);e&&(a=t.round(a)),o.setRelative(r,Jt,a,i),o.touch(r),t.rp0=t.rp1=n}function pn(e,t){var n,r,o,i=t.z2,a=i.length-2;exports.DEBUG&&console.log(t.step,"IUP["+e.axis+"]");for(var s=0;s1?"loop "+(t.loop-s)+": ":"")+"SHP["+(e?"rp1":"rp2")+"]",c)}t.loop=1}function hn(e,t){var n=t.stack,r=e?t.rp1:t.rp2,o=(e?t.z0:t.z1)[r],i=t.fv,a=t.pv,s=n.pop(),l=t.z2[t.contours[s]],c=l;exports.DEBUG&&console.log(t.step,"SHC["+e+"]",s);var u=a.distance(o,o,!1,!0);do{c!==o&&i.setRelative(c,c,u,a),c=c.nextPointOnContour}while(c!==l)}function gn(e,t){var n,r,o=t.stack,i=e?t.rp1:t.rp2,a=(e?t.z0:t.z1)[i],s=t.fv,l=t.pv,c=o.pop();switch(exports.DEBUG&&console.log(t.step,"SHZ["+e+"]",c),c){case 0:n=t.tZone;break;case 1:n=t.gZone;break;default:throw new Error("Invalid zone")}for(var u=l.distance(a,a,!1,!0),d=n.length-2,p=0;p",s),t.stack.push(Math.round(64*s))}function bn(e,t){var n=t.stack,r=n.pop(),o=t.fv,i=t.pv,a=t.ppem,s=t.deltaBase+16*(e-1),l=t.deltaShift,c=t.z0;exports.DEBUG&&console.log(t.step,"DELTAP["+e+"]",r,n);for(var u=0;u>4)===a){var f=(15&p)-8;f>=0&&f++,exports.DEBUG&&console.log(t.step,"DELTAPFIX",d,"by",f*l);var h=c[d];o.setRelative(h,h,f*l,i)}}}function Cn(e,t){var n=t.stack,r=n.pop();exports.DEBUG&&console.log(t.step,"ROUND[]"),n.push(64*t.round(r/64))}function En(e,t){var n=t.stack,r=n.pop(),o=t.ppem,i=t.deltaBase+16*(e-1),a=t.deltaShift;exports.DEBUG&&console.log(t.step,"DELTAC["+e+"]",r,n);for(var s=0;s>4)===o){var u=(15&c)-8;u>=0&&u++;var d=u*a;exports.DEBUG&&console.log(t.step,"DELTACFIX",l,"by",d),t.cvt[l]+=d}}}function Pn(e,t){var n,r,o=t.stack,i=o.pop(),a=o.pop(),s=t.z2[i],l=t.z1[a];exports.DEBUG&&console.log(t.step,"SDPVTL["+e+"]",i,a),e?(n=s.y-l.y,r=l.x-s.x):(n=l.x-s.x,r=l.y-s.y),t.dpv=Zt(n,r)}function kn(e,t){var n=t.stack,r=t.prog,o=t.ip;exports.DEBUG&&console.log(t.step,"PUSHB["+e+"]");for(var i=0;i=0?1:-1,s=Math.abs(s),e&&(c=i.cvt[d],r&&Math.abs(s-c)":"_")+(r?"R":"_")+(0===o?"Gr":1===o?"Bl":2===o?"Wh":"")+"]",e?d+"("+i.cvt[d]+","+c+")":"",p,"(d =",a,"->",l*s,")"),i.rp1=i.rp0,i.rp2=p,t&&(i.rp0=p)}function Sn(e){this.char=e,this.state={},this.activeState=null}function Rn(e,t,n){this.contextName=n,this.startIndex=e,this.endOffset=t}function An(e,t,n){this.contextName=e,this.openRange=null,this.ranges=[],this.checkStart=t,this.checkEnd=n}function Tn(e,t){this.context=e,this.index=t,this.length=e.length,this.current=e[t],this.backtrack=e.slice(0,t),this.lookahead=e.slice(t+1)}function Mn(e){this.eventId=e,this.subscribers=[]}function Ln(e){var t=this,n=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];n.forEach((function(e){Object.defineProperty(t.events,e,{value:new Mn(e)})})),e&&n.forEach((function(n){var r=e[n];"function"==typeof r&&t.events[n].subscribe(r)})),["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"].forEach((function(e){t.events[e].subscribe(t.updateContextsRanges)}))}function In(e){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Ln.call(this,e)}function On(e){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(e)}function Bn(e){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(e)}function Fn(e){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(e)}function Dn(e){return/[A-z]/.test(e)}function zn(e){this.font=e,this.features={}}function Un(e){this.id=e.id,this.tag=e.tag,this.substitution=e.substitution}function Nn(e,t){if(!e)return-1;switch(t.format){case 1:return t.glyphs.indexOf(e);case 2:for(var n=t.ranges,r=0;r=o.start&&e<=o.end){var i=e-o.start;return o.index+i}}break;default:return-1}return-1}function Gn(e,t){return-1===Nn(e,t.coverage)?null:e+t.deltaGlyphId}function jn(e,t){var n=Nn(e,t.coverage);return-1===n?null:t.substitute[n]}function Vn(e,t){for(var n=[],r=0;r2)){var n=this.font,r=this._prepState;if(!r||r.ppem!==t){var o=this._fpgmState;if(!o){tn.prototype=en,(o=this._fpgmState=new tn("fpgm",n.tables.fpgm)).funcs=[],o.font=n,exports.DEBUG&&(console.log("---EXEC FPGM---"),o.step=-1);try{Ft(o)}catch(e){return console.log("Hinting error in FPGM:"+e),void(this._errorState=3)}}tn.prototype=o,(r=this._prepState=new tn("prep",n.tables.prep)).ppem=t;var i=n.tables.cvt;if(i)for(var a=r.cvt=new Array(i.length),s=t/n.unitsPerEm,l=0;l1))try{return Dt(e,r)}catch(e){return this._errorState<1&&(console.log("Hinting error:"+e),console.log("Note: further hinting errors are silenced")),void(this._errorState=1)}}},Dt=function(e,t){var n,r,o,i=t.ppem/t.font.unitsPerEm,a=i,s=e.components;if(tn.prototype=t,s){var l=t.font;r=[],n=[];for(var c=0;c1?"loop "+(e.loop-n)+": ":"")+"SHPIX[]",a,o),r.setRelative(s,s,o),r.touch(s)}e.loop=1},function(e){for(var t=e.stack,n=e.rp1,r=e.rp2,o=e.loop,i=e.z0[n],a=e.z1[r],s=e.fv,l=e.dpv,c=e.z2;o--;){var u=t.pop(),d=c[u];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-o)+": ":"")+"IP[]",u,n,"<->",r),s.interpolate(d,i,a,l),s.touch(d)}e.loop=1},mn.bind(void 0,0),mn.bind(void 0,1),function(e){for(var t=e.stack,n=e.rp0,r=e.z0[n],o=e.loop,i=e.fv,a=e.pv,s=e.z1;o--;){var l=t.pop(),c=s[l];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-o)+": ":"")+"ALIGNRP[]",l),i.setRelative(c,r,0,a),i.touch(c)}e.loop=1},function(e){exports.DEBUG&&console.log(e.step,"RTDG[]"),e.round=Vt},yn.bind(void 0,0),yn.bind(void 0,1),function(e){var t=e.prog,n=e.ip,r=e.stack,o=t[++n];exports.DEBUG&&console.log(e.step,"NPUSHB[]",o);for(var i=0;in?1:0)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"GTEQ[]",n,r),t.push(r>=n?1:0)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"EQ[]",n,r),t.push(n===r?1:0)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"NEQ[]",n,r),t.push(n!==r?1:0)},function(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ODD[]",n),t.push(Math.trunc(n)%2?1:0)},function(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"EVEN[]",n),t.push(Math.trunc(n)%2?0:1)},function(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"IF[]",t),t||(rn(e,!0),exports.DEBUG&&console.log(e.step,"EIF[]"))},function(e){exports.DEBUG&&console.log(e.step,"EIF[]")},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"AND[]",n,r),t.push(n&&r?1:0)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"OR[]",n,r),t.push(n||r?1:0)},function(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"NOT[]",n),t.push(n?0:1)},bn.bind(void 0,1),function(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDB[]",t),e.deltaBase=t},function(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDS[]",t),e.deltaShift=Math.pow(.5,t)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"ADD[]",n,r),t.push(r+n)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"SUB[]",n,r),t.push(r-n)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"DIV[]",n,r),t.push(64*r/n)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"MUL[]",n,r),t.push(r*n/64)},function(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ABS[]",n),t.push(Math.abs(n))},function(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"NEG[]",n),t.push(-n)},function(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"FLOOR[]",n),t.push(64*Math.floor(n/64))},function(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"CEILING[]",n),t.push(64*Math.ceil(n/64))},Cn.bind(void 0,0),Cn.bind(void 0,1),Cn.bind(void 0,2),Cn.bind(void 0,3),void 0,void 0,void 0,void 0,function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"WCVTF[]",n,r),e.cvt[r]=n*e.ppem/e.font.unitsPerEm},bn.bind(void 0,2),bn.bind(void 0,3),En.bind(void 0,1),En.bind(void 0,2),En.bind(void 0,3),function(e){var t,n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SROUND[]",n),e.round=$t,192&n){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(e.srPeriod=t,48&n){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*t;break;case 32:e.srPhase=.5*t;break;case 48:e.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}n&=15,e.srThreshold=0===n?0:(n/8-.5)*t},function(e){var t,n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"S45ROUND[]",n),e.round=$t,192&n){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(e.srPeriod=t,48&n){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*t;break;case 32:e.srPhase=.5*t;break;case 48:e.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}n&=15,e.srThreshold=0===n?0:(n/8-.5)*t},void 0,void 0,function(e){exports.DEBUG&&console.log(e.step,"ROFF[]"),e.round=Gt},void 0,function(e){exports.DEBUG&&console.log(e.step,"RUTG[]"),e.round=Ht},function(e){exports.DEBUG&&console.log(e.step,"RDTG[]"),e.round=qt},un,un,void 0,void 0,void 0,void 0,void 0,function(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANCTRL[]",t)},Pn.bind(void 0,0),Pn.bind(void 0,1),function(e){var t=e.stack,n=t.pop(),r=0;exports.DEBUG&&console.log(e.step,"GETINFO[]",n),1&n&&(r=35),32&n&&(r|=4096),t.push(r)},void 0,function(e){var t=e.stack,n=t.pop(),r=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"ROLL[]"),t.push(r),t.push(n),t.push(o)},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"MAX[]",n,r),t.push(Math.max(r,n))},function(e){var t=e.stack,n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"MIN[]",n,r),t.push(Math.min(r,n))},function(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANTYPE[]",t)},function(e){var t=e.stack.pop(),n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"INSTCTRL[]",t,n),t){case 1:return void(e.inhibitGridFit=!!n);case 2:return void(e.ignoreCvt=!!n);default:throw new Error("invalid INSTCTRL[] selector")}},void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,kn.bind(void 0,1),kn.bind(void 0,2),kn.bind(void 0,3),kn.bind(void 0,4),kn.bind(void 0,5),kn.bind(void 0,6),kn.bind(void 0,7),kn.bind(void 0,8),wn.bind(void 0,1),wn.bind(void 0,2),wn.bind(void 0,3),wn.bind(void 0,4),wn.bind(void 0,5),wn.bind(void 0,6),wn.bind(void 0,7),wn.bind(void 0,8),_n.bind(void 0,0,0,0,0,0),_n.bind(void 0,0,0,0,0,1),_n.bind(void 0,0,0,0,0,2),_n.bind(void 0,0,0,0,0,3),_n.bind(void 0,0,0,0,1,0),_n.bind(void 0,0,0,0,1,1),_n.bind(void 0,0,0,0,1,2),_n.bind(void 0,0,0,0,1,3),_n.bind(void 0,0,0,1,0,0),_n.bind(void 0,0,0,1,0,1),_n.bind(void 0,0,0,1,0,2),_n.bind(void 0,0,0,1,0,3),_n.bind(void 0,0,0,1,1,0),_n.bind(void 0,0,0,1,1,1),_n.bind(void 0,0,0,1,1,2),_n.bind(void 0,0,0,1,1,3),_n.bind(void 0,0,1,0,0,0),_n.bind(void 0,0,1,0,0,1),_n.bind(void 0,0,1,0,0,2),_n.bind(void 0,0,1,0,0,3),_n.bind(void 0,0,1,0,1,0),_n.bind(void 0,0,1,0,1,1),_n.bind(void 0,0,1,0,1,2),_n.bind(void 0,0,1,0,1,3),_n.bind(void 0,0,1,1,0,0),_n.bind(void 0,0,1,1,0,1),_n.bind(void 0,0,1,1,0,2),_n.bind(void 0,0,1,1,0,3),_n.bind(void 0,0,1,1,1,0),_n.bind(void 0,0,1,1,1,1),_n.bind(void 0,0,1,1,1,2),_n.bind(void 0,0,1,1,1,3),_n.bind(void 0,1,0,0,0,0),_n.bind(void 0,1,0,0,0,1),_n.bind(void 0,1,0,0,0,2),_n.bind(void 0,1,0,0,0,3),_n.bind(void 0,1,0,0,1,0),_n.bind(void 0,1,0,0,1,1),_n.bind(void 0,1,0,0,1,2),_n.bind(void 0,1,0,0,1,3),_n.bind(void 0,1,0,1,0,0),_n.bind(void 0,1,0,1,0,1),_n.bind(void 0,1,0,1,0,2),_n.bind(void 0,1,0,1,0,3),_n.bind(void 0,1,0,1,1,0),_n.bind(void 0,1,0,1,1,1),_n.bind(void 0,1,0,1,1,2),_n.bind(void 0,1,0,1,1,3),_n.bind(void 0,1,1,0,0,0),_n.bind(void 0,1,1,0,0,1),_n.bind(void 0,1,1,0,0,2),_n.bind(void 0,1,1,0,0,3),_n.bind(void 0,1,1,0,1,0),_n.bind(void 0,1,1,0,1,1),_n.bind(void 0,1,1,0,1,2),_n.bind(void 0,1,1,0,1,3),_n.bind(void 0,1,1,1,0,0),_n.bind(void 0,1,1,1,0,1),_n.bind(void 0,1,1,1,0,2),_n.bind(void 0,1,1,1,0,3),_n.bind(void 0,1,1,1,1,0),_n.bind(void 0,1,1,1,1,1),_n.bind(void 0,1,1,1,1,2),_n.bind(void 0,1,1,1,1,3)],Sn.prototype.setState=function(e,t){return this.state[e]=t,this.activeState={key:e,value:this.state[e]},this.activeState},Sn.prototype.getState=function(e){return this.state[e]||null},In.prototype.inboundIndex=function(e){return e>=0&&e0&&e<=this.lookahead.length:return this.lookahead[e-1];default:return null}},In.prototype.rangeToText=function(e){if(e instanceof Rn)return this.getRangeTokens(e).map((function(e){return e.char})).join("")},In.prototype.getText=function(){return this.tokens.map((function(e){return e.char})).join("")},In.prototype.getContext=function(e){return this.registeredContexts[e]||null},In.prototype.on=function(e,t){var n=this.events[e];return n?n.subscribe(t):null},In.prototype.dispatch=function(e,t){var n=this,r=this.events[e];r instanceof Mn&&r.subscribers.forEach((function(e){e.apply(n,t||[])}))},In.prototype.registerContextChecker=function(e,t,n){if(this.getContext(e))return{FAIL:"context name '"+e+"' is already registered."};if("function"!=typeof t)return{FAIL:"missing context start check."};if("function"!=typeof n)return{FAIL:"missing context end check."};var r=new An(e,t,n);return this.registeredContexts[e]=r,this.contextCheckers.push(r),r},In.prototype.getRangeTokens=function(e){var t=e.startIndex+e.endOffset;return[].concat(this.tokens.slice(e.startIndex,t))},In.prototype.getContextRanges=function(e){var t=this.getContext(e);return t?t.ranges:{FAIL:"context checker '"+e+"' is not registered."}},In.prototype.resetContextsRanges=function(){var e=this.registeredContexts;for(var t in e)e.hasOwnProperty(t)&&(e[t].ranges=[])},In.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var e=this.tokens.map((function(e){return e.char})),t=0;t=0;n--){var r=t[n],o=Bn(r),i=Fn(r);if(!o&&!i)return!0;if(o)return!1}return!1}(a)&&(c|=1),function(e){if(Bn(e.current))return!1;for(var t=0;t=1.2&&(o.markGlyphSets=n.parsePointer(Er)),o}},kr=new Array(10);kr[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();return 1===t?{posFormat:1,coverage:this.parsePointer(ie.coverage),value:this.parseValueRecord()}:2===t?{posFormat:2,coverage:this.parsePointer(ie.coverage),values:this.parseValueRecordList()}:void M.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},kr[2]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();M.assert(1===t||2===t,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var n=this.parsePointer(ie.coverage),r=this.parseUShort(),o=this.parseUShort();if(1===t)return{posFormat:t,coverage:n,valueFormat1:r,valueFormat2:o,pairSets:this.parseList(ie.pointer(ie.list((function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(r),value2:this.parseValueRecord(o)}}))))};if(2===t){var i=this.parsePointer(ie.classDef),a=this.parsePointer(ie.classDef),s=this.parseUShort(),l=this.parseUShort();return{posFormat:t,coverage:n,valueFormat1:r,valueFormat2:o,classDef1:i,classDef2:a,class1Count:s,class2Count:l,classRecords:this.parseList(s,ie.list(l,(function(){return{value1:this.parseValueRecord(r),value2:this.parseValueRecord(o)}})))}}},kr[3]=function(){return{error:"GPOS Lookup 3 not supported"}},kr[4]=function(){return{error:"GPOS Lookup 4 not supported"}},kr[5]=function(){return{error:"GPOS Lookup 5 not supported"}},kr[6]=function(){return{error:"GPOS Lookup 6 not supported"}},kr[7]=function(){return{error:"GPOS Lookup 7 not supported"}},kr[8]=function(){return{error:"GPOS Lookup 8 not supported"}},kr[9]=function(){return{error:"GPOS Lookup 9 not supported"}};var wr=new Array(10),_r={parse:function(e,t){var n=new ie(e,t=t||0),r=n.parseVersion(1);return M.argument(1===r||1.1===r,"Unsupported GPOS table version "+r),1===r?{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(kr)}:{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(kr),variations:n.parseFeatureVariationsList()}},make:function(e){return new J.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new J.ScriptList(e.scripts)},{name:"features",type:"TABLE",value:new J.FeatureList(e.features)},{name:"lookups",type:"TABLE",value:new J.LookupList(e.lookups,wr)}])}},Sr={parse:function(e,t){var n=new se.Parser(e,t),r=n.parseUShort();if(0===r)return function(e){var t={};e.skip("uShort");var n=e.parseUShort();M.argument(0===n,"Unsupported kern sub-table version."),e.skip("uShort",2);var r=e.parseUShort();e.skip("uShort",3);for(var o=0;o1&&console.warn("Only the first kern subtable is supported."),e.skip("uLong");var n=255&e.parseUShort();if(e.skip("uShort"),0===n){var r=e.parseUShort();e.skip("uShort",3);for(var o=0;o{"use strict";var r=n(3696);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n