diff options
Diffstat (limited to 'frontend')
19 files changed, 8335 insertions, 6 deletions
diff --git a/frontend/elm-stuff/0.19.1/Cart.elmi b/frontend/elm-stuff/0.19.1/Cart.elmi deleted file mode 100644 index 60bb740..0000000 --- a/frontend/elm-stuff/0.19.1/Cart.elmi +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/elm-stuff/0.19.1/Cart.elmo b/frontend/elm-stuff/0.19.1/Cart.elmo deleted file mode 100644 index 0500a15..0000000 --- a/frontend/elm-stuff/0.19.1/Cart.elmo +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/elm-stuff/0.19.1/Catalog.elmi b/frontend/elm-stuff/0.19.1/Catalog.elmi deleted file mode 100644 index 0610f11..0000000 --- a/frontend/elm-stuff/0.19.1/Catalog.elmi +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/elm-stuff/0.19.1/Catalog.elmo b/frontend/elm-stuff/0.19.1/Catalog.elmo deleted file mode 100644 index c5146fc..0000000 --- a/frontend/elm-stuff/0.19.1/Catalog.elmo +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/elm-stuff/0.19.1/Login.elmi b/frontend/elm-stuff/0.19.1/Login.elmi deleted file mode 100644 index 75c4629..0000000 --- a/frontend/elm-stuff/0.19.1/Login.elmi +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/elm-stuff/0.19.1/Login.elmo b/frontend/elm-stuff/0.19.1/Login.elmo deleted file mode 100644 index 9a173e3..0000000 --- a/frontend/elm-stuff/0.19.1/Login.elmo +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/elm-stuff/0.19.1/Main.elmi b/frontend/elm-stuff/0.19.1/Main.elmi deleted file mode 100644 index 295ad17..0000000 --- a/frontend/elm-stuff/0.19.1/Main.elmi +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/elm-stuff/0.19.1/Main.elmo b/frontend/elm-stuff/0.19.1/Main.elmo deleted file mode 100644 index 0dc3269..0000000 --- a/frontend/elm-stuff/0.19.1/Main.elmo +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/elm-stuff/0.19.1/Product.elmi b/frontend/elm-stuff/0.19.1/Product.elmi deleted file mode 100644 index 396a174..0000000 --- a/frontend/elm-stuff/0.19.1/Product.elmi +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/elm-stuff/0.19.1/Product.elmo b/frontend/elm-stuff/0.19.1/Product.elmo deleted file mode 100644 index c387bed..0000000 --- a/frontend/elm-stuff/0.19.1/Product.elmo +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/elm-stuff/0.19.1/Signup.elmi b/frontend/elm-stuff/0.19.1/Signup.elmi deleted file mode 100644 index 190d9de..0000000 --- a/frontend/elm-stuff/0.19.1/Signup.elmi +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/elm-stuff/0.19.1/Signup.elmo b/frontend/elm-stuff/0.19.1/Signup.elmo deleted file mode 100644 index bcdb43d..0000000 --- a/frontend/elm-stuff/0.19.1/Signup.elmo +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/elm-stuff/0.19.1/d.dat b/frontend/elm-stuff/0.19.1/d.dat deleted file mode 100644 index 244afff..0000000 --- a/frontend/elm-stuff/0.19.1/d.dat +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/elm-stuff/0.19.1/i.dat b/frontend/elm-stuff/0.19.1/i.dat deleted file mode 100644 index d1d1ac1..0000000 --- a/frontend/elm-stuff/0.19.1/i.dat +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/elm-stuff/0.19.1/lock b/frontend/elm-stuff/0.19.1/lock deleted file mode 100644 index e69de29..0000000 --- a/frontend/elm-stuff/0.19.1/lock +++ /dev/null | |||
diff --git a/frontend/elm-stuff/0.19.1/o.dat b/frontend/elm-stuff/0.19.1/o.dat deleted file mode 100644 index f25f55b..0000000 --- a/frontend/elm-stuff/0.19.1/o.dat +++ /dev/null | |||
Binary files differ | |||
diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 0000000..be32ef3 --- /dev/null +++ b/frontend/index.html | |||
@@ -0,0 +1,20 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <html> | ||
3 | <head> | ||
4 | <meta charset="utf-8"> | ||
5 | <title>hello-world</title> | ||
6 | </head> | ||
7 | <body> | ||
8 | <script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script> | ||
9 | <div id="elm" /> | ||
10 | <model-viewer | ||
11 | src="https://poly.googleusercontent.com/downloads/c/fp/1606938083820086/9ycLAR71SmR/7wwOehn8nNN/Bedroom.gltf" | ||
12 | ios-src="https://poly.googleusercontent.com/downloads/c/fp/1606938083820086/9ycLAR71SmR/cTuWg1jk4jo/Bedroom.usdz" | ||
13 | alt="Bedroom by Poly by Google" | ||
14 | background-color="##607d8b" | ||
15 | camera-controls | ||
16 | auto-rotate > | ||
17 | </model-viewer> | ||
18 | </body> | ||
19 | </html> | ||
20 | |||
diff --git a/frontend/main.js b/frontend/main.js new file mode 100644 index 0000000..8224ee0 --- /dev/null +++ b/frontend/main.js | |||
@@ -0,0 +1,8305 @@ | |||
1 | (function(scope){ | ||
2 | 'use strict'; | ||
3 | |||
4 | function F(arity, fun, wrapper) { | ||
5 | wrapper.a = arity; | ||
6 | wrapper.f = fun; | ||
7 | return wrapper; | ||
8 | } | ||
9 | |||
10 | function F2(fun) { | ||
11 | return F(2, fun, function(a) { return function(b) { return fun(a,b); }; }) | ||
12 | } | ||
13 | function F3(fun) { | ||
14 | return F(3, fun, function(a) { | ||
15 | return function(b) { return function(c) { return fun(a, b, c); }; }; | ||
16 | }); | ||
17 | } | ||
18 | function F4(fun) { | ||
19 | return F(4, fun, function(a) { return function(b) { return function(c) { | ||
20 | return function(d) { return fun(a, b, c, d); }; }; }; | ||
21 | }); | ||
22 | } | ||
23 | function F5(fun) { | ||
24 | return F(5, fun, function(a) { return function(b) { return function(c) { | ||
25 | return function(d) { return function(e) { return fun(a, b, c, d, e); }; }; }; }; | ||
26 | }); | ||
27 | } | ||
28 | function F6(fun) { | ||
29 | return F(6, fun, function(a) { return function(b) { return function(c) { | ||
30 | return function(d) { return function(e) { return function(f) { | ||
31 | return fun(a, b, c, d, e, f); }; }; }; }; }; | ||
32 | }); | ||
33 | } | ||
34 | function F7(fun) { | ||
35 | return F(7, fun, function(a) { return function(b) { return function(c) { | ||
36 | return function(d) { return function(e) { return function(f) { | ||
37 | return function(g) { return fun(a, b, c, d, e, f, g); }; }; }; }; }; }; | ||
38 | }); | ||
39 | } | ||
40 | function F8(fun) { | ||
41 | return F(8, fun, function(a) { return function(b) { return function(c) { | ||
42 | return function(d) { return function(e) { return function(f) { | ||
43 | return function(g) { return function(h) { | ||
44 | return fun(a, b, c, d, e, f, g, h); }; }; }; }; }; }; }; | ||
45 | }); | ||
46 | } | ||
47 | function F9(fun) { | ||
48 | return F(9, fun, function(a) { return function(b) { return function(c) { | ||
49 | return function(d) { return function(e) { return function(f) { | ||
50 | return function(g) { return function(h) { return function(i) { | ||
51 | return fun(a, b, c, d, e, f, g, h, i); }; }; }; }; }; }; }; }; | ||
52 | }); | ||
53 | } | ||
54 | |||
55 | function A2(fun, a, b) { | ||
56 | return fun.a === 2 ? fun.f(a, b) : fun(a)(b); | ||
57 | } | ||
58 | function A3(fun, a, b, c) { | ||
59 | return fun.a === 3 ? fun.f(a, b, c) : fun(a)(b)(c); | ||
60 | } | ||
61 | function A4(fun, a, b, c, d) { | ||
62 | return fun.a === 4 ? fun.f(a, b, c, d) : fun(a)(b)(c)(d); | ||
63 | } | ||
64 | function A5(fun, a, b, c, d, e) { | ||
65 | return fun.a === 5 ? fun.f(a, b, c, d, e) : fun(a)(b)(c)(d)(e); | ||
66 | } | ||
67 | function A6(fun, a, b, c, d, e, f) { | ||
68 | return fun.a === 6 ? fun.f(a, b, c, d, e, f) : fun(a)(b)(c)(d)(e)(f); | ||
69 | } | ||
70 | function A7(fun, a, b, c, d, e, f, g) { | ||
71 | return fun.a === 7 ? fun.f(a, b, c, d, e, f, g) : fun(a)(b)(c)(d)(e)(f)(g); | ||
72 | } | ||
73 | function A8(fun, a, b, c, d, e, f, g, h) { | ||
74 | return fun.a === 8 ? fun.f(a, b, c, d, e, f, g, h) : fun(a)(b)(c)(d)(e)(f)(g)(h); | ||
75 | } | ||
76 | function A9(fun, a, b, c, d, e, f, g, h, i) { | ||
77 | return fun.a === 9 ? fun.f(a, b, c, d, e, f, g, h, i) : fun(a)(b)(c)(d)(e)(f)(g)(h)(i); | ||
78 | } | ||
79 | |||
80 | console.warn('Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.'); | ||
81 | |||
82 | |||
83 | // EQUALITY | ||
84 | |||
85 | function _Utils_eq(x, y) | ||
86 | { | ||
87 | for ( | ||
88 | var pair, stack = [], isEqual = _Utils_eqHelp(x, y, 0, stack); | ||
89 | isEqual && (pair = stack.pop()); | ||
90 | isEqual = _Utils_eqHelp(pair.a, pair.b, 0, stack) | ||
91 | ) | ||
92 | {} | ||
93 | |||
94 | return isEqual; | ||
95 | } | ||
96 | |||
97 | function _Utils_eqHelp(x, y, depth, stack) | ||
98 | { | ||
99 | if (x === y) | ||
100 | { | ||
101 | return true; | ||
102 | } | ||
103 | |||
104 | if (typeof x !== 'object' || x === null || y === null) | ||
105 | { | ||
106 | typeof x === 'function' && _Debug_crash(5); | ||
107 | return false; | ||
108 | } | ||
109 | |||
110 | if (depth > 100) | ||
111 | { | ||
112 | stack.push(_Utils_Tuple2(x,y)); | ||
113 | return true; | ||
114 | } | ||
115 | |||
116 | /**/ | ||
117 | if (x.$ === 'Set_elm_builtin') | ||
118 | { | ||
119 | x = $elm$core$Set$toList(x); | ||
120 | y = $elm$core$Set$toList(y); | ||
121 | } | ||
122 | if (x.$ === 'RBNode_elm_builtin' || x.$ === 'RBEmpty_elm_builtin') | ||
123 | { | ||
124 | x = $elm$core$Dict$toList(x); | ||
125 | y = $elm$core$Dict$toList(y); | ||
126 | } | ||
127 | //*/ | ||
128 | |||
129 | /**_UNUSED/ | ||
130 | if (x.$ < 0) | ||
131 | { | ||
132 | x = $elm$core$Dict$toList(x); | ||
133 | y = $elm$core$Dict$toList(y); | ||
134 | } | ||
135 | //*/ | ||
136 | |||
137 | for (var key in x) | ||
138 | { | ||
139 | if (!_Utils_eqHelp(x[key], y[key], depth + 1, stack)) | ||
140 | { | ||
141 | return false; | ||
142 | } | ||
143 | } | ||
144 | return true; | ||
145 | } | ||
146 | |||
147 | var _Utils_equal = F2(_Utils_eq); | ||
148 | var _Utils_notEqual = F2(function(a, b) { return !_Utils_eq(a,b); }); | ||
149 | |||
150 | |||
151 | |||
152 | // COMPARISONS | ||
153 | |||
154 | // Code in Generate/JavaScript.hs, Basics.js, and List.js depends on | ||
155 | // the particular integer values assigned to LT, EQ, and GT. | ||
156 | |||
157 | function _Utils_cmp(x, y, ord) | ||
158 | { | ||
159 | if (typeof x !== 'object') | ||
160 | { | ||
161 | return x === y ? /*EQ*/ 0 : x < y ? /*LT*/ -1 : /*GT*/ 1; | ||
162 | } | ||
163 | |||
164 | /**/ | ||
165 | if (x instanceof String) | ||
166 | { | ||
167 | var a = x.valueOf(); | ||
168 | var b = y.valueOf(); | ||
169 | return a === b ? 0 : a < b ? -1 : 1; | ||
170 | } | ||
171 | //*/ | ||
172 | |||
173 | /**_UNUSED/ | ||
174 | if (typeof x.$ === 'undefined') | ||
175 | //*/ | ||
176 | /**/ | ||
177 | if (x.$[0] === '#') | ||
178 | //*/ | ||
179 | { | ||
180 | return (ord = _Utils_cmp(x.a, y.a)) | ||
181 | ? ord | ||
182 | : (ord = _Utils_cmp(x.b, y.b)) | ||
183 | ? ord | ||
184 | : _Utils_cmp(x.c, y.c); | ||
185 | } | ||
186 | |||
187 | // traverse conses until end of a list or a mismatch | ||
188 | for (; x.b && y.b && !(ord = _Utils_cmp(x.a, y.a)); x = x.b, y = y.b) {} // WHILE_CONSES | ||
189 | return ord || (x.b ? /*GT*/ 1 : y.b ? /*LT*/ -1 : /*EQ*/ 0); | ||
190 | } | ||
191 | |||
192 | var _Utils_lt = F2(function(a, b) { return _Utils_cmp(a, b) < 0; }); | ||
193 | var _Utils_le = F2(function(a, b) { return _Utils_cmp(a, b) < 1; }); | ||
194 | var _Utils_gt = F2(function(a, b) { return _Utils_cmp(a, b) > 0; }); | ||
195 | var _Utils_ge = F2(function(a, b) { return _Utils_cmp(a, b) >= 0; }); | ||
196 | |||
197 | var _Utils_compare = F2(function(x, y) | ||
198 | { | ||
199 | var n = _Utils_cmp(x, y); | ||
200 | return n < 0 ? $elm$core$Basics$LT : n ? $elm$core$Basics$GT : $elm$core$Basics$EQ; | ||
201 | }); | ||
202 | |||
203 | |||
204 | // COMMON VALUES | ||
205 | |||
206 | var _Utils_Tuple0_UNUSED = 0; | ||
207 | var _Utils_Tuple0 = { $: '#0' }; | ||
208 | |||
209 | function _Utils_Tuple2_UNUSED(a, b) { return { a: a, b: b }; } | ||
210 | function _Utils_Tuple2(a, b) { return { $: '#2', a: a, b: b }; } | ||
211 | |||
212 | function _Utils_Tuple3_UNUSED(a, b, c) { return { a: a, b: b, c: c }; } | ||
213 | function _Utils_Tuple3(a, b, c) { return { $: '#3', a: a, b: b, c: c }; } | ||
214 | |||
215 | function _Utils_chr_UNUSED(c) { return c; } | ||
216 | function _Utils_chr(c) { return new String(c); } | ||
217 | |||
218 | |||
219 | // RECORDS | ||
220 | |||
221 | function _Utils_update(oldRecord, updatedFields) | ||
222 | { | ||
223 | var newRecord = {}; | ||
224 | |||
225 | for (var key in oldRecord) | ||
226 | { | ||
227 | newRecord[key] = oldRecord[key]; | ||
228 | } | ||
229 | |||
230 | for (var key in updatedFields) | ||
231 | { | ||
232 | newRecord[key] = updatedFields[key]; | ||
233 | } | ||
234 | |||
235 | return newRecord; | ||
236 | } | ||
237 | |||
238 | |||
239 | // APPEND | ||
240 | |||
241 | var _Utils_append = F2(_Utils_ap); | ||
242 | |||
243 | function _Utils_ap(xs, ys) | ||
244 | { | ||
245 | // append Strings | ||
246 | if (typeof xs === 'string') | ||
247 | { | ||
248 | return xs + ys; | ||
249 | } | ||
250 | |||
251 | // append Lists | ||
252 | if (!xs.b) | ||
253 | { | ||
254 | return ys; | ||
255 | } | ||
256 | var root = _List_Cons(xs.a, ys); | ||
257 | xs = xs.b | ||
258 | for (var curr = root; xs.b; xs = xs.b) // WHILE_CONS | ||
259 | { | ||
260 | curr = curr.b = _List_Cons(xs.a, ys); | ||
261 | } | ||
262 | return root; | ||
263 | } | ||
264 | |||
265 | |||
266 | |||
267 | var _List_Nil_UNUSED = { $: 0 }; | ||
268 | var _List_Nil = { $: '[]' }; | ||
269 | |||
270 | function _List_Cons_UNUSED(hd, tl) { return { $: 1, a: hd, b: tl }; } | ||
271 | function _List_Cons(hd, tl) { return { $: '::', a: hd, b: tl }; } | ||
272 | |||
273 | |||
274 | var _List_cons = F2(_List_Cons); | ||
275 | |||
276 | function _List_fromArray(arr) | ||
277 | { | ||
278 | var out = _List_Nil; | ||
279 | for (var i = arr.length; i--; ) | ||
280 | { | ||
281 | out = _List_Cons(arr[i], out); | ||
282 | } | ||
283 | return out; | ||
284 | } | ||
285 | |||
286 | function _List_toArray(xs) | ||
287 | { | ||
288 | for (var out = []; xs.b; xs = xs.b) // WHILE_CONS | ||
289 | { | ||
290 | out.push(xs.a); | ||
291 | } | ||
292 | return out; | ||
293 | } | ||
294 | |||
295 | var _List_map2 = F3(function(f, xs, ys) | ||
296 | { | ||
297 | for (var arr = []; xs.b && ys.b; xs = xs.b, ys = ys.b) // WHILE_CONSES | ||
298 | { | ||
299 | arr.push(A2(f, xs.a, ys.a)); | ||
300 | } | ||
301 | return _List_fromArray(arr); | ||
302 | }); | ||
303 | |||
304 | var _List_map3 = F4(function(f, xs, ys, zs) | ||
305 | { | ||
306 | for (var arr = []; xs.b && ys.b && zs.b; xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES | ||
307 | { | ||
308 | arr.push(A3(f, xs.a, ys.a, zs.a)); | ||
309 | } | ||
310 | return _List_fromArray(arr); | ||
311 | }); | ||
312 | |||
313 | var _List_map4 = F5(function(f, ws, xs, ys, zs) | ||
314 | { | ||
315 | for (var arr = []; ws.b && xs.b && ys.b && zs.b; ws = ws.b, xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES | ||
316 | { | ||
317 | arr.push(A4(f, ws.a, xs.a, ys.a, zs.a)); | ||
318 | } | ||
319 | return _List_fromArray(arr); | ||
320 | }); | ||
321 | |||
322 | var _List_map5 = F6(function(f, vs, ws, xs, ys, zs) | ||
323 | { | ||
324 | for (var arr = []; vs.b && ws.b && xs.b && ys.b && zs.b; vs = vs.b, ws = ws.b, xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES | ||
325 | { | ||
326 | arr.push(A5(f, vs.a, ws.a, xs.a, ys.a, zs.a)); | ||
327 | } | ||
328 | return _List_fromArray(arr); | ||
329 | }); | ||
330 | |||
331 | var _List_sortBy = F2(function(f, xs) | ||
332 | { | ||
333 | return _List_fromArray(_List_toArray(xs).sort(function(a, b) { | ||
334 | return _Utils_cmp(f(a), f(b)); | ||
335 | })); | ||
336 | }); | ||
337 | |||
338 | var _List_sortWith = F2(function(f, xs) | ||
339 | { | ||
340 | return _List_fromArray(_List_toArray(xs).sort(function(a, b) { | ||
341 | var ord = A2(f, a, b); | ||
342 | return ord === $elm$core$Basics$EQ ? 0 : ord === $elm$core$Basics$LT ? -1 : 1; | ||
343 | })); | ||
344 | }); | ||
345 | |||
346 | |||
347 | |||
348 | var _JsArray_empty = []; | ||
349 | |||
350 | function _JsArray_singleton(value) | ||
351 | { | ||
352 | return [value]; | ||
353 | } | ||
354 | |||
355 | function _JsArray_length(array) | ||
356 | { | ||
357 | return array.length; | ||
358 | } | ||
359 | |||
360 | var _JsArray_initialize = F3(function(size, offset, func) | ||
361 | { | ||
362 | var result = new Array(size); | ||
363 | |||
364 | for (var i = 0; i < size; i++) | ||
365 | { | ||
366 | result[i] = func(offset + i); | ||
367 | } | ||
368 | |||
369 | return result; | ||
370 | }); | ||
371 | |||
372 | var _JsArray_initializeFromList = F2(function (max, ls) | ||
373 | { | ||
374 | var result = new Array(max); | ||
375 | |||
376 | for (var i = 0; i < max && ls.b; i++) | ||
377 | { | ||
378 | result[i] = ls.a; | ||
379 | ls = ls.b; | ||
380 | } | ||
381 | |||
382 | result.length = i; | ||
383 | return _Utils_Tuple2(result, ls); | ||
384 | }); | ||
385 | |||
386 | var _JsArray_unsafeGet = F2(function(index, array) | ||
387 | { | ||
388 | return array[index]; | ||
389 | }); | ||
390 | |||
391 | var _JsArray_unsafeSet = F3(function(index, value, array) | ||
392 | { | ||
393 | var length = array.length; | ||
394 | var result = new Array(length); | ||
395 | |||
396 | for (var i = 0; i < length; i++) | ||
397 | { | ||
398 | result[i] = array[i]; | ||
399 | } | ||
400 | |||
401 | result[index] = value; | ||
402 | return result; | ||
403 | }); | ||
404 | |||
405 | var _JsArray_push = F2(function(value, array) | ||
406 | { | ||
407 | var length = array.length; | ||
408 | var result = new Array(length + 1); | ||
409 | |||
410 | for (var i = 0; i < length; i++) | ||
411 | { | ||
412 | result[i] = array[i]; | ||
413 | } | ||
414 | |||
415 | result[length] = value; | ||
416 | return result; | ||
417 | }); | ||
418 | |||
419 | var _JsArray_foldl = F3(function(func, acc, array) | ||
420 | { | ||
421 | var length = array.length; | ||
422 | |||
423 | for (var i = 0; i < length; i++) | ||
424 | { | ||
425 | acc = A2(func, array[i], acc); | ||
426 | } | ||
427 | |||
428 | return acc; | ||
429 | }); | ||
430 | |||
431 | var _JsArray_foldr = F3(function(func, acc, array) | ||
432 | { | ||
433 | for (var i = array.length - 1; i >= 0; i--) | ||
434 | { | ||
435 | acc = A2(func, array[i], acc); | ||
436 | } | ||
437 | |||
438 | return acc; | ||
439 | }); | ||
440 | |||
441 | var _JsArray_map = F2(function(func, array) | ||
442 | { | ||
443 | var length = array.length; | ||
444 | var result = new Array(length); | ||
445 | |||
446 | for (var i = 0; i < length; i++) | ||
447 | { | ||
448 | result[i] = func(array[i]); | ||
449 | } | ||
450 | |||
451 | return result; | ||
452 | }); | ||
453 | |||
454 | var _JsArray_indexedMap = F3(function(func, offset, array) | ||
455 | { | ||
456 | var length = array.length; | ||
457 | var result = new Array(length); | ||
458 | |||
459 | for (var i = 0; i < length; i++) | ||
460 | { | ||
461 | result[i] = A2(func, offset + i, array[i]); | ||
462 | } | ||
463 | |||
464 | return result; | ||
465 | }); | ||
466 | |||
467 | var _JsArray_slice = F3(function(from, to, array) | ||
468 | { | ||
469 | return array.slice(from, to); | ||
470 | }); | ||
471 | |||
472 | var _JsArray_appendN = F3(function(n, dest, source) | ||
473 | { | ||
474 | var destLen = dest.length; | ||
475 | var itemsToCopy = n - destLen; | ||
476 | |||
477 | if (itemsToCopy > source.length) | ||
478 | { | ||
479 | itemsToCopy = source.length; | ||
480 | } | ||
481 | |||
482 | var size = destLen + itemsToCopy; | ||
483 | var result = new Array(size); | ||
484 | |||
485 | for (var i = 0; i < destLen; i++) | ||
486 | { | ||
487 | result[i] = dest[i]; | ||
488 | } | ||
489 | |||
490 | for (var i = 0; i < itemsToCopy; i++) | ||
491 | { | ||
492 | result[i + destLen] = source[i]; | ||
493 | } | ||
494 | |||
495 | return result; | ||
496 | }); | ||
497 | |||
498 | |||
499 | |||
500 | // LOG | ||
501 | |||
502 | var _Debug_log_UNUSED = F2(function(tag, value) | ||
503 | { | ||
504 | return value; | ||
505 | }); | ||
506 | |||
507 | var _Debug_log = F2(function(tag, value) | ||
508 | { | ||
509 | console.log(tag + ': ' + _Debug_toString(value)); | ||
510 | return value; | ||
511 | }); | ||
512 | |||
513 | |||
514 | // TODOS | ||
515 | |||
516 | function _Debug_todo(moduleName, region) | ||
517 | { | ||
518 | return function(message) { | ||
519 | _Debug_crash(8, moduleName, region, message); | ||
520 | }; | ||
521 | } | ||
522 | |||
523 | function _Debug_todoCase(moduleName, region, value) | ||
524 | { | ||
525 | return function(message) { | ||
526 | _Debug_crash(9, moduleName, region, value, message); | ||
527 | }; | ||
528 | } | ||
529 | |||
530 | |||
531 | // TO STRING | ||
532 | |||
533 | function _Debug_toString_UNUSED(value) | ||
534 | { | ||
535 | return '<internals>'; | ||
536 | } | ||
537 | |||
538 | function _Debug_toString(value) | ||
539 | { | ||
540 | return _Debug_toAnsiString(false, value); | ||
541 | } | ||
542 | |||
543 | function _Debug_toAnsiString(ansi, value) | ||
544 | { | ||
545 | if (typeof value === 'function') | ||
546 | { | ||
547 | return _Debug_internalColor(ansi, '<function>'); | ||
548 | } | ||
549 | |||
550 | if (typeof value === 'boolean') | ||
551 | { | ||
552 | return _Debug_ctorColor(ansi, value ? 'True' : 'False'); | ||
553 | } | ||
554 | |||
555 | if (typeof value === 'number') | ||
556 | { | ||
557 | return _Debug_numberColor(ansi, value + ''); | ||
558 | } | ||
559 | |||
560 | if (value instanceof String) | ||
561 | { | ||
562 | return _Debug_charColor(ansi, "'" + _Debug_addSlashes(value, true) + "'"); | ||
563 | } | ||
564 | |||
565 | if (typeof value === 'string') | ||
566 | { | ||
567 | return _Debug_stringColor(ansi, '"' + _Debug_addSlashes(value, false) + '"'); | ||
568 | } | ||
569 | |||
570 | if (typeof value === 'object' && '$' in value) | ||
571 | { | ||
572 | var tag = value.$; | ||
573 | |||
574 | if (typeof tag === 'number') | ||
575 | { | ||
576 | return _Debug_internalColor(ansi, '<internals>'); | ||
577 | } | ||
578 | |||
579 | if (tag[0] === '#') | ||
580 | { | ||
581 | var output = []; | ||
582 | for (var k in value) | ||
583 | { | ||
584 | if (k === '$') continue; | ||
585 | output.push(_Debug_toAnsiString(ansi, value[k])); | ||
586 | } | ||
587 | return '(' + output.join(',') + ')'; | ||
588 | } | ||
589 | |||
590 | if (tag === 'Set_elm_builtin') | ||
591 | { | ||
592 | return _Debug_ctorColor(ansi, 'Set') | ||
593 | + _Debug_fadeColor(ansi, '.fromList') + ' ' | ||
594 | + _Debug_toAnsiString(ansi, $elm$core$Set$toList(value)); | ||
595 | } | ||
596 | |||
597 | if (tag === 'RBNode_elm_builtin' || tag === 'RBEmpty_elm_builtin') | ||
598 | { | ||
599 | return _Debug_ctorColor(ansi, 'Dict') | ||
600 | + _Debug_fadeColor(ansi, '.fromList') + ' ' | ||
601 | + _Debug_toAnsiString(ansi, $elm$core$Dict$toList(value)); | ||
602 | } | ||
603 | |||
604 | if (tag === 'Array_elm_builtin') | ||
605 | { | ||
606 | return _Debug_ctorColor(ansi, 'Array') | ||
607 | + _Debug_fadeColor(ansi, '.fromList') + ' ' | ||
608 | + _Debug_toAnsiString(ansi, $elm$core$Array$toList(value)); | ||
609 | } | ||
610 | |||
611 | if (tag === '::' || tag === '[]') | ||
612 | { | ||
613 | var output = '['; | ||
614 | |||
615 | value.b && (output += _Debug_toAnsiString(ansi, value.a), value = value.b) | ||
616 | |||
617 | for (; value.b; value = value.b) // WHILE_CONS | ||
618 | { | ||
619 | output += ',' + _Debug_toAnsiString(ansi, value.a); | ||
620 | } | ||
621 | return output + ']'; | ||
622 | } | ||
623 | |||
624 | var output = ''; | ||
625 | for (var i in value) | ||
626 | { | ||
627 | if (i === '$') continue; | ||
628 | var str = _Debug_toAnsiString(ansi, value[i]); | ||
629 | var c0 = str[0]; | ||
630 | var parenless = c0 === '{' || c0 === '(' || c0 === '[' || c0 === '<' || c0 === '"' || str.indexOf(' ') < 0; | ||
631 | output += ' ' + (parenless ? str : '(' + str + ')'); | ||
632 | } | ||
633 | return _Debug_ctorColor(ansi, tag) + output; | ||
634 | } | ||
635 | |||
636 | if (typeof DataView === 'function' && value instanceof DataView) | ||
637 | { | ||
638 | return _Debug_stringColor(ansi, '<' + value.byteLength + ' bytes>'); | ||
639 | } | ||
640 | |||
641 | if (typeof File !== 'undefined' && value instanceof File) | ||
642 | { | ||
643 | return _Debug_internalColor(ansi, '<' + value.name + '>'); | ||
644 | } | ||
645 | |||
646 | if (typeof value === 'object') | ||
647 | { | ||
648 | var output = []; | ||
649 | for (var key in value) | ||
650 | { | ||
651 | var field = key[0] === '_' ? key.slice(1) : key; | ||
652 | output.push(_Debug_fadeColor(ansi, field) + ' = ' + _Debug_toAnsiString(ansi, value[key])); | ||
653 | } | ||
654 | if (output.length === 0) | ||
655 | { | ||
656 | return '{}'; | ||
657 | } | ||
658 | return '{ ' + output.join(', ') + ' }'; | ||
659 | } | ||
660 | |||
661 | return _Debug_internalColor(ansi, '<internals>'); | ||
662 | } | ||
663 | |||
664 | function _Debug_addSlashes(str, isChar) | ||
665 | { | ||
666 | var s = str | ||
667 | .replace(/\\/g, '\\\\') | ||
668 | .replace(/\n/g, '\\n') | ||
669 | .replace(/\t/g, '\\t') | ||
670 | .replace(/\r/g, '\\r') | ||
671 | .replace(/\v/g, '\\v') | ||
672 | .replace(/\0/g, '\\0'); | ||
673 | |||
674 | if (isChar) | ||
675 | { | ||
676 | return s.replace(/\'/g, '\\\''); | ||
677 | } | ||
678 | else | ||
679 | { | ||
680 | return s.replace(/\"/g, '\\"'); | ||
681 | } | ||
682 | } | ||
683 | |||
684 | function _Debug_ctorColor(ansi, string) | ||
685 | { | ||
686 | return ansi ? '\x1b[96m' + string + '\x1b[0m' : string; | ||
687 | } | ||
688 | |||
689 | function _Debug_numberColor(ansi, string) | ||
690 | { | ||
691 | return ansi ? '\x1b[95m' + string + '\x1b[0m' : string; | ||
692 | } | ||
693 | |||
694 | function _Debug_stringColor(ansi, string) | ||
695 | { | ||
696 | return ansi ? '\x1b[93m' + string + '\x1b[0m' : string; | ||
697 | } | ||
698 | |||
699 | function _Debug_charColor(ansi, string) | ||
700 | { | ||
701 | return ansi ? '\x1b[92m' + string + '\x1b[0m' : string; | ||
702 | } | ||
703 | |||
704 | function _Debug_fadeColor(ansi, string) | ||
705 | { | ||
706 | return ansi ? '\x1b[37m' + string + '\x1b[0m' : string; | ||
707 | } | ||
708 | |||
709 | function _Debug_internalColor(ansi, string) | ||
710 | { | ||
711 | return ansi ? '\x1b[36m' + string + '\x1b[0m' : string; | ||
712 | } | ||
713 | |||
714 | function _Debug_toHexDigit(n) | ||
715 | { | ||
716 | return String.fromCharCode(n < 10 ? 48 + n : 55 + n); | ||
717 | } | ||
718 | |||
719 | |||
720 | // CRASH | ||
721 | |||
722 | |||
723 | function _Debug_crash_UNUSED(identifier) | ||
724 | { | ||
725 | throw new Error('https://github.com/elm/core/blob/1.0.0/hints/' + identifier + '.md'); | ||
726 | } | ||
727 | |||
728 | |||
729 | function _Debug_crash(identifier, fact1, fact2, fact3, fact4) | ||
730 | { | ||
731 | switch(identifier) | ||
732 | { | ||
733 | case 0: | ||
734 | throw new Error('What node should I take over? In JavaScript I need something like:\n\n Elm.Main.init({\n node: document.getElementById("elm-node")\n })\n\nYou need to do this with any Browser.sandbox or Browser.element program.'); | ||
735 | |||
736 | case 1: | ||
737 | throw new Error('Browser.application programs cannot handle URLs like this:\n\n ' + document.location.href + '\n\nWhat is the root? The root of your file system? Try looking at this program with `elm reactor` or some other server.'); | ||
738 | |||
739 | case 2: | ||
740 | var jsonErrorString = fact1; | ||
741 | throw new Error('Problem with the flags given to your Elm program on initialization.\n\n' + jsonErrorString); | ||
742 | |||
743 | case 3: | ||
744 | var portName = fact1; | ||
745 | throw new Error('There can only be one port named `' + portName + '`, but your program has multiple.'); | ||
746 | |||
747 | case 4: | ||
748 | var portName = fact1; | ||
749 | var problem = fact2; | ||
750 | throw new Error('Trying to send an unexpected type of value through port `' + portName + '`:\n' + problem); | ||
751 | |||
752 | case 5: | ||
753 | throw new Error('Trying to use `(==)` on functions.\nThere is no way to know if functions are "the same" in the Elm sense.\nRead more about this at https://package.elm-lang.org/packages/elm/core/latest/Basics#== which describes why it is this way and what the better version will look like.'); | ||
754 | |||
755 | case 6: | ||
756 | var moduleName = fact1; | ||
757 | throw new Error('Your page is loading multiple Elm scripts with a module named ' + moduleName + '. Maybe a duplicate script is getting loaded accidentally? If not, rename one of them so I know which is which!'); | ||
758 | |||
759 | case 8: | ||
760 | var moduleName = fact1; | ||
761 | var region = fact2; | ||
762 | var message = fact3; | ||
763 | throw new Error('TODO in module `' + moduleName + '` ' + _Debug_regionToString(region) + '\n\n' + message); | ||
764 | |||
765 | case 9: | ||
766 | var moduleName = fact1; | ||
767 | var region = fact2; | ||
768 | var value = fact3; | ||
769 | var message = fact4; | ||
770 | throw new Error( | ||
771 | 'TODO in module `' + moduleName + '` from the `case` expression ' | ||
772 | + _Debug_regionToString(region) + '\n\nIt received the following value:\n\n ' | ||
773 | + _Debug_toString(value).replace('\n', '\n ') | ||
774 | + '\n\nBut the branch that handles it says:\n\n ' + message.replace('\n', '\n ') | ||
775 | ); | ||
776 | |||
777 | case 10: | ||
778 | throw new Error('Bug in https://github.com/elm/virtual-dom/issues'); | ||
779 | |||
780 | case 11: | ||
781 | throw new Error('Cannot perform mod 0. Division by zero error.'); | ||
782 | } | ||
783 | } | ||
784 | |||
785 | function _Debug_regionToString(region) | ||
786 | { | ||
787 | if (region.start.line === region.end.line) | ||
788 | { | ||
789 | return 'on line ' + region.start.line; | ||
790 | } | ||
791 | return 'on lines ' + region.start.line + ' through ' + region.end.line; | ||
792 | } | ||
793 | |||
794 | |||
795 | |||
796 | // MATH | ||
797 | |||
798 | var _Basics_add = F2(function(a, b) { return a + b; }); | ||
799 | var _Basics_sub = F2(function(a, b) { return a - b; }); | ||
800 | var _Basics_mul = F2(function(a, b) { return a * b; }); | ||
801 | var _Basics_fdiv = F2(function(a, b) { return a / b; }); | ||
802 | var _Basics_idiv = F2(function(a, b) { return (a / b) | 0; }); | ||
803 | var _Basics_pow = F2(Math.pow); | ||
804 | |||
805 | var _Basics_remainderBy = F2(function(b, a) { return a % b; }); | ||
806 | |||
807 | // https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/divmodnote-letter.pdf | ||
808 | var _Basics_modBy = F2(function(modulus, x) | ||
809 | { | ||
810 | var answer = x % modulus; | ||
811 | return modulus === 0 | ||
812 | ? _Debug_crash(11) | ||
813 | : | ||
814 | ((answer > 0 && modulus < 0) || (answer < 0 && modulus > 0)) | ||
815 | ? answer + modulus | ||
816 | : answer; | ||
817 | }); | ||
818 | |||
819 | |||
820 | // TRIGONOMETRY | ||
821 | |||
822 | var _Basics_pi = Math.PI; | ||
823 | var _Basics_e = Math.E; | ||
824 | var _Basics_cos = Math.cos; | ||
825 | var _Basics_sin = Math.sin; | ||
826 | var _Basics_tan = Math.tan; | ||
827 | var _Basics_acos = Math.acos; | ||
828 | var _Basics_asin = Math.asin; | ||
829 | var _Basics_atan = Math.atan; | ||
830 | var _Basics_atan2 = F2(Math.atan2); | ||
831 | |||
832 | |||
833 | // MORE MATH | ||
834 | |||
835 | function _Basics_toFloat(x) { return x; } | ||
836 | function _Basics_truncate(n) { return n | 0; } | ||
837 | function _Basics_isInfinite(n) { return n === Infinity || n === -Infinity; } | ||
838 | |||
839 | var _Basics_ceiling = Math.ceil; | ||
840 | var _Basics_floor = Math.floor; | ||
841 | var _Basics_round = Math.round; | ||
842 | var _Basics_sqrt = Math.sqrt; | ||
843 | var _Basics_log = Math.log; | ||
844 | var _Basics_isNaN = isNaN; | ||
845 | |||
846 | |||
847 | // BOOLEANS | ||
848 | |||
849 | function _Basics_not(bool) { return !bool; } | ||
850 | var _Basics_and = F2(function(a, b) { return a && b; }); | ||
851 | var _Basics_or = F2(function(a, b) { return a || b; }); | ||
852 | var _Basics_xor = F2(function(a, b) { return a !== b; }); | ||
853 | |||
854 | |||
855 | |||
856 | var _String_cons = F2(function(chr, str) | ||
857 | { | ||
858 | return chr + str; | ||
859 | }); | ||
860 | |||
861 | function _String_uncons(string) | ||
862 | { | ||
863 | var word = string.charCodeAt(0); | ||
864 | return !isNaN(word) | ||
865 | ? $elm$core$Maybe$Just( | ||
866 | 0xD800 <= word && word <= 0xDBFF | ||
867 | ? _Utils_Tuple2(_Utils_chr(string[0] + string[1]), string.slice(2)) | ||
868 | : _Utils_Tuple2(_Utils_chr(string[0]), string.slice(1)) | ||
869 | ) | ||
870 | : $elm$core$Maybe$Nothing; | ||
871 | } | ||
872 | |||
873 | var _String_append = F2(function(a, b) | ||
874 | { | ||
875 | return a + b; | ||
876 | }); | ||
877 | |||
878 | function _String_length(str) | ||
879 | { | ||
880 | return str.length; | ||
881 | } | ||
882 | |||
883 | var _String_map = F2(function(func, string) | ||
884 | { | ||
885 | var len = string.length; | ||
886 | var array = new Array(len); | ||
887 | var i = 0; | ||
888 | while (i < len) | ||
889 | { | ||
890 | var word = string.charCodeAt(i); | ||
891 | if (0xD800 <= word && word <= 0xDBFF) | ||
892 | { | ||
893 | array[i] = func(_Utils_chr(string[i] + string[i+1])); | ||
894 | i += 2; | ||
895 | continue; | ||
896 | } | ||
897 | array[i] = func(_Utils_chr(string[i])); | ||
898 | i++; | ||
899 | } | ||
900 | return array.join(''); | ||
901 | }); | ||
902 | |||
903 | var _String_filter = F2(function(isGood, str) | ||
904 | { | ||
905 | var arr = []; | ||
906 | var len = str.length; | ||
907 | var i = 0; | ||
908 | while (i < len) | ||
909 | { | ||
910 | var char = str[i]; | ||
911 | var word = str.charCodeAt(i); | ||
912 | i++; | ||
913 | if (0xD800 <= word && word <= 0xDBFF) | ||
914 | { | ||
915 | char += str[i]; | ||
916 | i++; | ||
917 | } | ||
918 | |||
919 | if (isGood(_Utils_chr(char))) | ||
920 | { | ||
921 | arr.push(char); | ||
922 | } | ||
923 | } | ||
924 | return arr.join(''); | ||
925 | }); | ||
926 | |||
927 | function _String_reverse(str) | ||
928 | { | ||
929 | var len = str.length; | ||
930 | var arr = new Array(len); | ||
931 | var i = 0; | ||
932 | while (i < len) | ||
933 | { | ||
934 | var word = str.charCodeAt(i); | ||
935 | if (0xD800 <= word && word <= 0xDBFF) | ||
936 | { | ||
937 | arr[len - i] = str[i + 1]; | ||
938 | i++; | ||
939 | arr[len - i] = str[i - 1]; | ||
940 | i++; | ||
941 | } | ||
942 | else | ||
943 | { | ||
944 | arr[len - i] = str[i]; | ||
945 | i++; | ||
946 | } | ||
947 | } | ||
948 | return arr.join(''); | ||
949 | } | ||
950 | |||
951 | var _String_foldl = F3(function(func, state, string) | ||
952 | { | ||
953 | var len = string.length; | ||
954 | var i = 0; | ||
955 | while (i < len) | ||
956 | { | ||
957 | var char = string[i]; | ||
958 | var word = string.charCodeAt(i); | ||
959 | i++; | ||
960 | if (0xD800 <= word && word <= 0xDBFF) | ||
961 | { | ||
962 | char += string[i]; | ||
963 | i++; | ||
964 | } | ||
965 | state = A2(func, _Utils_chr(char), state); | ||
966 | } | ||
967 | return state; | ||
968 | }); | ||
969 | |||
970 | var _String_foldr = F3(function(func, state, string) | ||
971 | { | ||
972 | var i = string.length; | ||
973 | while (i--) | ||
974 | { | ||
975 | var char = string[i]; | ||
976 | var word = string.charCodeAt(i); | ||
977 | if (0xDC00 <= word && word <= 0xDFFF) | ||
978 | { | ||
979 | i--; | ||
980 | char = string[i] + char; | ||
981 | } | ||
982 | state = A2(func, _Utils_chr(char), state); | ||
983 | } | ||
984 | return state; | ||
985 | }); | ||
986 | |||
987 | var _String_split = F2(function(sep, str) | ||
988 | { | ||
989 | return str.split(sep); | ||
990 | }); | ||
991 | |||
992 | var _String_join = F2(function(sep, strs) | ||
993 | { | ||
994 | return strs.join(sep); | ||
995 | }); | ||
996 | |||
997 | var _String_slice = F3(function(start, end, str) { | ||
998 | return str.slice(start, end); | ||
999 | }); | ||
1000 | |||
1001 | function _String_trim(str) | ||
1002 | { | ||
1003 | return str.trim(); | ||
1004 | } | ||
1005 | |||
1006 | function _String_trimLeft(str) | ||
1007 | { | ||
1008 | return str.replace(/^\s+/, ''); | ||
1009 | } | ||
1010 | |||
1011 | function _String_trimRight(str) | ||
1012 | { | ||
1013 | return str.replace(/\s+$/, ''); | ||
1014 | } | ||
1015 | |||
1016 | function _String_words(str) | ||
1017 | { | ||
1018 | return _List_fromArray(str.trim().split(/\s+/g)); | ||
1019 | } | ||
1020 | |||
1021 | function _String_lines(str) | ||
1022 | { | ||
1023 | return _List_fromArray(str.split(/\r\n|\r|\n/g)); | ||
1024 | } | ||
1025 | |||
1026 | function _String_toUpper(str) | ||
1027 | { | ||
1028 | return str.toUpperCase(); | ||
1029 | } | ||
1030 | |||
1031 | function _String_toLower(str) | ||
1032 | { | ||
1033 | return str.toLowerCase(); | ||
1034 | } | ||
1035 | |||
1036 | var _String_any = F2(function(isGood, string) | ||
1037 | { | ||
1038 | var i = string.length; | ||
1039 | while (i--) | ||
1040 | { | ||
1041 | var char = string[i]; | ||
1042 | var word = string.charCodeAt(i); | ||
1043 | if (0xDC00 <= word && word <= 0xDFFF) | ||
1044 | { | ||
1045 | i--; | ||
1046 | char = string[i] + char; | ||
1047 | } | ||
1048 | if (isGood(_Utils_chr(char))) | ||
1049 | { | ||
1050 | return true; | ||
1051 | } | ||
1052 | } | ||
1053 | return false; | ||
1054 | }); | ||
1055 | |||
1056 | var _String_all = F2(function(isGood, string) | ||
1057 | { | ||
1058 | var i = string.length; | ||
1059 | while (i--) | ||
1060 | { | ||
1061 | var char = string[i]; | ||
1062 | var word = string.charCodeAt(i); | ||
1063 | if (0xDC00 <= word && word <= 0xDFFF) | ||
1064 | { | ||
1065 | i--; | ||
1066 | char = string[i] + char; | ||
1067 | } | ||
1068 | if (!isGood(_Utils_chr(char))) | ||
1069 | { | ||
1070 | return false; | ||
1071 | } | ||
1072 | } | ||
1073 | return true; | ||
1074 | }); | ||
1075 | |||
1076 | var _String_contains = F2(function(sub, str) | ||
1077 | { | ||
1078 | return str.indexOf(sub) > -1; | ||
1079 | }); | ||
1080 | |||
1081 | var _String_startsWith = F2(function(sub, str) | ||
1082 | { | ||
1083 | return str.indexOf(sub) === 0; | ||
1084 | }); | ||
1085 | |||
1086 | var _String_endsWith = F2(function(sub, str) | ||
1087 | { | ||
1088 | return str.length >= sub.length && | ||
1089 | str.lastIndexOf(sub) === str.length - sub.length; | ||
1090 | }); | ||
1091 | |||
1092 | var _String_indexes = F2(function(sub, str) | ||
1093 | { | ||
1094 | var subLen = sub.length; | ||
1095 | |||
1096 | if (subLen < 1) | ||
1097 | { | ||
1098 | return _List_Nil; | ||
1099 | } | ||
1100 | |||
1101 | var i = 0; | ||
1102 | var is = []; | ||
1103 | |||
1104 | while ((i = str.indexOf(sub, i)) > -1) | ||
1105 | { | ||
1106 | is.push(i); | ||
1107 | i = i + subLen; | ||
1108 | } | ||
1109 | |||
1110 | return _List_fromArray(is); | ||
1111 | }); | ||
1112 | |||
1113 | |||
1114 | // TO STRING | ||
1115 | |||
1116 | function _String_fromNumber(number) | ||
1117 | { | ||
1118 | return number + ''; | ||
1119 | } | ||
1120 | |||
1121 | |||
1122 | // INT CONVERSIONS | ||
1123 | |||
1124 | function _String_toInt(str) | ||
1125 | { | ||
1126 | var total = 0; | ||
1127 | var code0 = str.charCodeAt(0); | ||
1128 | var start = code0 == 0x2B /* + */ || code0 == 0x2D /* - */ ? 1 : 0; | ||
1129 | |||
1130 | for (var i = start; i < str.length; ++i) | ||
1131 | { | ||
1132 | var code = str.charCodeAt(i); | ||
1133 | if (code < 0x30 || 0x39 < code) | ||
1134 | { | ||
1135 | return $elm$core$Maybe$Nothing; | ||
1136 | } | ||
1137 | total = 10 * total + code - 0x30; | ||
1138 | } | ||
1139 | |||
1140 | return i == start | ||
1141 | ? $elm$core$Maybe$Nothing | ||
1142 | : $elm$core$Maybe$Just(code0 == 0x2D ? -total : total); | ||
1143 | } | ||
1144 | |||
1145 | |||
1146 | // FLOAT CONVERSIONS | ||
1147 | |||
1148 | function _String_toFloat(s) | ||
1149 | { | ||
1150 | // check if it is a hex, octal, or binary number | ||
1151 | if (s.length === 0 || /[\sxbo]/.test(s)) | ||
1152 | { | ||
1153 | return $elm$core$Maybe$Nothing; | ||
1154 | } | ||
1155 | var n = +s; | ||
1156 | // faster isNaN check | ||
1157 | return n === n ? $elm$core$Maybe$Just(n) : $elm$core$Maybe$Nothing; | ||
1158 | } | ||
1159 | |||
1160 | function _String_fromList(chars) | ||
1161 | { | ||
1162 | return _List_toArray(chars).join(''); | ||
1163 | } | ||
1164 | |||
1165 | |||
1166 | |||
1167 | |||
1168 | function _Char_toCode(char) | ||
1169 | { | ||
1170 | var code = char.charCodeAt(0); | ||
1171 | if (0xD800 <= code && code <= 0xDBFF) | ||
1172 | { | ||
1173 | return (code - 0xD800) * 0x400 + char.charCodeAt(1) - 0xDC00 + 0x10000 | ||
1174 | } | ||
1175 | return code; | ||
1176 | } | ||
1177 | |||
1178 | function _Char_fromCode(code) | ||
1179 | { | ||
1180 | return _Utils_chr( | ||
1181 | (code < 0 || 0x10FFFF < code) | ||
1182 | ? '\uFFFD' | ||
1183 | : | ||
1184 | (code <= 0xFFFF) | ||
1185 | ? String.fromCharCode(code) | ||
1186 | : | ||
1187 | (code -= 0x10000, | ||
1188 | String.fromCharCode(Math.floor(code / 0x400) + 0xD800, code % 0x400 + 0xDC00) | ||
1189 | ) | ||
1190 | ); | ||
1191 | } | ||
1192 | |||
1193 | function _Char_toUpper(char) | ||
1194 | { | ||
1195 | return _Utils_chr(char.toUpperCase()); | ||
1196 | } | ||
1197 | |||
1198 | function _Char_toLower(char) | ||
1199 | { | ||
1200 | return _Utils_chr(char.toLowerCase()); | ||
1201 | } | ||
1202 | |||
1203 | function _Char_toLocaleUpper(char) | ||
1204 | { | ||
1205 | return _Utils_chr(char.toLocaleUpperCase()); | ||
1206 | } | ||
1207 | |||
1208 | function _Char_toLocaleLower(char) | ||
1209 | { | ||
1210 | return _Utils_chr(char.toLocaleLowerCase()); | ||
1211 | } | ||
1212 | |||
1213 | |||
1214 | |||
1215 | /**/ | ||
1216 | function _Json_errorToString(error) | ||
1217 | { | ||
1218 | return $elm$json$Json$Decode$errorToString(error); | ||
1219 | } | ||
1220 | //*/ | ||
1221 | |||
1222 | |||
1223 | // CORE DECODERS | ||
1224 | |||
1225 | function _Json_succeed(msg) | ||
1226 | { | ||
1227 | return { | ||
1228 | $: 0, | ||
1229 | a: msg | ||
1230 | }; | ||
1231 | } | ||
1232 | |||
1233 | function _Json_fail(msg) | ||
1234 | { | ||
1235 | return { | ||
1236 | $: 1, | ||
1237 | a: msg | ||
1238 | }; | ||
1239 | } | ||
1240 | |||
1241 | function _Json_decodePrim(decoder) | ||
1242 | { | ||
1243 | return { $: 2, b: decoder }; | ||
1244 | } | ||
1245 | |||
1246 | var _Json_decodeInt = _Json_decodePrim(function(value) { | ||
1247 | return (typeof value !== 'number') | ||
1248 | ? _Json_expecting('an INT', value) | ||
1249 | : | ||
1250 | (-2147483647 < value && value < 2147483647 && (value | 0) === value) | ||
1251 | ? $elm$core$Result$Ok(value) | ||
1252 | : | ||
1253 | (isFinite(value) && !(value % 1)) | ||
1254 | ? $elm$core$Result$Ok(value) | ||
1255 | : _Json_expecting('an INT', value); | ||
1256 | }); | ||
1257 | |||
1258 | var _Json_decodeBool = _Json_decodePrim(function(value) { | ||
1259 | return (typeof value === 'boolean') | ||
1260 | ? $elm$core$Result$Ok(value) | ||
1261 | : _Json_expecting('a BOOL', value); | ||
1262 | }); | ||
1263 | |||
1264 | var _Json_decodeFloat = _Json_decodePrim(function(value) { | ||
1265 | return (typeof value === 'number') | ||
1266 | ? $elm$core$Result$Ok(value) | ||
1267 | : _Json_expecting('a FLOAT', value); | ||
1268 | }); | ||
1269 | |||
1270 | var _Json_decodeValue = _Json_decodePrim(function(value) { | ||
1271 | return $elm$core$Result$Ok(_Json_wrap(value)); | ||
1272 | }); | ||
1273 | |||
1274 | var _Json_decodeString = _Json_decodePrim(function(value) { | ||
1275 | return (typeof value === 'string') | ||
1276 | ? $elm$core$Result$Ok(value) | ||
1277 | : (value instanceof String) | ||
1278 | ? $elm$core$Result$Ok(value + '') | ||
1279 | : _Json_expecting('a STRING', value); | ||
1280 | }); | ||
1281 | |||
1282 | function _Json_decodeList(decoder) { return { $: 3, b: decoder }; } | ||
1283 | function _Json_decodeArray(decoder) { return { $: 4, b: decoder }; } | ||
1284 | |||
1285 | function _Json_decodeNull(value) { return { $: 5, c: value }; } | ||
1286 | |||
1287 | var _Json_decodeField = F2(function(field, decoder) | ||
1288 | { | ||
1289 | return { | ||
1290 | $: 6, | ||
1291 | d: field, | ||
1292 | b: decoder | ||
1293 | }; | ||
1294 | }); | ||
1295 | |||
1296 | var _Json_decodeIndex = F2(function(index, decoder) | ||
1297 | { | ||
1298 | return { | ||
1299 | $: 7, | ||
1300 | e: index, | ||
1301 | b: decoder | ||
1302 | }; | ||
1303 | }); | ||
1304 | |||
1305 | function _Json_decodeKeyValuePairs(decoder) | ||
1306 | { | ||
1307 | return { | ||
1308 | $: 8, | ||
1309 | b: decoder | ||
1310 | }; | ||
1311 | } | ||
1312 | |||
1313 | function _Json_mapMany(f, decoders) | ||
1314 | { | ||
1315 | return { | ||
1316 | $: 9, | ||
1317 | f: f, | ||
1318 | g: decoders | ||
1319 | }; | ||
1320 | } | ||
1321 | |||
1322 | var _Json_andThen = F2(function(callback, decoder) | ||
1323 | { | ||
1324 | return { | ||
1325 | $: 10, | ||
1326 | b: decoder, | ||
1327 | h: callback | ||
1328 | }; | ||
1329 | }); | ||
1330 | |||
1331 | function _Json_oneOf(decoders) | ||
1332 | { | ||
1333 | return { | ||
1334 | $: 11, | ||
1335 | g: decoders | ||
1336 | }; | ||
1337 | } | ||
1338 | |||
1339 | |||
1340 | // DECODING OBJECTS | ||
1341 | |||
1342 | var _Json_map1 = F2(function(f, d1) | ||
1343 | { | ||
1344 | return _Json_mapMany(f, [d1]); | ||
1345 | }); | ||
1346 | |||
1347 | var _Json_map2 = F3(function(f, d1, d2) | ||
1348 | { | ||
1349 | return _Json_mapMany(f, [d1, d2]); | ||
1350 | }); | ||
1351 | |||
1352 | var _Json_map3 = F4(function(f, d1, d2, d3) | ||
1353 | { | ||
1354 | return _Json_mapMany(f, [d1, d2, d3]); | ||
1355 | }); | ||
1356 | |||
1357 | var _Json_map4 = F5(function(f, d1, d2, d3, d4) | ||
1358 | { | ||
1359 | return _Json_mapMany(f, [d1, d2, d3, d4]); | ||
1360 | }); | ||
1361 | |||
1362 | var _Json_map5 = F6(function(f, d1, d2, d3, d4, d5) | ||
1363 | { | ||
1364 | return _Json_mapMany(f, [d1, d2, d3, d4, d5]); | ||
1365 | }); | ||
1366 | |||
1367 | var _Json_map6 = F7(function(f, d1, d2, d3, d4, d5, d6) | ||
1368 | { | ||
1369 | return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6]); | ||
1370 | }); | ||
1371 | |||
1372 | var _Json_map7 = F8(function(f, d1, d2, d3, d4, d5, d6, d7) | ||
1373 | { | ||
1374 | return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7]); | ||
1375 | }); | ||
1376 | |||
1377 | var _Json_map8 = F9(function(f, d1, d2, d3, d4, d5, d6, d7, d8) | ||
1378 | { | ||
1379 | return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7, d8]); | ||
1380 | }); | ||
1381 | |||
1382 | |||
1383 | // DECODE | ||
1384 | |||
1385 | var _Json_runOnString = F2(function(decoder, string) | ||
1386 | { | ||
1387 | try | ||
1388 | { | ||
1389 | var value = JSON.parse(string); | ||
1390 | return _Json_runHelp(decoder, value); | ||
1391 | } | ||
1392 | catch (e) | ||
1393 | { | ||
1394 | return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, 'This is not valid JSON! ' + e.message, _Json_wrap(string))); | ||
1395 | } | ||
1396 | }); | ||
1397 | |||
1398 | var _Json_run = F2(function(decoder, value) | ||
1399 | { | ||
1400 | return _Json_runHelp(decoder, _Json_unwrap(value)); | ||
1401 | }); | ||
1402 | |||
1403 | function _Json_runHelp(decoder, value) | ||
1404 | { | ||
1405 | switch (decoder.$) | ||
1406 | { | ||
1407 | case 2: | ||
1408 | return decoder.b(value); | ||
1409 | |||
1410 | case 5: | ||
1411 | return (value === null) | ||
1412 | ? $elm$core$Result$Ok(decoder.c) | ||
1413 | : _Json_expecting('null', value); | ||
1414 | |||
1415 | case 3: | ||
1416 | if (!_Json_isArray(value)) | ||
1417 | { | ||
1418 | return _Json_expecting('a LIST', value); | ||
1419 | } | ||
1420 | return _Json_runArrayDecoder(decoder.b, value, _List_fromArray); | ||
1421 | |||
1422 | case 4: | ||
1423 | if (!_Json_isArray(value)) | ||
1424 | { | ||
1425 | return _Json_expecting('an ARRAY', value); | ||
1426 | } | ||
1427 | return _Json_runArrayDecoder(decoder.b, value, _Json_toElmArray); | ||
1428 | |||
1429 | case 6: | ||
1430 | var field = decoder.d; | ||
1431 | if (typeof value !== 'object' || value === null || !(field in value)) | ||
1432 | { | ||
1433 | return _Json_expecting('an OBJECT with a field named `' + field + '`', value); | ||
1434 | } | ||
1435 | var result = _Json_runHelp(decoder.b, value[field]); | ||
1436 | return ($elm$core$Result$isOk(result)) ? result : $elm$core$Result$Err(A2($elm$json$Json$Decode$Field, field, result.a)); | ||
1437 | |||
1438 | case 7: | ||
1439 | var index = decoder.e; | ||
1440 | if (!_Json_isArray(value)) | ||
1441 | { | ||
1442 | return _Json_expecting('an ARRAY', value); | ||
1443 | } | ||
1444 | if (index >= value.length) | ||
1445 | { | ||
1446 | return _Json_expecting('a LONGER array. Need index ' + index + ' but only see ' + value.length + ' entries', value); | ||
1447 | } | ||
1448 | var result = _Json_runHelp(decoder.b, value[index]); | ||
1449 | return ($elm$core$Result$isOk(result)) ? result : $elm$core$Result$Err(A2($elm$json$Json$Decode$Index, index, result.a)); | ||
1450 | |||
1451 | case 8: | ||
1452 | if (typeof value !== 'object' || value === null || _Json_isArray(value)) | ||
1453 | { | ||
1454 | return _Json_expecting('an OBJECT', value); | ||
1455 | } | ||
1456 | |||
1457 | var keyValuePairs = _List_Nil; | ||
1458 | // TODO test perf of Object.keys and switch when support is good enough | ||
1459 | for (var key in value) | ||
1460 | { | ||
1461 | if (value.hasOwnProperty(key)) | ||
1462 | { | ||
1463 | var result = _Json_runHelp(decoder.b, value[key]); | ||
1464 | if (!$elm$core$Result$isOk(result)) | ||
1465 | { | ||
1466 | return $elm$core$Result$Err(A2($elm$json$Json$Decode$Field, key, result.a)); | ||
1467 | } | ||
1468 | keyValuePairs = _List_Cons(_Utils_Tuple2(key, result.a), keyValuePairs); | ||
1469 | } | ||
1470 | } | ||
1471 | return $elm$core$Result$Ok($elm$core$List$reverse(keyValuePairs)); | ||
1472 | |||
1473 | case 9: | ||
1474 | var answer = decoder.f; | ||
1475 | var decoders = decoder.g; | ||
1476 | for (var i = 0; i < decoders.length; i++) | ||
1477 | { | ||
1478 | var result = _Json_runHelp(decoders[i], value); | ||
1479 | if (!$elm$core$Result$isOk(result)) | ||
1480 | { | ||
1481 | return result; | ||
1482 | } | ||
1483 | answer = answer(result.a); | ||
1484 | } | ||
1485 | return $elm$core$Result$Ok(answer); | ||
1486 | |||
1487 | case 10: | ||
1488 | var result = _Json_runHelp(decoder.b, value); | ||
1489 | return (!$elm$core$Result$isOk(result)) | ||
1490 | ? result | ||
1491 | : _Json_runHelp(decoder.h(result.a), value); | ||
1492 | |||
1493 | case 11: | ||
1494 | var errors = _List_Nil; | ||
1495 | for (var temp = decoder.g; temp.b; temp = temp.b) // WHILE_CONS | ||
1496 | { | ||
1497 | var result = _Json_runHelp(temp.a, value); | ||
1498 | if ($elm$core$Result$isOk(result)) | ||
1499 | { | ||
1500 | return result; | ||
1501 | } | ||
1502 | errors = _List_Cons(result.a, errors); | ||
1503 | } | ||
1504 | return $elm$core$Result$Err($elm$json$Json$Decode$OneOf($elm$core$List$reverse(errors))); | ||
1505 | |||
1506 | case 1: | ||
1507 | return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, decoder.a, _Json_wrap(value))); | ||
1508 | |||
1509 | case 0: | ||
1510 | return $elm$core$Result$Ok(decoder.a); | ||
1511 | } | ||
1512 | } | ||
1513 | |||
1514 | function _Json_runArrayDecoder(decoder, value, toElmValue) | ||
1515 | { | ||
1516 | var len = value.length; | ||
1517 | var array = new Array(len); | ||
1518 | for (var i = 0; i < len; i++) | ||
1519 | { | ||
1520 | var result = _Json_runHelp(decoder, value[i]); | ||
1521 | if (!$elm$core$Result$isOk(result)) | ||
1522 | { | ||
1523 | return $elm$core$Result$Err(A2($elm$json$Json$Decode$Index, i, result.a)); | ||
1524 | } | ||
1525 | array[i] = result.a; | ||
1526 | } | ||
1527 | return $elm$core$Result$Ok(toElmValue(array)); | ||
1528 | } | ||
1529 | |||
1530 | function _Json_isArray(value) | ||
1531 | { | ||
1532 | return Array.isArray(value) || (typeof FileList !== 'undefined' && value instanceof FileList); | ||
1533 | } | ||
1534 | |||
1535 | function _Json_toElmArray(array) | ||
1536 | { | ||
1537 | return A2($elm$core$Array$initialize, array.length, function(i) { return array[i]; }); | ||
1538 | } | ||
1539 | |||
1540 | function _Json_expecting(type, value) | ||
1541 | { | ||
1542 | return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, 'Expecting ' + type, _Json_wrap(value))); | ||
1543 | } | ||
1544 | |||
1545 | |||
1546 | // EQUALITY | ||
1547 | |||
1548 | function _Json_equality(x, y) | ||
1549 | { | ||
1550 | if (x === y) | ||
1551 | { | ||
1552 | return true; | ||
1553 | } | ||
1554 | |||
1555 | if (x.$ !== y.$) | ||
1556 | { | ||
1557 | return false; | ||
1558 | } | ||
1559 | |||
1560 | switch (x.$) | ||
1561 | { | ||
1562 | case 0: | ||
1563 | case 1: | ||
1564 | return x.a === y.a; | ||
1565 | |||
1566 | case 2: | ||
1567 | return x.b === y.b; | ||
1568 | |||
1569 | case 5: | ||
1570 | return x.c === y.c; | ||
1571 | |||
1572 | case 3: | ||
1573 | case 4: | ||
1574 | case 8: | ||
1575 | return _Json_equality(x.b, y.b); | ||
1576 | |||
1577 | case 6: | ||
1578 | return x.d === y.d && _Json_equality(x.b, y.b); | ||
1579 | |||
1580 | case 7: | ||
1581 | return x.e === y.e && _Json_equality(x.b, y.b); | ||
1582 | |||
1583 | case 9: | ||
1584 | return x.f === y.f && _Json_listEquality(x.g, y.g); | ||
1585 | |||
1586 | case 10: | ||
1587 | return x.h === y.h && _Json_equality(x.b, y.b); | ||
1588 | |||
1589 | case 11: | ||
1590 | return _Json_listEquality(x.g, y.g); | ||
1591 | } | ||
1592 | } | ||
1593 | |||
1594 | function _Json_listEquality(aDecoders, bDecoders) | ||
1595 | { | ||
1596 | var len = aDecoders.length; | ||
1597 | if (len !== bDecoders.length) | ||
1598 | { | ||
1599 | return false; | ||
1600 | } | ||
1601 | for (var i = 0; i < len; i++) | ||
1602 | { | ||
1603 | if (!_Json_equality(aDecoders[i], bDecoders[i])) | ||
1604 | { | ||
1605 | return false; | ||
1606 | } | ||
1607 | } | ||
1608 | return true; | ||
1609 | } | ||
1610 | |||
1611 | |||
1612 | // ENCODE | ||
1613 | |||
1614 | var _Json_encode = F2(function(indentLevel, value) | ||
1615 | { | ||
1616 | return JSON.stringify(_Json_unwrap(value), null, indentLevel) + ''; | ||
1617 | }); | ||
1618 | |||
1619 | function _Json_wrap(value) { return { $: 0, a: value }; } | ||
1620 | function _Json_unwrap(value) { return value.a; } | ||
1621 | |||
1622 | function _Json_wrap_UNUSED(value) { return value; } | ||
1623 | function _Json_unwrap_UNUSED(value) { return value; } | ||
1624 | |||
1625 | function _Json_emptyArray() { return []; } | ||
1626 | function _Json_emptyObject() { return {}; } | ||
1627 | |||
1628 | var _Json_addField = F3(function(key, value, object) | ||
1629 | { | ||
1630 | object[key] = _Json_unwrap(value); | ||
1631 | return object; | ||
1632 | }); | ||
1633 | |||
1634 | function _Json_addEntry(func) | ||
1635 | { | ||
1636 | return F2(function(entry, array) | ||
1637 | { | ||
1638 | array.push(_Json_unwrap(func(entry))); | ||
1639 | return array; | ||
1640 | }); | ||
1641 | } | ||
1642 | |||
1643 | var _Json_encodeNull = _Json_wrap(null); | ||
1644 | |||
1645 | |||
1646 | |||
1647 | // TASKS | ||
1648 | |||
1649 | function _Scheduler_succeed(value) | ||
1650 | { | ||
1651 | return { | ||
1652 | $: 0, | ||
1653 | a: value | ||
1654 | }; | ||
1655 | } | ||
1656 | |||
1657 | function _Scheduler_fail(error) | ||
1658 | { | ||
1659 | return { | ||
1660 | $: 1, | ||
1661 | a: error | ||
1662 | }; | ||
1663 | } | ||
1664 | |||
1665 | function _Scheduler_binding(callback) | ||
1666 | { | ||
1667 | return { | ||
1668 | $: 2, | ||
1669 | b: callback, | ||
1670 | c: null | ||
1671 | }; | ||
1672 | } | ||
1673 | |||
1674 | var _Scheduler_andThen = F2(function(callback, task) | ||
1675 | { | ||
1676 | return { | ||
1677 | $: 3, | ||
1678 | b: callback, | ||
1679 | d: task | ||
1680 | }; | ||
1681 | }); | ||
1682 | |||
1683 | var _Scheduler_onError = F2(function(callback, task) | ||
1684 | { | ||
1685 | return { | ||
1686 | $: 4, | ||
1687 | b: callback, | ||
1688 | d: task | ||
1689 | }; | ||
1690 | }); | ||
1691 | |||
1692 | function _Scheduler_receive(callback) | ||
1693 | { | ||
1694 | return { | ||
1695 | $: 5, | ||
1696 | b: callback | ||
1697 | }; | ||
1698 | } | ||
1699 | |||
1700 | |||
1701 | // PROCESSES | ||
1702 | |||
1703 | var _Scheduler_guid = 0; | ||
1704 | |||
1705 | function _Scheduler_rawSpawn(task) | ||
1706 | { | ||
1707 | var proc = { | ||
1708 | $: 0, | ||
1709 | e: _Scheduler_guid++, | ||
1710 | f: task, | ||
1711 | g: null, | ||
1712 | h: [] | ||
1713 | }; | ||
1714 | |||
1715 | _Scheduler_enqueue(proc); | ||
1716 | |||
1717 | return proc; | ||
1718 | } | ||
1719 | |||
1720 | function _Scheduler_spawn(task) | ||
1721 | { | ||
1722 | return _Scheduler_binding(function(callback) { | ||
1723 | callback(_Scheduler_succeed(_Scheduler_rawSpawn(task))); | ||
1724 | }); | ||
1725 | } | ||
1726 | |||
1727 | function _Scheduler_rawSend(proc, msg) | ||
1728 | { | ||
1729 | proc.h.push(msg); | ||
1730 | _Scheduler_enqueue(proc); | ||
1731 | } | ||
1732 | |||
1733 | var _Scheduler_send = F2(function(proc, msg) | ||
1734 | { | ||
1735 | return _Scheduler_binding(function(callback) { | ||
1736 | _Scheduler_rawSend(proc, msg); | ||
1737 | callback(_Scheduler_succeed(_Utils_Tuple0)); | ||
1738 | }); | ||
1739 | }); | ||
1740 | |||
1741 | function _Scheduler_kill(proc) | ||
1742 | { | ||
1743 | return _Scheduler_binding(function(callback) { | ||
1744 | var task = proc.f; | ||
1745 | if (task.$ === 2 && task.c) | ||
1746 | { | ||
1747 | task.c(); | ||
1748 | } | ||
1749 | |||
1750 | proc.f = null; | ||
1751 | |||
1752 | callback(_Scheduler_succeed(_Utils_Tuple0)); | ||
1753 | }); | ||
1754 | } | ||
1755 | |||
1756 | |||
1757 | /* STEP PROCESSES | ||
1758 | |||
1759 | type alias Process = | ||
1760 | { $ : tag | ||
1761 | , id : unique_id | ||
1762 | , root : Task | ||
1763 | , stack : null | { $: SUCCEED | FAIL, a: callback, b: stack } | ||
1764 | , mailbox : [msg] | ||
1765 | } | ||
1766 | |||
1767 | */ | ||
1768 | |||
1769 | |||
1770 | var _Scheduler_working = false; | ||
1771 | var _Scheduler_queue = []; | ||
1772 | |||
1773 | |||
1774 | function _Scheduler_enqueue(proc) | ||
1775 | { | ||
1776 | _Scheduler_queue.push(proc); | ||
1777 | if (_Scheduler_working) | ||
1778 | { | ||
1779 | return; | ||
1780 | } | ||
1781 | _Scheduler_working = true; | ||
1782 | while (proc = _Scheduler_queue.shift()) | ||
1783 | { | ||
1784 | _Scheduler_step(proc); | ||
1785 | } | ||
1786 | _Scheduler_working = false; | ||
1787 | } | ||
1788 | |||
1789 | |||
1790 | function _Scheduler_step(proc) | ||
1791 | { | ||
1792 | while (proc.f) | ||
1793 | { | ||
1794 | var rootTag = proc.f.$; | ||
1795 | if (rootTag === 0 || rootTag === 1) | ||
1796 | { | ||
1797 | while (proc.g && proc.g.$ !== rootTag) | ||
1798 | { | ||
1799 | proc.g = proc.g.i; | ||
1800 | } | ||
1801 | if (!proc.g) | ||
1802 | { | ||
1803 | return; | ||
1804 | } | ||
1805 | proc.f = proc.g.b(proc.f.a); | ||
1806 | proc.g = proc.g.i; | ||
1807 | } | ||
1808 | else if (rootTag === 2) | ||
1809 | { | ||
1810 | proc.f.c = proc.f.b(function(newRoot) { | ||
1811 | proc.f = newRoot; | ||
1812 | _Scheduler_enqueue(proc); | ||
1813 | }); | ||
1814 | return; | ||
1815 | } | ||
1816 | else if (rootTag === 5) | ||
1817 | { | ||
1818 | if (proc.h.length === 0) | ||
1819 | { | ||
1820 | return; | ||
1821 | } | ||
1822 | proc.f = proc.f.b(proc.h.shift()); | ||
1823 | } | ||
1824 | else // if (rootTag === 3 || rootTag === 4) | ||
1825 | { | ||
1826 | proc.g = { | ||
1827 | $: rootTag === 3 ? 0 : 1, | ||
1828 | b: proc.f.b, | ||
1829 | i: proc.g | ||
1830 | }; | ||
1831 | proc.f = proc.f.d; | ||
1832 | } | ||
1833 | } | ||
1834 | } | ||
1835 | |||
1836 | |||
1837 | |||
1838 | function _Process_sleep(time) | ||
1839 | { | ||
1840 | return _Scheduler_binding(function(callback) { | ||
1841 | var id = setTimeout(function() { | ||
1842 | callback(_Scheduler_succeed(_Utils_Tuple0)); | ||
1843 | }, time); | ||
1844 | |||
1845 | return function() { clearTimeout(id); }; | ||
1846 | }); | ||
1847 | } | ||
1848 | |||
1849 | |||
1850 | |||
1851 | |||
1852 | // PROGRAMS | ||
1853 | |||
1854 | |||
1855 | var _Platform_worker = F4(function(impl, flagDecoder, debugMetadata, args) | ||
1856 | { | ||
1857 | return _Platform_initialize( | ||
1858 | flagDecoder, | ||
1859 | args, | ||
1860 | impl.init, | ||
1861 | impl.update, | ||
1862 | impl.subscriptions, | ||
1863 | function() { return function() {} } | ||
1864 | ); | ||
1865 | }); | ||
1866 | |||
1867 | |||
1868 | |||
1869 | // INITIALIZE A PROGRAM | ||
1870 | |||
1871 | |||
1872 | function _Platform_initialize(flagDecoder, args, init, update, subscriptions, stepperBuilder) | ||
1873 | { | ||
1874 | var result = A2(_Json_run, flagDecoder, _Json_wrap(args ? args['flags'] : undefined)); | ||
1875 | $elm$core$Result$isOk(result) || _Debug_crash(2 /**/, _Json_errorToString(result.a) /**/); | ||
1876 | var managers = {}; | ||
1877 | var initPair = init(result.a); | ||
1878 | var model = initPair.a; | ||
1879 | var stepper = stepperBuilder(sendToApp, model); | ||
1880 | var ports = _Platform_setupEffects(managers, sendToApp); | ||
1881 | |||
1882 | function sendToApp(msg, viewMetadata) | ||
1883 | { | ||
1884 | var pair = A2(update, msg, model); | ||
1885 | stepper(model = pair.a, viewMetadata); | ||
1886 | _Platform_enqueueEffects(managers, pair.b, subscriptions(model)); | ||
1887 | } | ||
1888 | |||
1889 | _Platform_enqueueEffects(managers, initPair.b, subscriptions(model)); | ||
1890 | |||
1891 | return ports ? { ports: ports } : {}; | ||
1892 | } | ||
1893 | |||
1894 | |||
1895 | |||
1896 | // TRACK PRELOADS | ||
1897 | // | ||
1898 | // This is used by code in elm/browser and elm/http | ||
1899 | // to register any HTTP requests that are triggered by init. | ||
1900 | // | ||
1901 | |||
1902 | |||
1903 | var _Platform_preload; | ||
1904 | |||
1905 | |||
1906 | function _Platform_registerPreload(url) | ||
1907 | { | ||
1908 | _Platform_preload.add(url); | ||
1909 | } | ||
1910 | |||
1911 | |||
1912 | |||
1913 | // EFFECT MANAGERS | ||
1914 | |||
1915 | |||
1916 | var _Platform_effectManagers = {}; | ||
1917 | |||
1918 | |||
1919 | function _Platform_setupEffects(managers, sendToApp) | ||
1920 | { | ||
1921 | var ports; | ||
1922 | |||
1923 | // setup all necessary effect managers | ||
1924 | for (var key in _Platform_effectManagers) | ||
1925 | { | ||
1926 | var manager = _Platform_effectManagers[key]; | ||
1927 | |||
1928 | if (manager.a) | ||
1929 | { | ||
1930 | ports = ports || {}; | ||
1931 | ports[key] = manager.a(key, sendToApp); | ||
1932 | } | ||
1933 | |||
1934 | managers[key] = _Platform_instantiateManager(manager, sendToApp); | ||
1935 | } | ||
1936 | |||
1937 | return ports; | ||
1938 | } | ||
1939 | |||
1940 | |||
1941 | function _Platform_createManager(init, onEffects, onSelfMsg, cmdMap, subMap) | ||
1942 | { | ||
1943 | return { | ||
1944 | b: init, | ||
1945 | c: onEffects, | ||
1946 | d: onSelfMsg, | ||
1947 | e: cmdMap, | ||
1948 | f: subMap | ||
1949 | }; | ||
1950 | } | ||
1951 | |||
1952 | |||
1953 | function _Platform_instantiateManager(info, sendToApp) | ||
1954 | { | ||
1955 | var router = { | ||
1956 | g: sendToApp, | ||
1957 | h: undefined | ||
1958 | }; | ||
1959 | |||
1960 | var onEffects = info.c; | ||
1961 | var onSelfMsg = info.d; | ||
1962 | var cmdMap = info.e; | ||
1963 | var subMap = info.f; | ||
1964 | |||
1965 | function loop(state) | ||
1966 | { | ||
1967 | return A2(_Scheduler_andThen, loop, _Scheduler_receive(function(msg) | ||
1968 | { | ||
1969 | var value = msg.a; | ||
1970 | |||
1971 | if (msg.$ === 0) | ||
1972 | { | ||
1973 | return A3(onSelfMsg, router, value, state); | ||
1974 | } | ||
1975 | |||
1976 | return cmdMap && subMap | ||
1977 | ? A4(onEffects, router, value.i, value.j, state) | ||
1978 | : A3(onEffects, router, cmdMap ? value.i : value.j, state); | ||
1979 | })); | ||
1980 | } | ||
1981 | |||
1982 | return router.h = _Scheduler_rawSpawn(A2(_Scheduler_andThen, loop, info.b)); | ||
1983 | } | ||
1984 | |||
1985 | |||
1986 | |||
1987 | // ROUTING | ||
1988 | |||
1989 | |||
1990 | var _Platform_sendToApp = F2(function(router, msg) | ||
1991 | { | ||
1992 | return _Scheduler_binding(function(callback) | ||
1993 | { | ||
1994 | router.g(msg); | ||
1995 | callback(_Scheduler_succeed(_Utils_Tuple0)); | ||
1996 | }); | ||
1997 | }); | ||
1998 | |||
1999 | |||
2000 | var _Platform_sendToSelf = F2(function(router, msg) | ||
2001 | { | ||
2002 | return A2(_Scheduler_send, router.h, { | ||
2003 | $: 0, | ||
2004 | a: msg | ||
2005 | }); | ||
2006 | }); | ||
2007 | |||
2008 | |||
2009 | |||
2010 | // BAGS | ||
2011 | |||
2012 | |||
2013 | function _Platform_leaf(home) | ||
2014 | { | ||
2015 | return function(value) | ||
2016 | { | ||
2017 | return { | ||
2018 | $: 1, | ||
2019 | k: home, | ||
2020 | l: value | ||
2021 | }; | ||
2022 | }; | ||
2023 | } | ||
2024 | |||
2025 | |||
2026 | function _Platform_batch(list) | ||
2027 | { | ||
2028 | return { | ||
2029 | $: 2, | ||
2030 | m: list | ||
2031 | }; | ||
2032 | } | ||
2033 | |||
2034 | |||
2035 | var _Platform_map = F2(function(tagger, bag) | ||
2036 | { | ||
2037 | return { | ||
2038 | $: 3, | ||
2039 | n: tagger, | ||
2040 | o: bag | ||
2041 | } | ||
2042 | }); | ||
2043 | |||
2044 | |||
2045 | |||
2046 | // PIPE BAGS INTO EFFECT MANAGERS | ||
2047 | // | ||
2048 | // Effects must be queued! | ||
2049 | // | ||
2050 | // Say your init contains a synchronous command, like Time.now or Time.here | ||
2051 | // | ||
2052 | // - This will produce a batch of effects (FX_1) | ||
2053 | // - The synchronous task triggers the subsequent `update` call | ||
2054 | // - This will produce a batch of effects (FX_2) | ||
2055 | // | ||
2056 | // If we just start dispatching FX_2, subscriptions from FX_2 can be processed | ||
2057 | // before subscriptions from FX_1. No good! Earlier versions of this code had | ||
2058 | // this problem, leading to these reports: | ||
2059 | // | ||
2060 | // https://github.com/elm/core/issues/980 | ||
2061 | // https://github.com/elm/core/pull/981 | ||
2062 | // https://github.com/elm/compiler/issues/1776 | ||
2063 | // | ||
2064 | // The queue is necessary to avoid ordering issues for synchronous commands. | ||
2065 | |||
2066 | |||
2067 | // Why use true/false here? Why not just check the length of the queue? | ||
2068 | // The goal is to detect "are we currently dispatching effects?" If we | ||
2069 | // are, we need to bail and let the ongoing while loop handle things. | ||
2070 | // | ||
2071 | // Now say the queue has 1 element. When we dequeue the final element, | ||
2072 | // the queue will be empty, but we are still actively dispatching effects. | ||
2073 | // So you could get queue jumping in a really tricky category of cases. | ||
2074 | // | ||
2075 | var _Platform_effectsQueue = []; | ||
2076 | var _Platform_effectsActive = false; | ||
2077 | |||
2078 | |||
2079 | function _Platform_enqueueEffects(managers, cmdBag, subBag) | ||
2080 | { | ||
2081 | _Platform_effectsQueue.push({ p: managers, q: cmdBag, r: subBag }); | ||
2082 | |||
2083 | if (_Platform_effectsActive) return; | ||
2084 | |||
2085 | _Platform_effectsActive = true; | ||
2086 | for (var fx; fx = _Platform_effectsQueue.shift(); ) | ||
2087 | { | ||
2088 | _Platform_dispatchEffects(fx.p, fx.q, fx.r); | ||
2089 | } | ||
2090 | _Platform_effectsActive = false; | ||
2091 | } | ||
2092 | |||
2093 | |||
2094 | function _Platform_dispatchEffects(managers, cmdBag, subBag) | ||
2095 | { | ||
2096 | var effectsDict = {}; | ||
2097 | _Platform_gatherEffects(true, cmdBag, effectsDict, null); | ||
2098 | _Platform_gatherEffects(false, subBag, effectsDict, null); | ||
2099 | |||
2100 | for (var home in managers) | ||
2101 | { | ||
2102 | _Scheduler_rawSend(managers[home], { | ||
2103 | $: 'fx', | ||
2104 | a: effectsDict[home] || { i: _List_Nil, j: _List_Nil } | ||
2105 | }); | ||
2106 | } | ||
2107 | } | ||
2108 | |||
2109 | |||
2110 | function _Platform_gatherEffects(isCmd, bag, effectsDict, taggers) | ||
2111 | { | ||
2112 | switch (bag.$) | ||
2113 | { | ||
2114 | case 1: | ||
2115 | var home = bag.k; | ||
2116 | var effect = _Platform_toEffect(isCmd, home, taggers, bag.l); | ||
2117 | effectsDict[home] = _Platform_insert(isCmd, effect, effectsDict[home]); | ||
2118 | return; | ||
2119 | |||
2120 | case 2: | ||
2121 | for (var list = bag.m; list.b; list = list.b) // WHILE_CONS | ||
2122 | { | ||
2123 | _Platform_gatherEffects(isCmd, list.a, effectsDict, taggers); | ||
2124 | } | ||
2125 | return; | ||
2126 | |||
2127 | case 3: | ||
2128 | _Platform_gatherEffects(isCmd, bag.o, effectsDict, { | ||
2129 | s: bag.n, | ||
2130 | t: taggers | ||
2131 | }); | ||
2132 | return; | ||
2133 | } | ||
2134 | } | ||
2135 | |||
2136 | |||
2137 | function _Platform_toEffect(isCmd, home, taggers, value) | ||
2138 | { | ||
2139 | function applyTaggers(x) | ||
2140 | { | ||
2141 | for (var temp = taggers; temp; temp = temp.t) | ||
2142 | { | ||
2143 | x = temp.s(x); | ||
2144 | } | ||
2145 | return x; | ||
2146 | } | ||
2147 | |||
2148 | var map = isCmd | ||
2149 | ? _Platform_effectManagers[home].e | ||
2150 | : _Platform_effectManagers[home].f; | ||
2151 | |||
2152 | return A2(map, applyTaggers, value) | ||
2153 | } | ||
2154 | |||
2155 | |||
2156 | function _Platform_insert(isCmd, newEffect, effects) | ||
2157 | { | ||
2158 | effects = effects || { i: _List_Nil, j: _List_Nil }; | ||
2159 | |||
2160 | isCmd | ||
2161 | ? (effects.i = _List_Cons(newEffect, effects.i)) | ||
2162 | : (effects.j = _List_Cons(newEffect, effects.j)); | ||
2163 | |||
2164 | return effects; | ||
2165 | } | ||
2166 | |||
2167 | |||
2168 | |||
2169 | // PORTS | ||
2170 | |||
2171 | |||
2172 | function _Platform_checkPortName(name) | ||
2173 | { | ||
2174 | if (_Platform_effectManagers[name]) | ||
2175 | { | ||
2176 | _Debug_crash(3, name) | ||
2177 | } | ||
2178 | } | ||
2179 | |||
2180 | |||
2181 | |||
2182 | // OUTGOING PORTS | ||
2183 | |||
2184 | |||
2185 | function _Platform_outgoingPort(name, converter) | ||
2186 | { | ||
2187 | _Platform_checkPortName(name); | ||
2188 | _Platform_effectManagers[name] = { | ||
2189 | e: _Platform_outgoingPortMap, | ||
2190 | u: converter, | ||
2191 | a: _Platform_setupOutgoingPort | ||
2192 | }; | ||
2193 | return _Platform_leaf(name); | ||
2194 | } | ||
2195 | |||
2196 | |||
2197 | var _Platform_outgoingPortMap = F2(function(tagger, value) { return value; }); | ||
2198 | |||
2199 | |||
2200 | function _Platform_setupOutgoingPort(name) | ||
2201 | { | ||
2202 | var subs = []; | ||
2203 | var converter = _Platform_effectManagers[name].u; | ||
2204 | |||
2205 | // CREATE MANAGER | ||
2206 | |||
2207 | var init = _Process_sleep(0); | ||
2208 | |||
2209 | _Platform_effectManagers[name].b = init; | ||
2210 | _Platform_effectManagers[name].c = F3(function(router, cmdList, state) | ||
2211 | { | ||
2212 | for ( ; cmdList.b; cmdList = cmdList.b) // WHILE_CONS | ||
2213 | { | ||
2214 | // grab a separate reference to subs in case unsubscribe is called | ||
2215 | var currentSubs = subs; | ||
2216 | var value = _Json_unwrap(converter(cmdList.a)); | ||
2217 | for (var i = 0; i < currentSubs.length; i++) | ||
2218 | { | ||
2219 | currentSubs[i](value); | ||
2220 | } | ||
2221 | } | ||
2222 | return init; | ||
2223 | }); | ||
2224 | |||
2225 | // PUBLIC API | ||
2226 | |||
2227 | function subscribe(callback) | ||
2228 | { | ||
2229 | subs.push(callback); | ||
2230 | } | ||
2231 | |||
2232 | function unsubscribe(callback) | ||
2233 | { | ||
2234 | // copy subs into a new array in case unsubscribe is called within a | ||
2235 | // subscribed callback | ||
2236 | subs = subs.slice(); | ||
2237 | var index = subs.indexOf(callback); | ||
2238 | if (index >= 0) | ||
2239 | { | ||
2240 | subs.splice(index, 1); | ||
2241 | } | ||
2242 | } | ||
2243 | |||
2244 | return { | ||
2245 | subscribe: subscribe, | ||
2246 | unsubscribe: unsubscribe | ||
2247 | }; | ||
2248 | } | ||
2249 | |||
2250 | |||
2251 | |||
2252 | // INCOMING PORTS | ||
2253 | |||
2254 | |||
2255 | function _Platform_incomingPort(name, converter) | ||
2256 | { | ||
2257 | _Platform_checkPortName(name); | ||
2258 | _Platform_effectManagers[name] = { | ||
2259 | f: _Platform_incomingPortMap, | ||
2260 | u: converter, | ||
2261 | a: _Platform_setupIncomingPort | ||
2262 | }; | ||
2263 | return _Platform_leaf(name); | ||
2264 | } | ||
2265 | |||
2266 | |||
2267 | var _Platform_incomingPortMap = F2(function(tagger, finalTagger) | ||
2268 | { | ||
2269 | return function(value) | ||
2270 | { | ||
2271 | return tagger(finalTagger(value)); | ||
2272 | }; | ||
2273 | }); | ||
2274 | |||
2275 | |||
2276 | function _Platform_setupIncomingPort(name, sendToApp) | ||
2277 | { | ||
2278 | var subs = _List_Nil; | ||
2279 | var converter = _Platform_effectManagers[name].u; | ||
2280 | |||
2281 | // CREATE MANAGER | ||
2282 | |||
2283 | var init = _Scheduler_succeed(null); | ||
2284 | |||
2285 | _Platform_effectManagers[name].b = init; | ||
2286 | _Platform_effectManagers[name].c = F3(function(router, subList, state) | ||
2287 | { | ||
2288 | subs = subList; | ||
2289 | return init; | ||
2290 | }); | ||
2291 | |||
2292 | // PUBLIC API | ||
2293 | |||
2294 | function send(incomingValue) | ||
2295 | { | ||
2296 | var result = A2(_Json_run, converter, _Json_wrap(incomingValue)); | ||
2297 | |||
2298 | $elm$core$Result$isOk(result) || _Debug_crash(4, name, result.a); | ||
2299 | |||
2300 | var value = result.a; | ||
2301 | for (var temp = subs; temp.b; temp = temp.b) // WHILE_CONS | ||
2302 | { | ||
2303 | sendToApp(temp.a(value)); | ||
2304 | } | ||
2305 | } | ||
2306 | |||
2307 | return { send: send }; | ||
2308 | } | ||
2309 | |||
2310 | |||
2311 | |||
2312 | // EXPORT ELM MODULES | ||
2313 | // | ||
2314 | // Have DEBUG and PROD versions so that we can (1) give nicer errors in | ||
2315 | // debug mode and (2) not pay for the bits needed for that in prod mode. | ||
2316 | // | ||
2317 | |||
2318 | |||
2319 | function _Platform_export_UNUSED(exports) | ||
2320 | { | ||
2321 | scope['Elm'] | ||
2322 | ? _Platform_mergeExportsProd(scope['Elm'], exports) | ||
2323 | : scope['Elm'] = exports; | ||
2324 | } | ||
2325 | |||
2326 | |||
2327 | function _Platform_mergeExportsProd(obj, exports) | ||
2328 | { | ||
2329 | for (var name in exports) | ||
2330 | { | ||
2331 | (name in obj) | ||
2332 | ? (name == 'init') | ||
2333 | ? _Debug_crash(6) | ||
2334 | : _Platform_mergeExportsProd(obj[name], exports[name]) | ||
2335 | : (obj[name] = exports[name]); | ||
2336 | } | ||
2337 | } | ||
2338 | |||
2339 | |||
2340 | function _Platform_export(exports) | ||
2341 | { | ||
2342 | scope['Elm'] | ||
2343 | ? _Platform_mergeExportsDebug('Elm', scope['Elm'], exports) | ||
2344 | : scope['Elm'] = exports; | ||
2345 | } | ||
2346 | |||
2347 | |||
2348 | function _Platform_mergeExportsDebug(moduleName, obj, exports) | ||
2349 | { | ||
2350 | for (var name in exports) | ||
2351 | { | ||
2352 | (name in obj) | ||
2353 | ? (name == 'init') | ||
2354 | ? _Debug_crash(6, moduleName) | ||
2355 | : _Platform_mergeExportsDebug(moduleName + '.' + name, obj[name], exports[name]) | ||
2356 | : (obj[name] = exports[name]); | ||
2357 | } | ||
2358 | } | ||
2359 | |||
2360 | |||
2361 | |||
2362 | |||
2363 | // HELPERS | ||
2364 | |||
2365 | |||
2366 | var _VirtualDom_divertHrefToApp; | ||
2367 | |||
2368 | var _VirtualDom_doc = typeof document !== 'undefined' ? document : {}; | ||
2369 | |||
2370 | |||
2371 | function _VirtualDom_appendChild(parent, child) | ||
2372 | { | ||
2373 | parent.appendChild(child); | ||
2374 | } | ||
2375 | |||
2376 | var _VirtualDom_init = F4(function(virtualNode, flagDecoder, debugMetadata, args) | ||
2377 | { | ||
2378 | // NOTE: this function needs _Platform_export available to work | ||
2379 | |||
2380 | /**_UNUSED/ | ||
2381 | var node = args['node']; | ||
2382 | //*/ | ||
2383 | /**/ | ||
2384 | var node = args && args['node'] ? args['node'] : _Debug_crash(0); | ||
2385 | //*/ | ||
2386 | |||
2387 | node.parentNode.replaceChild( | ||
2388 | _VirtualDom_render(virtualNode, function() {}), | ||
2389 | node | ||
2390 | ); | ||
2391 | |||
2392 | return {}; | ||
2393 | }); | ||
2394 | |||
2395 | |||
2396 | |||
2397 | // TEXT | ||
2398 | |||
2399 | |||
2400 | function _VirtualDom_text(string) | ||
2401 | { | ||
2402 | return { | ||
2403 | $: 0, | ||
2404 | a: string | ||
2405 | }; | ||
2406 | } | ||
2407 | |||
2408 | |||
2409 | |||
2410 | // NODE | ||
2411 | |||
2412 | |||
2413 | var _VirtualDom_nodeNS = F2(function(namespace, tag) | ||
2414 | { | ||
2415 | return F2(function(factList, kidList) | ||
2416 | { | ||
2417 | for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS | ||
2418 | { | ||
2419 | var kid = kidList.a; | ||
2420 | descendantsCount += (kid.b || 0); | ||
2421 | kids.push(kid); | ||
2422 | } | ||
2423 | descendantsCount += kids.length; | ||
2424 | |||
2425 | return { | ||
2426 | $: 1, | ||
2427 | c: tag, | ||
2428 | d: _VirtualDom_organizeFacts(factList), | ||
2429 | e: kids, | ||
2430 | f: namespace, | ||
2431 | b: descendantsCount | ||
2432 | }; | ||
2433 | }); | ||
2434 | }); | ||
2435 | |||
2436 | |||
2437 | var _VirtualDom_node = _VirtualDom_nodeNS(undefined); | ||
2438 | |||
2439 | |||
2440 | |||
2441 | // KEYED NODE | ||
2442 | |||
2443 | |||
2444 | var _VirtualDom_keyedNodeNS = F2(function(namespace, tag) | ||
2445 | { | ||
2446 | return F2(function(factList, kidList) | ||
2447 | { | ||
2448 | for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS | ||
2449 | { | ||
2450 | var kid = kidList.a; | ||
2451 | descendantsCount += (kid.b.b || 0); | ||
2452 | kids.push(kid); | ||
2453 | } | ||
2454 | descendantsCount += kids.length; | ||
2455 | |||
2456 | return { | ||
2457 | $: 2, | ||
2458 | c: tag, | ||
2459 | d: _VirtualDom_organizeFacts(factList), | ||
2460 | e: kids, | ||
2461 | f: namespace, | ||
2462 | b: descendantsCount | ||
2463 | }; | ||
2464 | }); | ||
2465 | }); | ||
2466 | |||
2467 | |||
2468 | var _VirtualDom_keyedNode = _VirtualDom_keyedNodeNS(undefined); | ||
2469 | |||
2470 | |||
2471 | |||
2472 | // CUSTOM | ||
2473 | |||
2474 | |||
2475 | function _VirtualDom_custom(factList, model, render, diff) | ||
2476 | { | ||
2477 | return { | ||
2478 | $: 3, | ||
2479 | d: _VirtualDom_organizeFacts(factList), | ||
2480 | g: model, | ||
2481 | h: render, | ||
2482 | i: diff | ||
2483 | }; | ||
2484 | } | ||
2485 | |||
2486 | |||
2487 | |||
2488 | // MAP | ||
2489 | |||
2490 | |||
2491 | var _VirtualDom_map = F2(function(tagger, node) | ||
2492 | { | ||
2493 | return { | ||
2494 | $: 4, | ||
2495 | j: tagger, | ||
2496 | k: node, | ||
2497 | b: 1 + (node.b || 0) | ||
2498 | }; | ||
2499 | }); | ||
2500 | |||
2501 | |||
2502 | |||
2503 | // LAZY | ||
2504 | |||
2505 | |||
2506 | function _VirtualDom_thunk(refs, thunk) | ||
2507 | { | ||
2508 | return { | ||
2509 | $: 5, | ||
2510 | l: refs, | ||
2511 | m: thunk, | ||
2512 | k: undefined | ||
2513 | }; | ||
2514 | } | ||
2515 | |||
2516 | var _VirtualDom_lazy = F2(function(func, a) | ||
2517 | { | ||
2518 | return _VirtualDom_thunk([func, a], function() { | ||
2519 | return func(a); | ||
2520 | }); | ||
2521 | }); | ||
2522 | |||
2523 | var _VirtualDom_lazy2 = F3(function(func, a, b) | ||
2524 | { | ||
2525 | return _VirtualDom_thunk([func, a, b], function() { | ||
2526 | return A2(func, a, b); | ||
2527 | }); | ||
2528 | }); | ||
2529 | |||
2530 | var _VirtualDom_lazy3 = F4(function(func, a, b, c) | ||
2531 | { | ||
2532 | return _VirtualDom_thunk([func, a, b, c], function() { | ||
2533 | return A3(func, a, b, c); | ||
2534 | }); | ||
2535 | }); | ||
2536 | |||
2537 | var _VirtualDom_lazy4 = F5(function(func, a, b, c, d) | ||
2538 | { | ||
2539 | return _VirtualDom_thunk([func, a, b, c, d], function() { | ||
2540 | return A4(func, a, b, c, d); | ||
2541 | }); | ||
2542 | }); | ||
2543 | |||
2544 | var _VirtualDom_lazy5 = F6(function(func, a, b, c, d, e) | ||
2545 | { | ||
2546 | return _VirtualDom_thunk([func, a, b, c, d, e], function() { | ||
2547 | return A5(func, a, b, c, d, e); | ||
2548 | }); | ||
2549 | }); | ||
2550 | |||
2551 | var _VirtualDom_lazy6 = F7(function(func, a, b, c, d, e, f) | ||
2552 | { | ||
2553 | return _VirtualDom_thunk([func, a, b, c, d, e, f], function() { | ||
2554 | return A6(func, a, b, c, d, e, f); | ||
2555 | }); | ||
2556 | }); | ||
2557 | |||
2558 | var _VirtualDom_lazy7 = F8(function(func, a, b, c, d, e, f, g) | ||
2559 | { | ||
2560 | return _VirtualDom_thunk([func, a, b, c, d, e, f, g], function() { | ||
2561 | return A7(func, a, b, c, d, e, f, g); | ||
2562 | }); | ||
2563 | }); | ||
2564 | |||
2565 | var _VirtualDom_lazy8 = F9(function(func, a, b, c, d, e, f, g, h) | ||
2566 | { | ||
2567 | return _VirtualDom_thunk([func, a, b, c, d, e, f, g, h], function() { | ||
2568 | return A8(func, a, b, c, d, e, f, g, h); | ||
2569 | }); | ||
2570 | }); | ||
2571 | |||
2572 | |||
2573 | |||
2574 | // FACTS | ||
2575 | |||
2576 | |||
2577 | var _VirtualDom_on = F2(function(key, handler) | ||
2578 | { | ||
2579 | return { | ||
2580 | $: 'a0', | ||
2581 | n: key, | ||
2582 | o: handler | ||
2583 | }; | ||
2584 | }); | ||
2585 | var _VirtualDom_style = F2(function(key, value) | ||
2586 | { | ||
2587 | return { | ||
2588 | $: 'a1', | ||
2589 | n: key, | ||
2590 | o: value | ||
2591 | }; | ||
2592 | }); | ||
2593 | var _VirtualDom_property = F2(function(key, value) | ||
2594 | { | ||
2595 | return { | ||
2596 | $: 'a2', | ||
2597 | n: key, | ||
2598 | o: value | ||
2599 | }; | ||
2600 | }); | ||
2601 | var _VirtualDom_attribute = F2(function(key, value) | ||
2602 | { | ||
2603 | return { | ||
2604 | $: 'a3', | ||
2605 | n: key, | ||
2606 | o: value | ||
2607 | }; | ||
2608 | }); | ||
2609 | var _VirtualDom_attributeNS = F3(function(namespace, key, value) | ||
2610 | { | ||
2611 | return { | ||
2612 | $: 'a4', | ||
2613 | n: key, | ||
2614 | o: { f: namespace, o: value } | ||
2615 | }; | ||
2616 | }); | ||
2617 | |||
2618 | |||
2619 | |||
2620 | // XSS ATTACK VECTOR CHECKS | ||
2621 | |||
2622 | |||
2623 | function _VirtualDom_noScript(tag) | ||
2624 | { | ||
2625 | return tag == 'script' ? 'p' : tag; | ||
2626 | } | ||
2627 | |||
2628 | function _VirtualDom_noOnOrFormAction(key) | ||
2629 | { | ||
2630 | return /^(on|formAction$)/i.test(key) ? 'data-' + key : key; | ||
2631 | } | ||
2632 | |||
2633 | function _VirtualDom_noInnerHtmlOrFormAction(key) | ||
2634 | { | ||
2635 | return key == 'innerHTML' || key == 'formAction' ? 'data-' + key : key; | ||
2636 | } | ||
2637 | |||
2638 | function _VirtualDom_noJavaScriptUri_UNUSED(value) | ||
2639 | { | ||
2640 | return /^javascript:/i.test(value.replace(/\s/g,'')) ? '' : value; | ||
2641 | } | ||
2642 | |||
2643 | function _VirtualDom_noJavaScriptUri(value) | ||
2644 | { | ||
2645 | return /^javascript:/i.test(value.replace(/\s/g,'')) | ||
2646 | ? 'javascript:alert("This is an XSS vector. Please use ports or web components instead.")' | ||
2647 | : value; | ||
2648 | } | ||
2649 | |||
2650 | function _VirtualDom_noJavaScriptOrHtmlUri_UNUSED(value) | ||
2651 | { | ||
2652 | return /^\s*(javascript:|data:text\/html)/i.test(value) ? '' : value; | ||
2653 | } | ||
2654 | |||
2655 | function _VirtualDom_noJavaScriptOrHtmlUri(value) | ||
2656 | { | ||
2657 | return /^\s*(javascript:|data:text\/html)/i.test(value) | ||
2658 | ? 'javascript:alert("This is an XSS vector. Please use ports or web components instead.")' | ||
2659 | : value; | ||
2660 | } | ||
2661 | |||
2662 | |||
2663 | |||
2664 | // MAP FACTS | ||
2665 | |||
2666 | |||
2667 | var _VirtualDom_mapAttribute = F2(function(func, attr) | ||
2668 | { | ||
2669 | return (attr.$ === 'a0') | ||
2670 | ? A2(_VirtualDom_on, attr.n, _VirtualDom_mapHandler(func, attr.o)) | ||
2671 | : attr; | ||
2672 | }); | ||
2673 | |||
2674 | function _VirtualDom_mapHandler(func, handler) | ||
2675 | { | ||
2676 | var tag = $elm$virtual_dom$VirtualDom$toHandlerInt(handler); | ||
2677 | |||
2678 | // 0 = Normal | ||
2679 | // 1 = MayStopPropagation | ||
2680 | // 2 = MayPreventDefault | ||
2681 | // 3 = Custom | ||
2682 | |||
2683 | return { | ||
2684 | $: handler.$, | ||
2685 | a: | ||
2686 | !tag | ||
2687 | ? A2($elm$json$Json$Decode$map, func, handler.a) | ||
2688 | : | ||
2689 | A3($elm$json$Json$Decode$map2, | ||
2690 | tag < 3 | ||
2691 | ? _VirtualDom_mapEventTuple | ||
2692 | : _VirtualDom_mapEventRecord, | ||
2693 | $elm$json$Json$Decode$succeed(func), | ||
2694 | handler.a | ||
2695 | ) | ||
2696 | }; | ||
2697 | } | ||
2698 | |||
2699 | var _VirtualDom_mapEventTuple = F2(function(func, tuple) | ||
2700 | { | ||
2701 | return _Utils_Tuple2(func(tuple.a), tuple.b); | ||
2702 | }); | ||
2703 | |||
2704 | var _VirtualDom_mapEventRecord = F2(function(func, record) | ||
2705 | { | ||
2706 | return { | ||
2707 | message: func(record.message), | ||
2708 | stopPropagation: record.stopPropagation, | ||
2709 | preventDefault: record.preventDefault | ||
2710 | } | ||
2711 | }); | ||
2712 | |||
2713 | |||
2714 | |||
2715 | // ORGANIZE FACTS | ||
2716 | |||
2717 | |||
2718 | function _VirtualDom_organizeFacts(factList) | ||
2719 | { | ||
2720 | for (var facts = {}; factList.b; factList = factList.b) // WHILE_CONS | ||
2721 | { | ||
2722 | var entry = factList.a; | ||
2723 | |||
2724 | var tag = entry.$; | ||
2725 | var key = entry.n; | ||
2726 | var value = entry.o; | ||
2727 | |||
2728 | if (tag === 'a2') | ||
2729 | { | ||
2730 | (key === 'className') | ||
2731 | ? _VirtualDom_addClass(facts, key, _Json_unwrap(value)) | ||
2732 | : facts[key] = _Json_unwrap(value); | ||
2733 | |||
2734 | continue; | ||
2735 | } | ||
2736 | |||
2737 | var subFacts = facts[tag] || (facts[tag] = {}); | ||
2738 | (tag === 'a3' && key === 'class') | ||
2739 | ? _VirtualDom_addClass(subFacts, key, value) | ||
2740 | : subFacts[key] = value; | ||
2741 | } | ||
2742 | |||
2743 | return facts; | ||
2744 | } | ||
2745 | |||
2746 | function _VirtualDom_addClass(object, key, newClass) | ||
2747 | { | ||
2748 | var classes = object[key]; | ||
2749 | object[key] = classes ? classes + ' ' + newClass : newClass; | ||
2750 | } | ||
2751 | |||
2752 | |||
2753 | |||
2754 | // RENDER | ||
2755 | |||
2756 | |||
2757 | function _VirtualDom_render(vNode, eventNode) | ||
2758 | { | ||
2759 | var tag = vNode.$; | ||
2760 | |||
2761 | if (tag === 5) | ||
2762 | { | ||
2763 | return _VirtualDom_render(vNode.k || (vNode.k = vNode.m()), eventNode); | ||
2764 | } | ||
2765 | |||
2766 | if (tag === 0) | ||
2767 | { | ||
2768 | return _VirtualDom_doc.createTextNode(vNode.a); | ||
2769 | } | ||
2770 | |||
2771 | if (tag === 4) | ||
2772 | { | ||
2773 | var subNode = vNode.k; | ||
2774 | var tagger = vNode.j; | ||
2775 | |||
2776 | while (subNode.$ === 4) | ||
2777 | { | ||
2778 | typeof tagger !== 'object' | ||
2779 | ? tagger = [tagger, subNode.j] | ||
2780 | : tagger.push(subNode.j); | ||
2781 | |||
2782 | subNode = subNode.k; | ||
2783 | } | ||
2784 | |||
2785 | var subEventRoot = { j: tagger, p: eventNode }; | ||
2786 | var domNode = _VirtualDom_render(subNode, subEventRoot); | ||
2787 | domNode.elm_event_node_ref = subEventRoot; | ||
2788 | return domNode; | ||
2789 | } | ||
2790 | |||
2791 | if (tag === 3) | ||
2792 | { | ||
2793 | var domNode = vNode.h(vNode.g); | ||
2794 | _VirtualDom_applyFacts(domNode, eventNode, vNode.d); | ||
2795 | return domNode; | ||
2796 | } | ||
2797 | |||
2798 | // at this point `tag` must be 1 or 2 | ||
2799 | |||
2800 | var domNode = vNode.f | ||
2801 | ? _VirtualDom_doc.createElementNS(vNode.f, vNode.c) | ||
2802 | : _VirtualDom_doc.createElement(vNode.c); | ||
2803 | |||
2804 | if (_VirtualDom_divertHrefToApp && vNode.c == 'a') | ||
2805 | { | ||
2806 | domNode.addEventListener('click', _VirtualDom_divertHrefToApp(domNode)); | ||
2807 | } | ||
2808 | |||
2809 | _VirtualDom_applyFacts(domNode, eventNode, vNode.d); | ||
2810 | |||
2811 | for (var kids = vNode.e, i = 0; i < kids.length; i++) | ||
2812 | { | ||
2813 | _VirtualDom_appendChild(domNode, _VirtualDom_render(tag === 1 ? kids[i] : kids[i].b, eventNode)); | ||
2814 | } | ||
2815 | |||
2816 | return domNode; | ||
2817 | } | ||
2818 | |||
2819 | |||
2820 | |||
2821 | // APPLY FACTS | ||
2822 | |||
2823 | |||
2824 | function _VirtualDom_applyFacts(domNode, eventNode, facts) | ||
2825 | { | ||
2826 | for (var key in facts) | ||
2827 | { | ||
2828 | var value = facts[key]; | ||
2829 | |||
2830 | key === 'a1' | ||
2831 | ? _VirtualDom_applyStyles(domNode, value) | ||
2832 | : | ||
2833 | key === 'a0' | ||
2834 | ? _VirtualDom_applyEvents(domNode, eventNode, value) | ||
2835 | : | ||
2836 | key === 'a3' | ||
2837 | ? _VirtualDom_applyAttrs(domNode, value) | ||
2838 | : | ||
2839 | key === 'a4' | ||
2840 | ? _VirtualDom_applyAttrsNS(domNode, value) | ||
2841 | : | ||
2842 | ((key !== 'value' && key !== 'checked') || domNode[key] !== value) && (domNode[key] = value); | ||
2843 | } | ||
2844 | } | ||
2845 | |||
2846 | |||
2847 | |||
2848 | // APPLY STYLES | ||
2849 | |||
2850 | |||
2851 | function _VirtualDom_applyStyles(domNode, styles) | ||
2852 | { | ||
2853 | var domNodeStyle = domNode.style; | ||
2854 | |||
2855 | for (var key in styles) | ||
2856 | { | ||
2857 | domNodeStyle[key] = styles[key]; | ||
2858 | } | ||
2859 | } | ||
2860 | |||
2861 | |||
2862 | |||
2863 | // APPLY ATTRS | ||
2864 | |||
2865 | |||
2866 | function _VirtualDom_applyAttrs(domNode, attrs) | ||
2867 | { | ||
2868 | for (var key in attrs) | ||
2869 | { | ||
2870 | var value = attrs[key]; | ||
2871 | typeof value !== 'undefined' | ||
2872 | ? domNode.setAttribute(key, value) | ||
2873 | : domNode.removeAttribute(key); | ||
2874 | } | ||
2875 | } | ||
2876 | |||
2877 | |||
2878 | |||
2879 | // APPLY NAMESPACED ATTRS | ||
2880 | |||
2881 | |||
2882 | function _VirtualDom_applyAttrsNS(domNode, nsAttrs) | ||
2883 | { | ||
2884 | for (var key in nsAttrs) | ||
2885 | { | ||
2886 | var pair = nsAttrs[key]; | ||
2887 | var namespace = pair.f; | ||
2888 | var value = pair.o; | ||
2889 | |||
2890 | typeof value !== 'undefined' | ||
2891 | ? domNode.setAttributeNS(namespace, key, value) | ||
2892 | : domNode.removeAttributeNS(namespace, key); | ||
2893 | } | ||
2894 | } | ||
2895 | |||
2896 | |||
2897 | |||
2898 | // APPLY EVENTS | ||
2899 | |||
2900 | |||
2901 | function _VirtualDom_applyEvents(domNode, eventNode, events) | ||
2902 | { | ||
2903 | var allCallbacks = domNode.elmFs || (domNode.elmFs = {}); | ||
2904 | |||
2905 | for (var key in events) | ||
2906 | { | ||
2907 | var newHandler = events[key]; | ||
2908 | var oldCallback = allCallbacks[key]; | ||
2909 | |||
2910 | if (!newHandler) | ||
2911 | { | ||
2912 | domNode.removeEventListener(key, oldCallback); | ||
2913 | allCallbacks[key] = undefined; | ||
2914 | continue; | ||
2915 | } | ||
2916 | |||
2917 | if (oldCallback) | ||
2918 | { | ||
2919 | var oldHandler = oldCallback.q; | ||
2920 | if (oldHandler.$ === newHandler.$) | ||
2921 | { | ||
2922 | oldCallback.q = newHandler; | ||
2923 | continue; | ||
2924 | } | ||
2925 | domNode.removeEventListener(key, oldCallback); | ||
2926 | } | ||
2927 | |||
2928 | oldCallback = _VirtualDom_makeCallback(eventNode, newHandler); | ||
2929 | domNode.addEventListener(key, oldCallback, | ||
2930 | _VirtualDom_passiveSupported | ||
2931 | && { passive: $elm$virtual_dom$VirtualDom$toHandlerInt(newHandler) < 2 } | ||
2932 | ); | ||
2933 | allCallbacks[key] = oldCallback; | ||
2934 | } | ||
2935 | } | ||
2936 | |||
2937 | |||
2938 | |||
2939 | // PASSIVE EVENTS | ||
2940 | |||
2941 | |||
2942 | var _VirtualDom_passiveSupported; | ||
2943 | |||
2944 | try | ||
2945 | { | ||
2946 | window.addEventListener('t', null, Object.defineProperty({}, 'passive', { | ||
2947 | get: function() { _VirtualDom_passiveSupported = true; } | ||
2948 | })); | ||
2949 | } | ||
2950 | catch(e) {} | ||
2951 | |||
2952 | |||
2953 | |||
2954 | // EVENT HANDLERS | ||
2955 | |||
2956 | |||
2957 | function _VirtualDom_makeCallback(eventNode, initialHandler) | ||
2958 | { | ||
2959 | function callback(event) | ||
2960 | { | ||
2961 | var handler = callback.q; | ||
2962 | var result = _Json_runHelp(handler.a, event); | ||
2963 | |||
2964 | if (!$elm$core$Result$isOk(result)) | ||
2965 | { | ||
2966 | return; | ||
2967 | } | ||
2968 | |||
2969 | var tag = $elm$virtual_dom$VirtualDom$toHandlerInt(handler); | ||
2970 | |||
2971 | // 0 = Normal | ||
2972 | // 1 = MayStopPropagation | ||
2973 | // 2 = MayPreventDefault | ||
2974 | // 3 = Custom | ||
2975 | |||
2976 | var value = result.a; | ||
2977 | var message = !tag ? value : tag < 3 ? value.a : value.message; | ||
2978 | var stopPropagation = tag == 1 ? value.b : tag == 3 && value.stopPropagation; | ||
2979 | var currentEventNode = ( | ||
2980 | stopPropagation && event.stopPropagation(), | ||
2981 | (tag == 2 ? value.b : tag == 3 && value.preventDefault) && event.preventDefault(), | ||
2982 | eventNode | ||
2983 | ); | ||
2984 | var tagger; | ||
2985 | var i; | ||
2986 | while (tagger = currentEventNode.j) | ||
2987 | { | ||
2988 | if (typeof tagger == 'function') | ||
2989 | { | ||
2990 | message = tagger(message); | ||
2991 | } | ||
2992 | else | ||
2993 | { | ||
2994 | for (var i = tagger.length; i--; ) | ||
2995 | { | ||
2996 | message = tagger[i](message); | ||
2997 | } | ||
2998 | } | ||
2999 | currentEventNode = currentEventNode.p; | ||
3000 | } | ||
3001 | currentEventNode(message, stopPropagation); // stopPropagation implies isSync | ||
3002 | } | ||
3003 | |||
3004 | callback.q = initialHandler; | ||
3005 | |||
3006 | return callback; | ||
3007 | } | ||
3008 | |||
3009 | function _VirtualDom_equalEvents(x, y) | ||
3010 | { | ||
3011 | return x.$ == y.$ && _Json_equality(x.a, y.a); | ||
3012 | } | ||
3013 | |||
3014 | |||
3015 | |||
3016 | // DIFF | ||
3017 | |||
3018 | |||
3019 | // TODO: Should we do patches like in iOS? | ||
3020 | // | ||
3021 | // type Patch | ||
3022 | // = At Int Patch | ||
3023 | // | Batch (List Patch) | ||
3024 | // | Change ... | ||
3025 | // | ||
3026 | // How could it not be better? | ||
3027 | // | ||
3028 | function _VirtualDom_diff(x, y) | ||
3029 | { | ||
3030 | var patches = []; | ||
3031 | _VirtualDom_diffHelp(x, y, patches, 0); | ||
3032 | return patches; | ||
3033 | } | ||
3034 | |||
3035 | |||
3036 | function _VirtualDom_pushPatch(patches, type, index, data) | ||
3037 | { | ||
3038 | var patch = { | ||
3039 | $: type, | ||
3040 | r: index, | ||
3041 | s: data, | ||
3042 | t: undefined, | ||
3043 | u: undefined | ||
3044 | }; | ||
3045 | patches.push(patch); | ||
3046 | return patch; | ||
3047 | } | ||
3048 | |||
3049 | |||
3050 | function _VirtualDom_diffHelp(x, y, patches, index) | ||
3051 | { | ||
3052 | if (x === y) | ||
3053 | { | ||
3054 | return; | ||
3055 | } | ||
3056 | |||
3057 | var xType = x.$; | ||
3058 | var yType = y.$; | ||
3059 | |||
3060 | // Bail if you run into different types of nodes. Implies that the | ||
3061 | // structure has changed significantly and it's not worth a diff. | ||
3062 | if (xType !== yType) | ||
3063 | { | ||
3064 | if (xType === 1 && yType === 2) | ||
3065 | { | ||
3066 | y = _VirtualDom_dekey(y); | ||
3067 | yType = 1; | ||
3068 | } | ||
3069 | else | ||
3070 | { | ||
3071 | _VirtualDom_pushPatch(patches, 0, index, y); | ||
3072 | return; | ||
3073 | } | ||
3074 | } | ||
3075 | |||
3076 | // Now we know that both nodes are the same $. | ||
3077 | switch (yType) | ||
3078 | { | ||
3079 | case 5: | ||
3080 | var xRefs = x.l; | ||
3081 | var yRefs = y.l; | ||
3082 | var i = xRefs.length; | ||
3083 | var same = i === yRefs.length; | ||
3084 | while (same && i--) | ||
3085 | { | ||
3086 | same = xRefs[i] === yRefs[i]; | ||
3087 | } | ||
3088 | if (same) | ||
3089 | { | ||
3090 | y.k = x.k; | ||
3091 | return; | ||
3092 | } | ||
3093 | y.k = y.m(); | ||
3094 | var subPatches = []; | ||
3095 | _VirtualDom_diffHelp(x.k, y.k, subPatches, 0); | ||
3096 | subPatches.length > 0 && _VirtualDom_pushPatch(patches, 1, index, subPatches); | ||
3097 | return; | ||
3098 | |||
3099 | case 4: | ||
3100 | // gather nested taggers | ||
3101 | var xTaggers = x.j; | ||
3102 | var yTaggers = y.j; | ||
3103 | var nesting = false; | ||
3104 | |||
3105 | var xSubNode = x.k; | ||
3106 | while (xSubNode.$ === 4) | ||
3107 | { | ||
3108 | nesting = true; | ||
3109 | |||
3110 | typeof xTaggers !== 'object' | ||
3111 | ? xTaggers = [xTaggers, xSubNode.j] | ||
3112 | : xTaggers.push(xSubNode.j); | ||
3113 | |||
3114 | xSubNode = xSubNode.k; | ||
3115 | } | ||
3116 | |||
3117 | var ySubNode = y.k; | ||
3118 | while (ySubNode.$ === 4) | ||
3119 | { | ||
3120 | nesting = true; | ||
3121 | |||
3122 | typeof yTaggers !== 'object' | ||
3123 | ? yTaggers = [yTaggers, ySubNode.j] | ||
3124 | : yTaggers.push(ySubNode.j); | ||
3125 | |||
3126 | ySubNode = ySubNode.k; | ||
3127 | } | ||
3128 | |||
3129 | // Just bail if different numbers of taggers. This implies the | ||
3130 | // structure of the virtual DOM has changed. | ||
3131 | if (nesting && xTaggers.length !== yTaggers.length) | ||
3132 | { | ||
3133 | _VirtualDom_pushPatch(patches, 0, index, y); | ||
3134 | return; | ||
3135 | } | ||
3136 | |||
3137 | // check if taggers are "the same" | ||
3138 | if (nesting ? !_VirtualDom_pairwiseRefEqual(xTaggers, yTaggers) : xTaggers !== yTaggers) | ||
3139 | { | ||
3140 | _VirtualDom_pushPatch(patches, 2, index, yTaggers); | ||
3141 | } | ||
3142 | |||
3143 | // diff everything below the taggers | ||
3144 | _VirtualDom_diffHelp(xSubNode, ySubNode, patches, index + 1); | ||
3145 | return; | ||
3146 | |||
3147 | case 0: | ||
3148 | if (x.a !== y.a) | ||
3149 | { | ||
3150 | _VirtualDom_pushPatch(patches, 3, index, y.a); | ||
3151 | } | ||
3152 | return; | ||
3153 | |||
3154 | case 1: | ||
3155 | _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKids); | ||
3156 | return; | ||
3157 | |||
3158 | case 2: | ||
3159 | _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKeyedKids); | ||
3160 | return; | ||
3161 | |||
3162 | case 3: | ||
3163 | if (x.h !== y.h) | ||
3164 | { | ||
3165 | _VirtualDom_pushPatch(patches, 0, index, y); | ||
3166 | return; | ||
3167 | } | ||
3168 | |||
3169 | var factsDiff = _VirtualDom_diffFacts(x.d, y.d); | ||
3170 | factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff); | ||
3171 | |||
3172 | var patch = y.i(x.g, y.g); | ||
3173 | patch && _VirtualDom_pushPatch(patches, 5, index, patch); | ||
3174 | |||
3175 | return; | ||
3176 | } | ||
3177 | } | ||
3178 | |||
3179 | // assumes the incoming arrays are the same length | ||
3180 | function _VirtualDom_pairwiseRefEqual(as, bs) | ||
3181 | { | ||
3182 | for (var i = 0; i < as.length; i++) | ||
3183 | { | ||
3184 | if (as[i] !== bs[i]) | ||
3185 | { | ||
3186 | return false; | ||
3187 | } | ||
3188 | } | ||
3189 | |||
3190 | return true; | ||
3191 | } | ||
3192 | |||
3193 | function _VirtualDom_diffNodes(x, y, patches, index, diffKids) | ||
3194 | { | ||
3195 | // Bail if obvious indicators have changed. Implies more serious | ||
3196 | // structural changes such that it's not worth it to diff. | ||
3197 | if (x.c !== y.c || x.f !== y.f) | ||
3198 | { | ||
3199 | _VirtualDom_pushPatch(patches, 0, index, y); | ||
3200 | return; | ||
3201 | } | ||
3202 | |||
3203 | var factsDiff = _VirtualDom_diffFacts(x.d, y.d); | ||
3204 | factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff); | ||
3205 | |||
3206 | diffKids(x, y, patches, index); | ||
3207 | } | ||
3208 | |||
3209 | |||
3210 | |||
3211 | // DIFF FACTS | ||
3212 | |||
3213 | |||
3214 | // TODO Instead of creating a new diff object, it's possible to just test if | ||
3215 | // there *is* a diff. During the actual patch, do the diff again and make the | ||
3216 | // modifications directly. This way, there's no new allocations. Worth it? | ||
3217 | function _VirtualDom_diffFacts(x, y, category) | ||
3218 | { | ||
3219 | var diff; | ||
3220 | |||
3221 | // look for changes and removals | ||
3222 | for (var xKey in x) | ||
3223 | { | ||
3224 | if (xKey === 'a1' || xKey === 'a0' || xKey === 'a3' || xKey === 'a4') | ||
3225 | { | ||
3226 | var subDiff = _VirtualDom_diffFacts(x[xKey], y[xKey] || {}, xKey); | ||
3227 | if (subDiff) | ||
3228 | { | ||
3229 | diff = diff || {}; | ||
3230 | diff[xKey] = subDiff; | ||
3231 | } | ||
3232 | continue; | ||
3233 | } | ||
3234 | |||
3235 | // remove if not in the new facts | ||
3236 | if (!(xKey in y)) | ||
3237 | { | ||
3238 | diff = diff || {}; | ||
3239 | diff[xKey] = | ||
3240 | !category | ||
3241 | ? (typeof x[xKey] === 'string' ? '' : null) | ||
3242 | : | ||
3243 | (category === 'a1') | ||
3244 | ? '' | ||
3245 | : | ||
3246 | (category === 'a0' || category === 'a3') | ||
3247 | ? undefined | ||
3248 | : | ||
3249 | { f: x[xKey].f, o: undefined }; | ||
3250 | |||
3251 | continue; | ||
3252 | } | ||
3253 | |||
3254 | var xValue = x[xKey]; | ||
3255 | var yValue = y[xKey]; | ||
3256 | |||
3257 | // reference equal, so don't worry about it | ||
3258 | if (xValue === yValue && xKey !== 'value' && xKey !== 'checked' | ||
3259 | || category === 'a0' && _VirtualDom_equalEvents(xValue, yValue)) | ||
3260 | { | ||
3261 | continue; | ||
3262 | } | ||
3263 | |||
3264 | diff = diff || {}; | ||
3265 | diff[xKey] = yValue; | ||
3266 | } | ||
3267 | |||
3268 | // add new stuff | ||
3269 | for (var yKey in y) | ||
3270 | { | ||
3271 | if (!(yKey in x)) | ||
3272 | { | ||
3273 | diff = diff || {}; | ||
3274 | diff[yKey] = y[yKey]; | ||
3275 | } | ||
3276 | } | ||
3277 | |||
3278 | return diff; | ||
3279 | } | ||
3280 | |||
3281 | |||
3282 | |||
3283 | // DIFF KIDS | ||
3284 | |||
3285 | |||
3286 | function _VirtualDom_diffKids(xParent, yParent, patches, index) | ||
3287 | { | ||
3288 | var xKids = xParent.e; | ||
3289 | var yKids = yParent.e; | ||
3290 | |||
3291 | var xLen = xKids.length; | ||
3292 | var yLen = yKids.length; | ||
3293 | |||
3294 | // FIGURE OUT IF THERE ARE INSERTS OR REMOVALS | ||
3295 | |||
3296 | if (xLen > yLen) | ||
3297 | { | ||
3298 | _VirtualDom_pushPatch(patches, 6, index, { | ||
3299 | v: yLen, | ||
3300 | i: xLen - yLen | ||
3301 | }); | ||
3302 | } | ||
3303 | else if (xLen < yLen) | ||
3304 | { | ||
3305 | _VirtualDom_pushPatch(patches, 7, index, { | ||
3306 | v: xLen, | ||
3307 | e: yKids | ||
3308 | }); | ||
3309 | } | ||
3310 | |||
3311 | // PAIRWISE DIFF EVERYTHING ELSE | ||
3312 | |||
3313 | for (var minLen = xLen < yLen ? xLen : yLen, i = 0; i < minLen; i++) | ||
3314 | { | ||
3315 | var xKid = xKids[i]; | ||
3316 | _VirtualDom_diffHelp(xKid, yKids[i], patches, ++index); | ||
3317 | index += xKid.b || 0; | ||
3318 | } | ||
3319 | } | ||
3320 | |||
3321 | |||
3322 | |||
3323 | // KEYED DIFF | ||
3324 | |||
3325 | |||
3326 | function _VirtualDom_diffKeyedKids(xParent, yParent, patches, rootIndex) | ||
3327 | { | ||
3328 | var localPatches = []; | ||
3329 | |||
3330 | var changes = {}; // Dict String Entry | ||
3331 | var inserts = []; // Array { index : Int, entry : Entry } | ||
3332 | // type Entry = { tag : String, vnode : VNode, index : Int, data : _ } | ||
3333 | |||
3334 | var xKids = xParent.e; | ||
3335 | var yKids = yParent.e; | ||
3336 | var xLen = xKids.length; | ||
3337 | var yLen = yKids.length; | ||
3338 | var xIndex = 0; | ||
3339 | var yIndex = 0; | ||
3340 | |||
3341 | var index = rootIndex; | ||
3342 | |||
3343 | while (xIndex < xLen && yIndex < yLen) | ||
3344 | { | ||
3345 | var x = xKids[xIndex]; | ||
3346 | var y = yKids[yIndex]; | ||
3347 | |||
3348 | var xKey = x.a; | ||
3349 | var yKey = y.a; | ||
3350 | var xNode = x.b; | ||
3351 | var yNode = y.b; | ||
3352 | |||
3353 | var newMatch = undefined; | ||
3354 | var oldMatch = undefined; | ||
3355 | |||
3356 | // check if keys match | ||
3357 | |||
3358 | if (xKey === yKey) | ||
3359 | { | ||
3360 | index++; | ||
3361 | _VirtualDom_diffHelp(xNode, yNode, localPatches, index); | ||
3362 | index += xNode.b || 0; | ||
3363 | |||
3364 | xIndex++; | ||
3365 | yIndex++; | ||
3366 | continue; | ||
3367 | } | ||
3368 | |||
3369 | // look ahead 1 to detect insertions and removals. | ||
3370 | |||
3371 | var xNext = xKids[xIndex + 1]; | ||
3372 | var yNext = yKids[yIndex + 1]; | ||
3373 | |||
3374 | if (xNext) | ||
3375 | { | ||
3376 | var xNextKey = xNext.a; | ||
3377 | var xNextNode = xNext.b; | ||
3378 | oldMatch = yKey === xNextKey; | ||
3379 | } | ||
3380 | |||
3381 | if (yNext) | ||
3382 | { | ||
3383 | var yNextKey = yNext.a; | ||
3384 | var yNextNode = yNext.b; | ||
3385 | newMatch = xKey === yNextKey; | ||
3386 | } | ||
3387 | |||
3388 | |||
3389 | // swap x and y | ||
3390 | if (newMatch && oldMatch) | ||
3391 | { | ||
3392 | index++; | ||
3393 | _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index); | ||
3394 | _VirtualDom_insertNode(changes, localPatches, xKey, yNode, yIndex, inserts); | ||
3395 | index += xNode.b || 0; | ||
3396 | |||
3397 | index++; | ||
3398 | _VirtualDom_removeNode(changes, localPatches, xKey, xNextNode, index); | ||
3399 | index += xNextNode.b || 0; | ||
3400 | |||
3401 | xIndex += 2; | ||
3402 | yIndex += 2; | ||
3403 | continue; | ||
3404 | } | ||
3405 | |||
3406 | // insert y | ||
3407 | if (newMatch) | ||
3408 | { | ||
3409 | index++; | ||
3410 | _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts); | ||
3411 | _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index); | ||
3412 | index += xNode.b || 0; | ||
3413 | |||
3414 | xIndex += 1; | ||
3415 | yIndex += 2; | ||
3416 | continue; | ||
3417 | } | ||
3418 | |||
3419 | // remove x | ||
3420 | if (oldMatch) | ||
3421 | { | ||
3422 | index++; | ||
3423 | _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index); | ||
3424 | index += xNode.b || 0; | ||
3425 | |||
3426 | index++; | ||
3427 | _VirtualDom_diffHelp(xNextNode, yNode, localPatches, index); | ||
3428 | index += xNextNode.b || 0; | ||
3429 | |||
3430 | xIndex += 2; | ||
3431 | yIndex += 1; | ||
3432 | continue; | ||
3433 | } | ||
3434 | |||
3435 | // remove x, insert y | ||
3436 | if (xNext && xNextKey === yNextKey) | ||
3437 | { | ||
3438 | index++; | ||
3439 | _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index); | ||
3440 | _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts); | ||
3441 | index += xNode.b || 0; | ||
3442 | |||
3443 | index++; | ||
3444 | _VirtualDom_diffHelp(xNextNode, yNextNode, localPatches, index); | ||
3445 | index += xNextNode.b || 0; | ||
3446 | |||
3447 | xIndex += 2; | ||
3448 | yIndex += 2; | ||
3449 | continue; | ||
3450 | } | ||
3451 | |||
3452 | break; | ||
3453 | } | ||
3454 | |||
3455 | // eat up any remaining nodes with removeNode and insertNode | ||
3456 | |||
3457 | while (xIndex < xLen) | ||
3458 | { | ||
3459 | index++; | ||
3460 | var x = xKids[xIndex]; | ||
3461 | var xNode = x.b; | ||
3462 | _VirtualDom_removeNode(changes, localPatches, x.a, xNode, index); | ||
3463 | index += xNode.b || 0; | ||
3464 | xIndex++; | ||
3465 | } | ||
3466 | |||
3467 | while (yIndex < yLen) | ||
3468 | { | ||
3469 | var endInserts = endInserts || []; | ||
3470 | var y = yKids[yIndex]; | ||
3471 | _VirtualDom_insertNode(changes, localPatches, y.a, y.b, undefined, endInserts); | ||
3472 | yIndex++; | ||
3473 | } | ||
3474 | |||
3475 | if (localPatches.length > 0 || inserts.length > 0 || endInserts) | ||
3476 | { | ||
3477 | _VirtualDom_pushPatch(patches, 8, rootIndex, { | ||
3478 | w: localPatches, | ||
3479 | x: inserts, | ||
3480 | y: endInserts | ||
3481 | }); | ||
3482 | } | ||
3483 | } | ||
3484 | |||
3485 | |||
3486 | |||
3487 | // CHANGES FROM KEYED DIFF | ||
3488 | |||
3489 | |||
3490 | var _VirtualDom_POSTFIX = '_elmW6BL'; | ||
3491 | |||
3492 | |||
3493 | function _VirtualDom_insertNode(changes, localPatches, key, vnode, yIndex, inserts) | ||
3494 | { | ||
3495 | var entry = changes[key]; | ||
3496 | |||
3497 | // never seen this key before | ||
3498 | if (!entry) | ||
3499 | { | ||
3500 | entry = { | ||
3501 | c: 0, | ||
3502 | z: vnode, | ||
3503 | r: yIndex, | ||
3504 | s: undefined | ||
3505 | }; | ||
3506 | |||
3507 | inserts.push({ r: yIndex, A: entry }); | ||
3508 | changes[key] = entry; | ||
3509 | |||
3510 | return; | ||
3511 | } | ||
3512 | |||
3513 | // this key was removed earlier, a match! | ||
3514 | if (entry.c === 1) | ||
3515 | { | ||
3516 | inserts.push({ r: yIndex, A: entry }); | ||
3517 | |||
3518 | entry.c = 2; | ||
3519 | var subPatches = []; | ||
3520 | _VirtualDom_diffHelp(entry.z, vnode, subPatches, entry.r); | ||
3521 | entry.r = yIndex; | ||
3522 | entry.s.s = { | ||
3523 | w: subPatches, | ||
3524 | A: entry | ||
3525 | }; | ||
3526 | |||
3527 | return; | ||
3528 | } | ||
3529 | |||
3530 | // this key has already been inserted or moved, a duplicate! | ||
3531 | _VirtualDom_insertNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, yIndex, inserts); | ||
3532 | } | ||
3533 | |||
3534 | |||
3535 | function _VirtualDom_removeNode(changes, localPatches, key, vnode, index) | ||
3536 | { | ||
3537 | var entry = changes[key]; | ||
3538 | |||
3539 | // never seen this key before | ||
3540 | if (!entry) | ||
3541 | { | ||
3542 | var patch = _VirtualDom_pushPatch(localPatches, 9, index, undefined); | ||
3543 | |||
3544 | changes[key] = { | ||
3545 | c: 1, | ||
3546 | z: vnode, | ||
3547 | r: index, | ||
3548 | s: patch | ||
3549 | }; | ||
3550 | |||
3551 | return; | ||
3552 | } | ||
3553 | |||
3554 | // this key was inserted earlier, a match! | ||
3555 | if (entry.c === 0) | ||
3556 | { | ||
3557 | entry.c = 2; | ||
3558 | var subPatches = []; | ||
3559 | _VirtualDom_diffHelp(vnode, entry.z, subPatches, index); | ||
3560 | |||
3561 | _VirtualDom_pushPatch(localPatches, 9, index, { | ||
3562 | w: subPatches, | ||
3563 | A: entry | ||
3564 | }); | ||
3565 | |||
3566 | return; | ||
3567 | } | ||
3568 | |||
3569 | // this key has already been removed or moved, a duplicate! | ||
3570 | _VirtualDom_removeNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, index); | ||
3571 | } | ||
3572 | |||
3573 | |||
3574 | |||
3575 | // ADD DOM NODES | ||
3576 | // | ||
3577 | // Each DOM node has an "index" assigned in order of traversal. It is important | ||
3578 | // to minimize our crawl over the actual DOM, so these indexes (along with the | ||
3579 | // descendantsCount of virtual nodes) let us skip touching entire subtrees of | ||
3580 | // the DOM if we know there are no patches there. | ||
3581 | |||
3582 | |||
3583 | function _VirtualDom_addDomNodes(domNode, vNode, patches, eventNode) | ||
3584 | { | ||
3585 | _VirtualDom_addDomNodesHelp(domNode, vNode, patches, 0, 0, vNode.b, eventNode); | ||
3586 | } | ||
3587 | |||
3588 | |||
3589 | // assumes `patches` is non-empty and indexes increase monotonically. | ||
3590 | function _VirtualDom_addDomNodesHelp(domNode, vNode, patches, i, low, high, eventNode) | ||
3591 | { | ||
3592 | var patch = patches[i]; | ||
3593 | var index = patch.r; | ||
3594 | |||
3595 | while (index === low) | ||
3596 | { | ||
3597 | var patchType = patch.$; | ||
3598 | |||
3599 | if (patchType === 1) | ||
3600 | { | ||
3601 | _VirtualDom_addDomNodes(domNode, vNode.k, patch.s, eventNode); | ||
3602 | } | ||
3603 | else if (patchType === 8) | ||
3604 | { | ||
3605 | patch.t = domNode; | ||
3606 | patch.u = eventNode; | ||
3607 | |||
3608 | var subPatches = patch.s.w; | ||
3609 | if (subPatches.length > 0) | ||
3610 | { | ||
3611 | _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode); | ||
3612 | } | ||
3613 | } | ||
3614 | else if (patchType === 9) | ||
3615 | { | ||
3616 | patch.t = domNode; | ||
3617 | patch.u = eventNode; | ||
3618 | |||
3619 | var data = patch.s; | ||
3620 | if (data) | ||
3621 | { | ||
3622 | data.A.s = domNode; | ||
3623 | var subPatches = data.w; | ||
3624 | if (subPatches.length > 0) | ||
3625 | { | ||
3626 | _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode); | ||
3627 | } | ||
3628 | } | ||
3629 | } | ||
3630 | else | ||
3631 | { | ||
3632 | patch.t = domNode; | ||
3633 | patch.u = eventNode; | ||
3634 | } | ||
3635 | |||
3636 | i++; | ||
3637 | |||
3638 | if (!(patch = patches[i]) || (index = patch.r) > high) | ||
3639 | { | ||
3640 | return i; | ||
3641 | } | ||
3642 | } | ||
3643 | |||
3644 | var tag = vNode.$; | ||
3645 | |||
3646 | if (tag === 4) | ||
3647 | { | ||
3648 | var subNode = vNode.k; | ||
3649 | |||
3650 | while (subNode.$ === 4) | ||
3651 | { | ||
3652 | subNode = subNode.k; | ||
3653 | } | ||
3654 | |||
3655 | return _VirtualDom_addDomNodesHelp(domNode, subNode, patches, i, low + 1, high, domNode.elm_event_node_ref); | ||
3656 | } | ||
3657 | |||
3658 | // tag must be 1 or 2 at this point | ||
3659 | |||
3660 | var vKids = vNode.e; | ||
3661 | var childNodes = domNode.childNodes; | ||
3662 | for (var j = 0; j < vKids.length; j++) | ||
3663 | { | ||
3664 | low++; | ||
3665 | var vKid = tag === 1 ? vKids[j] : vKids[j].b; | ||
3666 | var nextLow = low + (vKid.b || 0); | ||
3667 | if (low <= index && index <= nextLow) | ||
3668 | { | ||
3669 | i = _VirtualDom_addDomNodesHelp(childNodes[j], vKid, patches, i, low, nextLow, eventNode); | ||
3670 | if (!(patch = patches[i]) || (index = patch.r) > high) | ||
3671 | { | ||
3672 | return i; | ||
3673 | } | ||
3674 | } | ||
3675 | low = nextLow; | ||
3676 | } | ||
3677 | return i; | ||
3678 | } | ||
3679 | |||
3680 | |||
3681 | |||
3682 | // APPLY PATCHES | ||
3683 | |||
3684 | |||
3685 | function _VirtualDom_applyPatches(rootDomNode, oldVirtualNode, patches, eventNode) | ||
3686 | { | ||
3687 | if (patches.length === 0) | ||
3688 | { | ||
3689 | return rootDomNode; | ||
3690 | } | ||
3691 | |||
3692 | _VirtualDom_addDomNodes(rootDomNode, oldVirtualNode, patches, eventNode); | ||
3693 | return _VirtualDom_applyPatchesHelp(rootDomNode, patches); | ||
3694 | } | ||
3695 | |||
3696 | function _VirtualDom_applyPatchesHelp(rootDomNode, patches) | ||
3697 | { | ||
3698 | for (var i = 0; i < patches.length; i++) | ||
3699 | { | ||
3700 | var patch = patches[i]; | ||
3701 | var localDomNode = patch.t | ||
3702 | var newNode = _VirtualDom_applyPatch(localDomNode, patch); | ||
3703 | if (localDomNode === rootDomNode) | ||
3704 | { | ||
3705 | rootDomNode = newNode; | ||
3706 | } | ||
3707 | } | ||
3708 | return rootDomNode; | ||
3709 | } | ||
3710 | |||
3711 | function _VirtualDom_applyPatch(domNode, patch) | ||
3712 | { | ||
3713 | switch (patch.$) | ||
3714 | { | ||
3715 | case 0: | ||
3716 | return _VirtualDom_applyPatchRedraw(domNode, patch.s, patch.u); | ||
3717 | |||
3718 | case 4: | ||
3719 | _VirtualDom_applyFacts(domNode, patch.u, patch.s); | ||
3720 | return domNode; | ||
3721 | |||
3722 | case 3: | ||
3723 | domNode.replaceData(0, domNode.length, patch.s); | ||
3724 | return domNode; | ||
3725 | |||
3726 | case 1: | ||
3727 | return _VirtualDom_applyPatchesHelp(domNode, patch.s); | ||
3728 | |||
3729 | case 2: | ||
3730 | if (domNode.elm_event_node_ref) | ||
3731 | { | ||
3732 | domNode.elm_event_node_ref.j = patch.s; | ||
3733 | } | ||
3734 | else | ||
3735 | { | ||
3736 | domNode.elm_event_node_ref = { j: patch.s, p: patch.u }; | ||
3737 | } | ||
3738 | return domNode; | ||
3739 | |||
3740 | case 6: | ||
3741 | var data = patch.s; | ||
3742 | for (var i = 0; i < data.i; i++) | ||
3743 | { | ||
3744 | domNode.removeChild(domNode.childNodes[data.v]); | ||
3745 | } | ||
3746 | return domNode; | ||
3747 | |||
3748 | case 7: | ||
3749 | var data = patch.s; | ||
3750 | var kids = data.e; | ||
3751 | var i = data.v; | ||
3752 | var theEnd = domNode.childNodes[i]; | ||
3753 | for (; i < kids.length; i++) | ||
3754 | { | ||
3755 | domNode.insertBefore(_VirtualDom_render(kids[i], patch.u), theEnd); | ||
3756 | } | ||
3757 | return domNode; | ||
3758 | |||
3759 | case 9: | ||
3760 | var data = patch.s; | ||
3761 | if (!data) | ||
3762 | { | ||
3763 | domNode.parentNode.removeChild(domNode); | ||
3764 | return domNode; | ||
3765 | } | ||
3766 | var entry = data.A; | ||
3767 | if (typeof entry.r !== 'undefined') | ||
3768 | { | ||
3769 | domNode.parentNode.removeChild(domNode); | ||
3770 | } | ||
3771 | entry.s = _VirtualDom_applyPatchesHelp(domNode, data.w); | ||
3772 | return domNode; | ||
3773 | |||
3774 | case 8: | ||
3775 | return _VirtualDom_applyPatchReorder(domNode, patch); | ||
3776 | |||
3777 | case 5: | ||
3778 | return patch.s(domNode); | ||
3779 | |||
3780 | default: | ||
3781 | _Debug_crash(10); // 'Ran into an unknown patch!' | ||
3782 | } | ||
3783 | } | ||
3784 | |||
3785 | |||
3786 | function _VirtualDom_applyPatchRedraw(domNode, vNode, eventNode) | ||
3787 | { | ||
3788 | var parentNode = domNode.parentNode; | ||
3789 | var newNode = _VirtualDom_render(vNode, eventNode); | ||
3790 | |||
3791 | if (!newNode.elm_event_node_ref) | ||
3792 | { | ||
3793 | newNode.elm_event_node_ref = domNode.elm_event_node_ref; | ||
3794 | } | ||
3795 | |||
3796 | if (parentNode && newNode !== domNode) | ||
3797 | { | ||
3798 | parentNode.replaceChild(newNode, domNode); | ||
3799 | } | ||
3800 | return newNode; | ||
3801 | } | ||
3802 | |||
3803 | |||
3804 | function _VirtualDom_applyPatchReorder(domNode, patch) | ||
3805 | { | ||
3806 | var data = patch.s; | ||
3807 | |||
3808 | // remove end inserts | ||
3809 | var frag = _VirtualDom_applyPatchReorderEndInsertsHelp(data.y, patch); | ||
3810 | |||
3811 | // removals | ||
3812 | domNode = _VirtualDom_applyPatchesHelp(domNode, data.w); | ||
3813 | |||
3814 | // inserts | ||
3815 | var inserts = data.x; | ||
3816 | for (var i = 0; i < inserts.length; i++) | ||
3817 | { | ||
3818 | var insert = inserts[i]; | ||
3819 | var entry = insert.A; | ||
3820 | var node = entry.c === 2 | ||
3821 | ? entry.s | ||
3822 | : _VirtualDom_render(entry.z, patch.u); | ||
3823 | domNode.insertBefore(node, domNode.childNodes[insert.r]); | ||
3824 | } | ||
3825 | |||
3826 | // add end inserts | ||
3827 | if (frag) | ||
3828 | { | ||
3829 | _VirtualDom_appendChild(domNode, frag); | ||
3830 | } | ||
3831 | |||
3832 | return domNode; | ||
3833 | } | ||
3834 | |||
3835 | |||
3836 | function _VirtualDom_applyPatchReorderEndInsertsHelp(endInserts, patch) | ||
3837 | { | ||
3838 | if (!endInserts) | ||
3839 | { | ||
3840 | return; | ||
3841 | } | ||
3842 | |||
3843 | var frag = _VirtualDom_doc.createDocumentFragment(); | ||
3844 | for (var i = 0; i < endInserts.length; i++) | ||
3845 | { | ||
3846 | var insert = endInserts[i]; | ||
3847 | var entry = insert.A; | ||
3848 | _VirtualDom_appendChild(frag, entry.c === 2 | ||
3849 | ? entry.s | ||
3850 | : _VirtualDom_render(entry.z, patch.u) | ||
3851 | ); | ||
3852 | } | ||
3853 | return frag; | ||
3854 | } | ||
3855 | |||
3856 | |||
3857 | function _VirtualDom_virtualize(node) | ||
3858 | { | ||
3859 | // TEXT NODES | ||
3860 | |||
3861 | if (node.nodeType === 3) | ||
3862 | { | ||
3863 | return _VirtualDom_text(node.textContent); | ||
3864 | } | ||
3865 | |||
3866 | |||
3867 | // WEIRD NODES | ||
3868 | |||
3869 | if (node.nodeType !== 1) | ||
3870 | { | ||
3871 | return _VirtualDom_text(''); | ||
3872 | } | ||
3873 | |||
3874 | |||
3875 | // ELEMENT NODES | ||
3876 | |||
3877 | var attrList = _List_Nil; | ||
3878 | var attrs = node.attributes; | ||
3879 | for (var i = attrs.length; i--; ) | ||
3880 | { | ||
3881 | var attr = attrs[i]; | ||
3882 | var name = attr.name; | ||
3883 | var value = attr.value; | ||
3884 | attrList = _List_Cons( A2(_VirtualDom_attribute, name, value), attrList ); | ||
3885 | } | ||
3886 | |||
3887 | var tag = node.tagName.toLowerCase(); | ||
3888 | var kidList = _List_Nil; | ||
3889 | var kids = node.childNodes; | ||
3890 | |||
3891 | for (var i = kids.length; i--; ) | ||
3892 | { | ||
3893 | kidList = _List_Cons(_VirtualDom_virtualize(kids[i]), kidList); | ||
3894 | } | ||
3895 | return A3(_VirtualDom_node, tag, attrList, kidList); | ||
3896 | } | ||
3897 | |||
3898 | function _VirtualDom_dekey(keyedNode) | ||
3899 | { | ||
3900 | var keyedKids = keyedNode.e; | ||
3901 | var len = keyedKids.length; | ||
3902 | var kids = new Array(len); | ||
3903 | for (var i = 0; i < len; i++) | ||
3904 | { | ||
3905 | kids[i] = keyedKids[i].b; | ||
3906 | } | ||
3907 | |||
3908 | return { | ||
3909 | $: 1, | ||
3910 | c: keyedNode.c, | ||
3911 | d: keyedNode.d, | ||
3912 | e: kids, | ||
3913 | f: keyedNode.f, | ||
3914 | b: keyedNode.b | ||
3915 | }; | ||
3916 | } | ||
3917 | |||
3918 | |||
3919 | |||
3920 | |||
3921 | // ELEMENT | ||
3922 | |||
3923 | |||
3924 | var _Debugger_element; | ||
3925 | |||
3926 | var _Browser_element = _Debugger_element || F4(function(impl, flagDecoder, debugMetadata, args) | ||
3927 | { | ||
3928 | return _Platform_initialize( | ||
3929 | flagDecoder, | ||
3930 | args, | ||
3931 | impl.init, | ||
3932 | impl.update, | ||
3933 | impl.subscriptions, | ||
3934 | function(sendToApp, initialModel) { | ||
3935 | var view = impl.view; | ||
3936 | /**_UNUSED/ | ||
3937 | var domNode = args['node']; | ||
3938 | //*/ | ||
3939 | /**/ | ||
3940 | var domNode = args && args['node'] ? args['node'] : _Debug_crash(0); | ||
3941 | //*/ | ||
3942 | var currNode = _VirtualDom_virtualize(domNode); | ||
3943 | |||
3944 | return _Browser_makeAnimator(initialModel, function(model) | ||
3945 | { | ||
3946 | var nextNode = view(model); | ||
3947 | var patches = _VirtualDom_diff(currNode, nextNode); | ||
3948 | domNode = _VirtualDom_applyPatches(domNode, currNode, patches, sendToApp); | ||
3949 | currNode = nextNode; | ||
3950 | }); | ||
3951 | } | ||
3952 | ); | ||
3953 | }); | ||
3954 | |||
3955 | |||
3956 | |||
3957 | // DOCUMENT | ||
3958 | |||
3959 | |||
3960 | var _Debugger_document; | ||
3961 | |||
3962 | var _Browser_document = _Debugger_document || F4(function(impl, flagDecoder, debugMetadata, args) | ||
3963 | { | ||
3964 | return _Platform_initialize( | ||
3965 | flagDecoder, | ||
3966 | args, | ||
3967 | impl.init, | ||
3968 | impl.update, | ||
3969 | impl.subscriptions, | ||
3970 | function(sendToApp, initialModel) { | ||
3971 | var divertHrefToApp = impl.setup && impl.setup(sendToApp) | ||
3972 | var view = impl.view; | ||
3973 | var title = _VirtualDom_doc.title; | ||
3974 | var bodyNode = _VirtualDom_doc.body; | ||
3975 | var currNode = _VirtualDom_virtualize(bodyNode); | ||
3976 | return _Browser_makeAnimator(initialModel, function(model) | ||
3977 | { | ||
3978 | _VirtualDom_divertHrefToApp = divertHrefToApp; | ||
3979 | var doc = view(model); | ||
3980 | var nextNode = _VirtualDom_node('body')(_List_Nil)(doc.body); | ||
3981 | var patches = _VirtualDom_diff(currNode, nextNode); | ||
3982 | bodyNode = _VirtualDom_applyPatches(bodyNode, currNode, patches, sendToApp); | ||
3983 | currNode = nextNode; | ||
3984 | _VirtualDom_divertHrefToApp = 0; | ||
3985 | (title !== doc.title) && (_VirtualDom_doc.title = title = doc.title); | ||
3986 | }); | ||
3987 | } | ||
3988 | ); | ||
3989 | }); | ||
3990 | |||
3991 | |||
3992 | |||
3993 | // ANIMATION | ||
3994 | |||
3995 | |||
3996 | var _Browser_cancelAnimationFrame = | ||
3997 | typeof cancelAnimationFrame !== 'undefined' | ||
3998 | ? cancelAnimationFrame | ||
3999 | : function(id) { clearTimeout(id); }; | ||
4000 | |||
4001 | var _Browser_requestAnimationFrame = | ||
4002 | typeof requestAnimationFrame !== 'undefined' | ||
4003 | ? requestAnimationFrame | ||
4004 | : function(callback) { return setTimeout(callback, 1000 / 60); }; | ||
4005 | |||
4006 | |||
4007 | function _Browser_makeAnimator(model, draw) | ||
4008 | { | ||
4009 | draw(model); | ||
4010 | |||
4011 | var state = 0; | ||
4012 | |||
4013 | function updateIfNeeded() | ||
4014 | { | ||
4015 | state = state === 1 | ||
4016 | ? 0 | ||
4017 | : ( _Browser_requestAnimationFrame(updateIfNeeded), draw(model), 1 ); | ||
4018 | } | ||
4019 | |||
4020 | return function(nextModel, isSync) | ||
4021 | { | ||
4022 | model = nextModel; | ||
4023 | |||
4024 | isSync | ||
4025 | ? ( draw(model), | ||
4026 | state === 2 && (state = 1) | ||
4027 | ) | ||
4028 | : ( state === 0 && _Browser_requestAnimationFrame(updateIfNeeded), | ||
4029 | state = 2 | ||
4030 | ); | ||
4031 | }; | ||
4032 | } | ||
4033 | |||
4034 | |||
4035 | |||
4036 | // APPLICATION | ||
4037 | |||
4038 | |||
4039 | function _Browser_application(impl) | ||
4040 | { | ||
4041 | var onUrlChange = impl.onUrlChange; | ||
4042 | var onUrlRequest = impl.onUrlRequest; | ||
4043 | var key = function() { key.a(onUrlChange(_Browser_getUrl())); }; | ||
4044 | |||
4045 | return _Browser_document({ | ||
4046 | setup: function(sendToApp) | ||
4047 | { | ||
4048 | key.a = sendToApp; | ||
4049 | _Browser_window.addEventListener('popstate', key); | ||
4050 | _Browser_window.navigator.userAgent.indexOf('Trident') < 0 || _Browser_window.addEventListener('hashchange', key); | ||
4051 | |||
4052 | return F2(function(domNode, event) | ||
4053 | { | ||
4054 | if (!event.ctrlKey && !event.metaKey && !event.shiftKey && event.button < 1 && !domNode.target && !domNode.hasAttribute('download')) | ||
4055 | { | ||
4056 | event.preventDefault(); | ||
4057 | var href = domNode.href; | ||
4058 | var curr = _Browser_getUrl(); | ||
4059 | var next = $elm$url$Url$fromString(href).a; | ||
4060 | sendToApp(onUrlRequest( | ||
4061 | (next | ||
4062 | && curr.protocol === next.protocol | ||
4063 | && curr.host === next.host | ||
4064 | && curr.port_.a === next.port_.a | ||
4065 | ) | ||
4066 | ? $elm$browser$Browser$Internal(next) | ||
4067 | : $elm$browser$Browser$External(href) | ||
4068 | )); | ||
4069 | } | ||
4070 | }); | ||
4071 | }, | ||
4072 | init: function(flags) | ||
4073 | { | ||
4074 | return A3(impl.init, flags, _Browser_getUrl(), key); | ||
4075 | }, | ||
4076 | view: impl.view, | ||
4077 | update: impl.update, | ||
4078 | subscriptions: impl.subscriptions | ||
4079 | }); | ||
4080 | } | ||
4081 | |||
4082 | function _Browser_getUrl() | ||
4083 | { | ||
4084 | return $elm$url$Url$fromString(_VirtualDom_doc.location.href).a || _Debug_crash(1); | ||
4085 | } | ||
4086 | |||
4087 | var _Browser_go = F2(function(key, n) | ||
4088 | { | ||
4089 | return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() { | ||
4090 | n && history.go(n); | ||
4091 | key(); | ||
4092 | })); | ||
4093 | }); | ||
4094 | |||
4095 | var _Browser_pushUrl = F2(function(key, url) | ||
4096 | { | ||
4097 | return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() { | ||
4098 | history.pushState({}, '', url); | ||
4099 | key(); | ||
4100 | })); | ||
4101 | }); | ||
4102 | |||
4103 | var _Browser_replaceUrl = F2(function(key, url) | ||
4104 | { | ||
4105 | return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() { | ||
4106 | history.replaceState({}, '', url); | ||
4107 | key(); | ||
4108 | })); | ||
4109 | }); | ||
4110 | |||
4111 | |||
4112 | |||
4113 | // GLOBAL EVENTS | ||
4114 | |||
4115 | |||
4116 | var _Browser_fakeNode = { addEventListener: function() {}, removeEventListener: function() {} }; | ||
4117 | var _Browser_doc = typeof document !== 'undefined' ? document : _Browser_fakeNode; | ||
4118 | var _Browser_window = typeof window !== 'undefined' ? window : _Browser_fakeNode; | ||
4119 | |||
4120 | var _Browser_on = F3(function(node, eventName, sendToSelf) | ||
4121 | { | ||
4122 | return _Scheduler_spawn(_Scheduler_binding(function(callback) | ||
4123 | { | ||
4124 | function handler(event) { _Scheduler_rawSpawn(sendToSelf(event)); } | ||
4125 | node.addEventListener(eventName, handler, _VirtualDom_passiveSupported && { passive: true }); | ||
4126 | return function() { node.removeEventListener(eventName, handler); }; | ||
4127 | })); | ||
4128 | }); | ||
4129 | |||
4130 | var _Browser_decodeEvent = F2(function(decoder, event) | ||
4131 | { | ||
4132 | var result = _Json_runHelp(decoder, event); | ||
4133 | return $elm$core$Result$isOk(result) ? $elm$core$Maybe$Just(result.a) : $elm$core$Maybe$Nothing; | ||
4134 | }); | ||
4135 | |||
4136 | |||
4137 | |||
4138 | // PAGE VISIBILITY | ||
4139 | |||
4140 | |||
4141 | function _Browser_visibilityInfo() | ||
4142 | { | ||
4143 | return (typeof _VirtualDom_doc.hidden !== 'undefined') | ||
4144 | ? { hidden: 'hidden', change: 'visibilitychange' } | ||
4145 | : | ||
4146 | (typeof _VirtualDom_doc.mozHidden !== 'undefined') | ||
4147 | ? { hidden: 'mozHidden', change: 'mozvisibilitychange' } | ||
4148 | : | ||
4149 | (typeof _VirtualDom_doc.msHidden !== 'undefined') | ||
4150 | ? { hidden: 'msHidden', change: 'msvisibilitychange' } | ||
4151 | : | ||
4152 | (typeof _VirtualDom_doc.webkitHidden !== 'undefined') | ||
4153 | ? { hidden: 'webkitHidden', change: 'webkitvisibilitychange' } | ||
4154 | : { hidden: 'hidden', change: 'visibilitychange' }; | ||
4155 | } | ||
4156 | |||
4157 | |||
4158 | |||
4159 | // ANIMATION FRAMES | ||
4160 | |||
4161 | |||
4162 | function _Browser_rAF() | ||
4163 | { | ||
4164 | return _Scheduler_binding(function(callback) | ||
4165 | { | ||
4166 | var id = _Browser_requestAnimationFrame(function() { | ||
4167 | callback(_Scheduler_succeed(Date.now())); | ||
4168 | }); | ||
4169 | |||
4170 | return function() { | ||
4171 | _Browser_cancelAnimationFrame(id); | ||
4172 | }; | ||
4173 | }); | ||
4174 | } | ||
4175 | |||
4176 | |||
4177 | function _Browser_now() | ||
4178 | { | ||
4179 | return _Scheduler_binding(function(callback) | ||
4180 | { | ||
4181 | callback(_Scheduler_succeed(Date.now())); | ||
4182 | }); | ||
4183 | } | ||
4184 | |||
4185 | |||
4186 | |||
4187 | // DOM STUFF | ||
4188 | |||
4189 | |||
4190 | function _Browser_withNode(id, doStuff) | ||
4191 | { | ||
4192 | return _Scheduler_binding(function(callback) | ||
4193 | { | ||
4194 | _Browser_requestAnimationFrame(function() { | ||
4195 | var node = document.getElementById(id); | ||
4196 | callback(node | ||
4197 | ? _Scheduler_succeed(doStuff(node)) | ||
4198 | : _Scheduler_fail($elm$browser$Browser$Dom$NotFound(id)) | ||
4199 | ); | ||
4200 | }); | ||
4201 | }); | ||
4202 | } | ||
4203 | |||
4204 | |||
4205 | function _Browser_withWindow(doStuff) | ||
4206 | { | ||
4207 | return _Scheduler_binding(function(callback) | ||
4208 | { | ||
4209 | _Browser_requestAnimationFrame(function() { | ||
4210 | callback(_Scheduler_succeed(doStuff())); | ||
4211 | }); | ||
4212 | }); | ||
4213 | } | ||
4214 | |||
4215 | |||
4216 | // FOCUS and BLUR | ||
4217 | |||
4218 | |||
4219 | var _Browser_call = F2(function(functionName, id) | ||
4220 | { | ||
4221 | return _Browser_withNode(id, function(node) { | ||
4222 | node[functionName](); | ||
4223 | return _Utils_Tuple0; | ||
4224 | }); | ||
4225 | }); | ||
4226 | |||
4227 | |||
4228 | |||
4229 | // WINDOW VIEWPORT | ||
4230 | |||
4231 | |||
4232 | function _Browser_getViewport() | ||
4233 | { | ||
4234 | return { | ||
4235 | scene: _Browser_getScene(), | ||
4236 | viewport: { | ||
4237 | x: _Browser_window.pageXOffset, | ||
4238 | y: _Browser_window.pageYOffset, | ||
4239 | width: _Browser_doc.documentElement.clientWidth, | ||
4240 | height: _Browser_doc.documentElement.clientHeight | ||
4241 | } | ||
4242 | }; | ||
4243 | } | ||
4244 | |||
4245 | function _Browser_getScene() | ||
4246 | { | ||
4247 | var body = _Browser_doc.body; | ||
4248 | var elem = _Browser_doc.documentElement; | ||
4249 | return { | ||
4250 | width: Math.max(body.scrollWidth, body.offsetWidth, elem.scrollWidth, elem.offsetWidth, elem.clientWidth), | ||
4251 | height: Math.max(body.scrollHeight, body.offsetHeight, elem.scrollHeight, elem.offsetHeight, elem.clientHeight) | ||
4252 | }; | ||
4253 | } | ||
4254 | |||
4255 | var _Browser_setViewport = F2(function(x, y) | ||
4256 | { | ||
4257 | return _Browser_withWindow(function() | ||
4258 | { | ||
4259 | _Browser_window.scroll(x, y); | ||
4260 | return _Utils_Tuple0; | ||
4261 | }); | ||
4262 | }); | ||
4263 | |||
4264 | |||
4265 | |||
4266 | // ELEMENT VIEWPORT | ||
4267 | |||
4268 | |||
4269 | function _Browser_getViewportOf(id) | ||
4270 | { | ||
4271 | return _Browser_withNode(id, function(node) | ||
4272 | { | ||
4273 | return { | ||
4274 | scene: { | ||
4275 | width: node.scrollWidth, | ||
4276 | height: node.scrollHeight | ||
4277 | }, | ||
4278 | viewport: { | ||
4279 | x: node.scrollLeft, | ||
4280 | y: node.scrollTop, | ||
4281 | width: node.clientWidth, | ||
4282 | height: node.clientHeight | ||
4283 | } | ||
4284 | }; | ||
4285 | }); | ||
4286 | } | ||
4287 | |||
4288 | |||
4289 | var _Browser_setViewportOf = F3(function(id, x, y) | ||
4290 | { | ||
4291 | return _Browser_withNode(id, function(node) | ||
4292 | { | ||
4293 | node.scrollLeft = x; | ||
4294 | node.scrollTop = y; | ||
4295 | return _Utils_Tuple0; | ||
4296 | }); | ||
4297 | }); | ||
4298 | |||
4299 | |||
4300 | |||
4301 | // ELEMENT | ||
4302 | |||
4303 | |||
4304 | function _Browser_getElement(id) | ||
4305 | { | ||
4306 | return _Browser_withNode(id, function(node) | ||
4307 | { | ||
4308 | var rect = node.getBoundingClientRect(); | ||
4309 | var x = _Browser_window.pageXOffset; | ||
4310 | var y = _Browser_window.pageYOffset; | ||
4311 | return { | ||
4312 | scene: _Browser_getScene(), | ||
4313 | viewport: { | ||
4314 | x: x, | ||
4315 | y: y, | ||
4316 | width: _Browser_doc.documentElement.clientWidth, | ||
4317 | height: _Browser_doc.documentElement.clientHeight | ||
4318 | }, | ||
4319 | element: { | ||
4320 | x: x + rect.left, | ||
4321 | y: y + rect.top, | ||
4322 | width: rect.width, | ||
4323 | height: rect.height | ||
4324 | } | ||
4325 | }; | ||
4326 | }); | ||
4327 | } | ||
4328 | |||
4329 | |||
4330 | |||
4331 | // LOAD and RELOAD | ||
4332 | |||
4333 | |||
4334 | function _Browser_reload(skipCache) | ||
4335 | { | ||
4336 | return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function(callback) | ||
4337 | { | ||
4338 | _VirtualDom_doc.location.reload(skipCache); | ||
4339 | })); | ||
4340 | } | ||
4341 | |||
4342 | function _Browser_load(url) | ||
4343 | { | ||
4344 | return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function(callback) | ||
4345 | { | ||
4346 | try | ||
4347 | { | ||
4348 | _Browser_window.location = url; | ||
4349 | } | ||
4350 | catch(err) | ||
4351 | { | ||
4352 | // Only Firefox can throw a NS_ERROR_MALFORMED_URI exception here. | ||
4353 | // Other browsers reload the page, so let's be consistent about that. | ||
4354 | _VirtualDom_doc.location.reload(false); | ||
4355 | } | ||
4356 | })); | ||
4357 | } | ||
4358 | |||
4359 | |||
4360 | |||
4361 | // SEND REQUEST | ||
4362 | |||
4363 | var _Http_toTask = F3(function(router, toTask, request) | ||
4364 | { | ||
4365 | return _Scheduler_binding(function(callback) | ||
4366 | { | ||
4367 | function done(response) { | ||
4368 | callback(toTask(request.expect.a(response))); | ||
4369 | } | ||
4370 | |||
4371 | var xhr = new XMLHttpRequest(); | ||
4372 | xhr.addEventListener('error', function() { done($elm$http$Http$NetworkError_); }); | ||
4373 | xhr.addEventListener('timeout', function() { done($elm$http$Http$Timeout_); }); | ||
4374 | xhr.addEventListener('load', function() { done(_Http_toResponse(request.expect.b, xhr)); }); | ||
4375 | $elm$core$Maybe$isJust(request.tracker) && _Http_track(router, xhr, request.tracker.a); | ||
4376 | |||
4377 | try { | ||
4378 | xhr.open(request.method, request.url, true); | ||
4379 | } catch (e) { | ||
4380 | return done($elm$http$Http$BadUrl_(request.url)); | ||
4381 | } | ||
4382 | |||
4383 | _Http_configureRequest(xhr, request); | ||
4384 | |||
4385 | request.body.a && xhr.setRequestHeader('Content-Type', request.body.a); | ||
4386 | xhr.send(request.body.b); | ||
4387 | |||
4388 | return function() { xhr.c = true; xhr.abort(); }; | ||
4389 | }); | ||
4390 | }); | ||
4391 | |||
4392 | |||
4393 | // CONFIGURE | ||
4394 | |||
4395 | function _Http_configureRequest(xhr, request) | ||
4396 | { | ||
4397 | for (var headers = request.headers; headers.b; headers = headers.b) // WHILE_CONS | ||
4398 | { | ||
4399 | xhr.setRequestHeader(headers.a.a, headers.a.b); | ||
4400 | } | ||
4401 | xhr.timeout = request.timeout.a || 0; | ||
4402 | xhr.responseType = request.expect.d; | ||
4403 | xhr.withCredentials = request.allowCookiesFromOtherDomains; | ||
4404 | } | ||
4405 | |||
4406 | |||
4407 | // RESPONSES | ||
4408 | |||
4409 | function _Http_toResponse(toBody, xhr) | ||
4410 | { | ||
4411 | return A2( | ||
4412 | 200 <= xhr.status && xhr.status < 300 ? $elm$http$Http$GoodStatus_ : $elm$http$Http$BadStatus_, | ||
4413 | _Http_toMetadata(xhr), | ||
4414 | toBody(xhr.response) | ||
4415 | ); | ||
4416 | } | ||
4417 | |||
4418 | |||
4419 | // METADATA | ||
4420 | |||
4421 | function _Http_toMetadata(xhr) | ||
4422 | { | ||
4423 | return { | ||
4424 | url: xhr.responseURL, | ||
4425 | statusCode: xhr.status, | ||
4426 | statusText: xhr.statusText, | ||
4427 | headers: _Http_parseHeaders(xhr.getAllResponseHeaders()) | ||
4428 | }; | ||
4429 | } | ||
4430 | |||
4431 | |||
4432 | // HEADERS | ||
4433 | |||
4434 | function _Http_parseHeaders(rawHeaders) | ||
4435 | { | ||
4436 | if (!rawHeaders) | ||
4437 | { | ||
4438 | return $elm$core$Dict$empty; | ||
4439 | } | ||
4440 | |||
4441 | var headers = $elm$core$Dict$empty; | ||
4442 | var headerPairs = rawHeaders.split('\r\n'); | ||
4443 | for (var i = headerPairs.length; i--; ) | ||
4444 | { | ||
4445 | var headerPair = headerPairs[i]; | ||
4446 | var index = headerPair.indexOf(': '); | ||
4447 | if (index > 0) | ||
4448 | { | ||
4449 | var key = headerPair.substring(0, index); | ||
4450 | var value = headerPair.substring(index + 2); | ||
4451 | |||
4452 | headers = A3($elm$core$Dict$update, key, function(oldValue) { | ||
4453 | return $elm$core$Maybe$Just($elm$core$Maybe$isJust(oldValue) | ||
4454 | ? value + ', ' + oldValue.a | ||
4455 | : value | ||
4456 | ); | ||
4457 | }, headers); | ||
4458 | } | ||
4459 | } | ||
4460 | return headers; | ||
4461 | } | ||
4462 | |||
4463 | |||
4464 | // EXPECT | ||
4465 | |||
4466 | var _Http_expect = F3(function(type, toBody, toValue) | ||
4467 | { | ||
4468 | return { | ||
4469 | $: 0, | ||
4470 | d: type, | ||
4471 | b: toBody, | ||
4472 | a: toValue | ||
4473 | }; | ||
4474 | }); | ||
4475 | |||
4476 | var _Http_mapExpect = F2(function(func, expect) | ||
4477 | { | ||
4478 | return { | ||
4479 | $: 0, | ||
4480 | d: expect.d, | ||
4481 | b: expect.b, | ||
4482 | a: function(x) { return func(expect.a(x)); } | ||
4483 | }; | ||
4484 | }); | ||
4485 | |||
4486 | function _Http_toDataView(arrayBuffer) | ||
4487 | { | ||
4488 | return new DataView(arrayBuffer); | ||
4489 | } | ||
4490 | |||
4491 | |||
4492 | // BODY and PARTS | ||
4493 | |||
4494 | var _Http_emptyBody = { $: 0 }; | ||
4495 | var _Http_pair = F2(function(a, b) { return { $: 0, a: a, b: b }; }); | ||
4496 | |||
4497 | function _Http_toFormData(parts) | ||
4498 | { | ||
4499 | for (var formData = new FormData(); parts.b; parts = parts.b) // WHILE_CONS | ||
4500 | { | ||
4501 | var part = parts.a; | ||
4502 | formData.append(part.a, part.b); | ||
4503 | } | ||
4504 | return formData; | ||
4505 | } | ||
4506 | |||
4507 | var _Http_bytesToBlob = F2(function(mime, bytes) | ||
4508 | { | ||
4509 | return new Blob([bytes], { type: mime }); | ||
4510 | }); | ||
4511 | |||
4512 | |||
4513 | // PROGRESS | ||
4514 | |||
4515 | function _Http_track(router, xhr, tracker) | ||
4516 | { | ||
4517 | // TODO check out lengthComputable on loadstart event | ||
4518 | |||
4519 | xhr.upload.addEventListener('progress', function(event) { | ||
4520 | if (xhr.c) { return; } | ||
4521 | _Scheduler_rawSpawn(A2($elm$core$Platform$sendToSelf, router, _Utils_Tuple2(tracker, $elm$http$Http$Sending({ | ||
4522 | sent: event.loaded, | ||
4523 | size: event.total | ||
4524 | })))); | ||
4525 | }); | ||
4526 | xhr.addEventListener('progress', function(event) { | ||
4527 | if (xhr.c) { return; } | ||
4528 | _Scheduler_rawSpawn(A2($elm$core$Platform$sendToSelf, router, _Utils_Tuple2(tracker, $elm$http$Http$Receiving({ | ||
4529 | received: event.loaded, | ||
4530 | size: event.lengthComputable ? $elm$core$Maybe$Just(event.total) : $elm$core$Maybe$Nothing | ||
4531 | })))); | ||
4532 | }); | ||
4533 | } | ||
4534 | |||
4535 | function _Url_percentEncode(string) | ||
4536 | { | ||
4537 | return encodeURIComponent(string); | ||
4538 | } | ||
4539 | |||
4540 | function _Url_percentDecode(string) | ||
4541 | { | ||
4542 | try | ||
4543 | { | ||
4544 | return $elm$core$Maybe$Just(decodeURIComponent(string)); | ||
4545 | } | ||
4546 | catch (e) | ||
4547 | { | ||
4548 | return $elm$core$Maybe$Nothing; | ||
4549 | } | ||
4550 | }var $author$project$Main$LinkClicked = function (a) { | ||
4551 | return {$: 'LinkClicked', a: a}; | ||
4552 | }; | ||
4553 | var $author$project$Main$UrlChanged = function (a) { | ||
4554 | return {$: 'UrlChanged', a: a}; | ||
4555 | }; | ||
4556 | var $elm$core$Basics$EQ = {$: 'EQ'}; | ||
4557 | var $elm$core$Basics$GT = {$: 'GT'}; | ||
4558 | var $elm$core$Basics$LT = {$: 'LT'}; | ||
4559 | var $elm$core$List$cons = _List_cons; | ||
4560 | var $elm$core$Dict$foldr = F3( | ||
4561 | function (func, acc, t) { | ||
4562 | foldr: | ||
4563 | while (true) { | ||
4564 | if (t.$ === 'RBEmpty_elm_builtin') { | ||
4565 | return acc; | ||
4566 | } else { | ||
4567 | var key = t.b; | ||
4568 | var value = t.c; | ||
4569 | var left = t.d; | ||
4570 | var right = t.e; | ||
4571 | var $temp$func = func, | ||
4572 | $temp$acc = A3( | ||
4573 | func, | ||
4574 | key, | ||
4575 | value, | ||
4576 | A3($elm$core$Dict$foldr, func, acc, right)), | ||
4577 | $temp$t = left; | ||
4578 | func = $temp$func; | ||
4579 | acc = $temp$acc; | ||
4580 | t = $temp$t; | ||
4581 | continue foldr; | ||
4582 | } | ||
4583 | } | ||
4584 | }); | ||
4585 | var $elm$core$Dict$toList = function (dict) { | ||
4586 | return A3( | ||
4587 | $elm$core$Dict$foldr, | ||
4588 | F3( | ||
4589 | function (key, value, list) { | ||
4590 | return A2( | ||
4591 | $elm$core$List$cons, | ||
4592 | _Utils_Tuple2(key, value), | ||
4593 | list); | ||
4594 | }), | ||
4595 | _List_Nil, | ||
4596 | dict); | ||
4597 | }; | ||
4598 | var $elm$core$Dict$keys = function (dict) { | ||
4599 | return A3( | ||
4600 | $elm$core$Dict$foldr, | ||
4601 | F3( | ||
4602 | function (key, value, keyList) { | ||
4603 | return A2($elm$core$List$cons, key, keyList); | ||
4604 | }), | ||
4605 | _List_Nil, | ||
4606 | dict); | ||
4607 | }; | ||
4608 | var $elm$core$Set$toList = function (_v0) { | ||
4609 | var dict = _v0.a; | ||
4610 | return $elm$core$Dict$keys(dict); | ||
4611 | }; | ||
4612 | var $elm$core$Elm$JsArray$foldr = _JsArray_foldr; | ||
4613 | var $elm$core$Array$foldr = F3( | ||
4614 | function (func, baseCase, _v0) { | ||
4615 | var tree = _v0.c; | ||
4616 | var tail = _v0.d; | ||
4617 | var helper = F2( | ||
4618 | function (node, acc) { | ||
4619 | if (node.$ === 'SubTree') { | ||
4620 | var subTree = node.a; | ||
4621 | return A3($elm$core$Elm$JsArray$foldr, helper, acc, subTree); | ||
4622 | } else { | ||
4623 | var values = node.a; | ||
4624 | return A3($elm$core$Elm$JsArray$foldr, func, acc, values); | ||
4625 | } | ||
4626 | }); | ||
4627 | return A3( | ||
4628 | $elm$core$Elm$JsArray$foldr, | ||
4629 | helper, | ||
4630 | A3($elm$core$Elm$JsArray$foldr, func, baseCase, tail), | ||
4631 | tree); | ||
4632 | }); | ||
4633 | var $elm$core$Array$toList = function (array) { | ||
4634 | return A3($elm$core$Array$foldr, $elm$core$List$cons, _List_Nil, array); | ||
4635 | }; | ||
4636 | var $elm$core$Result$Err = function (a) { | ||
4637 | return {$: 'Err', a: a}; | ||
4638 | }; | ||
4639 | var $elm$json$Json$Decode$Failure = F2( | ||
4640 | function (a, b) { | ||
4641 | return {$: 'Failure', a: a, b: b}; | ||
4642 | }); | ||
4643 | var $elm$json$Json$Decode$Field = F2( | ||
4644 | function (a, b) { | ||
4645 | return {$: 'Field', a: a, b: b}; | ||
4646 | }); | ||
4647 | var $elm$json$Json$Decode$Index = F2( | ||
4648 | function (a, b) { | ||
4649 | return {$: 'Index', a: a, b: b}; | ||
4650 | }); | ||
4651 | var $elm$core$Result$Ok = function (a) { | ||
4652 | return {$: 'Ok', a: a}; | ||
4653 | }; | ||
4654 | var $elm$json$Json$Decode$OneOf = function (a) { | ||
4655 | return {$: 'OneOf', a: a}; | ||
4656 | }; | ||
4657 | var $elm$core$Basics$False = {$: 'False'}; | ||
4658 | var $elm$core$Basics$add = _Basics_add; | ||
4659 | var $elm$core$Maybe$Just = function (a) { | ||
4660 | return {$: 'Just', a: a}; | ||
4661 | }; | ||
4662 | var $elm$core$Maybe$Nothing = {$: 'Nothing'}; | ||
4663 | var $elm$core$String$all = _String_all; | ||
4664 | var $elm$core$Basics$and = _Basics_and; | ||
4665 | var $elm$core$Basics$append = _Utils_append; | ||
4666 | var $elm$json$Json$Encode$encode = _Json_encode; | ||
4667 | var $elm$core$String$fromInt = _String_fromNumber; | ||
4668 | var $elm$core$String$join = F2( | ||
4669 | function (sep, chunks) { | ||
4670 | return A2( | ||
4671 | _String_join, | ||
4672 | sep, | ||
4673 | _List_toArray(chunks)); | ||
4674 | }); | ||
4675 | var $elm$core$String$split = F2( | ||
4676 | function (sep, string) { | ||
4677 | return _List_fromArray( | ||
4678 | A2(_String_split, sep, string)); | ||
4679 | }); | ||
4680 | var $elm$json$Json$Decode$indent = function (str) { | ||
4681 | return A2( | ||
4682 | $elm$core$String$join, | ||
4683 | '\n ', | ||
4684 | A2($elm$core$String$split, '\n', str)); | ||
4685 | }; | ||
4686 | var $elm$core$List$foldl = F3( | ||
4687 | function (func, acc, list) { | ||
4688 | foldl: | ||
4689 | while (true) { | ||
4690 | if (!list.b) { | ||
4691 | return acc; | ||
4692 | } else { | ||
4693 | var x = list.a; | ||
4694 | var xs = list.b; | ||
4695 | var $temp$func = func, | ||
4696 | $temp$acc = A2(func, x, acc), | ||
4697 | $temp$list = xs; | ||
4698 | func = $temp$func; | ||
4699 | acc = $temp$acc; | ||
4700 | list = $temp$list; | ||
4701 | continue foldl; | ||
4702 | } | ||
4703 | } | ||
4704 | }); | ||
4705 | var $elm$core$List$length = function (xs) { | ||
4706 | return A3( | ||
4707 | $elm$core$List$foldl, | ||
4708 | F2( | ||
4709 | function (_v0, i) { | ||
4710 | return i + 1; | ||
4711 | }), | ||
4712 | 0, | ||
4713 | xs); | ||
4714 | }; | ||
4715 | var $elm$core$List$map2 = _List_map2; | ||
4716 | var $elm$core$Basics$le = _Utils_le; | ||
4717 | var $elm$core$Basics$sub = _Basics_sub; | ||
4718 | var $elm$core$List$rangeHelp = F3( | ||
4719 | function (lo, hi, list) { | ||
4720 | rangeHelp: | ||
4721 | while (true) { | ||
4722 | if (_Utils_cmp(lo, hi) < 1) { | ||
4723 | var $temp$lo = lo, | ||
4724 | $temp$hi = hi - 1, | ||
4725 | $temp$list = A2($elm$core$List$cons, hi, list); | ||
4726 | lo = $temp$lo; | ||
4727 | hi = $temp$hi; | ||
4728 | list = $temp$list; | ||
4729 | continue rangeHelp; | ||
4730 | } else { | ||
4731 | return list; | ||
4732 | } | ||
4733 | } | ||
4734 | }); | ||
4735 | var $elm$core$List$range = F2( | ||
4736 | function (lo, hi) { | ||
4737 | return A3($elm$core$List$rangeHelp, lo, hi, _List_Nil); | ||
4738 | }); | ||
4739 | var $elm$core$List$indexedMap = F2( | ||
4740 | function (f, xs) { | ||
4741 | return A3( | ||
4742 | $elm$core$List$map2, | ||
4743 | f, | ||
4744 | A2( | ||
4745 | $elm$core$List$range, | ||
4746 | 0, | ||
4747 | $elm$core$List$length(xs) - 1), | ||
4748 | xs); | ||
4749 | }); | ||
4750 | var $elm$core$Char$toCode = _Char_toCode; | ||
4751 | var $elm$core$Char$isLower = function (_char) { | ||
4752 | var code = $elm$core$Char$toCode(_char); | ||
4753 | return (97 <= code) && (code <= 122); | ||
4754 | }; | ||
4755 | var $elm$core$Char$isUpper = function (_char) { | ||
4756 | var code = $elm$core$Char$toCode(_char); | ||
4757 | return (code <= 90) && (65 <= code); | ||
4758 | }; | ||
4759 | var $elm$core$Basics$or = _Basics_or; | ||
4760 | var $elm$core$Char$isAlpha = function (_char) { | ||
4761 | return $elm$core$Char$isLower(_char) || $elm$core$Char$isUpper(_char); | ||
4762 | }; | ||
4763 | var $elm$core$Char$isDigit = function (_char) { | ||
4764 | var code = $elm$core$Char$toCode(_char); | ||
4765 | return (code <= 57) && (48 <= code); | ||
4766 | }; | ||
4767 | var $elm$core$Char$isAlphaNum = function (_char) { | ||
4768 | return $elm$core$Char$isLower(_char) || ($elm$core$Char$isUpper(_char) || $elm$core$Char$isDigit(_char)); | ||
4769 | }; | ||
4770 | var $elm$core$List$reverse = function (list) { | ||
4771 | return A3($elm$core$List$foldl, $elm$core$List$cons, _List_Nil, list); | ||
4772 | }; | ||
4773 | var $elm$core$String$uncons = _String_uncons; | ||
4774 | var $elm$json$Json$Decode$errorOneOf = F2( | ||
4775 | function (i, error) { | ||
4776 | return '\n\n(' + ($elm$core$String$fromInt(i + 1) + (') ' + $elm$json$Json$Decode$indent( | ||
4777 | $elm$json$Json$Decode$errorToString(error)))); | ||
4778 | }); | ||
4779 | var $elm$json$Json$Decode$errorToString = function (error) { | ||
4780 | return A2($elm$json$Json$Decode$errorToStringHelp, error, _List_Nil); | ||
4781 | }; | ||
4782 | var $elm$json$Json$Decode$errorToStringHelp = F2( | ||
4783 | function (error, context) { | ||
4784 | errorToStringHelp: | ||
4785 | while (true) { | ||
4786 | switch (error.$) { | ||
4787 | case 'Field': | ||
4788 | var f = error.a; | ||
4789 | var err = error.b; | ||
4790 | var isSimple = function () { | ||
4791 | var _v1 = $elm$core$String$uncons(f); | ||
4792 | if (_v1.$ === 'Nothing') { | ||
4793 | return false; | ||
4794 | } else { | ||
4795 | var _v2 = _v1.a; | ||
4796 | var _char = _v2.a; | ||
4797 | var rest = _v2.b; | ||
4798 | return $elm$core$Char$isAlpha(_char) && A2($elm$core$String$all, $elm$core$Char$isAlphaNum, rest); | ||
4799 | } | ||
4800 | }(); | ||
4801 | var fieldName = isSimple ? ('.' + f) : ('[\'' + (f + '\']')); | ||
4802 | var $temp$error = err, | ||
4803 | $temp$context = A2($elm$core$List$cons, fieldName, context); | ||
4804 | error = $temp$error; | ||
4805 | context = $temp$context; | ||
4806 | continue errorToStringHelp; | ||
4807 | case 'Index': | ||
4808 | var i = error.a; | ||
4809 | var err = error.b; | ||
4810 | var indexName = '[' + ($elm$core$String$fromInt(i) + ']'); | ||
4811 | var $temp$error = err, | ||
4812 | $temp$context = A2($elm$core$List$cons, indexName, context); | ||
4813 | error = $temp$error; | ||
4814 | context = $temp$context; | ||
4815 | continue errorToStringHelp; | ||
4816 | case 'OneOf': | ||
4817 | var errors = error.a; | ||
4818 | if (!errors.b) { | ||
4819 | return 'Ran into a Json.Decode.oneOf with no possibilities' + function () { | ||
4820 | if (!context.b) { | ||
4821 | return '!'; | ||
4822 | } else { | ||
4823 | return ' at json' + A2( | ||
4824 | $elm$core$String$join, | ||
4825 | '', | ||
4826 | $elm$core$List$reverse(context)); | ||
4827 | } | ||
4828 | }(); | ||
4829 | } else { | ||
4830 | if (!errors.b.b) { | ||
4831 | var err = errors.a; | ||
4832 | var $temp$error = err, | ||
4833 | $temp$context = context; | ||
4834 | error = $temp$error; | ||
4835 | context = $temp$context; | ||
4836 | continue errorToStringHelp; | ||
4837 | } else { | ||
4838 | var starter = function () { | ||
4839 | if (!context.b) { | ||
4840 | return 'Json.Decode.oneOf'; | ||
4841 | } else { | ||
4842 | return 'The Json.Decode.oneOf at json' + A2( | ||
4843 | $elm$core$String$join, | ||
4844 | '', | ||
4845 | $elm$core$List$reverse(context)); | ||
4846 | } | ||
4847 | }(); | ||
4848 | var introduction = starter + (' failed in the following ' + ($elm$core$String$fromInt( | ||
4849 | $elm$core$List$length(errors)) + ' ways:')); | ||
4850 | return A2( | ||
4851 | $elm$core$String$join, | ||
4852 | '\n\n', | ||
4853 | A2( | ||
4854 | $elm$core$List$cons, | ||
4855 | introduction, | ||
4856 | A2($elm$core$List$indexedMap, $elm$json$Json$Decode$errorOneOf, errors))); | ||
4857 | } | ||
4858 | } | ||
4859 | default: | ||
4860 | var msg = error.a; | ||
4861 | var json = error.b; | ||
4862 | var introduction = function () { | ||
4863 | if (!context.b) { | ||
4864 | return 'Problem with the given value:\n\n'; | ||
4865 | } else { | ||
4866 | return 'Problem with the value at json' + (A2( | ||
4867 | $elm$core$String$join, | ||
4868 | '', | ||
4869 | $elm$core$List$reverse(context)) + ':\n\n '); | ||
4870 | } | ||
4871 | }(); | ||
4872 | return introduction + ($elm$json$Json$Decode$indent( | ||
4873 | A2($elm$json$Json$Encode$encode, 4, json)) + ('\n\n' + msg)); | ||
4874 | } | ||
4875 | } | ||
4876 | }); | ||
4877 | var $elm$core$Array$branchFactor = 32; | ||
4878 | var $elm$core$Array$Array_elm_builtin = F4( | ||
4879 | function (a, b, c, d) { | ||
4880 | return {$: 'Array_elm_builtin', a: a, b: b, c: c, d: d}; | ||
4881 | }); | ||
4882 | var $elm$core$Elm$JsArray$empty = _JsArray_empty; | ||
4883 | var $elm$core$Basics$ceiling = _Basics_ceiling; | ||
4884 | var $elm$core$Basics$fdiv = _Basics_fdiv; | ||
4885 | var $elm$core$Basics$logBase = F2( | ||
4886 | function (base, number) { | ||
4887 | return _Basics_log(number) / _Basics_log(base); | ||
4888 | }); | ||
4889 | var $elm$core$Basics$toFloat = _Basics_toFloat; | ||
4890 | var $elm$core$Array$shiftStep = $elm$core$Basics$ceiling( | ||
4891 | A2($elm$core$Basics$logBase, 2, $elm$core$Array$branchFactor)); | ||
4892 | var $elm$core$Array$empty = A4($elm$core$Array$Array_elm_builtin, 0, $elm$core$Array$shiftStep, $elm$core$Elm$JsArray$empty, $elm$core$Elm$JsArray$empty); | ||
4893 | var $elm$core$Elm$JsArray$initialize = _JsArray_initialize; | ||
4894 | var $elm$core$Array$Leaf = function (a) { | ||
4895 | return {$: 'Leaf', a: a}; | ||
4896 | }; | ||
4897 | var $elm$core$Basics$apL = F2( | ||
4898 | function (f, x) { | ||
4899 | return f(x); | ||
4900 | }); | ||
4901 | var $elm$core$Basics$apR = F2( | ||
4902 | function (x, f) { | ||
4903 | return f(x); | ||
4904 | }); | ||
4905 | var $elm$core$Basics$eq = _Utils_equal; | ||
4906 | var $elm$core$Basics$floor = _Basics_floor; | ||
4907 | var $elm$core$Elm$JsArray$length = _JsArray_length; | ||
4908 | var $elm$core$Basics$gt = _Utils_gt; | ||
4909 | var $elm$core$Basics$max = F2( | ||
4910 | function (x, y) { | ||
4911 | return (_Utils_cmp(x, y) > 0) ? x : y; | ||
4912 | }); | ||
4913 | var $elm$core$Basics$mul = _Basics_mul; | ||
4914 | var $elm$core$Array$SubTree = function (a) { | ||
4915 | return {$: 'SubTree', a: a}; | ||
4916 | }; | ||
4917 | var $elm$core$Elm$JsArray$initializeFromList = _JsArray_initializeFromList; | ||
4918 | var $elm$core$Array$compressNodes = F2( | ||
4919 | function (nodes, acc) { | ||
4920 | compressNodes: | ||
4921 | while (true) { | ||
4922 | var _v0 = A2($elm$core$Elm$JsArray$initializeFromList, $elm$core$Array$branchFactor, nodes); | ||
4923 | var node = _v0.a; | ||
4924 | var remainingNodes = _v0.b; | ||
4925 | var newAcc = A2( | ||
4926 | $elm$core$List$cons, | ||
4927 | $elm$core$Array$SubTree(node), | ||
4928 | acc); | ||
4929 | if (!remainingNodes.b) { | ||
4930 | return $elm$core$List$reverse(newAcc); | ||
4931 | } else { | ||
4932 | var $temp$nodes = remainingNodes, | ||
4933 | $temp$acc = newAcc; | ||
4934 | nodes = $temp$nodes; | ||
4935 | acc = $temp$acc; | ||
4936 | continue compressNodes; | ||
4937 | } | ||
4938 | } | ||
4939 | }); | ||
4940 | var $elm$core$Tuple$first = function (_v0) { | ||
4941 | var x = _v0.a; | ||
4942 | return x; | ||
4943 | }; | ||
4944 | var $elm$core$Array$treeFromBuilder = F2( | ||
4945 | function (nodeList, nodeListSize) { | ||
4946 | treeFromBuilder: | ||
4947 | while (true) { | ||
4948 | var newNodeSize = $elm$core$Basics$ceiling(nodeListSize / $elm$core$Array$branchFactor); | ||
4949 | if (newNodeSize === 1) { | ||
4950 | return A2($elm$core$Elm$JsArray$initializeFromList, $elm$core$Array$branchFactor, nodeList).a; | ||
4951 | } else { | ||
4952 | var $temp$nodeList = A2($elm$core$Array$compressNodes, nodeList, _List_Nil), | ||
4953 | $temp$nodeListSize = newNodeSize; | ||
4954 | nodeList = $temp$nodeList; | ||
4955 | nodeListSize = $temp$nodeListSize; | ||
4956 | continue treeFromBuilder; | ||
4957 | } | ||
4958 | } | ||
4959 | }); | ||
4960 | var $elm$core$Array$builderToArray = F2( | ||
4961 | function (reverseNodeList, builder) { | ||
4962 | if (!builder.nodeListSize) { | ||
4963 | return A4( | ||
4964 | $elm$core$Array$Array_elm_builtin, | ||
4965 | $elm$core$Elm$JsArray$length(builder.tail), | ||
4966 | $elm$core$Array$shiftStep, | ||
4967 | $elm$core$Elm$JsArray$empty, | ||
4968 | builder.tail); | ||
4969 | } else { | ||
4970 | var treeLen = builder.nodeListSize * $elm$core$Array$branchFactor; | ||
4971 | var depth = $elm$core$Basics$floor( | ||
4972 | A2($elm$core$Basics$logBase, $elm$core$Array$branchFactor, treeLen - 1)); | ||
4973 | var correctNodeList = reverseNodeList ? $elm$core$List$reverse(builder.nodeList) : builder.nodeList; | ||
4974 | var tree = A2($elm$core$Array$treeFromBuilder, correctNodeList, builder.nodeListSize); | ||
4975 | return A4( | ||
4976 | $elm$core$Array$Array_elm_builtin, | ||
4977 | $elm$core$Elm$JsArray$length(builder.tail) + treeLen, | ||
4978 | A2($elm$core$Basics$max, 5, depth * $elm$core$Array$shiftStep), | ||
4979 | tree, | ||
4980 | builder.tail); | ||
4981 | } | ||
4982 | }); | ||
4983 | var $elm$core$Basics$idiv = _Basics_idiv; | ||
4984 | var $elm$core$Basics$lt = _Utils_lt; | ||
4985 | var $elm$core$Array$initializeHelp = F5( | ||
4986 | function (fn, fromIndex, len, nodeList, tail) { | ||
4987 | initializeHelp: | ||
4988 | while (true) { | ||
4989 | if (fromIndex < 0) { | ||
4990 | return A2( | ||
4991 | $elm$core$Array$builderToArray, | ||
4992 | false, | ||
4993 | {nodeList: nodeList, nodeListSize: (len / $elm$core$Array$branchFactor) | 0, tail: tail}); | ||
4994 | } else { | ||
4995 | var leaf = $elm$core$Array$Leaf( | ||
4996 | A3($elm$core$Elm$JsArray$initialize, $elm$core$Array$branchFactor, fromIndex, fn)); | ||
4997 | var $temp$fn = fn, | ||
4998 | $temp$fromIndex = fromIndex - $elm$core$Array$branchFactor, | ||
4999 | $temp$len = len, | ||
5000 | $temp$nodeList = A2($elm$core$List$cons, leaf, nodeList), | ||
5001 | $temp$tail = tail; | ||
5002 | fn = $temp$fn; | ||
5003 | fromIndex = $temp$fromIndex; | ||
5004 | len = $temp$len; | ||
5005 | nodeList = $temp$nodeList; | ||
5006 | tail = $temp$tail; | ||
5007 | continue initializeHelp; | ||
5008 | } | ||
5009 | } | ||
5010 | }); | ||
5011 | var $elm$core$Basics$remainderBy = _Basics_remainderBy; | ||
5012 | var $elm$core$Array$initialize = F2( | ||
5013 | function (len, fn) { | ||
5014 | if (len <= 0) { | ||
5015 | return $elm$core$Array$empty; | ||
5016 | } else { | ||
5017 | var tailLen = len % $elm$core$Array$branchFactor; | ||
5018 | var tail = A3($elm$core$Elm$JsArray$initialize, tailLen, len - tailLen, fn); | ||
5019 | var initialFromIndex = (len - tailLen) - $elm$core$Array$branchFactor; | ||
5020 | return A5($elm$core$Array$initializeHelp, fn, initialFromIndex, len, _List_Nil, tail); | ||
5021 | } | ||
5022 | }); | ||
5023 | var $elm$core$Basics$True = {$: 'True'}; | ||
5024 | var $elm$core$Result$isOk = function (result) { | ||
5025 | if (result.$ === 'Ok') { | ||
5026 | return true; | ||
5027 | } else { | ||
5028 | return false; | ||
5029 | } | ||
5030 | }; | ||
5031 | var $elm$json$Json$Decode$map = _Json_map1; | ||
5032 | var $elm$json$Json$Decode$map2 = _Json_map2; | ||
5033 | var $elm$json$Json$Decode$succeed = _Json_succeed; | ||
5034 | var $elm$virtual_dom$VirtualDom$toHandlerInt = function (handler) { | ||
5035 | switch (handler.$) { | ||
5036 | case 'Normal': | ||
5037 | return 0; | ||
5038 | case 'MayStopPropagation': | ||
5039 | return 1; | ||
5040 | case 'MayPreventDefault': | ||
5041 | return 2; | ||
5042 | default: | ||
5043 | return 3; | ||
5044 | } | ||
5045 | }; | ||
5046 | var $elm$browser$Browser$External = function (a) { | ||
5047 | return {$: 'External', a: a}; | ||
5048 | }; | ||
5049 | var $elm$browser$Browser$Internal = function (a) { | ||
5050 | return {$: 'Internal', a: a}; | ||
5051 | }; | ||
5052 | var $elm$core$Basics$identity = function (x) { | ||
5053 | return x; | ||
5054 | }; | ||
5055 | var $elm$browser$Browser$Dom$NotFound = function (a) { | ||
5056 | return {$: 'NotFound', a: a}; | ||
5057 | }; | ||
5058 | var $elm$url$Url$Http = {$: 'Http'}; | ||
5059 | var $elm$url$Url$Https = {$: 'Https'}; | ||
5060 | var $elm$url$Url$Url = F6( | ||
5061 | function (protocol, host, port_, path, query, fragment) { | ||
5062 | return {fragment: fragment, host: host, path: path, port_: port_, protocol: protocol, query: query}; | ||
5063 | }); | ||
5064 | var $elm$core$String$contains = _String_contains; | ||
5065 | var $elm$core$String$length = _String_length; | ||
5066 | var $elm$core$String$slice = _String_slice; | ||
5067 | var $elm$core$String$dropLeft = F2( | ||
5068 | function (n, string) { | ||
5069 | return (n < 1) ? string : A3( | ||
5070 | $elm$core$String$slice, | ||
5071 | n, | ||
5072 | $elm$core$String$length(string), | ||
5073 | string); | ||
5074 | }); | ||
5075 | var $elm$core$String$indexes = _String_indexes; | ||
5076 | var $elm$core$String$isEmpty = function (string) { | ||
5077 | return string === ''; | ||
5078 | }; | ||
5079 | var $elm$core$String$left = F2( | ||
5080 | function (n, string) { | ||
5081 | return (n < 1) ? '' : A3($elm$core$String$slice, 0, n, string); | ||
5082 | }); | ||
5083 | var $elm$core$String$toInt = _String_toInt; | ||
5084 | var $elm$url$Url$chompBeforePath = F5( | ||
5085 | function (protocol, path, params, frag, str) { | ||
5086 | if ($elm$core$String$isEmpty(str) || A2($elm$core$String$contains, '@', str)) { | ||
5087 | return $elm$core$Maybe$Nothing; | ||
5088 | } else { | ||
5089 | var _v0 = A2($elm$core$String$indexes, ':', str); | ||
5090 | if (!_v0.b) { | ||
5091 | return $elm$core$Maybe$Just( | ||
5092 | A6($elm$url$Url$Url, protocol, str, $elm$core$Maybe$Nothing, path, params, frag)); | ||
5093 | } else { | ||
5094 | if (!_v0.b.b) { | ||
5095 | var i = _v0.a; | ||
5096 | var _v1 = $elm$core$String$toInt( | ||
5097 | A2($elm$core$String$dropLeft, i + 1, str)); | ||
5098 | if (_v1.$ === 'Nothing') { | ||
5099 | return $elm$core$Maybe$Nothing; | ||
5100 | } else { | ||
5101 | var port_ = _v1; | ||
5102 | return $elm$core$Maybe$Just( | ||
5103 | A6( | ||
5104 | $elm$url$Url$Url, | ||
5105 | protocol, | ||
5106 | A2($elm$core$String$left, i, str), | ||
5107 | port_, | ||
5108 | path, | ||
5109 | params, | ||
5110 | frag)); | ||
5111 | } | ||
5112 | } else { | ||
5113 | return $elm$core$Maybe$Nothing; | ||
5114 | } | ||
5115 | } | ||
5116 | } | ||
5117 | }); | ||
5118 | var $elm$url$Url$chompBeforeQuery = F4( | ||
5119 | function (protocol, params, frag, str) { | ||
5120 | if ($elm$core$String$isEmpty(str)) { | ||
5121 | return $elm$core$Maybe$Nothing; | ||
5122 | } else { | ||
5123 | var _v0 = A2($elm$core$String$indexes, '/', str); | ||
5124 | if (!_v0.b) { | ||
5125 | return A5($elm$url$Url$chompBeforePath, protocol, '/', params, frag, str); | ||
5126 | } else { | ||
5127 | var i = _v0.a; | ||
5128 | return A5( | ||
5129 | $elm$url$Url$chompBeforePath, | ||
5130 | protocol, | ||
5131 | A2($elm$core$String$dropLeft, i, str), | ||
5132 | params, | ||
5133 | frag, | ||
5134 | A2($elm$core$String$left, i, str)); | ||
5135 | } | ||
5136 | } | ||
5137 | }); | ||
5138 | var $elm$url$Url$chompBeforeFragment = F3( | ||
5139 | function (protocol, frag, str) { | ||
5140 | if ($elm$core$String$isEmpty(str)) { | ||
5141 | return $elm$core$Maybe$Nothing; | ||
5142 | } else { | ||
5143 | var _v0 = A2($elm$core$String$indexes, '?', str); | ||
5144 | if (!_v0.b) { | ||
5145 | return A4($elm$url$Url$chompBeforeQuery, protocol, $elm$core$Maybe$Nothing, frag, str); | ||
5146 | } else { | ||
5147 | var i = _v0.a; | ||
5148 | return A4( | ||
5149 | $elm$url$Url$chompBeforeQuery, | ||
5150 | protocol, | ||
5151 | $elm$core$Maybe$Just( | ||
5152 | A2($elm$core$String$dropLeft, i + 1, str)), | ||
5153 | frag, | ||
5154 | A2($elm$core$String$left, i, str)); | ||
5155 | } | ||
5156 | } | ||
5157 | }); | ||
5158 | var $elm$url$Url$chompAfterProtocol = F2( | ||
5159 | function (protocol, str) { | ||
5160 | if ($elm$core$String$isEmpty(str)) { | ||
5161 | return $elm$core$Maybe$Nothing; | ||
5162 | } else { | ||
5163 | var _v0 = A2($elm$core$String$indexes, '#', str); | ||
5164 | if (!_v0.b) { | ||
5165 | return A3($elm$url$Url$chompBeforeFragment, protocol, $elm$core$Maybe$Nothing, str); | ||
5166 | } else { | ||
5167 | var i = _v0.a; | ||
5168 | return A3( | ||
5169 | $elm$url$Url$chompBeforeFragment, | ||
5170 | protocol, | ||
5171 | $elm$core$Maybe$Just( | ||
5172 | A2($elm$core$String$dropLeft, i + 1, str)), | ||
5173 | A2($elm$core$String$left, i, str)); | ||
5174 | } | ||
5175 | } | ||
5176 | }); | ||
5177 | var $elm$core$String$startsWith = _String_startsWith; | ||
5178 | var $elm$url$Url$fromString = function (str) { | ||
5179 | return A2($elm$core$String$startsWith, 'http://', str) ? A2( | ||
5180 | $elm$url$Url$chompAfterProtocol, | ||
5181 | $elm$url$Url$Http, | ||
5182 | A2($elm$core$String$dropLeft, 7, str)) : (A2($elm$core$String$startsWith, 'https://', str) ? A2( | ||
5183 | $elm$url$Url$chompAfterProtocol, | ||
5184 | $elm$url$Url$Https, | ||
5185 | A2($elm$core$String$dropLeft, 8, str)) : $elm$core$Maybe$Nothing); | ||
5186 | }; | ||
5187 | var $elm$core$Basics$never = function (_v0) { | ||
5188 | never: | ||
5189 | while (true) { | ||
5190 | var nvr = _v0.a; | ||
5191 | var $temp$_v0 = nvr; | ||
5192 | _v0 = $temp$_v0; | ||
5193 | continue never; | ||
5194 | } | ||
5195 | }; | ||
5196 | var $elm$core$Task$Perform = function (a) { | ||
5197 | return {$: 'Perform', a: a}; | ||
5198 | }; | ||
5199 | var $elm$core$Task$succeed = _Scheduler_succeed; | ||
5200 | var $elm$core$Task$init = $elm$core$Task$succeed(_Utils_Tuple0); | ||
5201 | var $elm$core$List$foldrHelper = F4( | ||
5202 | function (fn, acc, ctr, ls) { | ||
5203 | if (!ls.b) { | ||
5204 | return acc; | ||
5205 | } else { | ||
5206 | var a = ls.a; | ||
5207 | var r1 = ls.b; | ||
5208 | if (!r1.b) { | ||
5209 | return A2(fn, a, acc); | ||
5210 | } else { | ||
5211 | var b = r1.a; | ||
5212 | var r2 = r1.b; | ||
5213 | if (!r2.b) { | ||
5214 | return A2( | ||
5215 | fn, | ||
5216 | a, | ||
5217 | A2(fn, b, acc)); | ||
5218 | } else { | ||
5219 | var c = r2.a; | ||
5220 | var r3 = r2.b; | ||
5221 | if (!r3.b) { | ||
5222 | return A2( | ||
5223 | fn, | ||
5224 | a, | ||
5225 | A2( | ||
5226 | fn, | ||
5227 | b, | ||
5228 | A2(fn, c, acc))); | ||
5229 | } else { | ||
5230 | var d = r3.a; | ||
5231 | var r4 = r3.b; | ||
5232 | var res = (ctr > 500) ? A3( | ||
5233 | $elm$core$List$foldl, | ||
5234 | fn, | ||
5235 | acc, | ||
5236 | $elm$core$List$reverse(r4)) : A4($elm$core$List$foldrHelper, fn, acc, ctr + 1, r4); | ||
5237 | return A2( | ||
5238 | fn, | ||
5239 | a, | ||
5240 | A2( | ||
5241 | fn, | ||
5242 | b, | ||
5243 | A2( | ||
5244 | fn, | ||
5245 | c, | ||
5246 | A2(fn, d, res)))); | ||
5247 | } | ||
5248 | } | ||
5249 | } | ||
5250 | } | ||
5251 | }); | ||
5252 | var $elm$core$List$foldr = F3( | ||
5253 | function (fn, acc, ls) { | ||
5254 | return A4($elm$core$List$foldrHelper, fn, acc, 0, ls); | ||
5255 | }); | ||
5256 | var $elm$core$List$map = F2( | ||
5257 | function (f, xs) { | ||
5258 | return A3( | ||
5259 | $elm$core$List$foldr, | ||
5260 | F2( | ||
5261 | function (x, acc) { | ||
5262 | return A2( | ||
5263 | $elm$core$List$cons, | ||
5264 | f(x), | ||
5265 | acc); | ||
5266 | }), | ||
5267 | _List_Nil, | ||
5268 | xs); | ||
5269 | }); | ||
5270 | var $elm$core$Task$andThen = _Scheduler_andThen; | ||
5271 | var $elm$core$Task$map = F2( | ||
5272 | function (func, taskA) { | ||
5273 | return A2( | ||
5274 | $elm$core$Task$andThen, | ||
5275 | function (a) { | ||
5276 | return $elm$core$Task$succeed( | ||
5277 | func(a)); | ||
5278 | }, | ||
5279 | taskA); | ||
5280 | }); | ||
5281 | var $elm$core$Task$map2 = F3( | ||
5282 | function (func, taskA, taskB) { | ||
5283 | return A2( | ||
5284 | $elm$core$Task$andThen, | ||
5285 | function (a) { | ||
5286 | return A2( | ||
5287 | $elm$core$Task$andThen, | ||
5288 | function (b) { | ||
5289 | return $elm$core$Task$succeed( | ||
5290 | A2(func, a, b)); | ||
5291 | }, | ||
5292 | taskB); | ||
5293 | }, | ||
5294 | taskA); | ||
5295 | }); | ||
5296 | var $elm$core$Task$sequence = function (tasks) { | ||
5297 | return A3( | ||
5298 | $elm$core$List$foldr, | ||
5299 | $elm$core$Task$map2($elm$core$List$cons), | ||
5300 | $elm$core$Task$succeed(_List_Nil), | ||
5301 | tasks); | ||
5302 | }; | ||
5303 | var $elm$core$Platform$sendToApp = _Platform_sendToApp; | ||
5304 | var $elm$core$Task$spawnCmd = F2( | ||
5305 | function (router, _v0) { | ||
5306 | var task = _v0.a; | ||
5307 | return _Scheduler_spawn( | ||
5308 | A2( | ||
5309 | $elm$core$Task$andThen, | ||
5310 | $elm$core$Platform$sendToApp(router), | ||
5311 | task)); | ||
5312 | }); | ||
5313 | var $elm$core$Task$onEffects = F3( | ||
5314 | function (router, commands, state) { | ||
5315 | return A2( | ||
5316 | $elm$core$Task$map, | ||
5317 | function (_v0) { | ||
5318 | return _Utils_Tuple0; | ||
5319 | }, | ||
5320 | $elm$core$Task$sequence( | ||
5321 | A2( | ||
5322 | $elm$core$List$map, | ||
5323 | $elm$core$Task$spawnCmd(router), | ||
5324 | commands))); | ||
5325 | }); | ||
5326 | var $elm$core$Task$onSelfMsg = F3( | ||
5327 | function (_v0, _v1, _v2) { | ||
5328 | return $elm$core$Task$succeed(_Utils_Tuple0); | ||
5329 | }); | ||
5330 | var $elm$core$Task$cmdMap = F2( | ||
5331 | function (tagger, _v0) { | ||
5332 | var task = _v0.a; | ||
5333 | return $elm$core$Task$Perform( | ||
5334 | A2($elm$core$Task$map, tagger, task)); | ||
5335 | }); | ||
5336 | _Platform_effectManagers['Task'] = _Platform_createManager($elm$core$Task$init, $elm$core$Task$onEffects, $elm$core$Task$onSelfMsg, $elm$core$Task$cmdMap); | ||
5337 | var $elm$core$Task$command = _Platform_leaf('Task'); | ||
5338 | var $elm$core$Task$perform = F2( | ||
5339 | function (toMessage, task) { | ||
5340 | return $elm$core$Task$command( | ||
5341 | $elm$core$Task$Perform( | ||
5342 | A2($elm$core$Task$map, toMessage, task))); | ||
5343 | }); | ||
5344 | var $elm$browser$Browser$application = _Browser_application; | ||
5345 | var $author$project$Main$HomePage = {$: 'HomePage'}; | ||
5346 | var $author$project$Main$Model = F8( | ||
5347 | function (key, url, location, loginModel, catalogModel, productModel, signupModel, cartModel) { | ||
5348 | return {cartModel: cartModel, catalogModel: catalogModel, key: key, location: location, loginModel: loginModel, productModel: productModel, signupModel: signupModel, url: url}; | ||
5349 | }); | ||
5350 | var $author$project$Cart$Model = F2( | ||
5351 | function (pageStatus, products) { | ||
5352 | return {pageStatus: pageStatus, products: products}; | ||
5353 | }); | ||
5354 | var $author$project$Cart$NotLoaded = {$: 'NotLoaded'}; | ||
5355 | var $author$project$Cart$init = A2($author$project$Cart$Model, $author$project$Cart$NotLoaded, _List_Nil); | ||
5356 | var $author$project$Catalog$Model = F2( | ||
5357 | function (pageStatus, products) { | ||
5358 | return {pageStatus: pageStatus, products: products}; | ||
5359 | }); | ||
5360 | var $author$project$Catalog$NotLoaded = {$: 'NotLoaded'}; | ||
5361 | var $author$project$Catalog$init = A2($author$project$Catalog$Model, $author$project$Catalog$NotLoaded, _List_Nil); | ||
5362 | var $author$project$Login$Model = F3( | ||
5363 | function (username, password, loginStatus) { | ||
5364 | return {loginStatus: loginStatus, password: password, username: username}; | ||
5365 | }); | ||
5366 | var $author$project$Login$NotLoggedIn = {$: 'NotLoggedIn'}; | ||
5367 | var $author$project$Login$init = A3($author$project$Login$Model, '', '', $author$project$Login$NotLoggedIn); | ||
5368 | var $author$project$Product$Model = F6( | ||
5369 | function (pageStatus, listing, ratings, ratingStars, ratingText, addRatingStatus) { | ||
5370 | return {addRatingStatus: addRatingStatus, listing: listing, pageStatus: pageStatus, ratingStars: ratingStars, ratingText: ratingText, ratings: ratings}; | ||
5371 | }); | ||
5372 | var $author$project$Product$NotLoaded = {$: 'NotLoaded'}; | ||
5373 | var $author$project$Product$NotSubmitted = {$: 'NotSubmitted'}; | ||
5374 | var $author$project$Product$Product = F5( | ||
5375 | function (id, name, kind, price, description) { | ||
5376 | return {description: description, id: id, kind: kind, name: name, price: price}; | ||
5377 | }); | ||
5378 | var $elm$core$Basics$negate = function (n) { | ||
5379 | return -n; | ||
5380 | }; | ||
5381 | var $author$project$Product$emptyProduct = A5($author$project$Product$Product, -1, '', $elm$core$Maybe$Nothing, 0, $elm$core$Maybe$Nothing); | ||
5382 | var $author$project$Product$init = A6($author$project$Product$Model, $author$project$Product$NotLoaded, $author$project$Product$emptyProduct, _List_Nil, 0, '', $author$project$Product$NotSubmitted); | ||
5383 | var $author$project$Signup$Empty = {$: 'Empty'}; | ||
5384 | var $author$project$Signup$Model = F6( | ||
5385 | function (username, password, phoneNumber, emailId, address, status) { | ||
5386 | return {address: address, emailId: emailId, password: password, phoneNumber: phoneNumber, status: status, username: username}; | ||
5387 | }); | ||
5388 | var $author$project$Signup$init = A6($author$project$Signup$Model, '', '', '', '', $elm$core$Maybe$Nothing, $author$project$Signup$Empty); | ||
5389 | var $elm$core$Platform$Cmd$batch = _Platform_batch; | ||
5390 | var $elm$core$Platform$Cmd$none = $elm$core$Platform$Cmd$batch(_List_Nil); | ||
5391 | var $author$project$Main$init = F3( | ||
5392 | function (flags, url, key) { | ||
5393 | var start = $author$project$Main$HomePage; | ||
5394 | var signup = $author$project$Signup$init; | ||
5395 | var product = $author$project$Product$init; | ||
5396 | var login = $author$project$Login$init; | ||
5397 | var catalog = $author$project$Catalog$init; | ||
5398 | var cart = $author$project$Cart$init; | ||
5399 | return _Utils_Tuple2( | ||
5400 | A8($author$project$Main$Model, key, url, start, login, catalog, product, signup, cart), | ||
5401 | $elm$core$Platform$Cmd$none); | ||
5402 | }); | ||
5403 | var $elm$core$Platform$Sub$batch = _Platform_batch; | ||
5404 | var $elm$core$Platform$Sub$none = $elm$core$Platform$Sub$batch(_List_Nil); | ||
5405 | var $author$project$Main$subscriptions = function (_v0) { | ||
5406 | return $elm$core$Platform$Sub$none; | ||
5407 | }; | ||
5408 | var $author$project$Main$CartMessage = function (a) { | ||
5409 | return {$: 'CartMessage', a: a}; | ||
5410 | }; | ||
5411 | var $author$project$Main$CartPage = {$: 'CartPage'}; | ||
5412 | var $author$project$Main$CatalogMessage = function (a) { | ||
5413 | return {$: 'CatalogMessage', a: a}; | ||
5414 | }; | ||
5415 | var $author$project$Main$CatalogPage = {$: 'CatalogPage'}; | ||
5416 | var $author$project$Main$LoginMessage = function (a) { | ||
5417 | return {$: 'LoginMessage', a: a}; | ||
5418 | }; | ||
5419 | var $author$project$Main$NotFoundPage = {$: 'NotFoundPage'}; | ||
5420 | var $author$project$Main$ProductMessage = function (a) { | ||
5421 | return {$: 'ProductMessage', a: a}; | ||
5422 | }; | ||
5423 | var $author$project$Main$ProductPage = function (a) { | ||
5424 | return {$: 'ProductPage', a: a}; | ||
5425 | }; | ||
5426 | var $author$project$Main$SignupMessage = function (a) { | ||
5427 | return {$: 'SignupMessage', a: a}; | ||
5428 | }; | ||
5429 | var $author$project$Cart$CartLoaded = function (a) { | ||
5430 | return {$: 'CartLoaded', a: a}; | ||
5431 | }; | ||
5432 | var $author$project$Cart$Product = F5( | ||
5433 | function (id, name, kind, price, description) { | ||
5434 | return {description: description, id: id, kind: kind, name: name, price: price}; | ||
5435 | }); | ||
5436 | var $elm$json$Json$Decode$field = _Json_decodeField; | ||
5437 | var $elm$json$Json$Decode$float = _Json_decodeFloat; | ||
5438 | var $elm$json$Json$Decode$int = _Json_decodeInt; | ||
5439 | var $elm$json$Json$Decode$map5 = _Json_map5; | ||
5440 | var $elm$json$Json$Decode$null = _Json_decodeNull; | ||
5441 | var $elm$json$Json$Decode$oneOf = _Json_oneOf; | ||
5442 | var $elm$json$Json$Decode$nullable = function (decoder) { | ||
5443 | return $elm$json$Json$Decode$oneOf( | ||
5444 | _List_fromArray( | ||
5445 | [ | ||
5446 | $elm$json$Json$Decode$null($elm$core$Maybe$Nothing), | ||
5447 | A2($elm$json$Json$Decode$map, $elm$core$Maybe$Just, decoder) | ||
5448 | ])); | ||
5449 | }; | ||
5450 | var $elm$json$Json$Decode$string = _Json_decodeString; | ||
5451 | var $author$project$Cart$decodeProduct = A6( | ||
5452 | $elm$json$Json$Decode$map5, | ||
5453 | $author$project$Cart$Product, | ||
5454 | A2($elm$json$Json$Decode$field, 'id', $elm$json$Json$Decode$int), | ||
5455 | A2($elm$json$Json$Decode$field, 'name', $elm$json$Json$Decode$string), | ||
5456 | A2( | ||
5457 | $elm$json$Json$Decode$field, | ||
5458 | 'kind', | ||
5459 | $elm$json$Json$Decode$nullable($elm$json$Json$Decode$string)), | ||
5460 | A2($elm$json$Json$Decode$field, 'price', $elm$json$Json$Decode$float), | ||
5461 | A2( | ||
5462 | $elm$json$Json$Decode$field, | ||
5463 | 'description', | ||
5464 | $elm$json$Json$Decode$nullable($elm$json$Json$Decode$string))); | ||
5465 | var $elm$json$Json$Decode$list = _Json_decodeList; | ||
5466 | var $author$project$Cart$decodeResponse = $elm$json$Json$Decode$list($author$project$Cart$decodeProduct); | ||
5467 | var $elm$http$Http$BadStatus_ = F2( | ||
5468 | function (a, b) { | ||
5469 | return {$: 'BadStatus_', a: a, b: b}; | ||
5470 | }); | ||
5471 | var $elm$http$Http$BadUrl_ = function (a) { | ||
5472 | return {$: 'BadUrl_', a: a}; | ||
5473 | }; | ||
5474 | var $elm$http$Http$GoodStatus_ = F2( | ||
5475 | function (a, b) { | ||
5476 | return {$: 'GoodStatus_', a: a, b: b}; | ||
5477 | }); | ||
5478 | var $elm$http$Http$NetworkError_ = {$: 'NetworkError_'}; | ||
5479 | var $elm$http$Http$Receiving = function (a) { | ||
5480 | return {$: 'Receiving', a: a}; | ||
5481 | }; | ||
5482 | var $elm$http$Http$Sending = function (a) { | ||
5483 | return {$: 'Sending', a: a}; | ||
5484 | }; | ||
5485 | var $elm$http$Http$Timeout_ = {$: 'Timeout_'}; | ||
5486 | var $elm$core$Dict$RBEmpty_elm_builtin = {$: 'RBEmpty_elm_builtin'}; | ||
5487 | var $elm$core$Dict$empty = $elm$core$Dict$RBEmpty_elm_builtin; | ||
5488 | var $elm$core$Maybe$isJust = function (maybe) { | ||
5489 | if (maybe.$ === 'Just') { | ||
5490 | return true; | ||
5491 | } else { | ||
5492 | return false; | ||
5493 | } | ||
5494 | }; | ||
5495 | var $elm$core$Platform$sendToSelf = _Platform_sendToSelf; | ||
5496 | var $elm$core$Basics$compare = _Utils_compare; | ||
5497 | var $elm$core$Dict$get = F2( | ||
5498 | function (targetKey, dict) { | ||
5499 | get: | ||
5500 | while (true) { | ||
5501 | if (dict.$ === 'RBEmpty_elm_builtin') { | ||
5502 | return $elm$core$Maybe$Nothing; | ||
5503 | } else { | ||
5504 | var key = dict.b; | ||
5505 | var value = dict.c; | ||
5506 | var left = dict.d; | ||
5507 | var right = dict.e; | ||
5508 | var _v1 = A2($elm$core$Basics$compare, targetKey, key); | ||
5509 | switch (_v1.$) { | ||
5510 | case 'LT': | ||
5511 | var $temp$targetKey = targetKey, | ||
5512 | $temp$dict = left; | ||
5513 | targetKey = $temp$targetKey; | ||
5514 | dict = $temp$dict; | ||
5515 | continue get; | ||
5516 | case 'EQ': | ||
5517 | return $elm$core$Maybe$Just(value); | ||
5518 | default: | ||
5519 | var $temp$targetKey = targetKey, | ||
5520 | $temp$dict = right; | ||
5521 | targetKey = $temp$targetKey; | ||
5522 | dict = $temp$dict; | ||
5523 | continue get; | ||
5524 | } | ||
5525 | } | ||
5526 | } | ||
5527 | }); | ||
5528 | var $elm$core$Dict$Black = {$: 'Black'}; | ||
5529 | var $elm$core$Dict$RBNode_elm_builtin = F5( | ||
5530 | function (a, b, c, d, e) { | ||
5531 | return {$: 'RBNode_elm_builtin', a: a, b: b, c: c, d: d, e: e}; | ||
5532 | }); | ||
5533 | var $elm$core$Dict$Red = {$: 'Red'}; | ||
5534 | var $elm$core$Dict$balance = F5( | ||
5535 | function (color, key, value, left, right) { | ||
5536 | if ((right.$ === 'RBNode_elm_builtin') && (right.a.$ === 'Red')) { | ||
5537 | var _v1 = right.a; | ||
5538 | var rK = right.b; | ||
5539 | var rV = right.c; | ||
5540 | var rLeft = right.d; | ||
5541 | var rRight = right.e; | ||
5542 | if ((left.$ === 'RBNode_elm_builtin') && (left.a.$ === 'Red')) { | ||
5543 | var _v3 = left.a; | ||
5544 | var lK = left.b; | ||
5545 | var lV = left.c; | ||
5546 | var lLeft = left.d; | ||
5547 | var lRight = left.e; | ||
5548 | return A5( | ||
5549 | $elm$core$Dict$RBNode_elm_builtin, | ||
5550 | $elm$core$Dict$Red, | ||
5551 | key, | ||
5552 | value, | ||
5553 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Black, lK, lV, lLeft, lRight), | ||
5554 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Black, rK, rV, rLeft, rRight)); | ||
5555 | } else { | ||
5556 | return A5( | ||
5557 | $elm$core$Dict$RBNode_elm_builtin, | ||
5558 | color, | ||
5559 | rK, | ||
5560 | rV, | ||
5561 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Red, key, value, left, rLeft), | ||
5562 | rRight); | ||
5563 | } | ||
5564 | } else { | ||
5565 | if ((((left.$ === 'RBNode_elm_builtin') && (left.a.$ === 'Red')) && (left.d.$ === 'RBNode_elm_builtin')) && (left.d.a.$ === 'Red')) { | ||
5566 | var _v5 = left.a; | ||
5567 | var lK = left.b; | ||
5568 | var lV = left.c; | ||
5569 | var _v6 = left.d; | ||
5570 | var _v7 = _v6.a; | ||
5571 | var llK = _v6.b; | ||
5572 | var llV = _v6.c; | ||
5573 | var llLeft = _v6.d; | ||
5574 | var llRight = _v6.e; | ||
5575 | var lRight = left.e; | ||
5576 | return A5( | ||
5577 | $elm$core$Dict$RBNode_elm_builtin, | ||
5578 | $elm$core$Dict$Red, | ||
5579 | lK, | ||
5580 | lV, | ||
5581 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Black, llK, llV, llLeft, llRight), | ||
5582 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Black, key, value, lRight, right)); | ||
5583 | } else { | ||
5584 | return A5($elm$core$Dict$RBNode_elm_builtin, color, key, value, left, right); | ||
5585 | } | ||
5586 | } | ||
5587 | }); | ||
5588 | var $elm$core$Dict$insertHelp = F3( | ||
5589 | function (key, value, dict) { | ||
5590 | if (dict.$ === 'RBEmpty_elm_builtin') { | ||
5591 | return A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Red, key, value, $elm$core$Dict$RBEmpty_elm_builtin, $elm$core$Dict$RBEmpty_elm_builtin); | ||
5592 | } else { | ||
5593 | var nColor = dict.a; | ||
5594 | var nKey = dict.b; | ||
5595 | var nValue = dict.c; | ||
5596 | var nLeft = dict.d; | ||
5597 | var nRight = dict.e; | ||
5598 | var _v1 = A2($elm$core$Basics$compare, key, nKey); | ||
5599 | switch (_v1.$) { | ||
5600 | case 'LT': | ||
5601 | return A5( | ||
5602 | $elm$core$Dict$balance, | ||
5603 | nColor, | ||
5604 | nKey, | ||
5605 | nValue, | ||
5606 | A3($elm$core$Dict$insertHelp, key, value, nLeft), | ||
5607 | nRight); | ||
5608 | case 'EQ': | ||
5609 | return A5($elm$core$Dict$RBNode_elm_builtin, nColor, nKey, value, nLeft, nRight); | ||
5610 | default: | ||
5611 | return A5( | ||
5612 | $elm$core$Dict$balance, | ||
5613 | nColor, | ||
5614 | nKey, | ||
5615 | nValue, | ||
5616 | nLeft, | ||
5617 | A3($elm$core$Dict$insertHelp, key, value, nRight)); | ||
5618 | } | ||
5619 | } | ||
5620 | }); | ||
5621 | var $elm$core$Dict$insert = F3( | ||
5622 | function (key, value, dict) { | ||
5623 | var _v0 = A3($elm$core$Dict$insertHelp, key, value, dict); | ||
5624 | if ((_v0.$ === 'RBNode_elm_builtin') && (_v0.a.$ === 'Red')) { | ||
5625 | var _v1 = _v0.a; | ||
5626 | var k = _v0.b; | ||
5627 | var v = _v0.c; | ||
5628 | var l = _v0.d; | ||
5629 | var r = _v0.e; | ||
5630 | return A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Black, k, v, l, r); | ||
5631 | } else { | ||
5632 | var x = _v0; | ||
5633 | return x; | ||
5634 | } | ||
5635 | }); | ||
5636 | var $elm$core$Dict$getMin = function (dict) { | ||
5637 | getMin: | ||
5638 | while (true) { | ||
5639 | if ((dict.$ === 'RBNode_elm_builtin') && (dict.d.$ === 'RBNode_elm_builtin')) { | ||
5640 | var left = dict.d; | ||
5641 | var $temp$dict = left; | ||
5642 | dict = $temp$dict; | ||
5643 | continue getMin; | ||
5644 | } else { | ||
5645 | return dict; | ||
5646 | } | ||
5647 | } | ||
5648 | }; | ||
5649 | var $elm$core$Dict$moveRedLeft = function (dict) { | ||
5650 | if (((dict.$ === 'RBNode_elm_builtin') && (dict.d.$ === 'RBNode_elm_builtin')) && (dict.e.$ === 'RBNode_elm_builtin')) { | ||
5651 | if ((dict.e.d.$ === 'RBNode_elm_builtin') && (dict.e.d.a.$ === 'Red')) { | ||
5652 | var clr = dict.a; | ||
5653 | var k = dict.b; | ||
5654 | var v = dict.c; | ||
5655 | var _v1 = dict.d; | ||
5656 | var lClr = _v1.a; | ||
5657 | var lK = _v1.b; | ||
5658 | var lV = _v1.c; | ||
5659 | var lLeft = _v1.d; | ||
5660 | var lRight = _v1.e; | ||
5661 | var _v2 = dict.e; | ||
5662 | var rClr = _v2.a; | ||
5663 | var rK = _v2.b; | ||
5664 | var rV = _v2.c; | ||
5665 | var rLeft = _v2.d; | ||
5666 | var _v3 = rLeft.a; | ||
5667 | var rlK = rLeft.b; | ||
5668 | var rlV = rLeft.c; | ||
5669 | var rlL = rLeft.d; | ||
5670 | var rlR = rLeft.e; | ||
5671 | var rRight = _v2.e; | ||
5672 | return A5( | ||
5673 | $elm$core$Dict$RBNode_elm_builtin, | ||
5674 | $elm$core$Dict$Red, | ||
5675 | rlK, | ||
5676 | rlV, | ||
5677 | A5( | ||
5678 | $elm$core$Dict$RBNode_elm_builtin, | ||
5679 | $elm$core$Dict$Black, | ||
5680 | k, | ||
5681 | v, | ||
5682 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Red, lK, lV, lLeft, lRight), | ||
5683 | rlL), | ||
5684 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Black, rK, rV, rlR, rRight)); | ||
5685 | } else { | ||
5686 | var clr = dict.a; | ||
5687 | var k = dict.b; | ||
5688 | var v = dict.c; | ||
5689 | var _v4 = dict.d; | ||
5690 | var lClr = _v4.a; | ||
5691 | var lK = _v4.b; | ||
5692 | var lV = _v4.c; | ||
5693 | var lLeft = _v4.d; | ||
5694 | var lRight = _v4.e; | ||
5695 | var _v5 = dict.e; | ||
5696 | var rClr = _v5.a; | ||
5697 | var rK = _v5.b; | ||
5698 | var rV = _v5.c; | ||
5699 | var rLeft = _v5.d; | ||
5700 | var rRight = _v5.e; | ||
5701 | if (clr.$ === 'Black') { | ||
5702 | return A5( | ||
5703 | $elm$core$Dict$RBNode_elm_builtin, | ||
5704 | $elm$core$Dict$Black, | ||
5705 | k, | ||
5706 | v, | ||
5707 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Red, lK, lV, lLeft, lRight), | ||
5708 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Red, rK, rV, rLeft, rRight)); | ||
5709 | } else { | ||
5710 | return A5( | ||
5711 | $elm$core$Dict$RBNode_elm_builtin, | ||
5712 | $elm$core$Dict$Black, | ||
5713 | k, | ||
5714 | v, | ||
5715 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Red, lK, lV, lLeft, lRight), | ||
5716 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Red, rK, rV, rLeft, rRight)); | ||
5717 | } | ||
5718 | } | ||
5719 | } else { | ||
5720 | return dict; | ||
5721 | } | ||
5722 | }; | ||
5723 | var $elm$core$Dict$moveRedRight = function (dict) { | ||
5724 | if (((dict.$ === 'RBNode_elm_builtin') && (dict.d.$ === 'RBNode_elm_builtin')) && (dict.e.$ === 'RBNode_elm_builtin')) { | ||
5725 | if ((dict.d.d.$ === 'RBNode_elm_builtin') && (dict.d.d.a.$ === 'Red')) { | ||
5726 | var clr = dict.a; | ||
5727 | var k = dict.b; | ||
5728 | var v = dict.c; | ||
5729 | var _v1 = dict.d; | ||
5730 | var lClr = _v1.a; | ||
5731 | var lK = _v1.b; | ||
5732 | var lV = _v1.c; | ||
5733 | var _v2 = _v1.d; | ||
5734 | var _v3 = _v2.a; | ||
5735 | var llK = _v2.b; | ||
5736 | var llV = _v2.c; | ||
5737 | var llLeft = _v2.d; | ||
5738 | var llRight = _v2.e; | ||
5739 | var lRight = _v1.e; | ||
5740 | var _v4 = dict.e; | ||
5741 | var rClr = _v4.a; | ||
5742 | var rK = _v4.b; | ||
5743 | var rV = _v4.c; | ||
5744 | var rLeft = _v4.d; | ||
5745 | var rRight = _v4.e; | ||
5746 | return A5( | ||
5747 | $elm$core$Dict$RBNode_elm_builtin, | ||
5748 | $elm$core$Dict$Red, | ||
5749 | lK, | ||
5750 | lV, | ||
5751 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Black, llK, llV, llLeft, llRight), | ||
5752 | A5( | ||
5753 | $elm$core$Dict$RBNode_elm_builtin, | ||
5754 | $elm$core$Dict$Black, | ||
5755 | k, | ||
5756 | v, | ||
5757 | lRight, | ||
5758 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Red, rK, rV, rLeft, rRight))); | ||
5759 | } else { | ||
5760 | var clr = dict.a; | ||
5761 | var k = dict.b; | ||
5762 | var v = dict.c; | ||
5763 | var _v5 = dict.d; | ||
5764 | var lClr = _v5.a; | ||
5765 | var lK = _v5.b; | ||
5766 | var lV = _v5.c; | ||
5767 | var lLeft = _v5.d; | ||
5768 | var lRight = _v5.e; | ||
5769 | var _v6 = dict.e; | ||
5770 | var rClr = _v6.a; | ||
5771 | var rK = _v6.b; | ||
5772 | var rV = _v6.c; | ||
5773 | var rLeft = _v6.d; | ||
5774 | var rRight = _v6.e; | ||
5775 | if (clr.$ === 'Black') { | ||
5776 | return A5( | ||
5777 | $elm$core$Dict$RBNode_elm_builtin, | ||
5778 | $elm$core$Dict$Black, | ||
5779 | k, | ||
5780 | v, | ||
5781 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Red, lK, lV, lLeft, lRight), | ||
5782 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Red, rK, rV, rLeft, rRight)); | ||
5783 | } else { | ||
5784 | return A5( | ||
5785 | $elm$core$Dict$RBNode_elm_builtin, | ||
5786 | $elm$core$Dict$Black, | ||
5787 | k, | ||
5788 | v, | ||
5789 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Red, lK, lV, lLeft, lRight), | ||
5790 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Red, rK, rV, rLeft, rRight)); | ||
5791 | } | ||
5792 | } | ||
5793 | } else { | ||
5794 | return dict; | ||
5795 | } | ||
5796 | }; | ||
5797 | var $elm$core$Dict$removeHelpPrepEQGT = F7( | ||
5798 | function (targetKey, dict, color, key, value, left, right) { | ||
5799 | if ((left.$ === 'RBNode_elm_builtin') && (left.a.$ === 'Red')) { | ||
5800 | var _v1 = left.a; | ||
5801 | var lK = left.b; | ||
5802 | var lV = left.c; | ||
5803 | var lLeft = left.d; | ||
5804 | var lRight = left.e; | ||
5805 | return A5( | ||
5806 | $elm$core$Dict$RBNode_elm_builtin, | ||
5807 | color, | ||
5808 | lK, | ||
5809 | lV, | ||
5810 | lLeft, | ||
5811 | A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Red, key, value, lRight, right)); | ||
5812 | } else { | ||
5813 | _v2$2: | ||
5814 | while (true) { | ||
5815 | if ((right.$ === 'RBNode_elm_builtin') && (right.a.$ === 'Black')) { | ||
5816 | if (right.d.$ === 'RBNode_elm_builtin') { | ||
5817 | if (right.d.a.$ === 'Black') { | ||
5818 | var _v3 = right.a; | ||
5819 | var _v4 = right.d; | ||
5820 | var _v5 = _v4.a; | ||
5821 | return $elm$core$Dict$moveRedRight(dict); | ||
5822 | } else { | ||
5823 | break _v2$2; | ||
5824 | } | ||
5825 | } else { | ||
5826 | var _v6 = right.a; | ||
5827 | var _v7 = right.d; | ||
5828 | return $elm$core$Dict$moveRedRight(dict); | ||
5829 | } | ||
5830 | } else { | ||
5831 | break _v2$2; | ||
5832 | } | ||
5833 | } | ||
5834 | return dict; | ||
5835 | } | ||
5836 | }); | ||
5837 | var $elm$core$Dict$removeMin = function (dict) { | ||
5838 | if ((dict.$ === 'RBNode_elm_builtin') && (dict.d.$ === 'RBNode_elm_builtin')) { | ||
5839 | var color = dict.a; | ||
5840 | var key = dict.b; | ||
5841 | var value = dict.c; | ||
5842 | var left = dict.d; | ||
5843 | var lColor = left.a; | ||
5844 | var lLeft = left.d; | ||
5845 | var right = dict.e; | ||
5846 | if (lColor.$ === 'Black') { | ||
5847 | if ((lLeft.$ === 'RBNode_elm_builtin') && (lLeft.a.$ === 'Red')) { | ||
5848 | var _v3 = lLeft.a; | ||
5849 | return A5( | ||
5850 | $elm$core$Dict$RBNode_elm_builtin, | ||
5851 | color, | ||
5852 | key, | ||
5853 | value, | ||
5854 | $elm$core$Dict$removeMin(left), | ||
5855 | right); | ||
5856 | } else { | ||
5857 | var _v4 = $elm$core$Dict$moveRedLeft(dict); | ||
5858 | if (_v4.$ === 'RBNode_elm_builtin') { | ||
5859 | var nColor = _v4.a; | ||
5860 | var nKey = _v4.b; | ||
5861 | var nValue = _v4.c; | ||
5862 | var nLeft = _v4.d; | ||
5863 | var nRight = _v4.e; | ||
5864 | return A5( | ||
5865 | $elm$core$Dict$balance, | ||
5866 | nColor, | ||
5867 | nKey, | ||
5868 | nValue, | ||
5869 | $elm$core$Dict$removeMin(nLeft), | ||
5870 | nRight); | ||
5871 | } else { | ||
5872 | return $elm$core$Dict$RBEmpty_elm_builtin; | ||
5873 | } | ||
5874 | } | ||
5875 | } else { | ||
5876 | return A5( | ||
5877 | $elm$core$Dict$RBNode_elm_builtin, | ||
5878 | color, | ||
5879 | key, | ||
5880 | value, | ||
5881 | $elm$core$Dict$removeMin(left), | ||
5882 | right); | ||
5883 | } | ||
5884 | } else { | ||
5885 | return $elm$core$Dict$RBEmpty_elm_builtin; | ||
5886 | } | ||
5887 | }; | ||
5888 | var $elm$core$Dict$removeHelp = F2( | ||
5889 | function (targetKey, dict) { | ||
5890 | if (dict.$ === 'RBEmpty_elm_builtin') { | ||
5891 | return $elm$core$Dict$RBEmpty_elm_builtin; | ||
5892 | } else { | ||
5893 | var color = dict.a; | ||
5894 | var key = dict.b; | ||
5895 | var value = dict.c; | ||
5896 | var left = dict.d; | ||
5897 | var right = dict.e; | ||
5898 | if (_Utils_cmp(targetKey, key) < 0) { | ||
5899 | if ((left.$ === 'RBNode_elm_builtin') && (left.a.$ === 'Black')) { | ||
5900 | var _v4 = left.a; | ||
5901 | var lLeft = left.d; | ||
5902 | if ((lLeft.$ === 'RBNode_elm_builtin') && (lLeft.a.$ === 'Red')) { | ||
5903 | var _v6 = lLeft.a; | ||
5904 | return A5( | ||
5905 | $elm$core$Dict$RBNode_elm_builtin, | ||
5906 | color, | ||
5907 | key, | ||
5908 | value, | ||
5909 | A2($elm$core$Dict$removeHelp, targetKey, left), | ||
5910 | right); | ||
5911 | } else { | ||
5912 | var _v7 = $elm$core$Dict$moveRedLeft(dict); | ||
5913 | if (_v7.$ === 'RBNode_elm_builtin') { | ||
5914 | var nColor = _v7.a; | ||
5915 | var nKey = _v7.b; | ||
5916 | var nValue = _v7.c; | ||
5917 | var nLeft = _v7.d; | ||
5918 | var nRight = _v7.e; | ||
5919 | return A5( | ||
5920 | $elm$core$Dict$balance, | ||
5921 | nColor, | ||
5922 | nKey, | ||
5923 | nValue, | ||
5924 | A2($elm$core$Dict$removeHelp, targetKey, nLeft), | ||
5925 | nRight); | ||
5926 | } else { | ||
5927 | return $elm$core$Dict$RBEmpty_elm_builtin; | ||
5928 | } | ||
5929 | } | ||
5930 | } else { | ||
5931 | return A5( | ||
5932 | $elm$core$Dict$RBNode_elm_builtin, | ||
5933 | color, | ||
5934 | key, | ||
5935 | value, | ||
5936 | A2($elm$core$Dict$removeHelp, targetKey, left), | ||
5937 | right); | ||
5938 | } | ||
5939 | } else { | ||
5940 | return A2( | ||
5941 | $elm$core$Dict$removeHelpEQGT, | ||
5942 | targetKey, | ||
5943 | A7($elm$core$Dict$removeHelpPrepEQGT, targetKey, dict, color, key, value, left, right)); | ||
5944 | } | ||
5945 | } | ||
5946 | }); | ||
5947 | var $elm$core$Dict$removeHelpEQGT = F2( | ||
5948 | function (targetKey, dict) { | ||
5949 | if (dict.$ === 'RBNode_elm_builtin') { | ||
5950 | var color = dict.a; | ||
5951 | var key = dict.b; | ||
5952 | var value = dict.c; | ||
5953 | var left = dict.d; | ||
5954 | var right = dict.e; | ||
5955 | if (_Utils_eq(targetKey, key)) { | ||
5956 | var _v1 = $elm$core$Dict$getMin(right); | ||
5957 | if (_v1.$ === 'RBNode_elm_builtin') { | ||
5958 | var minKey = _v1.b; | ||
5959 | var minValue = _v1.c; | ||
5960 | return A5( | ||
5961 | $elm$core$Dict$balance, | ||
5962 | color, | ||
5963 | minKey, | ||
5964 | minValue, | ||
5965 | left, | ||
5966 | $elm$core$Dict$removeMin(right)); | ||
5967 | } else { | ||
5968 | return $elm$core$Dict$RBEmpty_elm_builtin; | ||
5969 | } | ||
5970 | } else { | ||
5971 | return A5( | ||
5972 | $elm$core$Dict$balance, | ||
5973 | color, | ||
5974 | key, | ||
5975 | value, | ||
5976 | left, | ||
5977 | A2($elm$core$Dict$removeHelp, targetKey, right)); | ||
5978 | } | ||
5979 | } else { | ||
5980 | return $elm$core$Dict$RBEmpty_elm_builtin; | ||
5981 | } | ||
5982 | }); | ||
5983 | var $elm$core$Dict$remove = F2( | ||
5984 | function (key, dict) { | ||
5985 | var _v0 = A2($elm$core$Dict$removeHelp, key, dict); | ||
5986 | if ((_v0.$ === 'RBNode_elm_builtin') && (_v0.a.$ === 'Red')) { | ||
5987 | var _v1 = _v0.a; | ||
5988 | var k = _v0.b; | ||
5989 | var v = _v0.c; | ||
5990 | var l = _v0.d; | ||
5991 | var r = _v0.e; | ||
5992 | return A5($elm$core$Dict$RBNode_elm_builtin, $elm$core$Dict$Black, k, v, l, r); | ||
5993 | } else { | ||
5994 | var x = _v0; | ||
5995 | return x; | ||
5996 | } | ||
5997 | }); | ||
5998 | var $elm$core$Dict$update = F3( | ||
5999 | function (targetKey, alter, dictionary) { | ||
6000 | var _v0 = alter( | ||
6001 | A2($elm$core$Dict$get, targetKey, dictionary)); | ||
6002 | if (_v0.$ === 'Just') { | ||
6003 | var value = _v0.a; | ||
6004 | return A3($elm$core$Dict$insert, targetKey, value, dictionary); | ||
6005 | } else { | ||
6006 | return A2($elm$core$Dict$remove, targetKey, dictionary); | ||
6007 | } | ||
6008 | }); | ||
6009 | var $elm$http$Http$emptyBody = _Http_emptyBody; | ||
6010 | var $elm$json$Json$Decode$decodeString = _Json_runOnString; | ||
6011 | var $elm$core$Basics$composeR = F3( | ||
6012 | function (f, g, x) { | ||
6013 | return g( | ||
6014 | f(x)); | ||
6015 | }); | ||
6016 | var $elm$http$Http$expectStringResponse = F2( | ||
6017 | function (toMsg, toResult) { | ||
6018 | return A3( | ||
6019 | _Http_expect, | ||
6020 | '', | ||
6021 | $elm$core$Basics$identity, | ||
6022 | A2($elm$core$Basics$composeR, toResult, toMsg)); | ||
6023 | }); | ||
6024 | var $elm$core$Result$mapError = F2( | ||
6025 | function (f, result) { | ||
6026 | if (result.$ === 'Ok') { | ||
6027 | var v = result.a; | ||
6028 | return $elm$core$Result$Ok(v); | ||
6029 | } else { | ||
6030 | var e = result.a; | ||
6031 | return $elm$core$Result$Err( | ||
6032 | f(e)); | ||
6033 | } | ||
6034 | }); | ||
6035 | var $elm$http$Http$BadBody = function (a) { | ||
6036 | return {$: 'BadBody', a: a}; | ||
6037 | }; | ||
6038 | var $elm$http$Http$BadStatus = function (a) { | ||
6039 | return {$: 'BadStatus', a: a}; | ||
6040 | }; | ||
6041 | var $elm$http$Http$BadUrl = function (a) { | ||
6042 | return {$: 'BadUrl', a: a}; | ||
6043 | }; | ||
6044 | var $elm$http$Http$NetworkError = {$: 'NetworkError'}; | ||
6045 | var $elm$http$Http$Timeout = {$: 'Timeout'}; | ||
6046 | var $elm$http$Http$resolve = F2( | ||
6047 | function (toResult, response) { | ||
6048 | switch (response.$) { | ||
6049 | case 'BadUrl_': | ||
6050 | var url = response.a; | ||
6051 | return $elm$core$Result$Err( | ||
6052 | $elm$http$Http$BadUrl(url)); | ||
6053 | case 'Timeout_': | ||
6054 | return $elm$core$Result$Err($elm$http$Http$Timeout); | ||
6055 | case 'NetworkError_': | ||
6056 | return $elm$core$Result$Err($elm$http$Http$NetworkError); | ||
6057 | case 'BadStatus_': | ||
6058 | var metadata = response.a; | ||
6059 | return $elm$core$Result$Err( | ||
6060 | $elm$http$Http$BadStatus(metadata.statusCode)); | ||
6061 | default: | ||
6062 | var body = response.b; | ||
6063 | return A2( | ||
6064 | $elm$core$Result$mapError, | ||
6065 | $elm$http$Http$BadBody, | ||
6066 | toResult(body)); | ||
6067 | } | ||
6068 | }); | ||
6069 | var $elm$http$Http$expectJson = F2( | ||
6070 | function (toMsg, decoder) { | ||
6071 | return A2( | ||
6072 | $elm$http$Http$expectStringResponse, | ||
6073 | toMsg, | ||
6074 | $elm$http$Http$resolve( | ||
6075 | function (string) { | ||
6076 | return A2( | ||
6077 | $elm$core$Result$mapError, | ||
6078 | $elm$json$Json$Decode$errorToString, | ||
6079 | A2($elm$json$Json$Decode$decodeString, decoder, string)); | ||
6080 | })); | ||
6081 | }); | ||
6082 | var $elm$core$Debug$log = _Debug_log; | ||
6083 | var $elm$http$Http$Request = function (a) { | ||
6084 | return {$: 'Request', a: a}; | ||
6085 | }; | ||
6086 | var $elm$http$Http$State = F2( | ||
6087 | function (reqs, subs) { | ||
6088 | return {reqs: reqs, subs: subs}; | ||
6089 | }); | ||
6090 | var $elm$http$Http$init = $elm$core$Task$succeed( | ||
6091 | A2($elm$http$Http$State, $elm$core$Dict$empty, _List_Nil)); | ||
6092 | var $elm$core$Process$kill = _Scheduler_kill; | ||
6093 | var $elm$core$Process$spawn = _Scheduler_spawn; | ||
6094 | var $elm$http$Http$updateReqs = F3( | ||
6095 | function (router, cmds, reqs) { | ||
6096 | updateReqs: | ||
6097 | while (true) { | ||
6098 | if (!cmds.b) { | ||
6099 | return $elm$core$Task$succeed(reqs); | ||
6100 | } else { | ||
6101 | var cmd = cmds.a; | ||
6102 | var otherCmds = cmds.b; | ||
6103 | if (cmd.$ === 'Cancel') { | ||
6104 | var tracker = cmd.a; | ||
6105 | var _v2 = A2($elm$core$Dict$get, tracker, reqs); | ||
6106 | if (_v2.$ === 'Nothing') { | ||
6107 | var $temp$router = router, | ||
6108 | $temp$cmds = otherCmds, | ||
6109 | $temp$reqs = reqs; | ||
6110 | router = $temp$router; | ||
6111 | cmds = $temp$cmds; | ||
6112 | reqs = $temp$reqs; | ||
6113 | continue updateReqs; | ||
6114 | } else { | ||
6115 | var pid = _v2.a; | ||
6116 | return A2( | ||
6117 | $elm$core$Task$andThen, | ||
6118 | function (_v3) { | ||
6119 | return A3( | ||
6120 | $elm$http$Http$updateReqs, | ||
6121 | router, | ||
6122 | otherCmds, | ||
6123 | A2($elm$core$Dict$remove, tracker, reqs)); | ||
6124 | }, | ||
6125 | $elm$core$Process$kill(pid)); | ||
6126 | } | ||
6127 | } else { | ||
6128 | var req = cmd.a; | ||
6129 | return A2( | ||
6130 | $elm$core$Task$andThen, | ||
6131 | function (pid) { | ||
6132 | var _v4 = req.tracker; | ||
6133 | if (_v4.$ === 'Nothing') { | ||
6134 | return A3($elm$http$Http$updateReqs, router, otherCmds, reqs); | ||
6135 | } else { | ||
6136 | var tracker = _v4.a; | ||
6137 | return A3( | ||
6138 | $elm$http$Http$updateReqs, | ||
6139 | router, | ||
6140 | otherCmds, | ||
6141 | A3($elm$core$Dict$insert, tracker, pid, reqs)); | ||
6142 | } | ||
6143 | }, | ||
6144 | $elm$core$Process$spawn( | ||
6145 | A3( | ||
6146 | _Http_toTask, | ||
6147 | router, | ||
6148 | $elm$core$Platform$sendToApp(router), | ||
6149 | req))); | ||
6150 | } | ||
6151 | } | ||
6152 | } | ||
6153 | }); | ||
6154 | var $elm$http$Http$onEffects = F4( | ||
6155 | function (router, cmds, subs, state) { | ||
6156 | return A2( | ||
6157 | $elm$core$Task$andThen, | ||
6158 | function (reqs) { | ||
6159 | return $elm$core$Task$succeed( | ||
6160 | A2($elm$http$Http$State, reqs, subs)); | ||
6161 | }, | ||
6162 | A3($elm$http$Http$updateReqs, router, cmds, state.reqs)); | ||
6163 | }); | ||
6164 | var $elm$core$List$maybeCons = F3( | ||
6165 | function (f, mx, xs) { | ||
6166 | var _v0 = f(mx); | ||
6167 | if (_v0.$ === 'Just') { | ||
6168 | var x = _v0.a; | ||
6169 | return A2($elm$core$List$cons, x, xs); | ||
6170 | } else { | ||
6171 | return xs; | ||
6172 | } | ||
6173 | }); | ||
6174 | var $elm$core$List$filterMap = F2( | ||
6175 | function (f, xs) { | ||
6176 | return A3( | ||
6177 | $elm$core$List$foldr, | ||
6178 | $elm$core$List$maybeCons(f), | ||
6179 | _List_Nil, | ||
6180 | xs); | ||
6181 | }); | ||
6182 | var $elm$http$Http$maybeSend = F4( | ||
6183 | function (router, desiredTracker, progress, _v0) { | ||
6184 | var actualTracker = _v0.a; | ||
6185 | var toMsg = _v0.b; | ||
6186 | return _Utils_eq(desiredTracker, actualTracker) ? $elm$core$Maybe$Just( | ||
6187 | A2( | ||
6188 | $elm$core$Platform$sendToApp, | ||
6189 | router, | ||
6190 | toMsg(progress))) : $elm$core$Maybe$Nothing; | ||
6191 | }); | ||
6192 | var $elm$http$Http$onSelfMsg = F3( | ||
6193 | function (router, _v0, state) { | ||
6194 | var tracker = _v0.a; | ||
6195 | var progress = _v0.b; | ||
6196 | return A2( | ||
6197 | $elm$core$Task$andThen, | ||
6198 | function (_v1) { | ||
6199 | return $elm$core$Task$succeed(state); | ||
6200 | }, | ||
6201 | $elm$core$Task$sequence( | ||
6202 | A2( | ||
6203 | $elm$core$List$filterMap, | ||
6204 | A3($elm$http$Http$maybeSend, router, tracker, progress), | ||
6205 | state.subs))); | ||
6206 | }); | ||
6207 | var $elm$http$Http$Cancel = function (a) { | ||
6208 | return {$: 'Cancel', a: a}; | ||
6209 | }; | ||
6210 | var $elm$http$Http$cmdMap = F2( | ||
6211 | function (func, cmd) { | ||
6212 | if (cmd.$ === 'Cancel') { | ||
6213 | var tracker = cmd.a; | ||
6214 | return $elm$http$Http$Cancel(tracker); | ||
6215 | } else { | ||
6216 | var r = cmd.a; | ||
6217 | return $elm$http$Http$Request( | ||
6218 | { | ||
6219 | allowCookiesFromOtherDomains: r.allowCookiesFromOtherDomains, | ||
6220 | body: r.body, | ||
6221 | expect: A2(_Http_mapExpect, func, r.expect), | ||
6222 | headers: r.headers, | ||
6223 | method: r.method, | ||
6224 | timeout: r.timeout, | ||
6225 | tracker: r.tracker, | ||
6226 | url: r.url | ||
6227 | }); | ||
6228 | } | ||
6229 | }); | ||
6230 | var $elm$http$Http$MySub = F2( | ||
6231 | function (a, b) { | ||
6232 | return {$: 'MySub', a: a, b: b}; | ||
6233 | }); | ||
6234 | var $elm$http$Http$subMap = F2( | ||
6235 | function (func, _v0) { | ||
6236 | var tracker = _v0.a; | ||
6237 | var toMsg = _v0.b; | ||
6238 | return A2( | ||
6239 | $elm$http$Http$MySub, | ||
6240 | tracker, | ||
6241 | A2($elm$core$Basics$composeR, toMsg, func)); | ||
6242 | }); | ||
6243 | _Platform_effectManagers['Http'] = _Platform_createManager($elm$http$Http$init, $elm$http$Http$onEffects, $elm$http$Http$onSelfMsg, $elm$http$Http$cmdMap, $elm$http$Http$subMap); | ||
6244 | var $elm$http$Http$command = _Platform_leaf('Http'); | ||
6245 | var $elm$http$Http$subscription = _Platform_leaf('Http'); | ||
6246 | var $elm$http$Http$riskyRequest = function (r) { | ||
6247 | return $elm$http$Http$command( | ||
6248 | $elm$http$Http$Request( | ||
6249 | {allowCookiesFromOtherDomains: true, body: r.body, expect: r.expect, headers: r.headers, method: r.method, timeout: r.timeout, tracker: r.tracker, url: r.url})); | ||
6250 | }; | ||
6251 | var $author$project$Cart$fetchCartItems = function () { | ||
6252 | var _v0 = A2($elm$core$Debug$log, 'cart', 'fetching cart items'); | ||
6253 | return $elm$http$Http$riskyRequest( | ||
6254 | { | ||
6255 | body: $elm$http$Http$emptyBody, | ||
6256 | expect: A2($elm$http$Http$expectJson, $author$project$Cart$CartLoaded, $author$project$Cart$decodeResponse), | ||
6257 | headers: _List_Nil, | ||
6258 | method: 'GET', | ||
6259 | timeout: $elm$core$Maybe$Nothing, | ||
6260 | tracker: $elm$core$Maybe$Nothing, | ||
6261 | url: 'http://127.0.0.1:7878/cart/items' | ||
6262 | }); | ||
6263 | }(); | ||
6264 | var $author$project$Product$ListingLoaded = function (a) { | ||
6265 | return {$: 'ListingLoaded', a: a}; | ||
6266 | }; | ||
6267 | var $author$project$Product$decodeProduct = A6( | ||
6268 | $elm$json$Json$Decode$map5, | ||
6269 | $author$project$Product$Product, | ||
6270 | A2($elm$json$Json$Decode$field, 'id', $elm$json$Json$Decode$int), | ||
6271 | A2($elm$json$Json$Decode$field, 'name', $elm$json$Json$Decode$string), | ||
6272 | A2( | ||
6273 | $elm$json$Json$Decode$field, | ||
6274 | 'kind', | ||
6275 | $elm$json$Json$Decode$nullable($elm$json$Json$Decode$string)), | ||
6276 | A2($elm$json$Json$Decode$field, 'price', $elm$json$Json$Decode$float), | ||
6277 | A2( | ||
6278 | $elm$json$Json$Decode$field, | ||
6279 | 'description', | ||
6280 | $elm$json$Json$Decode$nullable($elm$json$Json$Decode$string))); | ||
6281 | var $elm$http$Http$request = function (r) { | ||
6282 | return $elm$http$Http$command( | ||
6283 | $elm$http$Http$Request( | ||
6284 | {allowCookiesFromOtherDomains: false, body: r.body, expect: r.expect, headers: r.headers, method: r.method, timeout: r.timeout, tracker: r.tracker, url: r.url})); | ||
6285 | }; | ||
6286 | var $elm$http$Http$get = function (r) { | ||
6287 | return $elm$http$Http$request( | ||
6288 | {body: $elm$http$Http$emptyBody, expect: r.expect, headers: _List_Nil, method: 'GET', timeout: $elm$core$Maybe$Nothing, tracker: $elm$core$Maybe$Nothing, url: r.url}); | ||
6289 | }; | ||
6290 | var $author$project$Product$fetchListing = function (id) { | ||
6291 | var _v0 = A2( | ||
6292 | $elm$core$Debug$log, | ||
6293 | 'err', | ||
6294 | 'fetching listing ' + $elm$core$String$fromInt(id)); | ||
6295 | return $elm$http$Http$get( | ||
6296 | { | ||
6297 | expect: A2($elm$http$Http$expectJson, $author$project$Product$ListingLoaded, $author$project$Product$decodeProduct), | ||
6298 | url: 'http://127.0.0.1:7878/product/' + $elm$core$String$fromInt(id) | ||
6299 | }); | ||
6300 | }; | ||
6301 | var $author$project$Catalog$ProductsLoaded = function (a) { | ||
6302 | return {$: 'ProductsLoaded', a: a}; | ||
6303 | }; | ||
6304 | var $author$project$Catalog$Product = F5( | ||
6305 | function (id, name, kind, price, description) { | ||
6306 | return {description: description, id: id, kind: kind, name: name, price: price}; | ||
6307 | }); | ||
6308 | var $author$project$Catalog$decodeProduct = A6( | ||
6309 | $elm$json$Json$Decode$map5, | ||
6310 | $author$project$Catalog$Product, | ||
6311 | A2($elm$json$Json$Decode$field, 'id', $elm$json$Json$Decode$int), | ||
6312 | A2($elm$json$Json$Decode$field, 'name', $elm$json$Json$Decode$string), | ||
6313 | A2( | ||
6314 | $elm$json$Json$Decode$field, | ||
6315 | 'kind', | ||
6316 | $elm$json$Json$Decode$nullable($elm$json$Json$Decode$string)), | ||
6317 | A2($elm$json$Json$Decode$field, 'price', $elm$json$Json$Decode$float), | ||
6318 | A2( | ||
6319 | $elm$json$Json$Decode$field, | ||
6320 | 'description', | ||
6321 | $elm$json$Json$Decode$nullable($elm$json$Json$Decode$string))); | ||
6322 | var $author$project$Catalog$decodeResponse = $elm$json$Json$Decode$list($author$project$Catalog$decodeProduct); | ||
6323 | var $author$project$Catalog$fetchProducts = function () { | ||
6324 | var _v0 = A2($elm$core$Debug$log, 'err', 'fetching products'); | ||
6325 | return $elm$http$Http$get( | ||
6326 | { | ||
6327 | expect: A2($elm$http$Http$expectJson, $author$project$Catalog$ProductsLoaded, $author$project$Catalog$decodeResponse), | ||
6328 | url: 'http://127.0.0.1:7878/product/catalog' | ||
6329 | }); | ||
6330 | }(); | ||
6331 | var $author$project$Product$RatingsLoaded = function (a) { | ||
6332 | return {$: 'RatingsLoaded', a: a}; | ||
6333 | }; | ||
6334 | var $author$project$Product$Rating = F5( | ||
6335 | function (commentDate, commentText, customerName, productName, stars) { | ||
6336 | return {commentDate: commentDate, commentText: commentText, customerName: customerName, productName: productName, stars: stars}; | ||
6337 | }); | ||
6338 | var $author$project$Product$decodeRating = A6( | ||
6339 | $elm$json$Json$Decode$map5, | ||
6340 | $author$project$Product$Rating, | ||
6341 | A2($elm$json$Json$Decode$field, 'comment_date', $elm$json$Json$Decode$string), | ||
6342 | A2( | ||
6343 | $elm$json$Json$Decode$field, | ||
6344 | 'comment_text', | ||
6345 | $elm$json$Json$Decode$nullable($elm$json$Json$Decode$string)), | ||
6346 | A2($elm$json$Json$Decode$field, 'customer_name', $elm$json$Json$Decode$string), | ||
6347 | A2($elm$json$Json$Decode$field, 'product_name', $elm$json$Json$Decode$string), | ||
6348 | A2($elm$json$Json$Decode$field, 'stars', $elm$json$Json$Decode$int)); | ||
6349 | var $author$project$Product$decodeRatings = $elm$json$Json$Decode$list($author$project$Product$decodeRating); | ||
6350 | var $author$project$Product$fetchRatings = function (id) { | ||
6351 | var _v0 = A2( | ||
6352 | $elm$core$Debug$log, | ||
6353 | 'err', | ||
6354 | 'fetching ratings ' + $elm$core$String$fromInt(id)); | ||
6355 | return $elm$http$Http$get( | ||
6356 | { | ||
6357 | expect: A2($elm$http$Http$expectJson, $author$project$Product$RatingsLoaded, $author$project$Product$decodeRatings), | ||
6358 | url: 'http://127.0.0.1:7878/product/reviews/' + $elm$core$String$fromInt(id) | ||
6359 | }); | ||
6360 | }; | ||
6361 | var $elm$browser$Browser$Navigation$load = _Browser_load; | ||
6362 | var $elm$core$Platform$Cmd$map = _Platform_map; | ||
6363 | var $elm$url$Url$Parser$State = F5( | ||
6364 | function (visited, unvisited, params, frag, value) { | ||
6365 | return {frag: frag, params: params, unvisited: unvisited, value: value, visited: visited}; | ||
6366 | }); | ||
6367 | var $elm$url$Url$Parser$getFirstMatch = function (states) { | ||
6368 | getFirstMatch: | ||
6369 | while (true) { | ||
6370 | if (!states.b) { | ||
6371 | return $elm$core$Maybe$Nothing; | ||
6372 | } else { | ||
6373 | var state = states.a; | ||
6374 | var rest = states.b; | ||
6375 | var _v1 = state.unvisited; | ||
6376 | if (!_v1.b) { | ||
6377 | return $elm$core$Maybe$Just(state.value); | ||
6378 | } else { | ||
6379 | if ((_v1.a === '') && (!_v1.b.b)) { | ||
6380 | return $elm$core$Maybe$Just(state.value); | ||
6381 | } else { | ||
6382 | var $temp$states = rest; | ||
6383 | states = $temp$states; | ||
6384 | continue getFirstMatch; | ||
6385 | } | ||
6386 | } | ||
6387 | } | ||
6388 | } | ||
6389 | }; | ||
6390 | var $elm$url$Url$Parser$removeFinalEmpty = function (segments) { | ||
6391 | if (!segments.b) { | ||
6392 | return _List_Nil; | ||
6393 | } else { | ||
6394 | if ((segments.a === '') && (!segments.b.b)) { | ||
6395 | return _List_Nil; | ||
6396 | } else { | ||
6397 | var segment = segments.a; | ||
6398 | var rest = segments.b; | ||
6399 | return A2( | ||
6400 | $elm$core$List$cons, | ||
6401 | segment, | ||
6402 | $elm$url$Url$Parser$removeFinalEmpty(rest)); | ||
6403 | } | ||
6404 | } | ||
6405 | }; | ||
6406 | var $elm$url$Url$Parser$preparePath = function (path) { | ||
6407 | var _v0 = A2($elm$core$String$split, '/', path); | ||
6408 | if (_v0.b && (_v0.a === '')) { | ||
6409 | var segments = _v0.b; | ||
6410 | return $elm$url$Url$Parser$removeFinalEmpty(segments); | ||
6411 | } else { | ||
6412 | var segments = _v0; | ||
6413 | return $elm$url$Url$Parser$removeFinalEmpty(segments); | ||
6414 | } | ||
6415 | }; | ||
6416 | var $elm$url$Url$Parser$addToParametersHelp = F2( | ||
6417 | function (value, maybeList) { | ||
6418 | if (maybeList.$ === 'Nothing') { | ||
6419 | return $elm$core$Maybe$Just( | ||
6420 | _List_fromArray( | ||
6421 | [value])); | ||
6422 | } else { | ||
6423 | var list = maybeList.a; | ||
6424 | return $elm$core$Maybe$Just( | ||
6425 | A2($elm$core$List$cons, value, list)); | ||
6426 | } | ||
6427 | }); | ||
6428 | var $elm$url$Url$percentDecode = _Url_percentDecode; | ||
6429 | var $elm$url$Url$Parser$addParam = F2( | ||
6430 | function (segment, dict) { | ||
6431 | var _v0 = A2($elm$core$String$split, '=', segment); | ||
6432 | if ((_v0.b && _v0.b.b) && (!_v0.b.b.b)) { | ||
6433 | var rawKey = _v0.a; | ||
6434 | var _v1 = _v0.b; | ||
6435 | var rawValue = _v1.a; | ||
6436 | var _v2 = $elm$url$Url$percentDecode(rawKey); | ||
6437 | if (_v2.$ === 'Nothing') { | ||
6438 | return dict; | ||
6439 | } else { | ||
6440 | var key = _v2.a; | ||
6441 | var _v3 = $elm$url$Url$percentDecode(rawValue); | ||
6442 | if (_v3.$ === 'Nothing') { | ||
6443 | return dict; | ||
6444 | } else { | ||
6445 | var value = _v3.a; | ||
6446 | return A3( | ||
6447 | $elm$core$Dict$update, | ||
6448 | key, | ||
6449 | $elm$url$Url$Parser$addToParametersHelp(value), | ||
6450 | dict); | ||
6451 | } | ||
6452 | } | ||
6453 | } else { | ||
6454 | return dict; | ||
6455 | } | ||
6456 | }); | ||
6457 | var $elm$url$Url$Parser$prepareQuery = function (maybeQuery) { | ||
6458 | if (maybeQuery.$ === 'Nothing') { | ||
6459 | return $elm$core$Dict$empty; | ||
6460 | } else { | ||
6461 | var qry = maybeQuery.a; | ||
6462 | return A3( | ||
6463 | $elm$core$List$foldr, | ||
6464 | $elm$url$Url$Parser$addParam, | ||
6465 | $elm$core$Dict$empty, | ||
6466 | A2($elm$core$String$split, '&', qry)); | ||
6467 | } | ||
6468 | }; | ||
6469 | var $elm$url$Url$Parser$parse = F2( | ||
6470 | function (_v0, url) { | ||
6471 | var parser = _v0.a; | ||
6472 | return $elm$url$Url$Parser$getFirstMatch( | ||
6473 | parser( | ||
6474 | A5( | ||
6475 | $elm$url$Url$Parser$State, | ||
6476 | _List_Nil, | ||
6477 | $elm$url$Url$Parser$preparePath(url.path), | ||
6478 | $elm$url$Url$Parser$prepareQuery(url.query), | ||
6479 | url.fragment, | ||
6480 | $elm$core$Basics$identity))); | ||
6481 | }); | ||
6482 | var $author$project$Main$LoginPage = {$: 'LoginPage'}; | ||
6483 | var $author$project$Main$SignupPage = {$: 'SignupPage'}; | ||
6484 | var $elm$url$Url$Parser$Parser = function (a) { | ||
6485 | return {$: 'Parser', a: a}; | ||
6486 | }; | ||
6487 | var $elm$url$Url$Parser$custom = F2( | ||
6488 | function (tipe, stringToSomething) { | ||
6489 | return $elm$url$Url$Parser$Parser( | ||
6490 | function (_v0) { | ||
6491 | var visited = _v0.visited; | ||
6492 | var unvisited = _v0.unvisited; | ||
6493 | var params = _v0.params; | ||
6494 | var frag = _v0.frag; | ||
6495 | var value = _v0.value; | ||
6496 | if (!unvisited.b) { | ||
6497 | return _List_Nil; | ||
6498 | } else { | ||
6499 | var next = unvisited.a; | ||
6500 | var rest = unvisited.b; | ||
6501 | var _v2 = stringToSomething(next); | ||
6502 | if (_v2.$ === 'Just') { | ||
6503 | var nextValue = _v2.a; | ||
6504 | return _List_fromArray( | ||
6505 | [ | ||
6506 | A5( | ||
6507 | $elm$url$Url$Parser$State, | ||
6508 | A2($elm$core$List$cons, next, visited), | ||
6509 | rest, | ||
6510 | params, | ||
6511 | frag, | ||
6512 | value(nextValue)) | ||
6513 | ]); | ||
6514 | } else { | ||
6515 | return _List_Nil; | ||
6516 | } | ||
6517 | } | ||
6518 | }); | ||
6519 | }); | ||
6520 | var $elm$url$Url$Parser$int = A2($elm$url$Url$Parser$custom, 'NUMBER', $elm$core$String$toInt); | ||
6521 | var $elm$url$Url$Parser$mapState = F2( | ||
6522 | function (func, _v0) { | ||
6523 | var visited = _v0.visited; | ||
6524 | var unvisited = _v0.unvisited; | ||
6525 | var params = _v0.params; | ||
6526 | var frag = _v0.frag; | ||
6527 | var value = _v0.value; | ||
6528 | return A5( | ||
6529 | $elm$url$Url$Parser$State, | ||
6530 | visited, | ||
6531 | unvisited, | ||
6532 | params, | ||
6533 | frag, | ||
6534 | func(value)); | ||
6535 | }); | ||
6536 | var $elm$url$Url$Parser$map = F2( | ||
6537 | function (subValue, _v0) { | ||
6538 | var parseArg = _v0.a; | ||
6539 | return $elm$url$Url$Parser$Parser( | ||
6540 | function (_v1) { | ||
6541 | var visited = _v1.visited; | ||
6542 | var unvisited = _v1.unvisited; | ||
6543 | var params = _v1.params; | ||
6544 | var frag = _v1.frag; | ||
6545 | var value = _v1.value; | ||
6546 | return A2( | ||
6547 | $elm$core$List$map, | ||
6548 | $elm$url$Url$Parser$mapState(value), | ||
6549 | parseArg( | ||
6550 | A5($elm$url$Url$Parser$State, visited, unvisited, params, frag, subValue))); | ||
6551 | }); | ||
6552 | }); | ||
6553 | var $elm$core$List$append = F2( | ||
6554 | function (xs, ys) { | ||
6555 | if (!ys.b) { | ||
6556 | return xs; | ||
6557 | } else { | ||
6558 | return A3($elm$core$List$foldr, $elm$core$List$cons, ys, xs); | ||
6559 | } | ||
6560 | }); | ||
6561 | var $elm$core$List$concat = function (lists) { | ||
6562 | return A3($elm$core$List$foldr, $elm$core$List$append, _List_Nil, lists); | ||
6563 | }; | ||
6564 | var $elm$core$List$concatMap = F2( | ||
6565 | function (f, list) { | ||
6566 | return $elm$core$List$concat( | ||
6567 | A2($elm$core$List$map, f, list)); | ||
6568 | }); | ||
6569 | var $elm$url$Url$Parser$oneOf = function (parsers) { | ||
6570 | return $elm$url$Url$Parser$Parser( | ||
6571 | function (state) { | ||
6572 | return A2( | ||
6573 | $elm$core$List$concatMap, | ||
6574 | function (_v0) { | ||
6575 | var parser = _v0.a; | ||
6576 | return parser(state); | ||
6577 | }, | ||
6578 | parsers); | ||
6579 | }); | ||
6580 | }; | ||
6581 | var $elm$url$Url$Parser$s = function (str) { | ||
6582 | return $elm$url$Url$Parser$Parser( | ||
6583 | function (_v0) { | ||
6584 | var visited = _v0.visited; | ||
6585 | var unvisited = _v0.unvisited; | ||
6586 | var params = _v0.params; | ||
6587 | var frag = _v0.frag; | ||
6588 | var value = _v0.value; | ||
6589 | if (!unvisited.b) { | ||
6590 | return _List_Nil; | ||
6591 | } else { | ||
6592 | var next = unvisited.a; | ||
6593 | var rest = unvisited.b; | ||
6594 | return _Utils_eq(next, str) ? _List_fromArray( | ||
6595 | [ | ||
6596 | A5( | ||
6597 | $elm$url$Url$Parser$State, | ||
6598 | A2($elm$core$List$cons, next, visited), | ||
6599 | rest, | ||
6600 | params, | ||
6601 | frag, | ||
6602 | value) | ||
6603 | ]) : _List_Nil; | ||
6604 | } | ||
6605 | }); | ||
6606 | }; | ||
6607 | var $elm$url$Url$Parser$slash = F2( | ||
6608 | function (_v0, _v1) { | ||
6609 | var parseBefore = _v0.a; | ||
6610 | var parseAfter = _v1.a; | ||
6611 | return $elm$url$Url$Parser$Parser( | ||
6612 | function (state) { | ||
6613 | return A2( | ||
6614 | $elm$core$List$concatMap, | ||
6615 | parseAfter, | ||
6616 | parseBefore(state)); | ||
6617 | }); | ||
6618 | }); | ||
6619 | var $elm$url$Url$Parser$top = $elm$url$Url$Parser$Parser( | ||
6620 | function (state) { | ||
6621 | return _List_fromArray( | ||
6622 | [state]); | ||
6623 | }); | ||
6624 | var $author$project$Main$parseRoute = $elm$url$Url$Parser$oneOf( | ||
6625 | _List_fromArray( | ||
6626 | [ | ||
6627 | A2( | ||
6628 | $elm$url$Url$Parser$map, | ||
6629 | $author$project$Main$LoginPage, | ||
6630 | $elm$url$Url$Parser$s('login')), | ||
6631 | A2($elm$url$Url$Parser$map, $author$project$Main$HomePage, $elm$url$Url$Parser$top), | ||
6632 | A2( | ||
6633 | $elm$url$Url$Parser$map, | ||
6634 | $author$project$Main$CatalogPage, | ||
6635 | $elm$url$Url$Parser$s('catalog')), | ||
6636 | A2( | ||
6637 | $elm$url$Url$Parser$map, | ||
6638 | $author$project$Main$CartPage, | ||
6639 | $elm$url$Url$Parser$s('cart')), | ||
6640 | A2( | ||
6641 | $elm$url$Url$Parser$map, | ||
6642 | $author$project$Main$SignupPage, | ||
6643 | $elm$url$Url$Parser$s('signup')), | ||
6644 | A2( | ||
6645 | $elm$url$Url$Parser$map, | ||
6646 | $author$project$Main$ProductPage, | ||
6647 | A2( | ||
6648 | $elm$url$Url$Parser$slash, | ||
6649 | $elm$url$Url$Parser$s('product'), | ||
6650 | $elm$url$Url$Parser$int)) | ||
6651 | ])); | ||
6652 | var $elm$browser$Browser$Navigation$pushUrl = _Browser_pushUrl; | ||
6653 | var $elm$browser$Browser$Navigation$replaceUrl = _Browser_replaceUrl; | ||
6654 | var $elm$url$Url$addPort = F2( | ||
6655 | function (maybePort, starter) { | ||
6656 | if (maybePort.$ === 'Nothing') { | ||
6657 | return starter; | ||
6658 | } else { | ||
6659 | var port_ = maybePort.a; | ||
6660 | return starter + (':' + $elm$core$String$fromInt(port_)); | ||
6661 | } | ||
6662 | }); | ||
6663 | var $elm$url$Url$addPrefixed = F3( | ||
6664 | function (prefix, maybeSegment, starter) { | ||
6665 | if (maybeSegment.$ === 'Nothing') { | ||
6666 | return starter; | ||
6667 | } else { | ||
6668 | var segment = maybeSegment.a; | ||
6669 | return _Utils_ap( | ||
6670 | starter, | ||
6671 | _Utils_ap(prefix, segment)); | ||
6672 | } | ||
6673 | }); | ||
6674 | var $elm$url$Url$toString = function (url) { | ||
6675 | var http = function () { | ||
6676 | var _v0 = url.protocol; | ||
6677 | if (_v0.$ === 'Http') { | ||
6678 | return 'http://'; | ||
6679 | } else { | ||
6680 | return 'https://'; | ||
6681 | } | ||
6682 | }(); | ||
6683 | return A3( | ||
6684 | $elm$url$Url$addPrefixed, | ||
6685 | '#', | ||
6686 | url.fragment, | ||
6687 | A3( | ||
6688 | $elm$url$Url$addPrefixed, | ||
6689 | '?', | ||
6690 | url.query, | ||
6691 | _Utils_ap( | ||
6692 | A2( | ||
6693 | $elm$url$Url$addPort, | ||
6694 | url.port_, | ||
6695 | _Utils_ap(http, url.host)), | ||
6696 | url.path))); | ||
6697 | }; | ||
6698 | var $author$project$Main$LogoutSuccess = function (a) { | ||
6699 | return {$: 'LogoutSuccess', a: a}; | ||
6700 | }; | ||
6701 | var $elm$http$Http$expectBytesResponse = F2( | ||
6702 | function (toMsg, toResult) { | ||
6703 | return A3( | ||
6704 | _Http_expect, | ||
6705 | 'arraybuffer', | ||
6706 | _Http_toDataView, | ||
6707 | A2($elm$core$Basics$composeR, toResult, toMsg)); | ||
6708 | }); | ||
6709 | var $elm$http$Http$expectWhatever = function (toMsg) { | ||
6710 | return A2( | ||
6711 | $elm$http$Http$expectBytesResponse, | ||
6712 | toMsg, | ||
6713 | $elm$http$Http$resolve( | ||
6714 | function (_v0) { | ||
6715 | return $elm$core$Result$Ok(_Utils_Tuple0); | ||
6716 | })); | ||
6717 | }; | ||
6718 | var $author$project$Main$tryLogout = $elm$http$Http$riskyRequest( | ||
6719 | { | ||
6720 | body: $elm$http$Http$emptyBody, | ||
6721 | expect: $elm$http$Http$expectWhatever($author$project$Main$LogoutSuccess), | ||
6722 | headers: _List_Nil, | ||
6723 | method: 'POST', | ||
6724 | timeout: $elm$core$Maybe$Nothing, | ||
6725 | tracker: $elm$core$Maybe$Nothing, | ||
6726 | url: 'http://127.0.0.1:7878/user/logout' | ||
6727 | }); | ||
6728 | var $author$project$Cart$Loaded = {$: 'Loaded'}; | ||
6729 | var $author$project$Cart$Loading = {$: 'Loading'}; | ||
6730 | var $author$project$Cart$CartItemRemoved = function (a) { | ||
6731 | return {$: 'CartItemRemoved', a: a}; | ||
6732 | }; | ||
6733 | var $elm$http$Http$stringBody = _Http_pair; | ||
6734 | var $author$project$Cart$removeProduct = function (id) { | ||
6735 | var _v0 = A2($elm$core$Debug$log, 'cart', 'fetching cart items'); | ||
6736 | return $elm$http$Http$riskyRequest( | ||
6737 | { | ||
6738 | body: A2( | ||
6739 | $elm$http$Http$stringBody, | ||
6740 | 'application/json', | ||
6741 | $elm$core$String$fromInt(id)), | ||
6742 | expect: $elm$http$Http$expectWhatever($author$project$Cart$CartItemRemoved), | ||
6743 | headers: _List_Nil, | ||
6744 | method: 'POST', | ||
6745 | timeout: $elm$core$Maybe$Nothing, | ||
6746 | tracker: $elm$core$Maybe$Nothing, | ||
6747 | url: 'http://127.0.0.1:7878/cart/remove' | ||
6748 | }); | ||
6749 | }; | ||
6750 | var $author$project$Cart$update = F2( | ||
6751 | function (msg, model) { | ||
6752 | switch (msg.$) { | ||
6753 | case 'CartLoaded': | ||
6754 | var res = msg.a; | ||
6755 | if (res.$ === 'Ok') { | ||
6756 | var s = res.a; | ||
6757 | return _Utils_Tuple2( | ||
6758 | _Utils_update( | ||
6759 | model, | ||
6760 | {pageStatus: $author$project$Cart$Loaded, products: s}), | ||
6761 | $elm$core$Platform$Cmd$none); | ||
6762 | } else { | ||
6763 | var e = res.a; | ||
6764 | var _v2 = A2($elm$core$Debug$log, 'error', e); | ||
6765 | return _Utils_Tuple2( | ||
6766 | _Utils_update( | ||
6767 | model, | ||
6768 | {pageStatus: $author$project$Cart$NotLoaded}), | ||
6769 | $elm$core$Platform$Cmd$none); | ||
6770 | } | ||
6771 | case 'RemoveFromCart': | ||
6772 | var id = msg.a; | ||
6773 | return _Utils_Tuple2( | ||
6774 | model, | ||
6775 | $author$project$Cart$removeProduct(id)); | ||
6776 | case 'CartItemRemoved': | ||
6777 | return _Utils_Tuple2( | ||
6778 | _Utils_update( | ||
6779 | model, | ||
6780 | {pageStatus: $author$project$Cart$Loading}), | ||
6781 | $author$project$Cart$fetchCartItems); | ||
6782 | default: | ||
6783 | return _Utils_Tuple2( | ||
6784 | _Utils_update( | ||
6785 | model, | ||
6786 | {pageStatus: $author$project$Cart$Loading}), | ||
6787 | $author$project$Cart$fetchCartItems); | ||
6788 | } | ||
6789 | }); | ||
6790 | var $author$project$Catalog$Loaded = {$: 'Loaded'}; | ||
6791 | var $author$project$Catalog$Loading = {$: 'Loading'}; | ||
6792 | var $author$project$Catalog$update = F2( | ||
6793 | function (msg, model) { | ||
6794 | if (msg.$ === 'ProductsLoaded') { | ||
6795 | var res = msg.a; | ||
6796 | if (res.$ === 'Ok') { | ||
6797 | var s = res.a; | ||
6798 | return _Utils_Tuple2( | ||
6799 | _Utils_update( | ||
6800 | model, | ||
6801 | {pageStatus: $author$project$Catalog$Loaded, products: s}), | ||
6802 | $elm$core$Platform$Cmd$none); | ||
6803 | } else { | ||
6804 | var e = res.a; | ||
6805 | var _v2 = A2($elm$core$Debug$log, 'error', e); | ||
6806 | return _Utils_Tuple2( | ||
6807 | _Utils_update( | ||
6808 | model, | ||
6809 | {pageStatus: $author$project$Catalog$NotLoaded}), | ||
6810 | $elm$core$Platform$Cmd$none); | ||
6811 | } | ||
6812 | } else { | ||
6813 | return _Utils_Tuple2( | ||
6814 | _Utils_update( | ||
6815 | model, | ||
6816 | {pageStatus: $author$project$Catalog$Loading}), | ||
6817 | $author$project$Catalog$fetchProducts); | ||
6818 | } | ||
6819 | }); | ||
6820 | var $author$project$Login$InvalidLogin = {$: 'InvalidLogin'}; | ||
6821 | var $author$project$Login$LoggedIn = {$: 'LoggedIn'}; | ||
6822 | var $author$project$Login$LoggingIn = {$: 'LoggingIn'}; | ||
6823 | var $author$project$Login$LoginSuccess = function (a) { | ||
6824 | return {$: 'LoginSuccess', a: a}; | ||
6825 | }; | ||
6826 | var $elm$json$Json$Encode$object = function (pairs) { | ||
6827 | return _Json_wrap( | ||
6828 | A3( | ||
6829 | $elm$core$List$foldl, | ||
6830 | F2( | ||
6831 | function (_v0, obj) { | ||
6832 | var k = _v0.a; | ||
6833 | var v = _v0.b; | ||
6834 | return A3(_Json_addField, k, v, obj); | ||
6835 | }), | ||
6836 | _Json_emptyObject(_Utils_Tuple0), | ||
6837 | pairs)); | ||
6838 | }; | ||
6839 | var $elm$json$Json$Encode$string = _Json_wrap; | ||
6840 | var $author$project$Login$encodeLogin = function (model) { | ||
6841 | return $elm$json$Json$Encode$object( | ||
6842 | _List_fromArray( | ||
6843 | [ | ||
6844 | _Utils_Tuple2( | ||
6845 | 'username', | ||
6846 | $elm$json$Json$Encode$string(model.username)), | ||
6847 | _Utils_Tuple2( | ||
6848 | 'password', | ||
6849 | $elm$json$Json$Encode$string(model.password)) | ||
6850 | ])); | ||
6851 | }; | ||
6852 | var $elm$http$Http$jsonBody = function (value) { | ||
6853 | return A2( | ||
6854 | _Http_pair, | ||
6855 | 'application/json', | ||
6856 | A2($elm$json$Json$Encode$encode, 0, value)); | ||
6857 | }; | ||
6858 | var $author$project$Login$tryLogin = function (model) { | ||
6859 | return $elm$http$Http$riskyRequest( | ||
6860 | { | ||
6861 | body: $elm$http$Http$jsonBody( | ||
6862 | $author$project$Login$encodeLogin(model)), | ||
6863 | expect: $elm$http$Http$expectWhatever($author$project$Login$LoginSuccess), | ||
6864 | headers: _List_Nil, | ||
6865 | method: 'POST', | ||
6866 | timeout: $elm$core$Maybe$Nothing, | ||
6867 | tracker: $elm$core$Maybe$Nothing, | ||
6868 | url: 'http://127.0.0.1:7878/user/login' | ||
6869 | }); | ||
6870 | }; | ||
6871 | var $author$project$Login$update = F2( | ||
6872 | function (msg, model) { | ||
6873 | switch (msg.$) { | ||
6874 | case 'PassEntered': | ||
6875 | var s = msg.a; | ||
6876 | return _Utils_Tuple2( | ||
6877 | _Utils_update( | ||
6878 | model, | ||
6879 | {password: s}), | ||
6880 | $elm$core$Platform$Cmd$none); | ||
6881 | case 'UserEntered': | ||
6882 | var s = msg.a; | ||
6883 | return _Utils_Tuple2( | ||
6884 | _Utils_update( | ||
6885 | model, | ||
6886 | {username: s}), | ||
6887 | $elm$core$Platform$Cmd$none); | ||
6888 | case 'LoginPressed': | ||
6889 | return _Utils_Tuple2( | ||
6890 | _Utils_update( | ||
6891 | model, | ||
6892 | {loginStatus: $author$project$Login$LoggingIn}), | ||
6893 | $author$project$Login$tryLogin(model)); | ||
6894 | case 'LoginSuccess': | ||
6895 | var res = msg.a; | ||
6896 | if (res.$ === 'Ok') { | ||
6897 | var s = res.a; | ||
6898 | return _Utils_Tuple2( | ||
6899 | _Utils_update( | ||
6900 | model, | ||
6901 | {loginStatus: $author$project$Login$LoggedIn}), | ||
6902 | $elm$core$Platform$Cmd$none); | ||
6903 | } else { | ||
6904 | var e = res.a; | ||
6905 | return _Utils_Tuple2( | ||
6906 | _Utils_update( | ||
6907 | model, | ||
6908 | {loginStatus: $author$project$Login$InvalidLogin}), | ||
6909 | $elm$core$Platform$Cmd$none); | ||
6910 | } | ||
6911 | default: | ||
6912 | return _Utils_Tuple2( | ||
6913 | _Utils_update( | ||
6914 | model, | ||
6915 | {loginStatus: $author$project$Login$InvalidLogin}), | ||
6916 | $elm$core$Platform$Cmd$none); | ||
6917 | } | ||
6918 | }); | ||
6919 | var $author$project$Product$Loaded = {$: 'Loaded'}; | ||
6920 | var $author$project$Product$Loading = {$: 'Loading'}; | ||
6921 | var $author$project$Product$SubmitFail = {$: 'SubmitFail'}; | ||
6922 | var $author$project$Product$SubmitSuccess = {$: 'SubmitSuccess'}; | ||
6923 | var $author$project$Product$Submitting = {$: 'Submitting'}; | ||
6924 | var $author$project$Product$AddToCartSuccess = function (a) { | ||
6925 | return {$: 'AddToCartSuccess', a: a}; | ||
6926 | }; | ||
6927 | var $author$project$Product$addToCart = function (model) { | ||
6928 | var _v0 = A2( | ||
6929 | $elm$core$Debug$log, | ||
6930 | 'err', | ||
6931 | 'adding to cart: ' + $elm$core$String$fromInt(model.listing.id)); | ||
6932 | return $elm$http$Http$riskyRequest( | ||
6933 | { | ||
6934 | body: A2( | ||
6935 | $elm$http$Http$stringBody, | ||
6936 | 'applcation/json', | ||
6937 | $elm$core$String$fromInt(model.listing.id)), | ||
6938 | expect: $elm$http$Http$expectWhatever($author$project$Product$AddToCartSuccess), | ||
6939 | headers: _List_Nil, | ||
6940 | method: 'POST', | ||
6941 | timeout: $elm$core$Maybe$Nothing, | ||
6942 | tracker: $elm$core$Maybe$Nothing, | ||
6943 | url: 'http://127.0.0.1:7878/cart/add' | ||
6944 | }); | ||
6945 | }; | ||
6946 | var $author$project$Product$AddRatingSuccess = function (a) { | ||
6947 | return {$: 'AddRatingSuccess', a: a}; | ||
6948 | }; | ||
6949 | var $elm$json$Json$Encode$int = _Json_wrap; | ||
6950 | var $author$project$Product$encodeRatingForm = function (model) { | ||
6951 | return $elm$json$Json$Encode$object( | ||
6952 | _List_fromArray( | ||
6953 | [ | ||
6954 | _Utils_Tuple2( | ||
6955 | 'product_id', | ||
6956 | $elm$json$Json$Encode$int(model.listing.id)), | ||
6957 | _Utils_Tuple2( | ||
6958 | 'stars', | ||
6959 | $elm$json$Json$Encode$int(model.ratingStars)), | ||
6960 | _Utils_Tuple2( | ||
6961 | 'comment_text', | ||
6962 | $elm$json$Json$Encode$string(model.ratingText)) | ||
6963 | ])); | ||
6964 | }; | ||
6965 | var $author$project$Product$submitRating = function (model) { | ||
6966 | var _v0 = A2( | ||
6967 | $elm$core$Debug$log, | ||
6968 | 'err', | ||
6969 | 'submitting rating for' + $elm$core$String$fromInt(model.listing.id)); | ||
6970 | return $elm$http$Http$riskyRequest( | ||
6971 | { | ||
6972 | body: $elm$http$Http$jsonBody( | ||
6973 | $author$project$Product$encodeRatingForm(model)), | ||
6974 | expect: $elm$http$Http$expectWhatever($author$project$Product$AddRatingSuccess), | ||
6975 | headers: _List_Nil, | ||
6976 | method: 'POST', | ||
6977 | timeout: $elm$core$Maybe$Nothing, | ||
6978 | tracker: $elm$core$Maybe$Nothing, | ||
6979 | url: 'http://127.0.0.1:7878/rating/add' | ||
6980 | }); | ||
6981 | }; | ||
6982 | var $author$project$Product$update = F2( | ||
6983 | function (msg, model) { | ||
6984 | switch (msg.$) { | ||
6985 | case 'ListingLoaded': | ||
6986 | var res = msg.a; | ||
6987 | if (res.$ === 'Ok') { | ||
6988 | var s = res.a; | ||
6989 | return _Utils_Tuple2( | ||
6990 | _Utils_update( | ||
6991 | model, | ||
6992 | {listing: s, pageStatus: $author$project$Product$Loaded}), | ||
6993 | $elm$core$Platform$Cmd$none); | ||
6994 | } else { | ||
6995 | var e = res.a; | ||
6996 | var _v2 = A2($elm$core$Debug$log, 'error', e); | ||
6997 | return _Utils_Tuple2( | ||
6998 | _Utils_update( | ||
6999 | model, | ||
7000 | {pageStatus: $author$project$Product$NotLoaded}), | ||
7001 | $elm$core$Platform$Cmd$none); | ||
7002 | } | ||
7003 | case 'RatingsLoaded': | ||
7004 | var res = msg.a; | ||
7005 | if (res.$ === 'Ok') { | ||
7006 | var s = res.a; | ||
7007 | return _Utils_Tuple2( | ||
7008 | _Utils_update( | ||
7009 | model, | ||
7010 | {pageStatus: $author$project$Product$Loaded, ratings: s}), | ||
7011 | $elm$core$Platform$Cmd$none); | ||
7012 | } else { | ||
7013 | var e = res.a; | ||
7014 | var _v4 = A2($elm$core$Debug$log, 'error', e); | ||
7015 | return _Utils_Tuple2( | ||
7016 | _Utils_update( | ||
7017 | model, | ||
7018 | {pageStatus: $author$project$Product$NotLoaded}), | ||
7019 | $elm$core$Platform$Cmd$none); | ||
7020 | } | ||
7021 | case 'FetchProduct': | ||
7022 | var id = msg.a; | ||
7023 | return _Utils_Tuple2( | ||
7024 | _Utils_update( | ||
7025 | model, | ||
7026 | {pageStatus: $author$project$Product$Loading}), | ||
7027 | $author$project$Product$fetchListing(id)); | ||
7028 | case 'FetchRatings': | ||
7029 | var id = msg.a; | ||
7030 | return _Utils_Tuple2( | ||
7031 | _Utils_update( | ||
7032 | model, | ||
7033 | {pageStatus: $author$project$Product$Loading}), | ||
7034 | $author$project$Product$fetchRatings(id)); | ||
7035 | case 'AddRatingStars': | ||
7036 | var i = msg.a; | ||
7037 | return _Utils_Tuple2( | ||
7038 | _Utils_update( | ||
7039 | model, | ||
7040 | {ratingStars: i}), | ||
7041 | $elm$core$Platform$Cmd$none); | ||
7042 | case 'AddRatingComment': | ||
7043 | var s = msg.a; | ||
7044 | return _Utils_Tuple2( | ||
7045 | _Utils_update( | ||
7046 | model, | ||
7047 | {ratingText: s}), | ||
7048 | $elm$core$Platform$Cmd$none); | ||
7049 | case 'AddRatingPressed': | ||
7050 | return _Utils_Tuple2( | ||
7051 | _Utils_update( | ||
7052 | model, | ||
7053 | {addRatingStatus: $author$project$Product$Submitting}), | ||
7054 | $author$project$Product$submitRating(model)); | ||
7055 | case 'AddRatingSuccess': | ||
7056 | var res = msg.a; | ||
7057 | if (res.$ === 'Ok') { | ||
7058 | return _Utils_Tuple2( | ||
7059 | _Utils_update( | ||
7060 | model, | ||
7061 | {addRatingStatus: $author$project$Product$SubmitSuccess}), | ||
7062 | $author$project$Product$fetchRatings(model.listing.id)); | ||
7063 | } else { | ||
7064 | return _Utils_Tuple2( | ||
7065 | _Utils_update( | ||
7066 | model, | ||
7067 | {addRatingStatus: $author$project$Product$SubmitFail}), | ||
7068 | $elm$core$Platform$Cmd$none); | ||
7069 | } | ||
7070 | case 'AddRatingFail': | ||
7071 | return _Utils_Tuple2( | ||
7072 | _Utils_update( | ||
7073 | model, | ||
7074 | {addRatingStatus: $author$project$Product$SubmitFail}), | ||
7075 | $elm$core$Platform$Cmd$none); | ||
7076 | case 'AddToCartPressed': | ||
7077 | return _Utils_Tuple2( | ||
7078 | model, | ||
7079 | $author$project$Product$addToCart(model)); | ||
7080 | default: | ||
7081 | return _Utils_Tuple2(model, $elm$core$Platform$Cmd$none); | ||
7082 | } | ||
7083 | }); | ||
7084 | var $author$project$Signup$CreatedSuccessfully = {$: 'CreatedSuccessfully'}; | ||
7085 | var $author$project$Signup$CreatingUser = {$: 'CreatingUser'}; | ||
7086 | var $author$project$Signup$InvalidEmail = {$: 'InvalidEmail'}; | ||
7087 | var $author$project$Signup$InvalidPhone = {$: 'InvalidPhone'}; | ||
7088 | var $author$project$Signup$UsernameTaken = {$: 'UsernameTaken'}; | ||
7089 | var $elm$core$List$any = F2( | ||
7090 | function (isOkay, list) { | ||
7091 | any: | ||
7092 | while (true) { | ||
7093 | if (!list.b) { | ||
7094 | return false; | ||
7095 | } else { | ||
7096 | var x = list.a; | ||
7097 | var xs = list.b; | ||
7098 | if (isOkay(x)) { | ||
7099 | return true; | ||
7100 | } else { | ||
7101 | var $temp$isOkay = isOkay, | ||
7102 | $temp$list = xs; | ||
7103 | isOkay = $temp$isOkay; | ||
7104 | list = $temp$list; | ||
7105 | continue any; | ||
7106 | } | ||
7107 | } | ||
7108 | } | ||
7109 | }); | ||
7110 | var $elm$core$Basics$composeL = F3( | ||
7111 | function (g, f, x) { | ||
7112 | return g( | ||
7113 | f(x)); | ||
7114 | }); | ||
7115 | var $elm$core$Basics$not = _Basics_not; | ||
7116 | var $elm$core$List$all = F2( | ||
7117 | function (isOkay, list) { | ||
7118 | return !A2( | ||
7119 | $elm$core$List$any, | ||
7120 | A2($elm$core$Basics$composeL, $elm$core$Basics$not, isOkay), | ||
7121 | list); | ||
7122 | }); | ||
7123 | var $author$project$Signup$UsernameExists = function (a) { | ||
7124 | return {$: 'UsernameExists', a: a}; | ||
7125 | }; | ||
7126 | var $elm$http$Http$expectString = function (toMsg) { | ||
7127 | return A2( | ||
7128 | $elm$http$Http$expectStringResponse, | ||
7129 | toMsg, | ||
7130 | $elm$http$Http$resolve($elm$core$Result$Ok)); | ||
7131 | }; | ||
7132 | var $elm$http$Http$post = function (r) { | ||
7133 | return $elm$http$Http$request( | ||
7134 | {body: r.body, expect: r.expect, headers: _List_Nil, method: 'POST', timeout: $elm$core$Maybe$Nothing, tracker: $elm$core$Maybe$Nothing, url: r.url}); | ||
7135 | }; | ||
7136 | var $author$project$Signup$checkExists = function (model) { | ||
7137 | return $elm$http$Http$post( | ||
7138 | { | ||
7139 | body: A2($elm$http$Http$stringBody, 'application/json', model.username), | ||
7140 | expect: $elm$http$Http$expectString($author$project$Signup$UsernameExists), | ||
7141 | url: 'http://127.0.0.1:7878/user/existing' | ||
7142 | }); | ||
7143 | }; | ||
7144 | var $author$project$Signup$CreationSuccess = function (a) { | ||
7145 | return {$: 'CreationSuccess', a: a}; | ||
7146 | }; | ||
7147 | var $elm$core$Maybe$withDefault = F2( | ||
7148 | function (_default, maybe) { | ||
7149 | if (maybe.$ === 'Just') { | ||
7150 | var value = maybe.a; | ||
7151 | return value; | ||
7152 | } else { | ||
7153 | return _default; | ||
7154 | } | ||
7155 | }); | ||
7156 | var $author$project$Signup$encodeCreateUser = function (model) { | ||
7157 | return $elm$json$Json$Encode$object( | ||
7158 | _List_fromArray( | ||
7159 | [ | ||
7160 | _Utils_Tuple2( | ||
7161 | 'username', | ||
7162 | $elm$json$Json$Encode$string(model.username)), | ||
7163 | _Utils_Tuple2( | ||
7164 | 'password', | ||
7165 | $elm$json$Json$Encode$string(model.password)), | ||
7166 | _Utils_Tuple2( | ||
7167 | 'phone_number', | ||
7168 | $elm$json$Json$Encode$string(model.phoneNumber)), | ||
7169 | _Utils_Tuple2( | ||
7170 | 'email_id', | ||
7171 | $elm$json$Json$Encode$string(model.emailId)), | ||
7172 | _Utils_Tuple2( | ||
7173 | 'address', | ||
7174 | $elm$json$Json$Encode$string( | ||
7175 | A2($elm$core$Maybe$withDefault, '', model.address))) | ||
7176 | ])); | ||
7177 | }; | ||
7178 | var $author$project$Signup$createUser = function (model) { | ||
7179 | return $elm$http$Http$riskyRequest( | ||
7180 | { | ||
7181 | body: $elm$http$Http$jsonBody( | ||
7182 | $author$project$Signup$encodeCreateUser(model)), | ||
7183 | expect: $elm$http$Http$expectWhatever($author$project$Signup$CreationSuccess), | ||
7184 | headers: _List_Nil, | ||
7185 | method: 'POST', | ||
7186 | timeout: $elm$core$Maybe$Nothing, | ||
7187 | tracker: $elm$core$Maybe$Nothing, | ||
7188 | url: 'http://127.0.0.1:7878/user/new' | ||
7189 | }); | ||
7190 | }; | ||
7191 | var $elm$core$Basics$neq = _Utils_notEqual; | ||
7192 | var $elm$core$String$foldr = _String_foldr; | ||
7193 | var $elm$core$String$toList = function (string) { | ||
7194 | return A3($elm$core$String$foldr, $elm$core$List$cons, _List_Nil, string); | ||
7195 | }; | ||
7196 | var $author$project$Signup$update = F2( | ||
7197 | function (msg, model) { | ||
7198 | switch (msg.$) { | ||
7199 | case 'UserEntered': | ||
7200 | var s = msg.a; | ||
7201 | return _Utils_Tuple2( | ||
7202 | _Utils_update( | ||
7203 | model, | ||
7204 | {username: s}), | ||
7205 | $elm$core$Platform$Cmd$none); | ||
7206 | case 'PassEntered': | ||
7207 | var s = msg.a; | ||
7208 | return _Utils_Tuple2( | ||
7209 | _Utils_update( | ||
7210 | model, | ||
7211 | {password: s}), | ||
7212 | $elm$core$Platform$Cmd$none); | ||
7213 | case 'PhoneEntered': | ||
7214 | var s = msg.a; | ||
7215 | var status = (($elm$core$String$length(s) !== 10) || A2( | ||
7216 | $elm$core$List$all, | ||
7217 | A2($elm$core$Basics$composeL, $elm$core$Basics$not, $elm$core$Char$isDigit), | ||
7218 | $elm$core$String$toList(s))) ? $author$project$Signup$InvalidPhone : $author$project$Signup$Empty; | ||
7219 | return _Utils_Tuple2( | ||
7220 | _Utils_update( | ||
7221 | model, | ||
7222 | {phoneNumber: s, status: status}), | ||
7223 | $elm$core$Platform$Cmd$none); | ||
7224 | case 'EmailEntered': | ||
7225 | var s = msg.a; | ||
7226 | var status = (!A2($elm$core$String$contains, '@', s)) ? $author$project$Signup$InvalidEmail : $author$project$Signup$Empty; | ||
7227 | return _Utils_Tuple2( | ||
7228 | _Utils_update( | ||
7229 | model, | ||
7230 | {emailId: s, status: status}), | ||
7231 | $elm$core$Platform$Cmd$none); | ||
7232 | case 'AddressEntered': | ||
7233 | var s = msg.a; | ||
7234 | return _Utils_Tuple2( | ||
7235 | _Utils_update( | ||
7236 | model, | ||
7237 | { | ||
7238 | address: $elm$core$Maybe$Just(s) | ||
7239 | }), | ||
7240 | $elm$core$Platform$Cmd$none); | ||
7241 | case 'CreatePressed': | ||
7242 | return _Utils_Tuple2( | ||
7243 | _Utils_update( | ||
7244 | model, | ||
7245 | {status: $author$project$Signup$CreatingUser}), | ||
7246 | $author$project$Signup$checkExists(model)); | ||
7247 | case 'CreationSuccess': | ||
7248 | var res = msg.a; | ||
7249 | if (res.$ === 'Ok') { | ||
7250 | return _Utils_Tuple2( | ||
7251 | _Utils_update( | ||
7252 | model, | ||
7253 | {status: $author$project$Signup$CreatedSuccessfully}), | ||
7254 | $elm$core$Platform$Cmd$none); | ||
7255 | } else { | ||
7256 | return _Utils_Tuple2(model, $elm$core$Platform$Cmd$none); | ||
7257 | } | ||
7258 | case 'CreationFail': | ||
7259 | return _Utils_Tuple2($author$project$Signup$init, $elm$core$Platform$Cmd$none); | ||
7260 | default: | ||
7261 | var res = msg.a; | ||
7262 | _v2$2: | ||
7263 | while (true) { | ||
7264 | if (res.$ === 'Ok') { | ||
7265 | switch (res.a) { | ||
7266 | case 'true': | ||
7267 | return _Utils_Tuple2( | ||
7268 | _Utils_update( | ||
7269 | model, | ||
7270 | {status: $author$project$Signup$UsernameTaken}), | ||
7271 | $elm$core$Platform$Cmd$none); | ||
7272 | case 'false': | ||
7273 | var _v3 = A2($elm$core$Debug$log, 'signup', 'Hit create user ...'); | ||
7274 | return _Utils_Tuple2( | ||
7275 | _Utils_update( | ||
7276 | model, | ||
7277 | {status: $author$project$Signup$CreatingUser}), | ||
7278 | $author$project$Signup$createUser(model)); | ||
7279 | default: | ||
7280 | break _v2$2; | ||
7281 | } | ||
7282 | } else { | ||
7283 | break _v2$2; | ||
7284 | } | ||
7285 | } | ||
7286 | return _Utils_Tuple2(model, $elm$core$Platform$Cmd$none); | ||
7287 | } | ||
7288 | }); | ||
7289 | var $author$project$Main$update = F2( | ||
7290 | function (msg, model) { | ||
7291 | switch (msg.$) { | ||
7292 | case 'LinkClicked': | ||
7293 | var urlRequest = msg.a; | ||
7294 | if (urlRequest.$ === 'Internal') { | ||
7295 | var url = urlRequest.a; | ||
7296 | return _Utils_Tuple2( | ||
7297 | model, | ||
7298 | A2( | ||
7299 | $elm$browser$Browser$Navigation$pushUrl, | ||
7300 | model.key, | ||
7301 | $elm$url$Url$toString(url))); | ||
7302 | } else { | ||
7303 | var href = urlRequest.a; | ||
7304 | return _Utils_Tuple2( | ||
7305 | model, | ||
7306 | $elm$browser$Browser$Navigation$load(href)); | ||
7307 | } | ||
7308 | case 'LogoutPressed': | ||
7309 | return _Utils_Tuple2(model, $author$project$Main$tryLogout); | ||
7310 | case 'LogoutSuccess': | ||
7311 | return _Utils_Tuple2( | ||
7312 | model, | ||
7313 | A2($elm$browser$Browser$Navigation$replaceUrl, model.key, '/login')); | ||
7314 | case 'UrlChanged': | ||
7315 | var url = msg.a; | ||
7316 | var parsedUrl = A2($elm$url$Url$Parser$parse, $author$project$Main$parseRoute, url); | ||
7317 | if (parsedUrl.$ === 'Just') { | ||
7318 | switch (parsedUrl.a.$) { | ||
7319 | case 'CatalogPage': | ||
7320 | var _v3 = parsedUrl.a; | ||
7321 | return _Utils_Tuple2( | ||
7322 | _Utils_update( | ||
7323 | model, | ||
7324 | {location: $author$project$Main$CatalogPage}), | ||
7325 | A2($elm$core$Platform$Cmd$map, $author$project$Main$CatalogMessage, $author$project$Catalog$fetchProducts)); | ||
7326 | case 'ProductPage': | ||
7327 | var id = parsedUrl.a.a; | ||
7328 | var cmds = A2( | ||
7329 | $elm$core$List$map, | ||
7330 | $elm$core$Platform$Cmd$map($author$project$Main$ProductMessage), | ||
7331 | _List_fromArray( | ||
7332 | [ | ||
7333 | $author$project$Product$fetchListing(id), | ||
7334 | $author$project$Product$fetchRatings(id) | ||
7335 | ])); | ||
7336 | return _Utils_Tuple2( | ||
7337 | _Utils_update( | ||
7338 | model, | ||
7339 | { | ||
7340 | location: $author$project$Main$ProductPage(id) | ||
7341 | }), | ||
7342 | $elm$core$Platform$Cmd$batch(cmds)); | ||
7343 | case 'CartPage': | ||
7344 | var _v4 = parsedUrl.a; | ||
7345 | var cmd = A2($elm$core$Platform$Cmd$map, $author$project$Main$CartMessage, $author$project$Cart$fetchCartItems); | ||
7346 | return _Utils_Tuple2( | ||
7347 | _Utils_update( | ||
7348 | model, | ||
7349 | {location: $author$project$Main$CartPage}), | ||
7350 | cmd); | ||
7351 | default: | ||
7352 | var p = parsedUrl.a; | ||
7353 | return _Utils_Tuple2( | ||
7354 | _Utils_update( | ||
7355 | model, | ||
7356 | {location: p}), | ||
7357 | $elm$core$Platform$Cmd$none); | ||
7358 | } | ||
7359 | } else { | ||
7360 | return _Utils_Tuple2( | ||
7361 | _Utils_update( | ||
7362 | model, | ||
7363 | {location: $author$project$Main$NotFoundPage}), | ||
7364 | $elm$core$Platform$Cmd$none); | ||
7365 | } | ||
7366 | case 'LoginMessage': | ||
7367 | var lm = msg.a; | ||
7368 | var _v5 = A2($author$project$Login$update, lm, model.loginModel); | ||
7369 | var lmn = _v5.a; | ||
7370 | var cmd = _v5.b; | ||
7371 | var redir = function () { | ||
7372 | var _v6 = lmn.loginStatus; | ||
7373 | if (_v6.$ === 'LoggedIn') { | ||
7374 | return A2($elm$browser$Browser$Navigation$replaceUrl, model.key, '/catalog'); | ||
7375 | } else { | ||
7376 | return $elm$core$Platform$Cmd$none; | ||
7377 | } | ||
7378 | }(); | ||
7379 | return _Utils_Tuple2( | ||
7380 | _Utils_update( | ||
7381 | model, | ||
7382 | {loginModel: lmn}), | ||
7383 | $elm$core$Platform$Cmd$batch( | ||
7384 | _List_fromArray( | ||
7385 | [ | ||
7386 | A2($elm$core$Platform$Cmd$map, $author$project$Main$LoginMessage, cmd), | ||
7387 | redir | ||
7388 | ]))); | ||
7389 | case 'SignupMessage': | ||
7390 | var sm = msg.a; | ||
7391 | var _v7 = A2($author$project$Signup$update, sm, model.signupModel); | ||
7392 | var smn = _v7.a; | ||
7393 | var cmd = _v7.b; | ||
7394 | var redir = function () { | ||
7395 | var _v8 = smn.status; | ||
7396 | if (_v8.$ === 'CreatedSuccessfully') { | ||
7397 | return A2($elm$browser$Browser$Navigation$replaceUrl, model.key, '/login'); | ||
7398 | } else { | ||
7399 | return $elm$core$Platform$Cmd$none; | ||
7400 | } | ||
7401 | }(); | ||
7402 | return _Utils_Tuple2( | ||
7403 | _Utils_update( | ||
7404 | model, | ||
7405 | {signupModel: smn}), | ||
7406 | $elm$core$Platform$Cmd$batch( | ||
7407 | _List_fromArray( | ||
7408 | [ | ||
7409 | A2($elm$core$Platform$Cmd$map, $author$project$Main$SignupMessage, cmd), | ||
7410 | redir | ||
7411 | ]))); | ||
7412 | case 'CatalogMessage': | ||
7413 | var cm = msg.a; | ||
7414 | var _v9 = A2($author$project$Catalog$update, cm, model.catalogModel); | ||
7415 | var cmn = _v9.a; | ||
7416 | var cmd = _v9.b; | ||
7417 | return _Utils_Tuple2( | ||
7418 | _Utils_update( | ||
7419 | model, | ||
7420 | {catalogModel: cmn}), | ||
7421 | A2($elm$core$Platform$Cmd$map, $author$project$Main$CatalogMessage, cmd)); | ||
7422 | case 'CartMessage': | ||
7423 | var cm = msg.a; | ||
7424 | var _v10 = A2($author$project$Cart$update, cm, model.cartModel); | ||
7425 | var cmn = _v10.a; | ||
7426 | var cmd = _v10.b; | ||
7427 | return _Utils_Tuple2( | ||
7428 | _Utils_update( | ||
7429 | model, | ||
7430 | {cartModel: cmn}), | ||
7431 | A2($elm$core$Platform$Cmd$map, $author$project$Main$CartMessage, cmd)); | ||
7432 | default: | ||
7433 | var pm = msg.a; | ||
7434 | var redir = function () { | ||
7435 | if (pm.$ === 'AddToCartSuccess') { | ||
7436 | return A2($elm$browser$Browser$Navigation$replaceUrl, model.key, '/cart'); | ||
7437 | } else { | ||
7438 | return $elm$core$Platform$Cmd$none; | ||
7439 | } | ||
7440 | }(); | ||
7441 | var _v11 = A2($author$project$Product$update, pm, model.productModel); | ||
7442 | var pmn = _v11.a; | ||
7443 | var cmd = _v11.b; | ||
7444 | return _Utils_Tuple2( | ||
7445 | _Utils_update( | ||
7446 | model, | ||
7447 | {productModel: pmn}), | ||
7448 | $elm$core$Platform$Cmd$batch( | ||
7449 | _List_fromArray( | ||
7450 | [ | ||
7451 | A2($elm$core$Platform$Cmd$map, $author$project$Main$ProductMessage, cmd), | ||
7452 | redir | ||
7453 | ]))); | ||
7454 | } | ||
7455 | }); | ||
7456 | var $elm$html$Html$a = _VirtualDom_node('a'); | ||
7457 | var $elm$html$Html$b = _VirtualDom_node('b'); | ||
7458 | var $elm$html$Html$Attributes$stringProperty = F2( | ||
7459 | function (key, string) { | ||
7460 | return A2( | ||
7461 | _VirtualDom_property, | ||
7462 | key, | ||
7463 | $elm$json$Json$Encode$string(string)); | ||
7464 | }); | ||
7465 | var $elm$html$Html$Attributes$href = function (url) { | ||
7466 | return A2( | ||
7467 | $elm$html$Html$Attributes$stringProperty, | ||
7468 | 'href', | ||
7469 | _VirtualDom_noJavaScriptUri(url)); | ||
7470 | }; | ||
7471 | var $elm$virtual_dom$VirtualDom$map = _VirtualDom_map; | ||
7472 | var $elm$html$Html$map = $elm$virtual_dom$VirtualDom$map; | ||
7473 | var $elm$html$Html$div = _VirtualDom_node('div'); | ||
7474 | var $author$project$Main$LogoutPressed = {$: 'LogoutPressed'}; | ||
7475 | var $elm$html$Html$button = _VirtualDom_node('button'); | ||
7476 | var $elm$html$Html$li = _VirtualDom_node('li'); | ||
7477 | var $elm$virtual_dom$VirtualDom$Normal = function (a) { | ||
7478 | return {$: 'Normal', a: a}; | ||
7479 | }; | ||
7480 | var $elm$virtual_dom$VirtualDom$on = _VirtualDom_on; | ||
7481 | var $elm$html$Html$Events$on = F2( | ||
7482 | function (event, decoder) { | ||
7483 | return A2( | ||
7484 | $elm$virtual_dom$VirtualDom$on, | ||
7485 | event, | ||
7486 | $elm$virtual_dom$VirtualDom$Normal(decoder)); | ||
7487 | }); | ||
7488 | var $elm$html$Html$Events$onClick = function (msg) { | ||
7489 | return A2( | ||
7490 | $elm$html$Html$Events$on, | ||
7491 | 'click', | ||
7492 | $elm$json$Json$Decode$succeed(msg)); | ||
7493 | }; | ||
7494 | var $elm$virtual_dom$VirtualDom$text = _VirtualDom_text; | ||
7495 | var $elm$html$Html$text = $elm$virtual_dom$VirtualDom$text; | ||
7496 | var $elm$html$Html$ul = _VirtualDom_node('ul'); | ||
7497 | var $author$project$Main$viewHeader = function (model) { | ||
7498 | var links = _List_fromArray( | ||
7499 | [ | ||
7500 | _Utils_Tuple2('Home', '/'), | ||
7501 | _Utils_Tuple2('Catalog', '/catalog'), | ||
7502 | _Utils_Tuple2('Cart', '/cart') | ||
7503 | ]); | ||
7504 | return A2( | ||
7505 | $elm$html$Html$div, | ||
7506 | _List_Nil, | ||
7507 | _List_fromArray( | ||
7508 | [ | ||
7509 | A2( | ||
7510 | $elm$html$Html$ul, | ||
7511 | _List_Nil, | ||
7512 | _Utils_ap( | ||
7513 | A2( | ||
7514 | $elm$core$List$map, | ||
7515 | function (_v0) { | ||
7516 | var name = _v0.a; | ||
7517 | var loc = _v0.b; | ||
7518 | return A2( | ||
7519 | $elm$html$Html$li, | ||
7520 | _List_Nil, | ||
7521 | _List_fromArray( | ||
7522 | [ | ||
7523 | A2( | ||
7524 | $elm$html$Html$a, | ||
7525 | _List_fromArray( | ||
7526 | [ | ||
7527 | $elm$html$Html$Attributes$href(loc) | ||
7528 | ]), | ||
7529 | _List_fromArray( | ||
7530 | [ | ||
7531 | $elm$html$Html$text(name) | ||
7532 | ])) | ||
7533 | ])); | ||
7534 | }, | ||
7535 | links), | ||
7536 | _List_fromArray( | ||
7537 | [ | ||
7538 | (!_Utils_eq(model.loginModel.loginStatus, $author$project$Login$LoggedIn)) ? A2( | ||
7539 | $elm$html$Html$li, | ||
7540 | _List_Nil, | ||
7541 | _List_fromArray( | ||
7542 | [ | ||
7543 | A2( | ||
7544 | $elm$html$Html$a, | ||
7545 | _List_fromArray( | ||
7546 | [ | ||
7547 | $elm$html$Html$Attributes$href('/login') | ||
7548 | ]), | ||
7549 | _List_fromArray( | ||
7550 | [ | ||
7551 | $elm$html$Html$text('Login') | ||
7552 | ])) | ||
7553 | ])) : A2( | ||
7554 | $elm$html$Html$button, | ||
7555 | _List_fromArray( | ||
7556 | [ | ||
7557 | $elm$html$Html$Events$onClick($author$project$Main$LogoutPressed) | ||
7558 | ]), | ||
7559 | _List_fromArray( | ||
7560 | [ | ||
7561 | $elm$html$Html$text('Logout') | ||
7562 | ])) | ||
7563 | ]))) | ||
7564 | ])); | ||
7565 | }; | ||
7566 | var $author$project$Main$pageWrap = F2( | ||
7567 | function (model, page) { | ||
7568 | return _List_fromArray( | ||
7569 | [ | ||
7570 | A2( | ||
7571 | $elm$html$Html$div, | ||
7572 | _List_Nil, | ||
7573 | _List_fromArray( | ||
7574 | [ | ||
7575 | $author$project$Main$viewHeader(model), | ||
7576 | page | ||
7577 | ])) | ||
7578 | ]); | ||
7579 | }); | ||
7580 | var $elm$core$List$isEmpty = function (xs) { | ||
7581 | if (!xs.b) { | ||
7582 | return true; | ||
7583 | } else { | ||
7584 | return false; | ||
7585 | } | ||
7586 | }; | ||
7587 | var $author$project$Cart$RemoveFromCart = function (a) { | ||
7588 | return {$: 'RemoveFromCart', a: a}; | ||
7589 | }; | ||
7590 | var $elm$core$String$fromFloat = _String_fromNumber; | ||
7591 | var $author$project$Cart$viewProduct = function (p) { | ||
7592 | return A2( | ||
7593 | $elm$html$Html$div, | ||
7594 | _List_Nil, | ||
7595 | _List_fromArray( | ||
7596 | [ | ||
7597 | $elm$html$Html$text(p.name), | ||
7598 | A2( | ||
7599 | $elm$html$Html$div, | ||
7600 | _List_Nil, | ||
7601 | _List_fromArray( | ||
7602 | [ | ||
7603 | $elm$html$Html$text( | ||
7604 | A2($elm$core$Maybe$withDefault, '', p.kind)) | ||
7605 | ])), | ||
7606 | A2( | ||
7607 | $elm$html$Html$div, | ||
7608 | _List_Nil, | ||
7609 | _List_fromArray( | ||
7610 | [ | ||
7611 | $elm$html$Html$text( | ||
7612 | A2($elm$core$Maybe$withDefault, '', p.description)) | ||
7613 | ])), | ||
7614 | A2( | ||
7615 | $elm$html$Html$div, | ||
7616 | _List_Nil, | ||
7617 | _List_fromArray( | ||
7618 | [ | ||
7619 | $elm$html$Html$text( | ||
7620 | $elm$core$String$fromFloat(p.price)) | ||
7621 | ])), | ||
7622 | A2( | ||
7623 | $elm$html$Html$div, | ||
7624 | _List_Nil, | ||
7625 | _List_fromArray( | ||
7626 | [ | ||
7627 | A2( | ||
7628 | $elm$html$Html$button, | ||
7629 | _List_fromArray( | ||
7630 | [ | ||
7631 | $elm$html$Html$Events$onClick( | ||
7632 | $author$project$Cart$RemoveFromCart(p.id)) | ||
7633 | ]), | ||
7634 | _List_fromArray( | ||
7635 | [ | ||
7636 | $elm$html$Html$text('Remove') | ||
7637 | ])) | ||
7638 | ])), | ||
7639 | A2( | ||
7640 | $elm$html$Html$div, | ||
7641 | _List_Nil, | ||
7642 | _List_fromArray( | ||
7643 | [ | ||
7644 | A2( | ||
7645 | $elm$html$Html$a, | ||
7646 | _List_fromArray( | ||
7647 | [ | ||
7648 | $elm$html$Html$Attributes$href( | ||
7649 | '/product/' + $elm$core$String$fromInt(p.id)) | ||
7650 | ]), | ||
7651 | _List_fromArray( | ||
7652 | [ | ||
7653 | $elm$html$Html$text('View Product') | ||
7654 | ])) | ||
7655 | ])) | ||
7656 | ])); | ||
7657 | }; | ||
7658 | var $author$project$Cart$viewStatus = function (s) { | ||
7659 | switch (s.$) { | ||
7660 | case 'Loading': | ||
7661 | return 'Loading'; | ||
7662 | case 'Loaded': | ||
7663 | return 'Ready!'; | ||
7664 | default: | ||
7665 | return 'Not loaded ...'; | ||
7666 | } | ||
7667 | }; | ||
7668 | var $author$project$Cart$view = function (model) { | ||
7669 | var _v0 = model.pageStatus; | ||
7670 | if (_v0.$ === 'Loading') { | ||
7671 | return A2( | ||
7672 | $elm$html$Html$div, | ||
7673 | _List_Nil, | ||
7674 | _List_fromArray( | ||
7675 | [ | ||
7676 | $elm$html$Html$text( | ||
7677 | $author$project$Cart$viewStatus($author$project$Cart$Loading)) | ||
7678 | ])); | ||
7679 | } else { | ||
7680 | return A2( | ||
7681 | $elm$html$Html$div, | ||
7682 | _List_Nil, | ||
7683 | _List_fromArray( | ||
7684 | [ | ||
7685 | function () { | ||
7686 | var cart = A2($elm$core$List$map, $author$project$Cart$viewProduct, model.products); | ||
7687 | return $elm$core$List$isEmpty(cart) ? $elm$html$Html$text('No items in cart') : A2($elm$html$Html$ul, _List_Nil, cart); | ||
7688 | }() | ||
7689 | ])); | ||
7690 | } | ||
7691 | }; | ||
7692 | var $author$project$Catalog$viewProduct = function (p) { | ||
7693 | return A2( | ||
7694 | $elm$html$Html$div, | ||
7695 | _List_Nil, | ||
7696 | _List_fromArray( | ||
7697 | [ | ||
7698 | $elm$html$Html$text(p.name), | ||
7699 | $elm$html$Html$text( | ||
7700 | A2($elm$core$Maybe$withDefault, '', p.kind)), | ||
7701 | $elm$html$Html$text( | ||
7702 | A2($elm$core$Maybe$withDefault, '', p.description)), | ||
7703 | $elm$html$Html$text( | ||
7704 | $elm$core$String$fromFloat(p.price)), | ||
7705 | A2( | ||
7706 | $elm$html$Html$a, | ||
7707 | _List_fromArray( | ||
7708 | [ | ||
7709 | $elm$html$Html$Attributes$href( | ||
7710 | '/product/' + $elm$core$String$fromInt(p.id)) | ||
7711 | ]), | ||
7712 | _List_fromArray( | ||
7713 | [ | ||
7714 | $elm$html$Html$text('View Product') | ||
7715 | ])) | ||
7716 | ])); | ||
7717 | }; | ||
7718 | var $author$project$Catalog$viewStatus = function (s) { | ||
7719 | switch (s.$) { | ||
7720 | case 'Loading': | ||
7721 | return 'Loading'; | ||
7722 | case 'Loaded': | ||
7723 | return 'Ready!'; | ||
7724 | default: | ||
7725 | return 'Not loaded ...'; | ||
7726 | } | ||
7727 | }; | ||
7728 | var $author$project$Catalog$view = function (model) { | ||
7729 | var _v0 = model.pageStatus; | ||
7730 | if (_v0.$ === 'Loading') { | ||
7731 | return A2( | ||
7732 | $elm$html$Html$div, | ||
7733 | _List_Nil, | ||
7734 | _List_fromArray( | ||
7735 | [ | ||
7736 | $elm$html$Html$text( | ||
7737 | $author$project$Catalog$viewStatus($author$project$Catalog$Loading)) | ||
7738 | ])); | ||
7739 | } else { | ||
7740 | return A2( | ||
7741 | $elm$html$Html$div, | ||
7742 | _List_Nil, | ||
7743 | _List_fromArray( | ||
7744 | [ | ||
7745 | A2( | ||
7746 | $elm$html$Html$ul, | ||
7747 | _List_Nil, | ||
7748 | A2($elm$core$List$map, $author$project$Catalog$viewProduct, model.products)) | ||
7749 | ])); | ||
7750 | } | ||
7751 | }; | ||
7752 | var $author$project$Login$LoginPressed = {$: 'LoginPressed'}; | ||
7753 | var $author$project$Login$PassEntered = function (a) { | ||
7754 | return {$: 'PassEntered', a: a}; | ||
7755 | }; | ||
7756 | var $author$project$Login$UserEntered = function (a) { | ||
7757 | return {$: 'UserEntered', a: a}; | ||
7758 | }; | ||
7759 | var $elm$html$Html$input = _VirtualDom_node('input'); | ||
7760 | var $elm$html$Html$Events$alwaysStop = function (x) { | ||
7761 | return _Utils_Tuple2(x, true); | ||
7762 | }; | ||
7763 | var $elm$virtual_dom$VirtualDom$MayStopPropagation = function (a) { | ||
7764 | return {$: 'MayStopPropagation', a: a}; | ||
7765 | }; | ||
7766 | var $elm$html$Html$Events$stopPropagationOn = F2( | ||
7767 | function (event, decoder) { | ||
7768 | return A2( | ||
7769 | $elm$virtual_dom$VirtualDom$on, | ||
7770 | event, | ||
7771 | $elm$virtual_dom$VirtualDom$MayStopPropagation(decoder)); | ||
7772 | }); | ||
7773 | var $elm$json$Json$Decode$at = F2( | ||
7774 | function (fields, decoder) { | ||
7775 | return A3($elm$core$List$foldr, $elm$json$Json$Decode$field, decoder, fields); | ||
7776 | }); | ||
7777 | var $elm$html$Html$Events$targetValue = A2( | ||
7778 | $elm$json$Json$Decode$at, | ||
7779 | _List_fromArray( | ||
7780 | ['target', 'value']), | ||
7781 | $elm$json$Json$Decode$string); | ||
7782 | var $elm$html$Html$Events$onInput = function (tagger) { | ||
7783 | return A2( | ||
7784 | $elm$html$Html$Events$stopPropagationOn, | ||
7785 | 'input', | ||
7786 | A2( | ||
7787 | $elm$json$Json$Decode$map, | ||
7788 | $elm$html$Html$Events$alwaysStop, | ||
7789 | A2($elm$json$Json$Decode$map, tagger, $elm$html$Html$Events$targetValue))); | ||
7790 | }; | ||
7791 | var $elm$html$Html$Attributes$placeholder = $elm$html$Html$Attributes$stringProperty('placeholder'); | ||
7792 | var $elm$html$Html$Attributes$type_ = $elm$html$Html$Attributes$stringProperty('type'); | ||
7793 | var $elm$html$Html$Attributes$value = $elm$html$Html$Attributes$stringProperty('value'); | ||
7794 | var $author$project$Login$viewInput = F4( | ||
7795 | function (t, p, v, toMsg) { | ||
7796 | return A2( | ||
7797 | $elm$html$Html$input, | ||
7798 | _List_fromArray( | ||
7799 | [ | ||
7800 | $elm$html$Html$Attributes$type_(t), | ||
7801 | $elm$html$Html$Attributes$placeholder(p), | ||
7802 | $elm$html$Html$Attributes$value(v), | ||
7803 | $elm$html$Html$Events$onInput(toMsg) | ||
7804 | ]), | ||
7805 | _List_Nil); | ||
7806 | }); | ||
7807 | var $author$project$Login$viewStatus = function (ls) { | ||
7808 | switch (ls.$) { | ||
7809 | case 'NotLoggedIn': | ||
7810 | return 'Not Logged In'; | ||
7811 | case 'InvalidLogin': | ||
7812 | return 'Invalid Login'; | ||
7813 | case 'LoggedIn': | ||
7814 | return 'Logged in!'; | ||
7815 | default: | ||
7816 | return 'Logging In ...'; | ||
7817 | } | ||
7818 | }; | ||
7819 | var $author$project$Login$view = function (model) { | ||
7820 | return A2( | ||
7821 | $elm$html$Html$div, | ||
7822 | _List_Nil, | ||
7823 | _List_fromArray( | ||
7824 | [ | ||
7825 | A2( | ||
7826 | $elm$html$Html$div, | ||
7827 | _List_Nil, | ||
7828 | _List_fromArray( | ||
7829 | [ | ||
7830 | A4($author$project$Login$viewInput, 'text', 'Enter name here', model.username, $author$project$Login$UserEntered) | ||
7831 | ])), | ||
7832 | A2( | ||
7833 | $elm$html$Html$div, | ||
7834 | _List_Nil, | ||
7835 | _List_fromArray( | ||
7836 | [ | ||
7837 | A4($author$project$Login$viewInput, 'password', 'Password', model.password, $author$project$Login$PassEntered) | ||
7838 | ])), | ||
7839 | A2( | ||
7840 | $elm$html$Html$div, | ||
7841 | _List_Nil, | ||
7842 | _List_fromArray( | ||
7843 | [ | ||
7844 | A2( | ||
7845 | $elm$html$Html$button, | ||
7846 | _List_fromArray( | ||
7847 | [ | ||
7848 | $elm$html$Html$Events$onClick($author$project$Login$LoginPressed) | ||
7849 | ]), | ||
7850 | _List_fromArray( | ||
7851 | [ | ||
7852 | $elm$html$Html$text('Login') | ||
7853 | ])) | ||
7854 | ])), | ||
7855 | A2( | ||
7856 | $elm$html$Html$div, | ||
7857 | _List_Nil, | ||
7858 | _List_fromArray( | ||
7859 | [ | ||
7860 | $elm$html$Html$text( | ||
7861 | $author$project$Login$viewStatus(model.loginStatus)) | ||
7862 | ])), | ||
7863 | A2( | ||
7864 | $elm$html$Html$div, | ||
7865 | _List_Nil, | ||
7866 | _List_fromArray( | ||
7867 | [ | ||
7868 | $elm$html$Html$text('Don\'t have an account? '), | ||
7869 | A2( | ||
7870 | $elm$html$Html$a, | ||
7871 | _List_fromArray( | ||
7872 | [ | ||
7873 | $elm$html$Html$Attributes$href('/signup') | ||
7874 | ]), | ||
7875 | _List_fromArray( | ||
7876 | [ | ||
7877 | $elm$html$Html$text('Register now!') | ||
7878 | ])) | ||
7879 | ])) | ||
7880 | ])); | ||
7881 | }; | ||
7882 | var $author$project$Product$AddRatingComment = function (a) { | ||
7883 | return {$: 'AddRatingComment', a: a}; | ||
7884 | }; | ||
7885 | var $author$project$Product$AddRatingPressed = {$: 'AddRatingPressed'}; | ||
7886 | var $author$project$Product$AddToCartPressed = {$: 'AddToCartPressed'}; | ||
7887 | var $author$project$Product$viewInput = F4( | ||
7888 | function (t, p, v, toMsg) { | ||
7889 | return A2( | ||
7890 | $elm$html$Html$input, | ||
7891 | _List_fromArray( | ||
7892 | [ | ||
7893 | $elm$html$Html$Attributes$type_(t), | ||
7894 | $elm$html$Html$Attributes$placeholder(p), | ||
7895 | $elm$html$Html$Attributes$value(v), | ||
7896 | $elm$html$Html$Events$onInput(toMsg) | ||
7897 | ]), | ||
7898 | _List_Nil); | ||
7899 | }); | ||
7900 | var $author$project$Product$viewProduct = function (p) { | ||
7901 | return A2( | ||
7902 | $elm$html$Html$div, | ||
7903 | _List_Nil, | ||
7904 | _List_fromArray( | ||
7905 | [ | ||
7906 | $elm$html$Html$text(p.name), | ||
7907 | $elm$html$Html$text( | ||
7908 | A2($elm$core$Maybe$withDefault, '', p.kind)), | ||
7909 | $elm$html$Html$text( | ||
7910 | A2($elm$core$Maybe$withDefault, '', p.description)), | ||
7911 | $elm$html$Html$text( | ||
7912 | $elm$core$String$fromFloat(p.price)) | ||
7913 | ])); | ||
7914 | }; | ||
7915 | var $author$project$Product$viewRating = function (r) { | ||
7916 | return A2( | ||
7917 | $elm$html$Html$div, | ||
7918 | _List_Nil, | ||
7919 | _List_fromArray( | ||
7920 | [ | ||
7921 | $elm$html$Html$text(r.customerName + ' posted on '), | ||
7922 | $elm$html$Html$text(r.commentDate + ' '), | ||
7923 | $elm$html$Html$text( | ||
7924 | A2($elm$core$Maybe$withDefault, '', r.commentText)), | ||
7925 | $elm$html$Html$text( | ||
7926 | ' Stars: ' + $elm$core$String$fromInt(r.stars)) | ||
7927 | ])); | ||
7928 | }; | ||
7929 | var $author$project$Product$AddRatingStars = function (a) { | ||
7930 | return {$: 'AddRatingStars', a: a}; | ||
7931 | }; | ||
7932 | var $author$project$Product$viewStars = A2( | ||
7933 | $elm$html$Html$ul, | ||
7934 | _List_Nil, | ||
7935 | A2( | ||
7936 | $elm$core$List$map, | ||
7937 | function (i) { | ||
7938 | return A2( | ||
7939 | $elm$html$Html$button, | ||
7940 | _List_fromArray( | ||
7941 | [ | ||
7942 | $elm$html$Html$Events$onClick( | ||
7943 | $author$project$Product$AddRatingStars(i)) | ||
7944 | ]), | ||
7945 | _List_fromArray( | ||
7946 | [ | ||
7947 | $elm$html$Html$text( | ||
7948 | $elm$core$String$fromInt(i)) | ||
7949 | ])); | ||
7950 | }, | ||
7951 | _List_fromArray( | ||
7952 | [0, 1, 2, 3, 4, 5]))); | ||
7953 | var $author$project$Product$viewStatus = function (s) { | ||
7954 | switch (s.$) { | ||
7955 | case 'Loading': | ||
7956 | return 'Loading'; | ||
7957 | case 'Loaded': | ||
7958 | return 'Ready!'; | ||
7959 | default: | ||
7960 | return 'Not loaded ...'; | ||
7961 | } | ||
7962 | }; | ||
7963 | var $author$project$Product$view = function (model) { | ||
7964 | var _v0 = model.pageStatus; | ||
7965 | if (_v0.$ === 'Loading') { | ||
7966 | return A2( | ||
7967 | $elm$html$Html$div, | ||
7968 | _List_Nil, | ||
7969 | _List_fromArray( | ||
7970 | [ | ||
7971 | $elm$html$Html$text( | ||
7972 | $author$project$Product$viewStatus($author$project$Product$Loading)) | ||
7973 | ])); | ||
7974 | } else { | ||
7975 | return A2( | ||
7976 | $elm$html$Html$div, | ||
7977 | _List_Nil, | ||
7978 | _List_fromArray( | ||
7979 | [ | ||
7980 | A2( | ||
7981 | $elm$html$Html$div, | ||
7982 | _List_Nil, | ||
7983 | _List_fromArray( | ||
7984 | [ | ||
7985 | $author$project$Product$viewProduct(model.listing) | ||
7986 | ])), | ||
7987 | A2( | ||
7988 | $elm$html$Html$ul, | ||
7989 | _List_Nil, | ||
7990 | A2($elm$core$List$map, $author$project$Product$viewRating, model.ratings)), | ||
7991 | A2( | ||
7992 | $elm$html$Html$div, | ||
7993 | _List_Nil, | ||
7994 | _List_fromArray( | ||
7995 | [ | ||
7996 | $elm$html$Html$text('Add Rating: ') | ||
7997 | ])), | ||
7998 | A2( | ||
7999 | $elm$html$Html$div, | ||
8000 | _List_Nil, | ||
8001 | _List_fromArray( | ||
8002 | [ | ||
8003 | $author$project$Product$viewStars, | ||
8004 | A4($author$project$Product$viewInput, 'text', 'Enter Comment Text', model.ratingText, $author$project$Product$AddRatingComment), | ||
8005 | A2( | ||
8006 | $elm$html$Html$button, | ||
8007 | _List_fromArray( | ||
8008 | [ | ||
8009 | $elm$html$Html$Events$onClick($author$project$Product$AddRatingPressed) | ||
8010 | ]), | ||
8011 | _List_fromArray( | ||
8012 | [ | ||
8013 | $elm$html$Html$text('Submit Rating') | ||
8014 | ])) | ||
8015 | ])), | ||
8016 | A2( | ||
8017 | $elm$html$Html$div, | ||
8018 | _List_Nil, | ||
8019 | _List_fromArray( | ||
8020 | [ | ||
8021 | A2( | ||
8022 | $elm$html$Html$button, | ||
8023 | _List_fromArray( | ||
8024 | [ | ||
8025 | $elm$html$Html$Events$onClick($author$project$Product$AddToCartPressed) | ||
8026 | ]), | ||
8027 | _List_fromArray( | ||
8028 | [ | ||
8029 | $elm$html$Html$text('Add To Cart') | ||
8030 | ])) | ||
8031 | ])), | ||
8032 | A2( | ||
8033 | $elm$html$Html$div, | ||
8034 | _List_Nil, | ||
8035 | _List_fromArray( | ||
8036 | [ | ||
8037 | A2( | ||
8038 | $elm$html$Html$a, | ||
8039 | _List_fromArray( | ||
8040 | [ | ||
8041 | $elm$html$Html$Attributes$href('/catalog') | ||
8042 | ]), | ||
8043 | _List_fromArray( | ||
8044 | [ | ||
8045 | $elm$html$Html$text('Back to catalog') | ||
8046 | ])) | ||
8047 | ])) | ||
8048 | ])); | ||
8049 | } | ||
8050 | }; | ||
8051 | var $author$project$Signup$AddressEntered = function (a) { | ||
8052 | return {$: 'AddressEntered', a: a}; | ||
8053 | }; | ||
8054 | var $author$project$Signup$CreatePressed = {$: 'CreatePressed'}; | ||
8055 | var $author$project$Signup$EmailEntered = function (a) { | ||
8056 | return {$: 'EmailEntered', a: a}; | ||
8057 | }; | ||
8058 | var $author$project$Signup$PassEntered = function (a) { | ||
8059 | return {$: 'PassEntered', a: a}; | ||
8060 | }; | ||
8061 | var $author$project$Signup$PhoneEntered = function (a) { | ||
8062 | return {$: 'PhoneEntered', a: a}; | ||
8063 | }; | ||
8064 | var $author$project$Signup$UserEntered = function (a) { | ||
8065 | return {$: 'UserEntered', a: a}; | ||
8066 | }; | ||
8067 | var $author$project$Signup$viewInput = F4( | ||
8068 | function (t, p, v, toMsg) { | ||
8069 | return A2( | ||
8070 | $elm$html$Html$input, | ||
8071 | _List_fromArray( | ||
8072 | [ | ||
8073 | $elm$html$Html$Attributes$type_(t), | ||
8074 | $elm$html$Html$Attributes$placeholder(p), | ||
8075 | $elm$html$Html$Attributes$value(v), | ||
8076 | $elm$html$Html$Events$onInput(toMsg) | ||
8077 | ]), | ||
8078 | _List_Nil); | ||
8079 | }); | ||
8080 | var $author$project$Signup$viewStatus = function (s) { | ||
8081 | switch (s.$) { | ||
8082 | case 'UsernameTaken': | ||
8083 | return 'This username is taken!'; | ||
8084 | case 'InvalidPhone': | ||
8085 | return 'Invalid phone number!'; | ||
8086 | case 'InvalidEmail': | ||
8087 | return 'Invalid email address!'; | ||
8088 | case 'CreatedSuccessfully': | ||
8089 | return 'User created successfully'; | ||
8090 | case 'CreatingUser': | ||
8091 | return 'Creating user ...'; | ||
8092 | default: | ||
8093 | return ''; | ||
8094 | } | ||
8095 | }; | ||
8096 | var $author$project$Signup$view = function (model) { | ||
8097 | return A2( | ||
8098 | $elm$html$Html$div, | ||
8099 | _List_Nil, | ||
8100 | _List_fromArray( | ||
8101 | [ | ||
8102 | A2( | ||
8103 | $elm$html$Html$div, | ||
8104 | _List_Nil, | ||
8105 | _List_fromArray( | ||
8106 | [ | ||
8107 | A4($author$project$Signup$viewInput, 'text', 'Enter Username', model.username, $author$project$Signup$UserEntered) | ||
8108 | ])), | ||
8109 | A2( | ||
8110 | $elm$html$Html$div, | ||
8111 | _List_Nil, | ||
8112 | _List_fromArray( | ||
8113 | [ | ||
8114 | A4($author$project$Signup$viewInput, 'password', 'Password', model.password, $author$project$Signup$PassEntered) | ||
8115 | ])), | ||
8116 | A2( | ||
8117 | $elm$html$Html$div, | ||
8118 | _List_Nil, | ||
8119 | _List_fromArray( | ||
8120 | [ | ||
8121 | A4($author$project$Signup$viewInput, 'text', 'Email', model.emailId, $author$project$Signup$EmailEntered) | ||
8122 | ])), | ||
8123 | A2( | ||
8124 | $elm$html$Html$div, | ||
8125 | _List_Nil, | ||
8126 | _List_fromArray( | ||
8127 | [ | ||
8128 | A4($author$project$Signup$viewInput, 'text', 'Enter your Phone number', model.phoneNumber, $author$project$Signup$PhoneEntered) | ||
8129 | ])), | ||
8130 | A2( | ||
8131 | $elm$html$Html$div, | ||
8132 | _List_Nil, | ||
8133 | _List_fromArray( | ||
8134 | [ | ||
8135 | A4( | ||
8136 | $author$project$Signup$viewInput, | ||
8137 | 'text', | ||
8138 | 'Enter Shipping address', | ||
8139 | A2($elm$core$Maybe$withDefault, '', model.address), | ||
8140 | $author$project$Signup$AddressEntered) | ||
8141 | ])), | ||
8142 | A2( | ||
8143 | $elm$html$Html$div, | ||
8144 | _List_Nil, | ||
8145 | _List_fromArray( | ||
8146 | [ | ||
8147 | A2( | ||
8148 | $elm$html$Html$button, | ||
8149 | _List_fromArray( | ||
8150 | [ | ||
8151 | $elm$html$Html$Events$onClick($author$project$Signup$CreatePressed) | ||
8152 | ]), | ||
8153 | _List_fromArray( | ||
8154 | [ | ||
8155 | $elm$html$Html$text('Create') | ||
8156 | ])) | ||
8157 | ])), | ||
8158 | A2( | ||
8159 | $elm$html$Html$div, | ||
8160 | _List_Nil, | ||
8161 | _List_fromArray( | ||
8162 | [ | ||
8163 | $elm$html$Html$text('Already have a account? '), | ||
8164 | A2( | ||
8165 | $elm$html$Html$a, | ||
8166 | _List_fromArray( | ||
8167 | [ | ||
8168 | $elm$html$Html$Attributes$href('/login') | ||
8169 | ]), | ||
8170 | _List_fromArray( | ||
8171 | [ | ||
8172 | $elm$html$Html$text('Login >') | ||
8173 | ])) | ||
8174 | ])), | ||
8175 | $elm$html$Html$text( | ||
8176 | $author$project$Signup$viewStatus(model.status)) | ||
8177 | ])); | ||
8178 | }; | ||
8179 | var $author$project$Main$viewLink = function (path) { | ||
8180 | return A2( | ||
8181 | $elm$html$Html$li, | ||
8182 | _List_Nil, | ||
8183 | _List_fromArray( | ||
8184 | [ | ||
8185 | A2( | ||
8186 | $elm$html$Html$a, | ||
8187 | _List_fromArray( | ||
8188 | [ | ||
8189 | $elm$html$Html$Attributes$href(path) | ||
8190 | ]), | ||
8191 | _List_fromArray( | ||
8192 | [ | ||
8193 | $elm$html$Html$text(path) | ||
8194 | ])) | ||
8195 | ])); | ||
8196 | }; | ||
8197 | var $author$project$Main$view = function (model) { | ||
8198 | var _v0 = model.location; | ||
8199 | switch (_v0.$) { | ||
8200 | case 'LoginPage': | ||
8201 | return { | ||
8202 | body: _List_fromArray( | ||
8203 | [ | ||
8204 | A2( | ||
8205 | $elm$html$Html$map, | ||
8206 | $author$project$Main$LoginMessage, | ||
8207 | $author$project$Login$view(model.loginModel)) | ||
8208 | ]), | ||
8209 | title: 'Login' | ||
8210 | }; | ||
8211 | case 'SignupPage': | ||
8212 | return { | ||
8213 | body: _List_fromArray( | ||
8214 | [ | ||
8215 | A2( | ||
8216 | $elm$html$Html$map, | ||
8217 | $author$project$Main$SignupMessage, | ||
8218 | $author$project$Signup$view(model.signupModel)) | ||
8219 | ]), | ||
8220 | title: 'Signup' | ||
8221 | }; | ||
8222 | case 'HomePage': | ||
8223 | return { | ||
8224 | body: _List_fromArray( | ||
8225 | [ | ||
8226 | $elm$html$Html$text('The current URL is: '), | ||
8227 | A2( | ||
8228 | $elm$html$Html$b, | ||
8229 | _List_Nil, | ||
8230 | _List_fromArray( | ||
8231 | [ | ||
8232 | $elm$html$Html$text( | ||
8233 | $elm$url$Url$toString(model.url)) | ||
8234 | ])), | ||
8235 | A2( | ||
8236 | $elm$html$Html$ul, | ||
8237 | _List_Nil, | ||
8238 | _List_fromArray( | ||
8239 | [ | ||
8240 | $author$project$Main$viewLink('/login'), | ||
8241 | $author$project$Main$viewLink('/catalog'), | ||
8242 | $author$project$Main$viewLink('/cart'), | ||
8243 | $author$project$Main$viewLink('/signup') | ||
8244 | ])) | ||
8245 | ]), | ||
8246 | title: 'URL Interceptor' | ||
8247 | }; | ||
8248 | case 'NotFoundPage': | ||
8249 | return { | ||
8250 | body: _List_fromArray( | ||
8251 | [ | ||
8252 | $elm$html$Html$text('404 - Not Found'), | ||
8253 | A2( | ||
8254 | $elm$html$Html$a, | ||
8255 | _List_fromArray( | ||
8256 | [ | ||
8257 | $elm$html$Html$Attributes$href('/') | ||
8258 | ]), | ||
8259 | _List_fromArray( | ||
8260 | [ | ||
8261 | $elm$html$Html$text('Go back >') | ||
8262 | ])) | ||
8263 | ]), | ||
8264 | title: '404 - Not Found' | ||
8265 | }; | ||
8266 | case 'CatalogPage': | ||
8267 | return { | ||
8268 | body: A2( | ||
8269 | $author$project$Main$pageWrap, | ||
8270 | model, | ||
8271 | A2( | ||
8272 | $elm$html$Html$map, | ||
8273 | $author$project$Main$CatalogMessage, | ||
8274 | $author$project$Catalog$view(model.catalogModel))), | ||
8275 | title: 'Catalog' | ||
8276 | }; | ||
8277 | case 'CartPage': | ||
8278 | return { | ||
8279 | body: A2( | ||
8280 | $author$project$Main$pageWrap, | ||
8281 | model, | ||
8282 | A2( | ||
8283 | $elm$html$Html$map, | ||
8284 | $author$project$Main$CartMessage, | ||
8285 | $author$project$Cart$view(model.cartModel))), | ||
8286 | title: 'Cart' | ||
8287 | }; | ||
8288 | default: | ||
8289 | var item = _v0.a; | ||
8290 | return { | ||
8291 | body: A2( | ||
8292 | $author$project$Main$pageWrap, | ||
8293 | model, | ||
8294 | A2( | ||
8295 | $elm$html$Html$map, | ||
8296 | $author$project$Main$ProductMessage, | ||
8297 | $author$project$Product$view(model.productModel))), | ||
8298 | title: 'Product ' + $elm$core$String$fromInt(item) | ||
8299 | }; | ||
8300 | } | ||
8301 | }; | ||
8302 | var $author$project$Main$main = $elm$browser$Browser$application( | ||
8303 | {init: $author$project$Main$init, onUrlChange: $author$project$Main$UrlChanged, onUrlRequest: $author$project$Main$LinkClicked, subscriptions: $author$project$Main$subscriptions, update: $author$project$Main$update, view: $author$project$Main$view}); | ||
8304 | _Platform_export({'Main':{'init':$author$project$Main$main( | ||
8305 | $elm$json$Json$Decode$succeed(_Utils_Tuple0))(0)}});}(this)); \ No newline at end of file | ||
diff --git a/frontend/src/Signup.elm b/frontend/src/Signup.elm index 6395b57..30794e7 100644 --- a/frontend/src/Signup.elm +++ b/frontend/src/Signup.elm | |||
@@ -184,11 +184,15 @@ viewInput t p v toMsg = | |||
184 | view : Model -> Html Msg | 184 | view : Model -> Html Msg |
185 | view model = | 185 | view model = |
186 | div [] | 186 | div [] |
187 | [ viewInput "text" "Enter Username" model.username UserEntered | 187 | [ div [] [ viewInput "text" "Enter Username" model.username UserEntered ] |
188 | , viewInput "password" "Password" model.password PassEntered | 188 | , div [] [ viewInput "password" "Password" model.password PassEntered ] |
189 | , viewInput "text" "Email" model.emailId EmailEntered | 189 | , div [] [ viewInput "text" "Email" model.emailId EmailEntered ] |
190 | , viewInput "text" "Enter your Phone number" model.phoneNumber PhoneEntered | 190 | , div [] [ viewInput "text" "Enter your Phone number" model.phoneNumber PhoneEntered ] |
191 | , viewInput "text" "Enter Shipping address" (Maybe.withDefault "" model.address) AddressEntered | 191 | , div [] [ viewInput "text" "Enter Shipping address" (Maybe.withDefault "" model.address) AddressEntered ] |
192 | , button [ onClick CreatePressed ] [ text "Create" ] | 192 | , div [] [ button [ onClick CreatePressed ] [ text "Create" ] ] |
193 | , div [] | ||
194 | [ text "Already have a account? " | ||
195 | , a [ href "/login" ] [ text "Login >" ] | ||
196 | ] | ||
193 | , text (viewStatus model.status) | 197 | , text (viewStatus model.status) |
194 | ] | 198 | ] |