@pie-element/graphing-solution-set 6.4.0-beta.7 → 7.0.0-next.20261002100925
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/author.js +2 -0
- package/configure.js +2 -0
- package/controller.js +1 -0
- package/dist/author/configure.d.ts +26 -0
- package/dist/author/configure.js +190 -0
- package/dist/author/correct-response.d.ts +33 -0
- package/dist/author/correct-response.js +206 -0
- package/dist/author/defaults.d.ts +238 -0
- package/dist/author/defaults.js +339 -0
- package/dist/author/graphing-config.d.ts +33 -0
- package/dist/author/graphing-config.js +237 -0
- package/dist/author/index.d.ts +63 -0
- package/dist/author/index.js +95 -0
- package/dist/author/utils.d.ts +46 -0
- package/dist/author/utils.js +474 -0
- package/dist/browser/alert-dialog-mARgEnYR.js +50672 -0
- package/dist/browser/alert-dialog-mARgEnYR.js.map +1 -0
- package/dist/browser/assets/Symbola-4c507403.woff2 +0 -0
- package/dist/browser/author/index.js +3833 -0
- package/dist/browser/author/index.js.map +1 -0
- package/dist/browser/browser-bbrzkX59.js +352 -0
- package/dist/browser/browser-bbrzkX59.js.map +1 -0
- package/dist/browser/controller/index.js +193 -0
- package/dist/browser/controller/index.js.map +1 -0
- package/dist/browser/delivery/index.js +781 -0
- package/dist/browser/delivery/index.js.map +1 -0
- package/dist/browser/editor-runtime/alert-dialog-1f82g6Ih.js +34263 -0
- package/dist/browser/editor-runtime/alert-dialog-1f82g6Ih.js.map +1 -0
- package/dist/browser/editor-runtime/assets/Symbola-4c507403.woff2 +0 -0
- package/dist/browser/editor-runtime/author/index.js +3833 -0
- package/dist/browser/editor-runtime/author/index.js.map +1 -0
- package/dist/browser/editor-runtime/browser-d5JHIrvC.js +352 -0
- package/dist/browser/editor-runtime/browser-d5JHIrvC.js.map +1 -0
- package/dist/browser/editor-runtime/controller/index.js +193 -0
- package/dist/browser/editor-runtime/controller/index.js.map +1 -0
- package/dist/browser/editor-runtime/delivery/index.js +781 -0
- package/dist/browser/editor-runtime/delivery/index.js.map +1 -0
- package/dist/controller/defaults.d.ts +64 -0
- package/dist/controller/defaults.js +54 -0
- package/dist/controller/index.d.ts +24 -0
- package/dist/controller/index.js +110 -0
- package/dist/controller/utils.d.ts +20 -0
- package/dist/controller/utils.js +39 -0
- package/dist/delivery/index.d.ts +22 -0
- package/dist/delivery/index.js +62 -0
- package/dist/delivery/main.d.ts +31 -0
- package/dist/delivery/main.js +198 -0
- package/dist/delivery/utils.d.ts +12 -0
- package/dist/delivery/utils.js +220 -0
- package/dist/graphing-solution-set.css +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.iife.d.ts +8 -0
- package/dist/index.iife.js +369 -0
- package/dist/index.js +2 -0
- package/dist/runtime-support.d.ts +12 -0
- package/dist/runtime-support.js +12 -0
- package/package.json +94 -23
- package/CHANGELOG.json +0 -1
- package/CHANGELOG.md +0 -899
- package/LICENSE.md +0 -5
- package/README.md +0 -20
- package/configure/CHANGELOG.json +0 -1
- package/configure/CHANGELOG.md +0 -859
- package/configure/lib/configure.js +0 -312
- package/configure/lib/configure.js.map +0 -1
- package/configure/lib/correct-response.js +0 -435
- package/configure/lib/correct-response.js.map +0 -1
- package/configure/lib/defaults.js +0 -357
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/graphing-config.js +0 -408
- package/configure/lib/graphing-config.js.map +0 -1
- package/configure/lib/index.js +0 -167
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/utils.js +0 -630
- package/configure/lib/utils.js.map +0 -1
- package/configure/package.json +0 -29
- package/controller/CHANGELOG.json +0 -1
- package/controller/CHANGELOG.md +0 -715
- package/controller/lib/defaults.js +0 -69
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -351
- package/controller/lib/index.js.map +0 -1
- package/controller/lib/utils.js +0 -212
- package/controller/lib/utils.js.map +0 -1
- package/controller/package.json +0 -22
- package/demo-gss.gif +0 -0
- package/docs/config-schema.json +0 -1560
- package/docs/config-schema.json.md +0 -1114
- package/docs/demo/config.js +0 -8
- package/docs/demo/generate.js +0 -54
- package/docs/demo/index.html +0 -1
- package/docs/demo/session.js +0 -6
- package/docs/pie-schema.json +0 -1800
- package/docs/pie-schema.json.md +0 -952
- package/lib/index.js +0 -165
- package/lib/index.js.map +0 -1
- package/lib/main.js +0 -355
- package/lib/main.js.map +0 -1
- package/lib/utils.js +0 -515
- package/lib/utils.js.map +0 -1
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { checkIfLinesAreAdded as e, findSectionsInSolutionSet as t, pointInsidePolygon as n } from "./utils.js";
|
|
2
|
+
import r from "react";
|
|
3
|
+
import i from "prop-types";
|
|
4
|
+
import { styled as a } from "@mui/material/styles";
|
|
5
|
+
import { GraphContainer as o } from "@pie-lib/graphing-solution-set";
|
|
6
|
+
import * as s from "@pie-lib/render-ui";
|
|
7
|
+
import { Collapsible as c, PreviewPrompt as l, UiLayout as u, color as d, hasMedia as f, hasText as p } from "@pie-lib/render-ui";
|
|
8
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
9
|
+
import g from "@pie-lib/correct-answer-toggle";
|
|
10
|
+
import { AlertDialog as _ } from "@pie-lib/config-ui";
|
|
11
|
+
//#region src/delivery/main.tsx
|
|
12
|
+
function v(e) {
|
|
13
|
+
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
14
|
+
}
|
|
15
|
+
function y(e, t) {
|
|
16
|
+
return !e || v(e) ? e : v(e.default) ? e.default : t && v(e[t]) ? e[t] : t && v(e[t]?.default) ? e[t].default : e;
|
|
17
|
+
}
|
|
18
|
+
var b = y(u, "UiLayout") || y(T.UiLayout, "UiLayout"), x = y(l, "PreviewPrompt") || y(T.PreviewPrompt, "PreviewPrompt"), S = y(c, "Collapsible") || y(T.Collapsible, "Collapsible"), C = s, w = C.default, T = w && typeof w == "object" ? w : C, E = a(b)({
|
|
19
|
+
color: d.text(),
|
|
20
|
+
backgroundColor: d.background()
|
|
21
|
+
}), D = a(S)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), O = a(o)(({ theme: e }) => ({
|
|
22
|
+
marginTop: e.spacing(2),
|
|
23
|
+
marginBottom: e.spacing(2)
|
|
24
|
+
})), k = class extends r.Component {
|
|
25
|
+
static propTypes = {
|
|
26
|
+
model: i.object.isRequired,
|
|
27
|
+
session: i.object.isRequired,
|
|
28
|
+
onAnswersChange: i.func
|
|
29
|
+
};
|
|
30
|
+
state = {
|
|
31
|
+
showingCorrect: !1,
|
|
32
|
+
dialog: { open: !1 }
|
|
33
|
+
};
|
|
34
|
+
handleAlertDialog = (e, t) => this.setState({ dialog: { open: e } }, t);
|
|
35
|
+
toggleCorrect = (e) => this.setState({ showingCorrect: e });
|
|
36
|
+
onResetClick = () => {
|
|
37
|
+
let { model: e, session: t, setGssData: n } = this.props, { gssData: r } = e;
|
|
38
|
+
this.setState({ dialog: {
|
|
39
|
+
open: !0,
|
|
40
|
+
title: "Warning",
|
|
41
|
+
text: "This will remove all the elements added on the graph and reset graph to original state. Are you sure you want to continue?",
|
|
42
|
+
onConfirm: () => {
|
|
43
|
+
t.answer = [], r.selectedTool = "lineA", r.lineA.lineType = "Solid", r.lineB && (r.lineB.lineType = "Solid"), n(r, t), this.handleAlertDialog(!1);
|
|
44
|
+
},
|
|
45
|
+
onClose: () => this.handleAlertDialog(!1)
|
|
46
|
+
} });
|
|
47
|
+
};
|
|
48
|
+
onSolutionSetSelected = (e) => {
|
|
49
|
+
let { model: t, session: r, setGssData: i } = this.props, { gssData: a, disabled: o } = t;
|
|
50
|
+
if (!o) {
|
|
51
|
+
for (let t of a.sections) if (n(e, t)) {
|
|
52
|
+
let e = {
|
|
53
|
+
points: t,
|
|
54
|
+
building: !1,
|
|
55
|
+
type: "polygon",
|
|
56
|
+
closed: !0,
|
|
57
|
+
isSolution: !0
|
|
58
|
+
};
|
|
59
|
+
r.answer = r.answer.filter((e) => e.type !== "polygon"), r.answer.push(e);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
i(a, r);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
onChangeGssLineData = (n, r) => {
|
|
66
|
+
let { model: i, session: a } = this.props, { domain: o, range: s, disabled: c } = i;
|
|
67
|
+
if (!c) if (n.selectedTool === "solutionSet") {
|
|
68
|
+
let i = a.answer.filter((e) => e.type !== "polygon");
|
|
69
|
+
if (!e(n, i)) n.selectedTool = r, this.setState({ dialog: {
|
|
70
|
+
open: !0,
|
|
71
|
+
title: "Warning",
|
|
72
|
+
text: "Please define the line(s) and then select a solution set for the item.",
|
|
73
|
+
onConfirm: () => this.handleAlertDialog(!1)
|
|
74
|
+
} });
|
|
75
|
+
else {
|
|
76
|
+
let e = a.answer.filter((e) => e.type !== "polygon");
|
|
77
|
+
n = t(n, e, o, s);
|
|
78
|
+
}
|
|
79
|
+
this.handleGssDataChange(n, a);
|
|
80
|
+
} else {
|
|
81
|
+
let e = a.answer.filter((e) => e.type === "polygon");
|
|
82
|
+
r === "solutionSet" && e.length > 0 ? this.setState({ dialog: {
|
|
83
|
+
open: !0,
|
|
84
|
+
title: "Warning",
|
|
85
|
+
text: "Changing a line after adding a solution set will clear your selected solution set. Click 'Clear Solution Set' to change the line. Otherwise, click 'Cancel'.",
|
|
86
|
+
onConfirm: () => {
|
|
87
|
+
a.answer = a.answer.filter((e) => e.type !== "polygon"), this.handleGssDataChange(n, a), this.handleAlertDialog(!1);
|
|
88
|
+
},
|
|
89
|
+
onConfirmText: "CLEAR SOLUTION SET",
|
|
90
|
+
onClose: () => {
|
|
91
|
+
n.selectedTool = r, this.handleGssDataChange(n, a), this.handleAlertDialog(!1);
|
|
92
|
+
}
|
|
93
|
+
} }) : this.handleGssDataChange(n, a);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
handleGssDataChange = (e, t) => {
|
|
97
|
+
let { setGssData: n } = this.props;
|
|
98
|
+
t.answer && t.answer.length > 0 && t.answer[0] && e.lineA && (t.answer[0].fill = e.lineA.lineType), t.answer && t.answer.length > 1 && t.answer[1] && e.lineB && (t.answer[1].fill = e.lineB.lineType), (e.selectedTool === "lineB" && t.answer.length === 0 || e.selectedTool === "lineB" && t.answer[0].building) && (this.setState({ dialog: {
|
|
99
|
+
open: !0,
|
|
100
|
+
title: "Warning",
|
|
101
|
+
text: "Please add Line A to the graph before adding Line B",
|
|
102
|
+
onConfirm: () => this.handleAlertDialog(!1)
|
|
103
|
+
} }), e.selectedTool = "lineA"), e.selectedTool === "lineA" && t.answer.length > 1 && t.answer[1].building && (this.setState({ dialog: {
|
|
104
|
+
open: !0,
|
|
105
|
+
title: "Warning",
|
|
106
|
+
text: "Please add Line B to the graph before switching to Line A",
|
|
107
|
+
onConfirm: () => this.handleAlertDialog(!1)
|
|
108
|
+
} }), e.selectedTool = "lineB"), n(e, t);
|
|
109
|
+
};
|
|
110
|
+
render() {
|
|
111
|
+
let { model: e, onAnswersChange: t, session: n } = this.props, { showingCorrect: r, dialog: i } = this.state, { answer: a } = n || {}, { answersCorrected: o, arrows: s, coordinatesOnHover: c, correctResponse: l, defaultTool: u, disabled: d, domain: v, extraCSSRules: y, labels: b, labelsEnabled: C, prompt: w, range: T, rationale: k, size: A, showToggle: j, title: M, titleEnabled: N, teacherInstructions: P, language: F, gssLineData: I, gssData: L } = e || {}, R = o || a || [], z = e.rationale && (p(e.rationale) || f(e.rationale));
|
|
112
|
+
return /* @__PURE__ */ h(E, {
|
|
113
|
+
extraCSSRules: y,
|
|
114
|
+
children: [
|
|
115
|
+
e.teacherInstructions && (p(e.teacherInstructions) || f(e.teacherInstructions)) && /* @__PURE__ */ m(D, {
|
|
116
|
+
labels: {
|
|
117
|
+
hidden: "Show Teacher Instructions",
|
|
118
|
+
visible: "Hide Teacher Instructions"
|
|
119
|
+
},
|
|
120
|
+
children: /* @__PURE__ */ m(x, { prompt: P })
|
|
121
|
+
}),
|
|
122
|
+
w && /* @__PURE__ */ m(x, {
|
|
123
|
+
className: "prompt",
|
|
124
|
+
prompt: w
|
|
125
|
+
}),
|
|
126
|
+
/* @__PURE__ */ m(g, {
|
|
127
|
+
show: j,
|
|
128
|
+
toggled: r,
|
|
129
|
+
onToggle: this.toggleCorrect,
|
|
130
|
+
language: F
|
|
131
|
+
}),
|
|
132
|
+
r && j ? /* @__PURE__ */ m(O, {
|
|
133
|
+
axesSettings: { includeArrows: s },
|
|
134
|
+
coordinatesOnHover: c,
|
|
135
|
+
disabled: !0,
|
|
136
|
+
disabledLabels: !0,
|
|
137
|
+
disabledTitle: !0,
|
|
138
|
+
domain: v,
|
|
139
|
+
labels: b,
|
|
140
|
+
marks: l.map((e) => ({
|
|
141
|
+
...e,
|
|
142
|
+
correctness: "correct"
|
|
143
|
+
})),
|
|
144
|
+
onChangeMarks: t,
|
|
145
|
+
range: T,
|
|
146
|
+
showLabels: C,
|
|
147
|
+
showTitle: N,
|
|
148
|
+
size: A,
|
|
149
|
+
title: M,
|
|
150
|
+
language: F,
|
|
151
|
+
gssLineData: I,
|
|
152
|
+
onChangeGssLineData: this.onChangeGssLineData,
|
|
153
|
+
onSolutionSetSelected: this.onSolutionSetSelected,
|
|
154
|
+
toolbarTools: ["line", "polygon"]
|
|
155
|
+
}) : /* @__PURE__ */ m(O, {
|
|
156
|
+
axesSettings: { includeArrows: s },
|
|
157
|
+
coordinatesOnHover: c,
|
|
158
|
+
defaultTool: u,
|
|
159
|
+
disabled: d,
|
|
160
|
+
disabledLabels: !0,
|
|
161
|
+
disabledTitle: !0,
|
|
162
|
+
domain: v,
|
|
163
|
+
labels: b,
|
|
164
|
+
marks: R,
|
|
165
|
+
onChangeMarks: t,
|
|
166
|
+
onCustomReset: this.onResetClick,
|
|
167
|
+
range: T,
|
|
168
|
+
showLabels: C,
|
|
169
|
+
showTitle: N,
|
|
170
|
+
size: A,
|
|
171
|
+
title: M,
|
|
172
|
+
language: F,
|
|
173
|
+
gssLineData: L,
|
|
174
|
+
onChangeGssLineData: this.onChangeGssLineData,
|
|
175
|
+
onSolutionSetSelected: this.onSolutionSetSelected,
|
|
176
|
+
toolbarTools: ["line", "polygon"]
|
|
177
|
+
}),
|
|
178
|
+
z && /* @__PURE__ */ m(S, {
|
|
179
|
+
labels: {
|
|
180
|
+
hidden: "Show Rationale",
|
|
181
|
+
visible: "Hide Rationale"
|
|
182
|
+
},
|
|
183
|
+
children: /* @__PURE__ */ m(x, { prompt: k })
|
|
184
|
+
}),
|
|
185
|
+
/* @__PURE__ */ m(_, {
|
|
186
|
+
open: i.open,
|
|
187
|
+
title: i.title,
|
|
188
|
+
text: i.text,
|
|
189
|
+
onClose: i.onClose,
|
|
190
|
+
onConfirm: i.onConfirm,
|
|
191
|
+
onConfirmText: i.onConfirmText ? i.onConfirmText : "OK"
|
|
192
|
+
})
|
|
193
|
+
]
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
//#endregion
|
|
198
|
+
export { k as Main, k as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/graphing-solution-set/src/utils.js
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
export declare const findSectionsInSolutionSet: (gssLineData: any, answers: any, domain: any, range: any) => any;
|
|
10
|
+
export declare const pointInsidePolygon: (point: any, polygon: any) => boolean;
|
|
11
|
+
export declare const checkIfLinesAreAdded: (gssLineData: any, answer: any) => boolean | undefined;
|
|
12
|
+
export declare const removeInvalidAnswers: (answers: any) => any;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
var e = {
|
|
2
|
+
line: (t) => t && e.point(t.from) && e.point(t.to),
|
|
3
|
+
point: (e) => e && Number.isFinite(e.x) && Number.isFinite(e.y)
|
|
4
|
+
}, t = (e, t) => Number(Math.sqrt((e.x - t.x) ** 2 + (e.y - t.y) ** 2).toFixed(3)), n = (e, n) => {
|
|
5
|
+
let r = e, i = !1, a = [...n];
|
|
6
|
+
a.push(n[0]);
|
|
7
|
+
for (let e = 0; e < a.length - 1; e++) {
|
|
8
|
+
let n = a[e], o = a[e + 1];
|
|
9
|
+
if (t(n, r) + t(r, o) === t(n, o)) {
|
|
10
|
+
i = !0;
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return i;
|
|
15
|
+
}, r = (e, t, n, r, i, a, o, s) => {
|
|
16
|
+
let c, l = (s - a) * (n - e) - (o - i) * (r - t);
|
|
17
|
+
return l === 0 ? null : (c = ((o - i) * (t - a) - (s - a) * (e - i)) / l, {
|
|
18
|
+
x: Number((e + c * (n - e)).toFixed(3)),
|
|
19
|
+
y: Number((t + c * (r - t)).toFixed(3))
|
|
20
|
+
});
|
|
21
|
+
}, i = (e, t, n) => e.x > t.min && e.x < t.max && e.y > n.min && e.y < n.max, a = (e, t, n) => e.x >= t.min && e.x <= t.max && e.y >= n.min && e.y <= n.max, o = (e, t, n) => {
|
|
22
|
+
let i = [], o = [
|
|
23
|
+
[
|
|
24
|
+
t.max,
|
|
25
|
+
n.max,
|
|
26
|
+
t.max,
|
|
27
|
+
n.min
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
t.min,
|
|
31
|
+
n.max,
|
|
32
|
+
t.min,
|
|
33
|
+
n.min
|
|
34
|
+
],
|
|
35
|
+
[
|
|
36
|
+
t.min,
|
|
37
|
+
n.max,
|
|
38
|
+
t.max,
|
|
39
|
+
n.max
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
t.min,
|
|
43
|
+
n.min,
|
|
44
|
+
t.max,
|
|
45
|
+
n.min
|
|
46
|
+
]
|
|
47
|
+
];
|
|
48
|
+
for (let s = 0; s < o.length; s++) {
|
|
49
|
+
let c = r(e.from.x, e.from.y, e.to.x, e.to.y, o[s][0], o[s][1], o[s][2], o[s][3]);
|
|
50
|
+
c && a(c, t, n) && i.push(c);
|
|
51
|
+
}
|
|
52
|
+
return i;
|
|
53
|
+
}, s = (e) => {
|
|
54
|
+
e.sort((e, t) => e.y - t.y);
|
|
55
|
+
let t = (e[0].y + e[e.length - 1].y) / 2;
|
|
56
|
+
e.sort((e, t) => t.x - e.x);
|
|
57
|
+
let n = {
|
|
58
|
+
x: (e[0].x + e[e.length - 1].x) / 2,
|
|
59
|
+
y: t
|
|
60
|
+
}, r;
|
|
61
|
+
e.forEach((e) => {
|
|
62
|
+
let t = Math.atan2(e.y - n.y, e.x - n.x);
|
|
63
|
+
r ? t < r && (t += Math.PI * 2) : r = t, e.angle = t;
|
|
64
|
+
}), e.sort((e, t) => e.angle - t.angle);
|
|
65
|
+
let i = e.reverse();
|
|
66
|
+
return i.unshift(i.pop()), i.map(({ angle: e, ...t }) => t);
|
|
67
|
+
}, c = (e, t) => e.x * t.x + e.y * t.y, l = (e) => Math.sqrt(e.x * e.x + e.y * e.y), u = (e, t) => {
|
|
68
|
+
let n = c(e, t), r = l(e), i = l(t);
|
|
69
|
+
return Math.acos(n / (r * i));
|
|
70
|
+
}, d = (e, t, n, r) => {
|
|
71
|
+
let i = {
|
|
72
|
+
x: t.x - e.x,
|
|
73
|
+
y: t.y - e.y
|
|
74
|
+
}, a = {
|
|
75
|
+
x: n.x - e.x,
|
|
76
|
+
y: n.y - e.y
|
|
77
|
+
}, o = {
|
|
78
|
+
x: r.x - e.x,
|
|
79
|
+
y: r.y - e.y
|
|
80
|
+
}, s = u(i, o) + u(a, o);
|
|
81
|
+
return Math.abs(s - u(i, a)) < 1e-4;
|
|
82
|
+
}, f = (e) => e.filter((t, n) => n === e.findIndex((e) => t.x === e.x && t.y === e.y)), p = (e) => {
|
|
83
|
+
for (let t = 0; t < e.length; t++) e[t] = e[t].filter((n, r) => r === e[t].findIndex((e) => n.x === e.x && n.y === e.y));
|
|
84
|
+
e = e.filter((e) => e.length > 2);
|
|
85
|
+
for (let t = 0; t < e.length; t++) e[t] = s(e[t]);
|
|
86
|
+
return e;
|
|
87
|
+
}, m = (e, t, n) => {
|
|
88
|
+
let r = [];
|
|
89
|
+
return r.push([].concat(e)), r.push([].concat(e)), e[0].x === t.max && e[1].y === n.max || e[1].x === t.max && e[0].y === n.max ? (r[0].push({
|
|
90
|
+
x: t.max,
|
|
91
|
+
y: n.max
|
|
92
|
+
}), r[1].push({
|
|
93
|
+
x: t.min,
|
|
94
|
+
y: n.max
|
|
95
|
+
}, {
|
|
96
|
+
x: t.min,
|
|
97
|
+
y: n.min
|
|
98
|
+
}, {
|
|
99
|
+
x: t.max,
|
|
100
|
+
y: n.min
|
|
101
|
+
})) : e[0].x === t.min && e[1].y === n.max || e[1].x === t.min && e[0].y === n.max ? (r[0].push({
|
|
102
|
+
x: t.min,
|
|
103
|
+
y: n.max
|
|
104
|
+
}), r[1].push({
|
|
105
|
+
x: t.max,
|
|
106
|
+
y: n.max
|
|
107
|
+
}, {
|
|
108
|
+
x: t.max,
|
|
109
|
+
y: n.min
|
|
110
|
+
}, {
|
|
111
|
+
x: t.min,
|
|
112
|
+
y: n.min
|
|
113
|
+
})) : e[0].x === t.min && e[1].y === n.min || e[1].x === t.min && e[0].y === n.min ? (r[0].push({
|
|
114
|
+
x: t.min,
|
|
115
|
+
y: n.min
|
|
116
|
+
}), r[1].push({
|
|
117
|
+
x: t.max,
|
|
118
|
+
y: n.min
|
|
119
|
+
}, {
|
|
120
|
+
x: t.max,
|
|
121
|
+
y: n.max
|
|
122
|
+
}, {
|
|
123
|
+
x: t.min,
|
|
124
|
+
y: n.max
|
|
125
|
+
})) : e[0].x === t.max && e[1].y === n.min || e[1].x === t.max && e[0].y === n.min ? (r[0].push({
|
|
126
|
+
x: t.max,
|
|
127
|
+
y: n.min
|
|
128
|
+
}), r[1].push({
|
|
129
|
+
x: t.min,
|
|
130
|
+
y: n.min
|
|
131
|
+
}, {
|
|
132
|
+
x: t.min,
|
|
133
|
+
y: n.max
|
|
134
|
+
}, {
|
|
135
|
+
x: t.max,
|
|
136
|
+
y: n.max
|
|
137
|
+
})) : e[0].x === t.min && e[1].x === t.max || e[0].x === t.max && e[1].x === t.min ? (r[0].push({
|
|
138
|
+
x: t.min,
|
|
139
|
+
y: n.max
|
|
140
|
+
}, {
|
|
141
|
+
x: t.max,
|
|
142
|
+
y: n.max
|
|
143
|
+
}), r[1].push({
|
|
144
|
+
x: t.min,
|
|
145
|
+
y: n.min
|
|
146
|
+
}, {
|
|
147
|
+
x: t.max,
|
|
148
|
+
y: n.min
|
|
149
|
+
})) : (e[0].y === n.min && e[1].y === n.max || e[0].y === n.max && e[1].y === n.min) && (r[0].push({
|
|
150
|
+
x: t.min,
|
|
151
|
+
y: n.min
|
|
152
|
+
}, {
|
|
153
|
+
x: t.min,
|
|
154
|
+
y: n.max
|
|
155
|
+
}), r[1].push({
|
|
156
|
+
x: t.max,
|
|
157
|
+
y: n.min
|
|
158
|
+
}, {
|
|
159
|
+
x: t.max,
|
|
160
|
+
y: n.max
|
|
161
|
+
})), p(r);
|
|
162
|
+
}, h = (e, t, a, s) => {
|
|
163
|
+
let c = t[0], l = t[1], u = [
|
|
164
|
+
{
|
|
165
|
+
x: a.min,
|
|
166
|
+
y: s.min
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
x: a.min,
|
|
170
|
+
y: s.max
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
x: a.max,
|
|
174
|
+
y: s.min
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
x: a.max,
|
|
178
|
+
y: s.max
|
|
179
|
+
}
|
|
180
|
+
], h = r(c.from.x, c.from.y, c.to.x, c.to.y, l.from.x, l.from.y, l.to.x, l.to.y), g = [], _ = o(c, a, s);
|
|
181
|
+
_ = f(_);
|
|
182
|
+
let v = o(l, a, s);
|
|
183
|
+
if (v = f(v), h && i(h, a, s)) for (let e = 0; e < _.length; e++) for (let t = 0; t < v.length; t++) {
|
|
184
|
+
let n = [], r = [];
|
|
185
|
+
n.push(h), n.push(_[e]), n.push(v[t]);
|
|
186
|
+
for (let i = 0; i < u.length; i++) d(h, _[e], v[t], u[i]) ? n.push(u[i]) : r.push(u[i]);
|
|
187
|
+
u = r, g.push(n);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
let e = m(_, a, s), t = m(v, a, s);
|
|
191
|
+
for (let t = 0; t < e.length; t++) n(v[0], e[t]) && n(v[1], e[t]) || g.push(e[t]);
|
|
192
|
+
for (let e = 0; e < t.length; e++) n(_[0], t[e]) && n(_[1], t[e]) || g.push(t[e]);
|
|
193
|
+
for (let e = 0; e < g.length; e++) u = u.filter(function(t) {
|
|
194
|
+
return !g[e].some(function(e) {
|
|
195
|
+
return t.x === e.x && t.y === e.y;
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
let r = u.concat(_, v);
|
|
199
|
+
g.push(r);
|
|
200
|
+
}
|
|
201
|
+
return p(g);
|
|
202
|
+
}, g = (e, t, n, r) => (e.numberOfLines === 1 ? e.sections = m(o(t[0], n, r), n, r) : e.sections = h(e, t, n, r), e), _ = (e, t) => {
|
|
203
|
+
let n = t.length, r = e.x, i = e.y, a = !1, o = t[0], s;
|
|
204
|
+
for (let e = 1; e <= n; e++) {
|
|
205
|
+
if (s = t[e % n], i > Math.min(o.y, s.y) && i <= Math.max(o.y, s.y) && r <= Math.max(o.x, s.x)) {
|
|
206
|
+
let e = (i - o.y) * (s.x - o.x) / (s.y - o.y) + o.x;
|
|
207
|
+
(o.x === s.x || r <= e) && (a = !a);
|
|
208
|
+
}
|
|
209
|
+
o = s;
|
|
210
|
+
}
|
|
211
|
+
return a;
|
|
212
|
+
}, v = (e, t) => {
|
|
213
|
+
if (t.length === 0) return !1;
|
|
214
|
+
if (e.numberOfLines === 1) {
|
|
215
|
+
if (t.length === 1) return !t[0].building;
|
|
216
|
+
} else if (t.length !== 2) return !1;
|
|
217
|
+
else return !t[1].building;
|
|
218
|
+
}, y = (t) => t ? (t || []).filter(({ type: t, ...n }) => e[t] ? e[t](n) : !1) : [];
|
|
219
|
+
//#endregion
|
|
220
|
+
export { v as checkIfLinesAreAdded, g as findSectionsInSolutionSet, _ as pointInsidePolygon, y as removeInvalidAnswers };
|