-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
183 lines (165 loc) · 37.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!-- Saved from local source at 2023-03-31T18:14:54Z using monolith v2.7.0 -->
<!DOCTYPE html><html><head><meta http-equiv="Content-Security-Policy"></meta><meta charset="utf-8">
<title>OrderedLogit Link</title>
<meta name="viewport" content="width=device-width">
<link type="text/css" rel="stylesheet" media="screen" href="data:text/css;base64,QGltcG9ydCB1cmwoImRhdGE6dGV4dC9jc3M7Y2hhcnNldD11dGYtODtiYXNlNjQsTHlvZ1kzbHlhV3hzYVdNdFpYaDBJQ292Q2lBS0x5b2dZM2x5YVd4c2FXTWdLaThLSUFvdktpQm5jbVZsYXkxbGVIUWdLaThLSUFvdktpQm5jbVZsYXlBcUx3b2dDaThxSUhacFpYUnVZVzFsYzJVZ0tpOEtJQW92S2lCc1lYUnBiaTFsZUhRZ0tpOEtJQW92S2lCc1lYUnBiaUFxTHdvZ0NpOHFJR041Y21sc2JHbGpMV1Y0ZENBcUx3b2dDaThxSUdONWNtbHNiR2xqSUNvdkNpQUtMeW9nWjNKbFpXc3RaWGgwSUNvdkNpQUtMeW9nWjNKbFpXc2dLaThLSUFvdktpQjJhV1YwYm1GdFpYTmxJQ292Q2lBS0x5b2diR0YwYVc0dF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QyAhaW1wb3J0YW50OyAgICAgLyogbWljaGlnYW4gYmx1ZSAqLwp9Cg==">
<link type="text/css" rel="stylesheet" media="screen" href="data:text/css;base64,LnNsaWRlciB7CiAgd2lkdGg6IDYwMHB4Owp9CgouYXhpcyBwYXRoLAouYXhpcyBsaW5lIHsKICBzdHJva2U6IGJsYWNrOyAgCn0KIAouY2hhcnQgcGF0aCB7CiAgICBzdHJva2Utd2lkdGg6IDE7CiAgICBmaWxsOiBub25lOwp9CiAKLmxpbmUgewogIHN0cm9rZTogcmVkOwogIHN0cm9rZS13aWR0aDogNTsKICBvcGFjaXR5OiAwLjY7Cn0KCi5saW5lX3JlZmVyZW5jZSB7CiAgc3Ryb2tlOiBncmVlbjsKICBzdHJva2Utd2lkdGg6IDU7CiAgb3BhY2l0eTogMC42Owp9CgouYmFyIHsKICBmaWxsOiByZWQ7CiAgb3BhY2l0eTogMC44Owp9CgouYXJlYSB7CiAgZmlsbDogbGlnaHRzdGVlbGJsdWU7CiAgb3BhY2l0eTogMC41Owp9CgoueC1heGlzLCAueS1heGlzIHsKICBmb250LXNpemU6IDFlbTsKICBmb250LWZhbWlseTogc2Fucy1zZXJpZjsKfQoKLm1lYW57CiAgc3Ryb2tlLWRhc2hhcnJheTogNSw1OyAKICBzdHJva2Utd2lkdGg6IDI7CiAgc3Ryb2tlOiBsaWdodGdyYXk7Cn0K">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/14.6.3/nouislider.min.css" />
<script src="https://d3js.org/d3.v6.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/14.6.3/nouislider.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/wnumb/1.2.0/wNumb.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jstat@latest/dist/jstat.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
integrity="sha384-vKruj+a13U8yHIkAyGgK1J3ArTLzrFGBbBc0tDp4ad/EyewESeXE/Iv67Aj8gKZ0" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
integrity="sha384-PwRUT/YqbnEjkZO0zZxNqcxACrXe+j766U2amXcgMg5457rve2Y7I6ZJSm2A0mS4"
crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
renderMathInElement(document.body, {
// customised options
// • auto-render specific keys, e.g.:
delimiters: [
{ left: '$$', right: '$$', display: true },
{ left: '$', right: '$', display: false },
{ left: '\\(', right: '\\)', display: false },
],
// • rendering keys, e.g.:
throwOnError: false
});
});
</script>
</head>
<body>
<div class="contain">
<h1>Ordered Logit</h1>
<p class="description"></p>
<div class="frame">
<div id="chart"></div>
<aside>
<div class="phi">
<div class="slider-label">$\phi$</div>
<div id="slider_0"></div>
</div>
<div class="cutpoints">
<div>$\kappa_1=$ <span class="cutpoint"></span></div>
<div>$\kappa_2=$ <span class="cutpoint"></span></div>
<div>$\kappa_3=$ <span class="cutpoint"></span></div>
</div>
<div class="bars">
<div> <span class="simplex"></span>
<div id="slider_1" class="slider"></div> <span>$p_1$</span>
</div>
<div> <span class="simplex"></span>
<div id="slider_2" class="slider"></div> <span>$p_2$</span>
</div>
<div> <span class="simplex"></span>
<div id="slider_3" class="slider"></div> <span>$p_3$</span>
</div>
<div> <span class="simplex"></span>
<div id="slider_4" class="slider"></div> <span>$p_4$</span>
</div>
</div>
</aside>
</div>
<br><br><br><br>
<hr class="my-hr-line">
<div class="formula">
$$
\begin{aligned}
& R_i \sim Categorical(
\begin{bmatrix}
\Pr(R = 1) \\
\Pr(R = 2) \\
\Pr(R = 3) \\
\Pr(R = 4)
\end{bmatrix}
)\\
& Pr(R_i = 4) = Pr(R_i \le 4) - Pr(R_i \le 3) \\
& Pr(R_i = 3) = Pr(R_i \le 3) - Pr(R_i \le 2) \\
& Pr(R_i = 2) = Pr(R_i \le 2) - Pr(R_i \le 1) \\
& Pr(R_i = 1) = Pr(R_i \le 1) \\
\\
& logit[ Pr(R_i \le 4) ] = logit(1) = \infty \\
& logit[ Pr(R_i \le 3) ] = log \frac{Pr(R_i \le 3)}{1 - Pr(R_i \le 3)} = \kappa_3 - \phi_i \\
& logit[ Pr(R_i \le 2) ] = log \frac{Pr(R_i \le 2)}{1 - Pr(R_i \le 2)} = \kappa_2 - \phi_i \\
& logit[ Pr(R_i \le 1) ] = logit[ Pr(R_i = 1) ] = log \frac{Pr(R_i = 1)}{1 - Pr(R_i = 1)} = \kappa_1 - \phi_i \\
\\
&\text{ or succintly as } \\
& logit( P_c ) = \kappa_c - \phi_i ~, \\
& ~~~ \text{where } P_c = Pr(R_i \le c) \text{, cutpoint } c = 1, 2, 3
\end{aligned}
$$
</div>
<style>
.contain {
width: 1100px;
margin: 0px auto;
padding-top: 0px;
padding-bottom: 20px;
}
/* layout */
.frame {
display: flex;
flex-direction: row;
width: 88%;
min-width: 392px;
margin: 0 auto;
align-items: center;
/* align-content: space-between; */
justify-content: space-between;
}
#chart {
width: 40%;
min-width: 392px;
}
/* Slide bar styles*/
.phi {
width: 100%;
min-width: 200px;
margin: 3.5em auto;
}
.cutpoints {
width: 100%;
margin: 0 auto 1em auto;
display: flex;
justify-content: space-around;
align-items: flex-end;
}
.cutpoints > div {
text-align: right;
margin-right: 0.5em;
}
.bars {
width: 100%;
display: flex;
height: 200px;
justify-content: space-around;
text-align: right;
}
.bars>div>div.slider {
height: 150px;
}
.bars div .simplex, .bars div span {
display: inline-block;
margin-bottom: 1em;
}
@media (max-width: 1100px) {
.frame {
flex-direction: column;
}
#chart {
width: 100%;
}
}
</style>
</div>
<script src="data:application/javascript;base64,Y29uc3QgZGlzdF9uYW1lID0gIm9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p9KTsKCm5vVWlTbGlkZXIuY3JlYXRlKHNsaWRlcl8yLCB7CiAgICBvcmllbnRhdGlvbjogJ3ZlcnRpY2FsJywKICAgIGRpcmVjdGlvbjogJ3J0bCcsCiAgICBzdGFydDogcGFyYW1zWzJdLAogICAgc3RlcDogLjA1LAogICAgdG9vbHRpcHM6IGZhbHNlLAogICAgcmFuZ2U6IHsKICAgICAgICAnbWluJzogMCwKICAgICAgICAnbWF4JzogMQogICAgfQp9KTsKCm5vVWlTbGlkZXIuY3JlYXRlKHNsaWRlcl8zLCB7CiAgICBvcmllbnRhdGlvbjogJ3ZlcnRpY2FsJywKICAgIGRpcmVjdGlvbjogJ3J0bCcsCiAgICBzdGFydDogcGFyYW1zWzNdLAogICAgc3RlcDogLjA1LAogICAgdG9vbHRpcHM6IGZhbHNlLAogICAgcmFuZ2U6IHsKICAgICAgICAnbWluJzogMCwKICAgICAgICAnbWF4JzogMQogICAgfQp9KTsKCm5vVWlTbGlkZXIuY3JlYXRlKHNsaWRlcl80LCB7CiAgICBvcmllbnRhdGlvbjogJ3ZlcnRpY2FsJywKICAgIGRpcmVjdGlvbjogJ3J0bCcsCiAgICBzdGFydDogcGFyYW1zWzRdLAogICAgc3RlcDogLjA1LAogICAgdG9vbHRpcHM6IGZhbHNlLAogICAgcmFuZ2U6IHsKICAgICAgICAnbWluJzogMCwKICAgICAgICAnbWF4JzogMQogICAgfQp9KTsK"></script>
<script src="data:application/javascript;base64,Y29uc3Qgd2lkdGggPSA3NTA7CmNvbnN0IGhlaWdodCA9IDQwMDsKY29uc3QgbWFyZ2luID0ge3RvcDogNDAsIHJpZ2h0OiA0MCwgYm90dG9tOiAzMCwgbGVmdDogNzB9Owpjb25zdCBpbm5lcldpZHRoID0gd2lkdGggLSBtYXJnaW4ubGVmdCAtIG1hcmdpbi5yaWdodDsKY29uc3QgaW5uZXJIZWlnaHQgPSBoZWlnaHQgLSBtYXJnaW4udG9wIC0gbWFyZ2luLmJvdHRvbTsKCmNvbnN0IHN2ZyA9IGQzLnNlbGVjdCgiI2NoYXJ0IikKICAgICAgICAgICAgICAuYXBwZW5kKCJzdmciKQogICAgICAgICAgICAgICAgLmF0dHIoIndpZHRoIiwgd2lkdGgpCiAgICAgICAgICAgICAgICAuYXR0cigiaGVpZ2h0IiwgaGVpZ2h0KQogICAgICAgICAgICAgIC5hcHBlbmQoImciKQogICAgICAgICAgICAgICAgLmF0dHIoInRyYW5zZm9ybSIsICJ0cmFuc2xhdGUoIiArIG1hcmdpbi5sZWZ0ICsgIiwiICsgbWFyZ2luLnRvcCArICIpIik7Cgp2YXIgeFNjYWxlOwoKaWYgKGRpc3RfdHlwZSA9PSAiY29udGludW91cyIpIHsKICAgIHhTY2FsZSA9IGQzLnNjYWxlTGluZWFyKCkKICAgICAgICAuZG9tYWluKHhSYW5nZSkKICAgICAgICAucmFuZ2UoWzAsIGlubmVyV2lkdGhdKTsKCiAgICBzdmcuYXBwZW5kKCJnIikKICAgICAgICAuYXR0cigiY2xhc3MiLCAieC1heGlzIikKICAgICAgICAuYXR0cigidHJhbnNmb3JtIiwgInRyYW5zbGF0ZSgwLCIgKyBpbm5lckhlaWdodCArICIpIikKICAgICAgICAuY2FsbChkMy5heGlzQm90dG9tKHhTY2FsZSkKICAgICAgICApOwp9CmVsc2UgaWYgKGRpc3RfdHlwZSA9PSAiZGlzY3JldGUiKSB7CgogICAgaWYgKGRpc3RfbmFtZSA9PSAiYmVybm91bGxpIikgeyAgICAvLyBzcGVjaWFsIHRyZWF0bWVudCBmb3IgQmVybm91bGxpCiAgICAgICAgeFNjYWxlID0gZDMuc2NhbGVCYW5kKCkKICAgICAgICAuZG9tYWluKFstMSwgMCwgMSwgMl0pCiAgICAgICAgLnJhbmdlUm91bmQoWzAsIGlubmVyV2lkdGhdLCAwLjEpCiAgICAgICAgLnBhZGRpbmdJbm5lcigwLjg1KTsKICAgIH0KICAgIGVsc2UgaWYgKGRpc3RfbmFtZSA9PSAiYmVuZm9yZCIpIHsgICAgLy8gc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LCAiRCIsICJFIiwgIkYiXS5mbGF0KCkpCiAgICAgICAgKTsKICAgIH0KICAgIGVsc2UgewogICAgc3ZnLmFwcGVuZCgiZyIpCiAgICAgICAgLmF0dHIoImNsYXNzIiwgIngtYXhpcyIpCiAgICAgICAgLmF0dHIoInRyYW5zZm9ybSIsICJ0cmFuc2xhdGUoMCwiICsgaW5uZXJIZWlnaHQgKyAiKSIpCiAgICAgICAgLmNhbGwoZDMuYXhpc0JvdHRvbSh4U2NhbGUpCiAgICAgICAgICAgIC50aWNrVmFsdWVzKGQzLnJhbmdlKHhSYW5nZVswXSwgeFJhbmdlWzFdKzEsICh4UmFuZ2VbMV0gLSB4UmFuZ2VbMF0gPiAyMCkgPyA1IDogMSkpCiAgICAgICAgKTsKICAgIH0KCn0KCmNvbnN0IHlTY2FsZSA9IGQzLnNjYWxlTGluZWFyKCkKICAgICAgICAuZG9tYWluKHlSYW5nZSkKICAgICAgICAucmFuZ2UoW2lubmVySGVpZ2h0LCAwXSk7CgpzdmcuYXBwZW5kKCJnIikKICAgIC5hdHRyKCJjbGFzcyIsICJ5LWF4aXMiKSAgICAKICAgIC5jYWxsKGQzLmF4aXNMZWZ0KHlTY2FsZSkKICAgICAgICAudGlja3MoNSkKICAgICk7Cg=="></script>
<script src="data:application/javascript;base64,Ly8gZ2VuZXJhdGUgZGF0YSBmb3IgZWFjaCBkaXN0cmlidXRpb24KZnVuY3Rpb24gbG9naXQocCkgewogICAgLy8gRml4IG51bWVyaWMgZXJyb3IKICAgIGlmIChwID4gMSkgcCA9IDEKICAgIGlmIChwIDwgMCkgcCA9IDAKICAgIHJldHVybiBNYXRoLmxvZyhwKSAtIE1hdGgubG9nKDEgLSBwKQp9CmZ1bmN0aW9uIGxvZ2lzdGljKHgpIHsKICAgIHJldHVybiAxIC8gKDEgKyBNYXRoLmV4cCgteCkpCn0KZnVuY3Rpb24gdG9TaW1wbGV4KHgpIHsKICAgIGNvbnN0IHMgPSB4LnJlZHVjZSgoYSxiKSA9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AgICAgICAgICAgICAgIHJldHVybiBwbWY7CiAgICAgICAgICAgIH07CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICJiZW5mb3JkIjogCiAgICAgICAgICAgIHZhciBwZGYgPSBmdW5jdGlvbih4LCBwYXJhbXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IGJhc2UgPSBwYXJhbXNbMF07CiAgICAgICAgICAgICAgICB2YXIgcG1mOwogICAgICAgICAgICAgICAgaWYgKHggPCBiYXNlKSB7IHBtZiA9IE1hdGgubG9nKDErMS94KSAvIE1hdGgubG9nKGJhc2UpIH0gZWxzZSB7IHBtZiA9IDAgfQogICAgICAgICAgICAgICAgcmV0dXJuIHBtZjsKICAgICAgICAgICAgfTsKICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIGNhc2UgImJlcm5vdWxsaSI6IAogICAgICAgICAgICB2YXIgcGRmID0gZnVuY3Rpb24oeCwgcGFyYW1zKSB7CiAgICAgICAgICAgICAgICBjb25zdCBwID0gcGFyYW1zWzBdOwogICAgICAgICAgICAgICAgdmFyIHBtZjsKICAgICAgICAgICAgICAgIGlmICh4ID09IDEpIHsgcG1mID0gcCB9IGVsc2UgaWYoeCA9PSAwKSB7IHBtZiA9IDEtcCB9IGVsc2UgeyBwbWYgPSAwIH0KICAgICAgICAgICAgICAgIHJldHVybiBwbWY7CiAgICAgICAgICAgIH07CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICJiaW5vbWlhbCI6CiAgICAgICAgICAgIHZhciBwZGYgPSBmdW5jdGlvbih4LCBwYXJhbXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IG4gPSBwYXJhbXNbMF07CiAgICAgICAgICAgICAgICBjb25zdCBwID0gcGFyYW1zWzFdOwogICAgICAgICAgICAgICAgcmV0dXJuICh4ID4gbikgPyAwIDogalN0YXQuYmlub21pYWwucGRmKHgsIG4sIHApOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICJnZW9tZXRyaWMiOgogICAgICAgICAgICB2YXIgcGRmID0gZnVuY3Rpb24oeCwgcGFyYW1zKSB7CiAgICAgICAgICAgICAgICBjb25zdCBwID0gcGFyYW1zWzBdOwogICAgICAgICAgICAgICAgcmV0dXJuICh4IDwgMSkgPyAwIDogTWF0aC5wb3coMS1wLHgtMSkqcDsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKCiAgICAgICAgY2FzZSAiaHlwZ2VvbSI6CiAgICAgICAgICAgIHZhciBwZGYgPSBmdW5jdGlvbih4LCBwYXJhbXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IE4gPSBwYXJhbXNbMF07CiAgICAgICAgICAgICAgICBjb25zdCBLID0gcGFyYW1zWzFdOwogICAgICAgICAgICAgICAgY29uc3QgbiA9IHBhcmFtc1syXTsKICAgICAgICAgICAgICAgIHJldHVybiBqU3RhdC5oeXBnZW9tLnBkZih4LCBOLCBLLCBuKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKCiAgICAgICAgY2FzZSAibmVnYmluIjoKICAgICAgICAgICAgdmFyIHBkZiA9IGZ1bmN0aW9uKHgsIHBhcmFtcykgewogICAgICAgICAgICAgICAgY29uc3QgciA9IHBhcmFtc1swXTsKICAgICAgICAgICAgICAgIGNvbnN0IHAgPSBwYXJhbXNbMV07CiAgICAgICAgICAgICAgICByZXR1cm4galN0YXQubmVnYmluLnBkZih4LCByLCBwKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKCiAgICAgICAgY2FzZSAicG9pc3NvbiI6CiAgICAgICAgICAgIHZhciBwZGYgPSBmdW5jdGlvbih4LCBwYXJhbXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IGxhbWJkYSA9IHBhcmFtc1swXTsKICAgICAgICAgICAgICAgIHJldHVybiBqU3RhdC5wb2lzc29uLnBkZih4LCBsYW1iZGEpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICJ1bmlmb3JtX2Rpc2NyZXRlIjoKICAgICAgICAgICAgdmFyIHBkZiA9IGZ1bmN0aW9uKHgsIHBhcmFtcykgewogICAgICAgICAgICAgICAgY29uc3QgYSA9IHBhcmFtc1swXTsKICAgICAgICAgICAgICAgIGNvbnN0IGIgPSBwYXJhbXNbMV07CiAgICAgICAgICAgICAgICByZXR1cm4gKHggPCBhIHx8IHggPiBiKSA/IDAgOiAxLyhiLWErMSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIC8vIGNvbnRpbnVvdXMgZGlzdHJpYnV0aW9ucyAKCiAgICAgICAgY2FzZSAiYmV0YSI6CiAgICAgICAgICAgIHZhciBwZGYgPSBmdW5jdGlvbih4LCBwYXJhbXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IGFscGhhID0gcGFyYW1zWzBdOwogICAgICAgICAgICAgICAgY29uc3QgYmV0YSA9IHBhcmFtc1sxXTsKICAgICAgICAgICAgICAgIHJldHVybiBqU3RhdC5iZXRhLnBkZih4LCBhbHBoYSwgYmV0YSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIGNhc2UgImNoaXNxdWFyZSI6CiAgICAgICAgICAgIHZhciBwZGYgPSBmdW5jdGlvbih4LCBwYXJhbXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IGRvZiA9IHBhcmFtc1swXTsKICAgICAgICAgICAgICAgIHJldHVybiBqU3RhdC5jaGlzcXVhcmUucGRmKHgsIGRvZik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIAogICAgICAgIGNhc2UgImV4cG9uZW50aWFsIjogCiAgICAgICAgICAgIHZhciBwZGYgPSBmdW5jdGlvbih4LCBwYXJhbXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IGxhbWJkYSA9IHBhcmFtc1swXTsKICAgICAgICAgICAgICAgIHJldHVybiBqU3RhdC5leHBvbmVudGlhbC5wZGYoeCwgbGFtYmRhKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKCiAgICAgICAgY2FzZSAiY2VudHJhbEYiOgogICAgICAgICAgICB2YXIgcGRmID0gZnVuY3Rpb24oeCwgcGFyYW1zKSB7CiAgICAgICAgICAgICAgICBjb25zdCBkMSA9IHBhcmFtc1swXTsKICAgICAgICAgICAgICAgIGNvbnN0IGQyID0gcGFyYW1zWzFdOwogICAgICAgICAgICAgICAgcmV0dXJuIGpTdGF0LmNlbnRyYWxGLnBkZih4LCBkMSwgZDIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICJnYW1tYSI6CiAgICAgICAgICAgIHZhciBwZGYgPSBmdW5jdGlvbih4LCBwYXJhbXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IHNoYXBlID0gcGFyYW1zWzBdOwogICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSBwYXJhbXNbMV07CiAgICAgICAgICAgICAgICByZXR1cm4galN0YXQuZ2FtbWEucGRmKHgsIHNoYXBlLCBzY2FsZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIGNhc2UgImxvZ25vcm1hbCI6CiAgICAgICAgICAgIHZhciBwZGYgPSBmdW5jdGlvbih4LCBwYXJhbXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IG11ID0gcGFyYW1zWzBdOwogICAgICAgICAgICAgICAgY29uc3Qgc2lnbWEgPSBwYXJhbXNbMV07CiAgICAgICAgICAgICAgICByZXR1cm4galN0YXQubG9nbm9ybWFsLnBkZih4LCBtdSwgc2lnbWEpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICJub3JtYWwiOgogICAgICAgICAgICB2YXIgcGRmID0gZnVuY3Rpb24oeCwgcGFyYW1zKSB7CiAgICAgICAgICAgICAgICBjb25zdCBtdSA9IHBhcmFtc1swXTsKICAgICAgICAgICAgICAgIGNvbnN0IHNpZ21hID0gcGFyYW1zWzFdOwogICAgICAgICAgICAgICAgcmV0dXJuIGpTdGF0Lm5vcm1hbC5wZGYoeCwgbXUsIHNpZ21hKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKCiAgICAgICAgY2FzZSAicGFyZXRvIjoKICAgICAgICAgICAgdmFyIHBkZiA9IGZ1bmN0aW9uKHgsIHBhcmFtcykgewogICAgICAgICAgICAgICAgY29uc3QgeG0gPSBwYXJhbXNbMF07CiAgICAgICAgICAgICAgICBjb25zdCBzaGFwZSA9IHBhcmFtc1sxXTsKICAgICAgICAgICAgICAgIHJldHVybiBqU3RhdC5wYXJldG8ucGRmKHgsIHhtLCBzaGFwZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIGNhc2UgInJheWxlaWdoIjogCiAgICAgICAgICAgIHZhciBwZGYgPSBmdW5jdGlvbih4LCBwYXJhbXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IHNpZ21hID0gcGFyYW1zWzBdOwogICAgICAgICAgICAgICAgcmV0dXJuICh4ID49IDApID8geC9NYXRoLnBvdyhzaWdtYSwyKSpNYXRoLmV4cCgtTWF0aC5wb3coeCwyKS8yL01hdGgucG93KHNpZ21hLDIpKSA6IDA7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIGNhc2UgInN0dWRlbnR0IjoKICAgICAgICAgICAgdmFyIHBkZiA9IGZ1bmN0aW9uKHgsIHBhcmFtcykgewogICAgICAgICAgICAgICAgY29uc3QgZG9mID0gcGFyYW1zWzBdOwogICAgICAgICAgICAgICAgcmV0dXJuIGpTdGF0LnN0dWRlbnR0LnBkZih4LCBkb2YpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICJ0cmlhbmd1bGFyIjoKICAgICAgICAgICAgdmFyIHBkZiA9IGZ1bmN0aW9uKHgsIHBhcmFtcykgewogICAgICAgICAgICAgICAgY29uc3QgYSA9IHBhcmFtc1swXTsKICAgICAgICAgICAgICAgIGNvbnN0IGIgPSBwYXJhbXNbMV07CiAgICAgICAgICAgICAgICBjb25zdCBjID0gcGFyYW1zWzJdOwogICAgICAgICAgICAgICAgcmV0dXJuIGpTdGF0LnRyaWFuZ3VsYXIucGRmKHgsIGEsIGIsIGMpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICJ1bmlmb3JtIjoKICAgICAgICAgICAgdmFyIHBkZiA9IGZ1bmN0aW9uKHgsIHBhcmFtcykgewogICAgICAgICAgICAgICAgY29uc3QgYSA9IHBhcmFtc1swXTsKICAgICAgICAgICAgICAgIGNvbnN0IGIgPSBwYXJhbXNbMV07CiAgICAgICAgICAgICAgICByZXR1cm4galN0YXQudW5pZm9ybS5wZGYoeCwgYSwgYik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIGNhc2UgIndlaWJ1bGwiOgogICAgICAgICAgICB2YXIgcGRmID0gZnVuY3Rpb24oeCwgcGFyYW1zKSB7CiAgICAgICAgICAgICAgICBjb25zdCBzaGFwZSA9IHBhcmFtc1swXTsKICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlID0gcGFyYW1zWzFdOwogICAgICAgICAgICAgICAgcmV0dXJuIGpTdGF0LndlaWJ1bGwucGRmKHgsIHNjYWxlLCBzaGFwZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICB9CgogICAgLy8gZ2VuZXJhdGluZyBkYXRhIGZyb20gdGhlIHByb2JhYmlsaXR5IGZ1bmN0aW9uIChwZGYpCiAgICB2YXIgZGF0YSA9IFtdOwogICAgdmFyIHN0YXJ0LCBzdG9wLCBzdGVwOwoKICAgIGlmIChkaXN0X3R5cGUgPT0gImNvbnRpbnVvdXMiKSB7CgogICAgICAgIHN0ZXAgPSAoeFJhbmdlWzFdIC0geFJhbmdlWzBdKSAvIDUwMDsKICAgICAgICBzdGFydCA9IHhSYW5nZVswXSArIHN0ZXA7CiAgICAgICAgc3RvcCA9IHhSYW5nZVsxXSArIHN0ZXAgKiAyOwogICAgICAgIAogICAgfQoKICAgIGVsc2UgaWYgKGRpc3RfdHlwZSA9PSAiZGlzY3JldGUiKSB7CgogICAgICAgIHN0YXJ0ID0geFJhbmdlWzBdOwogICAgICAgIHN0b3AgPSB4UmFuZ2VbMV0gKyAxOwogICAgICAgIHN0ZXAgPSAxOwogICAgfQoKICAgIGlmIChkaXN0X25hbWUgPT0gImJlbmZvcmQiKSB7CiAgICAgICAgLy8gc3RhcnQgPSAxOwogICAgICAgIGZvciAobGV0IHggPSBzdGFydDsgeCA8IHN0b3A7IHggKz0gc3RlcCkgewogICAgICAgICAgICBpZiAoeCA8IDEwKSB7CiAgICAgICAgICAgICAgICBkYXRhLnB1c2goW3gsIHBkZih4LCBwYXJhbXMpXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZiAoeCA9PSAxMCkgewogICAgICAgICAgICAgICAgZGF0YS5wdXNoKFsiQSIsIHBkZih4LCBwYXJhbXMpXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZiAoeCA9PSAxMSkgewogICAgICAgICAgICAgICAgZGF0YS5wdXNoKFsiQiIsIHBkZih4LCBwYXJhbXMpXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZiAoeCA9PSAxMikgewogICAgICAgICAgICAgICAgZGF0YS5wdXNoKFsiQyIsIHBkZih4LCBwYXJhbXMpXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZiAoeCA9PSAxMykgewogICAgICAgICAgICAgICAgZGF0YS5wdXNoKFsiRCIsIHBkZih4LCBwYXJhbXMpXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZiAoeCA9PSAxNCkgewogICAgICAgICAgICAgICAgZGF0YS5wdXNoKFsiRSIsIHBkZih4LCBwYXJhbXMpXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZiAoeCA9PSAxNSkgewogICAgICAgICAgICAgICAgZGF0YS5wdXNoKFsiRiIsIHBkZih4LCBwYXJhbXMpXSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICBlbHNlIHsKICAgICAgICBmb3IgKGxldCB4ID0gc3RhcnQ7IHggPCBzdG9wOyB4ICs9IHN0ZXApIHsgCiAgICAgICAgICAgIGRhdGEucHVzaChbeCwgcGRmKHgsIHBhcmFtcyldKTsKICAgICAgICB9CiAgICB9CgogICAgcmV0dXJuIGRhdGE7Cn0K"></script>
<script src="data:application/javascript;base64,ZnVuY3Rpb24gdXBkYXRlU2ltcGxleChkaXN0X25hbWUsIHBhcmFtcykgewogICAgaWYgKGRpc3RfbmFtZSAhPSAib3JkZXJlZExvZ2l0IikgcmV0dXJuCiAgICBjb25zdCBzaW1wbGV4ID0gdG9TaW1wbGV4KHBhcmFtcy5zbGljZSgxKSk7CiAgICB2YXIgc3BhbnMgPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yQWxsKCJzcGFuLnNpbXBsZXgiKTsKICAgIGZvciAobGV0IGk9MDsgaTxzaW1wbGV4Lmxlbmd0aDsgaSsrKSB7CiAgICAgICAgdmFyIG51bSA9IE1hdGgucm91bmQoMTAwKnNpbXBsZXhbaV0pIC8gMTAwOwogICAgICAgIGlmIChudW0gPT0gMCkgewogICAgICAgICAgICBzcGFuc1tpXS5pbm5lclRleHQgPSAiMC4wMCIKICAgICAgICAgICAgY29udGludWUKICAgICAgICB9CiAgICAgICAgaWYgKG51bSA9PSAxKSB7CiAgICAgICAgICAgIHNwYW5zW2ldLmlubmVyVGV4dCA9ICIxLjAwIgogICAgICAgICAgICBjb250aW51ZQogICAgICAgIH0gICAgCiAgICAgICAgc3BhbnNbaV0uaW5uZXJUZXh0ID0gYCR7bnVtfWAucGFkRW5kKDQsICIwIikKICAgIH0KICAgI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gYmFycyA9IHN2Zy5zZWxlY3RBbGwoImJhciIpCiAgICAgICAgICAgICAgICAuZGF0YShkYXRhKQogICAgICAgICAgICAgICAgLmVudGVyKCkKICAgICAgICAgICAgICAgIC5hcHBlbmQoInJlY3QiKQogICAgICAgICAgICAgICAgLmF0dHIoImNsYXNzIiwgImJhciIpCiAgICAgICAgICAgICAgICAuYXR0cigieCIsIGQgPT4geFNjYWxlKGRbMF0pKQogICAgICAgICAgICAgICAgLmF0dHIoIndpZHRoIiwgeFNjYWxlLmJhbmR3aWR0aCgpKQogICAgICAgICAgICAgICAgLmF0dHIoInkiLCBkID0+IHlTY2FsZShkWzFdKSkKICAgICAgICAgICAgICAgIC5hdHRyKCJoZWlnaHQiLCBkID0+IGlubmVySGVpZ2h0IC0geVNjYWxlKGRbMV0pKTsKCn0KCmZ1bmN0aW9uIG1vdXNlb3Zlcl9iYXJzKCkgewoKICAgIGJhcnMub24oIm1vdXNlb3ZlciIsIGZ1bmN0aW9uKCkgewogICAgICAgIGQzLnNlbGVjdCh0aGlzKQogICAgICAgICAgLnN0eWxlKCJmaWxsIiwgIiNiMzAwMDAiKTsgICAgIC8vIGRhcmsgcmVkCiAgICAgICAgfSkKICAgICAgICAub24oIm1vdXNlb3V0IiwgZnVuY3Rpb24oKSB7CiAgICAgICAgZDMuc2VsZWN0KHRoaXMpCiAgICAgICAgICAuc3R5bGUoImZpbGwiLCAicmVkIik7CiAgICAgICAgfSk7IAp9CgpmdW5jdGlvbiBwbG90X2xpbmUoZGlzdF9uYW1lLCBkaXN0X3R5cGUsIHBhcmFtcywgcmVmPWZhbHNlKSB7CgogICAgdmFyIGRhdGEgPSBnZW5lcmF0ZV9kYXRhKGRpc3RfbmFtZSwgZGlzdF90eXBlLCBwYXJhbXMpOyAKCiAgICB2YXIgbGluZSA9IGQzLmxpbmUoKQogICAgICAgICAgICAgICAgIC54KGQgPT4geFNjYWxlKGRbMF0pKQogICAgICAgICAgICAgICAgIC55KGQgPT4geVNjYWxlKGRbMV0pKTsKCiAgICBpZiAocmVmID09IGZhbHNlKSB7CiAgICAgICAgcGF0aCA9IHN2Zy5hcHBlbmQoJ3BhdGgnKQogICAgICAgICAgICAgICAgICAgIC5hdHRyKCJjbGFzcyIsICJsaW5lIikKICAgICAgICAgICAgICAgICAgICAuZGF0dW0oZGF0YSkKICAgICAgICAgICAgICAgICAgICAuYXR0cigiZCIsIGxpbmUpOwogICAgfQogICAgZWxzZSB7CiAgICAgICAgcGF0aCA9IHN2Zy5hcHBlbmQoJ3BhdGgnKQogICAgICAgICAgICAgICAgICAgIC5hdHRyKCJjbGFzcyIsICJsaW5lX3JlZmVyZW5jZSIpCiAgICAgICAgICAgICAgICAgICAgLmRhdHVtKGRhdGEpCiAgICAgICAgICAgICAgICAgICAgLmF0dHIoImQiLCBsaW5lKTsKICAgIH0KfQoKZnVuY3Rpb24gaW5pdGlhbF90cmFuc2l0aW9uKGRpc3RfbmFtZSwgZGlzdF90eXBlLCBwYXJhbXMpIHsKCiAgICBkMy5zZWxlY3RBbGwoIi5iYXIsIC5iYXItdmFsdWUiKS5yZW1vdmUoKTsgIC8vIGNsZWFyIGNoYXJ0CiAgICBkMy5zZWxlY3RBbGwoIi5tZWFuIikucmVtb3ZlKCk7ICAvLyBjbGVhciBjaGFydAoKICAgIHVwZGF0ZV9jaGFydChkaXN0X25hbWUsIGRpc3RfdHlwZSwgcGFyYW1zKTsKCiAgICBpZiAoZGlzdF90eXBlID09ICJkaXNjcmV0ZSIpIHsKCiAgICAgICAgYmFycy5hdHRyKCJ5IiwgIGlubmVySGVpZ2h0KQogICAgICAgICAgICAuYXR0cigiaGVpZ2h0IiwgMCkKICAgICAgICAgICAgLnRyYW5zaXRpb24oKQogICAgICAgICAgICAuZHVyYXRpb24oNzAwKQogICAgICAgICAgICAuZGVsYXkoKGQsIGkpID0+IGkgKiA1MCkKICAgICAgICAgICAgLmF0dHIoInkiLCBkID0+IHlTY2FsZShkWzFdKSkKICAgICAgICAgICAgLmF0dHIoIm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icmVhazsKICAgICAgICAgICAgY2FzZSAidHJpYW5ndWxhciI6CiAgICAgICAgICAgICAgICB2YXIgYSA9IHBhcmFtc1swXTsKICAgICAgICAgICAgICAgIHZhciBiID0gcGFyYW1zWzFdOwogICAgICAgICAgICAgICAgdmFyIGMgPSBwYXJhbXNbMl07CiAgICAgICAgICAgICAgICB2YXIgeF9haWQgPSBjOwogICAgICAgICAgICAgICAgdmFyIGhlaWdodF9haWQgPSBqU3RhdC50cmlhbmd1bGFyLnBkZih4X2FpZCwgYSwgYiwgYyk7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAiZXhwb25lbnRpYWwiOiAKICAgICAgICAgICAgICAgIHZhciBsYW1iZGEgPSBwYXJhbXNbMF07ICAKICAgICAgICAgICAgICAgIHZhciB4X2FpZCA9IDEvbGFtYmRhOwogICAgICAgICAgICAgICAgdmFyIGhlaWdodF9haWQgPSBqU3RhdC5leHBvbmVudGlhbC5wZGYoeF9haWQsIGxhbWJkYSk7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICB9CgogICAgc3ZnLmFwcGVuZCgibGluZSIpCiAgICAgICAgLmF0dHIoImNsYXNzIiwgIm1lYW4iKQogICAgICAgIC5hdHRyKCJ4MSIsIHhTY2FsZSh4X2FpZCkpCiAgICAgICAgLmF0dHIoInkxIiwgeVNjYWxlKGhlaWdodF9haWQpKzQpICAvLyBhZGQgYSBmZXcgcGl4ZWxzIHRvIGF2b2lkIG92ZXJsYXBwaW5nCiAgICAgICAgLmF0dHIoIngyIiwgeFNjYWxlKHhfYWlkKSkKICAgICAgICAuYXR0cigieTIiLCBpbm5lckhlaWdodCk7CiAgICB9Cn0K"></script>
<script src="data:application/javascript;base64,aWYgKHNsaWRlcl9jb25maWcgPT0gIjEtc2xpZGVyIikgewoKICAgIHNsaWRlcl8wLm5vVWlTbGlkZXIub24oJ3VwZGF0ZScsIGZ1bmN0aW9uKCkgewogICAgICAgIHBhcmFtc1swXSA9ICtzbG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